25 from ROOT
import Belle2
26 from ROOT
import TFile, TH2F
27 from laserResolutionTools
import fitLaserResolution, plotLaserResolution
32 ''' Module to study resolution and performance of the top laser calibration.'''
35 h_LaserTimingVSChannel = TH2F(
36 'LaserTimingVSChannel',
37 'Laser timing in as function of the channel number',
45 h_LaserTimingVSChannelOneSlot = TH2F(
46 'LaserTimingVSChannelOneSlot',
47 'Laser timing in as function of the channel number',
56 h_crossOccupancy = [[TH2F(
57 'crossOccupancy_' + str(slotA) +
'_' + str(slotB),
64 200)
for slotA
in range(16)]
for slotB
in range(16)]
67 outname =
'outStudyLaserResolution.root'
70 m_ignoreNotCalibrated =
True
83 m_mcCorrectionsFile =
'/group/belle2/group/detector/TOP/calibration/MCreferences/t0MC.root'
88 ''' Sets the output file name '''
93 ''' Sets the maximum calpulse width '''
98 ''' Sets the minimum calpulse width '''
103 ''' Sets the maximum calpulse amplitude '''
108 ''' Sets the minimum calpulse amplitude '''
113 ''' Sets the file containing the MC correction'''
118 ''' Sets the flag to ingore the hits without calibration '''
123 ''' Event processor: fill histograms '''
126 nhits = [0
for i
in range(16)]
130 if (digit.getHitQuality() == 1
and
133 slotID = digit.getModuleID()
134 hwchan = digit.getChannel()
136 simhits = digit.getRelationsWith(
'TOPSimHits')
137 nhits[slotID - 1] = nhits[slotID - 1] + 1
138 for simhit
in simhits:
140 for slotA
in range(16):
141 for slotB
in range(16):
142 self.
h_crossOccupancyh_crossOccupancy[slotA][slotB].Fill(nhits[slotA], nhits[slotB])
145 ''' Write histograms to file, fills and fits the resolution plots'''
149 for slotA
in range(16):
150 for slotB
in range(16):
156 print(
'usage: basf2', argvs[0],
'runNumber outfileName')
163 runnumbers = sys.argv[6:]
166 for runnumber
in runnumbers:
167 if datatype ==
'root':
168 files += [f
for f
in glob.glob(str(folder) +
'/*' + str(runnumber) +
'*.root')]
171 files += [f
for f
in glob.glob(str(folder) +
'/*' + str(runnumber) +
'*.sroot')]
173 print(
"file: " + fname)
175 if dbaddress !=
'none':
176 print(
"using local DB " + dbaddress)
178 b2.use_local_database(dbaddress +
"/localDB.txt", dbaddress)
180 print(
"database not set. Continuing without calibrations")
183 b2.set_log_level(b2.LogLevel.ERROR)
186 b2.use_central_database(
'data_reprocessing_proc8')
189 main = b2.create_path()
192 if datatype ==
'root':
193 roinput = b2.register_module(
'RootInput')
194 roinput.param(
'inputFileNames', files)
195 main.add_module(roinput)
197 roinput = b2.register_module(
'SeqRootInput')
198 roinput.param(
'inputFileNames', files)
199 main.add_module(roinput)
202 if datatype ==
'pocket':
203 print(
'pocket DAQ data assumed')
204 converter = b2.register_module(
'Convert2RawDet')
205 main.add_module(converter)
208 main.add_module(
'TOPGeometryParInitializer')
210 if datatype !=
'root':
212 unpack = b2.register_module(
'TOPUnpacker')
213 main.add_module(unpack)
216 featureExtractor = b2.register_module(
'TOPWaveformFeatureExtractor')
217 main.add_module(featureExtractor)
220 converter = b2.register_module(
'TOPRawDigitConverter')
221 if dbaddress ==
'none':
222 print(
"Not using Calibrations")
223 converter.param(
'useSampleTimeCalibration',
False)
224 converter.param(
'useAsicShiftCalibration',
False)
225 converter.param(
'useChannelT0Calibration',
False)
226 converter.param(
'useModuleT0Calibration',
False)
228 print(
"Using Calibrations")
229 converter.param(
'useSampleTimeCalibration',
True)
230 converter.param(
'useAsicShiftCalibration',
True)
231 converter.param(
'useChannelT0Calibration',
True)
232 converter.param(
'useModuleT0Calibration',
True)
233 converter.param(
'useCommonT0Calibration',
False)
234 converter.param(
'calibrationChannel', -1)
235 converter.param(
'lookBackWindows', int(lookBack))
236 main.add_module(converter)
240 resolutionModule.setOutputName(outfile)
241 resolutionModule.setMinWidth(0.1)
242 resolutionModule.setMaxWidth(999)
243 resolutionModule.setMinAmp(100)
244 resolutionModule.setMaxAmp(999)
245 if dbaddress ==
'none':
246 resolutionModule.ignoreNotCalibrated(
True)
248 resolutionModule.ignoreNotCalibrated(
False)
249 main.add_module(resolutionModule)
252 progress = b2.register_module(
'Progress')
253 main.add_module(progress)
260 print(b2.statistics(b2.statistics.TERM))
263 fitLaserResolution(dataFile=outfile, outputFile=
'laserResolutionResults.root', pdfType=
'cb', saveFits=
True)
264 plotLaserResolution()
a (simplified) python wrapper for StoreArray.
int m_maxWidth
maximum width to accept a TOPDigit
bool m_ignoreNotCalibrated
ignores the hits wthout calibration
def setMinWidth(self, minWidth)
def ignoreNotCalibrated(self, ignoreNotCal)
string m_mcCorrectionsFile
root file with the MC distribution of the laser light, to get the light path corrections
def setOutputName(self, outputname)
def setMinAmp(self, minAmp)
int m_minAmp
minimum amplitude to accept a TOPDigit
m_mcCorrectionsFile
output name
def setMaxWidth(self, maxWidth)
int m_maxAmp
minimum amplitude to accept a TOPDigit
h_LaserTimingVSChannelOneSlot
Laser timing in as function of the channel number.
h_LaserTimingVSChannel
Width as function of the sample number in each channel.
string outname
output root file
m_ignoreNotCalibrated
output name
float m_minWidth
minimum width to accept a TOPDigit
def setMCCorrectionsFile(self, MCfile)
list h_crossOccupancy
cross occupancy
def setMaxAmp(self, maxAmp)