15 This module is used for the SVD validation.
16 It gets information about truehits and clusters, saving
17 in a ttree in a ROOT file.
19 <noexecute>SVD validation helper class</noexecute>
27 from ROOT
import Belle2
28 from ROOT
import gROOT, addressof
31 gROOT.ProcessLine(
'struct EventDataSimhit {\
42 from ROOT
import EventDataSimhit
46 '''class to create sim hit ttree'''
49 """Initialize the module"""
51 super(SVDValidationTTreeSimhit, self).
__init__()
53 self.
filefile = ROOT.TFile(
'../SVDValidationTTreeSimhit.root',
'recreate')
55 self.
treetree = ROOT.TTree(
'tree',
'Event data of SVD validation events')
57 self.
datadata = EventDataSimhit()
60 for key
in EventDataSimhit.__dict__:
63 if isinstance(self.
datadata.__getattribute__(key), int):
65 self.
treetree.Branch(key, addressof(self.
datadata, key), key + formstring)
68 """Find simhits with a truehit and save needed information"""
73 for truehit
in svd_truehits:
74 simhits = truehit.getRelationsTo(
'SVDSimHits')
75 for simhit
in simhits:
77 sensorID = simhit.getSensorID()
78 self.
datadata.sensor_id = int(sensorID)
79 sensorNum = sensorID.getSensorNumber()
80 self.
datadata.sensor = sensorNum
81 layerNum = sensorID.getLayerNumber()
82 self.
datadata.layer = layerNum
83 ladderNum = sensorID.getLadderNumber()
84 self.
datadata.ladder = ladderNum
92 self.
datadata.sensor_type = sensorType
95 particle = simhit.getRelatedFrom(
'MCParticles')
96 if not particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
99 length = (simhit.getPosOut() - simhit.getPosIn()).R()
102 energy = simhit.getElectrons() * Belle2.Const.ehEnergy
103 self.
datadata.simhit_length = length
104 self.
datadata.simhit_energy = energy
107 self.
datadata.simhit_dEdx = energy / length
117 """Close the output file. """
119 self.
filefile.Write()
120 self.
filefile.Close()
A (simplified) python wrapper for StoreArray.
data
instance of eventDataSimhit