16#include "FairRootManager.h"
17#include "FairRunOnline.h"
20#include "TClonesArray.h"
24#include "THttpServer.h"
30using std::setprecision;
56 FairRootManager* ioman = FairRootManager::Instance();
62 fBmonDigiVec = ioman->InitObjectAs<std::vector<CbmTofDigi>
const*>(
"BmonDigi");
64 fBmonDigiArr =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"BmonDigi"));
65 if (!
fBmonDigiArr) { LOG(fatal) <<
"No TClonesArray with Bmon digis found."; }
88 if (offsetRange < 1001) {
fBinWidth = 5; }
89 else if (offsetRange < 10001) {
92 else if (offsetRange < 100001) {
99 if ((
static_cast<Double_t
>(offsetRange) / 6.25) == (offsetRange / 6.25))
return (offsetRange / 6.25 * 2);
107 uint32_t iNbBinsLog = 0;
110 double* dBinsLog = dBinsLogVector.data();
118 fBmonStsDiffCharge =
new TH2F(
"fBmonStsDiffCharge",
"Sts-Bmon;time diff [ns]; Charge [a.u]; Counts", nrOfBinsSts,
121 fBmonStsDiffEvo =
new TH2F(
"fBmonStsDiffEvo",
"Sts-Bmon;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsSts,
130 fBmonMuchDiffCharge =
new TH2F(
"fBmonMuchDiffCharge",
"Much-Bmon;time diff [ns]; Charge [a.u]; ;Counts", nrOfBinsMuch,
133 fBmonMuchDiffEvo =
new TH2F(
"fBmonMuchDiffEvo",
"Much-Bmon;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsMuch,
141 fBmonTrdDiffCharge =
new TH2F(
"fBmonTrdDiffCharge",
"Trd-Bmon;time diff [ns]; Charge [a.u]; ;Counts", nrOfBinsTrd,
144 fBmonTrdDiffEvo =
new TH2F(
"fBmonTrdDiffEvo",
"Trd-Bmon;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsTrd,
152 fBmonTofDiffCharge =
new TH2F(
"fBmonTofDiffCharge",
"Tof-Bmon;time diff [ns]; Charge [a.u]; ;Counts", nrOfBinsTof,
155 fBmonTofDiffEvo =
new TH2F(
"fBmonTofDiffEvo",
"Tof-Bmon;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsTof,
164 fBmonRichDiffCharge =
new TH2F(
"fBmonRichDiffCharge",
"Rich-Bmon;time diff [ns]; Charge [a.u]; ;Counts", nrOfBinsRich,
167 fBmonRichDiffEvo =
new TH2F(
"fBmonRichDiffEvo",
"Rich-Bmon;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsRich,
175 fBmonPsdDiffCharge =
new TH2F(
"fBmonPsdDiffCharge",
"Psd-Bmon;time diff [ns]; Charge [a.u]; ;Counts", nrOfBinsPsd,
178 fBmonPsdDiffEvo =
new TH2F(
"fBmonPsdDiffEvo",
"Psd-Bmon;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsPsd,
182 fBmonStsDiffEvoLong =
new TH2F(
"fBmonStsDiffEvoLong",
"Sts-Bmon;TS; time diff [ns];Counts", 1800, 0, 180000,
185 fBmonMuchDiffEvoLong =
new TH2F(
"fBmonMuchDiffEvoLong",
"Much-Bmon;TS; time diff [ns];Counts", 1800, 0, 180000,
188 fBmonTrdDiffEvoLong =
new TH2F(
"fBmonTrdDiffEvoLong",
"Trd-Bmon;TS; time diff [ns];Counts", 1800, 0, 180000,
191 fBmonTofDiffEvoLong =
new TH2F(
"fBmonTofDiffEvoLong",
"Tof-Bmon;TS; time diff [ns];Counts", 1800, 0, 180000,
194 fBmonRichDiffEvoLong =
new TH2F(
"fBmonRichDiffEvoLong",
"Rich-Bmon;TS; time diff [ns];Counts", 1800, 0, 180000,
198 fBmonPsdDiffEvoLong =
new TH2F(
"fBmonPsdDiffEvoLong",
"Psd-Bmon;TS; time diff [ns];Counts", 1800, 0, 180000,
202 fBmonStsDpbDiff =
new TH2F(
"fBmonStsDpbDiff",
"Much-Bmon;DPB; time diff [ns];Counts", 2, -0.5, 1.5, nrOfBinsSts,
207 new TH2F(Form(
"fBmonStsDpbDiffEvo%02u", uStsDpb), Form(
"Sts-Bmon DPB %02u;TS; time diff [ns];Counts", uStsDpb),
210 new TH1F(Form(
"fStsDpbCntsEvo%02u", uStsDpb), Form(
"Time STS DPB %02u;TS; Hit Counts", uStsDpb), 1800, 0, 180000);
223 Form(
"Much-Bmon ASIC %02u;TS; time diff [ns];Counts", uMuchAsic), 1800,
227 fBmonBmonDiff =
new TH1F(
"fBmonBmonDiff",
"Bmon-Bmon_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
229 fStsStsDiff =
new TH1F(
"fStsStsDiff",
"Sts-Sts_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
231 fMuchMuchDiff =
new TH1F(
"fMuchMuchDiff",
"Much-Much_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
233 fTrdTrdDiff =
new TH1F(
"fTrdTrdDiff",
"Trd-Trd_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
235 fTofTofDiff =
new TH1F(
"fTofTofDiff",
"Tof-Tof_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
237 fRichRichDiff =
new TH1F(
"fRichRichDiff",
"Rich-Rich_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
239 fPsdPsdDiff =
new TH1F(
"fPsdPsdDiff",
"Psd-Psd_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
241 fBmonAddress =
new TH1F(
"fBmonAddress",
"Bmon address;address;Counts", 1000000, 0, 1000000.);
243 fBmonChannel =
new TH1F(
"fBmonChannel",
"Bmon channel;channel nr;Counts", 100, -0.5, 99.5);
245 fSelBmonStsDiff =
new TH1F(
"fSelBmonStsDiff",
"Sts-Bmon if Bmon in coinc with TOF;time diff [ns];Counts", nrOfBinsSts,
247 fSelBmonMuchDiff =
new TH1F(
"fSelBmonMuchDiff",
"Much-Bmon if Bmon in coinc with TOF;time diff [ns];Counts",
249 fSelBmonTrdDiff =
new TH1F(
"fSelBmonTrdDiff",
"Trd-Bmon if Bmon in coinc with TOF;time diff [ns];Counts", nrOfBinsTrd,
251 fSelBmonTofDiff =
new TH1F(
"fSelBmonTofDiff",
"Tof-Bmon if Bmon in coinc with TOF;time diff [ns];Counts", nrOfBinsTof,
253 fSelBmonRichDiff =
new TH1F(
"fSelBmonRichDiff",
"Rich-Bmon if Bmon in coinc with TOF;time diff [ns];Counts",
255 fSelBmonPsdDiff =
new TH1F(
"fSelBmonPsdDiff",
"Psd-Bmon if Bmon in coinc with TOF;time diff [ns];Counts", nrOfBinsPsd,
262 FairRunOnline* run = FairRunOnline::Instance();
264 THttpServer* server = run->GetHttpServer();
265 if (
nullptr != server) {
322 LOG(debug) <<
"executing TS " <<
fNrTs;
327 LOG(info) <<
"Fitting peaks for number of TS = " <<
fNrTs;
336 LOG(debug) <<
"Begin";
337 Int_t nrBmonDigis = 0;
341 LOG(debug) <<
"BmonDigis: " << nrBmonDigis;
343 Int_t nrStsDigis {0};
346 LOG(debug) <<
"StsDigis: " << nrStsDigis;
349 Int_t nrMuchDigis {0};
352 LOG(debug) <<
"MuchDigis: " << nrMuchDigis;
355 Int_t nrTrdDigis {0};
358 LOG(debug) <<
"TrdDigis: " << nrTrdDigis;
361 Int_t nrTofDigis {0};
364 LOG(debug) <<
"TofDigis: " << nrTofDigis;
367 Int_t nrRichDigis {0};
370 LOG(debug) <<
"RichDigis: " << nrRichDigis;
373 Int_t nrPsdDigis {0};
376 LOG(debug) <<
"PsdDigis: " << nrPsdDigis;
380 if (nrBmonDigis < 1000000) {
391 for (Int_t iBmon = 0; iBmon < nrBmonDigis; ++iBmon) {
393 if (iBmon % 1000 == 0) LOG(debug) <<
"Executing entry " << iBmon;
404 Double_t T0Time = BmonDigi->
GetTime();
410 if (nrStsDigis > 0 && nrStsDigis < 1000000)
416 if (nrMuchDigis > 0 && nrMuchDigis < 1000000)
420 if (nrTrdDigis > 0 && nrTrdDigis < 1000000)
425 if (nrTofDigis > 0 && nrTofDigis < 1000000)
429 if (nrRichDigis > 0 && nrRichDigis < 1000000)
433 if (nrPsdDigis > 0 && nrPsdDigis < 1000000)
449 if (nrStsDigis > 0 && nrStsDigis < 1000000)
455 if (nrMuchDigis > 0 && nrMuchDigis < 1000000)
459 if (nrTrdDigis > 0 && nrTrdDigis < 1000000)
463 if (nrTofDigis > 0 && nrTofDigis < 1000000)
467 if (nrRichDigis > 0 && nrRichDigis < 1000000)
471 if (nrPsdDigis > 0 && nrPsdDigis < 1000000)
481 TH2* histoAFCK,
const Double_t T0Time,
const Int_t offsetRange,
482 Int_t iStartDigi, Bool_t bSts, Bool_t bMuch, Bool_t bTof, Bool_t )
485 Int_t iFirstDigiInWin = iStartDigi;
487 for (Int_t i = iStartDigi; i < nrDigis; ++i) {
497 if( digi->GetCharge() < 2 )
502 if( ( digi->GetCharge() < 7 || 31 == digi->GetCharge() ) ||
503 ( 0 == ( digi->GetChannel() % 2 ) ) )
508 if( digi->GetAddress() != (0<<10)+8 )
513 Double_t diffTime = digi->GetTime() - T0Time;
515 if (diffTime < -offsetRange) {
519 if (diffTime > offsetRange)
break;
520 histo->Fill(diffTime);
521 histoCharge->Fill(diffTime, digi->GetCharge());
522 histoEvo->Fill(
fNrTs, diffTime);
523 histoEvoLong->Fill(
fNrTs, diffTime);
526 if (bSts && histoAFCK) {
527 UInt_t uDPB = (0 < (digi->GetAddress() & 0x00000400));
528 histoAFCK->Fill(uDPB, diffTime);
533 if (bMuch && histoAFCK) {
536 muchDigi = boost::any_cast<const CbmMuchBeamTimeDigi*>(digi);
539 LOG(fatal) <<
"Failed boost any_cast in CbmCheckTiming::FillSystemOffsetHistos "
540 "for a digi of type "
541 << Digi::GetClassName();
545 UInt_t asic = muchDigi->
GetNxId();
546 histoAFCK->Fill(afck, diffTime);
555 return iFirstDigiInWin;
560 Bool_t , Bool_t , Bool_t bTof, Bool_t )
563 Int_t iFirstDigiInWin = iStartDigi;
565 for (Int_t i = iStartDigi; i < nrDigis; ++i) {
575 if( digi->GetCharge() < 2 )
580 if( ( digi->GetCharge() < 7 || 31 == digi->GetCharge() ) ||
581 ( 0 == ( digi->GetChannel() % 2 ) ) )
586 if( digi->GetAddress() != (0<<10)+8 )
591 Double_t diffTime = digi->GetTime() - T0Time;
593 if (diffTime < -offsetRange) {
597 if (diffTime > offsetRange)
break;
598 histo->Fill(diffTime);
601 return iFirstDigiInWin;
607 Int_t nrBmonDigis = 0;
619 for (Int_t i = 0; i < nrStsDigis; ++i) {
621 UInt_t uDPB = (0 < (Digi->
GetAddress() & 0x00000400));
655 Int_t nrOfErrors = 0;
658 for (Int_t i = 0; i < nrDigis; ++i) {
662 Double_t diffTime = digi->GetTime() - prevTime;
663 histo->Fill(diffTime);
666 LOG(info) << fixed << setprecision(15) << diffTime <<
"ns";
667 LOG(info) <<
"Previous " << detector <<
" digi (" << fixed << setprecision(15) << prevTime * 1.e-9
668 <<
") has a larger time than the current one (" << digi->GetTime() * 1.e-9 <<
") for digi " << i
669 <<
" of ts " <<
fNrTs;
673 prevTime = digi->GetTime();
683 Int_t nrOfErrors = 0;
690 for (Int_t i = 0; i < nrDigis; ++i) {
701 Double_t diffTime = digi->
GetTime() - prevTime;
702 histo->Fill(diffTime);
705 LOG(info) << fixed << setprecision(15) << diffTime <<
"ns";
706 LOG(info) <<
"Previous " << detector <<
" digi (" << fixed << setprecision(15) << prevTime * 1.e-9
707 <<
") has a larger time than the current one (" << digi->
GetTime() * 1.e-9 <<
") for digi " << i
708 <<
" of ts " <<
fNrTs;
723 LOG(info) <<
"Total number of Bmon out of order digis: " <<
fNrOfBmonErrors;
725 LOG(info) <<
"Total number of Sts out of order digis: " <<
fNrOfStsErrors;
727 LOG(info) <<
"Total number of Much out of order digis: " <<
fNrOfMuchErrors;
729 LOG(info) <<
"Total number of Trd out of order digis: " <<
fNrOfTrdErrors;
731 LOG(info) <<
"Total number of Tof out of order digis: " <<
fNrOfTofErrors;
733 LOG(info) <<
"Total number of Rich out of order digis: " <<
fNrOfRichErrors;
735 LOG(info) <<
"Total number of Psd out of order digis: " <<
fNrOfPsdErrors;
741 LOG(info) << Form(
"Checked %6d Timeslices",
fNrTs);
768 LOG(info) <<
"STS entries = " <<
fBmonStsDiff->GetEntries();
769 LOG(info) <<
"STS-Bmon entries if Bmon in coincidence with TOF = " <<
fSelBmonStsDiff->GetEntries();
770 LOG(info) <<
"MUCH entries = " <<
fBmonMuchDiff->GetEntries();
771 LOG(info) <<
"MUCH-Bmon entries if Bmon in coincidence with TOF = " <<
fSelBmonMuchDiff->GetEntries();
772 LOG(info) <<
"TRD entries = " <<
fBmonTrdDiff->GetEntries();
773 LOG(info) <<
"TRD-Bmon entries if Bmon in coincidence with TOF = " <<
fSelBmonTrdDiff->GetEntries();
774 LOG(info) <<
"TOF entries = " <<
fBmonTofDiff->GetEntries();
775 LOG(info) <<
"RICH entries = " <<
fBmonRichDiff->GetEntries();
776 LOG(info) <<
"RICH-Bmon entries if Bmon in coincidence with TOF = " <<
fSelBmonRichDiff->GetEntries();
777 LOG(info) <<
"PSD entries = " <<
fBmonPsdDiff->GetEntries();
778 LOG(info) <<
"PSD-Bmon entries if Bmon in coincidence with TOF = " <<
fSelBmonPsdDiff->GetEntries();
779 LOG(info) <<
"STS peak position [ns] = " <<
sts_peak_pos;
780 LOG(info) <<
"STS peak position [ns] if Bmon in coincidence with TOF = " <<
sts_coin_peak_pos;
782 LOG(info) <<
"MUCH peak position [ns] if Bmon in coincidence with TOF = " <<
much_coin_peak_pos;
783 LOG(info) <<
"TRD peak position [ns] = " <<
trd_peak_pos;
784 LOG(info) <<
"TRD peak position [ns] if Bmon in coincidence with TOF = " <<
trd_coin_peak_pos;
785 LOG(info) <<
"TOF peak position [ns] = " <<
tof_peak_pos;
787 LOG(info) <<
"RICH peak position [ns] if Bmon in coincidence with TOF = " <<
rich_coin_peak_pos;
788 LOG(info) <<
"PSD peak position [ns] = " <<
psd_peak_pos;
789 LOG(info) <<
"PSD peak position [ns] if Bmon in coincidence with TOF = " <<
psd_coin_peak_pos;
805 TF1* fitresult_trd =
fBmonTrdDiff->GetFunction(
"gs_trd");
806 LOG(info) <<
"TRD parameters from Gauss fit = " << fitresult_trd->GetParameter(0) <<
", "
807 << fitresult_trd->GetParameter(1) <<
", " << fitresult_trd->GetParameter(2);
808 LOG(info) <<
"TRD signal/background (p0/p3) = "
809 << (fitresult_trd->GetParameter(0)) / (fitresult_trd->GetParameter(3));
818 TF1* fitresult_sts =
fBmonStsDiff->GetFunction(
"gs_sts");
819 LOG(info) <<
"STS parameters from Gauss fit = " << fitresult_sts->GetParameter(0) <<
", "
820 << fitresult_sts->GetParameter(1) <<
", " << fitresult_sts->GetParameter(2);
821 LOG(info) <<
"STS signal/background (p0/p3) = "
822 << (fitresult_sts->GetParameter(0)) / (fitresult_sts->GetParameter(3));
832 LOG(info) <<
"MUCH parameters from Gauss fit = " << fitresult_much->GetParameter(0) <<
", "
833 << fitresult_much->GetParameter(1) <<
", " << fitresult_much->GetParameter(2);
834 LOG(info) <<
"MUCH signal/background (p0/p3) = "
835 << (fitresult_much->GetParameter(0)) / (fitresult_much->GetParameter(3));
844 TF1* fitresult_tof =
fBmonTofDiff->GetFunction(
"gs_tof");
845 LOG(info) <<
"TOF parameters from Gauss fit = " << fitresult_tof->GetParameter(0) <<
", "
846 << fitresult_tof->GetParameter(1) <<
", " << fitresult_tof->GetParameter(2);
847 LOG(info) <<
"TOF signal/background (p0/p3) = "
848 << (fitresult_tof->GetParameter(0)) / (fitresult_tof->GetParameter(3));
858 LOG(info) <<
"RICH parameters from Gauss fit = " << fitresult_rich->GetParameter(0) <<
", "
859 << fitresult_rich->GetParameter(1) <<
", " << fitresult_rich->GetParameter(2);
860 LOG(info) <<
"RICH signal/background (p0/p3) = "
861 << (fitresult_rich->GetParameter(0)) / (fitresult_rich->GetParameter(3));
870 TF1* fitresult_psd =
fBmonPsdDiff->GetFunction(
"gs_psd");
871 LOG(info) <<
"PSD parameters from Gauss fit = " << fitresult_psd->GetParameter(0) <<
", "
872 << fitresult_psd->GetParameter(1) <<
", " << fitresult_psd->GetParameter(2);
873 LOG(info) <<
"PSD signal/background (p0/p3) = "
874 << (fitresult_psd->GetParameter(0)) / (fitresult_psd->GetParameter(3));
ClassImp(CbmConverterManager)
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kRich
Ring-Imaging Cherenkov Detector.
TClonesArray * fBmonDigiArr
Double_t sts_coin_peak_pos
TH2 * fBmonMuchAsicDiffEvo[kuMaxNbMuchAsics]
Double_t much_coin_peak_pos
TH1 * fStsDpbCntsEvo[kuMaxNbStsDpbs]
Int_t fPrevBmonFirstDigiTrd
TH2 * fBmonStsDpbDiffEvo[kuMaxNbStsDpbs]
virtual InitStatus Init()
const std::vector< CbmTofDigi > * fBmonDigiVec
TH2 * fBmonRichDiffCharge
TH2 * fBmonTrdDiffEvoLong
Int_t fPrevBmonFirstDigiMuch
static const UInt_t kuMaxNbStsDpbs
Double_t fMuchPeakWidthNs
TH2 * fBmonPsdDiffEvoLong
void CheckInterSystemOffset()
virtual InitStatus ReInit()
Double_t psd_coin_peak_pos
Int_t FillHistosSelBmon(TH1 *histo, const Double_t T0Time, const Int_t offsetRange, Int_t iStartDigi, Bool_t bSts=kFALSE, Bool_t bMuch=kFALSE, Bool_t bTof=kFALSE, Bool_t bPsd=kFALSE)
Int_t fPrevBmonFirstDigiSts
TH2 * fBmonRichDiffEvoLong
Double_t rich_coin_peak_pos
Double_t fPrevTimeBmon
Variables to store the previous digi time.
Double_t trd_coin_peak_pos
Bool_t fCheckTimeOrdering
Int_t fPrevBmonFirstDigiRich
static const UInt_t kuMaxNbMuchDpbs
CbmDigiManager * fDigiMan
Int_t fPrevBmonFirstDigiTof
Int_t FillSystemOffsetHistos(TH1 *histo, TH2 *histoCharge, TH2 *histoEvo, TH2 *histoEvoLong, TH2 *histoAFCK, const Double_t T0Time, const Int_t offsetRange, Int_t iStartDigi, Bool_t bSts=kFALSE, Bool_t bMuch=kFALSE, Bool_t bTof=kFALSE, Bool_t bPsd=kFALSE)
TH2 * fBmonMuchDiffCharge
Int_t CheckIfSorted(TH1 *, Double_t &, TString)
std::vector< Double_t > fvdTimeSelectedBmon
virtual void SetParContainers()
TH2 * fBmonTofDiffEvoLong
TH2 * fBmonMuchDiffEvoLong
static const UInt_t kuMaxNbMuchAsics
UInt_t fuMinTotPulserBmon
User settings: Data correction parameters.
TH2 * fBmonStsDiffEvoLong
UInt_t fuMaxTotPulserBmon
Int_t CheckIfSortedBmon(TH1 *, Double_t &, TString)
Double_t fRichPeakWidthNs
Int_t fPrevBmonFirstDigiPsd
virtual void Exec(Option_t *)
Bool_t fCheckInterSystemOffset
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
void UseMuchBeamTimeDigi(Bool_t)
Use CbmMuchBeamTimeDigi instead of CbmMuchDigi for MUCH.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
Data class for a single-channel message in the STS.
XPU_D int32_t GetAddress() const
Data class for expanded digital TOF information.
double GetChannel() const
Channel .
int32_t GetAddress() const
Inherited from CbmDigi.
double GetTime() const
Inherited from CbmDigi.
double GetCharge() const
Inherited from CbmDigi.