ATLAS Offline Software
Loading...
Searching...
No Matches
TileLaserTimingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Athena includes
7#include "CoralBase/Blob.h"
8#include "CoralBase/AttributeListSpecification.h"
12
13// Tile includes
14#include "TileLaserTimingTool.h"
20
21#include "TFile.h"
22#include "TTree.h"
23#include "TF1.h"
24#include "TObjArray.h"
25#include <TROOT.h>
26
27#include <cmath>
28
29//const unsigned NPmts = 48;
30
31template<class _T> inline _T sqr(const _T &data) { return data * data; }
32
33inline int imax(int i, int j) { return i < j ? j : i; }
34
36 : TimeDiffHisto(("pmt_dtime"+id).c_str(),("pmt_dtime"+id).c_str(),1200,-60,60)
37 , TimeDiffNoCFCorrHisto(("dtimeNoCorr"+id).c_str(),("dtimeNoCorr"+id).c_str(),1200,-60,60)
38
40 , timeHisto(("time" + id).c_str(), ("time" + id).c_str(), 200, -100, 100)
41 , eneHisto(("energy" + id).c_str(), ("energy" + id).c_str(), 300, 0., 300.)
42 , gainHisto(("gain" + id).c_str(), ("gain" + id).c_str(), 2, 0, 2)
43#endif
44
45#ifdef TileLaserTimingPMT0Mon
46 , TimeDiffHistoHigh(("dtime" + id + "hi").c_str(), ("dtime" + id + "hi").c_str(), 200, -40, 40)
47 , TimeDiffHistoLow(("dtime" + id + "lo").c_str(), ("dtime" + id + "lo").c_str(), 200, -60, 60)
48#endif
49
50#ifdef TileLaserTimingMonPulse
51 , pulseShapeHigh(("pulseShape_" + id + "hi").c_str(), ("pulseShape_" + id + "hi").c_str(), 400, -200., 300., 0, 100000.)
52 , pulseShapeLow(("pulseShape_" + id + "lo").c_str(), ("pulseShape_" + id + "lo").c_str(), 400, -200., 300., 0, 100000.)
53#endif
54
55 , TimeDiffResHis(("dtimeRes"+id).c_str(),("dtimeRes"+id).c_str(),1000,-40.,40.)
56 , time(0.0)
57
58#ifdef TileLaserTimingPMT0
59 , dtime(0.0)
60 , dtimeNoCFCorr(0.0)
61#endif
62
63 , energy(0.0)
64{
65}
66
74
79
81 m_mean_time = 0;
82 m_mean_rms = 0;
83
84 for (int i = 0; i < m_N_active; ++i) m_mean_time += m_ch_time[i];
85
87
88 for (int i = 0; i < m_N_active; ++i) m_mean_rms += sqr(m_ch_time[i] - m_mean_time);
89
90 m_mean_rms = m_mean_rms / ((float) m_N_active);
91 m_mean_rms = sqrt(m_mean_rms);
92}
93
95 : Digi0TimeDiffHisto(("TimeDiff" + id).c_str(), ("TimeDiff" + id).c_str(), 2000, -100., 100.)
96 , Digi0Time(("Digi0Time" + id).c_str(), ("Digi0Time" + id).c_str(), 2000, -100., 100.)
98{
99
100 for (int i = 0; i < 48; ++i) {
101 std::ostringstream sout;
102 sout << id << '_' << i;
103 pmtd[i] = new PMTData(sout.str());
104 }
105}
106
107
108// LBA | LBC
109// EBA | EBC
110float const TileLaserTimingTool::s_fiberLength[2][48] = {{167.1,167.1,178.7,178.7,190.3,190.3,201.9,201.9,213.5,213.5,
111 225.1,225.1,236.7,236.7,248.3,248.3,259.9,259.9,271.5,271.5,
112 283.1,283.1,294.7,294.7,201.9,201.9,213.5,213.5,225.1,225.1,
113 236.7,236.7,248.3,248.3,259.9,259.9,271.5,271.5,283.1,283.1,
114 294.7,294.7,306.3,306.3,317.9,317.9,329.6,329.6},
115
116 { 51.1, 51.1, 62.7, 62.7, 74.3, 74.3, 85.9, 85.9, 97.5, 97.5,
117 109.1,109.1,120.7,120.7,132.3,132.3,143.9,143.9,143.9,143.9,
118 167.1,167.1,178.1,178.1,178.1,178.1,178.1,178.1,213.5,213.5,
119 213.5,213.5,236.7,236.7,236.7,236.7,259.9,259.9,259.9,259.9,
120 283.1,283.1,294.7,294.7,294.7,294.7,294.7,294.7}};
121
122TileLaserTimingTool::TileLaserTimingTool(const std::string& type, const std::string& name, const IInterface* pParent)
123 : AthAlgTool(type, name, pParent)
124{
125
126 declareInterface<ITileCalibTool>( this );
127
128#ifdef TileLaserTimingMonPulse
129 // create mon histos
130 m_h1_time_check = new TH1F("h1_time_check", "Time(Tfit based) - Time(cispar based)", 1000, -200., 200.);
131 m_h2_time_check = new TH2F("h2_time_check", "Time(Tfit based) vs Time(cispar based)", 1000, -200., 200., 1000, -200., 200.);
132
133 m_PulseShapeHigh = new TProfile("pulse_shape_HG", "pulse shape HG", 400, -200., 300., 0, 100000.);
134 m_PulseShapeLow = new TProfile("pulse_shape_LG", "pulse shape LG", 400, -200., 300., 0, 100000.);
135#endif
136
137 // creating multi-dim arrays on the heap and initialize all elements to zeros
139
140 m_DrawerOffset = new float[NROS][NDRAWERS]();
141 m_DrawerOffsetError = new float[NROS][NDRAWERS]();
142
143 m_ChannelOffset = new float[NROS][NDRAWERS][NCHANNELS]();
145
146 m_ADCAmplitude = new float[NROS][NDRAWERS][NCHANNELS]();
147
148 m_PedestalMean = new float[NROS][NDRAWERS][NCHANNELS]();
149 m_PedestalSigma = new float[NROS][NDRAWERS][NCHANNELS]();
150
151 m_TimeDiffMean = new float[NROS][NDRAWERS][NCHANNELS]();
153 m_TimeDiffSigma = new float[NROS][NDRAWERS][NCHANNELS]();
154
155 m_MeanOddPmtTdiffPMT0 = new float[NROS][NDRAWERS]();
156 m_OddPmtCounterPMT0 = new int[NROS][NDRAWERS]();
157 m_MeanEvenPmtTdiffPMT0 = new float[NROS][NDRAWERS]();
158 m_EvenPmtCounterPMT0 = new int[NROS][NDRAWERS]();
159 m_EvenOddTimeDiffPMT0 = new float[NROS][NDRAWERS]();
160
161#ifdef TileLaserTimingPMT0Mon
162 m_TimeDiffHighMean = new float[NROS][NDRAWERS][NCHANNELS]();
163 m_TimeDiffHighMeanError = new float[NROS][NDRAWERS][NCHANNELS]();
164 m_TimeDiffHighSigma = new float[NROS][NDRAWERS][NCHANNELS]();
165
166 m_TimeDiffLowMean = new float[NROS][NDRAWERS][NCHANNELS]();
167 m_TimeDiffLowMeanError = new float[NROS][NDRAWERS][NCHANNELS]();
168 m_TimeDiffLowSigma = new float[NROS][NDRAWERS][NCHANNELS]();
169
170 m_TimeDiffNoCFCorrMean = new float[NROS][NDRAWERS][NCHANNELS]();
171 m_TimeDiffNoCFCorrMeanError = new float[NROS][NDRAWERS][NCHANNELS]();
172 m_TimeDiffNoCFCorrSigma = new float[NROS][NDRAWERS][NCHANNELS]();
173#endif
174
175 m_FiberLength = new float[NROS][NDRAWERS][NCHANNELS]();
176
177#ifdef TileLaserTimingMon
178 m_TimeDiffPMTDigi0 = new float[NROS][NDRAWERS][NCHANNELS]();
179 m_FiberCorrection = new float[NROS][NDRAWERS][NCHANNELS]();
180 m_IsConnected = new int[NROS][NDRAWERS][NCHANNELS]();
181
182 m_MeanOddPmtTdiff = new float[NROS][NDRAWERS]();
183 m_OddPmtCounter = new int[NROS][NDRAWERS]();
184 m_MeanEvenPmtTdiff = new float[NROS][NDRAWERS]();
185 m_EvenPmtCounter = new int[NROS][NDRAWERS]();
186
187 m_EvenOddTimeDiff = new float[NROS][NDRAWERS]();
188#endif
189
190 m_DSkewSet = new float[NROS][NDRAWERS][NDIGI]();
191 m_DigiMean = new float[NROS][NDRAWERS][NDIGI]();
192}
193
195
196 delete[] m_drawerData;
197 delete[] m_DrawerOffset;
198 delete[] m_DrawerOffsetError;
199 delete[] m_ChannelOffset;
200 delete[] m_ChannelOffsetError;
201 delete[] m_ADCAmplitude;
202 delete[] m_PedestalMean;
203 delete[] m_PedestalSigma;
204 delete[] m_TimeDiffMean;
205 delete[] m_TimeDiffMeanError;
206 delete[] m_TimeDiffSigma;
207 delete[] m_MeanOddPmtTdiffPMT0;
208 delete[] m_OddPmtCounterPMT0;
209 delete[] m_MeanEvenPmtTdiffPMT0;
210 delete[] m_EvenPmtCounterPMT0;
211 delete[] m_EvenOddTimeDiffPMT0;
212#ifdef TileLaserTimingPMT0Mon
213 delete[] m_TimeDiffHighMean;
214 delete[] m_TimeDiffHighMeanError;
215 delete[] m_TimeDiffHighSigma;
216 delete[] m_TimeDiffLowMean;
217 delete[] m_TimeDiffLowMeanError;
218 delete[] m_TimeDiffLowSigma;
219 delete[] m_TimeDiffNoCFCorrMean;
220 delete[] m_TimeDiffNoCFCorrMeanError;
221 delete[] m_TimeDiffNoCFCorrSigma;
222#endif
223
224 delete[] m_FiberLength;
225
226#ifdef TileLaserTimingMon
227 delete[] m_TimeDiffPMTDigi0;
228 delete[] m_FiberCorrection;
229 delete[] m_IsConnected;
230 delete[] m_MeanOddPmtTdiff;
231 delete[] m_OddPmtCounter;
232 delete[] m_MeanEvenPmtTdiff;
233 delete[] m_EvenPmtCounter;
234 delete[] m_EvenOddTimeDiff;
235#endif
236 delete[] m_DSkewSet;
237 delete[] m_DigiMean;
238}
239
240
241
243
244 ATH_MSG_INFO( "initialize()" );
245
246 // get TileHWID helper
247 CHECK( detStore()->retrieve(m_tileHWID) );
248
249 // get the timing tool
250 CHECK( m_tileToolTiming.retrieve() );
251
252 // get TileCabling Service
254
255 m_nevts = 0;
256
257 ATH_CHECK( m_eventInfoKey.initialize() );
258 ATH_CHECK( m_rawChannelContainerKey.initialize() );
259 ATH_CHECK( m_digitsContainerKey.initialize() );
260
261 // gauss fit function
262 m_gaussf = new TF1("GainGauss", "[0]*exp(- (x-[1])*(x-[1])/(2*[2]*[2]))", -60, 60);
263
264 ATH_MSG_DEBUG( "initialize() ready " );
265
276
277 return StatusCode::SUCCESS;
278}
279
280StatusCode TileLaserTimingTool::initNtuple(int runNumber, int runType, TFile * rootFile) {
281
282 ATH_MSG_INFO( "initNtuple(" << runNumber << "," << runType << "," << rootFile << ")" );
283
284 return StatusCode::SUCCESS;
285}
286
287// conv factor from low gain to high gain
288//const float LG2HG = 64.;
289
294
295 ATH_MSG_DEBUG( "execute()" );
296
297 gROOT->cd();
298
299 // Get event's CIS parameters
300 // QQQ: const uint32_t *cispar = m_beamInfo->cispar();
301 // QQQ: const uint32_t dac = cispar[6];
302 // QQQ: const uint32_t phase = cispar[5];
303 // QQQ: const uint32_t cap = cispar[7];
304
305 // Get EventInfo
307 ATH_CHECK( eventInfo.isValid() );
308
309
310 // QQQ: const unsigned runNumber = eventInfo->runNumber();
311 // QQQ: const unsigned eventNumber = eventInfo->eventNumber();
312
313 // Check if event should be used in calibration
314 bool pass = true;
315
316 // Get TileRawChannelContainer
318 ATH_CHECK( container.isValid() );
319
320 // Get TileDigitsContainer
322 ATH_CHECK( digitsCnt.isValid() );
323
324 // Create iterator over RawChannelContainer
325 TileRawChannelContainer::const_iterator itColl = (*container).begin();
326 TileRawChannelContainer::const_iterator itCollEnd = (*container).end();
328
329 // tmp vars
330 const TileDigitsCollection *digiColl = nullptr;
331 const TileDigits* digits;
332 const TileRawChannel *rawch = nullptr;
333 float dtime, dtimeNoCFCorr;
334
335#ifdef TileLaserTimingMonPulse
336 float f_SampleTime, f_phase1, f_phase2, f_time, f_tfittime;
337#endif
338
339 size_t colls;
340 int Nconnected;
341 float ChannelOffset;
342
343 DrawerData *ddata = nullptr;
344
345 unsigned frag;
346 if (pass) {
347 m_nevts++;
348
349 // Go through all TileRawChannelCollections
350 for (; itColl != itCollEnd; ++itColl) {
351 // Get the digits collection for the drawer corresponding to the raw channel
352 frag = (*itColl)->identify();
353 const auto *digiCollIt = digitsCnt->indexFindPtr(digitsCnt->hashFunc()(frag));
354 if (digiCollIt == nullptr) {
355 ATH_MSG_ERROR( " unable to get TileDigitsCollection for drawer:" << drawerIdStr(frag) );
356
357 } else {
358 digiColl = digiCollIt;
359 colls = (*itColl)->size();
360 ATH_MSG_VERBOSE( "execute() colls:" << colls
361 << " digiColl->size:" << digiColl->size()
362 << " drawer:" << drawerIdStr((*itColl)->identify()) );
363
364 if (digiColl->size() != colls) {
365 ATH_MSG_ERROR( " size of TileDigitsCollection and TileRawChannelCollection differ for drawer:" << drawerIdStr((*itColl)->identify()) );
366
367 } else {
368 // ZZZ: Assume the first RawChannel in the collection corresponds to PMT 0
369 // ZZZ: if this is not the case (for some reason) there will be a nasty segflt
370
371 // get drawer HWID
372 HWIdentifier dhwid = drawerId((*itColl)->identify());
373 // LBA=1 LBC=2 EBA=3 EBC=4
374 int ros = m_tileHWID->ros(dhwid);
375 // 0 to 63
376 int drawer = m_tileHWID->drawer(dhwid);
377 // get and create DrawerData if needed, cannot be null
378 ddata = drawerData(ros, drawer);
379 // store ref to first PMT
380 PMTData &pmt0data = *ddata->pmtd[0];
381
382 for (size_t i = 0; i < colls; ++i) {
383 digits = digiColl->at(i);
384 rawch = (*itColl)->at(i);
385
386 // require both digits and raw channels with equal ids
387 if (!digits || !rawch || (digits->identify() != rawch->identify())) {
388 if (!digits) {
389 ATH_MSG_ERROR( " no TileDigits for drawer:" << drawerIdStr((*itColl)->identify()) );
390 }
391
392 if (!rawch) {
393 ATH_MSG_ERROR( " no TileRawChannel for drawer:" << drawerIdStr((*itColl)->identify()) );
394 }
395
396 if (rawch && digits) {
397 ATH_MSG_ERROR( " no id mismatch for drawer:" << drawerIdStr((*itColl)->identify()) );
398 }
399
400 } else {
401 // get hardware id to identify adc
402 HWIdentifier hwid = rawch->adc_HWID();
403 // int ros = m_tileHWID->ros(hwid); // LBA=1 LBC=2 EBA=3 EBC=4
404 // int drawer = m_tileHWID->drawer(hwid); // 0 to 63
405 const int chan = m_tileHWID->channel(hwid); // 0 to 47 channel not PMT
406 const int gain = m_tileHWID->adc(hwid); // low=0 high=1
407 const int ipmt = channel2PMT(ros, chan);
408
409 // store Fit data
410 PMTData &pmtdata = *ddata->pmtd[ipmt];
411 pmtdata.time = rawch->time();
412 pmtdata.energy = rawch->amplitude();
413 pmtdata.pedestal.add(rawch->pedestal());
414
415 // in case of the first PMT (i.e. 0) this will be 0 as per definition
416 dtimeNoCFCorr = pmtdata.time - pmt0data.time;
417 dtime = dtimeNoCFCorr - fiberCorrection(ros, ipmt);
418 pmtdata.TimeDiffHisto.Fill(dtime);
419
420#ifdef TileLaserTimingPMT0
421 pmtdata.TimeDiffNoCFCorrHisto.Fill(dtimeNoCFCorr);
422
423 if(gain == 0) pmtdata.TimeDiffHistoLow.Fill(dtime);
424 else pmtdata.TimeDiffHistoHigh.Fill(dtime);
425#endif
426
427#ifdef TileLaserTimingMon
428 pmtdata.timeHisto.Fill(pmtdata.time);
429 pmtdata.eneHisto.Fill(pmtdata.energy);
430 pmtdata.gainHisto.Fill(gain);
431#endif
432
433 // pulse data-->
434#ifdef TileLaserTimingMonPulse
435 if(isConnectedChan(ros, chan)) {
436 std::vector<float> sample = digits->samples();
437 if(sample.size() != m_nSamples) {
438 ATH_MSG_ERROR( " sample size mismatch for drawer:" << drawerIdStr(frag)
439 <<" in:" << sample.size() << " expected:" << m_nSamples.value() );
440 } else {
441 for (unsigned jsample = 0; jsample < m_nSamples; ++jsample) {
442 f_SampleTime = ((float) jsample) * 25.;
443 f_phase1 = (25. * ((float) phase)) / (30. * 8);
444 f_phase2 = -pmtdata.time;
445 f_time = f_SampleTime + f_phase1 - 100;
446 f_tfittime = f_SampleTime + f_phase2 - 100;
447 if (phase >= 160) {
448 f_time -= 25;
449 f_phase1 -= 25;
450 }
451
452 if (phase < 140 || phase > 160) {
453 // if Low gain convert to the HG scale
454 if (gain == 0) {
455 m_h1_time_check->Fill(f_phase1 - f_phase2);
456 m_h2_time_check->Fill(f_phase1, f_phase2);
457
458 if (fabs(pmtdata.energy) > m_eneLowLimitPulseShape) {
459 pmtdata.pulseShapeLow.Fill(f_tfittime, (LG2HG * (sample[jsample] - rawch->pedestal())));
460 }
461 }
462 //HG
463 else if (fabs(pmtdata.energy) > m_eneLowLimitPulseShape) {
464 pmtdata.pulseShapeHigh.Fill(f_tfittime, (sample[jsample] - rawch->pedestal()));
465 }
466 } // if Cispar not in 140->160 (range with time jitter,
467 //difficult to handle for smooth pulse shape
468 }
469 } // end loop over jsample
470 } // end if PMT is connected
471#endif
472 // <--pulse data
473
474 } // else: ok digits and raw channels
475 } // end collection loop
476
477 //=====================================================================================
478 //=== Compute mean Tfit (corrected for laser fiber length) over the first digitizer ===
479 //=====================================================================================
480 Nconnected = 0;
481 ddata->FarDigitizerMeanTime = 0.;
482 for (int ipmt = 0; ipmt < 6; ++ipmt) {
483 if (isConnectedPMT(ros, ipmt)) {
484 ddata->FarDigitizerMeanTime += (ddata->pmtd[ipmt]->time - fiberCorrection(ros, ipmt));
485 Nconnected++;
486 }
487 }
488 if (Nconnected)
489 ddata->FarDigitizerMeanTime /= (float) Nconnected;
490
491#ifdef TileLaserTimingMon
492 ddata->Digi0Time.Fill(ddata->FarDigitizerMeanTime);
493#endif
494
495 if (msgLvl(MSG::VERBOSE) && (ros == 1) && (drawer == 1)) {
496 ATH_MSG_VERBOSE( " ddata->FarDigitizerMeanTime:" << ddata->FarDigitizerMeanTime );
497 }
498
499 //============================================================================
500 //=== Calculate residuals. Fill histos with time diff b/w PMT i and digi 1 ===
501 //============================================================================
502 for (int ipmt = 0; ipmt < NCHANNELS; ipmt++) {
503 if (isConnectedPMT(ros, ipmt)) {
504 ChannelOffset = -(ddata->pmtd[ipmt]->time - fiberCorrection(ros, ipmt) - ddata->FarDigitizerMeanTime);
505 ddata->pmtd[ipmt]->TimeDiffResHis.Fill(ChannelOffset);
506 if (msgLvl(MSG::VERBOSE) && (ros == 1) && (drawer == 1)) {
507 ATH_MSG_VERBOSE( " ipmt:" << ipmt << " ChannelOffset:" << ChannelOffset );
508 }
509 }
510 }
511
512 } // else: matching digits and raw channel collections
513 }
514 } // end container loop
515
516 //=====================================================================================
517 //=== this histogram contains the difference between first digitizer of drawer 1 and drawer 2: drawer offset
518 //=====================================================================================
519 for (unsigned int ros = 1; ros < TileCalibUtils::MAX_ROS; ++ros) {
520 if (drawerData(ros, m_refDrawer)) {
521 DrawerData &drawer0data = *drawerData(ros, m_refDrawer);
522 for (unsigned int drawer = 0; drawer < TileCalibUtils::MAX_DRAWER; ++drawer) {
523 if ((drawer != m_refDrawer) && drawerData(ros, drawer)) {
524 DrawerData &ddata = *drawerData(ros, drawer);
525 ddata.Digi0TimeDiffHisto.Fill( ddata.FarDigitizerMeanTime - drawer0data.FarDigitizerMeanTime);
526
527 if (msgLvl(MSG::VERBOSE) && (ros == 1) && (drawer == 1)) {
528 ATH_MSG_VERBOSE( " drawerdiff:" << ddata.FarDigitizerMeanTime - drawer0data.FarDigitizerMeanTime );
529 }
530 }
531 }
532 }
533 }
534 }
535
536 return StatusCode::SUCCESS;
537}
538
540
541 ATH_MSG_INFO( "finalizeCalculations()" );
542
543 gROOT->cd();
544
545 float fmean, fdummy, fchi2, fmeanerr;
546
547 for (unsigned int ros = 1; ros < TileCalibUtils::MAX_ROS; ++ros) {
548 for (unsigned int drawer = 0; drawer < TileCalibUtils::MAX_DRAWER; ++drawer) {
549 DrawerData &drawerd = *drawerData(ros, drawer);
550
551 for (int ipmt = 0; ipmt < NCHANNELS; ++ipmt) {
552 PMTData &pmtd = *drawerd.pmtd[ipmt];
553 // to simplify the root analysis, store the fiber length, not really neccessary
554 m_FiberLength[ros][drawer][ipmt] = fiberLength(ros, ipmt);
555#ifdef TileLaserTimingMon
556 m_FiberCorrection[ros][drawer][ipmt] = fiberCorrection(ros, ipmt);
557 m_IsConnected[ros][drawer][ipmt] = isConnectedPMT(ros, ipmt);
558#endif
559 //==========================================================================================
560 //==== Pulse shapes ====
561
562 // use the number of entries in the histos as the number of passed events for high/low
563
564#ifdef TileLaserTimingMonPulse
565 if(pmtd.TimeDiffHistoLow.GetEntries() > 0.99 * m_nevts) {
566 m_PulseShapeLow->Add(&pmtd.pulseShapeLow);
567 }
568
569 if(pmtd.TimeDiffHistoHigh.GetEntries() > 0.99 * m_nevts) {
570 m_PulseShapeHigh->Add(&pmtd.pulseShapeHigh);
571 }
572#endif
573
574 if (ipmt > 0) {
575 //==================================================================
576 // Fit time difference regardless of gain, to derive standard Dskews
577 //==================================================================
578 if (isConnectedPMT(ros, ipmt)) {
579 fitGauss(pmtd.TimeDiffHisto, m_TimeDiffMean[ros][drawer][ipmt], m_TimeDiffSigma[ros][drawer][ipmt], m_TimeDiffMeanError[ros][drawer][ipmt]);
580 }
581
582#ifdef TileLaserTimingPMT0
583 //===========================================================
584 //=== Fit time difference without clear fiber corrections ===
585 //===========================================================
586 if(isConnectedPMT(ros, ipmt)) {
587 fitGauss(pmtd.TimeDiffNoCFCorrHisto, m_TimeDiffNoCFCorrMean[ros][drawer][ipmt], m_TimeDiffNoCFCorrSigma[ros][drawer][ipmt], m_TimeDiffNoCFCorrMeanError[ros][drawer][ipmt]);
588 }
589
590 //================================================================================
591 //==== Fit gauss to time differences in all gains/ low gain/ high gain in all PMTs
592 //================================================================================
593
594 fitGauss(pmtd.TimeDiffHistoLow, m_TimeDiffLowMean[ros][drawer][ipmt], m_TimeDiffLowSigma[ros][drawer][ipmt], m_TimeDiffLowMeanError[ros][drawer][ipmt]);
595
596 //------------------------------------- For high gain --------------------------------------
597
598 fitGauss(pmtd.TimeDiffHistoHigh, m_TimeDiffHighMean[ros][drawer][ipmt], m_TimeDiffHighSigma[ros][drawer][ipmt], m_TimeDiffHighMeanError[ros][drawer][ipmt]);
599#endif
600 }
601
602 //==================================================================================
603 //=== Fit mean value of time difference b/w drawer_i(pmt_j) and drawer_i(digi_1) ===
604 //==================================================================================
605
606 // TODO: previous values on error
607 if (isConnectedPMT(ros, ipmt)) {
609 m_TimeDiffPMTDigi0[ros][drawer][ipmt] = m_ChannelOffset[ros][drawer][ipmt] = pmtd.TimeDiffResHis.GetMean();
610 m_ChannelOffsetError[ros][drawer][ipmt] = pmtd.TimeDiffResHis.GetMeanError();
611 } else {
612 fitGauss2(pmtd.TimeDiffResHis, fmean, fdummy, fchi2, fmeanerr, 1.0, 3.0);
613
614 if (fchi2 > 500) {
615 ATH_MSG_WARNING( "pmt # " << ipmt + 1
616 << " has chi2 value " << fchi2
617 << " force timing residual same as PMT-1 " );
618
619 // FittedMean=PreviousFittedMean;
620 fchi2 = -fchi2; // just to make Coverity happt
621 fmean = -4711;
622 fmeanerr = 0.0;
623 }
624 if (fabs(fmean) > 100) {
625 ATH_MSG_WARNING( " pmt # " << ipmt + 1
626 << " has ChannelOffset " << fmean
627 << " force timing residual same as PMT-1" );
628
629 // FittedMean=PreviousFittedMean;
630 fmean = -4711;
631 fmeanerr = 0.0;
632 }
633 m_ChannelOffset[ros][drawer][ipmt] = fmean;
634 m_ChannelOffsetError[ros][drawer][ipmt] = fmeanerr;
635 }
636 } else {
637 m_ChannelOffset[ros][drawer][ipmt] = 0.0;
638 m_ChannelOffsetError[ros][drawer][ipmt] = 0.0;
639 }
640
641#ifdef TileLaserTimingMonPulse
642 //===========================================================
643 //=== Pedestal and ADC Amplitudes ===
644 //===========================================================
645 pmtd.pedestal.getStat(m_PedestalMean[ros][drawer][ipmt], m_PedestalSigma[ros][drawer][ipmt]);
646 if (isConnectedPMT(ros, ipmt))
647 m_ADCAmplitude[ros][drawer][ipmt] = fmax(pmtd.pulseShapeHigh.GetMaximum(), pmtd.pulseShapeLow.GetMaximum());
648 else
649 m_ADCAmplitude[ros][drawer][ipmt] = 0.;
650
651 if (msgLvl(MSG::VERBOSE) && (ros == 1) && (drawer == 1)) {
652 msg(MSG::VERBOSE) << "ipmt: " << ipmt
653 << " TimeDiffLow: " << m_TimeDiffLowMean[ros][drawer][ipmt] << "(" << m_TimeDiffLowSigma[ros][drawer][ipmt] << ") +-" << m_TimeDiffLowMeanError[ros][drawer][ipmt]
654 << " TimeDiffHigh:" << m_TimeDiffHighMean[ros][drawer][ipmt] << "(" << m_TimeDiffHighSigma[ros][drawer][ipmt] << ") +-" << m_TimeDiffHighMeanError[ros][drawer][ipmt] << endmsg;
655
656 msg(MSG::VERBOSE) << " TimeDiff:" << m_TimeDiffMean[ros][drawer][ipmt] << "(" << m_TimeDiffSigma[ros][drawer][ipmt] << ") +-" << m_TimeDiffMeanError[ros][drawer][ipmt]
657 << " TomeDiffNoCF:" << m_TimeDiffNoCFCorrMean[ros][drawer][ipmt] << "(" << m_TimeDiffNoCFCorrSigma[ros][drawer][ipmt] << ") +-" << m_TimeDiffNoCFCorrMeanError[ros][drawer][ipmt] << endmsg;
658
659 msg(MSG::VERBOSE) << " ped:" << m_PedestalMean[ros][drawer][ipmt] << "(" << m_PedestalSigma[ros][drawer][ipmt]
660 << ") amp:" << m_ADCAmplitude[ros][drawer][ipmt] << endmsg;
661 }
662#endif
663
664 } // end PMT loop
665
666 //============================================
667 //========= Fit mean DrawerOffset ============
668 //============================================
669
670 fitGauss2(drawerd.Digi0TimeDiffHisto, m_DrawerOffset[ros][drawer], fdummy, fdummy, m_DrawerOffsetError[ros][drawer], 0.5, 1.0);
671
672 ATH_MSG_DEBUG( "finalizeCalculations()"
673 << " ros: " << ros
674 << " drawer:" << drawer
675 << " DrawerOffset:" << m_DrawerOffset[ros][drawer] << "("
676 << m_DrawerOffsetError[ros][drawer] << ")" );
677
678 //==============================================================
679 //=== correct for overall offset between odd and even fibers ===
680 //
681 // Better would be to meassure the laser fiber lengths and
682 // implement this as a correction. Meanwhile, use this as
683 // a compromise.
684 //==============================================================
685 // CCC: MeanEvenPmtTdiff= 0;
686 // CCC: MeanOddPmtTdiff = 0;
687 // CCC: DeltaParity = 0;
688 // CCC: OddPmtCounter =0;
689 // CCC: EvenPmtCounter =0;
690
692
694
696
697 //==================================================================
698 //=== Calculate Dskews ===
699 //==================================================================
700 for (int ipmt = 0; ipmt < NCHANNELS; ++ipmt) {
701 // LBA and LBC
702 if (isBarrel(ros)) {
703 if (isConnectedPMT(ros, ipmt) && (timeDiffs[ros][drawer][ipmt] < 300)) {
704 drawerd.digid[ipmt / 6].Add(timeDiffs[ros][drawer][ipmt]);
705 }
706 if (ipmt % 6 == 5) {
707 drawerd.digid[ipmt / 6].Freeze();
708 }
709 } // end isBarrel
710 // EBA and EBC%
711 else if (isExtBarrel(ros)) {
712 if (isConnectedPMT(ros, ipmt) && (timeDiffs[ros][drawer][ipmt] < 300)) {
713 if (ipmt < 6) drawerd.digid[0].Add(timeDiffs[ros][drawer][ipmt]);
714 else if (ipmt > 5 && ipmt < 12) drawerd.digid[1].Add(timeDiffs[ros][drawer][ipmt]);
715 else if (ipmt > 11 && ipmt < 18) drawerd.digid[2].Add(timeDiffs[ros][drawer][ipmt]);
716 else if (ipmt > 17 && ipmt < 24) drawerd.digid[3].Add(timeDiffs[ros][drawer][ipmt]);
717 else if (ipmt > 27 && ipmt < 34) {
718 drawerd.digid[4].Add(timeDiffs[ros][drawer][ipmt]);
719 drawerd.digid[5].Add(timeDiffs[ros][drawer][ipmt]);
720 } else if (ipmt > 35) {
721 drawerd.digid[6].Add(timeDiffs[ros][drawer][ipmt]);
722 drawerd.digid[7].Add(timeDiffs[ros][drawer][ipmt]);
723 }
724 }
725
726 if (ipmt == 5) drawerd.digid[0].Freeze();
727 else if (ipmt == 11) drawerd.digid[1].Freeze();
728 else if (ipmt == 17) drawerd.digid[2].Freeze();
729 else if (ipmt == 23) drawerd.digid[3].Freeze();
730 else if (ipmt == 33) {
731 drawerd.digid[4].Freeze();
732 drawerd.digid[5].Freeze();
733 } else if (ipmt == 47) {
734 drawerd.digid[6].Freeze();
735 drawerd.digid[7].Freeze();
736 }
737 } // end isExtBarrel
738 } // end PMT loop
739
740 for (int digi = 0; digi < NDIGI; ++digi) {
741 m_DigiMean[ros][drawer][digi] = drawerd.digid[digi].GetDigiTime();
742 m_DSkewSet[ros][drawer][digi] = (m_DigiMean[ros][drawer][digi] - m_DigiMean[ros][drawer][0]) * 240. / 25.;
743
744 ATH_MSG_DEBUG( "finalizeCalculations()"
745 << " ros: " << ros
746 << " drawer: " << drawer
747 << " digi: " << digi
748 << " digi_time: " << drawerd.digid[digi].GetDigiTime()
749 << " #active: " << drawerd.digid[digi].GetTotActive()
750 << " DSkewSet: " << m_DSkewSet[ros][drawer][digi] );
751
752 }
753 } // end drawer loop
754 } // end ros loop
755
756 return StatusCode::SUCCESS;
757}
758
759StatusCode TileLaserTimingTool::writeNtuple(int runNumber, int runType, TFile* rootFile) {
760
761 ATH_MSG_INFO( "writeNtuple(" << runNumber << "," << runType << "," << rootFile << ")" );
762
763 // Write a tree with all arrays
764 TTree *t = new TTree(m_ntupleID.value().c_str(), "TileLaserTimingNtuple");
765 t->Branch("DrawerOffset", m_DrawerOffset, "DrawerOffset[5][64]/F"); // float m_DrawerOffset[s_NRos][64];
766 t->Branch("DrawerOffsetError", m_DrawerOffsetError, "DrawerOffsetError[5][64]/F"); // float m_DrawerOffsetError[NROS][64];
767
768 t->Branch("ChannelOffset", m_ChannelOffset, "ChannelOffset[5][64][48]/F"); // float m_ChannelOffset[NROS][64][48];
769 t->Branch("ChannelOffsetError", m_ChannelOffsetError, "ChannelOffsetError[5][64][48]/F"); // float m_ChannelOffsetError[NROS][64][48];
770
771 t->Branch("ADCAmplitude", m_ADCAmplitude, "ADCAmplitude[5][64][48]/F"); // float m_ADCAmplitude[NROS][64][48];
772
773 t->Branch("PedestalMean", m_PedestalMean, "PedestalMean[5][64][48]/F"); // float m_PedestalMean[NROS][64][48];
774 t->Branch("PedestalSigma", m_PedestalSigma, "PedestalSigma[5][64][48]/F"); // float m_PedestalSigma[NROS][64][48];
775
776 t->Branch("TimeDiffMean", m_TimeDiffMean, "TimeDiffMean[5][64][48]/F"); // float m_TimeDiffMean[NROS][64][48];
777 t->Branch("TimeDiffMeanError", m_TimeDiffMeanError, "TimeDiffMeanError[5][64][48]/F"); // float m_TimeDiffMeanError[NROS][64][48];
778 t->Branch("TimeDiffSigma", m_TimeDiffSigma, "TimeDiffSigma[5][64][48]/F"); // float m_TimeDiffSigma[NROS][64][48];
779
780#ifdef TileLaserTimingPMT0Mon
781 t->Branch("TimeDiffHighMean", m_TimeDiffHighMean, "TimeDiffHighMean[5][64][48]/F"); // float m_TimeDiffHighMean[NROS][64][48];
782 t->Branch("TimeDiffHighMeanError", m_TimeDiffHighMeanError, "TimeDiffHighMeanError[5][64][48]/F"); // float m_TimeDiffHighMeanError[NROS][64][48];
783 t->Branch("TimeDiffHighSigma", m_TimeDiffHighSigma, "TimeDiffHighSigma[5][64][48]/F"); // float m_TimeDiffHighSigma[NROS][64][48];
784 t->Branch("TimeDiffLowMean", m_TimeDiffLowMean, "TimeDiffLowMean[5][64][48]/F"); // float m_TimeDiffLowMean[NROS][64][48];
785 t->Branch("TimeDiffLowMeanError", m_TimeDiffLowMeanError, "TimeDiffLowMeanError[5][64][48]/F"); // float m_TimeDiffLowMeanError[NROS][64][48];
786 t->Branch("TimeDiffLowSigma", m_TimeDiffLowSigma, "TimeDiffLowSigma[5][64][48]/F"); // float m_TimeDiffLowSigma[NROS][64][48];
787 t->Branch("TimeDiffNoCFCorrMean", m_TimeDiffNoCFCorrMean, "TimeDiffNoCFCorrMean[5][64][48]/F"); // float m_TimeDiffNoCFCorrMean[NROS][64][48];
788 t->Branch("TimeDiffNoCFCorrMeanError", m_TimeDiffNoCFCorrMeanError, "TimeDiffNoCFCorrMeanError[5][64][48]/F"); // float m_TimeDiffNoCFCorrMeanError[NROS][64][48];
789 t->Branch("TimeDiffNoCFCorrSigma", m_TimeDiffNoCFCorrSigma, "TimeDiffNoCFCorrSigma[5][64][48]/F"); // float m_TimeDiffNoCFCorrSigma[NROS][64][48];
790#endif
791 t->Branch("FiberLength", m_FiberLength, "FiberLength[5][64][48]/F"); // float m_FiberLength[NROS][64][48];
792
793#ifdef TileLaserTimingMon
794 t->Branch("EvenOddTimeDiff", m_EvenOddTimeDiff, "EvenOddTimeDiff[5][64]/F"); // float m_EvenOddTimeDiff[NROS][64];
795
796 t->Branch("FiberCorrection", m_FiberCorrection, "FiberCorrection[5][64][48]/F"); // float m_FiberCorrection[NROS][64][48];
797 t->Branch("IsConnected", m_IsConnected, "IsConnected[5][64][48]/F"); // float m_FiberCorrection[NROS][64][48];
798
799 t->Branch("MeanOddPmtTdiff", m_MeanOddPmtTdiff, "MeanOddPmtTdiff[5][64]/F");
800 t->Branch("OddPmtCounter", m_OddPmtCounter, "OddPmtCounter[5][64]/I");
801 t->Branch("MeanEvenPmtTdiff", m_MeanEvenPmtTdiff, "MeanEvenPmtTdiff[5][64]/F");
802 t->Branch("EvenPmtCounter", m_EvenPmtCounter, "EvenPmtCounter[5][64]/I");
803
804 t->Branch("TimeDiffPMTDigi0", m_TimeDiffPMTDigi0, "TimeDiffPMTDigi0[5][64][48]/F");
805#endif
806
807 // mon pmt0-->
808 t->Branch("EvenOddTimeDiffPMT0", m_EvenOddTimeDiffPMT0, "EvenOddTimeDiffPMT0[5][64]/F");
809 t->Branch("MeanOddPmtTdiffPMT0", m_MeanOddPmtTdiffPMT0, "MeanOddPmtTdiffPMT0[5][64]/F");
810 t->Branch("OddPmtCounterPMT0", m_OddPmtCounterPMT0, "OddPmtCounterPMT0[5][64]/I");
811 t->Branch("MeanEvenPmtTdiffPMT0", m_MeanEvenPmtTdiffPMT0, "MeanEvenPmtTdiffPMT0[5][64]/F");
812 t->Branch("EvenPmtCounterPMT0", m_EvenPmtCounterPMT0, "EvenPmtCounterPMT0[5][64]/I");
813 // <-- mon pmt0
814
815 t->Branch("DSkewSet", m_DSkewSet, "DSkewSet[5][64][8]/F"); // float m_DSkewSet[NROS][64][8];
816 t->Branch("DigiMean", m_DigiMean, "DigiMean[5][64][8]/F"); // float m_DigiMean[NROS][64][8];
817 t->Fill();
818 rootFile->cd();
819 t->Write();
820
821 ATH_MSG_INFO( "writeNtuple(" << runNumber << "," << runType << "," << rootFile << ") data written" );
822
823 rootFile->ls();
824
825 // store histos
826 for (unsigned int ros = 1; ros < TileCalibUtils::MAX_ROS; ++ros) {
827 for (unsigned int drawer = 0; drawer < TileCalibUtils::MAX_DRAWER; ++drawer) {
828 ATH_MSG_VERBOSE( "writeNtuple() ros:" << ros << " drawer:" << drawer );
829
830 DrawerData* dd = drawerData(ros, drawer);
831 if (dd) {
832 dd->Digi0TimeDiffHisto.Write();
833#ifdef TileLaserTimingMon
834 dd->Digi0Time.Write();
835#endif
836 for (int ipmt = 0; ipmt < NCHANNELS; ++ipmt) {
837 if (isConnectedPMT(ros, ipmt)) {
838 /*dd->pmtd[ipmt]->TimeDiffHisto.Write();
839 dd->pmtd[ipmt]->TimeDiffNoCFCorrHisto.Write();*/
840#ifdef TileLaserTimingMon
841 dd->pmtd[ipmt]->timeHisto.Write();
842 dd->pmtd[ipmt]->eneHisto.Write();
843 dd->pmtd[ipmt]->gainHisto.Write();
844#endif
845 /*dd->pmtd[ipmt]->TimeDiffHistoHigh.Write();
846 dd->pmtd[ipmt]->pulseShapeHigh.Write();
847 dd->pmtd[ipmt]->TimeDiffHistoLow.Write();
848 dd->pmtd[ipmt]->pulseShapeLow.Write();*/
849 dd->pmtd[ipmt]->TimeDiffResHis.Write();
850 }
851 }
852 }
853 }
854 }
855
856 return StatusCode::SUCCESS;
857}
858
860
861 ATH_MSG_INFO( "finalize()" );
862
863 return StatusCode::SUCCESS;
864}
865
866
867
868bool TileLaserTimingTool::isConnectedPMT(int ros, int ipmt) {
869 if (isBarrel(ros)) {
870 return !(ipmt == 31 || ipmt == 32 || ipmt == 43);
871 } else if (isExtBarrel(ros)) {
872 return !( ipmt == 18 || ipmt == 19 || ipmt == 24 || ipmt == 25
873 || ipmt == 26 || ipmt == 27 || ipmt == 30 || ipmt == 31
874 || ipmt == 34 || ipmt == 35 || ipmt == 38 || ipmt == 39
875 || ipmt == 44 || ipmt == 45 || ipmt == 46 || ipmt == 47);
876 }
877
878 return false;
879}
880
881
882void TileLaserTimingTool::fitGauss(TH1F &hi, float &p1, float &p2, float &p1_err) {
883
884 if (hi.GetEntries() == 0) {
885 p1 = p2 = p1_err = 0.0;
886 return;
887 }
888 double MaxAmplitude = hi.GetMaximum();
889 double MeanTimeDiff = hi.GetMean();
890 double RMSTimeDiff = hi.GetRMS();
891 m_gaussf->SetParameter(0, MaxAmplitude);
892 m_gaussf->SetParameter(1, MeanTimeDiff);
893 m_gaussf->SetParameter(2, RMSTimeDiff);
894 m_gaussf->SetRange(MeanTimeDiff - 2.0 * RMSTimeDiff, MeanTimeDiff + 2.0 * RMSTimeDiff);
895
896 hi.Fit(m_gaussf, "QR");
897
898 p1 = m_gaussf->GetParameter(1);
899 p1_err = m_gaussf->GetParError(1);
900 p2 = m_gaussf->GetParameter(2);
901}
902
903void TileLaserTimingTool::fitGauss2(TH1F &hi, float &p1, float &p2, float &chi2, float &p1_err, float w1, float w2) {
904
905 if (hi.GetEntries() == 0) {
906 p1 = p2 = chi2 = p1_err = w1 = w2 = 0.0;
907 return;
908 }
909
910 double MaxAmplitude = hi.GetMaximum();
911 double MeanTimeDiff = hi.GetMean();
912 double RMSTimeDiff = hi.GetRMS();
913
914 m_gaussf->SetParameter(0, MaxAmplitude);
915 m_gaussf->SetParameter(1, MeanTimeDiff);
916 m_gaussf->SetParameter(2, RMSTimeDiff);
917 m_gaussf->SetRange(MeanTimeDiff - w1 * RMSTimeDiff, MeanTimeDiff + w1 * RMSTimeDiff);
918
919 hi.Fit(m_gaussf, "QR");
920 double FittedAmplitude = m_gaussf->GetParameter(0);
921 double FittedMean = m_gaussf->GetParameter(1);
922 double FittedSigma = m_gaussf->GetParameter(2);
923
924 //=== Iterate once ===
925
926 m_gaussf->SetParameter(0, FittedAmplitude);
927 m_gaussf->SetParameter(1, FittedMean);
928 m_gaussf->SetParameter(2, FittedSigma);
929 m_gaussf->SetRange(FittedMean - w2 * FittedSigma, FittedMean + w2 * FittedSigma);
930
931 hi.Fit(m_gaussf, "QR");
932 p1 = m_gaussf->GetParameter(1);
933 p2 = m_gaussf->GetParameter(2);
934 p1_err = m_gaussf->GetParError(1);
935 chi2 = m_gaussf->GetChisquare();
936}
937
938void TileLaserTimingTool::correctEvenOddPMT(int ros, int drawer, TPMTArray& ChannelOffset
939 , TDrawerArrayF& MeanOddPmtTdiff, TDrawerArrayI& OddPmtCounter
940 , TDrawerArrayF& MeanEvenPmtTdiff, TDrawerArrayI& EvenPmtCounter
941 , TDrawerArrayF& EvenOddTimeDiff) {
942
943
944 float DeltaParity = 0;
945
946 //=== determine overall shift between odd and even fibers ===
947 //=== for this take only into account channels with connected PMT
948 //=== don't take into the mean the value of tdiff when it is too far from zero
949 for (int ipmt = 0; ipmt < NCHANNELS; ++ipmt) {
950 if (isConnectedPMT(ros, ipmt)) {
951 if (ipmt % 2 == 1) {
952 // odd PMTs
953 if (fabs(ChannelOffset[ros][drawer][ipmt]) < m_maxTimeDiff) {
954 MeanOddPmtTdiff[ros][drawer] += ChannelOffset[ros][drawer][ipmt];
955 ++OddPmtCounter[ros][drawer];
956 } else {
957 ATH_MSG_WARNING( "correctEvenOddPMT()"
958 << " time overflow (" << ChannelOffset[ros][drawer][ipmt]
959 << ") ros:" << ros
960 << " dr:" << drawer
961 << " pmt:" << ipmt );
962
963 }
964 } else if (ipmt % 2 == 0) {
965 // even PMTs
966 if (fabs(ChannelOffset[ros][drawer][ipmt]) < m_maxTimeDiff) {
967 MeanEvenPmtTdiff[ros][drawer] += ChannelOffset[ros][drawer][ipmt];
968 ++EvenPmtCounter[ros][drawer];
969 } else {
970 ATH_MSG_WARNING( "correctEvenOddPMT()"
971 << " time overflow (" << ChannelOffset[ros][drawer][ipmt]
972 << ") ros:" << ros
973 << " dr:" << drawer
974 << " pmt:" << ipmt );
975 }
976 }
977 }
978 }
979
980 // Save Time difference b/w odd/even pmt's
981 MeanOddPmtTdiff[ros][drawer] /= (float) OddPmtCounter[ros][drawer];
982 MeanEvenPmtTdiff[ros][drawer] /= (float) EvenPmtCounter[ros][drawer];
983 DeltaParity = 0.5 * (MeanOddPmtTdiff[ros][drawer] - MeanEvenPmtTdiff[ros][drawer]);
984
985 EvenOddTimeDiff[ros][drawer] = 2 * DeltaParity;
986
987 ATH_MSG_DEBUG( "correctEvenOddPMT()"
988 << " ros: " << ros
989 << " drawer:" << drawer
990 << " EvenOddTimeDiff:" << EvenOddTimeDiff[ros][drawer]
991 << " | MeanOddPmtTdiff:" << MeanOddPmtTdiff[ros][drawer]
992 << " MeanEvenPmtTdiff:" << MeanEvenPmtTdiff[ros][drawer]
993 << " DeltaParity:" << DeltaParity );
994
995 //==================================================================
996 //=== Correct for overall shift b/w odd and even fibers ===
997 //==================================================================
998 for (int ipmt = 0; ipmt < NCHANNELS; ++ipmt) {
999 if (isConnectedPMT(ros, ipmt)) {
1000 if (ipmt % 2 == 1)
1001 ChannelOffset[ros][drawer][ipmt] -= DeltaParity;
1002 else if (ipmt % 2 == 0) ChannelOffset[ros][drawer][ipmt] += DeltaParity;
1003 }
1004 } // end pmt loop
1005}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
#define sqr(t)
Handle class for reading from StoreGate.
int imax(int i, int j)
#define NDIGI
#define NCHANNELS
#define NPARTITIONS
#define NDRAWERS
#define TileLaserTimingMon
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:861
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static const TileCablingService * getInstance()
get pointer to service instance
static const unsigned int MAX_ROS
Number of ROSs.
static const unsigned int MAX_DRAWER
Number of drawers in ROS 1-4.
const std::vector< float > & samples() const
Definition TileDigits.h:58
float(* m_FiberCorrection)[NDRAWERS][NCHANNELS]
Gaudi::Property< std::string > m_ntupleID
float(* m_ChannelOffset)[NDRAWERS][NCHANNELS]
float(* m_TimeDiffMean)[NDRAWERS][NCHANNELS]
Gaudi::Property< float > m_maxTimeDiff
ToolHandle< TileCondToolTiming > m_tileToolTiming
float(* m_EvenOddTimeDiff)[NDRAWERS]
HWIdentifier drawerId(int frag)
float(* TDrawerArrayF)[NDRAWERS]
int(* m_IsConnected)[NDRAWERS][NCHANNELS]
void fitGauss(TH1F &hi, float &p1, float &p2, float &p1_err)
Fit a Gaussian function (m_gaussf) to the given histogram, store mean, rms and mean error.
int(* m_OddPmtCounterPMT0)[NDRAWERS]
virtual StatusCode execute() override
TODO: determine event type, select laser?
const TileHWID * m_tileHWID
static bool isConnectedPMT(int ros, int chan)
virtual StatusCode finalize() override
float(* m_TimeDiffPMTDigi0)[NDRAWERS][NCHANNELS]
Gaudi::Property< unsigned int > m_refDrawer
int(* m_EvenPmtCounterPMT0)[NDRAWERS]
int(* m_OddPmtCounter)[NDRAWERS]
Gaudi::Property< bool > m_usePMT0AsDskewRef
float(* m_ADCAmplitude)[NDRAWERS][NCHANNELS]
virtual StatusCode initNtuple(int runNumber, int runType, TFile *rootfile) override
static bool isExtBarrel(int ros)
float(* m_DrawerOffset)[NDRAWERS]
float(* m_TimeDiffMeanError)[NDRAWERS][NCHANNELS]
virtual StatusCode finalizeCalculations() override
DrawerData *(* m_drawerData)[NDRAWERS]
int(* m_EvenPmtCounter)[NDRAWERS]
static bool isBarrel(int ros)
float(* m_MeanOddPmtTdiffPMT0)[NDRAWERS]
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
const TileCablingService * m_cabling
float(* m_PedestalMean)[NDRAWERS][NCHANNELS]
bool isConnectedChan(int ros, int chan)
int m_nevts
number of laser events
std::string drawerIdStr(int frag)
float(* m_MeanOddPmtTdiff)[NDRAWERS]
DrawerData * drawerData(int ros, int drawer)
Gaudi::Property< unsigned > m_nSamples
static float fiberLength(int ros, int pmt)
void correctEvenOddPMT(int ros, int drawer, TPMTArray &ChannelOffset, TDrawerArrayF &MeanOddPmtTdiff, TDrawerArrayI &OddPmtCounter, TDrawerArrayF &MeanEvenPmtTdiff, TDrawerArrayI &EvenPmtCounter, TDrawerArrayF &EvenOddTimeDiff)
Correct for differences between even and odd PMTs.
float(* m_TimeDiffSigma)[NDRAWERS][NCHANNELS]
float(* m_MeanEvenPmtTdiff)[NDRAWERS]
float(* TPMTArray)[NDRAWERS][NCHANNELS]
int channel2PMT(int ros, int chan)
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
float(* m_ChannelOffsetError)[NDRAWERS][NCHANNELS]
float(* m_FiberLength)[NDRAWERS][NCHANNELS]
virtual StatusCode initialize() override
float(* m_DigiMean)[NDRAWERS][NDIGI]
float(* m_PedestalSigma)[NDRAWERS][NCHANNELS]
double fiberCorrection(int ros, int pmt)
static const float s_fiberLength[2][48]
virtual StatusCode writeNtuple(int runNumber, int runType, TFile *rootfile) override
float(* m_DrawerOffsetError)[NDRAWERS]
float(* m_DSkewSet)[NDRAWERS][NDIGI]
float(* m_MeanEvenPmtTdiffPMT0)[NDRAWERS]
int(* TDrawerArrayI)[NDRAWERS]
void fitGauss2(TH1F &hi, float &p1, float &p2, float &chi2, float &p1_err, float w1, float w2)
Fit a Gaussian function with two iterations mean range = hi.mean +- w1|w2 * hi.rms.
TileLaserTimingTool(const std::string &type, const std::string &name, const IInterface *pParent)
Gaudi::Property< double > m_eneLowLimitPulseShape
Gaudi::Property< bool > m_useMeanChannelOffset
float(* m_EvenOddTimeDiffPMT0)[NDRAWERS]
float pedestal(void) const
float time(int ind=0) const
float amplitude(int ind=0) const
Identifier identify(void) const
Definition TileRawData.h:52
HWIdentifier adc_HWID(void) const
Definition TileRawData.h:53
void getStat(double &mean, double &sigma)
void add(double val)
double chi2(TH1 *h0, TH1 *h1)