Replace AliTRDCalibra
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraVector.h
1 #ifndef ALITRDCALIBRAVECTOR_H
2 #define ALITRDCALIBRAVECTOR_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////////////////
9 //                                                                           //
10 //  TRD calibration class                                                    //
11 //                                                                           //
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #ifndef ROOT_TObject
15 #  include <TObject.h>
16 #endif
17
18 class TGraphErrors;
19 class TH1F;
20 class TTree;
21 class TObjArray;
22
23 class AliTRDCalibraVector : public TObject {
24
25  public: 
26
27   AliTRDCalibraVector();
28   AliTRDCalibraVector(const AliTRDCalibraVector &c);
29   virtual ~AliTRDCalibraVector();
30   AliTRDCalibraVector &operator=(const AliTRDCalibraVector &) { return *this; }
31
32   Int_t          SearchBin(Float_t value, Int_t i) const;  
33   Int_t          SearchInVector(Int_t group, Int_t i) const;
34   Int_t          SearchInTreeVector (TObjArray *vectorplace, Int_t group) const;
35   Bool_t         UpdateVectorCH(Int_t group, Float_t value);
36   Bool_t         UpdateVectorPRF(Int_t group, Float_t x, Float_t y);
37   Bool_t         UpdateVectorPH(Int_t group, Int_t time, Float_t value);
38   TH1F          *ConvertVectorCTHisto(Int_t place, const Char_t *name) const;
39   TTree         *ConvertVectorCTTreeHisto(TObjArray *vVectorCT, TObjArray *pPlaCT
40                                         , const Char_t *name, const Char_t *nametitle) const;
41   TGraphErrors  *ConvertVectorPHisto(Int_t place, const Char_t *name) const;
42   TTree         *ConvertVectorPTreeHisto(TObjArray *vVectorP, TObjArray *pPlaP
43                                        , const Char_t *name, const Char_t *nametitle) const;
44   TObjArray     *ConvertTreeVector(TTree *tree) const ;
45   Bool_t         MergeVectorCT(TObjArray *vVectorCT2, TObjArray *pPlaCT2);
46   Bool_t         MergeVectorP(TObjArray *vVectorP2, TObjArray *pPlaP2, Int_t i);
47   //Add two trees
48   TTree         *Sum2Trees(const Char_t *filename1, const Char_t *filename2, const Char_t *variablecali);
49   //Correct the errors
50   TGraphErrors  *AddProfiles(TGraphErrors *hist1, TGraphErrors *hist2) const ;
51
52   //
53   // Set and Get methods
54   //
55
56   void           SetNumberBinCharge(Short_t numberbincharge)   { fNumberBinCharge = numberbincharge;            } 
57   void           SetNumberBinPRF(Short_t numberbinprf)         { fNumberBinPRF    = numberbinprf;               } 
58   void           SetTimeMax(Int_t timemax)                     { fTimeMax         = timemax;                    }  
59   void           SetVectorPH(TObjArray *vectorPH)              { fVectorPH        = vectorPH;                   }
60   void           SetPlaPH(TObjArray *plaPH)                    { fPlaPH           = plaPH;                      }
61   void           SetVectorCH(TObjArray *vectorCH)              { fVectorCH        = vectorCH;                   }
62   void           SetPlaCH(TObjArray *plaCH)                    { fPlaCH           = plaCH;                      }
63   void           SetVectorPRF(TObjArray *vectorPRF)            { fVectorPRF       = vectorPRF;                  }
64   void           SetPlaPRF(TObjArray *plaPRF)                  { fPlaPRF          = plaPRF;                     }
65
66   Short_t        GetNumberBinCharge()const                     { return fNumberBinCharge;                       }
67   Short_t        GetNumberBinPRF()const                        { return fNumberBinPRF;                          }
68   Int_t          GetTimeMax()const                             { return fTimeMax;                               } 
69   TObjArray*     GetVectorPH()const                            { return fVectorPH;                              } 
70   TObjArray*     GetPlaPH()const                               { return fPlaPH;                                 } 
71   TObjArray*     GetVectorCH()const                            { return fVectorCH;                              } 
72   TObjArray*     GetPlaCH()const                               { return fPlaCH;                                 } 
73   TObjArray*     GetVectorPRF()const                           { return fVectorPRF;                             } 
74   TObjArray*     GetPlaPRF()const                              { return fPlaPRF;                                } 
75  
76  protected:
77
78  // Objects for storing the infos per calibration group
79           
80           class AliTRDPlace : public TObject {
81
82           public: 
83     
84             AliTRDPlace()
85               :TObject()
86               ,fPlace(0x0)                                     { }
87             AliTRDPlace(const AliTRDPlace &i)
88               :TObject(i)
89               ,fPlace(0x0)                                     { }
90             AliTRDPlace &operator=(const AliTRDPlace&)         { return *this;            } 
91             virtual ~AliTRDPlace()                             { }
92             
93             void      SetPlace(Int_t place)                    { fPlace = place;          }
94             Int_t     GetPlace() const                         { return  fPlace;          }
95             
96           protected:
97             
98             Int_t     fPlace;                       // Place of the calibration group
99             
100           };
101           
102           class AliTRDCTInfo : public TObject {
103             
104           public: 
105             
106             AliTRDCTInfo()
107               :TObject()
108               ,fEntries(0x0)                                   { }
109             AliTRDCTInfo(const AliTRDCTInfo &i)
110               :TObject(i)
111               ,fEntries(0x0)                                   { }
112             AliTRDCTInfo &operator=(const AliTRDCTInfo&)       { return *this;            } 
113             virtual ~AliTRDCTInfo()                            { }
114             
115             void      SetEntries(UShort_t *entries)            { fEntries = entries;      }
116             
117             UShort_t *GetEntries() const                       { return fEntries;         }
118             
119           protected:
120             
121             UShort_t *fEntries;                     // Current number of entries for each bin of CH
122             
123           };
124           
125           
126           class AliTRDPInfo : public TObject {
127           public:
128             
129             AliTRDPInfo()
130               :TObject()
131               ,fSum(0x0) 
132               ,fSumSquare(0x0)
133               ,fEntries(0x0)                                   { }
134             AliTRDPInfo(const AliTRDPInfo &i)
135               :TObject(i)
136               ,fSum(0x0) 
137               ,fSumSquare(0x0)
138               ,fEntries(0x0)                                   { } 
139             AliTRDPInfo &operator=(const AliTRDPInfo&)         { return *this;            }
140             virtual ~AliTRDPInfo()                             { }
141             
142             void      SetSum(Float_t *sum)                     { fSum       = sum;        }
143             void      SetSumSquare(Float_t *sumSquare)         { fSumSquare = sumSquare;  }
144             void      SetEntries(UShort_t *entries)            { fEntries   = entries;    }
145             
146             Float_t  *GetSum() const                           { return fSum;             }
147             Float_t  *GetSumSquare() const                     { return fSumSquare;       }
148             UShort_t *GetEntries() const                       { return fEntries;         }
149             
150           protected:
151             
152             Float_t  *fSum;                         // Current mean for each bin of the average pulse height
153             Float_t  *fSumSquare;                   // Current mean of square values for each bin of the average pulse height
154             UShort_t *fEntries;                     // Current number of entries for each bin of the average pulse height
155             
156           };
157
158   // Arrays of these objects 
159           
160           TObjArray       *fVectorPH;               // Vectors to fill
161           TObjArray       *fPlaPH;                  // Vectors to fill
162           
163           TObjArray       *fVectorCH;               // Vectors to fill
164           TObjArray       *fPlaCH;                  // Vectors to fill
165           
166           TObjArray       *fVectorPRF;              // Vectors to fill
167           TObjArray       *fPlaPRF;                 // Vectors to fill
168
169   // Size of the infos
170
171           Short_t          fNumberBinCharge;        // Number of bins for the gain factor
172           Short_t          fNumberBinPRF;           // Number of bin for the PRF
173           Int_t            fTimeMax;                // Number of time bins
174
175   // Some functions
176
177           TGraphErrors  *ConvertVectorPHistoI(AliTRDPInfo *pInfo, const Char_t *name) const;
178           TH1F          *ConvertVectorCTHistoI(AliTRDCTInfo *cTInfo, const Char_t *name) const;
179
180   ClassDef(AliTRDCalibraVector,1)                   // TRD Calibration class
181
182 };
183   
184 #endif
185
186