Created
September 4, 2023 19:42
-
-
Save veprbl/2640d540a9da1b471322f583399d68ae to your computer and use it in GitHub Desktop.
Read EICrecon exported parameters JSON and calculate effective thresholds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
expected_threshold = { | |
"HcalBarrelRawHits": 5000, # cHCAL (per layer) Barrel 7680 (scint tiles) 5 MeV (deposited in scintillator) | |
"EcalEndcapPInsertRawHits": "???", | |
"HcalEndcapPInsertRawHits": 250, # fHCAL insert Forward 9000 250 keV (0.5 MIP, with 1 MIP MPV=15 p.e at +2V and 1e5 gain) | |
"EcalBarrelImagingRawHits": 15, # AstroPix Barrel 510M pixels (3.54E+05 chips) 15 keV | |
"EcalEndcapNRawHits": 5000, # EEMC Backward 3000 5000 keV | |
"HcalEndcapNRawHits": 170, # bHCAL (per layer) Backward 10350 3 p.e./170 keV | |
"EcalBarrelScFiRawHits": 500, # ScifiPb Barrel 3360 500 keV per readout unit (not fiber) | |
"ZDCEcalRawHits": "???", | |
"B0ECalRawHits": 1000, # B0 PbWO4 Far Forward 105 1 MeV | |
"LFHCALRawHits": 5000, # fHCAL (per unit) Forward 63280 5000 keV | |
"EcalLumiSpecRawHits": "???", | |
"EcalEndcapPRawHits": 15000, # FEMC Forward 19000 15 MeV | |
} | |
with open("2023-09-03T17-26-13_fc444ef56747675141d7e6e04698914ba07129b4/pi_craterlake_flags.json", "rt") as fp: | |
params = json.load(fp) | |
factories = set( | |
tuple(key.split(":")[:2]) for key, value, default, _help in params | |
if key.find("RawHits:dynamicRangeADC") != -1 | |
) | |
defaults = {key: default for key, value, default, _help in params} | |
print("| " + "\t| ".join([ | |
"Detector", | |
f"Threshold [ADC]", | |
f"Gain [keV / ADC]", | |
f"Scale factor", | |
f"Threshold [keV]", | |
f"Spreadsheet [keV]"] | |
) + "\t|") | |
print("-".join(["|"] * 7)) | |
for plugin, digi_factory in factories: | |
reco_factory = digi_factory.replace("RawHits", "RecHits") | |
capacity_adc = float(defaults[f"{plugin}:{digi_factory}:capacityADC"]) | |
dynamic_range_adc = float(defaults[f"{plugin}:{digi_factory}:dynamicRangeADC"]) | |
scale_response = float(defaults[f"{plugin}:{digi_factory}:scaleResponse"]) | |
pedestal_sigma = float(defaults[f"{plugin}:{digi_factory}:pedestalSigma"]) | |
assert capacity_adc == float(defaults[f"{plugin}:{reco_factory}:capacityADC"]) | |
assert dynamic_range_adc == float(defaults[f"{plugin}:{reco_factory}:dynamicRangeADC"]) | |
assert pedestal_sigma == float(defaults[f"{plugin}:{reco_factory}:pedestalSigma"]) | |
threshold_value = float(defaults[f"{plugin}:{reco_factory}:thresholdValue"]) | |
threshold_factor = float(defaults[f"{plugin}:{reco_factory}:thresholdFactor"]) | |
threshold_adc = threshold_value + pedestal_sigma * threshold_factor | |
gain = scale_response * dynamic_range_adc / capacity_adc | |
print("| " + "\t| ".join([ | |
digi_factory.replace("RawHits", ""), | |
f"{threshold_adc:.3f} [ADC]", | |
f"{gain * 1e6:.1e} [keV / ADC]", | |
f"{scale_response:.1e}", | |
f"{threshold_adc * gain * 1e6:.1f} [keV]", | |
f"{expected_threshold.get(digi_factory, 'undef')} [keV]"] | |
) + "\t|") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment