24from ROOT
import Belle2
25from ROOT
import TFile, TH2F
26from laserResolutionTools
import fitLaserResolution, plotLaserResolution
31 ''' Module to study resolution and performance of the top laser calibration.'''
34 h_LaserTimingVSChannel = TH2F(
35 'LaserTimingVSChannel',
36 'Laser timing in as function of the channel number',
44 h_LaserTimingVSChannelOneSlot = TH2F(
45 'LaserTimingVSChannelOneSlot',
46 'Laser timing in as function of the channel number',
55 h_crossOccupancy = [[TH2F(
56 'crossOccupancy_' + str(slotA) +
'_' + str(slotB),
63 200)
for slotA
in range(16)]
for slotB
in range(16)]
66 outname =
'outStudyLaserResolution.root'
69 m_ignoreNotCalibrated =
True
82 m_mcCorrectionsFile =
'/group/belle2/group/detector/TOP/calibration/MCreferences/t0MC.root'
87 ''' Sets the output file name '''
92 ''' Sets the maximum calpulse width '''
97 ''' Sets the minimum calpulse width '''
102 ''' Sets the maximum calpulse amplitude '''
107 ''' Sets the minimum calpulse amplitude '''
112 ''' Sets the file containing the MC correction'''
117 ''' Sets the flag to ingore the hits without calibration '''
122 ''' Event processor: fill histograms '''
125 nhits = [0
for i
in range(16)]
129 if (digit.getHitQuality() == 1
and
131 digit.getPulseHeight() > self.
m_minAmp and digit.getPulseHeight() < self.
m_maxAmp):
132 slotID = digit.getModuleID()
133 hwchan = digit.getChannel()
135 simhits = digit.getRelationsWith(
'TOPSimHits')
136 nhits[slotID - 1] = nhits[slotID - 1] + 1
137 for simhit
in simhits:
139 for slotA
in range(16):
140 for slotB
in range(16):
144 ''' Write histograms to file, fills and fits the resolution plots'''
145 tfile = TFile(self.
outname,
'recreate')
148 for slotA
in range(16):
149 for slotB
in range(16):
155print(
'usage: basf2', argvs[0],
'runNumber outfileName')
162runnumbers = sys.argv[6:]
165for runnumber
in runnumbers:
166 if datatype ==
'root':
167 files += [f
for f
in glob.glob(str(folder) +
'/*' + str(runnumber) +
'*.root')]
170 files += [f
for f
in glob.glob(str(folder) +
'/*' + str(runnumber) +
'*.sroot')]
172 print(
"file: " + fname)
174if dbaddress !=
'none':
175 print(
"using local DB " + dbaddress)
176 b2.conditions.append_testing_payloads(dbaddress +
"/localDB.txt")
178 print(
"database not set. Continuing without calibrations")
181b2.set_log_level(b2.LogLevel.ERROR)
184b2.conditions.append_globaltag(
'data_reprocessing_proc8')
187main = b2.create_path()
190if datatype ==
'root':
191 roinput = b2.register_module(
'RootInput')
192 roinput.param(
'inputFileNames', files)
193 main.add_module(roinput)
195 roinput = b2.register_module(
'SeqRootInput')
196 roinput.param(
'inputFileNames', files)
197 main.add_module(roinput)
200if datatype ==
'pocket':
201 print(
'pocket DAQ data assumed')
202 converter = b2.register_module(
'Convert2RawDet')
203 main.add_module(converter)
206main.add_module(
'TOPGeometryParInitializer')
208if datatype !=
'root':
210 unpack = b2.register_module(
'TOPUnpacker')
211 main.add_module(unpack)
214 featureExtractor = b2.register_module(
'TOPWaveformFeatureExtractor')
215 main.add_module(featureExtractor)
218 converter = b2.register_module(
'TOPRawDigitConverter')
219 if dbaddress ==
'none':
220 print(
"Not using Calibrations")
221 converter.param(
'useSampleTimeCalibration',
False)
222 converter.param(
'useAsicShiftCalibration',
False)
223 converter.param(
'useChannelT0Calibration',
False)
224 converter.param(
'useModuleT0Calibration',
False)
226 print(
"Using Calibrations")
227 converter.param(
'useSampleTimeCalibration',
True)
228 converter.param(
'useAsicShiftCalibration',
True)
229 converter.param(
'useChannelT0Calibration',
True)
230 converter.param(
'useModuleT0Calibration',
True)
231 converter.param(
'useCommonT0Calibration',
False)
232 converter.param(
'calibrationChannel', -1)
233 converter.param(
'lookBackWindows', int(lookBack))
234 main.add_module(converter)
238resolutionModule.setOutputName(outfile)
239resolutionModule.setMinWidth(0.1)
240resolutionModule.setMaxWidth(999)
241resolutionModule.setMinAmp(100)
242resolutionModule.setMaxAmp(999)
243if dbaddress ==
'none':
244 resolutionModule.ignoreNotCalibrated(
True)
246 resolutionModule.ignoreNotCalibrated(
False)
247main.add_module(resolutionModule)
250progress = b2.register_module(
'Progress')
251main.add_module(progress)
258print(b2.statistics(b2.statistics.TERM))
261fitLaserResolution(dataFile=outfile, outputFile=
'laserResolutionResults.root', pdfType=
'cb', saveFits=
True)
A (simplified) python wrapper for StoreArray.
int m_maxWidth
maximum width to accept a TOPDigit
bool m_ignoreNotCalibrated
ignores the hits wthout calibration
str m_mcCorrectionsFile
root file with the MC distribution of the laser light, to get the light path corrections
int m_minAmp
minimum amplitude to accept a TOPDigit
ignoreNotCalibrated(self, ignoreNotCal)
setMinWidth(self, minWidth)
h_LaserTimingVSChannelOneSlot
Laser timing in as function of the channel number.
h_LaserTimingVSChannel
Width as function of the sample number in each channel.
str outname
output root file
setOutputName(self, outputname)
float m_minWidth
minimum width to accept a TOPDigit
int m_maxAmp
minimum amplitude to accept a TOPDigit
list h_crossOccupancy
cross occupancy
setMaxWidth(self, maxWidth)
setMCCorrectionsFile(self, MCfile)