-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
While using the RelationCaloHit (podio::Link<edm4hep::CalorimeterHit,edm4hep::SimCalorimeterHit>), I noticed that sometimes a reconstructed calorimeter hit and the associated simulated hit have a different cell ID. I'd not expect hits from different cells to be associated, is this expected?
example (from_elem and to_elem are the cell IDs of the hits):
ev=1, from ECALBarrel, to ECalBarrelCollection, FromIndex=6155, ToIndex=6870, from_elem=22518247251248276, to_elem=18361738493319709588
ev=1, from ECALBarrel, to ECalBarrelCollection, FromIndex=6156, ToIndex=3238, from_elem=18423100386128167828, to_elem=22518247251248276
ev=1, from ECALBarrel, to ECalBarrelCollection, FromIndex=6157, ToIndex=2319, from_elem=34058304684557332, to_elem=18422255948316279700
Steps I followed:
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
git clone --recurse-submodules https://github.com/key4hep/k4Clue.git
git clone https://github.com/iLCSoft/CLICPerformance
cd CLICPerformance/clicConfig
ddsim --steeringFile clic_steer.py --compactFile $LCGEO/CLIC/compact/CLIC_o3_v14/CLIC_o3_v14.xml --enableGun --gun.distribution uniform --gun.particle gamma --gun.energy "50*GeV" --gun.multiplicity 10 --outputFile 10gamma_50GeV.root --numberOfEvents 10
cp ../../k4Clue/gaudi_opts/clicRec_e4h_input_gun.py .
k4run clicRec_e4h_input_gun.py --EventDataSvc.input 10gamma_50GeV.root
I then opened the file my_ouput.root with Python:
import uproot as uproot
# use this to load the tree if some of file.keys() are duplicates ending with different numbers
def load_branch_with_highest_cycle(file_path, branch_name):
file = uproot.open(file_path)
all_keys = file.keys()
matching_keys = [key for key in all_keys if key.startswith(branch_name)]
if not matching_keys:
raise ValueError(f"No branch with name '{branch_name}' found in the file.")
highest_cycle_key = max(matching_keys, key=lambda key: int(key.split(";")[1]))
branch = file[highest_cycle_key]
return branch
#load file
filename = '/eos/user/a/aperego/fcc/CLICPerformance/clicConfig/my_output.root'
events = load_branch_with_highest_cycle(filename, "events")
# load links
links = events.arrays(['RelationCaloHit/RelationCaloHit.weight', '_RelationCaloHit_from/_RelationCaloHit_from.index', '_RelationCaloHit_from/_RelationCaloHit_from.collectionID',
'_RelationCaloHit_to/_RelationCaloHit_to.index', '_RelationCaloHit_to/_RelationCaloHit_to.collectionID'])
linkWeight = links['RelationCaloHit/RelationCaloHit.weight']
linkFromIndex = links['_RelationCaloHit_from/_RelationCaloHit_from.index']
linkFromID = links['_RelationCaloHit_from/_RelationCaloHit_from.collectionID']
linkToIndex = links['_RelationCaloHit_to/_RelationCaloHit_to.index']
linkToID = links['_RelationCaloHit_to/_RelationCaloHit_to.collectionID']
# load ECAL / HCAL collections
collections = events.arrays(['ECalPlugCollection/ECalPlugCollection.cellID', 'ECALOther/ECALOther.cellID', 'ECALBarrel/ECALBarrel.cellID', 'ECALEndcap/ECALEndcap.cellID',
'ECalBarrelCollection/ECalBarrelCollection.cellID', 'ECalEndcapCollection/ECalEndcapCollection.cellID',
'_ECalEndcapCollection_contributions/_ECalEndcapCollection_contributions.collectionID',
'HCALBarrel/HCALBarrel.cellID', 'HCalBarrelCollection/HCalBarrelCollection.cellID', 'HCALEndcap/HCALEndcap.cellID',
'HCalEndcapCollection/HCalEndcapCollection.cellID', 'HCALOther/HCALOther.cellID', 'HCalRingCollection/HCalRingCollection.cellID'])
simBarrel = collections['ECALBarrel/ECALBarrel.cellID']
simEndcap = collections['ECALEndcap/ECALEndcap.cellID']
recBarrel = collections['ECalBarrelCollection/ECalBarrelCollection.cellID']
recEndcap = collections['ECalEndcapCollection/ECalEndcapCollection.cellID']
ecalOther = collections['ECALOther/ECALOther.cellID']
ecalPlug = collections['ECalPlugCollection/ECalPlugCollection.cellID']
simHCALBarrel = collections['HCALBarrel/HCALBarrel.cellID']
recHCalBarrel = collections['HCalBarrelCollection/HCalBarrelCollection.cellID']
simHCALEndcap = collections['HCALEndcap/HCALEndcap.cellID']
recHCalEndcap = collections['HCalEndcapCollection/HCalEndcapCollection.cellID']
HCALOther = collections['HCALOther/HCALOther.cellID']
HCalRing = collections['HCalRingCollection/HCalRingCollection.cellID']
# map taken with the podio-dump on the input file, the collection hashes may change with a different file
collection_hashes = {
"0x4b6bf95c": simBarrel, #"ECALBarrel",
"0x407eb17b": recBarrel, #"ECalBarrelCollection",
"0x868b64f8": simEndcap, #"ECALEndcap",
"0xc09a156": recEndcap, #"ECalEndcapCollection",
"0x1cbea96": ecalOther, #"ECALOther",
"0xd36e0cf8": ecalPlug, #"ECalPlugCollection",
"0x76db0c4": simHCALBarrel, #"HCALBarrel",
"0x6daf3b41": recHCalBarrel, #"HCalBarrelCollection",
"0x4ca8cf89": simHCALEndcap, #"HCALEndcap",
"0x50d90aed": recHCalEndcap, #"HCalEndcapCollection",
"0x3ba1679d": HCALOther, #"HCALOther",
"0xad7abfca": HCalRing, #"HCalRingCollection",
}
collection_names = {
"0x4b6bf95c": "ECALBarrel",
"0x407eb17b": "ECalBarrelCollection",
"0x868b64f8": "ECALEndcap",
"0xc09a156": "ECalEndcapCollection",
"0x1cbea96": "ECALOther",
"0xd36e0cf8": "ECalPlugCollection",
"0x76db0c4": "HCALBarrel",
"0x6daf3b41": "HCalBarrelCollection",
"0x4ca8cf89": "HCALEndcap",
"0x50d90aed": "HCalEndcapCollection",
"0x3ba1679d": "HCALOther",
"0xad7abfca": "HCalRingCollection",
}
# comparison
for ev in range(len(simBarrel)):
linkFromID_ev = linkFromID[ev]
linkFromIndex_ev = linkFromIndex[ev]
linkToID_ev = linkToID[ev]
linkToIndex_ev = linkToIndex[ev]
for FromID, FromIndex, ToID, ToIndex in zip(linkFromID_ev, linkFromIndex_ev, linkToID_ev, linkToIndex_ev):
from_elem = collection_hashes[hex(FromID)][ev][FromIndex]
to_elem = collection_hashes[hex(ToID)][ev][ToIndex]
if not (from_elem == to_elem):
print(f"{ev=}, from {collection_names[hex(FromID)]}, to {collection_names[hex(ToID)]}, {FromIndex=}, {ToIndex=}, {from_elem=}, {to_elem=}")output:
ev=0, from ECALBarrel, to ECalBarrelCollection, FromIndex=7912, ToIndex=8290, from_elem=19140057907593236, to_elem=32087902547083284
ev=0, from ECALBarrel, to ECalBarrelCollection, FromIndex=7913, ToIndex=7569, from_elem=39125300942471444, to_elem=19140057907593236
ev=0, from ECALBarrel, to ECalBarrelCollection, FromIndex=7914, ToIndex=6507, from_elem=18418878059618238996, to_elem=39125300942471444
ev=0, from ECALBarrel, to ECalBarrelCollection, FromIndex=7915, ToIndex=5398, from_elem=68961261923075220, to_elem=18418878059618238996
ev=0, from ECALBarrel, to ECalBarrelCollection, FromIndex=7916, ToIndex=1257, from_elem=18359205437560062100, to_elem=68961261923075220
ev=0, from ECALEndcap, to ECalEndcapCollection, FromIndex=3623, ToIndex=4060, from_elem=18386227701044740157, to_elem=280680418771005
ev=0, from ECALEndcap, to ECalEndcapCollection, FromIndex=3624, ToIndex=2995, from_elem=18434358234149552189, to_elem=18386227701044740157
ev=0, from HCALBarrel, to HCalBarrelCollection, FromIndex=48, ToIndex=240, from_elem=7036930252865802, to_elem=4222094585888778
ev=0, from HCALBarrel, to HCalBarrelCollection, FromIndex=49, ToIndex=184, from_elem=7318405229576458, to_elem=7036930252865802
ev=0, from HCALBarrel, to HCalBarrelCollection, FromIndex=50, ToIndex=139, from_elem=18441959003400438282, to_elem=18441396049152573962
ev=0, from HCALBarrel, to HCalBarrelCollection, FromIndex=51, ToIndex=105, from_elem=18441396049152049674, to_elem=18441959003400438282
ev=1, from ECALBarrel, to ECalBarrelCollection, FromIndex=6155, ToIndex=6870, from_elem=22518247251248276, to_elem=18361738493319709588
ev=1, from ECALBarrel, to ECalBarrelCollection, FromIndex=6156, ToIndex=3238, from_elem=18423100386128167828, to_elem=22518247251248276
ev=1, from ECALBarrel, to ECalBarrelCollection, FromIndex=6157, ToIndex=2319, from_elem=34058304684557332, to_elem=18422255948316279700
ev=1, from ECALEndcap, to ECalEndcapCollection, FromIndex=4839, ToIndex=5438, from_elem=18441959570348703837, to_elem=18403396265873768509
ev=1, from ECALEndcap, to ECalEndcapCollection, FromIndex=4840, ToIndex=3544, from_elem=18416345394704285757, to_elem=18441959570348703837
ev=1, from ECALEndcap, to ECalEndcapCollection, FromIndex=4841, ToIndex=2333, from_elem=18415499814436339773, to_elem=18416345394704285757
ev=1, from HCALBarrel, to HCalBarrelCollection, FromIndex=42, ToIndex=198, from_elem=18442240517031854986, to_elem=6755438098383370
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=130, ToIndex=452, from_elem=18440833206572810283, to_elem=18441677425345560619
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=131, ToIndex=290, from_elem=18446181183886196811, to_elem=18445618246819774539
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=132, ToIndex=260, from_elem=18445055283979354187, to_elem=18446181183886196811
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=133, ToIndex=109, from_elem=18445899713204453451, to_elem=18445336780432474187
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=134, ToIndex=98, from_elem=18445618229638856779, to_elem=18445899713204453451
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=135, ToIndex=96, from_elem=18445336750367178827, to_elem=18445618229638856779
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=136, ToIndex=94, from_elem=18445336754661621835, to_elem=18445336750367178827
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=137, ToIndex=93, from_elem=18445899704614518859, to_elem=18445336754661621835
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=138, ToIndex=92, from_elem=18445618229638332491, to_elem=18445899704614518859
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=139, ToIndex=89, from_elem=18445336754662146123, to_elem=18445618229638332491
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=140, ToIndex=84, from_elem=18445618251112644683, to_elem=18445618242522710091
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=141, ToIndex=83, from_elem=18445055288273797195, to_elem=18445618251112644683
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=142, ToIndex=81, from_elem=18445336763252605003, to_elem=18445055288273797195
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=143, ToIndex=71, from_elem=18445618233932775499, to_elem=18445336763252605003
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=144, ToIndex=64, from_elem=18445899708909486155, to_elem=18445618233932775499
ev=1, from HCALEndcap, to HCalEndcapCollection, FromIndex=145, ToIndex=60, from_elem=18445899713206026315, to_elem=18445899708909486155
ev=2, from ECALEndcap, to ECalEndcapCollection, FromIndex=6476, ToIndex=7300, from_elem=5628868187127901, to_elem=2814268750692445
ev=2, from ECALEndcap, to ECalEndcapCollection, FromIndex=6477, ToIndex=6747, from_elem=5065918227939421, to_elem=4221476120559709
...
Metadata
Metadata
Assignees
Labels
No labels