CbmRoot
Loading...
Searching...
No Matches
CbmTofCosmicClusterizer.h
Go to the documentation of this file.
1/* Copyright (C) 2018-2020 PI-UHd/GSI, Heidelberg/Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Norbert Herrmann [committer] */
4
15#ifndef CBMTOFCOSMICCLUSTERIZER_H
16#define CBMTOFCOSMICCLUSTERIZER_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 TFile;
42class TF1;
43class TH1;
44class TH2;
45class TH3;
46class TProfile;
47class TString;
48#include "TTimeStamp.h"
49
50// C++ Classes and includes
51#include <list>
52#include <map>
53#include <vector>
54
55class CbmTofCosmicClusterizer : public FairTask {
56
57 friend class CbmTofAnaTestbeam;
58
59 public:
60 inline static CbmTofCosmicClusterizer* Instance() { return fInstance; }
61
66
70 CbmTofCosmicClusterizer(const char* name, Int_t verbose = 1, Bool_t writeDataInOut = kTRUE);
75
79 virtual InitStatus Init();
80
84 virtual void SetParContainers();
85
89 virtual void Exec(Option_t* option);
90
94 virtual void Finish();
95 virtual void Finish(Double_t calMode);
96
97 inline void SetCalMode(Int_t iMode) { fCalMode = iMode; }
98 inline void SetCalSel(Int_t iSel) { fCalSel = iSel; }
99 inline void SetCalSmType(Int_t iCalSmType) { fCalSmAddr = CbmTofAddress::GetUniqueAddress(0, 0, 0, 0, iCalSmType); }
100 inline void SetCalSmAddr(Int_t iCalSmAddr) { fCalSmAddr = iCalSmAddr; }
101 inline void SetCalRpc(Int_t iCalRpc)
102 {
103 if (iCalRpc != 0) {
104 Int_t iSign = iCalRpc / TMath::Abs(iCalRpc);
105 iCalRpc *= iSign; // always a positive number
106 Int_t iRpc = iCalRpc % 10;
107 iCalRpc = (iCalRpc - iRpc) / 10;
108 Int_t iSm = iCalRpc % 10;
109 iCalRpc = (iCalRpc - iSm) / 10;
110 iRpc = 0; // ignore RPC number
111 fCalSmAddr = iSign * CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iCalRpc);
112 }
113 else {
114 fCalSmAddr = 0;
115 }
116 }
117 inline void SetCaldXdYMax(Double_t dCaldXdYMax) { fdCaldXdYMax = dCaldXdYMax; }
118 inline void SetCalCluMulMax(Int_t ival) { fiCluMulMax = ival; }
119 inline void SetTRefId(Int_t Id) { fTRefMode = Id; }
120 inline void SetDutId(Int_t Id) { fDutId = Id; }
121 inline void SetDutSm(Int_t Id) { fDutSm = Id; }
122 inline void SetDutRpc(Int_t Id) { fDutRpc = Id; }
123 inline void SetSelId(Int_t Id) { fSelId = Id; }
124 inline void SetSelSm(Int_t Id) { fSelSm = Id; }
125 inline void SetSelRpc(Int_t Id) { fSelRpc = Id; }
126 inline void SetTRefDifMax(Double_t val) { fTRefDifMax = val; }
127 inline void SetdTRefMax(Double_t val) { fdTRefMax = val; }
128 inline void PosYMaxScal(Double_t val) { fPosYMaxScal = val; }
129 inline void SetTotMax(Double_t val) { fTotMax = val; }
130 inline void SetTotMin(Double_t val) { fTotMin = val; }
131 inline void SetTotMean(Double_t val) { fTotMean = val; }
132 inline void SetDelTofMax(Double_t val) { fdDelTofMax = val; }
133 inline void SetTotPreRange(Double_t val) { fTotPreRange = val; }
134 inline void SetMaxTimeDist(Double_t val) { fMaxTimeDist = val; }
135 inline void SetChannelDeadtime(Double_t val) { fdChannelDeadtime = val; }
136 inline void SetMemoryTime(Double_t val) { fdMemoryTime = val; }
137 inline void SetYFitMin(Double_t val) { fdYFitMin = val; }
138 inline void SetSel2Id(Int_t ival) { fSel2Id = ival; }
139 inline void SetSel2Sm(Int_t ival) { fSel2Sm = ival; }
140 inline void SetSel2Rpc(Int_t ival) { fSel2Rpc = ival; }
141 inline void SetSel2MulMax(Int_t Id) { fSel2MulMax = Id; }
142
143 inline void SetOutHstFileName(TString OutHstFileName) { fOutHstFileName = OutHstFileName; }
144 inline void SetCalParFileName(TString CalParFileName) { fCalParFileName = CalParFileName; }
145
146 inline void SetEnableMatchPosScaling(Bool_t bval) { fEnableMatchPosScaling = bval; }
147 inline void SetEnableAvWalk(Bool_t bval) { fEnableAvWalk = bval; }
148 inline void SetPs2Ns(Bool_t bval) { fbPs2Ns = bval; }
149 inline void SetTimePeriod(Double_t dval) { fdTimePeriod = dval; }
150 inline void SetCorMode(Int_t ival) { fiCorMode = ival; }
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 virtual Double_t TimeInPeriod(Double_t dTime);
163
164 protected:
165 private:
175
176 // Functions common for all clusters approximations
180 Bool_t RegisterInputs();
184 Bool_t RegisterOutputs();
188 Bool_t InitParameters();
192 Bool_t InitCalibParameter();
196 Bool_t LoadGeometry();
200 Bool_t DeleteGeometry();
201
202 // Histogramming functions
203 Bool_t CreateHistos();
204 Bool_t FillHistos();
205 Bool_t WriteHistos();
206 Bool_t DeleteHistos();
207
211 Bool_t BuildClusters();
212 Bool_t MergeClusters();
213
214 // ToF geometry variables
220
222
223 // Input variables
224 TClonesArray* fTofPointsColl; // TOF MC points
225 TClonesArray* fMcTracksColl; // MC tracks
226 TClonesArray* fTofDigisColl; // TOF Digis
227
228 // Output variables
231 TClonesArray* fTofCalDigisColl; // Calibrated TOF Digis
232 TClonesArray* fTofHitsColl; // TOF hits
233 TClonesArray* fTofDigiMatchColl; // TOF Digi Links
234 Int_t fiNbHits; // Index of the CbmTofHit TClonesArray
235
236 // Generic
237 Int_t fVerbose;
238
239 // Intermediate storage variables
240 std::vector<std::vector<std::vector<std::vector<CbmTofDigi*>>>> fStorDigiExp; //[nbType][nbSm*nbRpc][nbCh][nDigis]
241 std::vector<std::vector<std::vector<std::vector<Int_t>>>> fStorDigiInd; //[nbType][nbSm*nbRpc][nbCh][nDigis]
242 /*
243 std::vector< std::vector< std::vector< std::vector< std::vector< CbmTofDigi* > > > > >
244 fStorDigi; //[nbType][nbSm][nbRpc][nbCh][nDigis]
245 std::vector< std::vector< std::vector< std::vector< std::vector< CbmTofDigiExp* > > > > >
246 fStorDigiExp; //[nbType][nbSm][nbRpc][nbCh][nDigis]
247 */
248 std::vector<std::vector<std::vector<Int_t>>> fviClusterMul; //[nbType][nbSm][nbRpc]
249 std::vector<std::vector<std::vector<Int_t>>> fviClusterSize; //[nbType][nbRpc][nClusters]
250 std::vector<std::vector<std::vector<Int_t>>> fviTrkMul; //[nbType][nbRpc][nClusters]
251 std::vector<std::vector<std::vector<Double_t>>> fvdX; //[nbType][nbRpc][nClusters]
252 std::vector<std::vector<std::vector<Double_t>>> fvdY; //[nbType][nbRpc][nClusters]
253 std::vector<std::vector<std::vector<Double_t>>> fvdDifX; //[nbType][nbRpc][nClusters]
254 std::vector<std::vector<std::vector<Double_t>>> fvdDifY; //[nbType][nbRpc][nClusters]
255 std::vector<std::vector<std::vector<Double_t>>> fvdDifCh; //[nbType][nbRpc][nClusters]
256
257 // Histograms
280
281 std::vector<TH2*> fhRpcDigiCor; //[nbDet]
282 std::vector<TH1*> fhRpcCluMul; //[nbDet]
283 std::vector<TH1*> fhRpcCluRate; //[nbDet]
284 std::vector<TH2*> fhRpcCluPosition; //[nbDet]
285 std::vector<TProfile*> fhRpcCluPositionEvol; //[nbDet]
286 std::vector<TProfile*> fhRpcCluTimeEvol; //[nbDet]
287 std::vector<TH2*> fhRpcCluDelPos; //[nbDet]
288 std::vector<TH2*> fhRpcCluDelMatPos; //[nbDet]
289 std::vector<TH2*> fhRpcCluTOff; //[nbDet]
290 std::vector<TH2*> fhRpcCluDelTOff; //[nbDet]
291 std::vector<TH2*> fhRpcCluDelMatTOff; //[nbDet]
292 std::vector<TH2*> fhRpcCluTrms; //[nbDet]
293 std::vector<TH2*> fhRpcCluTot; //[nbDet]
294 std::vector<TH2*> fhRpcCluSize; //[nbDet]
295 std::vector<TH2*> fhRpcCluAvWalk; //[nbDet]
296 std::vector<TH2*> fhRpcCluAvLnWalk; //[nbDet]
297 std::vector<std::vector<std::vector<TH2*>>> fhRpcCluWalk; // [nbDet][nbCh][nSide]
298 std::vector<TH2*> fhSmCluPosition; //[nbSmTypes]
299 std::vector<TH2*> fhSmCluTOff;
300 std::vector<TProfile*> fhSmCluSvel;
301 std::vector<std::vector<TProfile*>> fhSmCluFpar;
302 std::vector<TH1*> fhRpcDTLastHits; //[nbDet]
303 std::vector<TH1*> fhRpcDTLastHits_Tot; //[nbDet]
304 std::vector<TH1*> fhRpcDTLastHits_CluSize; //[nbDet]
305
306 std::vector<std::vector<TH1*>> fhTRpcCluMul; //[nbDet][nbSel]
307 std::vector<std::vector<TH2*>> fhTRpcCluPosition; //[nbDet][nbSel]
308 std::vector<std::vector<TH2*>> fhTRpcCluTOff; //[nbDet] [nbSel]
309 std::vector<std::vector<TH2*>> fhTRpcCluTot; // [nbDet][nbSel]
310 std::vector<std::vector<TH2*>> fhTRpcCluSize; // [nbDet][nbSel]
311 std::vector<std::vector<TH2*>> fhTRpcCluAvWalk; // [nbDet][nbSel]
312 std::vector<std::vector<TH2*>> fhTRpcCluDelTof; // [nbDet][nbSel]
313 std::vector<std::vector<TH2*>> fhTRpcCludXdY; // [nbDet][nbSel]
314 std::vector<std::vector<std::vector<std::vector<TH2*>>>> fhTRpcCluWalk; // [nbDet][nbSel][nbCh][nSide]
315 std::vector<std::vector<TH3*>> fhTRpcCluWalk2; // [nbDet][nbSel]
316
317 std::vector<std::vector<TH2*>> fhTSmCluPosition; //[nbSmTypes][nbSel]
318 std::vector<std::vector<TH2*>> fhTSmCluTOff; //[nbSmTypes][nbSel]
319 std::vector<std::vector<TH2*>> fhTSmCluTRun; //[nbSmTypes][nbSel]
320 std::vector<std::vector<TH2*>> fhTRpcCluTOffDTLastHits;
321 std::vector<std::vector<TH2*>> fhTRpcCluTotDTLastHits;
322 std::vector<std::vector<TH2*>> fhTRpcCluSizeDTLastHits;
323 std::vector<std::vector<TH2*>> fhTRpcCluMemMulDTLastHits;
324
325 std::vector<TH1*> fhSeldT; //[nbSel]
326
327 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPDelTof; //[nSMT][nRpc][nbClDelTofBinX][nbSel]
328 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTOff; //[nSMT][nRpc][nCh][nbSide]
329 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTotGain; //[nSMT][nRpc][nCh][nbSide]
330 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTotOff; //[nSMT][nRpc][nCh][nbSide]
331 std::vector<std::vector<std::vector<std::vector<std::vector<Double_t>>>>>
332 fvCPWalk; //[nSMT][nRpc][nCh][nbSide][nbWalkBins]
333
334 std::vector<std::vector<std::vector<std::vector<std::list<CbmTofHit*>>>>> fvLastHits; //[nSMT[nSm][nRpc][nCh][NHits]
335
336 // Digis quality
340
341 // Control
342 TTimeStamp fStart;
343 TTimeStamp fStop;
344
345 // Calib
346 Double_t dTRef;
347 Double_t fdTRefMax;
348 Int_t fCalMode;
349 Int_t fCalSel;
351 Double_t fdCaldXdYMax;
355 Int_t fDutId;
356 Int_t fDutSm;
357 Int_t fDutRpc;
358 Int_t fDutAddr;
359 Int_t fSelId;
360 Int_t fSelSm;
361 Int_t fSelRpc;
362 Int_t fSelAddr;
363 Int_t fSel2Id;
364 Int_t fSel2Sm;
365 Int_t fSel2Rpc;
368
369 std::map<UInt_t, UInt_t> fDetIdIndexMap;
370 std::vector<Int_t> fviDetId;
371 std::vector<Int_t> vDigiIndRef;
372
373 Double_t fPosYMaxScal;
374 Double_t fTRefDifMax;
375 Double_t fTotMax;
376 Double_t fTotMin;
377 Double_t fTotOff;
378 Double_t fTotMean;
379 Double_t fdDelTofMax;
380 Double_t fTotPreRange;
381 Double_t fMaxTimeDist;
383 Double_t fdMemoryTime;
384 Double_t fdYFitMin;
385 Double_t fdTimePeriod;
387
390 Bool_t fbPs2Ns; // convert input raw digis from ps to ns
391
392 TString fCalParFileName; // name of the file name with Calibration Parameters
393 TString fOutHstFileName; // name of the histogram output file name with Calibration Parameters
394 TFile* fCalParFile; // pointer to Calibration Parameter file
395
396 // Constants or setting parameters
398 Int_t fiMsgCnt;
399
400 Double_t fdTOTMax;
401 Double_t fdTOTMin;
402 Double_t fdTTotMean;
403
404 Double_t fdMaxTimeDist; // Isn't this just a local variable? Why make it global and preset?!?
405 Double_t fdMaxSpaceDist; // Isn't this just a local variable? Why make it global and preset?!?
406
407 Double_t fdEvent;
408
410};
411
412#endif // CBMTOFCOSMICCLUSTERIZER_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)
Bool_t InitParameters()
Initialize other parameters not included in parameter classes.
std::vector< TH1 * > fhRpcCluRate
Bool_t RegisterOutputs()
Create and register output TClonesArray of Tof Hits.
std::vector< std::vector< std::vector< std::vector< Int_t > > > > fStorDigiInd
std::vector< std::vector< std::vector< Double_t > > > fvdDifCh
std::vector< std::vector< TH2 * > > fhTRpcCluPosition
std::vector< TH2 * > fhRpcCluSize
std::vector< TProfile * > fhRpcCluTimeEvol
std::vector< std::vector< TH2 * > > fhTRpcCluDelTof
std::vector< std::vector< std::vector< std::vector< std::vector< Double_t > > > > > fvCPWalk
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)
virtual Double_t TimeInPeriod(Double_t dTime)
std::vector< TH2 * > fhRpcCluAvWalk
virtual void Finish()
Inherited from FairTask.
virtual InitStatus Init()
Inherited from FairTask.
void SetCalSmAddr(Int_t iCalSmAddr)
std::vector< TProfile * > fhRpcCluPositionEvol
std::vector< TH2 * > fhRpcCluTOff
void SetEnableMatchPosScaling(Bool_t bval)
std::vector< std::vector< TH2 * > > fhTRpcCluAvWalk
CbmTofCosmicClusterizer & operator=(const CbmTofCosmicClusterizer &)
Copy operator.
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPDelTof
std::vector< std::vector< std::vector< Int_t > > > fviTrkMul
Bool_t BuildClusters()
Build clusters out of ToF Digis and store the resulting info in a TofHit.
std::vector< TH2 * > fhRpcCluDelPos
std::vector< TH2 * > fhRpcCluDelMatTOff
virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit *pHit)
std::vector< TH2 * > fhRpcCluDelTOff
void SetCalParFileName(TString CalParFileName)
void SetCaldXdYMax(Double_t dCaldXdYMax)
std::vector< std::vector< TH2 * > > fhTSmCluTOff
std::vector< std::vector< TH2 * > > fhTRpcCluSize
std::vector< TH2 * > fhRpcDigiCor
static CbmTofCosmicClusterizer * fInstance
std::vector< std::vector< TH2 * > > fhTRpcCluTotDTLastHits
std::vector< std::vector< TH2 * > > fhTRpcCluTOffDTLastHits
std::vector< std::vector< TH2 * > > fhTRpcCluSizeDTLastHits
std::vector< std::vector< TProfile * > > fhSmCluFpar
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTOff
ClassDef(CbmTofCosmicClusterizer, 1)
void SetChannelDeadtime(Double_t val)
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotOff
std::map< UInt_t, UInt_t > fDetIdIndexMap
std::vector< TH1 * > fhRpcDTLastHits_Tot
std::vector< std::vector< TH2 * > > fhTRpcCluTot
CbmTofCosmicClusterizer(const CbmTofCosmicClusterizer &)
Copy constructor.
void SetCalSmType(Int_t iCalSmType)
std::vector< std::vector< std::vector< Double_t > > > fvdDifX
void SetOutHstFileName(TString OutHstFileName)
std::vector< TH1 * > fhRpcDTLastHits
virtual ~CbmTofCosmicClusterizer()
Destructor.
std::vector< std::vector< TH2 * > > fhTRpcCludXdY
std::vector< TH2 * > fhSmCluPosition
std::vector< std::vector< std::vector< Int_t > > > fviClusterMul
std::vector< TH1 * > fhRpcDTLastHits_CluSize
std::vector< TProfile * > fhSmCluSvel
Bool_t DeleteGeometry()
Delete the geometry related arrays: for now just clearing the Digis temporary vectors.
Bool_t InitCalibParameter()
Initialize other parameters not included in parameter classes.
virtual void SetParContainers()
Inherited from FairTask.
std::vector< std::vector< TH3 * > > fhTRpcCluWalk2
std::vector< std::vector< std::vector< Double_t > > > fvdDifY
std::vector< TH2 * > fhRpcCluPosition
std::vector< TH2 * > fhRpcCluTrms
std::vector< TH2 * > fhRpcCluDelMatPos
std::vector< std::vector< std::vector< std::vector< std::list< CbmTofHit * > > > > > fvLastHits
std::vector< std::vector< std::vector< std::vector< TH2 * > > > > fhTRpcCluWalk
virtual void Exec(Option_t *option)
Inherited from FairTask.
virtual void fit_ybox(const char *hname)
std::vector< std::vector< std::vector< Int_t > > > fviClusterSize
std::vector< TH2 * > fhRpcCluAvLnWalk
Bool_t RegisterInputs()
Recover pointer on input TClonesArray: TofPoints, TofDigis...
std::vector< std::vector< TH2 * > > fhTSmCluTRun
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotGain
std::vector< std::vector< std::vector< TH2 * > > > fhRpcCluWalk
std::vector< std::vector< TH2 * > > fhTRpcCluMemMulDTLastHits
Bool_t LoadGeometry()
Load the geometry: for now just resizing the Digis temporary vectors.
std::vector< std::vector< std::vector< Double_t > > > fvdX
std::vector< std::vector< TH2 * > > fhTRpcCluTOff
std::vector< std::vector< TH2 * > > fhTSmCluPosition
std::vector< std::vector< std::vector< std::vector< CbmTofDigi * > > > > fStorDigiExp
std::vector< std::vector< std::vector< Double_t > > > fvdY
std::vector< std::vector< TH1 * > > fhTRpcCluMul
static CbmTofCosmicClusterizer * Instance()
Parameters class for the CBM ToF digitizer using beam data distributions.
Data class for expanded digital TOF information.
Definition CbmTofDigi.h:47