-
Notifications
You must be signed in to change notification settings - Fork 29
Add pedestal variations for FSD #299
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me. I also updated the voltages in fsd.yaml to match what is used in flow after conferring with Jaafar. With these changes larnd-sim still runs fine for me.
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