13 <contact>christian.wessel@belle2.org</contact>
14 <input>EvtGenSimNoBkg.root</input>
15 <output>BasicSimulationAndReconstruction.root</output>
17 This validation script checks the basic of our detector simulation (digits)
18 and reconstruction (clusters etc) in a simulation without background
23from ROOT
import Belle2
24from ROOT
import TH1F, TFile, TNamed
26from svd
import add_svd_reconstruction
27from pxd
import add_pxd_reconstruction
29NAME =
'Basic detector simulation and reconstruction'
30CONTACT =
'christian.wessel@belle2.org'
31INPUT_FILE =
'../EvtGenSimNoBkg.root'
32OUTPUT_FILE =
'BasicSimulationAndReconstruction.root'
40 Check the number of hits that are produced by add_simulation and the basic reconstruction in SVD and CDC.
42 class BasicSimulationAndReconstructionValidation(basf2.Module):
44 Module to collect information about the number of
52 * CDCHits above threshold
63 output_file_name=None,
68 ## name of this validation output
69 self.validation_name = NAME
71 self.contact = CONTACT
72 ## ## name of the output ROOT file
73 self.output_file_name = OUTPUT_FILE
76 ''' Initialize the Module: book histograms and set descriptions and checks'''
79 self.hists.append(TH1F('PXDDigits', 'PXDDigits (no data reduction)',
81 self.hists.append(TH1F('PXDClusters', 'PXDClusters (no data reduction)',
83 self.hists.append(TH1F('PXDSpacePoints', 'PXDSpacePoints (no data reduction)',
85 self.hists.append(TH1F('SVDShaperDigits', 'SVDShaperDigits', 200, 0, 800))
86 self.hists.append(TH1F('SVDClusters', 'SVDClusters', 200, 0, 400))
87 self.hists.append(TH1F('SVDSpacePoints', 'SVDSpacePoints', 200, 0, 600))
88 self.hists.append(TH1F('CDCHits', 'CDCHits (all)', 200, 0, 2000))
89 self.hists.append(TH1F('CDCHitsAboveThreshold', 'CDCHits (above threshold)', 200, 0, 2000))
90 self.hists.append(TH1F('TOPDigits', 'TOPDigits', 200, 0, 800))
91 self.hists.append(TH1F('ARICHDigits', 'ARICHDigits', 200, 0, 200))
92 self.hists.append(TH1F('ECLDigits', 'ECLDigits, m_Amp > 500 (roughly 25 MeV)',
94 self.hists.append(TH1F('KLMDigits', 'KLMDigits', 200, 0, 200))
97 h.SetXTitle(f'Number of {h.GetName()} in event')
99 descr = TNamed('Description', 'Number of ' + h.GetName() +
100 ' per event (no BG overlay, just result of add_simulation and basic reconstruction)')
102 h.SetYTitle('entries per bin')
103 h.GetListOfFunctions().Add(descr)
104 check = TNamed('Check', 'Distribution must agree with its reference')
105 h.GetListOfFunctions().Add(check)
106 contact = TNamed('Contact', self.contact)
107 h.GetListOfFunctions().Add(contact)
108 options = TNamed('MetaOptions', option)
109 h.GetListOfFunctions().Add(options)
111 ## number of L3 strips (u+v)
112 self.nSVDL3 = 768 * 7 * 2 * 2
115 ''' Event processor: fill histograms '''
118 digits = Belle2.PyStoreArray(h.GetName())
119 if h.GetName() == 'ECLDigits':
122 if digit.getAmp() > 500: # roughly 25 MeV
125 elif h.GetName() == 'CDCHitsAboveThreshold':
128 h.Fill(digits.getEntries())
131 cdcHits = Belle2.PyStoreArray('CDCHits')
132 nCDC_above_threshold = 0
133 for cdcHit in cdcHits: # count wires of inner/outer layers
134 if cdcHit.getISuperLayer() == 0 and cdcHit.getADCCount() > 15:
135 nCDC_above_threshold += 1
136 if cdcHit.getISuperLayer() != 0 and cdcHit.getADCCount() > 18:
137 nCDC_above_threshold += 1
139 if h.GetName() == 'CDCHitsAboveThreshold':
140 h.Fill(nCDC_above_threshold)
143 """ Write histograms to file."""
145 tfile = TFile(self.output_file_name, 'recreate')
151 basf2.set_random_seed(1509)
153 path = basf2.create_path()
155 path.add_module('RootInput', inputFileName=INPUT_FILE)
156 path.add_module('Gearbox')
157 path.add_module('Geometry')
158 add_svd_reconstruction(path, isROIsimulation=False)
159 add_pxd_reconstruction(path)
161 path.add_module(BasicSimulationAndReconstructionValidation())
163 path.add_module('Progress')
167 print(basf2.statistics)
170if __name__ == '__main__':
174 print("This validation deactivated and thus basf2 is not executed.\n"
175 "If you want to run this validation, please set the 'ACTIVE' flag above to 'True'.\n"