]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDPreprocessorOffline.h
- add missing forward declaration of AliESDtrack
[u/mrichter/AliRoot.git] / TRD / AliTRDPreprocessorOffline.h
1 #ifndef ALITRDPREPROCESSOROFFLINE_H
2 #define ALITRDPREPROCESSOROFFLINE_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 //
8 //
9 //    Class to create OCDB entries - processing the results of the OFFLINE calibration
10 //
11
12
13 #include "TNamed.h"
14 #include "AliTRDCalChamberStatus.h"
15 #include <THnSparse.h>
16 class TObjArray;
17 class AliTRDCalDet;
18 class TH2I;
19 class TProfile2D;
20 class AliTRDCalibraVdriftLinearFit;
21 class AliTRDCalibraExbAltFit;
22 class TH1I;
23 class TH2F;
24 class TString;
25 class AliCDBStorage;
26
27 class AliTRDPreprocessorOffline:public TNamed { 
28 public:
29   enum{ kGain = 0,
30         kVdriftPHDet = 1,
31         kVdriftPHPad = 2,
32         kT0PHDet = 3,
33         kT0PHPad = 4,
34         kVdriftLinear = 5,
35         kLorentzLinear = 6,
36         kChamberStatus = 7,
37         kPRF = 8,
38         kExbAlt = 9,
39         kPHQ = 10,
40         kNumCalibObjs = 11
41   };
42   enum { kGainNotEnoughStatsButFill = 2,
43          kVdriftNotEnoughStatsButFill = 4,
44          kGainNotEnoughStatsNotFill = 8,
45          kVdriftNotEnoughStatsNotFill = 16,
46          kTimeOffsetNotEnoughStatsNotFill = 32,
47          kExBErrorRange = 64};  
48   enum { kGainErrorOld = 2,
49          kVdriftErrorOld = 4,
50          kExBErrorOld = 8,
51          kGainErrorRange = 16,
52          kVdriftErrorRange = 32,
53          kTimeOffsetErrorRange = 64,
54          kChamberStatusErrorRange = 128};  
55
56
57   AliTRDPreprocessorOffline();
58   virtual ~AliTRDPreprocessorOffline();
59
60   Bool_t Init(const Char_t* fileName);
61   void Process(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* ocdbStorage);
62
63   // settings
64   void SetLinearFitForVdrift(Bool_t methodsecond) { fMethodSecond = methodsecond;};
65   void SetNameList(TString nameList) { fNameList = nameList;};
66   void     SetMinStatsVdriftT0PH(Int_t minStatsVdriftT0PH)           { fMinStatsVdriftT0PH = minStatsVdriftT0PH; }  
67   void     SetMinStatsVdriftLinear(Int_t minStatsVdriftLinear)       { fMinStatsVdriftLinear = minStatsVdriftLinear; }  
68   void     SetMinStatsGain(Int_t minStatsGain)                       { fMinStatsGain = minStatsGain; }  
69   void     SetMinStatsPRF(Int_t minStatsPRF)                         { fMinStatsPRF = minStatsPRF; }  
70   void     SetMinStatsChamberStatus(Int_t minStatsChamberStatus)     { fMinStatsChamberStatus = minStatsChamberStatus; }
71   void     SetSingleMinStatsChamberStatus(Int_t minSingleStatsChamberStatus) { fMinSingleStatsChamberStatus = minSingleStatsChamberStatus; }
72   void     SetLimitValidateNoData(Int_t nodatavalidate)              { fNoDataValidate = nodatavalidate; };
73   void     SetLimitValidateBadCalib(Int_t badcalibvalidate)          { fBadCalibValidate = badcalibvalidate; };
74   void     SetBackCorrectGain(Bool_t backCorrectGain)                { fBackCorrectGain = backCorrectGain; }
75   void     SetBackCorrectVdrift(Bool_t backCorrectVdrift)            { fBackCorrectVdrift = backCorrectVdrift; }
76   void     SetNoExBUsedInReco(Bool_t noExBUsedInReco)                { fNoExBUsedInReco    = noExBUsedInReco;   };
77   void     SetSwitchOnValidation(Bool_t switchOnValidation)          { fSwitchOnValidation = switchOnValidation;};
78   void     SetRMSBadCalibratedGain(Double_t rms)                     { fRMSBadCalibratedGain = rms;};
79   void     SetRMSBadCalibratedVdrift(Double_t rms)                   { fRMSBadCalibratedVdrift = rms;};
80   void     SetRMSBadCalibratedExB(Double_t rms)                      { fRMSBadCalibratedExB = rms;};
81   void     SetMinTimeOffsetValidate(Double_t min)                    { fMinTimeOffsetValidate = min;};
82   void     SetRobustFitDriftVelocity(Bool_t robustFitDriftVelocity)  { fRobustFitDriftVelocity = robustFitDriftVelocity;};
83   void     SetRobustFitExbAlt(Bool_t robustFitExbAlt)                { fRobustFitExbAlt = robustFitExbAlt;};
84   void     SetAlternativeDriftVelocityFit(Bool_t alt)                { fAlternativeVdrfitFit = alt;};
85   void     SetMinNbOfPointVdriftFit(Int_t minNbOfPointVdriftFit)     { fMinNbOfPointVdriftFit = minNbOfPointVdriftFit;};
86   void     SetAlternativeExbAltFit(Bool_t alt)                       { fAlternativeExbAltFit = alt;};
87   void     SetMethodeFitGain(Int_t methodeFitGain)                   { fMethodeGain = methodeFitGain;};
88   void     SetOutliersFitChargeLow(Float_t outliersFitChargeLow)     { fOutliersFitChargeLow = outliersFitChargeLow; }
89   void     SetOutliersFitChargeHigh(Float_t outliersFitChargeHigh)   { fOutliersFitChargeHigh = outliersFitChargeHigh; }
90   void     SetBeginFitCharge(Float_t beginFitCharge)                 { fBeginFitCharge = beginFitCharge;};
91   void     SetT0Shift0(Float_t t0Shift0)                             { fT0Shift0 = t0Shift0;};
92   void     SetT0Shift1(Float_t t0Shift1)                             { fT0Shift1 = t0Shift1;};
93
94
95
96   Bool_t GetLinearFitForVdrift() const { return fMethodSecond;};
97   TString GetNameList() const { return fNameList;}; 
98
99   // status
100   Bool_t      CheckStatus(Int_t status, Int_t bitMask) const;
101   void PrintStatus() const;
102
103   Bool_t      IsGainNotEnoughStatsButFill() const 
104     { return CheckStatus(fStatusNeg, kGainNotEnoughStatsButFill);  };
105   Bool_t      IsGainNotEnoughStatsNotFill() const 
106     { return CheckStatus(fStatusNeg, kGainNotEnoughStatsNotFill);  };
107   Bool_t      IsVdriftNotEnoughStatsButFill() const 
108     { return CheckStatus(fStatusNeg, kVdriftNotEnoughStatsButFill);  };
109   Bool_t      IsVdriftNotEnoughStatsNotFill() const 
110     { return CheckStatus(fStatusNeg, kVdriftNotEnoughStatsNotFill);  };
111   Bool_t      IsTimeOffsetNotEnoughStatsNotFill() const 
112     { return CheckStatus(fStatusNeg, kTimeOffsetNotEnoughStatsNotFill);  };
113   Bool_t      IsExBErrorRange() const 
114     { return CheckStatus(fStatusNeg, kExBErrorRange);  };
115   
116   Bool_t      IsGainErrorOld() const 
117     { return CheckStatus(fStatusPos, kGainErrorOld);  };
118   Bool_t      IsVdriftErrorOld() const 
119     { return CheckStatus(fStatusPos, kVdriftErrorOld);  };
120   Bool_t      IsExBErrorOld() const 
121     { return CheckStatus(fStatusPos, kExBErrorOld);  };
122   Bool_t      IsGainErrorRange() const 
123     { return CheckStatus(fStatusPos, kGainErrorRange);  };
124   Bool_t      IsVdriftErrorRange() const 
125     { return CheckStatus(fStatusPos, kVdriftErrorRange);  };
126   Bool_t      IsTimeOffsetErrorRange() const 
127     { return CheckStatus(fStatusPos, kTimeOffsetErrorRange);  };
128   Bool_t      IsChamberStatusErrorRange() const 
129     { return CheckStatus(fStatusPos, kChamberStatusErrorRange);  };
130   
131
132   // Back corrections
133   void SetCalDetGain(AliTRDCalDet *calDetGainUsed) {fCalDetGainUsed = calDetGainUsed;};
134   void SetCalDetVdrift(AliTRDCalDet *calDetVdriftUsed);
135   void SetCalDetVdriftExB(AliTRDCalDet *calDetVdriftUsed,AliTRDCalDet *calDetExBUsed) {fCalDetVdriftUsed = calDetVdriftUsed; fCalDetExBUsed = calDetExBUsed;};
136   Bool_t SetCalDetGain(Int_t runNumber, Int_t version, Int_t subversion);
137   Bool_t SetCalDetVdriftExB(Int_t runNumber, Int_t versionv, Int_t subversionv, Int_t versionexb, Int_t subversionexb);
138   
139   AliTRDCalDet *GetCalDetGain() const { return fCalDetGainUsed;};
140   AliTRDCalDet *GetCalDetVdrift() const { return fCalDetVdriftUsed;};
141   Int_t    GetFirstRunGainUsed() const                               { return fFirstRunGainUsed;       }
142   Int_t    GetVersionGainUsed() const                                { return fVersionGainUsed;        }
143   Int_t    GetSubVersionGainUsed() const                             { return fSubVersionGainUsed;     }
144   Int_t    GetFirstRunVdriftUsed() const                             { return fFirstRunVdriftUsed;     }
145   Int_t    GetVersionVdriftUsed() const                              { return fVersionVdriftUsed;      }
146   Int_t    GetSubVersionVdriftUsed() const                           { return fSubVersionVdriftUsed;   }
147   Int_t    GetFirstRunExBUsed() const                                { return fFirstRunExBUsed;        }
148   Int_t    GetVersionExBUsed() const                                 { return fVersionExBUsed;         }
149   Int_t    GetSubVersionExBUsed() const                              { return fSubVersionExBUsed;      }
150
151
152   // Internal functions
153
154   void CalibVdriftT0(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* ocdbStorage=0x0);
155   void CalibExbAlt(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* ocdbStorage=0x0);
156   void CalibGain(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber,  AliCDBStorage* ocdbStorage=0x0);
157   void CalibPRF(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber,  AliCDBStorage* ocdbStorage=0x0);
158   void CalibChamberStatus(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* ocdbStorage=0x0);
159   void CalibPHQ(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* ocdbStorage);
160
161   Bool_t ReadStatusGlobal(const Char_t* fileName="CalibObjects.root");
162   Bool_t ReadGainGlobal(const Char_t* fileName="CalibObjects.root");
163   Bool_t ReadVdriftT0Global(const Char_t* fileName="CalibObjects.root");
164   Bool_t ReadVdriftLinearFitGlobal(const Char_t* fileName="CalibObjects.root");
165   Bool_t ReadExbAltFitGlobal(const Char_t* fileName="CalibObjects.root");
166   Bool_t ReadPRFGlobal(const Char_t* fileName="CalibObjects.root");
167   Bool_t ReadPHQGlobal(const Char_t* fileName);
168
169   Bool_t AnalyzeGain(); 
170   Bool_t AnalyzeVdriftT0(); 
171   Bool_t AnalyzeVdriftLinearFit(); 
172   Bool_t AnalyzeExbAltFit();
173   Bool_t AnalyzePRF();
174   Bool_t AnalyzeChamberStatus(); 
175   Bool_t AnalyzePHQ(Int_t startRunNumber);
176
177   void CorrectFromDetGainUsed();
178   void CorrectFromDetVdriftUsed();
179   
180   void UpdateOCDBT0(Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* storage);
181   void UpdateOCDBVdrift(Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* storage);
182   void UpdateOCDBExB(Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* storage);
183   void UpdateOCDBExBAlt(Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* storage);
184   void UpdateOCDBGain(Int_t  startRunNumber, Int_t endRunNumber, AliCDBStorage* storage);
185   void UpdateOCDBPRF(Int_t  startRunNumber, Int_t endRunNumber, AliCDBStorage* storage);
186   void UpdateOCDBChamberStatus(Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* storage);
187   void UpdateOCDBPHQ(Int_t startRunNumber, Int_t endRunNumber, AliCDBStorage* storage);
188
189   Bool_t ValidateGain();
190   Bool_t ValidateVdrift();
191   Bool_t ValidateExB();
192   Bool_t ValidateT0();
193   Bool_t ValidatePRF() const;
194   Bool_t ValidateChamberStatus();
195
196   Int_t    GetStatus() const;
197   Int_t    GetStatusPos() const                                      { return fStatusPos;              }
198   Int_t    GetStatusNeg() const                                      { return fStatusNeg;              }
199  
200   Bool_t IsPHQon() const { return fPHQon ;};
201   void SetPHQon(const Bool_t kphq){ fPHQon = kphq; }
202
203   Bool_t IsDebugPHQon() const { return fDebugPHQon ;};
204   void SetDebugPHQon(const Bool_t kphq){ fDebugPHQon = kphq; }
205
206  private:
207   Bool_t fMethodSecond;                      // Second Method for drift velocity   
208   TString fNameList;                         // Name of the list
209   AliTRDCalDet *fCalDetGainUsed;             // CalDet used and to be corrected for
210   AliTRDCalDet *fCalDetVdriftUsed;           // CalDet used and to be corrected for
211   AliTRDCalDet *fCalDetExBUsed;              // CalDet used and to be corrected for
212   TH2I *fCH2d;                               // Gain
213   TProfile2D *fPH2d;                         // Drift velocity first method
214   TProfile2D *fPRF2d;                        // PRF
215   THnSparseI *fSparse;                       // chamberstatus
216   AliTRDCalibraVdriftLinearFit *fAliTRDCalibraVdriftLinearFit; // Drift velocity second method
217   AliTRDCalibraExbAltFit* fAliTRDCalibraExbAltFit; //ExB alternative method
218   TH1I *fNEvents;                         // Number of events 
219   TH2F *fAbsoluteGain;                    // Absolute Gain calibration
220   TObjArray * fPlots;                     // array with some plots to check
221   TObjArray * fCalibObjects;              // array with calibration objects 
222   Int_t    fFirstRunGainUsed;             // first run gain used 
223   Int_t    fVersionGainUsed;              // VersionGainUsed 
224   Int_t    fSubVersionGainUsed;           // SubVersionGainUsed
225   Int_t    fFirstRunVdriftUsed;           // FirstRunVdrift 
226   Int_t    fVersionVdriftUsed;            // VersionVdriftUsed 
227   Int_t    fSubVersionVdriftUsed;         // SubVersionVdriftUsed
228   Int_t    fFirstRunExBUsed;              // FirstRunExB 
229   Int_t    fVersionExBUsed;               // VersionExBUsed 
230   Int_t    fSubVersionExBUsed;            // SubVersionExBUsed
231   Bool_t   fNoExBUsedInReco;              // ExB not used yet in the reco
232   Bool_t   fSwitchOnValidation;           // Validation
233   Bool_t   fVdriftValidated;              // Vdrift validation
234   Bool_t   fExBValidated;                 // ExB validation
235   Bool_t   fT0Validated;                  // T0 validation
236   Int_t    fMinStatsVdriftT0PH;           // MinStats VdriftT0
237   Int_t    fMinStatsVdriftLinear;         // MinStats Vdrift Linear
238   Int_t    fMinStatsGain;                 // MinStats Gain
239   Int_t    fMinStatsPRF;                  // MinStats PRF
240   Int_t    fMinStatsChamberStatus;        // MinStats ChamberStatus
241   Double_t fMinSingleStatsChamberStatus;  // MinStats per chamber in % of mean (ChamberStatus)
242   Bool_t   fBackCorrectGain;              // Back correction afterwards gain  
243   Bool_t   fBackCorrectVdrift;            // Back correction afterwards vdrift
244   Bool_t   fNotEnoughStatisticsForTheGain;// Take the chamber per chamber distribution from the default distribution
245   Bool_t   fNotEnoughStatisticsForTheVdriftLinear;// Take the chamber per chamber distribution from the default distribution
246   Int_t    fStatusNeg;                    // Info but ok
247   Int_t    fStatusPos;                    // Problems
248   Int_t    fBadCalib[18];                 // number of bad calibrated chambers per sm
249   Int_t    fNoData[18];                   // number of  chambers w/o data per sm
250   Int_t    fBadCalibValidate;             // validation limit for bad calibrated chambers
251   Int_t    fNoDataValidate;               // validation limit for chamber w/o data (sm w/o data excluded)
252   Double_t fRMSBadCalibratedGain;         // value to decide when it is bad calibrated 
253   Double_t fRMSBadCalibratedVdrift;       // value to decide when it is bad calibrated 
254   Double_t fRMSBadCalibratedExB;          // value to decide when it is bad calibrated 
255   Double_t fMinTimeOffsetValidate;        // For validation of timeoffset min value  
256   Bool_t   fRobustFitDriftVelocity;       // Robust fit for the drift velocity
257   Bool_t   fRobustFitExbAlt;              // Robust fit for the exb alt 
258   Bool_t   fAlternativeVdrfitFit;         // Alternative fitting method for vdrift calibration
259   Bool_t   fAlternativeExbAltFit;         // Alternative fitting method for the alternative exb calibarion method
260   Int_t    fMinNbOfPointVdriftFit;        // Min number of points for the drift velocity calibration
261   Int_t    fMethodeGain;                  // Methode Gain Fit
262   Float_t  fOutliersFitChargeLow;         // The fit starts at fOutliersFitChargeLow procent number of entries
263   Float_t  fOutliersFitChargeHigh;        // The fit starts at fOutliersFitChargeHigh procent number of entries
264   Float_t  fBeginFitCharge;               // Fit Begin Charge starts at mean/fBeginFitCharge
265   Float_t  fT0Shift0;                    // T0 Shift with the maximum positive slope
266   Float_t  fT0Shift1;                    // T0 Shift with the maximum of the amplification region
267
268   Int_t GetSubVersion(TString name) const;
269   Int_t GetVersion(TString name) const;
270   Int_t GetFirstRun(TString name) const;
271
272   
273
274 private:
275   AliTRDPreprocessorOffline& operator=(const AliTRDPreprocessorOffline&); // not implemented
276   AliTRDPreprocessorOffline(const AliTRDPreprocessorOffline&); // not implemented
277
278   Bool_t fPHQon;                 //switch of PHQ
279   Bool_t fDebugPHQon;                 //switch of DebugPHQ
280
281   ClassDef(AliTRDPreprocessorOffline,4)
282 };
283
284 #endif
285
286