10 from ROOT
import Belle2
11 from ROOT
import gROOT, AddressOf
14 gROOT.ProcessLine(
'struct EventData {\
27 float truehit_EntryW;\
29 float truehit_LossMomentum;\
31 float truehit_charge;\
36 float cluster_uEtaPosition;\
37 float cluster_vEtaPosition;\
38 float cluster_uError;\
39 float cluster_vError;\
41 float cluster_charge;\
51 from ROOT
import EventData
57 A simple module to check the reconstruction of PXDTrueHits.
58 This module writes its output to a ROOT tree.
59 Primary goal is supporting of validation plots
63 """Initialize the module"""
65 super(PXDValidationTTree, self).
__init__()
67 self.
file = ROOT.TFile(
'PXDValidationTTreeOutput.root',
'recreate')
69 self.
tree = ROOT.TTree(
'tree',
'Event data of PXD simulation')
71 self.
h_consts = ROOT.TH1F(
'h_consts',
'Constances', 12, 0, 12)
72 self.
h_consts.GetXaxis().SetBinLabel(1,
'Sensor thicknes [cm] (0.0075)')
73 self.
h_consts.GetXaxis().SetBinLabel(2,
'Pitch in u - all sensors [cm] (0.005)')
74 self.
h_consts.GetXaxis().SetBinLabel(3,
'Pitch in v, layer 1 small pitch [cm] (0.0055)')
75 self.
h_consts.GetXaxis().SetBinLabel(4,
'Pitch in v, layer 1 large pitch [cm] (0.006)')
76 self.
h_consts.GetXaxis().SetBinLabel(5,
'Pitch in v, layer 2 small pitch [cm] (0.007)')
77 self.
h_consts.GetXaxis().SetBinLabel(6,
'Pitch in v, layer 2 large pitch [cm] (0.0085)')
78 self.
h_consts.GetXaxis().SetBinLabel(7,
'Number of cells in u, all layers (250)')
79 self.
h_consts.GetXaxis().SetBinLabel(8,
'Number of cells in v, layer 1 small pitch (256)')
80 self.
h_consts.GetXaxis().SetBinLabel(9,
'Number of cells in v, layer 1 large pitch (512)')
81 self.
h_consts.GetXaxis().SetBinLabel(10,
'Number of cells in v, layer 2 small pitch (256)')
82 self.
h_consts.GetXaxis().SetBinLabel(11,
'Number of cells in v, layer 2 large pitch (512)')
83 self.
h_consts.GetXaxis().SetBinLabel(12,
'Noise of digits of sensors [electrons] (200)')
87 for key
in EventData.__dict__:
90 if isinstance(self.
data.__getattribute__(key), int):
92 self.
tree.Branch(key, AddressOf(self.
data, key), key + formstring)
98 """Find clusters with a truehit and save needed information."""
110 for cluster
in pxd_clusters:
111 cluster_truehits = cluster.getRelationsTo(
'PXDTrueHits')
114 if len(cluster_truehits) != 1:
117 for truehit
in cluster_truehits:
124 vxd_id = truehit.getSensorID()
125 self.data.vxd_id = vxd_id.getID()
126 self.data.layer = vxd_id.getLayerNumber()
127 self.data.ladder = vxd_id.getLadderNumber()
128 self.data.sensor = vxd_id.getSensorNumber()
130 UPitch = sensor_info.getUPitch()
131 VPitch = sensor_info.getVPitch(truehit.getV())
132 if vxd_id.getLayerNumber() == 1:
133 if vxd_id.getSensorNumber() == 1:
135 self.h_consts.SetBinContent(1, sensor_info.getThickness())
136 self.h_consts.SetBinContent(2, sensor_info.getUPitch())
137 self.h_consts.SetBinContent(3, sensor_info.getVPitch(-2.0))
138 self.h_consts.SetBinContent(4, sensor_info.getVPitch(+2.0))
139 self.h_consts.SetBinContent(7, sensor_info.getUCells())
140 self.h_consts.SetBinContent(8, VCellsSplit)
141 self.h_consts.SetBinContent(9, sensor_info.getVCells() - VCellsSplit)
142 self.h_consts.SetBinContent(12, DigitNoise)
144 if vxd_id.getLayerNumber() == 2:
145 if vxd_id.getSensorNumber() == 1:
147 self.h_consts.SetBinContent(5, sensor_info.getVPitch(-2.0))
148 self.h_consts.SetBinContent(6, sensor_info.getVPitch(+2.0))
149 self.h_consts.SetBinContent(10, VCellsSplit)
150 self.h_consts.SetBinContent(11, sensor_info.getVCells() - VCellsSplit)
152 self.data.pixel_type = (vxd_id.getLayerNumber() - 1) * 2
153 if vxd_id.getLayerNumber() == 1:
155 self.data.pixel_type += 1
156 if vxd_id.getLayerNumber() == 2:
158 self.data.pixel_type += 1
160 self.data.truehit_index = truehit.getArrayIndex()
161 self.data.cluster_index = cluster.getArrayIndex()
164 thickness = sensor_info.getThickness()
166 self.data.truehit_u = truehit.getU()
167 self.data.truehit_v = truehit.getV()
168 self.data.truehit_EntryW = truehit.getEntryW()
169 self.data.truehit_ExitW = truehit.getExitW()
170 self.data.truehit_LossMomentum = truehit.getEntryMomentum().Mag() - truehit.getExitMomentum().Mag()
171 self.data.truehit_time = truehit.getGlobalTime()
172 self.data.truehit_charge = truehit.getEnergyDep()
173 self.data.theta_u = math.atan2(truehit.getExitU() - truehit.getEntryU(), thickness)
174 self.data.theta_v = math.atan2(truehit.getExitV() - truehit.getEntryV(), thickness)
176 self.data.cluster_u = cluster.getU()
177 self.data.cluster_v = cluster.getV()
178 self.data.cluster_uError = cluster.getUSigma()
179 self.data.cluster_vError = cluster.getVSigma()
180 self.data.cluster_rho = cluster.getRho()
181 self.data.cluster_charge = cluster.getCharge()
182 self.data.cluster_seed = cluster.getSeedCharge()
183 self.data.cluster_size = cluster.getSize()
184 self.data.cluster_uSize = cluster.getUSize()
185 self.data.cluster_vSize = cluster.getVSize()
186 self.data.cluster_uEtaPosition = \
187 0.5 + (cluster.getU() - sensor_info.getUCellPosition(sensor_info.getUCellID(cluster.getU()))) / UPitch
188 self.data.cluster_vEtaPosition = \
189 0.5 + (cluster.getV() - sensor_info.getVCellPosition(sensor_info.getVCellID(cluster.getV()))) / VPitch
190 self.data.cluster_uPull = (cluster.getU() - truehit.getU()) / cluster.getUSigma()
191 self.data.cluster_vPull = (cluster.getV() - truehit.getV()) / cluster.getVSigma()
197 """ Close the output file."""
199 self.
h_consts.GetListOfFunctions().Add(ROOT.TNamed(
'Description',
'Transfer of some basic constances to root '
200 'for later procesing.'))
201 self.
h_consts.GetListOfFunctions().Add(ROOT.TNamed(
'Check',
'Validation: Check differences to reference plot, '
202 'must be no change.'))