]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCCalibCE.h
Bug fix
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibCE.h
1 #ifndef ALITPCCALIBCE_H
2 #define ALITPCCALIBCE_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 #include <TVectorT.h>
7 class TObjArray;
8 class TH1S;
9 class TH2S;
10 class TH1F;
11 class TTreeSRedirector;
12 class AliTPCCalPad;
13 class AliTPCROC;
14 class AliTPCCalROC;
15 class AliTPCParam;
16 class AliRawReader;
17 class AliTPCRawStream;
18 class TGraph;
19 struct eventHeaderStruct;
20
21 class AliTPCCalibCE : public TObject {
22
23 public:
24     AliTPCCalibCE();
25     AliTPCCalibCE(const AliTPCCalibCE &sig);
26     virtual ~AliTPCCalibCE();
27
28     AliTPCCalibCE& operator = (const  AliTPCCalibCE &source);
29
30
31     Bool_t ProcessEvent(AliTPCRawStream *rawStream);
32     Bool_t ProcessEvent(AliRawReader    *rawReader);
33     Bool_t ProcessEvent(eventHeaderStruct   *event);
34
35     Int_t Update(const Int_t isector, const Int_t iRow, const Int_t iPad,
36                const Int_t iTimeBin, const Float_t signal);
37     void Analyse();
38     //
39     AliTPCCalROC* GetCalRocT0 (Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
40     AliTPCCalROC* GetCalRocQ  (Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
41     AliTPCCalROC* GetCalRocRMS(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
42     AliTPCCalROC* GetCalRocOutliers(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
43
44     const TObjArray* GetCalPadT0() { return &fCalRocArrayT0; }      // get calibration object
45     const TObjArray* GetCalPadQ()  { return &fCalRocArrayQ;  }      // get calibration object
46     const TObjArray* GetCalPadRMS(){ return &fCalRocArrayRMS;}      // get calibration object
47     const TObjArray* GetCalPadOutliers(){ return &fCalRocArrayOutliers;}      // get calibration object
48
49     TH2S* GetHistoQ  (Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
50     TH2S* GetHistoT0 (Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
51     TH2S* GetHistoRMS(Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
52
53     TH1S* GetHistoTmean(Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
54
55     Short_t GetDebugLevel()     const { return fDebugLevel;    }
56     //
57     void  SetRangeTime (Int_t firstTimeBin, Int_t lastTimeBin) { fFirstTimeBin=firstTimeBin;   fLastTimeBin=lastTimeBin;  } //Set range in which the pulser signal is expected
58     //
59     void  SetRangeRefQ  (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsQ   = nBins; fXminQ   = xMin; fXmaxQ   = xMax; }   //Set range for Q reference histograms
60     void  SetRangeRefT0 (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsT0  = nBins; fXminT0  = xMin; fXmaxT0  = xMax; }   //Set range for T0 reference histograms
61     void  SetRangeRefRMS(Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsRMS = nBins; fXminRMS = xMin; fXmaxRMS = xMax; }   //Set range for T0 reference histograms
62     //
63     void  SetTimeStampEvent(Float_t timestamp){ fTimeStamp = timestamp; }
64     void  SetRunNumber(Float_t eventnumber){ fRunNumber = eventnumber; }
65
66     void  SetOldRCUformat(Bool_t format=kTRUE){ fOldRCUformat = format; }
67
68     void  SetDebugLevel(Short_t debug=1){ fDebugLevel = debug;}
69
70     void  SetPedestalDatabase(AliTPCCalPad *pedestalTPC, AliTPCCalPad *padNoiseTPC) {fPedestalTPC = pedestalTPC; fPadNoiseTPC = padNoiseTPC;}
71
72     Int_t GetFirstTimeBin()   const { return fFirstTimeBin;  }
73     Int_t GetLastTimeBin()    const { return fLastTimeBin;   }
74
75     Int_t GetNeventsProcessed() { return fNevents; }
76
77     TGraph *MakeGraphTimeCE(Int_t sector, Int_t xVariable=0, Int_t fitType=0, Int_t fitParameter=0);
78
79     void DumpToFile(const Char_t *filename, const Char_t *dir="", Bool_t append=kFALSE);
80
81 private:
82     Int_t fFirstTimeBin;              //  First Time bin needed for analysis
83     Int_t fLastTimeBin;               //  Last Time bin needed for analysis
84
85     // reference histogram ranges
86     Int_t   fNbinsT0;                 //  Number of bins for T0 reference histogram
87     Float_t fXminT0;                  //  xmin   of T0 reference histogram
88     Float_t fXmaxT0;                  //  xmax   of T0 reference histogram
89     Int_t   fNbinsQ;                  //  Number of bins for T0 reference histogram
90     Float_t fXminQ;                   //  xmin   of T0 reference histogram
91     Float_t fXmaxQ;                   //  xmax   of T0 reference histogram
92     Int_t   fNbinsRMS;                //  Number of bins for T0 reference histogram
93     Float_t fXminRMS;                 //  xmin   of T0 reference histogram
94     Float_t fXmaxRMS;                 //  xmax   of T0 reference histogram
95
96     Int_t     fLastSector;            //! Last sector processed
97
98     Bool_t  fOldRCUformat;            //! Should we use the old RCU format for data reading
99
100     AliTPCROC   *fROC;                //! ROC information
101     AliTPCParam *fParam;              //! TPC information
102
103     AliTPCCalPad *fPedestalTPC;       //! Pedestal Information whole TPC
104     AliTPCCalPad *fPadNoiseTPC;       //! Pad noise Information whole TPC
105     AliTPCCalROC *fPedestalROC;       //! Pedestal Information for current ROC
106     AliTPCCalROC *fPadNoiseROC;       //! Pad noise Information for current ROC
107
108     TObjArray fCalRocArrayT0;         //  Array of AliTPCCalROC class for Time0 calibration
109     TObjArray fCalRocArrayQ;          //  Array of AliTPCCalROC class for Charge calibration
110     TObjArray fCalRocArrayRMS;        //  Array of AliTPCCalROC class for signal width calibration
111     TObjArray fCalRocArrayOutliers;   //  Array of AliTPCCalROC class for signal outliers
112
113     TObjArray fHistoQArray;           //  Calibration histograms for Charge distribution
114     TObjArray fHistoT0Array;          //  Calibration histograms for Time0  distribution
115     TObjArray fHistoRMSArray;         //  Calibration histograms for signal width distribution
116
117     TObjArray fHistoTmean;            //! Calibration histograms of the mean CE position for all sectors
118
119     TObjArray fParamArrayEvent;       //  Store mean arrival time parameters for each event
120     TObjArray fParamArrayEventPol1;   //  Store mean arrival time parameters for each sector event by event from global plane fit
121     TObjArray fParamArrayEventPol2;   //  Store mean arrival time parameters for each sector event by event from global parabola fit
122     TObjArray fTMeanArrayEvent;       //  Store mean arrival time for each sector event by event
123     TObjArray fQMeanArrayEvent;       //  Store mean arrival Charge for each sector event by event
124     TVectorD  fVEventTime;            //  Timestamps of the events
125     TVectorD  fVEventNumber;          //  Eventnumbers of the events
126     Int_t     fNevents;               //  Event counter
127     Double_t   fTimeStamp;             //! Timestamp of the current event
128     Double_t   fRunNumber;             //! Run Number of the current event
129     Double_t   fOldRunNumber;          //! Old Run Number
130
131     TObjArray fPadTimesArrayEvent;    //! Pad Times for the event, before mean Time0 corrections
132     TObjArray fPadQArrayEvent;        //! Charge for the event, only needed for debugging streamer
133     TObjArray fPadRMSArrayEvent;      //! Signal width for the event, only needed for debugging streamer
134     TObjArray fPadPedestalArrayEvent; //! Signal width for the event, only needed for debugging streamer
135
136     Int_t     fCurrentChannel;         //! current channel processed
137     Int_t     fCurrentSector;          //! current sector processed
138     Int_t     fCurrentRow;             //! current row processed
139     Float_t   fMaxPadSignal;           //! maximum bin of current pad
140     Int_t     fMaxTimeBin;             //! time bin with maximum value
141     TVectorF  fPadSignal;              //! signal of current Pad
142     Float_t   fPadPedestal;            //! Pedestal Value of current pad
143     Float_t   fPadNoise;               //! Noise Value of current pad
144
145     TVectorD  fVTime0Offset;          //!  Time0 Offset for each sector;
146     TVectorD  fVTime0OffsetCounter;   //!  Time0 Offset counter for each sector;
147     TVectorD  fVMeanQ;                //!  Mean Q for each sector;
148     TVectorD  fVMeanQCounter;         //!  Mean Q counter for each sector;
149 //    TH1F      *fHTime0;                //!  Time0 Offset ( mean Time0 )                          ???????????????????????????
150     //debugging
151     Int_t fEvent;
152     TTreeSRedirector *fDebugStreamer;  //! debug streamer
153
154     Short_t fDebugLevel;
155     //! debugging
156
157     void   FindPedestal(Float_t part=.6);
158     void   FindCESignal(TVectorD &param, Float_t &qSum, const TVectorF maxima);
159     void   FindLocalMaxima(TVectorF &maxima);
160     Bool_t IsPeak(Int_t pos, Int_t tminus, Int_t tplus);
161
162     TH2S* GetHisto(Int_t sector, TObjArray *arr,
163                    Int_t nbinsY, Float_t ymin, Float_t ymax,
164                    Char_t *type, Bool_t force);
165     TH1S* GetHisto(Int_t sector, TObjArray *arr,
166                    Char_t *type, Bool_t force);
167
168     AliTPCCalROC* GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force);
169
170     TVectorF* GetPadTimesEvent(Int_t sector, Bool_t force=kFALSE);
171
172     TObjArray* GetParamArray(Int_t sector, TObjArray *arr, Bool_t force=kFALSE);
173     TObjArray* GetParamArrayPol1(Int_t sector, Bool_t force=kFALSE);
174     TObjArray* GetParamArrayPol2(Int_t sector, Bool_t force=kFALSE);
175
176     void ResetEvent();
177     void ResetPad();
178     void ProcessPad();
179     void EndEvent();
180
181
182     //debug
183     TVectorF* GetPadInfoEvent(Int_t sector, TObjArray *arr, Bool_t force=kFALSE);
184     TVectorF* GetPadQEvent(Int_t sector, Bool_t force=kFALSE);
185     TVectorF* GetPadRMSEvent(Int_t sector, Bool_t force=kFALSE);
186     TVectorF* GetPadPedestalEvent(Int_t sector, Bool_t force=kFALSE);
187
188
189 public:
190
191
192   ClassDef(AliTPCCalibCE,1)
193 };
194
195
196
197 #endif
198