6 <contact>G. Caria, gcaria@student.unimelb.edu.au</contact>
8 This module is used for the SVD validation.
9 It gets information about digits, saving
10 in a ttree in a ROOT file.
16 import xml.etree.ElementTree
as ET
22 from ROOT
import Belle2
23 from ROOT
import gROOT, AddressOf
24 from ROOT
import PyConfig
25 from ROOT
import TVector3
28 gROOT.ProcessLine(
'struct EventDataStrip {\
39 from ROOT
import EventDataStrip
43 '''class to create the strip ttree'''
46 """Initialize the module"""
48 super(SVDValidationTTreeStrip, self).
__init__()
49 self.
file = ROOT.TFile(
'../SVDValidationTTreeStrip.root',
'recreate')
50 '''Output ROOT file'''
51 self.
tree = ROOT.TTree(
'tree',
'Event data of SVD validation events')
52 '''TTrees for output data'''
53 self.
data = EventDataStrip()
54 '''Instance of the EventDataStrip class'''
57 for key
in EventDataStrip.__dict__:
60 if isinstance(self.
data.__getattribute__(key), int):
62 self.
tree.Branch(key, AddressOf(self.
data, key), key + formstring)
65 """Find digit with a cluster and save needed information"""
70 for sensor
in root.findall(
'Sensor'):
71 if sensor.get(
'type') ==
'Layer3':
72 if len(sensor.findall(
'Active')) == 1:
73 active = sensor.find(
'Active')
74 NoiseULayer3 = int(active.find(
'ElectronicNoiseU').text)
75 NoiseVLayer3 = int(active.find(
'ElectronicNoiseV').text)
76 for sensorbase
in root.iter(
'SensorBase'):
77 if sensorbase.get(
'type') ==
'Barrel':
78 active = sensorbase.find(
'Active')
79 NoiseUBarrel = int(active.find(
'ElectronicNoiseU').text)
80 NoiseVBarrel = int(active.find(
'ElectronicNoiseV').text)
81 elif sensorbase.get(
'type') ==
'Slanted':
82 active = sensorbase.find(
'Active')
83 NoiseUSlanted = int(active.find(
'ElectronicNoiseU').text)
84 NoiseVSlanted = int(active.find(
'ElectronicNoiseV').text)
89 for cluster
in clusters:
93 cluster_truehits = cluster.getRelationsTo(
'SVDTrueHits')
95 if len(cluster_truehits) != 1:
97 digits = cluster.getRelationsTo(
'SVDRecoDigits')
101 if digit.getCellID()
not in cls_strip_ids:
102 cls_strip_ids.append(digit.getCellID())
105 for strip_id
in cls_strip_ids:
109 if strip_id != digit.getCellID():
114 if(digit.getCharge() > strip_charge):
115 strip_charge = digit.getCharge()
118 sensorID = cluster.getSensorID()
119 self.
data.sensor_id = int(sensorID)
120 sensorNum = sensorID.getSensorNumber()
121 self.
data.sensor = sensorNum
122 layerNum = sensorID.getLayerNumber()
123 self.
data.layer = layerNum
131 self.
data.sensor_type = sensorType
132 ladderNum = sensorID.getLadderNumber()
133 self.
data.ladder = ladderNum
134 self.
data.strip_charge = strip_charge
143 noise = NoiseUSlanted
152 noise = NoiseVSlanted
155 self.
data.strip_dir = strip_dir
156 self.
data.strip_noise = noise
162 """Close the output file. """