integrated times correction implemented during reconstruction in AliTOFReconstructor...
[u/mrichter/AliRoot.git] / TOF / AliTOFcalib.h
CommitLineData
6dc9348d 1#ifndef ALITOFCALIB_H
2#define ALITOFCALIB_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// class for TOF calibration:: simulation of uncalibrated data //
9//////////////////////////////////////////////////////////////////
10
0a749fa5 11#define CHENTRIESSMALL 300 // number of entries per TOF channel per run
12 // (to be divided by 3 to get the
13 // real number of entries), smallarray
14#define MAXCHENTRIESSMALL 10000 // max number of entries per TOF channel
15 // (to be divided by 3 to get the
16 // real number of entries), smallarray
17
18#define NIDXSMALL 3 // number of values stored
19 // after Comb PID per ESD track
20#define DELTAIDXTOT 0 // index for ToT in bigarray
21#define DELTAIDXTIME 1 // index for TOF time in big/smallarray
22#define DELTAIDXPID 2 // index for Exp Time after Comb PID
23 // in smallarray
24#define MEANENTRIES 15 // Mean number of entries per channel
25 // to perform calibration
26
6dc9348d 27#include "TTask.h"
0e46b9ae 28
29class TArrayF;
30class TF1;
31class TH1F;
32class TObjArray;
0a749fa5 33class TTree;
296591ad 34class TChain;
17149e6b 35class TMap;
0e46b9ae 36
5c7c93fa 37//class AliESD;
0e46b9ae 38
39class AliTOFCal;
7037bd93 40class AliTOFRecoParam;
17149e6b 41class AliTOFChannelOnlineStatusArray;
42class AliTOFChannelOnlineArray;
2bf4d9d6 43class AliTOFDeltaBCOffset;
44class AliTOFCTPLatency;
45class AliTOFT0Fill;
f04b3a69 46class AliTOFRunParams;
5b4ed716 47class AliTOFResponseParams;
48class AliESDEvent;
6dc9348d 49
50class AliTOFcalib:public TTask{
51public:
52 AliTOFcalib(); // ctor
7aeeaf38 53 AliTOFcalib(const AliTOFcalib & calib); // copy constructor
54 AliTOFcalib& operator=(const AliTOFcalib & calib); // assignment operator
6dc9348d 55 virtual ~AliTOFcalib() ; // dtor
0a749fa5 56 void CreateCalArrays();
24d1e16e 57 void CreateCalObjects();
0a749fa5 58 TObjArray * GetTOFCalArrayOnline() const {return fTOFCalOnline;}
17149e6b 59 AliTOFChannelOnlineArray * GetTOFOnlineDelay() const {return fCal;}
60 AliTOFChannelOnlineStatusArray * GetTOFOnlineStatus() const {return fStatus;}
7fffa85b 61 TObjArray * GetTOFCalArrayOnlinePulser() const {return fTOFCalOnlinePulser;}
62 TObjArray * GetTOFCalArrayOnlineNoise() const {return fTOFCalOnlineNoise;}
63 TObjArray * GetTOFCalArrayOnlineHW() const {return fTOFCalOnlineHW;}
0a749fa5 64 TObjArray * GetTOFCalArrayOffline() const {return fTOFCalOffline;}
17149e6b 65 TMap * GetConfigMap() const {return fConfigMap;}
d4ad0d6b 66 TH1F * GetTOFSimToT() const {return fTOFSimToT;}
0a749fa5 67 TTree * GetTOFCalibTree() const {return fTree;}
296591ad 68 TChain * GetTOFCalibChain() const {return fChain;}
0a749fa5 69 const char * GetOfflineValidity() const {return fkValidity;}
70 void SetOfflineValidity(const char* validity) {fkValidity = validity;}
d4ad0d6b 71 Int_t NChannels()const{return fNChannels;}
17149e6b 72
2bf4d9d6 73 void CreateDeltaBCOffset();
74 void CreateCTPLatency();
75 void CreateT0Fill();
f04b3a69 76 void CreateRunParams();
2bf4d9d6 77 AliTOFDeltaBCOffset *GetDeltaBCOffset() const {return fDeltaBCOffset;};
78 AliTOFCTPLatency *GetCTPLatency() const {return fCTPLatency;};
79 AliTOFT0Fill *GetT0Fill() const {return fT0Fill;};
f04b3a69 80 AliTOFRunParams *GetRunParams() const {return fRunParams;};
5b4ed716 81 AliTOFResponseParams *GetResponseParams() const {return fResponseParams;};
2bf4d9d6 82
d4ad0d6b 83 // Methods to retrieve/write parameters from/on CDB
17149e6b 84 // writing
85
a6e0ebfe 86 void WriteSimHistoOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TH1F *histo);
87 void WriteConfigMapOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
88 void WriteConfigMapOnCDB(const Char_t *sel);
17149e6b 89 // new calib objs
a6e0ebfe 90 void WriteParOnlineDelayOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
91 void WriteParOnlineStatusOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
92 void WriteParOnlineDelayOnCDB(const Char_t *sel);
93 void WriteParOnlineStatusOnCDB(const Char_t *sel);
17149e6b 94 // old calib objs
a6e0ebfe 95 void WriteParOnlineOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
96 void WriteParOnlinePulserOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
97 void WriteParOnlineNoiseOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
98 void WriteParOnlineHWOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
99 void WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun);
100 void WriteParOnlineOnCDB(const Char_t *sel);
101 void WriteParOnlinePulserOnCDB(const Char_t *sel); // old, before unification of status info
102 void WriteParOnlineNoiseOnCDB(const Char_t *sel); // old, before unification of status info
103 void WriteParOnlineHWOnCDB(const Char_t *sel); // old, before unification of status info
104 void WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity);
17149e6b 105
2bf4d9d6 106 void WriteDeltaBCOffsetOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
107 void WriteCTPLatencyOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
108 void WriteT0FillOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
f04b3a69 109 void WriteRunParamsOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
2bf4d9d6 110
17149e6b 111 // reading
a6e0ebfe 112 Bool_t ReadSimHistoFromCDB(const Char_t *sel, Int_t nrun);
113 Bool_t ReadConfigMapFromCDB(const Char_t *sel, Int_t nrun);
17149e6b 114 // new objs
a6e0ebfe 115 Bool_t ReadParOnlineDelayFromCDB(const Char_t *sel, Int_t nrun);
116 Bool_t ReadParOnlineStatusFromCDB(const Char_t *sel, Int_t nrun);
17149e6b 117 // old objs
a6e0ebfe 118 Bool_t ReadParOnlineFromCDB(const Char_t *sel, Int_t nrun);
119 Bool_t ReadParOnlinePulserFromCDB(const Char_t *sel, Int_t nrun); // old, before unification of status info
120 Bool_t ReadParOnlineNoiseFromCDB(const Char_t *sel, Int_t nrun); // old, before unification of status info
121 Bool_t ReadParOnlineHWFromCDB(const Char_t *sel, Int_t nrun); // old, before unification of status info
122 Bool_t ReadParOfflineFromCDB(const Char_t *sel, Int_t nrun);
123 void WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param);
f858b00e 124 void WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TObjArray *arr);
d6888ae2 125 AliTOFRecoParam * ReadRecParFromCDB(const Char_t *sel, Int_t nrun, Int_t eventType=0);
0a749fa5 126 void CreateTreeFromCDB(Int_t minrun, Int_t maxrun);
127 void CreateTreeFromFile(Int_t minrun, Int_t maxrun);
128 void CreateTreeFromGrid(Int_t minrun, Int_t maxrun);
296591ad 129 void CreateChainFromGrid(Int_t minrun, Int_t maxrun);
0a749fa5 130 Int_t Calibrate(Option_t *optionSave="", Option_t *optionFit="RQ");
131 Int_t Calibrate(Int_t nch,Int_t *ich, Option_t *optionSave="", Option_t *optionFit="RQ");
132 Int_t Calibrate(Int_t ichmin, Int_t ichmax, Option_t *optionSave="", Option_t *optionFit="RQ");
133 Int_t Calibrate(Int_t ich, Option_t *optionSave="", Option_t *optionFit="RQ");
134 Int_t CalibrateFromProfile(Int_t ich, Option_t *optionSave="", Option_t *optionFit="RQ");
135 TH1F* Profile(Int_t i);
136 Int_t FindBins (TH1F* h, Double_t *bins) const;
137 void SetNruns(Int_t nruns) {fNruns=nruns;}
138 Int_t GetNruns() const {return fNruns;}
0cb9d099 139 void SetFirstRun(Int_t firstRun) {fFirstRun=firstRun;}
140 Int_t GetFirstRun() const {return fFirstRun;}
141 void SetLastRun(Int_t lastRun) {fLastRun=lastRun;}
142 Int_t GetLastRun() const {return fLastRun;}
6dc9348d 143
2bf4d9d6 144 Bool_t ReadDeltaBCOffsetFromCDB(const Char_t *sel, Int_t nrun);
145 Bool_t ReadCTPLatencyFromCDB(const Char_t *sel, Int_t nrun);
146 Bool_t ReadT0FillFromCDB(const Char_t *sel, Int_t nrun);
f04b3a69 147 Bool_t ReadRunParamsFromCDB(const Char_t *sel, Int_t nrun);
2bf4d9d6 148
5b4ed716 149 Bool_t Init(Int_t run = -1); // init
150 Double_t GetTimeCorrection(Int_t index, Double_t tot, Int_t deltaBC, Int_t l0l1, UInt_t timestamp); // get time correction
151 void CalibrateESD(AliESDEvent *event); // calibrate ESD
c2fb5b09 152 void CalibrateTExp(AliESDEvent *event) const; // calibrate TExp
5b4ed716 153 void SetRemoveMeanT0(Bool_t value) {fRemoveMeanT0 = value;}; // setter
8bb89c94 154 void SetCalibrateTOFsignal(Bool_t value) {fCalibrateTOFsignal = value;}; // setter
5b4ed716 155 void SetCorrectTExp(Bool_t value) {fCorrectTExp = value;}; // setter
156 Bool_t IsChannelEnabled(Int_t index); // is channel enabled
157
6dc9348d 158private:
d4ad0d6b 159 Int_t fNChannels; // number of TOF channels
17149e6b 160
161 // old calibration objects
0a749fa5 162 TObjArray *fTOFCalOnline; // array of AliTOFChannels storing calib parameters
17149e6b 163 TObjArray *fTOFCalOnlinePulser; // array of AliTOFChannels storing calib status from pulser // old, before unification of status info
164 TObjArray *fTOFCalOnlineNoise; // array of AliTOFChannels storing calib status from noise // old, before unification of status info
165 TObjArray *fTOFCalOnlineHW; // array of AliTOFChannels storing calib status from hardware // old, before unification of status info
0a749fa5 166 TObjArray *fTOFCalOffline; // array of AliTOFChannels storing calib parameters
17149e6b 167
168 // new calibration objects
169 AliTOFChannelOnlineArray *fCal; // object with delay array for TOF channels
170 AliTOFChannelOnlineStatusArray *fStatus; // object with status array for TOF channels
171
d4ad0d6b 172 TH1F *fTOFSimToT; // histo with realistic ToT signal from TB Data
0a749fa5 173 const char *fkValidity; // validity for offline calibration object
174 TTree *fTree; // tree for TOF calibration
296591ad 175 TChain *fChain; // chain for TOF calibration
0a749fa5 176 Int_t fNruns; // number of runs to be processed
0cb9d099 177 Int_t fFirstRun; // first run for calibration obj validity
178 Int_t fLastRun; // last run for calib obj validity
17149e6b 179 TMap* fConfigMap; // map holding configuration obj
0cb9d099 180
2bf4d9d6 181 AliTOFDeltaBCOffset *fDeltaBCOffset; // deltaBC offset
182 AliTOFCTPLatency *fCTPLatency; // CTP latency
183 AliTOFT0Fill *fT0Fill; // T0 fill
f04b3a69 184 AliTOFRunParams *fRunParams; // run params
5b4ed716 185 AliTOFResponseParams *fResponseParams; // run params
186
187 Bool_t fInitFlag; // init flag
188 Bool_t fRemoveMeanT0; // remove mean T0
8bb89c94 189 Bool_t fCalibrateTOFsignal; // calibrate TOF signal
5b4ed716 190 Bool_t fCorrectTExp; // correct expected time
2bf4d9d6 191
5b4ed716 192 ClassDef(AliTOFcalib,10);
6dc9348d 193};
194
195#endif // AliTOFcalib_H
196