CbmRoot
Loading...
Searching...
No Matches
CbmDeviceHitBuilderTof.h
Go to the documentation of this file.
1/* Copyright (C) 2018-2020 PI-UHd, GSI
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Norbert Herrmann [committer] */
4
12#ifndef CBMDEVICEHITBUILDERTOF_H_
13#define CBMDEVICEHITBUILDERTOF_H_
14
15#include "CbmMqTMessage.h"
16#include "CbmTofAddress.h" // in cbmdata/tof
17#include "CbmTofGeoHandler.h" // in tof/TofTools
18
19#include "MicrosliceDescriptor.hpp"
20#include "Timeslice.hpp"
21
22#include "FairEventHeader.h"
23#include "FairMQDevice.h"
24
25#include "Rtypes.h"
26#include "TFile.h"
27#include "TGeoManager.h"
28#include "TMessage.h"
29#include "TTree.h"
30
31#include <map>
32#include <vector>
33
34class CbmHistManager;
35// Relevant TOF classes
36class CbmTofDigi;
37class CbmTofHit;
38class CbmMatch;
39class CbmEvent;
40class CbmVertex;
41// Geometry
44class CbmTofDigiPar;
46class CbmTofCell;
47
48// ROOT Classes and includes
49class TClonesArray;
50class TF1;
51class TH1;
52class TH2;
53class TProfile;
54class TString;
55
56// C++ Classes and includes
57#include <list>
58#include <map>
59#include <vector>
60
61class CbmDeviceHitBuilderTof : public FairMQDevice {
62public:
65
66protected:
67 virtual void InitTask();
68 //bool HandleData(FairMQMessagePtr&, int);
69 bool HandleData(FairMQParts&, int);
70 bool HandleMessage(FairMQMessagePtr&, int);
71
72 virtual void fit_ybox(const char* hname); // Fit
73 virtual void fit_ybox(TH1* h, Double_t dy); // Fit
74 virtual void fit_ybox(TH1* h, Double_t dy, Double_t* fpar); // Fit
75 virtual void CheckLHMemory(); // Check consistency of stored last hits
76 virtual void CleanLHMemory(); // Cleanup
77 virtual Bool_t AddNextChan(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iLastChan, Double_t dLastPosX,
78 Double_t dLastPosY, Double_t dLastTime,
79 Double_t dLastTot); // needed for time based data
80 virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit* pHit);
81
82private:
83 // Variables used for histo filling
84
85 Bool_t IsChannelNameAllowed(std::string channelName);
86
87 Bool_t InitWorkspace();
88 Bool_t InitContainers();
89 Bool_t LoadGeometry();
90 Bool_t InitRootOutput();
91
92 Bool_t ReInitContainers();
93 void CreateHistograms();
94 void WriteHistograms();
95
96 Bool_t MonitorPulser();
97 Bool_t ApplyPulserCorrection();
98 Bool_t InitCalibParameter();
99 Bool_t BuildClusters();
100 Bool_t InspectRawDigis();
101 Bool_t CalibRawDigis();
102 Bool_t FillDigiStor();
103 Bool_t BuildHits();
104 Bool_t MergeClusters();
105 Bool_t FillHistos();
106 Bool_t SendHits();
107 Bool_t SendAll();
108
109 uint64_t fNumMessages;
110 std::vector<std::string> fAllowedChannels = {"tofcomponent", "parameters", "tofdigis", "tofhits", "syscmd"};
111
112 TGeoManager* fGeoMan;
113 // ToF geometry variables
119 // Input variables
121 std::vector<CbmTofDigi> fvDigiIn;
122 std::vector<uint64_t> fEventHeader;
123 FairEventHeader* fEvtHeader;
124
125 // Output variables
126 // TClonesArray* fTofCalDigisColl; // Calibrated TOF Digis
127 std::vector<CbmTofDigi>* fTofCalDigiVec = nullptr; // Calibrated TOF Digis
128 TClonesArray* fTofHitsColl; // TOF hits
129 TClonesArray* fTofDigiMatchColl; // TOF Digi Links
130 TClonesArray* fTofHitsCollOut; // TOF hits
131 TClonesArray* fTofDigiMatchCollOut; // TOF Digi Links
132 Int_t fiNbHits; // Index of the CbmTofHit TClonesArray
133
134 // Constants or setting parameters
136 Int_t fiMsgCnt;
137
138 Double_t fdTOTMax;
139 Double_t fdTOTMin;
140 Double_t fdTTotMean;
141
142 Double_t fdMaxTimeDist; // Isn't this just a local variable? Why make it global and preset?!?
143 Double_t fdMaxSpaceDist; // Isn't this just a local variable? Why make it global and preset?!?
144
145 Double_t fdEvent;
147 Int_t fiRunId;
148
151
152 // Intermediate storage variables
153 std::vector<std::vector<std::vector<std::vector<CbmTofDigi*>>>> fStorDigi; //[nbType][nbSm*nbRpc][nbCh][nDigis]
154 std::vector<std::vector<std::vector<std::vector<Int_t>>>> fStorDigiInd; //[nbType][nbSm*nbRpc][nbCh][nDigis]
155 std::vector<Int_t> vDigiIndRef;
156
157 std::vector<std::vector<std::vector<Int_t>>> fviClusterMul; //[nbType][nbSm][nbRpc]
158 std::vector<std::vector<std::vector<Int_t>>> fviClusterSize; //[nbType][nbRpc][nClusters]
159 std::vector<std::vector<std::vector<Int_t>>> fviTrkMul; //[nbType][nbRpc][nClusters]
160 std::vector<std::vector<std::vector<Double_t>>> fvdX; //[nbType][nbRpc][nClusters]
161 std::vector<std::vector<std::vector<Double_t>>> fvdY; //[nbType][nbRpc][nClusters]
162 std::vector<std::vector<std::vector<Double_t>>> fvdDifX; //[nbType][nbRpc][nClusters]
163 std::vector<std::vector<std::vector<Double_t>>> fvdDifY; //[nbType][nbRpc][nClusters]
164 std::vector<std::vector<std::vector<Double_t>>> fvdDifCh; //[nbType][nbRpc][nClusters]
165
166 // Intermediate calibration variables
167 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPDelTof; //[nSMT][nRpc][nbClDelTofBinX][nbSel]
168 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTOff; //[nSMT][nRpc][nCh][nbSide]
169 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTotGain; //[nSMT][nRpc][nCh][nbSide]
170 std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTotOff; //[nSMT][nRpc][nCh][nbSide]
171 std::vector<std::vector<std::vector<std::vector<std::vector<Double_t>>>>>
172 fvCPWalk; //[nSMT][nRpc][nCh][nbSide][nbWalkBins]
173 std::vector<std::vector<std::vector<std::vector<std::list<CbmTofHit*>>>>> fvLastHits; //[nSMT[nSm][nRpc][nCh][NHits]
174 std::vector<Int_t> fvDeadStrips; //[nbDet]
175
176 std::vector<std::vector<Double_t>> fvPulserOffset; //[nbDet][nbSide]
177 const Int_t NPulserTimes = 10;
178 std::vector<std::vector<std::list<Double_t>>> fvPulserTimes; //[nbDet][nbSide][NPulserTimes]
179
180
181 // histograms
189 std::vector<TProfile*> fhPulserTimeRawEvo;
193
194 std::vector<TH2*> fhRpcDigiTot; //[nbDet]
195 std::vector<TH2*> fhRpcDigiCor; //[nbDet]
196 std::vector<TH1*> fhRpcCluMul; //[nbDet]
197 std::vector<TH1*> fhRpcCluRate; //[nbDet]
198 std::vector<TH2*> fhRpcCluPosition; //[nbDet]
199 std::vector<TH2*> fhRpcCluDelPos; //[nbDet]
200 std::vector<TH2*> fhRpcCluDelMatPos; //[nbDet]
201 std::vector<TH2*> fhRpcCluTOff; //[nbDet]
202 std::vector<TH2*> fhRpcCluDelTOff; //[nbDet]
203 std::vector<TH2*> fhRpcCluDelMatTOff; //[nbDet]
204 std::vector<TH2*> fhRpcCluTrms; //[nbDet]
205 std::vector<TH2*> fhRpcCluTot; //[nbDet]
206 std::vector<TH2*> fhRpcCluSize; //[nbDet]
207 std::vector<TH2*> fhRpcCluAvWalk; //[nbDet]
208 std::vector<TH2*> fhRpcCluAvLnWalk; //[nbDet]
209 std::vector<std::vector<std::vector<TH2*>>> fhRpcCluWalk; // [nbDet][nbCh][nSide]
210 std::vector<TH2*> fhSmCluPosition; //[nbSmTypes]
211 std::vector<TH2*> fhSmCluTOff;
212 std::vector<TProfile*> fhSmCluSvel;
213 std::vector<std::vector<TProfile*>> fhSmCluFpar;
214 std::vector<TH1*> fhRpcDTLastHits; //[nbDet]
215 std::vector<TH1*> fhRpcDTLastHits_Tot; //[nbDet]
216 std::vector<TH1*> fhRpcDTLastHits_CluSize; //[nbDet]
217
218 std::vector<std::vector<TH1*>> fhTRpcCluMul; //[nbDet][nbSel]
219 std::vector<std::vector<TH2*>> fhTRpcCluPosition; //[nbDet][nbSel]
220 std::vector<std::vector<TH2*>> fhTRpcCluTOff; //[nbDet] [nbSel]
221 std::vector<std::vector<TH2*>> fhTRpcCluTot; // [nbDet][nbSel]
222 std::vector<std::vector<TH2*>> fhTRpcCluSize; // [nbDet][nbSel]
223 std::vector<std::vector<TH2*>> fhTRpcCluAvWalk; // [nbDet][nbSel]
224 std::vector<std::vector<TH2*>> fhTRpcCluDelTof; // [nbDet][nbSel]
225 std::vector<std::vector<TH2*>> fhTRpcCludXdY; // [nbDet][nbSel]
226 std::vector<std::vector<std::vector<std::vector<TH2*>>>> fhTRpcCluWalk; // [nbDet][nbSel][nbCh][nSide]
227
228 std::vector<std::vector<TH2*>> fhTSmCluPosition; //[nbSmTypes][nbSel]
229 std::vector<std::vector<TH2*>> fhTSmCluTOff; //[nbSmTypes][nbSel]
230 std::vector<std::vector<TH2*>> fhTSmCluTRun; //[nbSmTypes][nbSel]
231 std::vector<std::vector<TH2*>> fhTRpcCluTOffDTLastHits;
232 std::vector<std::vector<TH2*>> fhTRpcCluTotDTLastHits;
233 std::vector<std::vector<TH2*>> fhTRpcCluSizeDTLastHits;
234 std::vector<std::vector<TH2*>> fhTRpcCluMemMulDTLastHits;
235
236 std::vector<TH1*> fhSeldT; //[nbSel]
237
238 // Calibration control variables
239 Double_t dTRef;
240 Int_t fCalMode;
241 Double_t fdCaldXdYMax;
245 Int_t fDutId;
246 Int_t fDutSm;
247 Int_t fDutRpc;
248 Int_t fDutAddr;
249 Int_t fSelId;
250 Int_t fSelSm;
251 Int_t fSelRpc;
252 Int_t fSelAddr;
259 Int_t fSel2Id;
260 Int_t fSel2Sm;
261 Int_t fSel2Rpc;
263 Int_t fiMode;
265 uint64_t fiPulMulMin;
266 uint64_t fiPulDetRef;
267 uint64_t fiPulTotMin;
268 uint64_t fiPulTotMax;
269
270 std::map<UInt_t, UInt_t> fDetIdIndexMap;
271 std::vector<Int_t> fviDetId;
272
273 Double_t fPosYMaxScal;
274 Double_t fTRefDifMax;
275 Double_t fTotMax;
276 Double_t fTotMin;
277 Double_t fTotMean;
278 Double_t fdDelTofMax;
279 Double_t fMaxTimeDist;
281 Double_t fdMemoryTime;
282
284 Bool_t fbPs2Ns; // convert input raw digis from ps to ns
285
286 TString fCalParFileName; // name of the file name with Calibration Parameters
287 TString fOutHstFileName; // name of the histogram output file name with Calibration Parameters
288 TString fOutRootFileName; // name of the output file name with Digis & Hits
289 TFile* fCalParFile; // pointer to Calibration Parameter file
290 TFile* fOutRootFile; // pointer to root output file
291};
292
293#endif /* CBMDEVICEHITBUILDERTOF_H_ */
std::vector< std::vector< std::vector< std::vector< CbmTofDigi * > > > > fStorDigi
std::vector< TH1 * > fhRpcDTLastHits_CluSize
std::vector< std::string > fAllowedChannels
std::vector< std::vector< std::vector< Double_t > > > fvdDifCh
std::vector< std::vector< std::vector< Double_t > > > fvdX
std::vector< TH2 * > fhRpcCluAvWalk
std::vector< TH2 * > fhRpcCluTrms
std::vector< TH2 * > fhRpcCluPosition
std::vector< std::vector< TH2 * > > fhTRpcCluPosition
std::vector< CbmTofDigi > fvDigiIn
std::vector< TH2 * > fhRpcCluDelMatPos
std::vector< Int_t > vDigiIndRef
std::vector< TH2 * > fhRpcCluDelTOff
std::vector< std::vector< TH2 * > > fhTRpcCluTotDTLastHits
std::vector< TH2 * > fhRpcDigiTot
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)
std::vector< TH2 * > fhSmCluTOff
std::map< UInt_t, UInt_t > fDetIdIndexMap
std::vector< TH2 * > fhRpcDigiCor
std::vector< std::vector< std::vector< Int_t > > > fviClusterMul
std::vector< TH2 * > fhRpcCluAvLnWalk
std::vector< TH2 * > fhRpcCluTot
std::vector< TH2 * > fhSmCluPosition
std::vector< TProfile * > fhPulserTimeRawEvo
std::vector< TH2 * > fhRpcCluSize
bool HandleMessage(FairMQMessagePtr &, int)
std::vector< std::vector< TProfile * > > fhSmCluFpar
bool HandleData(FairMQParts &, int)
std::vector< std::vector< std::vector< Double_t > > > fvdDifX
std::vector< std::vector< TH2 * > > fhTRpcCluSizeDTLastHits
Bool_t IsChannelNameAllowed(std::string channelName)
std::vector< std::vector< std::vector< std::vector< Int_t > > > > fStorDigiInd
std::vector< std::vector< TH2 * > > fhTRpcCluAvWalk
std::vector< TH1 * > fhRpcDTLastHits_Tot
std::vector< std::vector< std::vector< Int_t > > > fviClusterSize
std::vector< std::vector< TH1 * > > fhTRpcCluMul
std::vector< CbmTofDigi > * fTofCalDigiVec
std::vector< std::vector< TH2 * > > fhTRpcCluTOff
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTOff
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotGain
std::vector< std::vector< TH2 * > > fhTSmCluPosition
std::vector< std::vector< TH2 * > > fhTRpcCluTot
std::vector< std::vector< std::vector< Double_t > > > fvdY
std::vector< std::vector< std::vector< Double_t > > > fvdDifY
std::vector< uint64_t > fEventHeader
std::vector< std::vector< TH2 * > > fhTRpcCludXdY
std::vector< std::vector< TH2 * > > fhTRpcCluMemMulDTLastHits
std::vector< std::vector< TH2 * > > fhTSmCluTRun
virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit *pHit)
virtual void fit_ybox(const char *hname)
std::vector< std::vector< TH2 * > > fhTRpcCluDelTof
std::vector< TProfile * > fhSmCluSvel
std::vector< TH1 * > fhRpcCluRate
std::vector< std::vector< std::vector< std::vector< TH2 * > > > > fhTRpcCluWalk
std::vector< std::vector< std::list< Double_t > > > fvPulserTimes
std::vector< std::vector< std::vector< TH2 * > > > fhRpcCluWalk
std::vector< std::vector< TH2 * > > fhTRpcCluSize
std::vector< std::vector< TH2 * > > fhTSmCluTOff
std::vector< TH2 * > fhRpcCluDelMatTOff
std::vector< std::vector< std::vector< std::vector< std::list< CbmTofHit * > > > > > fvLastHits
std::vector< std::vector< std::vector< std::vector< std::vector< Double_t > > > > > fvCPWalk
std::vector< std::vector< TH2 * > > fhTRpcCluTOffDTLastHits
std::vector< std::vector< std::vector< Int_t > > > fviTrkMul
std::vector< std::vector< Double_t > > fvPulserOffset
std::vector< TH2 * > fhRpcCluTOff
std::vector< TH2 * > fhRpcCluDelPos
std::vector< TH1 * > fhRpcDTLastHits
std::vector< TH1 * > fhRpcCluMul
std::vector< Int_t > fviDetId
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPDelTof
std::vector< Int_t > fvDeadStrips
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotOff
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
Histogram manager.
Data class with information on a STS local track.
Parameters class for the CBM ToF digitizer using beam data distributions.
Data class for expanded digital TOF information.
Definition CbmTofDigi.h:47