55a288e5 |
1 | #ifndef ALITRDCALIBRAFILLHISTO_H |
bcb6fb78 |
2 | #define ALITRDCALIBRAFILLHISTOs_H |
55a288e5 |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * See cxx source for full Copyright notice */ |
5 | |
6 | /* $Id$ */ |
7 | |
8 | /////////////////////////////////////////////////////////////////////////////// |
9 | // // |
10 | // TRD calibration class for the HLT parameters // |
11 | // // |
12 | /////////////////////////////////////////////////////////////////////////////// |
13 | |
14 | #ifndef ROOT_TObject |
15 | # include <TObject.h> |
16 | #endif |
170c35f1 |
17 | #ifndef ROOT_TLinearFitter |
18 | # include <TLinearFitter.h> |
19 | #endif |
20 | #ifndef ROOT_TProfile2D |
21 | # include <TProfile2D.h> |
22 | #endif |
23 | #ifndef ROOT_TH2I |
24 | # include <TH2I.h> |
25 | #endif |
55a288e5 |
26 | |
55a288e5 |
27 | class TProfile2D; |
55a288e5 |
28 | class TObjArray; |
29 | class TH1F; |
30 | class TH2I; |
170c35f1 |
31 | class TH2F; |
55a288e5 |
32 | class TH2; |
170c35f1 |
33 | class TLinearFitter; |
3a0f6479 |
34 | class TTreeSRedirector; |
55a288e5 |
35 | |
36 | class AliLog; |
f162af62 |
37 | class AliRawReader; |
38 | |
55a288e5 |
39 | class AliTRDCalibraMode; |
40 | class AliTRDCalibraVector; |
3a0f6479 |
41 | class AliTRDCalibraVdriftLinearFit; |
b70c68da |
42 | class AliTRDrawStreamBase; |
55a288e5 |
43 | class AliTRDcluster; |
bcb6fb78 |
44 | class AliTRDtrackV1; |
55a288e5 |
45 | class AliTRDtrack; |
bcb6fb78 |
46 | class AliTRDseedV1; |
f162af62 |
47 | class AliTRDgeometry; |
d0569428 |
48 | class AliTRDCalDet; |
49 | class AliTRDCalROC; |
50 | |
170c35f1 |
51 | |
52 | struct eventHeaderStruct; |
55a288e5 |
53 | |
54 | class AliTRDCalibraFillHisto : public TObject { |
55 | |
56 | public: |
57 | |
58 | // Instance |
59 | static AliTRDCalibraFillHisto *Instance(); |
60 | static void Terminate(); |
61 | static void Destroy(); |
bcb6fb78 |
62 | void DestroyDebugStreamer(); |
63 | |
55a288e5 |
64 | |
65 | AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c); |
66 | AliTRDCalibraFillHisto &operator=(const AliTRDCalibraFillHisto &) { return *this; } |
67 | |
bcb6fb78 |
68 | // Functions for initialising and filling with AliTRDtrackV1 |
69 | Bool_t Init2Dhistos(); |
70 | Bool_t UpdateHistograms(AliTRDtrack *t); |
71 | Bool_t UpdateHistogramsV1(AliTRDtrackV1 *t); |
55a288e5 |
72 | |
3a0f6479 |
73 | // Process events DAQ |
b70c68da |
74 | Int_t ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bool_t nocheck = kFALSE); |
3a0f6479 |
75 | Int_t ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck = kFALSE); |
76 | Int_t ProcessEventDAQ(eventHeaderStruct *event, Bool_t nocheck = kFALSE); |
170c35f1 |
77 | |
55a288e5 |
78 | // Is Pad on |
bcb6fb78 |
79 | Bool_t IsPadOn(Int_t detector, Int_t row, Int_t col) const; |
55a288e5 |
80 | |
170c35f1 |
81 | // Functions for write |
82 | void Write2d(const Char_t *filename = "TRD.calibration.root", Bool_t append = kFALSE); |
83 | |
55a288e5 |
84 | //For the statistics |
85 | Double_t *StatH(TH2 *ch, Int_t i); |
170c35f1 |
86 | Double_t *GetMeanMedianRMSNumberCH(); |
87 | Double_t *GetMeanMedianRMSNumberLinearFitter() const; |
64942b85 |
88 | // LinearFitter |
89 | void AnalyseLinearFitter(); |
170c35f1 |
90 | |
55a288e5 |
91 | |
92 | // |
93 | // Set of Get the variables |
94 | // |
95 | |
64942b85 |
96 | void SetIsHLT(Bool_t isHLT = kTRUE) { fIsHLT = isHLT; } |
97 | Bool_t IsHLT() const { return fIsHLT; } |
98 | |
55a288e5 |
99 | // Choice to fill or not the 2D |
e526983e |
100 | void SetPH2dOn(Bool_t ph2don = kTRUE) { fPH2dOn = ph2don; } |
3a0f6479 |
101 | void SetCH2dOn(Bool_t ch2don = kTRUE) { fCH2dOn = ch2don; } |
102 | void SetPRF2dOn(Bool_t prf2don = kTRUE) { fPRF2dOn = prf2don; } |
103 | void SetHisto2d(Bool_t histo2d = kTRUE) { fHisto2d = histo2d; } |
104 | void SetVector2d(Bool_t vector2d = kTRUE) { fVector2d = vector2d; } |
105 | void SetLinearFitterOn(Bool_t linearfitteron = kTRUE) { fLinearFitterOn = linearfitteron;} |
106 | void SetLinearFitterDebugOn(Bool_t debug = kTRUE) { fLinearFitterDebugOn = debug; } |
107 | |
55a288e5 |
108 | |
e526983e |
109 | Bool_t GetPH2dOn() const { return fPH2dOn; } |
55a288e5 |
110 | Bool_t GetCH2dOn() const { return fCH2dOn; } |
111 | Bool_t GetPRF2dOn() const { return fPRF2dOn; } |
112 | Bool_t GetHisto2d() const { return fHisto2d; } |
113 | Bool_t GetVector2d() const { return fVector2d; } |
3a0f6479 |
114 | Bool_t GetLinearFitterOn() const { return fLinearFitterOn; } |
bcb6fb78 |
115 | Bool_t GetLinearFitterDebugOn() const { return fLinearFitterDebugOn; } |
116 | |
117 | |
118 | // Get stuff that are filled |
119 | TH2I *GetCH2d(); |
3a0f6479 |
120 | TProfile2D *GetPH2d(Int_t nbtimebin=24, Float_t samplefrequency= 10.0); |
170c35f1 |
121 | TProfile2D *GetPRF2d() const { return fPRF2d; } |
122 | TObjArray GetLinearFitterArray() const { return fLinearFitterArray; } |
123 | TLinearFitter *GetLinearFitter(Int_t detector, Bool_t force=kFALSE); |
d0569428 |
124 | AliTRDCalibraVdriftLinearFit *GetVdriftLinearFit() const { return fLinearVdriftFit; } |
3a0f6479 |
125 | |
170c35f1 |
126 | |
55a288e5 |
127 | // How to fill the 2D |
55a288e5 |
128 | void SetRelativeScale(Float_t relativeScale); |
55a288e5 |
129 | void SetThresholdClusterPRF2(Float_t thresholdClusterPRF2) { fThresholdClusterPRF2 = thresholdClusterPRF2; } |
b70c68da |
130 | void SetLimitChargeIntegration(Bool_t limitChargeIntegration) { fLimitChargeIntegration = limitChargeIntegration; } |
37b0cf5e |
131 | void SetFillWithZero(Bool_t fillWithZero) { fFillWithZero = fillWithZero; } |
64942b85 |
132 | void SetNormalizeNbOfCluster(Bool_t normalizeNbOfCluster) { fNormalizeNbOfCluster = normalizeNbOfCluster; } |
133 | void SetMaxCluster(Float_t maxCluster) { fMaxCluster = maxCluster; } |
134 | void SetNbMaxCluster(Short_t nbMaxCluster) { fNbMaxCluster = nbMaxCluster; } |
170c35f1 |
135 | void SetNz(Int_t i, Short_t nz); |
55a288e5 |
136 | void SetNrphi(Int_t i, Short_t nrphi); |
64942b85 |
137 | void SetAllTogether(Int_t i); |
138 | void SetPerSuperModule(Int_t i); |
139 | void SetProcent(Float_t procent) { fProcent = procent; } |
55a288e5 |
140 | void SetDifference(Short_t difference) { fDifference = difference; } |
e526983e |
141 | void SetNumberClusters(Short_t numberClusters) { if(numberClusters >= 0) fNumberClusters = numberClusters; } |
bcb6fb78 |
142 | void SetNumberClustersf(Short_t numberClustersf) { fNumberClustersf = numberClustersf; } |
55a288e5 |
143 | void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; } |
144 | void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; } |
170c35f1 |
145 | void SetNumberGroupsPRF(Short_t numberGroupsPRF); |
55a288e5 |
146 | |
147 | Float_t GetRelativeScale() const { return fRelativeScale; } |
55a288e5 |
148 | Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; } |
b70c68da |
149 | Bool_t GetLimitChargeIntegration() const { return fLimitChargeIntegration; } |
37b0cf5e |
150 | Bool_t GetFillWithZero() const { return fFillWithZero; } |
64942b85 |
151 | Bool_t GetNormalizeNbOfCluster() const { return fNormalizeNbOfCluster; } |
152 | Float_t GetMaxCluster() const { return fMaxCluster; } |
153 | Short_t GetNbMaxCluster() const { return fNbMaxCluster; } |
55a288e5 |
154 | Float_t GetProcent() const { return fProcent; } |
155 | Short_t GetDifference() const { return fDifference; } |
156 | Short_t GetNumberClusters() const { return fNumberClusters; } |
bcb6fb78 |
157 | Short_t GetNumberClustersf() const { return fNumberClustersf; } |
55a288e5 |
158 | Short_t GetNumberBinCharge() const { return fNumberBinCharge; } |
159 | Short_t GetNumberBinPRF() const { return fNumberBinPRF; } |
170c35f1 |
160 | Short_t GetNumberGroupsPRF() const { return fNgroupprf; } |
161 | Int_t *GetEntriesLinearFitter() const { return fEntriesLinearFitter; } |
55a288e5 |
162 | |
170c35f1 |
163 | // Debug |
164 | void SetDebugLevel(Short_t level) { fDebugLevel = level; } |
165 | |
166 | // Vector method |
55a288e5 |
167 | AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; } |
e4db522f |
168 | |
55a288e5 |
169 | protected: |
170 | |
f162af62 |
171 | // Geometry |
172 | AliTRDgeometry *fGeo; //! The TRD geometry |
173 | |
64942b85 |
174 | // Is HLT |
175 | Bool_t fIsHLT; // Now if HLT, the per detector |
176 | |
55a288e5 |
177 | // Choice to fill or not the 2D |
e526983e |
178 | Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration |
55a288e5 |
179 | Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0 |
180 | Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration |
181 | Bool_t fHisto2d; // Chose to fill the 2D histos |
182 | Bool_t fVector2d; // Chose to fill vectors |
170c35f1 |
183 | Bool_t fLinearFitterOn; // Method with linear fit for drift velocity |
184 | Bool_t fLinearFitterDebugOn; // Method with linear fit for drift velocity |
55a288e5 |
185 | |
186 | // How to fill the 2D |
187 | Float_t fRelativeScale; // Scale of the deposited charge |
170c35f1 |
188 | Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals |
b70c68da |
189 | Bool_t fLimitChargeIntegration; // Integration range for the gain calibration |
37b0cf5e |
190 | Bool_t fFillWithZero; // Fill with zero or not the average pulse height |
64942b85 |
191 | Bool_t fNormalizeNbOfCluster; // Normalize with the number of cluster for the gain |
192 | Float_t fMaxCluster; // Max amplitude of one cluster |
193 | Short_t fNbMaxCluster; // Number of tb at the end |
170c35f1 |
194 | // Calibration mode |
55a288e5 |
195 | AliTRDCalibraMode *fCalibraMode; // Calibration mode |
196 | |
170c35f1 |
197 | //For debugging |
198 | TTreeSRedirector *fDebugStreamer; //!Debug streamer |
199 | Short_t fDebugLevel; // Flag for debugging |
55a288e5 |
200 | // |
201 | // Internal variables |
202 | // |
203 | |
204 | // Fill the 2D histos in the offline tracking |
170c35f1 |
205 | Int_t fDetectorPreviousTrack; // Change of detector |
e4db522f |
206 | Int_t fMCMPrevious; // Change of MCM |
207 | Int_t fROBPrevious; // Change of ROB |
170c35f1 |
208 | Short_t fNumberClusters; // Minimum number of clusters in the tracklets |
bcb6fb78 |
209 | Short_t fNumberClustersf; // Maximum number of clusters in the tracklets |
55a288e5 |
210 | Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH) |
211 | Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH) |
212 | Int_t fNumberTrack; // How many tracks could be used (Debug for the moment) |
213 | Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent) |
214 | Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference) |
215 | Int_t fTimeMax; // Number of time bins |
216 | Float_t fSf; // Sampling frequence |
217 | Short_t fNumberBinCharge; // Number of bins for the gain factor |
218 | Short_t fNumberBinPRF; // Number of bin for the PRF |
170c35f1 |
219 | Short_t fNgroupprf; // Number of groups in tnp bins for PRF /2.0 |
220 | |
221 | // Variables per tracklet |
170c35f1 |
222 | Float_t *fAmpTotal; // Energy deposited in the calibration group by the track |
223 | Short_t *fPHPlace; // Calibration group of PH |
224 | Float_t *fPHValue; // PH |
225 | Bool_t fGoodTracklet; // Good tracklet |
1ca79a00 |
226 | TLinearFitter *fLinearFitterTracklet; // linear fitter tracklet |
bcb6fb78 |
227 | //Statistics |
170c35f1 |
228 | Int_t *fEntriesCH; // Number of entries CH |
229 | Int_t *fEntriesLinearFitter; // Number of entries LinearFitter |
230 | |
55a288e5 |
231 | |
232 | // |
233 | // Vector method |
234 | // |
d0569428 |
235 | |
236 | AliTRDCalibraVector *fCalibraVector; // The vector object |
55a288e5 |
237 | |
238 | |
239 | // Histograms to store the info from the digits, from the tracklets or from the tracks |
d0569428 |
240 | TProfile2D *fPH2d; // 2D average pulse height |
241 | TProfile2D *fPRF2d; // 2D PRF |
242 | TH2I *fCH2d; // 2D deposited charge |
243 | TObjArray fLinearFitterArray; // TObjArray of Linear Fitters for the detectors |
244 | AliTRDCalibraVdriftLinearFit *fLinearVdriftFit; // Info Linear Fit |
245 | |
246 | // Current calib object: to correct for the database used |
247 | AliTRDCalDet *fCalDetGain; // Current calib object gain |
248 | AliTRDCalROC *fCalROCGain; // Current calib object gain |
bcb6fb78 |
249 | |
55a288e5 |
250 | // |
251 | // A lot of internal functions...... |
252 | // |
55a288e5 |
253 | // Create the 2D histo to be filled Online |
254 | void CreateCH2d(Int_t nn); |
255 | void CreatePH2d(Int_t nn); |
3a0f6479 |
256 | void CreatePRF2d(Int_t nn); |
55a288e5 |
257 | |
bcb6fb78 |
258 | // Calibration with AliTRDtrackV1 |
55a288e5 |
259 | void FillTheInfoOfTheTrackPH(); |
bcb6fb78 |
260 | void FillTheInfoOfTheTrackCH(Int_t nbclusters); |
261 | Bool_t FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index0, Int_t index1); |
262 | Bool_t FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters); |
263 | Bool_t HandlePRFtracklet(AliTRDtrack *t, Int_t index0, Int_t index1); |
264 | Bool_t HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters); |
265 | void ResetfVariablestracklet(); |
266 | void StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl, Int_t *group, Int_t row, Int_t col); |
170c35f1 |
267 | void FillCH2d(Int_t x, Float_t y); |
bcb6fb78 |
268 | |
269 | // Calibration on DAQ |
270 | |
271 | Int_t FillDAQ(Double_t phvalue[16][144][36]); |
bcb6fb78 |
272 | Bool_t UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins); |
00a3834d |
273 | |
274 | // row col calibration groups stuff |
55a288e5 |
275 | Bool_t LocalisationDetectorXbins(Int_t detector); |
170c35f1 |
276 | Int_t CalculateTotalNumberOfBins(Int_t i); |
d95484e4 |
277 | void CheckGoodTrackletV0(Int_t detector, Int_t row, Int_t col); |
278 | void CheckGoodTrackletV1(AliTRDcluster *cl); |
bcb6fb78 |
279 | Int_t CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const; |
170c35f1 |
280 | |
55a288e5 |
281 | // Clear |
282 | void ClearHistos(); |
283 | |
284 | // Some basic geometry function |
053767a4 |
285 | virtual Int_t GetLayer(Int_t d) const; |
286 | virtual Int_t GetStack(Int_t d) const; |
55a288e5 |
287 | virtual Int_t GetSector(Int_t d) const; |
d0569428 |
288 | |
bcb6fb78 |
289 | |
55a288e5 |
290 | // Instance of this class and so on |
170c35f1 |
291 | static AliTRDCalibraFillHisto *fgInstance; // Instance |
292 | static Bool_t fgTerminated; // If terminated |
0c349049 |
293 | |
0c349049 |
294 | private: |
295 | |
296 | // This is a singleton, contructor is private! |
297 | AliTRDCalibraFillHisto(); |
e4db522f |
298 | virtual ~AliTRDCalibraFillHisto(); |
55a288e5 |
299 | |
e4db522f |
300 | ClassDef(AliTRDCalibraFillHisto,4) // TRD Calibration class |
55a288e5 |
301 | |
302 | }; |
303 | |
304 | #endif |
305 | |
306 | |