Conversation
|
I also did a check with the flow outputs. I flowed a file with the new pedestals. With the output, I looped over each hit and manually calculate what Q should be given the adc value and the pedestal from the pedestal file. I check that this calculated Q matches with the output from flow. with open('/global/common/software/dune/inputs/FSD/pedestals/FSD_pedestals_20241112.json', 'r') as f:
data = json.load(f)
def charge_from_dataword(dw, vref, vcm, ped, adc_counts, gain):
return (dw / adc_counts * (vref - vcm) + vcm - ped) / gain
mask = ~dm['charge/calib_prompt_hits/data']['is_disabled']
packets = dm['charge/calib_prompt_hits','/charge/packets'][['dataword', 'io_group', 'io_channel', 'chip_id', 'channel_id']][:,0][mask]
hits = dm['charge/calib_prompt_hits/data'][mask]
diff = list()
notfound = list()
n_notfound = 0
unique_ids = list()
for (hit, packet) in zip(hits, packets):
(adc, io_group, io_channel, chip_id, channel_id) = packet[['dataword', 'io_group', 'io_channel', 'chip_id', 'channel_id']]
tile_id = 10*(io_group-1) + (io_channel-1)//4 +1
unique_id = (int(io_group)*1000_000_000
+ int(tile_id)*100_000
+ int(chip_id)*100
+ int(channel_id))
unique_ids.append(unique_id)
try:
ped = data[str(unique_id)]['pedestal_mv']
except KeyError:
ped= 580
n_notfound+=1
notfound.append(unique_id)
charge = charge_from_dataword(dw = adc, vref = 1568., vcm=478.1, ped = ped, adc_counts=256, gain=4.522)
if charge - hit['Q'] != 0:
print((io_group, io_channel, chip_id, channel_id))
print(tile_id)
print(i, unique_id, charge, hit['Q'])
raise ValueError("fuck")
diff.append(charge - hit['Q'])
print("Number of hits: {}".format(len(packets)))
print("Number of unique ids: {}".format(np.unique(np.array(unique_ids)).shape))
print("Number of hits without corresponding id in pedestal file: {}".format(n_notfound))
print("Number of unique ids without corresponding id in pedestal file: {}".format(np.unique(np.array(notfound)).shape))
print("Are valid hits all consistent?", np.all(np.array(diff) == 0.)) |
|
Note @cuddandr, I think the gains used in larndsim are currently different than the gains in flow. |
Where are those even defined in flow? @jaafar-chakrani updated the FSD gain in larnd-sim so I can see them being different from flow right now. |
|
@cuddandr |
|
Of course not. But the voltage values in flow are more recent than the ones in larnd-sim, which are the original values when that file was first made. So I'd be inclined to copy the values from |
Based on the numbers used in flow in CalibHitBuilderData.yaml
This PR adds pedestal variations for FSD.
To test the pedestal implementation, I take the difference of the ADC values for each hit with and without pedestal variation. Given this equation, that value should be consistent with (pedestal_from_file - 580.)*256/(v_ref-v_cm). Where pedestal_from_file is the pedestal extracted from the inputted pedestal file for that given pixel, and 580 is the default pedestal voltage. Below is the code used, and the outputs