CbmRoot
CbmMcbm2019CheckTimingPairs.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
9 
10 #include "CbmDigiManager.h"
11 #include "CbmFlesHistosTools.h"
12 
13 #include "FairLogger.h"
14 #include "FairRootManager.h"
15 #include "FairRunOnline.h"
16 
17 #include "TClonesArray.h"
18 #include "TH1.h"
19 #include "TH2.h"
20 #include "THttpServer.h"
21 #include "TProfile.h"
22 #include <TFile.h>
23 
24 
25 #include <iomanip>
26 #include <iostream>
27 #include <type_traits>
28 using std::fixed;
29 using std::setprecision;
30 
31 // ---- Default constructor -------------------------------------------
33  : FairTask("CbmMcbm2019CheckTimingPairs") {}
34 
35 // ---- Destructor ----------------------------------------------------
37 
38 // ---- Initialisation ----------------------------------------------
40  // Load all necessary parameter containers from the runtime data base
41  /*
42  FairRunAna* ana = FairRunAna::Instance();
43  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
44 
45  <CbmMcbm2019CheckTimingPairsDataMember> = (<ClassPointer>*)
46  (rtdb->getContainer("<ContainerName>"));
47  */
48 }
49 
50 // ---- Init ----------------------------------------------------------
52 
53  // Get a handle from the IO manager
54  FairRootManager* ioman = FairRootManager::Instance();
55 
56  // Digi manager
59  fDigiMan->Init();
60 
61  // T0 is not included in DigiManager; have to take care here
62  // Try to find a vector branch for the digi
63  fT0DigiVector = ioman->InitObjectAs<std::vector<CbmTofDigi> const*>("T0Digi");
64  if (!fT0DigiVector) {
65  LOG(info) << "No T0 digi vector found; trying TClonesArray";
66  if (std::is_convertible<TObject*, CbmTofDigi*>::value) {
67  fT0DigiArray = dynamic_cast<TClonesArray*>(ioman->GetObject("T0Digi"));
68  if (!fT0DigiArray) LOG(info) << "No T0 digi input found.";
69  } //? CbmTofDigi derives from TObject
70  } //? No vector for T0 digis
71 
73  LOG(info) << "No STS digi input found.";
74  }
75 
77  LOG(info) << "No MUCH digi input found.";
78  }
79 
81  LOG(info) << "No TRD digi input found.";
82  } // if ( ! fDigiMan->IsPresent(ECbmModuleId::kTrd) )
83  else {} // else of if ( ! fDigiMan->IsPresent(ECbmModuleId::kTrd) )
84 
86  LOG(info) << "No TOF digi input found.";
87  }
88 
90  LOG(info) << "No RICH digi input found.";
91  }
92 
94  LOG(info) << "No PSD digi input found.";
95  }
96 
99  dynamic_cast<TClonesArray*>(ioman->GetObject("TimesliceMetaData"));
100  if (!fTimeSliceMetaDataArray) LOG(fatal) << "No TS metadata input found";
101 
102  CreateHistos();
103 
104  return kSUCCESS;
105 }
106 
108 
109  Double_t dHistLim = kdDefaultTimeWin + kdClockCycle / 2.0;
110  for (UInt_t uDetA = 0; uDetA < fvsDetectors.size(); ++uDetA) {
111  for (UInt_t uDetB = uDetA; uDetB < fvsDetectors.size(); ++uDetB) {
112  std::string sName = Form("hDt%s_Vs_%s",
113  fvsDetectors[uDetA].c_str(),
114  fvsDetectors[uDetB].c_str());
115  std::string sTitle = Form("Time diff to T0 for %s VS for %s; Dt %s [ns]; "
116  "dT %s [ns]; Possible pairs []",
117  fvsDetectors[uDetA].c_str(),
118  fvsDetectors[uDetB].c_str(),
119  fvsDetectors[uDetA].c_str(),
120  fvsDetectors[uDetB].c_str());
121  fhDtADtB.push_back(new TH2D(sName.c_str(),
122  sTitle.c_str(),
123  kuNbBinsDefault + 1,
124  -dHistLim,
125  dHistLim,
126  kuNbBinsDefault + 1,
127  -dHistLim,
128  dHistLim));
129  } // for( UInt_t uDetB = uDetA; uDetB < fvsDetectors.size(); ++uDetB )
130  } // for( UInt_t uDetA = 0; uDetA < fvsDetectors.size(); ++uDetA )
131 
132 
134  FairRunOnline* run = FairRunOnline::Instance();
135  if (run) {
136  THttpServer* server = run->GetHttpServer();
137  if (nullptr != server) {
138  for (UInt_t uPair = 0; uPair < fhDtADtB.size(); ++uPair) {
139  server->Register("/PairTiming", fhDtADtB[uPair]);
140  } // for( UInt_t uPair = 0; uPar < fhDtADtB.size(); ++uPair )
141  } // if( nullptr != server )
142  } // if( run )
143 }
144 // ---- ReInit -------------------------------------------------------
145 InitStatus CbmMcbm2019CheckTimingPairs::ReInit() { return kSUCCESS; }
146 
147 // ---- Exec ----------------------------------------------------------
148 void CbmMcbm2019CheckTimingPairs::Exec(Option_t* /*option*/) {
149  LOG(debug) << "executing TS " << fNrTs;
150 
151  if (0 < fNrTs && 0 == fNrTs % 1000)
152  LOG(info) << Form("Processing TS %6d", fNrTs);
153 
155  UInt_t uNbT0Digis = 0;
156  if (fT0DigiVector)
157  uNbT0Digis = fT0DigiVector->size();
158  else if (fT0DigiArray)
159  uNbT0Digis = fT0DigiArray->GetEntriesFast();
160 
161  /*
162  UInt_t uNbStsDigis = fDigiMan->GetNofDigis(ECbmModuleId::kSts);
163  UInt_t uNbMuchDigis = fDigiMan->GetNofDigis(ECbmModuleId::kMuch);
164  UInt_t uNbTrdDigis = fDigiMan->GetNofDigis(ECbmModuleId::kTrd);
165  UInt_t uNbTofDigis = fDigiMan->GetNofDigis(ECbmModuleId::kTof);
166  UInt_t uNbRichDigis = fDigiMan->GetNofDigis(ECbmModuleId::kRich);
167  UInt_t uNbPsdDigis = fDigiMan->GetNofDigis(ECbmModuleId::kPsd);
168 */
169 
171  for (UInt_t uT0Digi = 0; uT0Digi < uNbT0Digis; ++uT0Digi) {
172  const CbmTofDigi* pDigiT0 = nullptr;
173  if (fT0DigiVector)
174  pDigiT0 = &(fT0DigiVector->at(uT0Digi));
175  else if (fT0DigiArray)
176  pDigiT0 = dynamic_cast<CbmTofDigi*>(fT0DigiArray->At(uT0Digi));
177  assert(pDigiT0);
178 
179  // UInt_t uChannel = pDigiT0->GetChannel();
180  Double_t dTimeT0 = pDigiT0->GetTime();
181 
182  fuNbCoincDigisSts = 0;
183  fuNbCoincDigisMuch = 0;
184  fuNbCoincDigisTrd = 0;
185  fuNbCoincDigisTof = 0;
186  fuNbCoincDigisRich = 0;
187  fuNbCoincDigisPsd = 0;
188  for (UInt_t uIndexDet = 0; uIndexDet < fvsDetectors.size(); ++uIndexDet) {
189  if ("STS" == fvsDetectors[uIndexDet]) {
190  fvuPrevT0FirstDigiDet[uIndexDet] =
191  FillCorrBuffer<CbmStsDigi>(dTimeT0,
192  fvuPrevT0FirstDigiDet[uIndexDet],
193  -fdStsTimeWin,
194  fdStsTimeWin,
195  fvDigisSts,
197  } // if( "STS" == fvsDetectors[ uIndexDet ] )
198  else if ("MUCH" == fvsDetectors[uIndexDet]) {
199  fvuPrevT0FirstDigiDet[uIndexDet] =
200  FillCorrBuffer<CbmMuchBeamTimeDigi>(dTimeT0,
201  fvuPrevT0FirstDigiDet[uIndexDet],
202  -fdMuchTimeWin,
204  fvDigisMuch,
206  } // else if( "MUCH" == fvsDetectors[ uIndexDet ] )
207  else if ("TRD" == fvsDetectors[uIndexDet]) {
208  fvuPrevT0FirstDigiDet[uIndexDet] =
209  FillCorrBuffer<CbmTrdDigi>(dTimeT0,
210  fvuPrevT0FirstDigiDet[uIndexDet],
211  -fdTrdTimeWin,
212  fdTrdTimeWin,
213  fvDigisTrd,
215  } // else if( "TRD" == fvsDetectors[ uIndexDet ] )
216  else if ("TOF" == fvsDetectors[uIndexDet]) {
217  fvuPrevT0FirstDigiDet[uIndexDet] =
218  FillCorrBuffer<CbmTofDigi>(dTimeT0,
219  fvuPrevT0FirstDigiDet[uIndexDet],
220  -fdTofTimeWin,
221  fdTofTimeWin,
222  fvDigisTof,
224  } // else if( "TOF" == fvsDetectors[ uIndexDet ] )
225  else if ("RICH" == fvsDetectors[uIndexDet]) {
226  fvuPrevT0FirstDigiDet[uIndexDet] =
227  FillCorrBuffer<CbmRichDigi>(dTimeT0,
228  fvuPrevT0FirstDigiDet[uIndexDet],
229  -fdRichTimeWin,
231  fvDigisRich,
233  } // else if( "RICH" == fvsDetectors[ uIndexDet ] )
234  else if ("PSD" == fvsDetectors[uIndexDet]) {
235  fvuPrevT0FirstDigiDet[uIndexDet] =
236  FillCorrBuffer<CbmPsdDigi>(dTimeT0,
237  fvuPrevT0FirstDigiDet[uIndexDet],
238  -fdPsdTimeWin,
239  fdPsdTimeWin,
240  fvDigisPsd,
242  } // else if( "PSD" == fvsDetectors[ uIndexDet ] )
243  else
244  LOG(fatal) << "CbmMcbm2019CheckTimingPairs => Unknown detector";
245  } // for( UInt_t uIndexDet = 0; uIndexDet < fvsDetectors.size(); ++uIndexDet )
246 
250  || 0 < fuNbCoincDigisPsd) {
251  fvDigisT0.push_back(*pDigiT0);
253 
255  if (0 == fuNbCoincDigisSts)
256  fvDigisSts.push_back(std::vector<CbmStsDigi>());
257  if (0 == fuNbCoincDigisMuch)
258  fvDigisMuch.push_back(std::vector<CbmMuchBeamTimeDigi>());
259  if (0 == fuNbCoincDigisTrd)
260  fvDigisTrd.push_back(std::vector<CbmTrdDigi>());
261  if (0 == fuNbCoincDigisTof)
262  fvDigisTof.push_back(std::vector<CbmTofDigi>());
263  if (0 == fuNbCoincDigisRich)
264  fvDigisRich.push_back(std::vector<CbmRichDigi>());
265  if (0 == fuNbCoincDigisPsd)
266  fvDigisPsd.push_back(std::vector<CbmPsdDigi>());
267  } // if( 0 < uNbCoincDigisSts || 0 < uNbCoincDigisMuch )
268  } // for( UInt_t uT0Digi = 0; uT0Digi < uNbT0Digis; ++uT0Digi )
269 
271  for (UInt_t uIndexT0 = 0; uIndexT0 < fvDigisT0.size(); ++uIndexT0) {
272  UInt_t uHistoIdx = 0;
273  for (UInt_t uIndexDetA = 0; uIndexDetA < fvsDetectors.size();
274  ++uIndexDetA) {
275  for (UInt_t uIndexDetB = uIndexDetA; uIndexDetB < fvsDetectors.size();
276  ++uIndexDetB) {
277  if ("STS" == fvsDetectors[uIndexDetA]) {
278  FillHistosInter<CbmStsDigi>(
279  uIndexT0, uIndexDetA, uIndexDetB, fvDigisSts[uIndexT0], uHistoIdx);
280  } // if( "STS" == fvsDetectors[ uIndexDetA ] )
281  else if ("MUCH" == fvsDetectors[uIndexDetA]) {
282  FillHistosInter<CbmMuchBeamTimeDigi>(
283  uIndexT0, uIndexDetA, uIndexDetB, fvDigisMuch[uIndexT0], uHistoIdx);
284  } // else if( "MUCH" == fvsDetectors[ uIndexDetA ] )
285  else if ("TRD" == fvsDetectors[uIndexDetA]) {
286  FillHistosInter<CbmTrdDigi>(
287  uIndexT0, uIndexDetA, uIndexDetB, fvDigisTrd[uIndexT0], uHistoIdx);
288  } // else if( "TRD" == fvsDetectors[ uIndexDetA ] )
289  else if ("TOF" == fvsDetectors[uIndexDetA]) {
290  FillHistosInter<CbmTofDigi>(
291  uIndexT0, uIndexDetA, uIndexDetB, fvDigisTof[uIndexT0], uHistoIdx);
292  } // else if( "TOF" == fvsDetectors[ uIndexDetA ] )
293  else if ("RICH" == fvsDetectors[uIndexDetA]) {
294  FillHistosInter<CbmRichDigi>(
295  uIndexT0, uIndexDetA, uIndexDetB, fvDigisRich[uIndexT0], uHistoIdx);
296  } // else if( "RICH" == fvsDetectors[ uIndexDetA ] )
297  else if ("PSD" == fvsDetectors[uIndexDetA]) {
298  FillHistosInter<CbmPsdDigi>(
299  uIndexT0, uIndexDetA, uIndexDetB, fvDigisPsd[uIndexT0], uHistoIdx);
300  } // else if( "PSD" == fvsDetectors[ uIndexDetA ] )
301  else
302  LOG(fatal) << "CbmMcbm2019CheckTimingPairs => Unknown detector";
303 
304  uHistoIdx++;
305  } // for( UInt_t uIndexDetB = uIndexDetA; uIndexDetB < fvsDetectors.size(); ++uIndexDetB )
306  } // for( UInt_t uIndexDetA = 0; uIndexDetA < fvsDetectors.size(); ++uIndexDetA )
307 
309  fvDigisSts[uIndexT0].clear();
310  fvDigisMuch[uIndexT0].clear();
311  fvDigisTrd[uIndexT0].clear();
312  fvDigisTof[uIndexT0].clear();
313  fvDigisRich[uIndexT0].clear();
314  fvDigisPsd[uIndexT0].clear();
315  } // for( UInt_t uIndexT0 = 0; uIndexT0 < fvDigisT0.size(); ++uIndexT0 )
317  fvDigisT0.clear();
318  fvDigisSts.clear();
319  fvDigisMuch.clear();
320  fvDigisTrd.clear();
321  fvDigisTof.clear();
322  fvDigisRich.clear();
323  fvDigisPsd.clear();
324 
325  fNrTs++;
326 
327  if (0 < fNrTs && 0 == fNrTs % 10000) WriteHistos();
328 }
329 
330 template<class Digi>
332  Double_t dTimeT0,
333  UInt_t uIndexStart,
334  Double_t dWinStartTime,
335  Double_t dWinStopTime,
336  std::vector<std::vector<Digi>>& vDigi,
337  ECbmModuleId iDetId) {
338 
339  UInt_t nrDigis = fDigiMan->GetNofDigis(iDetId);
340  UInt_t uFirstDigiInWin = uIndexStart;
341 
342  for (UInt_t iDigi = uIndexStart; iDigi < nrDigis; ++iDigi) {
343  const Digi* digi = fDigiMan->Get<Digi>(iDigi);
344 
345  Double_t dTimeDet = digi->GetTime();
346  Double_t dTimeDiff = dTimeDet - dTimeT0;
347 
348  if (dTimeDiff < dWinStartTime) {
349  uFirstDigiInWin = iDigi;
350  continue;
351  } // if( dTimeDiff < dWinStartTime )
352  else if (dWinStopTime < dTimeDiff) {
353  break;
354  } // else if( dWinStopTime < dTimeDiff ) of if( dTimeDiff < dWinStartTime )
355 
356  switch (iDetId) {
357  case ECbmModuleId::kSts:
358  {
359  const CbmStsDigi* stsDigi = nullptr;
360  try {
361  stsDigi = boost::any_cast<const CbmStsDigi*>(digi);
362  } catch (...) {
363  LOG(fatal) << "Failed boost any_cast in "
364  "CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a "
365  "digi of type "
366  << Digi::GetClassName();
367  } // try/catch
368  assert(stsDigi);
369  UInt_t uAddr = stsDigi->GetAddress();
370  // UInt_t uChan = stsDigi->GetChannel();
371 
373  if ((kuDefaultAddress != fuStsAddress && uAddr == fuStsAddress))
374  continue;
375 
377  if (0 == fuNbCoincDigisSts) vDigi.push_back(std::vector<Digi>());
378 
379  vDigi[fuNbDigisWithCoincT0].push_back((*digi));
381 
382  break;
383  } // case ECbmModuleId::kSts:
384  case ECbmModuleId::kMuch:
385  {
386  const CbmMuchBeamTimeDigi* muchDigi {nullptr};
387  try {
388  muchDigi = boost::any_cast<const CbmMuchBeamTimeDigi*>(digi);
389  } catch (...) {
390  LOG(fatal) << "Failed boost any_cast in "
391  "CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a "
392  "digi of type "
393  << Digi::GetClassName();
394  } // try/catch
395  assert(muchDigi);
396  UInt_t uAsic = muchDigi->GetNxId();
397  // UInt_t uChan = muchDigi->GetNxCh();
398 
400  if ((kuMaxNbMuchAsics != fuMuchAsic && uAsic == fuMuchAsic)) continue;
401 
403  if (0 == fuNbCoincDigisMuch) vDigi.push_back(std::vector<Digi>());
404 
405  vDigi[fuNbDigisWithCoincT0].push_back((*digi));
407 
408  break;
409  } // case ECbmModuleId::kMuch:
410  case ECbmModuleId::kTrd:
411  {
412  /*
413  UInt_t uAddr = digi->GetAddress();
414 
415  if( ( kuDefaultAddress != fuTrdAddress && uAddr == fuTrdAddress ) )
416  continue;
417 
419  if( fuMinChargePulserTrd < digi->GetCharge() && digi->GetCharge() < fuMaxChargePulserTrd )
420  continue;
421 */
423  if (0 == fuNbCoincDigisTrd) vDigi.push_back(std::vector<Digi>());
424 
425  vDigi[fuNbDigisWithCoincT0].push_back((*digi));
427 
428  break;
429  } // case ECbmModuleId::kTrd:
430  case ECbmModuleId::kTof:
431  {
433  if (fuMinTotPulserTof < digi->GetCharge()
434  && digi->GetCharge() < fuMaxTotPulserTof)
435  continue;
436 
438  if (0 == fuNbCoincDigisTof) vDigi.push_back(std::vector<Digi>());
439 
440  vDigi[fuNbDigisWithCoincT0].push_back((*digi));
442 
443  break;
444  } // case ECbmModuleId::kTof:
445  case ECbmModuleId::kRich:
446  {
448  if (fuMinTotPulserRich < digi->GetCharge()
449  && digi->GetCharge() < fuMaxTotPulserRich)
450  continue;
451 
453  if (0 == fuNbCoincDigisRich) vDigi.push_back(std::vector<Digi>());
454 
455  vDigi[fuNbDigisWithCoincT0].push_back((*digi));
457 
458  break;
459  } // case ECbmModuleId::kRich:
460  case ECbmModuleId::kPsd:
461  {
462  UInt_t uAddr = digi->GetAddress();
463 
465  if ((kuDefaultAddress != fuPsdAddress && uAddr == fuPsdAddress))
466  continue;
467  if (fuMinAdcPulserPsd < digi->GetCharge()
468  && digi->GetCharge() < fuMaxAdcPulserPsd)
469  continue;
470  /*
471  if( digi->GetAddress() == (9<<10)+8 )
472  continue;
473 */
475  if (0 == fuNbCoincDigisPsd) vDigi.push_back(std::vector<Digi>());
476 
477  vDigi[fuNbDigisWithCoincT0].push_back((*digi));
479 
480  break;
481  } // case ECbmModuleId::kPsd:
482  default: return 0;
483  } // switch( iDetId )
484  } // for( UInt_t iDigi = uIndexStart; iDigi < nrDigis; ++iDigi )
485 
486  return uFirstDigiInWin;
487 }
488 
489 template<class DigiA>
491  UInt_t uIndexDetA,
492  UInt_t uIndexDetB,
493  std::vector<DigiA>& vCorrDigA,
494  UInt_t uHistoIdx) {
495  if ("STS" == fvsDetectors[uIndexDetB]) {
496  FillHistos<DigiA, CbmStsDigi>(uIndexT0,
497  uIndexDetA,
498  uIndexDetB,
499  vCorrDigA,
500  fvDigisSts[uIndexT0],
501  uHistoIdx);
502  } // if( "STS" == fvsDetectors[ uIndexDetB ] )
503  else if ("MUCH" == fvsDetectors[uIndexDetB]) {
504  FillHistos<DigiA, CbmMuchBeamTimeDigi>(uIndexT0,
505  uIndexDetA,
506  uIndexDetB,
507  vCorrDigA,
508  fvDigisMuch[uIndexT0],
509  uHistoIdx);
510  } // else if( "MUCH" == fvsDetectors[ uIndexDetB ] )
511  else if ("TRD" == fvsDetectors[uIndexDetB]) {
512  FillHistos<DigiA, CbmTrdDigi>(uIndexT0,
513  uIndexDetA,
514  uIndexDetB,
515  vCorrDigA,
516  fvDigisTrd[uIndexT0],
517  uHistoIdx);
518  } // else if( "TRD" == fvsDetectors[ uIndexDetB ] )
519  else if ("TOF" == fvsDetectors[uIndexDetB]) {
520  FillHistos<DigiA, CbmTofDigi>(uIndexT0,
521  uIndexDetA,
522  uIndexDetB,
523  vCorrDigA,
524  fvDigisTof[uIndexT0],
525  uHistoIdx);
526  } // else if( "TOF" == fvsDetectors[ uIndexDetB ] )
527  else if ("RICH" == fvsDetectors[uIndexDetB]) {
528  FillHistos<DigiA, CbmRichDigi>(uIndexT0,
529  uIndexDetA,
530  uIndexDetB,
531  vCorrDigA,
532  fvDigisRich[uIndexT0],
533  uHistoIdx);
534  } // else if( "RICH" == fvsDetectors[ uIndexDetB ] )
535  else if ("PSD" == fvsDetectors[uIndexDetB]) {
536  FillHistos<DigiA, CbmPsdDigi>(uIndexT0,
537  uIndexDetA,
538  uIndexDetB,
539  vCorrDigA,
540  fvDigisPsd[uIndexT0],
541  uHistoIdx);
542  } // else if( "PSD" == fvsDetectors[ uIndexDetB ] )
543  else
544  LOG(fatal) << "CbmMcbm2019CheckTimingPairs => Unknown detector";
545 }
546 template<class DigiA, class DigiB>
548  UInt_t /*uIndexDetA*/,
549  UInt_t /*uIndexDetB*/,
550  std::vector<DigiA>& vCorrDigA,
551  std::vector<DigiB>& vCorrDigB,
552  UInt_t uHistoIdx) {
553  Double_t dTimeT0 = fvDigisT0[uIndexT0].GetTime();
554  /*
555  std::vector< DigiA > vCorrDigA;
556  std::vector< DigiB > vCorrDigB;
557 
559  if( "STS" == fvsDetectors[ uIndexDetA ] )
560  {
561  vCorrDigA = fvDigisSts[ uIndexT0 ];
562  } // if( "STS" == fvsDetectors[ uIndexDetA ] )
563  else if( "MUCH" == fvsDetectors[ uIndexDetA ] )
564  {
565  vCorrDigA = fvDigisMuch[ uIndexT0 ];
566  } // else if( "MUCH" == fvsDetectors[ uIndexDetA ] )
567  else if( "TRD" == fvsDetectors[ uIndexDetA ] )
568  {
569  vCorrDigA = fvDigisTrd[ uIndexT0 ];
570  } // else if( "TRD" == fvsDetectors[ uIndexDetA ] )
571  else if( "TOF" == fvsDetectors[ uIndexDetA ] )
572  {
573  vCorrDigA = fvDigisTof[ uIndexT0 ];
574  } // else if( "TOF" == fvsDetectors[ uIndexDetA ] )
575  else if( "RICH" == fvsDetectors[ uIndexDetA ] )
576  {
577  vCorrDigA = fvDigisRich[ uIndexT0 ];
578  } // else if( "RICH" == fvsDetectors[ uIndexDetA ] )
579  else if( "PSD" == fvsDetectors[ uIndexDetA ] )
580  {
581  vCorrDigA = fvDigisPsd[ uIndexT0 ];
582  } // else if( "PSD" == fvsDetectors[ uIndexDetA ] )
583  else LOG( fatal ) << "CbmMcbm2019CheckTimingPairs => Unknown detector";
584 
585  if( "STS" == fvsDetectors[ uIndexDetB ] )
586  {
587  vCorrDigB = fvDigisSts[ uIndexT0 ];
588  } // if( "STS" == fvsDetectors[ uIndexDetB ] )
589  else if( "MUCH" == fvsDetectors[ uIndexDetB ] )
590  {
591  vCorrDigB = fvDigisMuch[ uIndexT0 ];
592  } // else if( "MUCH" == fvsDetectors[ uIndexDetB ] )
593  else if( "TRD" == fvsDetectors[ uIndexDetB ] )
594  {
595  vCorrDigB = fvDigisTrd[ uIndexT0 ];
596  } // else if( "TRD" == fvsDetectors[ uIndexDetB ] )
597  else if( "TOF" == fvsDetectors[ uIndexDetB ] )
598  {
599  vCorrDigB = fvDigisTof[ uIndexT0 ];
600  } // else if( "TOF" == fvsDetectors[ uIndexDetB ] )
601  else if( "RICH" == fvsDetectors[ uIndexDetB ] )
602  {
603  vCorrDigB = fvDigisRich[ uIndexT0 ];
604  } // else if( "RICH" == fvsDetectors[ uIndexDetB ] )
605  else if( "PSD" == fvsDetectors[ uIndexDetB ] )
606  {
607  vCorrDigB = fvDigisPsd[ uIndexT0 ];
608  } // else if( "PSD" == fvsDetectors[ uIndexDetB ] )
609  else LOG( fatal ) << "CbmMcbm2019CheckTimingPairs => Unknown detector";
610 */
611  for (UInt_t uIdxDetA = 0; uIdxDetA < vCorrDigA.size(); ++uIdxDetA) {
612  Double_t dTimeDetA = vCorrDigA[uIdxDetA].GetTime();
613  Double_t dDtDetA = dTimeDetA - dTimeT0;
614 
615  for (UInt_t uIdxDetB = 0; uIdxDetB < vCorrDigB.size(); ++uIdxDetB) {
616  Double_t dTimeDetB = vCorrDigB[uIdxDetB].GetTime();
617  Double_t dDtDetB = dTimeDetB - dTimeT0;
618 
619  fhDtADtB[uHistoIdx]->Fill(dDtDetA, dDtDetB);
620  } // for( UInt_t uIdxDetB = 0; uIdxDetB < vCoincDigisDetB[ uEvent ].size(); ++vCoincDigisDetB )
621  } // for( UInt_t uIdxDetA = 0; uIdxDetA < vCoincDigisDetA[ uEvent ].size(); ++vCoincDigisDetA )
622 }
623 
624 
625 // ---- Finish --------------------------------------------------------
627 
629  TFile* old = gFile;
630  TFile* outfile = TFile::Open(fOutFileName, "RECREATE");
631 
632  for (UInt_t uPair = 0; uPair < fhDtADtB.size(); ++uPair) {
633  fhDtADtB[uPair]->Write();
634  } // for( UInt_t uPair = 0; uPair < fhDtADtB.size(); ++uPair )
635 
636  outfile->Close();
637  delete outfile;
638 
639  gFile = old;
640 }
641 
CbmMcbm2019CheckTimingPairs::fdRichTimeWin
Double_t fdRichTimeWin
Definition: CbmMcbm2019CheckTimingPairs.h:233
CbmMcbm2019CheckTimingPairs::Init
virtual InitStatus Init()
Definition: CbmMcbm2019CheckTimingPairs.cxx:51
CbmMcbm2019CheckTimingPairs::kuMaxNbMuchAsics
static const UInt_t kuMaxNbMuchAsics
Definition: CbmMcbm2019CheckTimingPairs.h:158
CbmMcbm2019CheckTimingPairs::fuStsAddress
UInt_t fuStsAddress
Definition: CbmMcbm2019CheckTimingPairs.h:217
CbmMcbm2019CheckTimingPairs::fOutFileName
TString fOutFileName
Definition: CbmMcbm2019CheckTimingPairs.h:240
CbmMcbm2019CheckTimingPairs::fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmMcbm2019CheckTimingPairs.h:148
CbmMcbm2019CheckTimingPairs::fdMuchTimeWin
Double_t fdMuchTimeWin
Definition: CbmMcbm2019CheckTimingPairs.h:230
CbmMcbm2019CheckTimingPairs::fNrTs
Int_t fNrTs
Definition: CbmMcbm2019CheckTimingPairs.h:227
CbmDigiManager::Init
InitStatus Init()
Initialisation.
Definition: CbmDigiManager.cxx:71
CbmMcbm2019CheckTimingPairs::fuNbCoincDigisTof
UInt_t fuNbCoincDigisTof
Definition: CbmMcbm2019CheckTimingPairs.h:196
CbmMuchBeamTimeDigi
Definition: CbmMuchBeamTimeDigi.h:29
CbmMcbm2019CheckTimingPairs::fdPsdTimeWin
Double_t fdPsdTimeWin
Definition: CbmMcbm2019CheckTimingPairs.h:234
CbmMcbm2019CheckTimingPairs::fTimeSliceMetaDataArray
TClonesArray * fTimeSliceMetaDataArray
Definition: CbmMcbm2019CheckTimingPairs.h:151
CbmMcbm2019CheckTimingPairs::fuNbCoincDigisPsd
UInt_t fuNbCoincDigisPsd
Definition: CbmMcbm2019CheckTimingPairs.h:198
CbmMcbm2019CheckTimingPairs::fvsDetectors
std::vector< std::string > fvsDetectors
List of detectors.
Definition: CbmMcbm2019CheckTimingPairs.h:167
CbmMcbm2019CheckTimingPairs::fvDigisPsd
std::vector< std::vector< CbmPsdDigi > > fvDigisPsd
Definition: CbmMcbm2019CheckTimingPairs.h:188
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmDigiManager::GetNofDigis
static Int_t GetNofDigis(ECbmModuleId systemId)
Definition: CbmDigiManager.cxx:62
CbmDigiManager::UseMuchBeamTimeDigi
void UseMuchBeamTimeDigi(Bool_t choice=kTRUE)
Use CbmMuchBeamTimeDigi instead of CbmMuchDigi for MUCH.
Definition: CbmDigiManager.h:130
CbmMcbm2019CheckTimingPairs::fuMaxTotPulserRich
UInt_t fuMaxTotPulserRich
Default: No cut.
Definition: CbmMcbm2019CheckTimingPairs.h:213
CbmMcbm2019CheckTimingPairs
Definition: CbmMcbm2019CheckTimingPairs.h:37
CbmMcbm2019CheckTimingPairs::Finish
virtual void Finish()
Definition: CbmMcbm2019CheckTimingPairs.cxx:626
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmMcbm2019CheckTimingPairs::fuNbCoincDigisSts
UInt_t fuNbCoincDigisSts
Variable to store counts of T0 with at least one coincidence.
Definition: CbmMcbm2019CheckTimingPairs.h:193
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
CbmMcbm2019CheckTimingPairs::ReInit
virtual InitStatus ReInit()
Definition: CbmMcbm2019CheckTimingPairs.cxx:145
CbmMcbm2019CheckTimingPairs::fuMaxAdcPulserPsd
UInt_t fuMaxAdcPulserPsd
Default: No cut.
Definition: CbmMcbm2019CheckTimingPairs.h:215
CbmDigiManager::Instance
static CbmDigiManager * Instance()
Static instance.
Definition: CbmDigiManager.h:93
CbmMcbm2019CheckTimingPairs::fhDtADtB
std::vector< TH1 * > fhDtADtB
Definition: CbmMcbm2019CheckTimingPairs.h:238
CbmMcbm2019CheckTimingPairs::kdClockCycle
static constexpr Double_t kdClockCycle
Definition: CbmMcbm2019CheckTimingPairs.h:162
CbmMcbm2019CheckTimingPairs.h
CbmMcbm2019CheckTimingPairs::CbmMcbm2019CheckTimingPairs
CbmMcbm2019CheckTimingPairs()
Definition: CbmMcbm2019CheckTimingPairs.cxx:32
CbmMcbm2019CheckTimingPairs::fdStsTimeWin
Double_t fdStsTimeWin
Definition: CbmMcbm2019CheckTimingPairs.h:229
CbmMcbm2019CheckTimingPairs::fuNbDigisWithCoincT0
UInt_t fuNbDigisWithCoincT0
Variable to store counts of T0 with at least one coincidence.
Definition: CbmMcbm2019CheckTimingPairs.h:191
CbmDigiManager::Get
const Digi * Get(Int_t index) const
Get a digi object.
Definition: CbmDigiManager.h:52
CbmMcbm2019CheckTimingPairs::FillCorrBuffer
UInt_t FillCorrBuffer(Double_t dTimeT0, UInt_t uIndexStart, Double_t dWinStartTime, Double_t dWinStopTime, std::vector< std::vector< Digi >> &vDigi, ECbmModuleId iDetId=ECbmModuleId::kLastModule)
Definition: CbmMcbm2019CheckTimingPairs.cxx:331
CbmMcbm2019CheckTimingPairs::fuNbCoincDigisTrd
UInt_t fuNbCoincDigisTrd
Definition: CbmMcbm2019CheckTimingPairs.h:195
CbmTofDigi::GetTime
Double_t GetTime() const
Inherited from CbmDigi.
Definition: CbmTofDigi.h:111
ECbmModuleId::kRich
@ kRich
Ring-Imaging Cherenkov Detector.
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMcbm2019CheckTimingPairs::fT0DigiVector
const std::vector< CbmTofDigi > * fT0DigiVector
Definition: CbmMcbm2019CheckTimingPairs.h:149
CbmStsDigi
Data class for a single-channel message in the STS.
Definition: CbmStsDigi.h:29
CbmMcbm2019CheckTimingPairs::fvuPrevT0FirstDigiDet
std::vector< UInt_t > fvuPrevT0FirstDigiDet
Definition: CbmMcbm2019CheckTimingPairs.h:178
CbmMcbm2019CheckTimingPairs::fdTrdTimeWin
Double_t fdTrdTimeWin
Definition: CbmMcbm2019CheckTimingPairs.h:231
CbmMcbm2019CheckTimingPairs::fvDigisRich
std::vector< std::vector< CbmRichDigi > > fvDigisRich
Definition: CbmMcbm2019CheckTimingPairs.h:187
CbmTofDigi
Data class for expanded digital TOF information.
Definition: CbmTofDigi.h:38
CbmMcbm2019CheckTimingPairs::fvDigisTrd
std::vector< std::vector< CbmTrdDigi > > fvDigisTrd
Definition: CbmMcbm2019CheckTimingPairs.h:185
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmStsDigi::GetAddress
Int_t GetAddress() const
Definition: CbmStsDigi.h:53
CbmMcbm2019CheckTimingPairs::fuPsdAddress
UInt_t fuPsdAddress
Definition: CbmMcbm2019CheckTimingPairs.h:224
CbmDigiManager.h
CbmMcbm2019CheckTimingPairs::fuMuchAsic
UInt_t fuMuchAsic
Definition: CbmMcbm2019CheckTimingPairs.h:220
CbmMcbm2019CheckTimingPairs::FillHistosInter
void FillHistosInter(UInt_t uIndexT0, UInt_t uIndexA, UInt_t uIndexB, std::vector< DigiA > &vCorrDigA, UInt_t uHistoIdx)
Definition: CbmMcbm2019CheckTimingPairs.cxx:490
CbmMcbm2019CheckTimingPairs::fvDigisSts
std::vector< std::vector< CbmStsDigi > > fvDigisSts
Definition: CbmMcbm2019CheckTimingPairs.h:183
CbmFlesHistosTools.h
CbmMcbm2019CheckTimingPairs::FillHistos
void FillHistos(UInt_t uIndexT0, UInt_t uIndexA, UInt_t uIndexB, std::vector< DigiA > &vCorrDigA, std::vector< DigiB > &vCorrDigB, UInt_t uHistoIdx)
Definition: CbmMcbm2019CheckTimingPairs.cxx:547
CbmMcbm2019CheckTimingPairs::fvDigisMuch
std::vector< std::vector< CbmMuchBeamTimeDigi > > fvDigisMuch
Definition: CbmMcbm2019CheckTimingPairs.h:184
CbmMcbm2019CheckTimingPairs::CreateHistos
void CreateHistos()
Definition: CbmMcbm2019CheckTimingPairs.cxx:107
CbmMcbm2019CheckTimingPairs::fuNbCoincDigisMuch
UInt_t fuNbCoincDigisMuch
Definition: CbmMcbm2019CheckTimingPairs.h:194
CbmMcbm2019CheckTimingPairs::~CbmMcbm2019CheckTimingPairs
~CbmMcbm2019CheckTimingPairs()
Definition: CbmMcbm2019CheckTimingPairs.cxx:36
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
ECbmModuleId::kPsd
@ kPsd
Projectile spectator detector.
CbmMcbm2019CheckTimingPairs::fuNbCoincDigisRich
UInt_t fuNbCoincDigisRich
Definition: CbmMcbm2019CheckTimingPairs.h:197
CbmMcbm2019CheckTimingPairs::kuDefaultAddress
static const UInt_t kuDefaultAddress
Definition: CbmMcbm2019CheckTimingPairs.h:159
CbmMcbm2019CheckTimingPairs::fvDigisTof
std::vector< std::vector< CbmTofDigi > > fvDigisTof
Definition: CbmMcbm2019CheckTimingPairs.h:186
CbmMcbm2019CheckTimingPairs::fvDigisT0
std::vector< CbmTofDigi > fvDigisT0
Variable to store correlated Digis.
Definition: CbmMcbm2019CheckTimingPairs.h:182
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
CbmMcbm2019CheckTimingPairs::fT0DigiArray
TClonesArray * fT0DigiArray
Definition: CbmMcbm2019CheckTimingPairs.h:150
CbmMcbm2019CheckTimingPairs::kdDefaultTimeWin
static constexpr Double_t kdDefaultTimeWin
Definition: CbmMcbm2019CheckTimingPairs.h:163
CbmMcbm2019CheckTimingPairs::SetParContainers
virtual void SetParContainers()
Definition: CbmMcbm2019CheckTimingPairs.cxx:39
CbmMcbm2019CheckTimingPairs::Exec
virtual void Exec(Option_t *)
Definition: CbmMcbm2019CheckTimingPairs.cxx:148
CbmMcbm2019CheckTimingPairs::fdTofTimeWin
Double_t fdTofTimeWin
Definition: CbmMcbm2019CheckTimingPairs.h:232
CbmMcbm2019CheckTimingPairs::kuNbBinsDefault
static const UInt_t kuNbBinsDefault
Definition: CbmMcbm2019CheckTimingPairs.h:161
CbmMcbm2019CheckTimingPairs::WriteHistos
void WriteHistos()
Definition: CbmMcbm2019CheckTimingPairs.cxx:628
CbmMcbm2019CheckTimingPairs::fuMaxTotPulserTof
UInt_t fuMaxTotPulserTof
Definition: CbmMcbm2019CheckTimingPairs.h:211