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