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)
177 b2.conditions.append_testing_payloads(dbaddress +
"/localDB.txt")
179 print(
"database not set. Continuing without calibrations")
182 b2.set_log_level(b2.LogLevel.ERROR)
185 b2.conditions.append_globaltag(
'data_reprocessing_proc8')
188 main = b2.create_path()
191 if datatype ==
'root':
192 roinput = b2.register_module(
'RootInput')
193 roinput.param(
'inputFileNames', files)
194 main.add_module(roinput)
196 roinput = b2.register_module(
'SeqRootInput')
197 roinput.param(
'inputFileNames', files)
198 main.add_module(roinput)
201 if datatype ==
'pocket':
202 print(
'pocket DAQ data assumed')
203 converter = b2.register_module(
'Convert2RawDet')
204 main.add_module(converter)
207 main.add_module(
'TOPGeometryParInitializer')
209 if datatype !=
'root':
211 unpack = b2.register_module(
'TOPUnpacker')
212 main.add_module(unpack)
215 featureExtractor = b2.register_module(
'TOPWaveformFeatureExtractor')
216 main.add_module(featureExtractor)
219 converter = b2.register_module(
'TOPRawDigitConverter')
220 if dbaddress ==
'none':
221 print(
"Not using Calibrations")
222 converter.param(
'useSampleTimeCalibration',
False)
223 converter.param(
'useAsicShiftCalibration',
False)
224 converter.param(
'useChannelT0Calibration',
False)
225 converter.param(
'useModuleT0Calibration',
False)
227 print(
"Using Calibrations")
228 converter.param(
'useSampleTimeCalibration',
True)
229 converter.param(
'useAsicShiftCalibration',
True)
230 converter.param(
'useChannelT0Calibration',
True)
231 converter.param(
'useModuleT0Calibration',
True)
232 converter.param(
'useCommonT0Calibration',
False)
233 converter.param(
'calibrationChannel', -1)
234 converter.param(
'lookBackWindows', int(lookBack))
235 main.add_module(converter)
239 resolutionModule.setOutputName(outfile)
240 resolutionModule.setMinWidth(0.1)
241 resolutionModule.setMaxWidth(999)
242 resolutionModule.setMinAmp(100)
243 resolutionModule.setMaxAmp(999)
244 if dbaddress ==
'none':
245 resolutionModule.ignoreNotCalibrated(
True)
247 resolutionModule.ignoreNotCalibrated(
False)
248 main.add_module(resolutionModule)
251 progress = b2.register_module(
'Progress')
252 main.add_module(progress)
259 print(b2.statistics(b2.statistics.TERM))
262 fitLaserResolution(dataFile=outfile, outputFile=
'laserResolutionResults.root', pdfType=
'cb', saveFits=
True)
263 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)