New DAQ calibration DAs by Raphaelle
[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           SetPRFRange(Float_t prfrange)                 { fPRFRange        = prfrange;                   }  
60   void           SetVectorPH(TObjArray *vectorPH)              { fVectorPH        = vectorPH;                   }
61   void           SetPlaPH(TObjArray *plaPH)                    { fPlaPH           = plaPH;                      }
62   void           SetVectorCH(TObjArray *vectorCH)              { fVectorCH        = vectorCH;                   }
63   void           SetPlaCH(TObjArray *plaCH)                    { fPlaCH           = plaCH;                      }
64   void           SetVectorPRF(TObjArray *vectorPRF)            { fVectorPRF       = vectorPRF;                  }
65   void           SetPlaPRF(TObjArray *plaPRF)                  { fPlaPRF          = plaPRF;                     }
66
67   Short_t        GetNumberBinCharge()const                     { return fNumberBinCharge;                       }
68   Short_t        GetNumberBinPRF()const                        { return fNumberBinPRF;                          }
69   Int_t          GetTimeMax()const                             { return fTimeMax;                               } 
70   Float_t        GetPRFRange()const                            { return fPRFRange;                              } 
71   TObjArray*     GetVectorPH()const                            { return fVectorPH;                              } 
72   TObjArray*     GetPlaPH()const                               { return fPlaPH;                                 } 
73   TObjArray*     GetVectorCH()const                            { return fVectorCH;                              } 
74   TObjArray*     GetPlaCH()const                               { return fPlaCH;                                 } 
75   TObjArray*     GetVectorPRF()const                           { return fVectorPRF;                             } 
76   TObjArray*     GetPlaPRF()const                              { return fPlaPRF;                                } 
77  
78  protected:
79
80  // Objects for storing the infos per calibration group
81           
82           class AliTRDPlace : public TObject {
83
84           public: 
85     
86             AliTRDPlace()
87               :TObject()
88               ,fPlace(0x0)                                     { }
89             AliTRDPlace(const AliTRDPlace &i)
90               :TObject(i)
91               ,fPlace(0x0)                                     { }
92             AliTRDPlace &operator=(const AliTRDPlace&)         { return *this;            } 
93             virtual ~AliTRDPlace()                             { }
94             
95             void      SetPlace(Int_t place)                    { fPlace = place;          }
96             Int_t     GetPlace() const                         { return  fPlace;          }
97             
98           protected:
99             
100             Int_t     fPlace;                       // Place of the calibration group
101             
102           };
103           
104           class AliTRDCTInfo : public TObject {
105             
106           public: 
107             
108             AliTRDCTInfo()
109               :TObject()
110               ,fEntries(0x0)                                   { }
111             AliTRDCTInfo(const AliTRDCTInfo &i)
112               :TObject(i)
113               ,fEntries(0x0)                                   { }
114             AliTRDCTInfo &operator=(const AliTRDCTInfo&)       { return *this;            } 
115             virtual ~AliTRDCTInfo()                            { }
116             
117             void      SetEntries(UShort_t *entries)            { fEntries = entries;      }
118             
119             UShort_t *GetEntries() const                       { return fEntries;         }
120             
121           protected:
122             
123             UShort_t *fEntries;                     // Current number of entries for each bin of CH
124             
125           };
126           
127           
128           class AliTRDPInfo : public TObject {
129           public:
130             
131             AliTRDPInfo()
132               :TObject()
133               ,fSum(0x0) 
134               ,fSumSquare(0x0)
135               ,fEntries(0x0)                                   { }
136             AliTRDPInfo(const AliTRDPInfo &i)
137               :TObject(i)
138               ,fSum(0x0) 
139               ,fSumSquare(0x0)
140               ,fEntries(0x0)                                   { } 
141             AliTRDPInfo &operator=(const AliTRDPInfo&)         { return *this;            }
142             virtual ~AliTRDPInfo()                             { }
143             
144             void      SetSum(Float_t *sum)                     { fSum       = sum;        }
145             void      SetSumSquare(Float_t *sumSquare)         { fSumSquare = sumSquare;  }
146             void      SetEntries(UShort_t *entries)            { fEntries   = entries;    }
147             
148             Float_t  *GetSum() const                           { return fSum;             }
149             Float_t  *GetSumSquare() const                     { return fSumSquare;       }
150             UShort_t *GetEntries() const                       { return fEntries;         }
151             
152           protected:
153             
154             Float_t  *fSum;                         // Current mean for each bin of the average pulse height
155             Float_t  *fSumSquare;                   // Current mean of square values for each bin of the average pulse height
156             UShort_t *fEntries;                     // Current number of entries for each bin of the average pulse height
157             
158           };
159
160   // Arrays of these objects 
161           
162           TObjArray       *fVectorPH;               // Vectors to fill
163           TObjArray       *fPlaPH;                  // Vectors to fill
164           
165           TObjArray       *fVectorCH;               // Vectors to fill
166           TObjArray       *fPlaCH;                  // Vectors to fill
167           
168           TObjArray       *fVectorPRF;              // Vectors to fill
169           TObjArray       *fPlaPRF;                 // Vectors to fill
170
171   // Size of the infos
172
173           Short_t          fNumberBinCharge;        // Number of bins for the gain factor
174           Short_t          fNumberBinPRF;           // Number of bin for the PRF
175           Int_t            fTimeMax;                // Number of time bins
176           Float_t          fPRFRange;               // Range PRF
177
178   // Some functions
179
180           TGraphErrors  *ConvertVectorPHistoI(AliTRDPInfo *pInfo, const Char_t *name) const;
181           TH1F          *ConvertVectorCTHistoI(AliTRDCTInfo *cTInfo, const Char_t *name) const;
182
183   ClassDef(AliTRDCalibraVector,1)                   // TRD Calibration class
184
185 };
186   
187 #endif
188
189