8#include "BmnTrigDigit.h"
10#include "BmnTrigWaveDigit.h"
11#include "FairRootManager.h"
13#include <TStopwatch.h>
17static Double_t workTime = 0.0;
23 LOG(debug) <<
"Defaul Constructor of BmnFillTrigInfoDst";
30 , doProcessTriggers(true)
31 , fDigiEventHeader(nullptr)
37 , fSiMDDigits(nullptr)
39 , fBC1Digits_Top(nullptr)
40 , fBC1Digits_Bottom(nullptr)
43 fGr4FitBC1Top =
new TGraph();
44 fGr4FitBC1Bottom =
new TGraph();
45 f_gaus =
new TF1(
"f_gaus",
"gaus", 0, 500);
49 f_BC1 =
new TF1(
"f_BC1",
"[0] + [1]*TMath::Exp([2]*([3]+x))", 0, 20000);
50 f_BC1->SetParameters(1.07489, -3.01848, -0.000169763, 358.637);
60 LOG(debug) <<
"Constructor with experimental data flag of BmnFillTrigInfoDst";
66 LOG(debug) <<
"Destructor of BmnFillTrigInfoDst";
74 LOG(debug) <<
"Initialization of BmnFillTrigInfoDst";
77 FairRootManager* ioman = FairRootManager::Instance();
79 LOG(error) <<
"Init: FairRootManager is not instantiated! BmnFillTrigInfoDst task will be deactivated";
86 fDigiEventHeader = (
BmnEventHeader*)ioman->GetObject(
"BmnEventHeader.");
87 fVCDigits = (TClonesArray*)ioman->GetObject(
"TQDC_VCS");
88 fBC0Digits = (TClonesArray*)ioman->GetObject(
"TQDC_BC0");
89 fBC1Digits = (TClonesArray*)ioman->GetObject(
"TQDC_BC1S");
91 fBC1Digits = (TClonesArray*)ioman->GetObject(
"TQDC_BC1");
92 fBC2Digits = (TClonesArray*)ioman->GetObject(
"TQDC_BC2AS");
94 fBC2Digits = (TClonesArray*)ioman->GetObject(
"TQDC_BC2");
95 fBDDigits = (TClonesArray*)ioman->GetObject(
"BD");
96 fSiMDDigits = (TClonesArray*)ioman->GetObject(
"SiMD");
97 fFDDigits = (TClonesArray*)ioman->GetObject(
"TQDC_FD");
98 fBC1Digits_Top = (TClonesArray*)ioman->GetObject(
"TQDC_BC1T");
99 fBC1Digits_Bottom = (TClonesArray*)ioman->GetObject(
"TQDC_BC1B");
101 fBDDigits = (TClonesArray*)ioman->GetObject(
"BdDigit");
102 fFDDigits = (TClonesArray*)ioman->GetObject(
"FDPoint");
105 if (isExpData && !fVCDigits && !fBC0Digits && !fBC1Digits && !fBC2Digits && !fBDDigits && !fSiMDDigits
108 LOG(error) <<
"Init: all trigger branches not found! BmnFillTrigInfoDst task will process only basic data";
109 doProcessTriggers =
false;
116 ioman->Register(
"BmnTrigInfo.",
"TRIGGER", fTrigInfo, kTRUE);
118 LOG(error) <<
"Init: BmnTrigInfo not created! BmnFillTrigInfoDst task will be deactivated";
136 cout <<
"\n======================== BmnFillTrigInfoDst exec started =====================\n" << endl;
140 if (fDigiEventHeader) {
146 if (doProcessTriggers) {
147 if (fVCDigits && fVCDigits->GetEntriesFast() > 0) {
151 if (fBC0Digits && fBC0Digits->GetEntriesFast() > 0) {
156 if (fBC1Digits && fBC1Digits->GetEntriesFast() > 0) {
162 if (fBC2Digits && fBC2Digits->GetEntriesFast() > 0) {
168 fTrigInfo->
SetBDMult(fBDDigits->GetEntriesFast());
169 fTrigInfo->
GetBDDigits()->AbsorbObjects(fBDDigits);
172 fTrigInfo->
SetSiMDMult(fSiMDDigits->GetEntriesFast());
173 if (fFDDigits && fFDDigits->GetEntriesFast() > 0) {
178 fTrigInfo->
GetFDDigits()->AbsorbObjects(fFDDigits);
180 if (isExpData && fBC1Digits_Top && fBC1Digits_Top->GetEntriesFast() > 0 && fBC1Digits_Bottom
181 && fBC1Digits_Bottom->GetEntriesFast() > 0)
183 Float_t* amp_temp =
new Float_t();
194 workTime += sw.RealTime();
200 LOG(debug) <<
"Finish of BmnFillTrigInfoDst";
201 printf(
"Work time of BmnFillTrigInfoDst: %4.2f sec.\n", workTime);
205Float_t BmnFillTrigInfoDst::CalculateT0(Float_t* amp)
217 vector<Double_t> vtimeBC1T = digBC1T->
TdcVector();
218 vector<Double_t> vtimeBC1B = digBC1B->
TdcVector();
220 if (nSemplesWF <= 0 || LimitWvHgh >= nSemplesWF)
223 if (vtimeBC1T.size() == 0 || vtimeBC1B.size() == 0)
226 if (valBC1T ==
nullptr || valBC1B ==
nullptr)
229 Double_t timeBC1 = 0, timeBC1T = 0, timeBC1B = 0;
232 timeBC1T = FindTimeFromVector(vtimeBC1T);
233 timeBC1B = FindTimeFromVector(vtimeBC1B);
234 timeBC1 = (timeBC1T + timeBC1B) * 0.5;
237 Double_t maxBC1T = 0, maxBC1B = 0, maxBC1T_fit = 0, maxBC1B_fit = 0;
238 Double_t maxStBC1T = 0, maxStBC1B = 0;
240 ClearTGraph(fGr4FitBC1Top);
241 ClearTGraph(fGr4FitBC1Bottom);
242 for (Int_t ist = LimitWvLow; ist < LimitWvHgh; ist++) {
243 fGr4FitBC1Top->AddPoint(ist, valBC1T[ist]);
244 fGr4FitBC1Bottom->AddPoint(ist, valBC1B[ist]);
245 if (maxBC1T < valBC1T[ist]) {
246 maxBC1T = valBC1T[ist];
247 maxStBC1T = (Double_t)ist;
249 if (maxBC1B < valBC1B[ist]) {
250 maxBC1B = valBC1B[ist];
251 maxStBC1B = (Double_t)ist;
255 f_gaus->SetParameters(maxBC1T, maxStBC1T, 1);
256 fGr4FitBC1Top->Fit(f_gaus,
"QW",
"", maxStBC1T - GateFitLow, maxStBC1T + GateFitHgh);
257 maxBC1T_fit = f_gaus->GetParameter(0);
259 f_gaus->SetParameters(maxBC1B, maxStBC1B, 1);
260 fGr4FitBC1Bottom->Fit(f_gaus,
"QW",
"", maxStBC1B - GateFitLow, maxStBC1B + GateFitHgh);
261 maxBC1B_fit = f_gaus->GetParameter(0);
264 Double_t gAmpBC1 = TMath::Sqrt(maxBC1T_fit * maxBC1B_fit);
268 tempT0 = timeBC1 + f_BC1->Eval(gAmpBC1);
276Double_t BmnFillTrigInfoDst::FindTimeFromVector(vector<Double_t> vtime)
279 for (UInt_t
i = 0;
i < vtime.size();
i++) {
280 if (vtime.at(
i) > LimitTdcLow && vtime.at(
i) < LimitTdcHgh)
287void BmnFillTrigInfoDst::ClearTGraph(TGraph* g1)
292 for (
int ip = g1->GetN() - 1; ip >= 0; ip--) {
virtual void Exec(Option_t *opt)
virtual InitStatus Init()
void SetT0_time(Float_t v)
void SetSiMDMult(UInt_t a)
void SetInputSignalsVector(vector< uint32_t > v)
void SetT0_amp(Float_t v)
void SetBC2Amp(Float_t a)
TClonesArray * GetBDDigits()
TClonesArray * GetBC0Digits()
TClonesArray * GetBC1Digits()
TClonesArray * GetBC2Digits()
void SetInputSignalsAR(UInt_t v)
void SetBC1Amp(Float_t a)
void SetInputSignalsBR(UInt_t v)
TClonesArray * GetFDDigits()
void SetBC1Integral(Float_t a)
void SetBC0Amp(Float_t a)
Short_t * GetShortValue() const
int GetPeak(UInt_t start=0, UInt_t stop=1e9) const
UInt_t GetNSamples() const
vector< Double_t > & TdcVector()
int GetIntegral(UInt_t start=0, UInt_t stop=1e9) const