CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2019TimeWinEventBuilderAlgo.h
Go to the documentation of this file.
1/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5#ifndef CBMMCBM2019TIMEWINEVENTBUILDERALGO_H
6#define CBMMCBM2019TIMEWINEVENTBUILDERALGO_H
7
9#include "CbmTofDigi.h"
10
12#include "FairTask.h"
13
15
17#include <tuple>
18
19#include <array>
20#include <map>
21#include <set>
22#include <vector>
23
25class CbmEvent;
26class CbmDigiManager;
27class TClonesArray;
28class TH1;
29class TH2;
30class TNamed;
31class TCanvas;
32
33enum class EOverlapMode
34{
38};
39
41public:
43 EventBuilderDetector(ECbmModuleId detIdIn, ECbmDataType dataTypeIn, std::string sNameIn)
44 {
45 detId = detIdIn;
46 dataType = dataTypeIn;
47 sName = sNameIn;
48 }
49 EventBuilderDetector(ECbmModuleId detIdIn, ECbmDataType dataTypeIn, std::string sNameIn, UInt_t uTriggerMinDigisIn,
50 Int_t iTriggerMaxDigisIn, Double_t fdTimeWinBegIn, Double_t fdTimeWinEndIn)
51 : EventBuilderDetector(detIdIn, dataTypeIn, sNameIn)
52 {
53 fuTriggerMinDigis = uTriggerMinDigisIn;
54 fiTriggerMaxDigis = iTriggerMaxDigisIn;
55
56 fdTimeWinBeg = fdTimeWinBegIn;
57 fdTimeWinEnd = fdTimeWinEndIn;
58 }
59
60 bool operator==(const EventBuilderDetector& other) const { return (other.detId == this->detId); }
61 bool operator!=(const EventBuilderDetector& other) const { return (other.detId != this->detId); }
62
63 Double_t GetTimeWinRange() { return fdTimeWinEnd - fdTimeWinBeg; }
64
68 std::string sName = "Invalid";
74 Double_t fdTimeWinBeg = -100;
75 Double_t fdTimeWinEnd = 100;
76
78 UInt_t fuStartIndex = 0;
79 UInt_t fuEndIndex = 0;
80};
81
98
100public:
103
106
109
111 Bool_t InitAlgo();
112
114 void ProcessTs();
115
117 void Finish();
118
119 void SetFillHistos(Bool_t var) { fbFillHistos = var; }
120 void ResetHistograms(Bool_t bResetTime = kTRUE);
121
122 void SetReferenceDetector(ECbmModuleId refDet, ECbmDataType dataTypeIn, std::string sNameIn,
123 UInt_t uTriggerMinDigisIn = 0, Int_t iTriggerMaxDigisIn = -1,
124 Double_t fdTimeWinBegIn = -100, Double_t fdTimeWinEndIn = 100);
125 void AddDetector(ECbmModuleId selDet, ECbmDataType dataTypeIn, std::string sNameIn, UInt_t uTriggerMinDigisIn = 0,
126 Int_t iTriggerMaxDigisIn = -1, Double_t fdTimeWinBegIn = -100, Double_t fdTimeWinEndIn = 100);
127
131
132 void SetTriggerMinNumber(ECbmModuleId selDet, UInt_t uVal);
133 void SetTriggerMaxNumber(ECbmModuleId selDet, Int_t iVal);
134
135 void SetTriggerWindow(ECbmModuleId selDet, Double_t dWinBeg, Double_t dWinEnd);
136
137 void SetTsParameters(Double_t dTsStartTime, Double_t dTsLength, Double_t dTsOverLength)
138 {
140 fdTsLength = dTsLength;
141 fdTsOverLength = dTsOverLength;
142 }
143
146 void SetIgnoreTsOverlap(Bool_t bFlagIn = kTRUE) { fbIgnoreTsOverlap = bFlagIn; }
147
148 void ChangeMuchBeamtimeDigiFlag(Bool_t bFlagIn = kFALSE) { fbUseMuchBeamtimeDigi = bFlagIn; }
149
151 void AddHistoToVector(TNamed* pointer, std::string sFolder = "")
152 {
153 fvpAllHistoPointers.push_back(std::pair<TNamed*, std::string>(pointer, sFolder));
154 }
155 std::vector<std::pair<TNamed*, std::string>> GetHistoVector() { return fvpAllHistoPointers; }
156 void AddCanvasToVector(TCanvas* pointer, std::string sFolder = "")
157 {
158 fvpAllCanvasPointers.push_back(std::pair<TCanvas*, std::string>(pointer, sFolder));
159 }
160 std::vector<std::pair<TCanvas*, std::string>> GetCanvasVector() { return fvpAllCanvasPointers; }
161
163 std::vector<CbmEvent*>& GetEventVector() { return fEventVector; }
164 void ClearEventVector();
165
166private:
169 void InitTs();
170 void BuildEvents();
171
172 void CreateHistograms();
173 void FillHistos();
174
175 template<class DigiSeed>
176 void LoopOnSeeds();
177 void CheckSeed(Double_t dSeedTime, UInt_t uSeedDigiIdx);
178 template<class DigiCheck>
179 void SearchMatches(Double_t dSeedTime, EventBuilderDetector& detMatch);
180 void AddDigiToEvent(EventBuilderDetector& det, Int_t uIdx);
181 Bool_t HasTrigger(CbmEvent*);
183
186
188 static constexpr Double_t kdDefaultTimeWinBeg = -100.0;
189 static constexpr Double_t kdDefaultTimeWinEnd = 100.0;
190
193 Bool_t fbIgnoreTsOverlap = kFALSE;
194 Bool_t fbFillHistos {kTRUE};
195 Bool_t fbUseMuchBeamtimeDigi = kTRUE;
198
207
211
212 Double_t fdTsStartTime = -1;
213 Double_t fdTsLength = -1;
214 Double_t fdTsOverLength = -1;
215
220 const std::vector<CbmTofDigi>* fBmonDigiVec = nullptr;
221 TClonesArray* fTimeSliceMetaDataArray = nullptr;
223
226 std::vector<CbmEvent*> fEventVector = {};
227
239 std::vector<std::pair<TNamed*, std::string>>
241 std::vector<std::pair<TCanvas*, std::string>>
243
244 TH1* fhEventTime = nullptr;
245 TH1* fhEventDt = nullptr;
246 TH1* fhEventSize = nullptr;
247 TH2* fhNbDigiPerEvtTime = nullptr;
248 std::vector<TH2*> fvhNbDigiPerEvtTimeDet =
249 {};
250
252 UInt_t fuCurEv = 0;
253 UInt_t fuErrors = 0;
254 UInt_t fuNrTs = 0;
255 Double_t fdPrevEvtTime = 0.;
256 Double_t fdPrevEvtEndTime = 0.;
257
259};
260
261#endif // CBMMCBM2019TIMEWINEVENTBUILDERALGO_H
ECbmDataType
Definition CbmDefs.h:90
ECbmModuleId
Definition CbmDefs.h:39
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kNotExist
If not found.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kRich
Ring-Imaging Cherenkov Detector.
static const EventBuilderDetector kEventBuilderDetSts
Pre-defined detector types.
static const EventBuilderDetector kEventBuilderDetPsd
static const EventBuilderDetector kEventBuilderDetUndef
static const EventBuilderDetector kEventBuilderDetBmon
static const EventBuilderDetector kEventBuilderDetTrd
static const EventBuilderDetector kEventBuilderDetRich
static const EventBuilderDetector kEventBuilderDetMuch
static const EventBuilderDetector kEventBuilderDetTof
static double dTsStartTime
CbmDigiManager.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
TH2 * fhNbDigiPerEvtTime
histogram with the nb of all digis in the event
void SetTsParameters(Double_t dTsStartTime, Double_t dTsLength, Double_t dTsOverLength)
void CheckSeed(Double_t dSeedTime, UInt_t uSeedDigiIdx)
CbmMcbm2019TimeWinEventBuilderAlgo(const CbmMcbm2019TimeWinEventBuilderAlgo &)=delete
std::vector< std::pair< TNamed *, std::string > > fvpAllHistoPointers
vector with all created events
void SetTriggerWindow(ECbmModuleId selDet, Double_t dWinBeg, Double_t dWinEnd)
void AddDigiToEvent(EventBuilderDetector &det, Int_t uIdx)
static constexpr Double_t kdDefaultTimeWinBeg
Constants.
TH1 * fhEventSize
histogram with the interval in seed time of consecutive events
Bool_t CheckDataAvailable(EventBuilderDetector &det)
Internal methods.
void SetTriggerMinNumber(ECbmModuleId selDet, UInt_t uVal)
Bool_t fbFillHistos
Ignore data in Overlap part of the TS.
Bool_t fbUseMuchBeamtimeDigi
Switch ON/OFF filling of histograms.
EOverlapMode fOverMode
Event building mode and detectors selection.
std::vector< TH2 * > fvhNbDigiPerEvtTimeDet
histogram with the nb of all digis per event vs seed time of the events
void SetReferenceDetector(ECbmModuleId refDet, ECbmDataType dataTypeIn, std::string sNameIn, UInt_t uTriggerMinDigisIn=0, Int_t iTriggerMaxDigisIn=-1, Double_t fdTimeWinBegIn=-100, Double_t fdTimeWinEndIn=100)
void AddDetector(ECbmModuleId selDet, ECbmDataType dataTypeIn, std::string sNameIn, UInt_t uTriggerMinDigisIn=0, Int_t iTriggerMaxDigisIn=-1, Double_t fdTimeWinBegIn=-100, Double_t fdTimeWinEndIn=100)
ClassDefNV(CbmMcbm2019TimeWinEventBuilderAlgo, 1)
Save previous event last digi time information.
std::vector< std::pair< TNamed *, std::string > > GetHistoVector()
void AddHistoToVector(TNamed *pointer, std::string sFolder="")
For monitor algos.
UInt_t fuCurEv
histograms with the nb of digis in each detector per event vs seed time of the events
std::vector< std::pair< TCanvas *, std::string > > fvpAllCanvasPointers
Vector of pointers to histograms + optional folder name.
std::vector< std::pair< TCanvas *, std::string > > GetCanvasVector()
TH1 * fhEventDt
histogram with the seed time of the events
std::vector< CbmEvent * > fEventVector
pointer to the event which is currently build
Bool_t CheckTriggerConditions(CbmEvent *event, EventBuilderDetector &det)
Double_t fdPrevEvtEndTime
Save previous time information.
void SetEventOverlapMode(EOverlapMode mode)
Control flags.
CbmMcbm2019TimeWinEventBuilderAlgo operator=(const CbmMcbm2019TimeWinEventBuilderAlgo &)=delete
void SearchMatches(Double_t dSeedTime, EventBuilderDetector &detMatch)
void AddCanvasToVector(TCanvas *pointer, std::string sFolder="")
TH1 * fhEventTime
Vector of pointers to canvases + optional folder name.
std::vector< CbmEvent * > & GetEventVector()
Data output access.
void SetTriggerMaxNumber(ECbmModuleId selDet, Int_t iVal)
Int_t fiTriggerMaxDigis
Maximum number of digis per detector to generate an event, -1 means no cut, 0 means anti-coinc trigge...
bool operator!=(const EventBuilderDetector &other) const
EventBuilderDetector(ECbmModuleId detIdIn, ECbmDataType dataTypeIn, std::string sNameIn, UInt_t uTriggerMinDigisIn, Int_t iTriggerMaxDigisIn, Double_t fdTimeWinBegIn, Double_t fdTimeWinEndIn)
bool operator==(const EventBuilderDetector &other) const
UInt_t fuTriggerMinDigis
Minimum number of Bmon digis needed to generate a trigger, 0 means don't use for trigger generation.
UInt_t fuStartIndex
Book-keeping variables.
Double_t fdTimeWinBeg
Selection Window.
EventBuilderDetector(ECbmModuleId detIdIn, ECbmDataType dataTypeIn, std::string sNameIn)