]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/TRDbase/AliTRDCalibraFillHisto.h
Coverity fix
[u/mrichter/AliRoot.git] / TRD / TRDbase / AliTRDCalibraFillHisto.h
CommitLineData
55a288e5 1#ifndef ALITRDCALIBRAFILLHISTO_H
6bbdc11a 2#define ALITRDCALIBRAFILLHISTO_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_TProfile2D
18# include <TProfile2D.h>
19#endif
6bbdc11a 20
464611d8 21#include "TObjArray.h"
55a288e5 22
55a288e5 23class TProfile2D;
55a288e5 24class TObjArray;
25class TH1F;
26class TH2I;
170c35f1 27class TH2F;
55a288e5 28class TH2;
170c35f1 29class TLinearFitter;
3a0f6479 30class TTreeSRedirector;
55a288e5 31
32class AliLog;
f162af62 33class AliRawReader;
34
5f689709 35class AliESDtrack;
36
55a288e5 37class AliTRDCalibraMode;
38class AliTRDCalibraVector;
3a0f6479 39class AliTRDCalibraVdriftLinearFit;
a0bb5615 40class AliTRDCalibraExbAltFit;
55a288e5 41class AliTRDcluster;
bcb6fb78 42class AliTRDtrackV1;
bcb6fb78 43class AliTRDseedV1;
f162af62 44class AliTRDgeometry;
d0569428 45class AliTRDCalDet;
46class AliTRDCalROC;
01239968 47class AliTRDcalibDB;
d0569428 48
1785640c 49class AliTRDdigitsManager;
50class AliTRDSignalIndex;
170c35f1 51
52struct eventHeaderStruct;
55a288e5 53
54class 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
9ff7be6d 69 Bool_t Init2Dhistos(Int_t nboftimebin = -1);
a2a4ec8e 70 Bool_t InitCalDet();
5f689709 71 Bool_t UpdateHistogramsV1(const AliTRDtrackV1 *t,const AliESDtrack *esdtrack = NULL);
55a288e5 72
3a0f6479 73 // Process events DAQ
8df1f8f5 74 Int_t ProcessEventDAQ(AliRawReader *rawReader);
170c35f1 75
55a288e5 76 // Is Pad on
bcb6fb78 77 Bool_t IsPadOn(Int_t detector, Int_t row, Int_t col) const;
55a288e5 78
170c35f1 79 // Functions for write
80 void Write2d(const Char_t *filename = "TRD.calibration.root", Bool_t append = kFALSE);
81
55a288e5 82 //For the statistics
83 Double_t *StatH(TH2 *ch, Int_t i);
170c35f1 84 Double_t *GetMeanMedianRMSNumberCH();
85 Double_t *GetMeanMedianRMSNumberLinearFitter() const;
64942b85 86 // LinearFitter
87 void AnalyseLinearFitter();
170c35f1 88
55a288e5 89
90 //
91 // Set of Get the variables
92 //
93
64942b85 94 void SetIsHLT(Bool_t isHLT = kTRUE) { fIsHLT = isHLT; }
95 Bool_t IsHLT() const { return fIsHLT; }
96
55a288e5 97 // Choice to fill or not the 2D
e526983e 98 void SetPH2dOn(Bool_t ph2don = kTRUE) { fPH2dOn = ph2don; }
3a0f6479 99 void SetCH2dOn(Bool_t ch2don = kTRUE) { fCH2dOn = ch2don; }
100 void SetPRF2dOn(Bool_t prf2don = kTRUE) { fPRF2dOn = prf2don; }
101 void SetHisto2d(Bool_t histo2d = kTRUE) { fHisto2d = histo2d; }
102 void SetVector2d(Bool_t vector2d = kTRUE) { fVector2d = vector2d; }
103 void SetLinearFitterOn(Bool_t linearfitteron = kTRUE) { fLinearFitterOn = linearfitteron;}
104 void SetLinearFitterDebugOn(Bool_t debug = kTRUE) { fLinearFitterDebugOn = debug; }
a0bb5615 105 void SetExbAltFitOn(Bool_t fiton = kTRUE) { fExbAltFitOn = fiton;}
532be2d4 106 void SetScaleWithTPCSignal(Bool_t scaleWithTPCSignal = kTRUE) { fScaleWithTPCSignal = scaleWithTPCSignal;}
bb14268f 107 void SetTakeSnapshot(Bool_t takesnapshot) { fTakeSnapshot = takesnapshot; }
d085ba91 108 void SetFirstRunGain(Int_t firstRunGain) { fFirstRunGain = firstRunGain; }
4c865c34 109 void SetVersionGainUsed(Int_t versionGainUsed) { fVersionGainUsed = versionGainUsed; }
110 void SetSubVersionGainUsed(Int_t subVersionGainUsed) { fSubVersionGainUsed = subVersionGainUsed; }
d085ba91 111 void SetFirstRunGainLocal(Int_t firstRunGainLocal) { fFirstRunGainLocal = firstRunGainLocal; }
a2a4ec8e 112 void SetVersionGainLocalUsed(Int_t versionGainLocalUsed) { fVersionGainLocalUsed = versionGainLocalUsed; }
113 void SetSubVersionGainLocalUsed(Int_t subVersionGainLocalUsed) { fSubVersionGainLocalUsed = subVersionGainLocalUsed; }
d085ba91 114 void SetFirstRunVdrift(Int_t firstRunVdrift) { fFirstRunVdrift = firstRunVdrift; }
4c865c34 115 void SetVersionVdriftUsed(Int_t versionVdriftUsed) { fVersionVdriftUsed = versionVdriftUsed; }
116 void SetSubVersionVdriftUsed(Int_t subVersionVdriftUsed) { fSubVersionVdriftUsed = subVersionVdriftUsed; }
b2277aa2 117 void SetFirstRunExB(Int_t firstRunExB) { fFirstRunExB = firstRunExB; }
118 void SetVersionExBUsed(Int_t versionExBUsed) { fVersionExBUsed = versionExBUsed; }
119 void SetSubVersionExBUsed(Int_t subVersionExBUsed) { fSubVersionExBUsed = subVersionExBUsed; }
120
55a288e5 121
e526983e 122 Bool_t GetPH2dOn() const { return fPH2dOn; }
55a288e5 123 Bool_t GetCH2dOn() const { return fCH2dOn; }
124 Bool_t GetPRF2dOn() const { return fPRF2dOn; }
125 Bool_t GetHisto2d() const { return fHisto2d; }
126 Bool_t GetVector2d() const { return fVector2d; }
3a0f6479 127 Bool_t GetLinearFitterOn() const { return fLinearFitterOn; }
4c865c34 128 Bool_t GetLinearFitterDebugOn() const { return fLinearFitterDebugOn; }
129 Int_t GetVersionGainUsed() const { return fVersionGainUsed; }
130 Int_t GetSubVersionGainUsed() const { return fSubVersionGainUsed; }
131 Int_t GetVersionVdriftUsed() const { return fVersionVdriftUsed; }
132 Int_t GetSubVersionVdriftUsed() const { return fSubVersionVdriftUsed; }
bcb6fb78 133
134
135 // Get stuff that are filled
136 TH2I *GetCH2d();
3a0f6479 137 TProfile2D *GetPH2d(Int_t nbtimebin=24, Float_t samplefrequency= 10.0);
170c35f1 138 TProfile2D *GetPRF2d() const { return fPRF2d; }
139 TObjArray GetLinearFitterArray() const { return fLinearFitterArray; }
140 TLinearFitter *GetLinearFitter(Int_t detector, Bool_t force=kFALSE);
a0bb5615 141 AliTRDCalibraVdriftLinearFit *GetVdriftLinearFit() const { return fLinearVdriftFit; }
142 AliTRDCalibraExbAltFit *GetExbAltFit() const { return fExbAltFit; }
3a0f6479 143
170c35f1 144
55a288e5 145 // How to fill the 2D
55a288e5 146 void SetRelativeScale(Float_t relativeScale);
55a288e5 147 void SetThresholdClusterPRF2(Float_t thresholdClusterPRF2) { fThresholdClusterPRF2 = thresholdClusterPRF2; }
b70c68da 148 void SetLimitChargeIntegration(Bool_t limitChargeIntegration) { fLimitChargeIntegration = limitChargeIntegration; }
37b0cf5e 149 void SetFillWithZero(Bool_t fillWithZero) { fFillWithZero = fillWithZero; }
64942b85 150 void SetNormalizeNbOfCluster(Bool_t normalizeNbOfCluster) { fNormalizeNbOfCluster = normalizeNbOfCluster; }
151 void SetMaxCluster(Float_t maxCluster) { fMaxCluster = maxCluster; }
152 void SetNbMaxCluster(Short_t nbMaxCluster) { fNbMaxCluster = nbMaxCluster; }
5f689709 153 void SetCutWithVdriftCalib(Bool_t cutWithVdriftCalib) { fCutWithVdriftCalib = cutWithVdriftCalib; }
154 void SetMinNbTRDtracklets(Int_t minNbTRDtracklets) { fMinNbTRDtracklets = minNbTRDtracklets; }
155 void SetMinTRDMomentum(Float_t minTRDMomentum) { fMinTRDMomentum = minTRDMomentum; }
170c35f1 156 void SetNz(Int_t i, Short_t nz);
55a288e5 157 void SetNrphi(Int_t i, Short_t nrphi);
64942b85 158 void SetAllTogether(Int_t i);
159 void SetPerSuperModule(Int_t i);
160 void SetProcent(Float_t procent) { fProcent = procent; }
55a288e5 161 void SetDifference(Short_t difference) { fDifference = difference; }
e526983e 162 void SetNumberClusters(Short_t numberClusters) { if(numberClusters >= 0) fNumberClusters = numberClusters; }
bcb6fb78 163 void SetNumberClustersf(Short_t numberClustersf) { fNumberClustersf = numberClustersf; }
6aafa7ea 164 void SetNumberClustersProcent(Float_t numberClustersProcent) { fNumberClustersProcent = numberClustersProcent; }
165 void SetThresholdClustersDAQ(Float_t thresholdClustersDAQ) { fThresholdClustersDAQ = thresholdClustersDAQ; }
166 void SetNumberRowDAQ(Short_t numberRowDAQ) { fNumberRowDAQ = numberRowDAQ; }
167 void SetNumberColDAQ(Short_t numberColDAQ) { fNumberColDAQ = numberColDAQ; }
4f3bd513 168 void SetRangeHistoCharge(Float_t rangeHistoCharge) { fRangeHistoCharge = rangeHistoCharge; }
1785640c 169 void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; }
55a288e5 170 void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; }
170c35f1 171 void SetNumberGroupsPRF(Short_t numberGroupsPRF);
55a288e5 172
173 Float_t GetRelativeScale() const { return fRelativeScale; }
55a288e5 174 Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; }
b70c68da 175 Bool_t GetLimitChargeIntegration() const { return fLimitChargeIntegration; }
37b0cf5e 176 Bool_t GetFillWithZero() const { return fFillWithZero; }
64942b85 177 Bool_t GetNormalizeNbOfCluster() const { return fNormalizeNbOfCluster; }
178 Float_t GetMaxCluster() const { return fMaxCluster; }
179 Short_t GetNbMaxCluster() const { return fNbMaxCluster; }
5f689709 180 Bool_t GetCutWithVdriftCalib() const { return fCutWithVdriftCalib; }
55a288e5 181 Float_t GetProcent() const { return fProcent; }
182 Short_t GetDifference() const { return fDifference; }
183 Short_t GetNumberClusters() const { return fNumberClusters; }
bcb6fb78 184 Short_t GetNumberClustersf() const { return fNumberClustersf; }
55a288e5 185 Short_t GetNumberBinCharge() const { return fNumberBinCharge; }
186 Short_t GetNumberBinPRF() const { return fNumberBinPRF; }
170c35f1 187 Short_t GetNumberGroupsPRF() const { return fNgroupprf; }
188 Int_t *GetEntriesLinearFitter() const { return fEntriesLinearFitter; }
55a288e5 189
170c35f1 190 // Debug
191 void SetDebugLevel(Short_t level) { fDebugLevel = level; }
192
193 // Vector method
55a288e5 194AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; }
e4db522f 195
55a288e5 196 protected:
197
f162af62 198 // Geometry
199 AliTRDgeometry *fGeo; //! The TRD geometry
01239968 200 // calibration DB
201 AliTRDcalibDB *fCalibDB; //! The pointer to the TRDcalibDB instance
f162af62 202
64942b85 203 // Is HLT
204 Bool_t fIsHLT; // Now if HLT, the per detector
205
55a288e5 206 // Choice to fill or not the 2D
e526983e 207 Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration
55a288e5 208 Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0
209 Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration
210 Bool_t fHisto2d; // Chose to fill the 2D histos
211 Bool_t fVector2d; // Chose to fill vectors
170c35f1 212 Bool_t fLinearFitterOn; // Method with linear fit for drift velocity
213 Bool_t fLinearFitterDebugOn; // Method with linear fit for drift velocity
532be2d4 214 Bool_t fExbAltFitOn; // Enable parabolic fit for exb
215 Bool_t fScaleWithTPCSignal; // Scale the gain with TPC signal (If use then ask at least 70 TPC clusters)
55a288e5 216
217 // How to fill the 2D
218 Float_t fRelativeScale; // Scale of the deposited charge
170c35f1 219 Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals
b70c68da 220 Bool_t fLimitChargeIntegration; // Integration range for the gain calibration
37b0cf5e 221 Bool_t fFillWithZero; // Fill with zero or not the average pulse height
64942b85 222 Bool_t fNormalizeNbOfCluster; // Normalize with the number of cluster for the gain
223 Float_t fMaxCluster; // Max amplitude of one cluster
224 Short_t fNbMaxCluster; // Number of tb at the end
5f689709 225 Bool_t fCutWithVdriftCalib; // CutWithVdriftCalib for the gain and PH
226 Int_t fMinNbTRDtracklets; // Min number of TRD tracklets
227 Float_t fMinTRDMomentum; // Min TRD momentum
4c865c34 228 // Back correction
bb14268f 229 Bool_t fTakeSnapshot; // Take from snapshot
d085ba91 230 Int_t fFirstRunGain; // FirstRunGain
4c865c34 231 Int_t fVersionGainUsed; // VersionGainUsed
232 Int_t fSubVersionGainUsed; // SubVersionGainUsed
d085ba91 233 Int_t fFirstRunGainLocal; // FirstRunGainLocal
a2a4ec8e 234 Int_t fVersionGainLocalUsed; // VersionGainUsed
235 Int_t fSubVersionGainLocalUsed;// SubVersionGainUsed
d085ba91 236 Int_t fFirstRunVdrift; // FirstRunVdrift
4c865c34 237 Int_t fVersionVdriftUsed; // VersionVdriftUsed
238 Int_t fSubVersionVdriftUsed; // SubVersionVdriftUsed
b2277aa2 239 Int_t fFirstRunExB; // FirstRunExB
240 Int_t fVersionExBUsed; // VersionExBUsed
241 Int_t fSubVersionExBUsed; // SubVersionExBUsed
170c35f1 242 // Calibration mode
55a288e5 243 AliTRDCalibraMode *fCalibraMode; // Calibration mode
244
170c35f1 245 //For debugging
246 TTreeSRedirector *fDebugStreamer; //!Debug streamer
247 Short_t fDebugLevel; // Flag for debugging
55a288e5 248 //
249 // Internal variables
250 //
251
252 // Fill the 2D histos in the offline tracking
170c35f1 253 Int_t fDetectorPreviousTrack; // Change of detector
e4db522f 254 Int_t fMCMPrevious; // Change of MCM
255 Int_t fROBPrevious; // Change of ROB
170c35f1 256 Short_t fNumberClusters; // Minimum number of clusters in the tracklets
bcb6fb78 257 Short_t fNumberClustersf; // Maximum number of clusters in the tracklets
6aafa7ea 258 Float_t fNumberClustersProcent; // Procent of number of time bins for fNumberClusters
259 Float_t fThresholdClustersDAQ; // Threshold clusters for DAQ algorithm
260 Short_t fNumberRowDAQ; // Size of the spot for DAQ algorithm
261 Short_t fNumberColDAQ; // Size of the spot for DAQ algorithm
55a288e5 262 Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
263 Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
264 Int_t fNumberTrack; // How many tracks could be used (Debug for the moment)
265 Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent)
266 Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference)
267 Int_t fTimeMax; // Number of time bins
268 Float_t fSf; // Sampling frequence
4f3bd513 269 Float_t fRangeHistoCharge; // Range of the histo for the charge
55a288e5 270 Short_t fNumberBinCharge; // Number of bins for the gain factor
271 Short_t fNumberBinPRF; // Number of bin for the PRF
170c35f1 272 Short_t fNgroupprf; // Number of groups in tnp bins for PRF /2.0
273
274 // Variables per tracklet
170c35f1 275 Float_t *fAmpTotal; // Energy deposited in the calibration group by the track
276 Short_t *fPHPlace; // Calibration group of PH
277 Float_t *fPHValue; // PH
278 Bool_t fGoodTracklet; // Good tracklet
1ca79a00 279 TLinearFitter *fLinearFitterTracklet; // linear fitter tracklet
bcb6fb78 280 //Statistics
170c35f1 281 Int_t *fEntriesCH; // Number of entries CH
282 Int_t *fEntriesLinearFitter; // Number of entries LinearFitter
283
55a288e5 284
285 //
286 // Vector method
287 //
d0569428 288
289 AliTRDCalibraVector *fCalibraVector; // The vector object
55a288e5 290
291
292 // Histograms to store the info from the digits, from the tracklets or from the tracks
d0569428 293 TProfile2D *fPH2d; // 2D average pulse height
294 TProfile2D *fPRF2d; // 2D PRF
295 TH2I *fCH2d; // 2D deposited charge
296 TObjArray fLinearFitterArray; // TObjArray of Linear Fitters for the detectors
297 AliTRDCalibraVdriftLinearFit *fLinearVdriftFit; // Info Linear Fit
a0bb5615 298 AliTRDCalibraExbAltFit *fExbAltFit; // ExB parabolic fit (alternative to vdrift linear fit)
d0569428 299
300 // Current calib object: to correct for the database used
301 AliTRDCalDet *fCalDetGain; // Current calib object gain
302 AliTRDCalROC *fCalROCGain; // Current calib object gain
bcb6fb78 303
55a288e5 304 //
305 // A lot of internal functions......
a2a4ec8e 306 // Init
307 Bool_t InitCalPad(Int_t detector);
55a288e5 308 //
55a288e5 309 // Create the 2D histo to be filled Online
310 void CreateCH2d(Int_t nn);
311 void CreatePH2d(Int_t nn);
3a0f6479 312 void CreatePRF2d(Int_t nn);
55a288e5 313
bcb6fb78 314 // Calibration with AliTRDtrackV1
55a288e5 315 void FillTheInfoOfTheTrackPH();
bcb6fb78 316 void FillTheInfoOfTheTrackCH(Int_t nbclusters);
bcb6fb78 317 Bool_t FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters);
bcb6fb78 318 Bool_t HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters);
319 void ResetfVariablestracklet();
5f689709 320 Float_t StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls=0x0);
170c35f1 321 void FillCH2d(Int_t x, Float_t y);
bcb6fb78 322
323 // Calibration on DAQ
324
325 Int_t FillDAQ(Double_t phvalue[16][144][36]);
bcb6fb78 326 Bool_t UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins);
00a3834d 327
328 // row col calibration groups stuff
55a288e5 329 Bool_t LocalisationDetectorXbins(Int_t detector);
170c35f1 330 Int_t CalculateTotalNumberOfBins(Int_t i);
6bbdc11a 331 void CheckGoodTrackletV0(const Int_t detector,const Int_t row,const Int_t col);
332 void CheckGoodTrackletV1(const AliTRDcluster *cl);
bcb6fb78 333 Int_t CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const;
170c35f1 334
55a288e5 335 // Clear
336 void ClearHistos();
337
338 // Some basic geometry function
053767a4 339 virtual Int_t GetLayer(Int_t d) const;
340 virtual Int_t GetStack(Int_t d) const;
55a288e5 341 virtual Int_t GetSector(Int_t d) const;
d0569428 342
bcb6fb78 343
55a288e5 344 // Instance of this class and so on
170c35f1 345 static AliTRDCalibraFillHisto *fgInstance; // Instance
346 static Bool_t fgTerminated; // If terminated
0c349049 347
0c349049 348 private:
349
350 // This is a singleton, contructor is private!
351 AliTRDCalibraFillHisto();
e4db522f 352 virtual ~AliTRDCalibraFillHisto();
55a288e5 353
bb14268f 354 ClassDef(AliTRDCalibraFillHisto,8) // TRD Calibration class
55a288e5 355
356};
357
358#endif
a2a4ec8e 359
068b874f 360