3 from HitIdentifier
import RpcIdentifier
4 from ROOT
import TVector3, TVector2, TFile
5 from argparse
import ArgumentParser
10 stationIndex=-1, stationEta=-1, stationPhi=-1,
11 doubletR = -1, doubletPhi = -1, doubletZ = -1,
12 gasGap =-1, measuresPhi = False, strip = -1,
13 globPosX= -1, globPosY = -1., globPosZ = -1,
14 locPosX = -1, locPosY= -1,
17 self.
__id =
RpcIdentifier(stationIndex=stationIndex, stationEta = stationEta, stationPhi = stationPhi,
18 doubletR= doubletR, doubletPhi = doubletPhi, doubletZ = doubletZ,
19 gasGap = gasGap, measuresPhi = measuresPhi, strip = strip)
21 self.
__globPos = TVector3(globPosX, globPosY, globPosZ)
22 self.
__locPos = TVector2(locPosX, locPosY)
38 return "Rpc digit {id}, time {time:.2f}, localPos ({locX:.2f}, {locY:.2f}) globalPos ({globX:.2f}, {globY:.2f}, {globZ:.2f})".
format(id =
str(self.
identify()),
46 return self.
identify() == other.identify()
and \
51 def __init__(self, stationIndex=-1, stationEta=-1, stationPhi=-1,
52 doubletR=-1, doubletPhi=-1, doubletZ=-1, gasGap=-1,
53 measuresPhi=False, strip=-1,
54 globPosX=-1, globPosY=-1, globPosZ=-1,
55 locPosX=-1, locPosY=-1,
56 time=-1, barcode = -1) -> None:
57 super().
__init__(stationIndex, stationEta, stationPhi,
58 doubletR, doubletPhi, doubletZ,
59 gasGap, measuresPhi, strip,
60 globPosX, globPosY, globPosZ,
61 locPosX, locPosY, time)
68 return "Rpc SDO {id}, time {time:.2f}, localPos ({locX:.2f}, {locY:.2f}), globalPos ({globX:.2f}, {globY:.2f}, {globZ:.2f}), barcode {barcode}".
format(id =
str(self.
identify()),
79 t_file = TFile.Open(in_file,
"READ")
81 print(f
"Failed to open {in_file}")
83 tree = t_file.Get(treeName)
85 print(
"Failed to read tree {treeName} from {file}".
format(treeName=treeName, file=t_file.GetName()))
88 for entry
in range(tree.GetEntries()):
92 for digit
in range(len(tree.Digits_RPC_stationIndex)):
93 digits.append(
RpcDigit(stationIndex = ord(tree.Digits_RPC_stationIndex[digit]),
94 stationEta = ord(tree.Digits_RPC_stationEta[digit]),
95 stationPhi = ord(tree.Digits_RPC_stationPhi[digit]),
96 doubletR = ord(tree.Digits_RPC_doubletR[digit]),
97 doubletPhi= ord(tree.Digits_RPC_doubletPhi[digit]),
98 gasGap = ord(tree.Digits_RPC_gasGap[digit]),
99 measuresPhi=tree.Digits_RPC_measuresPhi[digit],
100 strip = ord(tree.Digits_RPC_strip[digit]),
101 globPosX= tree.Digits_RPC_globalPosX[digit],
102 globPosY= tree.Digits_RPC_globalPosY[digit],
103 globPosZ= tree.Digits_RPC_globalPosZ[digit],
105 locPosX = tree.Digits_RPC_localPosX[digit],
106 locPosY = tree.Digits_RPC_localPosY[digit],
107 time = tree.Digits_RPC_time[digit]
111 if len (digits): allDigits[evt] = digits
116 t_file = TFile.Open(in_file,
"READ")
118 print(f
"Failed to open {in_file}")
120 tree = t_file.Get(treeName)
122 print(
"Failed to read tree {treeName} from {file}".
format(treeName=treeName, file=t_file.GetName()))
125 for entry
in range(tree.GetEntries()):
127 evt= tree.eventNumber
130 for sdo
in range(len(tree.SDO_RPC_stationIndex)):
131 SDOs.append(
RpcSDO(stationIndex = ord(tree.SDO_RPC_stationIndex[sdo]),
132 stationEta = ord(tree.SDO_RPC_stationEta[sdo]),
133 stationPhi = ord(tree.SDO_RPC_stationPhi[sdo]),
134 doubletR = ord(tree.SDO_RPC_doubletR[sdo]),
135 doubletPhi = ord(tree.SDO_RPC_doubletPhi[sdo]),
136 gasGap = ord(tree.SDO_RPC_gasGap[sdo]),
137 measuresPhi=tree.SDO_RPC_measuresPhi[sdo],
138 strip = ord(tree.SDO_RPC_strip[sdo]),
139 globPosX = tree.SDO_RPC_globalPosX[sdo],
140 globPosY = tree.SDO_RPC_globalPosY[sdo],
141 globPosZ = tree.SDO_RPC_globalPosZ[sdo],
143 locPosX = tree.SDO_RPC_localPosX[sdo],
144 locPosY = tree.SDO_RPC_localPosY[sdo],
146 barcode=tree.SDO_RPC_barcode[sdo]
154 if __name__ ==
"__main__":
156 parser = ArgumentParser(prog=
"checkRpcDigits", description=
"Script comparing the Rpc digitization validation n-tuples")
157 parser.add_argument(
"--refFile", help=
"Reference file location", default =
"/media/slowSSD/jojungge/ATLPHYSVAL-1018/SimulationTest/24.0.35/NSWPRDValAlg.digi.ntuple.root", type = str)
158 parser.add_argument(
"--testFile", help=
"Reference file location", default =
"/media/slowSSD/jojungge/ATLPHYSVAL-1018/SimulationTest/25.0.5/NSWPRDValAlg.digi.ntuple.root", type = str)
159 parser.add_argument(
"--outFile", help=
"Location where the out file is stored", default=
"DigitComparison.txt")
160 args = parser.parse_args()
168 outFile =
open(args.outFile,
"w")
172 for event, refContent
in refDigits.items():
173 if not event
in testDigits:
174 print (
"WARNING {event} is not part of the test file {testFile}".
format(event = event, testFile=args.testFile))
176 testContent = testDigits[event]
178 for refObj
in refContent:
179 if refObj.identify().measuresPhi():
181 if refObj
not in testContent:
182 errorStr =
"In Event {event}, {digit} cannot be found in the test sample. Potential candidates: \n".
format(digit =
str(refObj),
184 for testObj
in testContent:
185 if testObj.identify().gasGapID() == refObj.identify().gasGapID():
186 errorStr +=
" **** {digit} \n".
format(digit =
str(testObj))
188 outFile.write(
"{msg}\n".
format(msg= errorStr))
191 exit(allGood ==
False)