]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFcalibHisto.h
Implemented lookup tables between LTM signals and volume IDs and viceversa (A.Silenzi)
[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   enum ECalibStat_t {
98     kStripStat,
99     kNcalibStats
100   };
101
102  private:
103
104   static TFile *fgCalibHistoFile; /* calib histo file */
105   static TFile *fgCalibParFile; /* calib par file */
106   static TFile *fgCalibStatFile; /* calib stat file */
107
108   static TString fgCalibHistoFileName; /* calib histo file name */
109   static TString fgCalibParFileName; /* calib par file name */
110   static TString fgCalibStatFileName; /* calib par file name */
111   static const TString fgkCalibConstName[kNcalibConsts]; // calib const name array */
112   static const TString fgkCalibMapName[kNcalibMaps]; // calib map name array */
113   static const TString fgkCalibParName[kNcalibPars]; // calib par name array */
114   static const TString fgkCalibStatName[kNcalibStats]; // calib stat name array */
115
116   static const Double_t fgkLHCperiod; /* LHC clock period */
117   static const Double_t fgkAmphenolCableDelay; /* Amphenol cable delay */
118   static const Double_t fgkFlatCableDelay; /* flat cable delay */
119   static const Double_t fgkInterfaceCardDelay; /* interface card delay */
120
121   static const Int_t fgkNchannels; /* number of readout channels (DO) */
122   static const Int_t fgkNchannelsEO; /* number of readout channels (EO) */
123   static const Int_t fgkDDLBCshift[72]; /* DDL BC shifts due to TTC fibers */
124   static const Double_t fgkFlatCableLength[91]; /* strip flat-cable length */
125   static const Double_t fgkInterfaceCardLength[48]; /* interface card length */
126
127   static Bool_t fgCableCorrectionFlag[kNcorrections]; // cable correction flag
128   static Bool_t fgFullCorrectionFlag[kNcorrections]; // full correction flag
129
130   static const Int_t fgkStripStat[18][91]; // strip status
131
132   TH1D *fCalibConst[kNcalibConsts]; // calib const array
133   TH1D *fCalibMap[kNcalibMaps]; // calib map array
134   TH1D *fCalibPar[kNcalibPars]; // calib par array
135   TH1D *fCalibStat[kNcalibStats]; // calib stat array
136
137   /* methods */
138   void LoadHisto(TFile *file, TH1D **histo, const Char_t *name); /* create histo */
139   void CreateHisto(TH1D **histo, const Char_t *name, Int_t size); /* create histo */
140   void WriteHisto(TFile *file, TH1D *histo); /* write histo */
141   void SetHisto(TH1D *histo, Int_t index, Double_t value); /* set histo */
142   Double_t GetHisto(TH1D *histo, Int_t index); /* get histo */
143   
144   AliTOFcalibHisto(const AliTOFcalibHisto &source) : TObject(source) {}; /* copy constructor */
145   AliTOFcalibHisto &operator=(const AliTOFcalibHisto &) {return *this;}; /* operator= */
146
147  public:
148
149   AliTOFcalibHisto(); /* default constructor */
150   virtual ~AliTOFcalibHisto(); /* default destructor */
151
152   /* getters */
153   static const Char_t *GetCalibHistoFileName() {return fgCalibHistoFileName.Data();}; /* get calib histo file name */
154   static const Char_t *GetCalibParFileName() {return fgCalibParFileName.Data();}; /* get calib par file name */
155   static const Char_t *GetCalibStatFileName() {return fgCalibStatFileName.Data();}; /* get calib stat file name */
156
157   /* setters */
158   static void SetCalibHistoFileName(const Char_t *value) {fgCalibHistoFileName = value;}; /* set calib histo file name */
159   static void SetCalibParFileName(const Char_t *value) {fgCalibParFileName = value;}; /* set calib par file name */
160   static void SetCalibStatFileName(const Char_t *value) {fgCalibStatFileName = value;}; /* set calib stat file name */
161   static void SetCableCorrectionFlag(Int_t i, Bool_t flag) {if (i < kNcorrections) fgCableCorrectionFlag[i] = flag;}; // set cable correction flag
162   static void SetFullCorrectionFlag(Int_t i, Bool_t flag) {if (i < kNcorrections) fgFullCorrectionFlag[i] = flag;}; // set full correction flag
163
164   /* methods */
165   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 */
166   void LoadCalibHisto(); /* load calib histo */
167   void LoadCalibPar(); /* load calib par */
168   void LoadCalibStat(); /* load calib stat */
169   void WriteCalibHisto(); /* write calib histo */
170   void WriteCalibStat(); /* write calib stat */
171   Double_t GetCalibConst(Int_t histo) {return GetHisto(fCalibConst[histo], 0);}; /* get calib const */
172   Double_t GetCalibMap(Int_t histo, Int_t index) {return GetHisto(fCalibMap[histo], index);}; /* get calib map */
173   Double_t GetCalibPar(Int_t histo, Int_t index) {return GetHisto(fCalibPar[histo], index);}; /* get calib par */
174   Bool_t GetCalibStat(Int_t histo, Int_t index) {return GetHisto(fCalibStat[histo], index) != 0. ? kTRUE : kFALSE;}; /* get calib stat */
175   Double_t GetCorrection(Int_t corr, Int_t index, Double_t tot = 0.); /* get correction */
176   Double_t GetNominalCorrection(Int_t index); /* get nominal correction */
177   void ApplyNominalCorrection(AliESDtrack *track); /* apply nominal corrections */
178
179   Double_t GetCableCorrection(Int_t index); /* get cable correction */
180   Double_t GetFullCorrection(Int_t index, Double_t tot = 0.); /* get full correction */
181
182   Bool_t GetStatus(Int_t index); /* get status */
183   
184   ClassDef(AliTOFcalibHisto, 1);
185   
186 };
187
188 #endif /* ALITOFCALIBHISTO_H */