Due to developments in the Off-line code there is an impact on the HLT DA algorithms...
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFillHisto.h
CommitLineData
55a288e5 1#ifndef ALITRDCALIBRAFILLHISTO_H
2#define ALITRDCALIBRAFILLHISTO_H
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 27class TProfile2D;
55a288e5 28class TObjArray;
29class TH1F;
30class TH2I;
170c35f1 31class TH2F;
55a288e5 32class TH2;
170c35f1 33class TLinearFitter;
55a288e5 34
35class AliLog;
36class AliTRDCalibraMode;
37class AliTRDCalibraVector;
38
170c35f1 39class AliRawReader;
40class AliTRDRawStream;
55a288e5 41class AliTRDcluster;
42class AliTRDtrack;
43class AliTRDmcmTracklet;
170c35f1 44class TTreeSRedirector;
45
46struct eventHeaderStruct;
55a288e5 47
48class AliTRDCalibraFillHisto : public TObject {
49
50 public:
51
52 // Instance
53 static AliTRDCalibraFillHisto *Instance();
54 static void Terminate();
55 static void Destroy();
56
57 AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c);
58 AliTRDCalibraFillHisto &operator=(const AliTRDCalibraFillHisto &) { return *this; }
59
60 // Functions for initialising the AliTRDCalibraFillHisto in the code
61 Bool_t Init2Dhistos();
62
63 // Functions for filling the histos in the code
64 Bool_t ResetTrack();
65 Bool_t UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t);
66 Bool_t UpdateHistogramcm(AliTRDmcmTracklet *trk);
67
170c35f1 68 // Process events DAQ
69 Bool_t ProcessEventDAQ(AliTRDRawStream *rawStream);
70 Bool_t ProcessEventDAQ(AliRawReader *rawReader);
71 Bool_t ProcessEventDAQ(eventHeaderStruct *event);
72
73 Bool_t UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Int_t signal, Int_t nbtimebins);
74
75
55a288e5 76 // Is Pad on
77 Bool_t IsPadOn(Int_t detector, Int_t col, Int_t row) const;
78
79 // Functions for plotting the 2D
80 void Plot2d();
81
170c35f1 82 // Functions for write
83 void Write2d(const Char_t *filename = "TRD.calibration.root", Bool_t append = kFALSE);
84
85 // Reset the linearfitter objects
86 void ResetLinearFitter();
87 void ResetCHHisto() { if(fCH2d) fCH2d->Reset(); }
88 void ResetPHHisto() { if(fPH2d) fPH2d->Reset(); }
89 void ResetPRFHisto() { if(fPRF2d) fPRF2d->Reset();}
55a288e5 90
91 //For the statistics
92 Double_t *StatH(TH2 *ch, Int_t i);
170c35f1 93 Double_t *GetMeanMedianRMSNumberCH();
94 Double_t *GetMeanMedianRMSNumberLinearFitter() const;
95
55a288e5 96
97 //
98 // Set of Get the variables
99 //
100
101 // Choice to fill or not the 2D
102 void SetMITracking(Bool_t mitracking = kTRUE) { fMITracking = mitracking; }
103 void SetMcmTracking(Bool_t mcmtracking = kTRUE) { fMcmTracking = mcmtracking; }
104 void SetMcmCorrectAngle() { fMcmCorrectAngle = kTRUE; }
105 void SetPH2dOn() { fPH2dOn = kTRUE; }
106 void SetCH2dOn() { fCH2dOn = kTRUE; }
107 void SetPRF2dOn() { fPRF2dOn = kTRUE; }
108 void SetHisto2d() { fHisto2d = kTRUE; }
109 void SetVector2d() { fVector2d = kTRUE; }
170c35f1 110 void SetLinearFitterOn() { fLinearFitterOn = kTRUE; }
111 void SetLinearFitterDebugOn() { fLinearFitterDebugOn = kTRUE; }
112
55a288e5 113
114 Bool_t GetMITracking() const { return fMITracking; }
115 Bool_t GetMcmTracking() const { return fMcmTracking; }
116 Bool_t GetMcmCorrectAngle() const { return fMcmCorrectAngle; }
117 Bool_t GetPH2dOn() const { return fPH2dOn; }
118 Bool_t GetCH2dOn() const { return fCH2dOn; }
119 Bool_t GetPRF2dOn() const { return fPRF2dOn; }
120 Bool_t GetHisto2d() const { return fHisto2d; }
121 Bool_t GetVector2d() const { return fVector2d; }
122 TH2I *GetCH2d() const { return fCH2d; }
170c35f1 123 TProfile2D *GetPH2d(Int_t nbtimebin=24, Float_t samplefrequency= 10.0, Bool_t force=kFALSE);
124 TProfile2D *GetPRF2d() const { return fPRF2d; }
125 TObjArray GetLinearFitterArray() const { return fLinearFitterArray; }
126 TLinearFitter *GetLinearFitter(Int_t detector, Bool_t force=kFALSE);
127 TH2F *GetLinearFitterHisto(Int_t detector, Bool_t force=kFALSE);
128
55a288e5 129 // How to fill the 2D
55a288e5 130 void SetRelativeScale(Float_t relativeScale);
55a288e5 131 void SetThresholdClusterPRF2(Float_t thresholdClusterPRF2) { fThresholdClusterPRF2 = thresholdClusterPRF2; }
170c35f1 132 void SetNz(Int_t i, Short_t nz);
55a288e5 133 void SetNrphi(Int_t i, Short_t nrphi);
134 void SetProcent(Float_t procent) { fProcent = procent; }
135 void SetDifference(Short_t difference) { fDifference = difference; }
136 void SetNumberClusters(Short_t numberClusters) { fNumberClusters = numberClusters; }
137 void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; }
138 void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; }
170c35f1 139 void SetNumberGroupsPRF(Short_t numberGroupsPRF);
55a288e5 140
141 Float_t GetRelativeScale() const { return fRelativeScale; }
55a288e5 142 Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; }
143 Float_t GetProcent() const { return fProcent; }
144 Short_t GetDifference() const { return fDifference; }
145 Short_t GetNumberClusters() const { return fNumberClusters; }
146 Short_t GetNumberBinCharge() const { return fNumberBinCharge; }
147 Short_t GetNumberBinPRF() const { return fNumberBinPRF; }
170c35f1 148 Short_t GetNumberGroupsPRF() const { return fNgroupprf; }
149 Int_t *GetEntriesLinearFitter() const { return fEntriesLinearFitter; }
150 // Calibration mode
55a288e5 151AliTRDCalibraMode *GetCalibraMode() const { return fCalibraMode; }
152
170c35f1 153 // Debug
154 void SetDebugLevel(Short_t level) { fDebugLevel = level; }
155
156 // Vector method
55a288e5 157AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; }
158
159 private:
160
161 // This is a singleton, contructor is private!
162 AliTRDCalibraFillHisto();
163 virtual ~AliTRDCalibraFillHisto();
164
165 protected:
166
167 // Choice to fill or not the 2D
168 Bool_t fMITracking; // Chose to fill the 2D histos or vectors during the offline MI tracking
169 Bool_t fMcmTracking; // Chose to fill the 2D histos or vectors during the tracking with tracklets
170 Bool_t fMcmCorrectAngle; // Apply correction due to the mcmtrackletangle in the z direction (only) assuming from vertex
171 Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration
172 Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0
173 Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration
174 Bool_t fHisto2d; // Chose to fill the 2D histos
175 Bool_t fVector2d; // Chose to fill vectors
170c35f1 176 Bool_t fLinearFitterOn; // Method with linear fit for drift velocity
177 Bool_t fLinearFitterDebugOn; // Method with linear fit for drift velocity
55a288e5 178
179 // How to fill the 2D
180 Float_t fRelativeScale; // Scale of the deposited charge
170c35f1 181 Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals
182 // Calibration mode
55a288e5 183 AliTRDCalibraMode *fCalibraMode; // Calibration mode
184
170c35f1 185 //For debugging
186 TTreeSRedirector *fDebugStreamer; //!Debug streamer
187 Short_t fDebugLevel; // Flag for debugging
55a288e5 188 //
189 // Internal variables
190 //
191
192 // Fill the 2D histos in the offline tracking
193 Bool_t fDetectorAliTRDtrack; // Change of track
170c35f1 194 Int_t fDetectorPreviousTrack; // Change of detector
195 Short_t fNumberClusters; // Minimum number of clusters in the tracklets
55a288e5 196 Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
197 Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
198 Int_t fNumberTrack; // How many tracks could be used (Debug for the moment)
199 Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent)
200 Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference)
201 Int_t fTimeMax; // Number of time bins
202 Float_t fSf; // Sampling frequence
203 Short_t fNumberBinCharge; // Number of bins for the gain factor
204 Short_t fNumberBinPRF; // Number of bin for the PRF
170c35f1 205 Short_t fNgroupprf; // Number of groups in tnp bins for PRF /2.0
206
207 // Variables per tracklet
208 TObjArray *fListClusters; // List of clusters
209 Double_t *fPar0; // List of track parameter fP[0]
210 Double_t *fPar1; // List of track parameter fP[1]
211 Double_t *fPar2; // List of track parameter fP[2]
212 Double_t *fPar3; // List of track parameter fP[3]
213 Double_t *fPar4; // List of track paarmeter fP[4]
214 Float_t *fAmpTotal; // Energy deposited in the calibration group by the track
215 Short_t *fPHPlace; // Calibration group of PH
216 Float_t *fPHValue; // PH
217 Bool_t fGoodTracklet; // Good tracklet
218 // Variables per track
219 Bool_t fGoodTrack; // no return
220
221 //Statistics
222 Int_t *fEntriesCH; // Number of entries CH
223 Int_t *fEntriesLinearFitter; // Number of entries LinearFitter
224
55a288e5 225
226 //
227 // Vector method
228 //
229
230
231 AliTRDCalibraVector *fCalibraVector; // The vector object
232
233
234 // Histograms to store the info from the digits, from the tracklets or from the tracks
235 TProfile2D *fPH2d; // 2D average pulse height
236 TProfile2D *fPRF2d; // 2D PRF
170c35f1 237 TH2I *fCH2d; // 2D deposited charge
238 TObjArray fLinearFitterArray; // TObjArray of Linear Fitters for the detectors
239 TObjArray fLinearFitterHistoArray; // TObjArray of histo2D for debugging Linear Fitters
55a288e5 240
241 //
242 // A lot of internal functions......
243 //
55a288e5 244 // Create the 2D histo to be filled Online
245 void CreateCH2d(Int_t nn);
246 void CreatePH2d(Int_t nn);
247 void CreatePRF2d(Int_t nn);
248
249 // Fill the 2D
250 void FillTheInfoOfTheTrackPH();
251 void FillTheInfoOfTheTrackCH();
170c35f1 252 void FillCH2d(Int_t x, Float_t y);
170c35f1 253 Bool_t FindP1TrackPH();
55a288e5 254 void ResetfVariables();
255 Bool_t LocalisationDetectorXbins(Int_t detector);
170c35f1 256 Int_t *CalculateRowCol(AliTRDcluster *cl) const;
257 void CheckGoodTracklet(Int_t detector, Int_t *rowcol);
258 Int_t CalculateCalibrationGroup(Int_t i, Int_t *rowcol) const;
259 Int_t CalculateTotalNumberOfBins(Int_t i);
260 void StoreInfoCHPH(AliTRDcluster *cl, AliTRDtrack *t, Int_t *group);
261 Bool_t HandlePRF();
262
55a288e5 263 // Clear
264 void ClearHistos();
265
266 // Some basic geometry function
267 virtual Int_t GetPlane(Int_t d) const;
268 virtual Int_t GetChamber(Int_t d) const;
269 virtual Int_t GetSector(Int_t d) const;
270
271
272 // Instance of this class and so on
170c35f1 273 static AliTRDCalibraFillHisto *fgInstance; // Instance
274 static Bool_t fgTerminated; // If terminated
275
55a288e5 276
170c35f1 277 ClassDef(AliTRDCalibraFillHisto,2) // TRD Calibration class
55a288e5 278
279};
280
281#endif
282
283