Skip to content

Commit

Permalink
Merge pull request #141 from DUNE/feature_config
Browse files Browse the repository at this point in the history
add an option of larpix fee config as a constant in yaml
  • Loading branch information
YifanC authored Oct 15, 2024
2 parents 4b1b75f + bbff220 commit f3cb8d7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
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

0 comments on commit f3cb8d7

Please sign in to comment.