13 #include "FairLogger.h"
14 #include "FairRootManager.h"
15 #include "FairRunOnline.h"
17 #include "TClonesArray.h"
20 #include "THttpServer.h"
27 #include <type_traits>
29 using std::setprecision;
33 : FairTask(
"CbmMcbm2019CheckTimingPairs") {}
54 FairRootManager* ioman = FairRootManager::Instance();
63 fT0DigiVector = ioman->InitObjectAs<std::vector<CbmTofDigi>
const*>(
"T0Digi");
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.";
73 LOG(info) <<
"No STS digi input found.";
77 LOG(info) <<
"No MUCH digi input found.";
81 LOG(info) <<
"No TRD digi input found.";
86 LOG(info) <<
"No TOF digi input found.";
90 LOG(info) <<
"No RICH digi input found.";
94 LOG(info) <<
"No PSD digi input found.";
99 dynamic_cast<TClonesArray*
>(ioman->GetObject(
"TimesliceMetaData"));
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",
115 std::string sTitle = Form(
"Time diff to T0 for %s VS for %s; Dt %s [ns]; "
116 "dT %s [ns]; Possible pairs []",
121 fhDtADtB.push_back(
new TH2D(sName.c_str(),
134 FairRunOnline* run = FairRunOnline::Instance();
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]);
149 LOG(debug) <<
"executing TS " <<
fNrTs;
152 LOG(info) << Form(
"Processing TS %6d",
fNrTs);
155 UInt_t uNbT0Digis = 0;
171 for (UInt_t uT0Digi = 0; uT0Digi < uNbT0Digis; ++uT0Digi) {
180 Double_t dTimeT0 = pDigiT0->
GetTime();
188 for (UInt_t uIndexDet = 0; uIndexDet <
fvsDetectors.size(); ++uIndexDet) {
191 FillCorrBuffer<CbmStsDigi>(dTimeT0,
200 FillCorrBuffer<CbmMuchBeamTimeDigi>(dTimeT0,
209 FillCorrBuffer<CbmTrdDigi>(dTimeT0,
218 FillCorrBuffer<CbmTofDigi>(dTimeT0,
227 FillCorrBuffer<CbmRichDigi>(dTimeT0,
236 FillCorrBuffer<CbmPsdDigi>(dTimeT0,
244 LOG(fatal) <<
"CbmMcbm2019CheckTimingPairs => Unknown detector";
256 fvDigisSts.push_back(std::vector<CbmStsDigi>());
258 fvDigisMuch.push_back(std::vector<CbmMuchBeamTimeDigi>());
260 fvDigisTrd.push_back(std::vector<CbmTrdDigi>());
262 fvDigisTof.push_back(std::vector<CbmTofDigi>());
266 fvDigisPsd.push_back(std::vector<CbmPsdDigi>());
271 for (UInt_t uIndexT0 = 0; uIndexT0 <
fvDigisT0.size(); ++uIndexT0) {
272 UInt_t uHistoIdx = 0;
273 for (UInt_t uIndexDetA = 0; uIndexDetA <
fvsDetectors.size();
275 for (UInt_t uIndexDetB = uIndexDetA; uIndexDetB <
fvsDetectors.size();
278 FillHistosInter<CbmStsDigi>(
279 uIndexT0, uIndexDetA, uIndexDetB,
fvDigisSts[uIndexT0], uHistoIdx);
282 FillHistosInter<CbmMuchBeamTimeDigi>(
283 uIndexT0, uIndexDetA, uIndexDetB,
fvDigisMuch[uIndexT0], uHistoIdx);
286 FillHistosInter<CbmTrdDigi>(
287 uIndexT0, uIndexDetA, uIndexDetB,
fvDigisTrd[uIndexT0], uHistoIdx);
290 FillHistosInter<CbmTofDigi>(
291 uIndexT0, uIndexDetA, uIndexDetB,
fvDigisTof[uIndexT0], uHistoIdx);
294 FillHistosInter<CbmRichDigi>(
295 uIndexT0, uIndexDetA, uIndexDetB,
fvDigisRich[uIndexT0], uHistoIdx);
298 FillHistosInter<CbmPsdDigi>(
299 uIndexT0, uIndexDetA, uIndexDetB,
fvDigisPsd[uIndexT0], uHistoIdx);
302 LOG(fatal) <<
"CbmMcbm2019CheckTimingPairs => Unknown detector";
334 Double_t dWinStartTime,
335 Double_t dWinStopTime,
336 std::vector<std::vector<Digi>>& vDigi,
340 UInt_t uFirstDigiInWin = uIndexStart;
342 for (UInt_t iDigi = uIndexStart; iDigi < nrDigis; ++iDigi) {
345 Double_t dTimeDet = digi->GetTime();
346 Double_t dTimeDiff = dTimeDet - dTimeT0;
348 if (dTimeDiff < dWinStartTime) {
349 uFirstDigiInWin = iDigi;
352 else if (dWinStopTime < dTimeDiff) {
361 stsDigi = boost::any_cast<const CbmStsDigi*>(digi);
363 LOG(fatal) <<
"Failed boost any_cast in "
364 "CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a "
366 << Digi::GetClassName();
388 muchDigi = boost::any_cast<const CbmMuchBeamTimeDigi*>(digi);
390 LOG(fatal) <<
"Failed boost any_cast in "
391 "CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a "
393 << Digi::GetClassName();
396 UInt_t uAsic = muchDigi->GetNxId();
433 if (fuMinTotPulserTof < digi->GetCharge()
448 if (fuMinTotPulserRich < digi->GetCharge()
462 UInt_t uAddr = digi->GetAddress();
467 if (fuMinAdcPulserPsd < digi->GetCharge()
486 return uFirstDigiInWin;
489 template<
class DigiA>
493 std::vector<DigiA>& vCorrDigA,
496 FillHistos<DigiA, CbmStsDigi>(uIndexT0,
504 FillHistos<DigiA, CbmMuchBeamTimeDigi>(uIndexT0,
512 FillHistos<DigiA, CbmTrdDigi>(uIndexT0,
520 FillHistos<DigiA, CbmTofDigi>(uIndexT0,
528 FillHistos<DigiA, CbmRichDigi>(uIndexT0,
536 FillHistos<DigiA, CbmPsdDigi>(uIndexT0,
544 LOG(fatal) <<
"CbmMcbm2019CheckTimingPairs => Unknown detector";
546 template<
class DigiA,
class DigiB>
550 std::vector<DigiA>& vCorrDigA,
551 std::vector<DigiB>& vCorrDigB,
553 Double_t dTimeT0 =
fvDigisT0[uIndexT0].GetTime();
611 for (UInt_t uIdxDetA = 0; uIdxDetA < vCorrDigA.size(); ++uIdxDetA) {
612 Double_t dTimeDetA = vCorrDigA[uIdxDetA].GetTime();
613 Double_t dDtDetA = dTimeDetA - dTimeT0;
615 for (UInt_t uIdxDetB = 0; uIdxDetB < vCorrDigB.size(); ++uIdxDetB) {
616 Double_t dTimeDetB = vCorrDigB[uIdxDetB].GetTime();
617 Double_t dDtDetB = dTimeDetB - dTimeT0;
619 fhDtADtB[uHistoIdx]->Fill(dDtDetA, dDtDetB);
632 for (UInt_t uPair = 0; uPair <
fhDtADtB.size(); ++uPair) {