Belle II Software development
SVDValidationTTreeRecoDigit Class Reference
Inheritance diagram for SVDValidationTTreeRecoDigit:

Public Member Functions

def __init__ (self)
 
def event (self)
 
def terminate (self)
 

Public Attributes

 file
 output file
 
 tree
 ttree
 
 data
 instance of event data class
 

Detailed Description

class to create reco digitis ttree

Definition at line 45 of file SVDValidationTTreeRecoDigit.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
Initialize the module

Definition at line 48 of file SVDValidationTTreeRecoDigit.py.

48 def __init__(self):
49 """Initialize the module"""
50
51 super().__init__()
52
53 self.file = ROOT.TFile('../SVDValidationTTreeRecoDigit.root', 'recreate')
54
55 self.tree = ROOT.TTree('tree', 'Event data of SVD validation events')
56
57 self.data = EventDataRecoDigit()
58
59 # Declare tree branches
60 for key in EventDataRecoDigit.__dict__:
61 if '__' not in key:
62 formstring = '/F'
63 if isinstance(self.data.__getattribute__(key), int):
64 formstring = '/I'
65 self.tree.Branch(key, addressof(self.data, key), key + formstring)
66

Member Function Documentation

◆ event()

def event (   self)
Take digits from SVDRecoDigits with at least one truehit and save needed information

Definition at line 67 of file SVDValidationTTreeRecoDigit.py.

67 def event(self):
68 """Take digits from SVDRecoDigits with at least one truehit and save needed information"""
69 digits = Belle2.PyStoreArray('SVDRecoDigits')
70 shaperDigits = Belle2.PyStoreArray('SVDShaperDigits')
71 for digit in digits:
72 # get the true hit from the related SVDShaperDigit
73 # it works because there is a 1-to-1 correspondence between
74 # ShaperDigits and RecoDigits
75 digit_truehits = shaperDigits[digit.getArrayIndex()].getRelationsTo('SVDTrueHits')
76
77 if len(digit_truehits) == 0:
78 continue
79
80 # find the trueHit with highest energy deposit (the "best" match)
81 energy = 0
82 bestTrueHitIndex = 0
83
84 for i, trueHit in enumerate(digit_truehits):
85 if trueHit.getEnergyDep() > energy:
86 energy = trueHit.getEnergyDep()
87 bestTrueHitIndex = i
88 bestTrueHit = digit_truehits[bestTrueHitIndex]
89
90 # Sensor identification
91 sensorID = digit.getSensorID()
92 self.data.sensor_id = int(sensorID)
93 sensorNum = sensorID.getSensorNumber()
94 self.data.sensor = sensorNum
95 layerNum = sensorID.getLayerNumber()
96 self.data.layer = layerNum
97 if (layerNum == 3):
98 sensorType = 1 # Barrel
99 else:
100 if (sensorNum == 1):
101 sensorType = 0
102 else:
103 sensorType = 1
104 self.data.sensor_type = sensorType
105 ladderNum = sensorID.getLadderNumber()
106 self.data.ladder = ladderNum
107 if digit.isUStrip():
108 self.data.strip_dir = 0
109 else:
110 self.data.strip_dir = 1
111 self.data.recodigit_charge = digit.getCharge()
112 self.data.recodigit_time = digit.getTime()
113 self.data.truehit_time = bestTrueHit.getGlobalTime()
114 # Fill tree
115 self.file.cd()
116 self.tree.Fill()
117
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ terminate()

def terminate (   self)
Close the output file. 

Definition at line 118 of file SVDValidationTTreeRecoDigit.py.

118 def terminate(self):
119 """Close the output file. """
120 self.file.cd()
121 self.file.Write()
122 self.file.Close()

Member Data Documentation

◆ data

data

instance of event data class

Definition at line 57 of file SVDValidationTTreeRecoDigit.py.

◆ file

file

output file

Definition at line 53 of file SVDValidationTTreeRecoDigit.py.

◆ tree

tree

ttree

Definition at line 55 of file SVDValidationTTreeRecoDigit.py.


The documentation for this class was generated from the following file: