Effective C++ warnings
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFillHisto.h
CommitLineData
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 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;
d4232bb6 42class AliTRDrawStreamTB;
55a288e5 43class AliTRDcluster;
bcb6fb78 44class AliTRDtrackV1;
55a288e5 45class AliTRDtrack;
bcb6fb78 46class AliTRDseedV1;
47class AliTRDmcm;
55a288e5 48class AliTRDmcmTracklet;
f162af62 49class AliTRDgeometry;
d0569428 50class AliTRDCalDet;
51class AliTRDCalROC;
52
170c35f1 53
54struct eventHeaderStruct;
55a288e5 55
56class AliTRDCalibraFillHisto : public TObject {
57
58 public:
59
60 // Instance
61 static AliTRDCalibraFillHisto *Instance();
62 static void Terminate();
63 static void Destroy();
bcb6fb78 64 void DestroyDebugStreamer();
65
55a288e5 66
67 AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c);
68 AliTRDCalibraFillHisto &operator=(const AliTRDCalibraFillHisto &) { return *this; }
69
bcb6fb78 70 // Functions for initialising and filling with AliTRDtrackV1
71 Bool_t Init2Dhistos();
72 Bool_t UpdateHistograms(AliTRDtrack *t);
73 Bool_t UpdateHistogramsV1(AliTRDtrackV1 *t);
55a288e5 74
3a0f6479 75 // Process events DAQ
d4232bb6 76 Int_t ProcessEventDAQ(AliTRDrawStreamTB *rawStream, Bool_t nocheck = kFALSE);
3a0f6479 77 Int_t ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck = kFALSE);
78 Int_t ProcessEventDAQ(eventHeaderStruct *event, Bool_t nocheck = kFALSE);
170c35f1 79
bcb6fb78 80 Int_t ProcessEventDAQV1(AliTRDrawStreamTB *rawStream, Bool_t nocheck = kFALSE);
81 Int_t ProcessEventDAQV1(AliRawReader *rawReader, Bool_t nocheck = kFALSE);
82 Int_t ProcessEventDAQV1(eventHeaderStruct *event, Bool_t nocheck = kFALSE);
170c35f1 83
55a288e5 84 // Is Pad on
bcb6fb78 85 Bool_t IsPadOn(Int_t detector, Int_t row, Int_t col) const;
55a288e5 86
170c35f1 87 // Functions for write
88 void Write2d(const Char_t *filename = "TRD.calibration.root", Bool_t append = kFALSE);
89
55a288e5 90 //For the statistics
91 Double_t *StatH(TH2 *ch, Int_t i);
170c35f1 92 Double_t *GetMeanMedianRMSNumberCH();
93 Double_t *GetMeanMedianRMSNumberLinearFitter() const;
94
55a288e5 95
96 //
97 // Set of Get the variables
98 //
99
100 // Choice to fill or not the 2D
3a0f6479 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
55a288e5 111 Bool_t GetMcmCorrectAngle() const { return fMcmCorrectAngle; }
112 Bool_t GetPH2dOn() const { return fPH2dOn; }
113 Bool_t GetCH2dOn() const { return fCH2dOn; }
114 Bool_t GetPRF2dOn() const { return fPRF2dOn; }
115 Bool_t GetHisto2d() const { return fHisto2d; }
116 Bool_t GetVector2d() const { return fVector2d; }
3a0f6479 117 Bool_t GetLinearFitterOn() const { return fLinearFitterOn; }
bcb6fb78 118 Bool_t GetLinearFitterDebugOn() const { return fLinearFitterDebugOn; }
119
120
121 // Get stuff that are filled
122 TH2I *GetCH2d();
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; }
bcb6fb78 138 void SetNumberClustersf(Short_t numberClustersf) { fNumberClustersf = numberClustersf; }
55a288e5 139 void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; }
140 void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; }
170c35f1 141 void SetNumberGroupsPRF(Short_t numberGroupsPRF);
55a288e5 142
143 Float_t GetRelativeScale() const { return fRelativeScale; }
55a288e5 144 Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; }
145 Float_t GetProcent() const { return fProcent; }
146 Short_t GetDifference() const { return fDifference; }
147 Short_t GetNumberClusters() const { return fNumberClusters; }
bcb6fb78 148 Short_t GetNumberClustersf() const { return fNumberClustersf; }
55a288e5 149 Short_t GetNumberBinCharge() const { return fNumberBinCharge; }
150 Short_t GetNumberBinPRF() const { return fNumberBinPRF; }
170c35f1 151 Short_t GetNumberGroupsPRF() const { return fNgroupprf; }
152 Int_t *GetEntriesLinearFitter() const { return fEntriesLinearFitter; }
55a288e5 153
170c35f1 154 // Debug
155 void SetDebugLevel(Short_t level) { fDebugLevel = level; }
156
157 // Vector method
55a288e5 158AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; }
e4db522f 159
55a288e5 160 protected:
161
f162af62 162 // Geometry
163 AliTRDgeometry *fGeo; //! The TRD geometry
164
55a288e5 165 // Choice to fill or not the 2D
55a288e5 166 Bool_t fMcmCorrectAngle; // Apply correction due to the mcmtrackletangle in the z direction (only) assuming from vertex
167 Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration
168 Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0
169 Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration
170 Bool_t fHisto2d; // Chose to fill the 2D histos
171 Bool_t fVector2d; // Chose to fill vectors
170c35f1 172 Bool_t fLinearFitterOn; // Method with linear fit for drift velocity
173 Bool_t fLinearFitterDebugOn; // Method with linear fit for drift velocity
55a288e5 174
175 // How to fill the 2D
176 Float_t fRelativeScale; // Scale of the deposited charge
170c35f1 177 Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals
178 // Calibration mode
55a288e5 179 AliTRDCalibraMode *fCalibraMode; // Calibration mode
180
170c35f1 181 //For debugging
182 TTreeSRedirector *fDebugStreamer; //!Debug streamer
183 Short_t fDebugLevel; // Flag for debugging
55a288e5 184 //
185 // Internal variables
186 //
187
188 // Fill the 2D histos in the offline tracking
170c35f1 189 Int_t fDetectorPreviousTrack; // Change of detector
e4db522f 190 Int_t fMCMPrevious; // Change of MCM
191 Int_t fROBPrevious; // Change of ROB
170c35f1 192 Short_t fNumberClusters; // Minimum number of clusters in the tracklets
bcb6fb78 193 Short_t fNumberClustersf; // Maximum number of clusters in the tracklets
55a288e5 194 Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
195 Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
196 Int_t fNumberTrack; // How many tracks could be used (Debug for the moment)
197 Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent)
198 Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference)
199 Int_t fTimeMax; // Number of time bins
200 Float_t fSf; // Sampling frequence
201 Short_t fNumberBinCharge; // Number of bins for the gain factor
202 Short_t fNumberBinPRF; // Number of bin for the PRF
170c35f1 203 Short_t fNgroupprf; // Number of groups in tnp bins for PRF /2.0
204
205 // Variables per tracklet
170c35f1 206 Float_t *fAmpTotal; // Energy deposited in the calibration group by the track
207 Short_t *fPHPlace; // Calibration group of PH
208 Float_t *fPHValue; // PH
209 Bool_t fGoodTracklet; // Good tracklet
bcb6fb78 210 //Statistics
170c35f1 211 Int_t *fEntriesCH; // Number of entries CH
212 Int_t *fEntriesLinearFitter; // Number of entries LinearFitter
213
55a288e5 214
215 //
216 // Vector method
217 //
d0569428 218
219 AliTRDCalibraVector *fCalibraVector; // The vector object
55a288e5 220
221
222 // Histograms to store the info from the digits, from the tracklets or from the tracks
d0569428 223 TProfile2D *fPH2d; // 2D average pulse height
224 TProfile2D *fPRF2d; // 2D PRF
225 TH2I *fCH2d; // 2D deposited charge
226 TObjArray fLinearFitterArray; // TObjArray of Linear Fitters for the detectors
227 AliTRDCalibraVdriftLinearFit *fLinearVdriftFit; // Info Linear Fit
228
229 // Current calib object: to correct for the database used
230 AliTRDCalDet *fCalDetGain; // Current calib object gain
231 AliTRDCalROC *fCalROCGain; // Current calib object gain
bcb6fb78 232
55a288e5 233 //
234 // A lot of internal functions......
235 //
55a288e5 236 // Create the 2D histo to be filled Online
237 void CreateCH2d(Int_t nn);
238 void CreatePH2d(Int_t nn);
3a0f6479 239 void CreatePRF2d(Int_t nn);
55a288e5 240
bcb6fb78 241 // Calibration with AliTRDtrackV1
55a288e5 242 void FillTheInfoOfTheTrackPH();
bcb6fb78 243 void FillTheInfoOfTheTrackCH(Int_t nbclusters);
244 Bool_t FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index0, Int_t index1);
245 Bool_t FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters);
246 Bool_t HandlePRFtracklet(AliTRDtrack *t, Int_t index0, Int_t index1);
247 Bool_t HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters);
248 void ResetfVariablestracklet();
249 void StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl, Int_t *group, Int_t row, Int_t col);
170c35f1 250 void FillCH2d(Int_t x, Float_t y);
bcb6fb78 251
252 // Calibration on DAQ
253
254 Int_t FillDAQ(Double_t phvalue[16][144][36]);
255 Int_t FillDAQ(AliTRDmcm *mcm);
256 Int_t TestTracklet( Int_t idet, Int_t row, Int_t iSeed, AliTRDmcm *mcm);
257 Bool_t UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins);
258 Int_t UpdateHistogramcm(AliTRDmcmTracklet *trk);
259
260 // row col calibration groups stuff
55a288e5 261 Bool_t LocalisationDetectorXbins(Int_t detector);
170c35f1 262 Int_t CalculateTotalNumberOfBins(Int_t i);
bcb6fb78 263 void CheckGoodTracklet(Int_t detector, Int_t row, Int_t col);
264 Int_t CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const;
3a0f6479 265
266 // LinearFitter
267 void AnalyseLinearFitter();
170c35f1 268
55a288e5 269 // Clear
270 void ClearHistos();
271
272 // Some basic geometry function
273 virtual Int_t GetPlane(Int_t d) const;
274 virtual Int_t GetChamber(Int_t d) const;
275 virtual Int_t GetSector(Int_t d) const;
d0569428 276
bcb6fb78 277
55a288e5 278 // Instance of this class and so on
170c35f1 279 static AliTRDCalibraFillHisto *fgInstance; // Instance
280 static Bool_t fgTerminated; // If terminated
0c349049 281
0c349049 282 private:
283
284 // This is a singleton, contructor is private!
285 AliTRDCalibraFillHisto();
e4db522f 286 virtual ~AliTRDCalibraFillHisto();
55a288e5 287
e4db522f 288 ClassDef(AliTRDCalibraFillHisto,4) // TRD Calibration class
55a288e5 289
290};
291
292#endif
293
294