10from ROOT
import TVector3
19 This class represents a
dataset.
25 varnum[
"recoz"] = [0,
r'$Z_{Reco}$',
r'$[cm]$']
26 varnum[
"recotheta"] = [1,
r'$\theta_{Reco}$',
r'$[°]$']
27 varnum[
"recophi"] = [2,
r'$\phi_{Reco}$',
r'$[°]$']
28 varnum[
"recopt"] = [3,
r'$P_{t, Reco}$',
r'$[GeV]$']
29 varnum[
"recop"] = [4,
r'$P_{Reco}$',
r'$[GeV]$']
30 varnum[
"neuroz"] = [5,
r'$Z_{Neuro}$',
r'$[cm]$']
31 varnum[
"neurotheta"] = [6,
r'$\theta_{Neuro}$',
r'$[°]$']
32 varnum[
"neurophi"] = [7,
r'$\phi_{Neuro}$',
r'$[°]$']
33 varnum[
"neuropt"] = [8,
r'$P_{Neuro}$',
r'$[GeV]$']
34 varnum[
"neurop"] = [9,
r'$P_{t, Neuro}$',
r'$[GeV]$']
35 varnum[
"neuroval"] = [10,
r'Validity',
'']
36 varnum[
"neuroqual"] = [11,
r'Quality',
'']
37 varnum[
"neurots"] = [12,
r'TSVector',
'']
38 varnum[
"neuroexp"] = [13,
r'Expert Number',
'']
39 varnum[
"neurodriftth"] = [14,
r'Driftthreshold',
'']
40 varnum[
"neuroquad"] = [15,
r'Quadrant',
'']
41 varnum[
"neurofp"] = [16,
r'Fastestpriority Eventtime',
'clocks']
42 varnum[
"neuroetf"] = [17,
r'ETF Eventtime',
'clocks']
43 varnum[
"twodphi"] = [18,
r'$\phi_{2D}$',
r'$[°]$']
44 varnum[
"twodpt"] = [19,
r'$P_{t, 2D}$',
r'$[GeV]$']
45 varnum[
"twodfot"] = [20,
r'FoundOldTrack',
'']
46 varnum[
"hwneuroz"] = [21,
r'$Z_{HWNeuro}$',
r'$[cm]$']
47 varnum[
"hwneurotheta"] = [22,
r'$\theta_{HWNeuro}$',
r'$[°]$']
48 varnum[
"hwneurophi"] = [23,
r'$\phi_{HWNeuro}$',
r'$[°]$']
49 varnum[
"hwneuropt"] = [24,
r'$P_{t, HWNeuro}$',
r'$[GeV]$']
50 varnum[
"hwneurop"] = [25,
r'$P_{HWNeuro}$',
r'$[GeV]$']
51 varnum[
"hwneuroval"] = [26,
r'Validity',
'']
52 varnum[
"hwneuroqual"] = [27,
r'Quality',
'']
53 varnum[
"hwneurots"] = [28,
r'TSVector',
'']
54 varnum[
"hwneuroexp"] = [29,
r'Expert Number',
'']
55 varnum[
"hwneurodriftth"] = [30,
r'Driftthreshold',
'']
56 varnum[
"hwneuroquad"] = [31,
r'Quadrant',
'']
57 varnum[
"hwneurofp"] = [32,
r'Fastestpriority Eventtime',
'clocks']
58 varnum[
"hwneuroetf"] = [33,
r'ETF Eventtime',
'clocks']
59 varnum[
"swneuroz"] = [34,
r'$Z_{SWNeuro}$',
r'$[cm]$']
60 varnum[
"swneurotheta"] = [35,
r'$\theta_{SWNeuro}$',
r'$[°]$']
61 varnum[
"swneurophi"] = [36,
r'$\phi_{SWNeuro}$',
r'$[°]$']
62 varnum[
"swneuropt"] = [37,
r'$P_{t, SWNeuro}$',
r'$[GeV]$']
63 varnum[
"swneurop"] = [38,
r'$P_{SWNeuro}$',
r'$[GeV]$']
64 varnum[
"swneuroval"] = [39,
r'Validity',
'']
65 varnum[
"swneuroqual"] = [40,
r'Quality',
'']
66 varnum[
"swneurots"] = [41,
r'TSVector',
'']
67 varnum[
"swneuroexp"] = [42,
r'Expert Number',
'']
68 varnum[
"swneurodriftth"] = [43,
r'Driftthreshold',
'']
69 varnum[
"swneuroquad"] = [44,
r'Quadrant',
'']
70 varnum[
"swneurofp"] = [45,
r'Fastestpriority Eventtime',
'clocks']
71 varnum[
"swneuroetf"] = [46,
r'ETF Eventtime',
'clocks']
72 varnum[
"swtwodphi"] = [47,
r'$\phi_{SW2D}$',
r'$[°]$']
73 varnum[
"swtwodpt"] = [48,
r'$P_{t, SW2D}$',
r'$[GeV]$']
74 varnum[
"swtwodfot"] = [49,
r'FoundOldTrack',
'']
75 varnum[
"neuroats"] = [50,
r'NumberOfAxials',
'']
76 varnum[
"hwneuroats"] = [51,
r'NumberOfAxials',
'']
77 varnum[
"swneuroats"] = [52,
r'NumberOfAxials',
'']
78 varnum[
"neuroetfcc"] = [53,
r'ETF Eventtime from CC',
'clocks']
79 varnum[
"neurohwtime"] = [54,
r'Reconstructed HW Eventtime',
'clocks']
80 varnum[
"hwneuroetfcc"] = [55,
r'ETF Eventtime',
'clocks']
81 varnum[
"hwneurohwtime"] = [56,
r'Reconstructed HW Eventtime',
'clocks']
86 def param(self, params):
87 for key, value
in params.items():
88 setattr(self, key, value)
110 self.
etfname =
"CDCTriggerNeuroETFT0"
111 self.
tsname =
"CDCTriggerNNInputSegmentHits"
150 def costotheta(self, x):
151 if isinstance(x, list):
163 return 180. / np.pi * np.arccos(x)
165 def getrecovalsold(self, evlist, fitres):
167 evlist[self.
varnumvarnum[
"recoz"][0]] = fitres.getPosition().Z()
168 evlist[self.
varnumvarnum[
"recotheta"][0]] = fitres.getMomentum().Theta()
169 evlist[self.
varnumvarnum[
"recophi"][0]] = fitres.getMomentum().Phi()
170 evlist[self.
varnumvarnum[
"recopt"][0]] = fitres.getTransverseMomentum()
171 evlist[self.
varnumvarnum[
"recop"][0]] = fitres.getMomentum().R()
174 def getrecovals(self, evlist, state):
176 evlist[self.
varnumvarnum[
"recoz"][0]] = state.getPos().Z()
177 evlist[self.
varnumvarnum[
"recotheta"][0]] = state.getMom().Theta()
178 evlist[self.
varnumvarnum[
"recophi"][0]] = state.getMom().Phi()
179 evlist[self.
varnumvarnum[
"recopt"][0]] = state.getMom().Pt()
180 evlist[self.
varnumvarnum[
"recop"][0]] = state.getMomMag()
183 def getneurovals(self, evlist, neuro, status=""):
187 evlist[self.
varnumvarnum[pre +
"neuroz"][0]] = neuro.getZ0()
188 evlist[self.
varnumvarnum[pre +
"neurotheta"][0]] = self.
costotheta(neuro.getCotTheta() / np.sqrt(1 + neuro.getCotTheta()**2))
189 evlist[self.
varnumvarnum[pre +
"neurophi"][0]] = neuro.getPhi0()
190 evlist[self.
varnumvarnum[pre +
"neuropt"][0]] = neuro.getPt()
192 np.sqrt(1 + neuro.getCotTheta()**2)))
193 evlist[self.
varnumvarnum[pre +
"neuroval"][0]] = neuro.getValidStereoBit()
194 evlist[self.
varnumvarnum[pre +
"neuroqual"][0]] = neuro.getQualityVector()
195 evlist[self.
varnumvarnum[pre +
"neurots"][0]] = int(
"".join([str(x)
for x
in neuro.getTSVector()]))
196 xx = sum([int(i != 0)
for i
in neuro.getTSVector()][::2])
200 evlist[self.
varnumvarnum[pre +
"neuroexp"][0]] = neuro.getExpert()
201 evlist[self.
varnumvarnum[pre +
"neurodriftth"][0]] = int(
"".join([str(int(x))
for x
in neuro.getDriftThreshold()]))
202 evlist[self.
varnumvarnum[pre +
"neuroquad"][0]] = neuro.getQuadrant()
204 for ts
in neuro.getRelationsTo(self.
tsname):
205 if ts.priorityTime() < fpt:
206 fpt = ts.priorityTime()
207 if self.
etf.hasBinnedEventT0(Belle2.Const.CDC):
208 eft = self.
etf.getBinnedEventT0(Belle2.Const.CDC)
217 evlist[self.
varnumvarnum[pre +
"neuroetfcc"][0]] = neuro.getETF_unpacked()
218 evlist[self.
varnumvarnum[pre +
"neurohwtime"][0]] = neuro.getETF_recalced()
221 def gettwodvals(self, evlist, twod):
223 evlist[self.
varnumvarnum[
"twodphi"][0]] = twod.getPhi0()
228 def getswtwodvals(self, evlist, twod):
230 evlist[self.
varnumvarnum[
"swtwodphi"][0]] = twod.getPhi0()
244 track = reco.getRelatedFrom(
"Tracks")
256 print(
"no track found for recotrack")
265 reps = reco.getRepresentations()
267 for irep, rep
in enumerate(reps):
268 if not reco.wasFitSuccessful(rep):
271 state = reco.getMeasuredStateOnPlaneClosestTo(XYZVector(0, 0, 0), rep)
272 rep.extrapolateToLine(state, TVector3(0, 0, -1000), TVector3(0, 0, 2000))
273 except BaseException:
284 except BaseException:
288 except BaseException:
292 except BaseException:
296 except BaseException:
304 event[-1] = self.
getneurovals(event[-1], hwneuro, status=
"hw")
305 event[-1] = self.
getneurovals(event[-1], swneuro, status=
"sw")
317 except BaseException:
321 except BaseException:
325 event[-1] = self.
getneurovals(event[-1], hwneuro, status=
"hw")
336 except BaseException:
338 event[-1] = self.
getneurovals(event[-1], swneuro, status=
"sw")
363 for i
in range(self.
maxtracks - len(event)):
375 def save(self, filename=None, netname=None, dataname=None):
377 filename = self.filename
379 netname = self.netname
387 savedict[
"networkname"] = netname
388 savedict[
"dataname"] = dataname
389 savedict[
"version"] = nntd.version
390 f = open(filename,
'wb')
391 pickle.dump(savedict, f)
393 print(
'file ' + filename +
' has been saved. ')
395 def loadmore(self, filenames):
400 if "NNTD_EVLIMIT" in os.environ:
401 evlim = int(os.environ[
"NNTD_EVLIMIT"])
404 for i, x
in enumerate(filenames):
405 print(
"checking file: " + str(i) +
"/" + str(len(filenames)))
407 evnumber += len(pickle.load(f)[
"eventlist"])
409 print(
"total number of available events is " + str(evnumber))
410 skipev = int(evnumber/evlim)
411 print(
"Number of events more than " + str(evlim) +
" only taking every " + str(skipev) +
" event")
416 savedict = pickle.load(f)
418 if self.
version != savedict[
"version"]:
419 print(
"Error! loaded file was made with different version of nntd! exiting ... ")
422 if "dataname" in savedict:
423 self.
dataname = savedict[
"dataname"]
425 self.
eventlist += savedict[
"eventlist"][::skipev][:templim]
427 print(
"Loaded file: " + x)
428 print(
"length of eventlist: " + str(len(self.
eventlist)))
430 print(
"stop loading, maximum event number reached")
433 print(
"all files loaded, array.size: " + str(self.
data.size) +
", array.shape: " + str(self.
data.shape))
435 def load(self, filename):
437 f = open(filename,
'rb')
438 savedict = pickle.load(f)
440 if self.
version != savedict[
"version"]:
441 print(
"Error! loaded file was made with different version of nntd! exiting ... ")
446 self.
dataname = savedict[
"dataname"]
450 def makearray(self, evlist):
452 self.
data = np.array(evlist)
Provides a type-safe way to pass members of the chargedStableSet set.
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.
def getswtwodvals(self, evlist, twod)
def getneurovals(self, evlist, neuro, status="")
def getrecovals(self, evlist, state)
def save(self, filename=None, netname=None, dataname=None)
def makearray(self, evlist)
def gettwodvals(self, evlist, twod)
def getrecovalsold(self, evlist, fitres)