]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFcalibHisto.h
Update of the online calibration scheme for on-the-fly time correction (usually used...
[u/mrichter/AliRoot.git] / TOF / AliTOFcalibHisto.h
1 #ifndef ALITOFCALIBHISTO_H
2 #define ALITOFCALIBHISTO_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  * AliTOFcalibHisto - class to handle TOF calibration histograms,
10  *                    map histograms and more
11  *
12  *
13  * autors:   Roberto Preghenella (R+)
14  * concacts: preghenella@bo.infn.it
15  *
16  *************************************************************************/
17
18 #include "TObject.h"
19 #include "TString.h"
20
21 class TH1D;
22 class TFile;
23 class AliESDtrack;
24
25 class AliTOFcalibHisto :
26 public TObject
27 {
28
29  public:
30
31   enum ECorrection_t {
32     kDDLBCcorr,
33     kAmphenolCableCorr,
34     kFlatCableCorr,
35     kInterfaceCardCorr,
36     kDDLdelayCorr,
37     kHPTDCdelayCorr,
38     kFEAchDelayCorr,
39     kFEAdelayCorr,
40     kTRMdelayCorr,
41     kICdelayCorr,
42     kStripDelayCorr,
43     kIndexDelayCorr,
44     kTimeSlewingCorr,
45     kNcorrections
46   };
47   
48   enum ECalibConst_t {
49     kLHCperiod,
50     kAmphenolCableDelay,
51     kFlatCableDelay,
52     kInterfaceCardDelay,
53     kNcalibConsts
54   };
55
56   enum ECalibMap_t {
57     /* main index */
58     kIndex,
59     /* EO indices */
60     kDDL, 
61     kTRM, 
62     kChain, 
63     kTDC, 
64     kChannel, 
65     /* DO indices */
66     kSector, 
67     kPlate, 
68     kStrip, 
69     kSectorStrip, 
70     kPadZ, 
71     kPadX, 
72     kPad,
73     kInterfaceCardIndex,
74     /* calib constants */
75     kDDLBCshift,
76     kFlatCableLength,
77     kInterfaceCardLength,
78     kAmphenolCableLength,
79     /* number of histos */
80     kNcalibMaps
81   };
82
83   enum ECalibPar_t {
84     kDDLdelayPar,
85     kHPTDCdelayPar,
86     kLeftFEAchDelayPar,
87     kRightFEAchDelayPar,
88     kFEAdelayPar,
89     kICdelayPar,
90     kTRMdelayPar,
91     kStripDelayPar,
92     kIndexDelayPar,
93     kTimeSlewingPar,
94     kNcalibPars
95   };
96
97  private:
98
99   static TFile *fgCalibHistoFile; /* calib histo file */
100   static TFile *fgCalibParFile; /* calib par file */
101
102   static TString fgCalibHistoFileName; /* calib histo file name */
103   static TString fgCalibParFileName; /* calib par file name */
104   static const TString fgkCalibConstName[kNcalibConsts]; // calib const name array */
105   static const TString fgkCalibMapName[kNcalibMaps]; // calib map name array */
106   static const TString fgkCalibParName[kNcalibPars]; // calib par name array */
107
108   static const Double_t fgkLHCperiod; /* LHC clock period */
109   static const Double_t fgkAmphenolCableDelay; /* Amphenol cable delay */
110   static const Double_t fgkFlatCableDelay; /* flat cable delay */
111   static const Double_t fgkInterfaceCardDelay; /* interface card delay */
112
113   static const Int_t fgkNchannels; /* number of readout channels (DO) */
114   static const Int_t fgkNchannelsEO; /* number of readout channels (EO) */
115   static const Int_t fgkDDLBCshift[72]; /* DDL BC shifts due to TTC fibers */
116   static const Double_t fgkFlatCableLength[91]; /* strip flat-cable length */
117   static const Double_t fgkInterfaceCardLength[48]; /* interface card length */
118
119   static Bool_t fgCableCorrectionFlag[kNcorrections]; // cable correction flag
120   static Bool_t fgFullCorrectionFlag[kNcorrections]; // full correction flag
121
122   TH1D *fCalibConst[kNcalibConsts]; // calib const array
123   TH1D *fCalibMap[kNcalibMaps]; // calib map array
124   TH1D *fCalibPar[kNcalibPars]; // calib par array
125
126   /* methods */
127   void LoadHisto(TFile *file, TH1D **histo, const Char_t *name); /* create histo */
128   void CreateHisto(TH1D **histo, const Char_t *name, Int_t size); /* create histo */
129   void WriteHisto(TFile *file, TH1D *histo); /* write histo */
130   void SetHisto(TH1D *histo, Int_t index, Double_t value); /* set histo */
131   Double_t GetHisto(TH1D *histo, Int_t index); /* get histo */
132   
133   AliTOFcalibHisto(const AliTOFcalibHisto &source) : TObject(source) {}; /* copy constructor */
134   AliTOFcalibHisto &operator=(const AliTOFcalibHisto &) {return *this;}; /* operator= */
135
136  public:
137
138   AliTOFcalibHisto(); /* default constructor */
139   virtual ~AliTOFcalibHisto(); /* default destructor */
140
141   /* getters */
142   static const Char_t *GetCalibHistoFileName() {return fgCalibHistoFileName.Data();}; /* get calib histo file name */
143   static const Char_t *GetCalibParFileName() {return fgCalibParFileName.Data();}; /* get calib par file name */
144
145   /* setters */
146   static void SetCalibHistoFileName(const Char_t *value) {fgCalibHistoFileName = value;}; /* set calib histo file name */
147   static void SetCalibParFileName(const Char_t *value) {fgCalibParFileName = value;}; /* set calib par file name */
148   static void SetCableCorrectionFlag(Int_t i, Bool_t flag) {if (i < kNcorrections) fgCableCorrectionFlag[i] = flag;}; // set cable correction flag
149   static void SetFullCorrectionFlag(Int_t i, Bool_t flag) {if (i < kNcorrections) fgFullCorrectionFlag[i] = flag;}; // set full correction flag
150
151   /* methods */
152   static Int_t GetIndexEO(Int_t ddl, Int_t trm, Int_t chain, Int_t tdc, Int_t channel) {return (channel + 8 * tdc + 120 * chain + 240 * trm + 2400 * ddl);}; /* get index EO */
153   void LoadCalibHisto(); /* load calib histo */
154   void LoadCalibPar(); /* load calib par */
155   void WriteCalibHisto(); /* write calib histo */
156   Double_t GetCalibConst(Int_t histo) {return GetHisto(fCalibConst[histo], 0);}; /* get calib const */
157   Double_t GetCalibMap(Int_t histo, Int_t index) {return GetHisto(fCalibMap[histo], index);}; /* get calib map */
158   Double_t GetCalibPar(Int_t histo, Int_t index) {return GetHisto(fCalibPar[histo], index);}; /* get calib par */
159   Double_t GetCorrection(Int_t corr, Int_t index, Double_t tot = 0.); /* get correction */
160   Double_t GetNominalCorrection(Int_t index); /* get nominal correction */
161   void ApplyNominalCorrection(AliESDtrack *track); /* apply nominal corrections */
162
163   Double_t GetCableCorrection(Int_t index); /* get cable correction */
164   Double_t GetFullCorrection(Int_t index, Double_t tot = 0.); /* get full correction */
165   
166   ClassDef(AliTOFcalibHisto, 1);
167   
168 };
169
170 #endif /* ALITOFCALIBHISTO_H */