- adjusting binning of pad histograms to make single pad cluster contribution and...
[u/mrichter/AliRoot.git] / TRD / AliTRDPreprocessorOffline.h
CommitLineData
b3fcfd96 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"
81a5aeca 14#include "AliTRDCalChamberStatus.h"
83d0cc79 15#include <THnSparse.h>
b3fcfd96 16class TObjArray;
01239968 17class AliTRDCalDet;
b3fcfd96 18class TH2I;
19class TProfile2D;
20class AliTRDCalibraVdriftLinearFit;
21class TH1I;
22class TH2F;
01239968 23class TString;
b3fcfd96 24
25
26class AliTRDPreprocessorOffline:public TNamed {
27public:
28 enum{
29 kGain = 0,
30 kVdriftPHDet = 1,
31 kVdriftPHPad = 2,
32 kT0PHDet = 3,
33 kT0PHPad = 4,
34 kVdriftLinear = 5,
35 kLorentzLinear = 6,
a5dcf618 36 kChamberStatus = 7,
37 kPRF = 8
b3fcfd96 38 };
840ec79d 39 enum { kGainNotEnoughStatsButFill = 2,
40 kVdriftNotEnoughStatsButFill = 4,
41 kGainNotEnoughStatsNotFill = 8,
42 kVdriftNotEnoughStatsNotFill = 16,
43 kTimeOffsetNotEnoughStatsNotFill = 32,
44 kExBErrorRange = 64};
45 enum { kGainErrorOld = 2,
46 kVdriftErrorOld = 4,
47 kExBErrorOld = 8,
48 kGainErrorRange = 16,
49 kVdriftErrorRange = 32,
50 kTimeOffsetErrorRange = 64,
51 kChamberStatusErrorRange = 128};
82b413fd 52
53
b3fcfd96 54 AliTRDPreprocessorOffline();
55 virtual ~AliTRDPreprocessorOffline();
56
83d0cc79 57 Bool_t Init(const Char_t* fileName);
58 void Process(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage);
59
60 // settings
61 void SetLinearFitForVdrift(Bool_t methodsecond) { fMethodSecond = methodsecond;};
62 void SetNameList(TString nameList) { fNameList = nameList;};
63 void SetMinStatsVdriftT0PH(Int_t minStatsVdriftT0PH) { fMinStatsVdriftT0PH = minStatsVdriftT0PH; }
64 void SetMinStatsVdriftLinear(Int_t minStatsVdriftLinear) { fMinStatsVdriftLinear = minStatsVdriftLinear; }
65 void SetMinStatsGain(Int_t minStatsGain) { fMinStatsGain = minStatsGain; }
66 void SetMinStatsPRF(Int_t minStatsPRF) { fMinStatsPRF = minStatsPRF; }
67 void SetMinStatsChamberStatus(Int_t minStatsChamberStatus) { fMinStatsChamberStatus = minStatsChamberStatus; }
68 void SetLimitValidateNoData(Int_t nodatavalidate) { fNoDataValidate = nodatavalidate; };
69 void SetLimitValidateBadCalib(Int_t badcalibvalidate) { fBadCalibValidate = badcalibvalidate; };
70 void SetBackCorrectGain(Bool_t backCorrectGain) { fBackCorrectGain = backCorrectGain; }
71 void SetBackCorrectVdrift(Bool_t backCorrectVdrift) { fBackCorrectVdrift = backCorrectVdrift; }
72 void SetNoExBUsedInReco(Bool_t noExBUsedInReco) { fNoExBUsedInReco = noExBUsedInReco; };
73 void SetSwitchOnValidation(Bool_t switchOnValidation) { fSwitchOnValidation = switchOnValidation;};
74 void SetRMSBadCalibratedGain(Double_t rms) { fRMSBadCalibratedGain = rms;};
75 void SetRMSBadCalibratedVdrift(Double_t rms) { fRMSBadCalibratedVdrift = rms;};
76 void SetRMSBadCalibratedExB(Double_t rms) { fRMSBadCalibratedExB = rms;};
77
78 Bool_t GetLinearFitForVdrift() const { return fMethodSecond;};
79 TString GetNameList() const { return fNameList;};
80
81 // status
82 Bool_t CheckStatus(Int_t status, Int_t bitMask) const;
83 void PrintStatus() const;
84
82b413fd 85 Bool_t IsGainNotEnoughStatsButFill() const
86 { return CheckStatus(fStatusNeg, kGainNotEnoughStatsButFill); };
87 Bool_t IsGainNotEnoughStatsNotFill() const
88 { return CheckStatus(fStatusNeg, kGainNotEnoughStatsNotFill); };
89 Bool_t IsVdriftNotEnoughStatsButFill() const
90 { return CheckStatus(fStatusNeg, kVdriftNotEnoughStatsButFill); };
91 Bool_t IsVdriftNotEnoughStatsNotFill() const
92 { return CheckStatus(fStatusNeg, kVdriftNotEnoughStatsNotFill); };
93 Bool_t IsTimeOffsetNotEnoughStatsNotFill() const
840ec79d 94 { return CheckStatus(fStatusNeg, kTimeOffsetNotEnoughStatsNotFill); };
95 Bool_t IsExBErrorRange() const
96 { return CheckStatus(fStatusNeg, kExBErrorRange); };
82b413fd 97
98 Bool_t IsGainErrorOld() const
99 { return CheckStatus(fStatusPos, kGainErrorOld); };
100 Bool_t IsVdriftErrorOld() const
101 { return CheckStatus(fStatusPos, kVdriftErrorOld); };
840ec79d 102 Bool_t IsExBErrorOld() const
103 { return CheckStatus(fStatusPos, kExBErrorOld); };
82b413fd 104 Bool_t IsGainErrorRange() const
105 { return CheckStatus(fStatusPos, kGainErrorRange); };
106 Bool_t IsVdriftErrorRange() const
107 { return CheckStatus(fStatusPos, kVdriftErrorRange); };
108 Bool_t IsTimeOffsetErrorRange() const
109 { return CheckStatus(fStatusPos, kTimeOffsetErrorRange); };
110 Bool_t IsChamberStatusErrorRange() const
111 { return CheckStatus(fStatusPos, kChamberStatusErrorRange); };
112
82b413fd 113
83d0cc79 114 // Back corrections
01239968 115 void SetCalDetGain(AliTRDCalDet *calDetGainUsed) {fCalDetGainUsed = calDetGainUsed;};
840ec79d 116 void SetCalDetVdrift(AliTRDCalDet *calDetVdriftUsed);
117 void SetCalDetVdriftExB(AliTRDCalDet *calDetVdriftUsed,AliTRDCalDet *calDetExBUsed) {fCalDetVdriftUsed = calDetVdriftUsed; fCalDetExBUsed = calDetExBUsed;};
83d0cc79 118 Bool_t SetCalDetGain(Int_t runNumber, Int_t version, Int_t subversion);
119 Bool_t SetCalDetVdriftExB(Int_t runNumber, Int_t versionv, Int_t subversionv, Int_t versionexb, Int_t subversionexb);
120
01239968 121 AliTRDCalDet *GetCalDetGain() const { return fCalDetGainUsed;};
4c865c34 122 AliTRDCalDet *GetCalDetVdrift() const { return fCalDetVdriftUsed;};
83d0cc79 123 Int_t GetFirstRunGainUsed() const { return fFirstRunGainUsed; }
124 Int_t GetVersionGainUsed() const { return fVersionGainUsed; }
125 Int_t GetSubVersionGainUsed() const { return fSubVersionGainUsed; }
126 Int_t GetFirstRunVdriftUsed() const { return fFirstRunVdriftUsed; }
127 Int_t GetVersionVdriftUsed() const { return fVersionVdriftUsed; }
128 Int_t GetSubVersionVdriftUsed() const { return fSubVersionVdriftUsed; }
129 Int_t GetFirstRunExBUsed() const { return fFirstRunExBUsed; }
130 Int_t GetVersionExBUsed() const { return fVersionExBUsed; }
131 Int_t GetSubVersionExBUsed() const { return fSubVersionExBUsed; }
132
133
134 // Internal functions
b3fcfd96 135
136 void CalibVdriftT0(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage="");
137 void CalibGain(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage="");
138 void CalibPRF(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage="");
83d0cc79 139 void CalibChamberStatus(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage="");
81a5aeca 140
83d0cc79 141 Bool_t ReadStatusGlobal(const Char_t* fileName="CalibObjects.root");
b3fcfd96 142 Bool_t ReadGainGlobal(const Char_t* fileName="CalibObjects.root");
143 Bool_t ReadVdriftT0Global(const Char_t* fileName="CalibObjects.root");
144 Bool_t ReadVdriftLinearFitGlobal(const Char_t* fileName="CalibObjects.root");
145 Bool_t ReadPRFGlobal(const Char_t* fileName="CalibObjects.root");
146
147 Bool_t AnalyzeGain();
148 Bool_t AnalyzeVdriftT0();
149 Bool_t AnalyzeVdriftLinearFit();
a5dcf618 150 Bool_t AnalyzePRF();
151 Bool_t AnalyzeChamberStatus();
b3fcfd96 152
01239968 153 void CorrectFromDetGainUsed();
4c865c34 154 void CorrectFromDetVdriftUsed();
a5dcf618 155
b3fcfd96 156 void UpdateOCDBT0(Int_t startRunNumber, Int_t endRunNumber, const char* storagePath);
157 void UpdateOCDBVdrift(Int_t startRunNumber, Int_t endRunNumber, const char* storagePath);
eec29d56 158 void UpdateOCDBExB(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath);
b3fcfd96 159 void UpdateOCDBGain(Int_t startRunNumber, Int_t endRunNumber, const char* storagePath);
160 void UpdateOCDBPRF(Int_t startRunNumber, Int_t endRunNumber, const char* storagePath);
a5dcf618 161 void UpdateOCDBChamberStatus(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath);
b3fcfd96 162
54f2ff1c 163 Bool_t ValidateGain();
00d203b6 164 Bool_t ValidateVdrift();
840ec79d 165 Bool_t ValidateExB();
00d203b6 166 Bool_t ValidateT0();
167 Bool_t ValidatePRF() const;
82b413fd 168 Bool_t ValidateChamberStatus();
00d203b6 169
82b413fd 170 Int_t GetStatus() const;
171 Int_t GetStatusPos() const { return fStatusPos; }
172 Int_t GetStatusNeg() const { return fStatusNeg; }
a5dcf618 173
83d0cc79 174
4c865c34 175
176 private:
81a5aeca 177 Bool_t fMethodSecond; // Second Method for drift velocity
178 TString fNameList; // Name of the list
179 AliTRDCalDet *fCalDetGainUsed; // CalDet used and to be corrected for
180 AliTRDCalDet *fCalDetVdriftUsed; // CalDet used and to be corrected for
840ec79d 181 AliTRDCalDet *fCalDetExBUsed; // CalDet used and to be corrected for
81a5aeca 182 TH2I *fCH2d; // Gain
183 TProfile2D *fPH2d; // Drift velocity first method
184 TProfile2D *fPRF2d; // PRF
83d0cc79 185 THnSparseI *fSparse; // chamberstatus
b3fcfd96 186 AliTRDCalibraVdriftLinearFit *fAliTRDCalibraVdriftLinearFit; // Drift velocity second method
187 TH1I *fNEvents; // Number of events
188 TH2F *fAbsoluteGain; // Absolute Gain calibration
189 TObjArray * fPlots; // array with some plots to check
190 TObjArray * fCalibObjects; // array with calibration objects
83d0cc79 191 Int_t fFirstRunGainUsed; // first run gain used
4c865c34 192 Int_t fVersionGainUsed; // VersionGainUsed
193 Int_t fSubVersionGainUsed; // SubVersionGainUsed
ca7e6e64 194 Int_t fFirstRunVdriftUsed; // FirstRunVdrift
4c865c34 195 Int_t fVersionVdriftUsed; // VersionVdriftUsed
196 Int_t fSubVersionVdriftUsed; // SubVersionVdriftUsed
83d0cc79 197 Int_t fFirstRunExBUsed; // FirstRunExB
198 Int_t fVersionExBUsed; // VersionExBUsed
199 Int_t fSubVersionExBUsed; // SubVersionExBUsed
200 Bool_t fNoExBUsedInReco; // ExB not used yet in the reco
00d203b6 201 Bool_t fSwitchOnValidation; // Validation
202 Bool_t fVdriftValidated; // Vdrift validation
840ec79d 203 Bool_t fExBValidated; // ExB validation
00d203b6 204 Bool_t fT0Validated; // T0 validation
a2a4ec8e 205 Int_t fMinStatsVdriftT0PH; // MinStats VdriftT0
206 Int_t fMinStatsVdriftLinear; // MinStats Vdrift Linear
207 Int_t fMinStatsGain; // MinStats Gain
208 Int_t fMinStatsPRF; // MinStats PRF
83d0cc79 209 Int_t fMinStatsChamberStatus; // MinStats ChamberStatus
54f2ff1c 210 Bool_t fBackCorrectGain; // Back correction afterwards gain
211 Bool_t fBackCorrectVdrift; // Back correction afterwards vdrift
212 Bool_t fNotEnoughStatisticsForTheGain;// Take the chamber per chamber distribution from the default distribution
213 Bool_t fNotEnoughStatisticsForTheVdriftLinear;// Take the chamber per chamber distribution from the default distribution
82b413fd 214 Int_t fStatusNeg; // Info but ok
215 Int_t fStatusPos; // Problems
83d0cc79 216 Int_t fBadCalib[18]; // number of bad calibrated chambers per sm
217 Int_t fNoData[18]; // number of chambers w/o data per sm
218 Int_t fBadCalibValidate; // validation limit for bad calibrated chambers
219 Int_t fNoDataValidate; // validation limit for chamber w/o data (sm w/o data excluded)
220 Double_t fRMSBadCalibratedGain; // value to decide when it is bad calibrated
221 Double_t fRMSBadCalibratedVdrift; // value to decide when it is bad calibrated
222 Double_t fRMSBadCalibratedExB; // value to decide when it is bad calibrated
b3fcfd96 223
4c865c34 224 Int_t GetSubVersion(TString name) const;
225 Int_t GetVersion(TString name) const;
ca7e6e64 226 Int_t GetFirstRun(TString name) const;
b3fcfd96 227
228
229
230private:
231 AliTRDPreprocessorOffline& operator=(const AliTRDPreprocessorOffline&); // not implemented
232 AliTRDPreprocessorOffline(const AliTRDPreprocessorOffline&); // not implemented
54f2ff1c 233 ClassDef(AliTRDPreprocessorOffline,2)
b3fcfd96 234};
235
236#endif
01239968 237
a5dcf618 238