Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an option of larpix fee config as a constant in yaml #141

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions src/proto_nd_flow/reco/charge/calib_prompt_hits.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ def __init__(self, **params):
self.t0_dset_name = params.get('t0_dset_name')
self.pedestal_file = params.get('pedestal_file', '')
self.configuration_file = params.get('configuration_file', '')
self.pedestal_mv = params.get('pdestal_mv', 580.0)
self.vref_mv = params.get('vref_mv', 1568.0)
self.vcm_mv = params.get('vcm_mv', 478.1)
self.adc_counts = params.get('adc_counts', 256)
self.gain = params.get('gain', 4.522)

def init(self, source_name):
super(CalibHitBuilder, self).init(source_name)
Expand Down Expand Up @@ -211,12 +216,19 @@ def run(self, source_name, source_slice, cache):
+ packets_arr['chip_id'].astype(int)) * 64 \
+ packets_arr['channel_id'].astype(int)
hit_uniqueid_str = hit_uniqueid.astype(str)
vref = np.array(
[self.configuration[unique_id]['vref_mv'] for unique_id in hit_uniqueid_str])
vcm = np.array([self.configuration[unique_id]['vcm_mv']
for unique_id in hit_uniqueid_str])
ped = np.array([self.pedestal[unique_id]['pedestal_mv']
for unique_id in hit_uniqueid_str])
if self.configuration_file != '':
vref = np.array(
[self.configuration[unique_id]['vref_mv'] for unique_id in hit_uniqueid_str])
vcm = np.array([self.configuration[unique_id]['vcm_mv']
for unique_id in hit_uniqueid_str])
else:
vref = np.full(len(hit_uniqueid_str), self.vref_mv)
vcm = np.full(len(hit_uniqueid_str), self.vcm_mv)
if self.pedestal_file != '':
ped = np.array([self.pedestal[unique_id]['pedestal_mv']
for unique_id in hit_uniqueid_str])
else:
ped = np.full(len(hit_uniqueid_str), self.pedestal_mv)
calib_hits_arr['id'] = calib_hits_slice.start + np.arange(n, dtype=int)
calib_hits_arr['x'] = x
if has_mc_truth:
Expand All @@ -227,7 +239,7 @@ def run(self, source_name, source_slice, cache):
calib_hits_arr['t_drift'] = drift_t
calib_hits_arr['io_group'] = packets_arr['io_group']
calib_hits_arr['io_channel'] = packets_arr['io_channel']
hits_charge = self.charge_from_dataword(packets_arr['dataword'],vref,vcm,ped) # ke-
hits_charge = self.charge_from_dataword(packets_arr['dataword'], vref, vcm, ped, self.adc_counts, self.gain) # ke-
calib_hits_arr['Q'] = hits_charge # ke-
#FIXME supply more realistic dEdx in the recombination; also apply measured electron lifetime
calib_hits_arr['E'] = hits_charge * (1000 * units.e) / resources['LArData'].ionization_recombination(mode=2,dEdx=2) * (resources['LArData'].ionization_w / units.MeV) # MeV
Expand Down Expand Up @@ -266,8 +278,8 @@ def run(self, source_name, source_slice, cache):


@staticmethod
def charge_from_dataword(dw, vref, vcm, ped):
return (dw / 256. * (vref - vcm) + vcm - ped) / 4. # hardcoding 4 mV/ke- conv.
def charge_from_dataword(dw, vref, vcm, ped, adc_counts, gain):
return (dw / adc_counts * (vref - vcm) + vcm - ped) / gain

def load_pedestals(self):
if self.pedestal_file != '' and not resources['RunData'].is_mc:
Expand Down
6 changes: 6 additions & 0 deletions yamls/proto_nd_flow/reco/charge/CalibHitBuilder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ params:
# download link: https://portal.nersc.gov/project/dune/data/Module0/TPC1+2/configFiles/datalog_2021_04_02_19_00_46_CESTevd_ped.json
#configuration_file: 'data/module0_flow/evd_config_21-03-31_12-36-13.json'
# download link: https://portal.nersc.gov/project/dune/data/Module0/TPC1+2/configFiles/evd_config_21-03-31_12-36-13.json

pedestal_mv: 580.0
vref_mv: 1568.0 #M0-like: 1300 #2x2: 1568.0
vcm_mv: 478.1 #M0-like:288 #478.0 #2x2: 478.1
adc_counts: 256
gain: 4.522 #datasheet: 4 #measurement(?): 4.522
Loading