CbmRoot
Loading...
Searching...
No Matches
CbmTofTestBeamClusterizer.h
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 PI-UHd, GSI
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Norbert Herrmann [committer], Pierre-Alain Loizeau */
4
15#ifndef CBMTOFTESTBEAMCLUSTERIZER_H
16#define CBMTOFTESTBEAMCLUSTERIZER_H 1
17
18// TOF Classes and includes
19// Input/Output
20//class CbmTofPoint;
21class CbmTofDigi;
22class CbmTofHit;
23class CbmMatch;
24// Geometry
27class CbmTofDigiPar;
29class CbmTofCell;
31
32class TTofCalibData;
33class TTrbHeader;
34
35// FAIR classes and includes
36#include "CbmTofAddress.h" // in cbmdata/tof
37#include "FairTask.h"
38
39// ROOT Classes and includes
40class TClonesArray;
41class TF1;
42class TFile;
43class TH1;
44class TH2;
45class TProfile;
46class TString;
47#include "TTimeStamp.h"
48
49// C++ Classes and includes
50#include <list>
51#include <map>
52#include <vector>
53
54class CbmTofTestBeamClusterizer : public FairTask {
55
56 friend class CbmTofAnaTestbeam;
57
58 public:
59 inline static CbmTofTestBeamClusterizer* Instance() { return fInstance; }
60
65
69 CbmTofTestBeamClusterizer(const char* name, Int_t verbose = 1, Bool_t writeDataInOut = kTRUE);
74
78 virtual InitStatus Init();
79
83 virtual void SetParContainers();
84
88 virtual void Exec(Option_t* option);
89
93 virtual void Finish();
94 virtual void Finish(Double_t calMode);
95
96 inline void SetCalMode(Int_t iMode) { fCalMode = iMode; }
97 inline void SetCalSel(Int_t iSel) { fCalSel = iSel; }
98 inline void SetCalSmType(Int_t iCalSmType) { fCalSmAddr = CbmTofAddress::GetUniqueAddress(0, 0, 0, 0, iCalSmType); }
99 inline void SetCalSmAddr(Int_t iCalSmAddr) { fCalSmAddr = iCalSmAddr; }
100 inline void SetCalRpc(Int_t iCalRpc)
101 {
102 if (iCalRpc != 0) {
103 Int_t iSign = iCalRpc / TMath::Abs(iCalRpc);
104 iCalRpc *= iSign; // always a positive number
105 Int_t iRpc = iCalRpc % 10;
106 iCalRpc = (iCalRpc - iRpc) / 10;
107 Int_t iSm = iCalRpc % 10;
108 iCalRpc = (iCalRpc - iSm) / 10;
109 fCalSmAddr = iSign * CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iCalRpc);
110 }
111 else {
112 fCalSmAddr = 0;
113 }
114 }
115 inline void SetCaldXdYMax(Double_t dCaldXdYMax) { fdCaldXdYMax = dCaldXdYMax; }
116 inline void SetCalCluMulMax(Int_t ival) { fiCluMulMax = ival; }
117 inline void SetTRefId(Int_t Id) { fTRefMode = Id; }
118 inline void SetDutId(Int_t Id) { fDutId = Id; }
119 inline void SetDutSm(Int_t Id) { fDutSm = Id; }
120 inline void SetDutRpc(Int_t Id) { fDutRpc = Id; }
121 inline void SetSelId(Int_t Id) { fSelId = Id; }
122 inline void SetSelSm(Int_t Id) { fSelSm = Id; }
123 inline void SetSelRpc(Int_t Id) { fSelRpc = Id; }
124 inline void SetBeamRefId(Int_t Id) { fiBeamRefType = Id; }
125 inline void SetBeamRefSm(Int_t Id) { fiBeamRefSm = Id; }
126 inline void SetBeamRefDet(Int_t Id) { fiBeamRefDet = Id; }
127 inline void SetBeamRefMulMax(Int_t Id) { fiBeamRefMulMax = Id; }
128 inline void SetBeamAddRefMul(Int_t ival) { fiBeamAddRefMul = ival; }
129 inline void SetTRefDifMax(Double_t val) { fTRefDifMax = val; }
130 inline void SetdTRefMax(Double_t val) { fdTRefMax = val; }
131 inline void PosYMaxScal(Double_t val) { fPosYMaxScal = val; }
132 inline void SetTotMax(Double_t val) { fTotMax = val; }
133 inline void SetTotMin(Double_t val) { fTotMin = val; }
134 inline void SetTotMean(Double_t val) { fTotMean = val; }
135 inline void SetDelTofMax(Double_t val) { fdDelTofMax = val; }
136 inline void SetTotPreRange(Double_t val) { fTotPreRange = val; }
137 inline void SetMaxTimeDist(Double_t val) { fMaxTimeDist = val; }
138 inline void SetChannelDeadtime(Double_t val) { fdChannelDeadtime = val; }
139 inline void SetMemoryTime(Double_t val) { fdMemoryTime = val; }
140 inline void SetYFitMin(Double_t val) { fdYFitMin = val; }
141 inline void SetSel2Id(Int_t ival) { fSel2Id = ival; }
142 inline void SetSel2Sm(Int_t ival) { fSel2Sm = ival; }
143 inline void SetSel2Rpc(Int_t ival) { fSel2Rpc = ival; }
144
145 inline void SetOutHstFileName(TString OutHstFileName) { fOutHstFileName = OutHstFileName; }
146 inline void SetCalParFileName(TString CalParFileName) { fCalParFileName = CalParFileName; }
147
148 inline void SetEnableMatchPosScaling(Bool_t bval) { fEnableMatchPosScaling = bval; }
149 inline void SetEnableAvWalk(Bool_t bval) { fEnableAvWalk = bval; }
150 inline void SetPs2Ns(Bool_t bval) { fbPs2Ns = bval; }
151
152 //static Double_t f1_xboxe(double *x, double *par); // Fit function
153 virtual void fit_ybox(const char* hname); // Fit
154 virtual void fit_ybox(TH1* h, Double_t dy); // Fit
155 virtual void fit_ybox(TH1* h, Double_t dy, Double_t* fpar); // Fit
156 virtual void CheckLHMemory(); // Check consistency of stored last hits
157 virtual void CleanLHMemory(); // Cleanup
158 virtual Bool_t AddNextChan(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iLastChan, Double_t dLastPosX,
159 Double_t dLastPosY, Double_t dLastTime,
160 Double_t dLastTot); // needed for time based data
161 virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit* pHit);
162
163 void SwapChannelSides(Bool_t bSwap) { fbSwapChannelSides = bSwap; }
164 void SetFileIndex(Int_t iIndex) { fiFileIndex = iIndex; }
165 void SetWriteDigisInOut(Bool_t bDigis) { fbWriteDigisInOut = bDigis; }
166 void SetWriteHitsInOut(Bool_t bHits) { fbWriteHitsInOut = bHits; }
167 void SetAlternativeBranchNames(Bool_t bNames) { fbAlternativeBranchNames = bNames; }
168
169 protected:
170 private:
180
181 // Functions common for all clusters approximations
185 Bool_t RegisterInputs();
189 Bool_t RegisterOutputs();
193 Bool_t InitParameters();
197 Bool_t InitCalibParameter();
201 Bool_t LoadGeometry();
205 Bool_t DeleteGeometry();
206
207 // Histogramming functions
208 Bool_t CreateHistos();
209 Bool_t FillHistos();
210 Bool_t WriteHistos();
211 Bool_t DeleteHistos();
212
216 Bool_t BuildClusters();
217 Bool_t MergeClusters();
218
219 // ToF geometry variables
225
227
228 // Input variables
229 TClonesArray* fTofPointsColl; // TOF MC points
230 TClonesArray* fMcTracksColl; // MC tracks
231 TClonesArray* fTofDigisColl; // TOF Digis
232
233 // Output variables
236 TClonesArray* fTofCalDigisColl; // Calibrated TOF Digis
237 TClonesArray* fTofHitsColl; // TOF hits
238 TClonesArray* fTofDigiMatchColl; // TOF Digi Links
239 Int_t fiNbHits; // Index of the CbmTofHit TClonesArray
240
241 // Generic
242 Int_t fVerbose;
243
244 // Intermediate storage variables
245 std::vector<std::vector<std::vector<std::vector<CbmTofDigi*>>>> fStorDigiExp; //[nbType][nbSm*nbRpc][nbCh][nDigis]
246 std::vector<std::vector<std::vector<std::vector<Int_t>>>> fStorDigiInd; //[nbType][nbSm*nbRpc][nbCh][nDigis]
247 /*
248 std::vector< std::vector< std::vector< std::vector< std::vector< CbmTofDigi* > > > > >
249 fStorDigi; //[nbType][nbSm][nbRpc][nbCh][nDigis]
250 std::vector< std::vector< std::vector< std::vector< std::vector< CbmTofDigiExp* > > > > >
251 fStorDigiExp; //[nbType][nbSm][nbRpc][nbCh][nDigis]
252 */
253 std::vector<std::vector<std::vector<Int_t>>> fviClusterMul; //[nbType][nbSm][nbRpc]
254 std::vector<std::vector<std::vector<Int_t>>> fviClusterSize; //[nbType][nbRpc][nClusters]
255 std::vector<std::vector<std::vector<Int_t>>> fviTrkMul; //[nbType][nbRpc][nClusters]
256 std::vector<std::vector<std::vector<Double_t>>> fvdX; //[nbType][nbRpc][nClusters]
257 std::vector<std::vector<std::vector<Double_t>>> fvdY; //[nbType][nbRpc][nClusters]
258 std::vector<std::vector<std::vector<Double_t>>> fvdDifX; //[nbType][nbRpc][nClusters]
259 std::vector<std::vector<std::vector<Double_t>>> fvdDifY; //[nbType][nbRpc][nClusters]
260 std::vector<std::vector<std::vector<Double_t>>> fvdDifCh; //[nbType][nbRpc][nClusters]
261
262 // Histograms
285
286 std::vector<TH2*> fhRpcDigiCor; //[nbDet]
287 std::vector<TH1*> fhRpcCluMul; //[nbDet]
288 std::vector<TH1*> fhRpcCluRate; //[nbDet]
289 std::vector<TH2*> fhRpcCluPosition; //[nbDet]
290 std::vector<TH2*> fhRpcCluDelPos; //[nbDet]
291 std::vector<TH2*> fhRpcCluDelMatPos; //[nbDet]
292 std::vector<TH2*> fhRpcCluTOff; //[nbDet]
293 std::vector<TH2*> fhRpcCluDelTOff; //[nbDet]
294 std::vector<TH2*> fhRpcCluDelMatTOff; //[nbDet]
295 std::vector<TH2*> fhRpcCluTrms; //[nbDet]
296 std::vector<TH2*> fhRpcCluTot; //[nbDet]
297 std::vector<TH2*> fhRpcCluSize; //[nbDet]
298 std::vector<TH2*> fhRpcCluAvWalk; //[nbDet]
299 std::vector<TH2*> fhRpcCluAvLnWalk; //[nbDet]
300 std::vector<std::vector<std::vector<TH2*>>> fhRpcCluWalk; // [nbDet][nbCh][nSide]
301 std::vector<TH2*> fhSmCluPosition; //[nbSmTypes]
302 std::vector<TH2*> fhSmCluTOff;
303 std::vector<TProfile*> fhSmCluSvel;
304 std::vector<std::vector<TProfile*>> fhSmCluFpar;
305 std::vector<TH1*> fhRpcDTLastHits; //[nbDet]
306 std::vector<TH1*> fhRpcDTLastHits_Tot; //[nbDet]
307 std::vector<TH1*> fhRpcDTLastHits_CluSize; //[nbDet]
308
309 std::vector<std::vector<TH1*>> fhTRpcCluMul; //[nbDet][nbSel]
310 std::vector<std::vector<TH2*>> fhTRpcCluPosition; //[nbDet][nbSel]
311 std::vector<std::vector<TH2*>> fhTRpcCluTOff; //[nbDet] [nbSel]
312 std::vector<std::vector<TH2*>> fhTRpcCluTot; // [nbDet][nbSel]
313 std::vector<std::vector<TH2*>> fhTRpcCluSize; // [nbDet][nbSel]
314 std::vector<std::vector<TH2*>> fhTRpcCluAvWalk; // [nbDet][nbSel]
315 std::vector<std::vector<TH2*>> fhTRpcCluDelTof; // [nbDet][nbSel]
316 std::vector<std::vector<TH2*>> fhTRpcCludXdY; // [nbDet][nbSel]
317 std::vector<std::vector<std::vector<std::vector<TH2*>>>> fhTRpcCluWalk; // [nbDet][nbSel][nbCh][nSide]
318
319 std::vector<std::vector<TH2*>> fhTSmCluPosition; //[nbSmTypes][nbSel]
320 std::vector<std::vector<TH2*>> fhTSmCluTOff; //[nbSmTypes][nbSel]
321 std::vector<std::vector<TH2*>> fhTSmCluTRun; //[nbSmTypes][nbSel]
322 std::vector<std::vector<TH2*>> fhTRpcCluTOffDTLastHits;
323 std::vector<std::vector<TH2*>> fhTRpcCluTotDTLastHits;
324 std::vector<std::vector<TH2*>> fhTRpcCluSizeDTLastHits;
325 std::vector<std::vector<TH2*>> fhTRpcCluMemMulDTLastHits;
326
327 std::vector<TH1*> fhSeldT; //[nbSel]
328
329 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPDelTof; //[nSMT][nRpc][nbClDelTofBinX][nbSel]
330 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTOff; //[nSMT][nRpc][nCh][nbSide]
331 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTotGain; //[nSMT][nRpc][nCh][nbSide]
332 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTotOff; //[nSMT][nRpc][nCh][nbSide]
333 std::vector<std::vector<std::vector<std::vector<std::vector<Double_t>>>>>
334 fvCPWalk; //[nSMT][nRpc][nCh][nbSide][nbWalkBins]
335
336 std::vector<std::vector<std::vector<std::vector<std::list<CbmTofHit*>>>>> fvLastHits; //[nSMT[nSm][nRpc][nCh][NHits]
337
338 // Digis quality
342
343 // Control
344 TTimeStamp fStart;
345 TTimeStamp fStop;
346
347 // Calib
348 Double_t dTRef;
349 Double_t fdTRefMax;
350 Int_t fCalMode;
351 Int_t fCalSel;
353 Double_t fdCaldXdYMax;
357 Int_t fDutId;
358 Int_t fDutSm;
359 Int_t fDutRpc;
360 Int_t fDutAddr;
361 Int_t fSelId;
362 Int_t fSelSm;
363 Int_t fSelRpc;
364 Int_t fSelAddr;
371 Int_t fSel2Id;
372 Int_t fSel2Sm;
373 Int_t fSel2Rpc;
375
376 std::map<UInt_t, UInt_t> fDetIdIndexMap;
377 std::vector<Int_t> fviDetId;
378
379 Double_t fPosYMaxScal;
380 Double_t fTRefDifMax;
381 Double_t fTotMax;
382 Double_t fTotMin;
383 Double_t fTotOff;
384 Double_t fTotMean;
385 Double_t fdDelTofMax;
386 Double_t fTotPreRange;
387 Double_t fMaxTimeDist;
389 Double_t fdMemoryTime;
390 Double_t fdYFitMin;
391
394 Bool_t fbPs2Ns; // convert input raw digis from ps to ns
395
396 TString fCalParFileName; // name of the file name with Calibration Parameters
397 TString fOutHstFileName; // name of the histogram output file name with Calibration Parameters
398 TFile* fCalParFile; // pointer to Calibration Parameter file
399
400 // Constants or setting parameters
402 Int_t fiMsgCnt;
403
404 Double_t fdTOTMax;
405 Double_t fdTOTMin;
406 Double_t fdTTotMean;
407
408 Double_t fdMaxTimeDist; // Isn't this just a local variable? Why make it global and preset?!?
409 Double_t fdMaxSpaceDist; // Isn't this just a local variable? Why make it global and preset?!?
410
411 Double_t fdEvent;
412
417
419};
420
421#endif // CBMTOFTESTBEAMCLUSTERIZER_H
Data class with information on a STS local track.
static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side=0, uint32_t SmType=0, uint32_t RpcType=0)
Parameters class for the CBM ToF digitizer using beam data distributions.
Data class for expanded digital TOF information.
Definition CbmTofDigi.h:47
std::vector< std::vector< std::vector< std::vector< std::vector< Double_t > > > > > fvCPWalk
std::vector< std::vector< std::vector< Int_t > > > fviClusterMul
void SetCalSmType(Int_t iCalSmType)
Bool_t LoadGeometry()
Load the geometry: for now just resizing the Digis temporary vectors.
std::vector< std::vector< TH2 * > > fhTRpcCluTOffDTLastHits
std::vector< std::vector< TH2 * > > fhTRpcCluTOff
std::vector< std::vector< TProfile * > > fhSmCluFpar
std::vector< std::vector< TH2 * > > fhTRpcCluAvWalk
static CbmTofTestBeamClusterizer * Instance()
CbmTofTestBeamClusterizer(const CbmTofTestBeamClusterizer &)
Copy constructor.
std::vector< TProfile * > fhSmCluSvel
std::vector< std::vector< std::vector< Double_t > > > fvdDifCh
std::vector< std::vector< std::vector< std::vector< CbmTofDigi * > > > > fStorDigiExp
virtual void fit_ybox(const char *hname)
virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit *pHit)
Bool_t BuildClusters()
Build clusters out of ToF Digis and store the resulting info in a TofHit.
void SetOutHstFileName(TString OutHstFileName)
std::vector< std::vector< TH2 * > > fhTRpcCluDelTof
std::vector< TH1 * > fhRpcDTLastHits_CluSize
std::vector< std::vector< TH2 * > > fhTRpcCluSize
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTOff
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotOff
virtual void Finish()
Inherited from FairTask.
static CbmTofTestBeamClusterizer * fInstance
virtual ~CbmTofTestBeamClusterizer()
Destructor.
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotGain
Bool_t DeleteGeometry()
Delete the geometry related arrays: for now just clearing the Digis temporary vectors.
ClassDef(CbmTofTestBeamClusterizer, 1)
std::vector< std::vector< TH1 * > > fhTRpcCluMul
std::vector< std::vector< TH2 * > > fhTRpcCluMemMulDTLastHits
std::vector< std::vector< std::vector< Int_t > > > fviTrkMul
Bool_t InitCalibParameter()
Initialize other parameters not included in parameter classes.
std::vector< std::vector< TH2 * > > fhTRpcCludXdY
std::vector< std::vector< std::vector< std::vector< TH2 * > > > > fhTRpcCluWalk
void SetCaldXdYMax(Double_t dCaldXdYMax)
std::vector< std::vector< TH2 * > > fhTRpcCluTotDTLastHits
std::map< UInt_t, UInt_t > fDetIdIndexMap
Bool_t InitParameters()
Initialize other parameters not included in parameter classes.
std::vector< std::vector< std::vector< Double_t > > > fvdDifX
std::vector< std::vector< TH2 * > > fhTRpcCluPosition
void SetAlternativeBranchNames(Bool_t bNames)
Bool_t RegisterOutputs()
Create and register output TClonesArray of Tof Hits.
virtual InitStatus Init()
Inherited from FairTask.
void SetCalSmAddr(Int_t iCalSmAddr)
virtual Bool_t AddNextChan(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iLastChan, Double_t dLastPosX, Double_t dLastPosY, Double_t dLastTime, Double_t dLastTot)
CbmTofTestBeamClusterizer & operator=(const CbmTofTestBeamClusterizer &)
Copy operator.
void SetCalParFileName(TString CalParFileName)
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPDelTof
std::vector< std::vector< std::vector< Double_t > > > fvdX
virtual void SetParContainers()
Inherited from FairTask.
std::vector< std::vector< TH2 * > > fhTSmCluPosition
std::vector< std::vector< TH2 * > > fhTRpcCluSizeDTLastHits
Bool_t RegisterInputs()
Recover pointer on input TClonesArray: TofPoints, TofDigis...
std::vector< std::vector< TH2 * > > fhTSmCluTRun
std::vector< std::vector< std::vector< TH2 * > > > fhRpcCluWalk
std::vector< std::vector< std::vector< Double_t > > > fvdY
std::vector< std::vector< std::vector< std::vector< Int_t > > > > fStorDigiInd
std::vector< std::vector< TH2 * > > fhTRpcCluTot
std::vector< std::vector< TH2 * > > fhTSmCluTOff
std::vector< std::vector< std::vector< Double_t > > > fvdDifY
std::vector< std::vector< std::vector< std::vector< std::list< CbmTofHit * > > > > > fvLastHits
std::vector< std::vector< std::vector< Int_t > > > fviClusterSize
virtual void Exec(Option_t *option)
Inherited from FairTask.