19 #include "FairLogger.h"
20 #include "FairRootManager.h"
21 #include "FairRunOnline.h"
25 #include "THttpServer.h"
31 using std::setprecision;
57 for (std::vector<CheckTimingDetector>::iterator det =
fvDets.begin();
70 FairRootManager* ioman = FairRootManager::Instance();
78 fpT0DigiVec = ioman->InitObjectAs<std::vector<CbmTofDigi>
const*>(
"T0Digi");
80 LOG(fatal) <<
"No storage with T0 digis found while it should be used. "
85 LOG(fatal) <<
"No " << detToCheck.
sName
86 <<
" digis found while it should be used. Stopping there!";
95 uint32_t iNbBinsLog = 0;
98 double* dBinsLog = dBinsLogVector.data();
100 for( std::vector< CheckTimingDetector >::iterator det =
fvDets.begin(); det !=
fvDets.end(); ++det )
102 fvhDetSelfDiff.push_back(
new TH1D( Form(
"h%sSelfDiff", (*det).sName.data() ),
103 Form(
"time difference between consecutivs %s Digis;time diff [ns];Counts",
104 (*det).sName.data() ),
105 iNbBinsLog, dBinsLog )
109 Form(
"%s - %s time difference;time diff [ns];Counts",
111 (*det).uRangeNbBins, (*det).dTimeRangeBeg, (*det).dTimeRangeEnd )
115 Form(
"%s - %s;time diff [ns]; %s Charge [a.u]; Counts",
117 (*det).uRangeNbBins, (*det).dTimeRangeBeg, (*det).dTimeRangeEnd,
121 Form(
"%s - %s;time diff [ns]; %s Charge [a.u]; Counts",
122 (*det).sName.data(),
fRefDet.
sName.data(), (*det).sName.data() ),
123 (*det).uRangeNbBins, (*det).dTimeRangeBeg, (*det).dTimeRangeEnd,
127 Form(
"%s - %s;TS; time diff [ns];Counts",
130 (*det).uRangeNbBins, (*det).dTimeRangeBeg, (*det).dTimeRangeEnd )
133 Form(
"%s - %s;TS; time diff [ns];Counts",
136 (*det).uRangeNbBins, (*det).dTimeRangeBeg, (*det).dTimeRangeEnd )
138 LOG( info ) <<
"Created histos for " << (*det).sName;
143 Form(
"time difference between consecutivs %s Digis;time diff [ns];Counts",
145 iNbBinsLog, dBinsLog )
149 FairRunOnline* run = FairRunOnline::Instance();
152 THttpServer* server = run->GetHttpServer();
153 if(
nullptr != server )
156 for( UInt_t uDetIdx = 0; uDetIdx <
fvDets.size(); ++uDetIdx )
158 server->Register(
"/CheckTiming/SelfDiff",
fvhDetSelfDiff[ uDetIdx ] );
179 LOG(debug) <<
"executing TS " <<
fuNbTs;
183 CheckInterSystemOffset<CbmStsDigi>();
187 CheckInterSystemOffset<CbmMuchBeamTimeDigi>();
191 CheckInterSystemOffset<CbmTrdDigi>();
195 CheckInterSystemOffset<CbmTofDigi>();
199 CheckInterSystemOffset<CbmRichDigi>();
203 CheckInterSystemOffset<CbmPsdDigi>();
207 CheckInterSystemOffset<CbmTofDigi>();
211 LOG(fatal) <<
"CbmMcbm2019TimeWinEventBuilderAlgo::LoopOnSeeds => "
212 <<
"Trying to search matches with unsupported det: "
221 template<
class DigiRef>
223 UInt_t uNbRefDigis = 0;
227 <<
"CbmMcbmCheckTimingAlgo::Exec => Unknow reference detector enum! "
242 for (std::vector<CheckTimingDetector>::iterator det =
fvDets.begin();
245 (*det).iPrevRefFirstDigi = 0;
248 for (UInt_t uDigi = 0; uDigi < uNbRefDigis; ++uDigi) {
249 LOG(debug) << Form(
"Checking seed %6u / %6u", uDigi, uNbRefDigis);
251 Double_t dRefTime = 0;
252 Double_t dRefCharge = 0;
258 dRefTime =
fDigiMan->
Get<DigiRef>(uDigi)->GetTime();
259 dRefCharge =
fDigiMan->
Get<DigiRef>(uDigi)->GetCharge();
285 for (UInt_t uDetIdx = 0; uDetIdx <
fvDets.size(); ++uDetIdx) {
286 switch (
fvDets[uDetIdx].detId) {
288 FillTimeOffsetHistos<CbmStsDigi>(dRefTime, dRefCharge, uDetIdx);
292 FillTimeOffsetHistos<CbmMuchBeamTimeDigi>(
293 dRefTime, dRefCharge, uDetIdx);
297 FillTimeOffsetHistos<CbmTrdDigi>(dRefTime, dRefCharge, uDetIdx);
301 FillTimeOffsetHistos<CbmTofDigi>(dRefTime, dRefCharge, uDetIdx);
305 FillTimeOffsetHistos<CbmRichDigi>(dRefTime, dRefCharge, uDetIdx);
309 FillTimeOffsetHistos<CbmPsdDigi>(dRefTime, dRefCharge, uDetIdx);
313 FillTimeOffsetHistos<CbmTofDigi>(dRefTime, dRefCharge, uDetIdx);
317 LOG(fatal) <<
"CbmMcbmCheckTimingAlgo::CheckInterSystemOffset => "
318 <<
"Trying to search matches with unsupported det: "
329 const Double_t dRefCharge,
332 switch (
fvDets[uDetIdx].detId) {
334 LOG(fatal) <<
"CbmMcbmCheckTimingAlgo::FillTimeOffsetHistos => Unknow "
349 UInt_t uFirstDigiInWin =
fvDets[uDetIdx].iPrevRefFirstDigi;
351 for (UInt_t uDigiIdx =
fvDets[uDetIdx].iPrevRefFirstDigi; uDigiIdx < uNbDigis;
354 Double_t dCharge = 0;
361 dCharge =
fDigiMan->
Get<Digi>(uDigiIdx)->GetCharge();
366 if (
fvDets[uDetIdx].dPrevTime <= dTime) {
368 fvDets[uDetIdx].dPrevTime = dTime;
371 Double_t dDiffTime = dTime - dRefTime;
373 if (dDiffTime <
fvDets[uDetIdx].dTimeRangeBeg) {
377 if (
fvDets[uDetIdx].dTimeRangeEnd < dDiffTime) {
383 if (
fvDets[uDetIdx].uChargeCutMin !=
fvDets[uDetIdx].uChargeCutMax) {
384 if (
fvDets[uDetIdx].uChargeCutMin <
fvDets[uDetIdx].uChargeCutMax) {
386 if (
fvDets[uDetIdx].uChargeCutMin < dCharge
387 && dCharge <
fvDets[uDetIdx].uChargeCutMax) {
393 if (
fvDets[uDetIdx].uChargeCutMin < dCharge
394 || dCharge <
fvDets[uDetIdx].uChargeCutMax) {
409 fvDets[uDetIdx].iPrevRefFirstDigi = uFirstDigiInWin;
414 LOG(info) << Form(
"Checked %6d Timeslices",
fuNbTs);
421 for (UInt_t uDetIdx = 0; uDetIdx <
fvDets.size(); ++uDetIdx) {
422 LOG(info) <<
"Saving histos for " <<
fvDets[uDetIdx].sName;
429 LOG(info) <<
"Saved histos for " <<
fvDets[uDetIdx].sName;
444 Double_t dTimeRangeBegIn,
445 Double_t dTimeRangeEndIn,
446 UInt_t uRangeNbBinsIn,
447 UInt_t uChargeCutMinIn,
448 UInt_t uChargeCutMaxIn) {
459 Double_t dTimeRangeBegIn,
460 Double_t dTimeRangeEndIn,
461 UInt_t uRangeNbBinsIn,
462 UInt_t uChargeCutMinIn,
463 UInt_t uChargeCutMaxIn) {
464 std::vector<CheckTimingDetector>::iterator det;
465 for (det =
fvDets.begin(); det !=
fvDets.end(); ++det) {
466 if ((*det).detId == detIn) {
468 <<
"CbmMcbmCheckTimingAlgo::AddCheckDetector => Detector already in "
469 "list, this call will only update the parameters!";
471 (*det).dTimeRangeBeg = dTimeRangeBegIn;
472 (*det).dTimeRangeEnd = dTimeRangeEndIn;
473 (*det).uRangeNbBins = uRangeNbBinsIn;
474 (*det).uChargeCutMin = uChargeCutMinIn;
475 (*det).uChargeCutMax = uChargeCutMaxIn;
481 if (
fvDets.end() == det) {
485 (*det).dTimeRangeBeg = dTimeRangeBegIn;
486 (*det).dTimeRangeEnd = dTimeRangeEndIn;
487 (*det).uRangeNbBins = uRangeNbBinsIn;
488 (*det).uChargeCutMin = uChargeCutMinIn;
489 (*det).uChargeCutMax = uChargeCutMaxIn;
494 for (std::vector<CheckTimingDetector>::iterator det =
fvDets.begin();
497 if ((*det).detId == detIn) {