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