]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCCalibCE.h
Reverting back the TPC set branch (Marian)
[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 ////////////////////////////////////////////////////////////////////////////////////////
7 //                                                                                    //
8 //             Implementation of the TPC Central Electrode calibration                //
9 //                                                                                    //
10 ////////////////////////////////////////////////////////////////////////////////////////
11
12 #include <TVectorT.h>
13 #include <TObjArray.h>
14 class TH1S;
15 class TH2S;
16 class TH1F;
17 class TTreeSRedirector;
18 class AliTPCCalPad;
19 class AliTPCROC;
20 class AliTPCCalROC;
21 class AliTPCParam;
22 class AliRawReader;
23 class AliTPCRawStream;
24 class AliTPCRawStreamFast;
25 class TGraph;
26 class AliTPCAltroMapping;
27 class TMap;
28
29 struct eventHeaderStruct;
30
31 class AliTPCCalibCE : public TObject {
32
33 public:
34     AliTPCCalibCE();
35     AliTPCCalibCE(const AliTPCCalibCE &sig);
36     AliTPCCalibCE(const TMap *config);
37     virtual ~AliTPCCalibCE();
38
39     AliTPCCalibCE& operator = (const  AliTPCCalibCE &source);
40
41     Bool_t ProcessEventFast(AliTPCRawStreamFast *rawStreamFast);
42     Bool_t ProcessEventFast(AliRawReader            *rawReader);
43
44
45     Bool_t ProcessEvent(AliTPCRawStream *rawStream);
46     Bool_t ProcessEvent(AliRawReader    *rawReader);
47     Bool_t ProcessEvent(eventHeaderStruct   *event);
48
49     Int_t Update(const Int_t isector, const Int_t iRow, const Int_t iPad,
50                const Int_t iTimeBin, const Float_t signal);
51     void Analyse();
52      //
53     AliTPCAltroMapping **GetAltroMapping() { return fMapping; };
54     void  SetAltroMapping(AliTPCAltroMapping **mapp) { fMapping = mapp; };
55
56     //
57     AliTPCCalROC* GetCalRocT0  (Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
58     AliTPCCalROC* GetCalRocT0Err(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
59     AliTPCCalROC* GetCalRocQ   (Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
60     AliTPCCalROC* GetCalRocRMS(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
61     AliTPCCalROC* GetCalRocOutliers(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
62
63     const TObjArray* GetCalPadT0()    const { return &fCalRocArrayT0; }      // get calibration object
64     const TObjArray* GetCalPadT0Err() const { return &fCalRocArrayT0Err; }      // get calibration object
65     const TObjArray* GetCalPadQ()     const { return &fCalRocArrayQ;  }      // get calibration object
66     const TObjArray* GetCalPadRMS()   const { return &fCalRocArrayRMS;}      // get calibration object
67     const TObjArray* GetCalPadOutliers() const { return &fCalRocArrayOutliers;}      // get calibration object
68
69     TH2S* GetHistoQ  (Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
70     TH2S* GetHistoT0 (Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
71     TH2S* GetHistoRMS(Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
72
73     Float_t GetMeanT0rms() const {return fMeanT0rms;}
74     Float_t GetMeanQrms() const {return fMeanQrms;}
75     Float_t GetMeanRMSrms() const {return fMeanRMSrms;}
76
77     Int_t   GetPeakDetectionMinus() const {return fPeakMinus;}
78     Int_t   GetPeakDetectionPlus()  const {return fPeakPlus;}
79     Float_t GetNnoiseThresholdMax() const {return fNoiseThresholdMax;}
80     Float_t GetNnoiseThresholdSum() const {return fNoiseThresholdSum;}
81
82     TH1S* GetHistoTmean(Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
83
84     //needed here to merge ClibCE objects
85     TObjArray* GetParamArrayPol1(Int_t sector, Bool_t force=kFALSE);
86     TObjArray* GetParamArrayPol2(Int_t sector, Bool_t force=kFALSE);
87
88 //    TObjArray*  GetTMeanArrayEvent(){ return &fTMeanArrayEvent; }
89 //    TObjArray*  GetQMeanArrayEvent(){ return &fQMeanArrayEvent; }
90     TVectorF* GetTMeanEvents(Int_t sector, Bool_t force=kFALSE);
91     TVectorF* GetQMeanEvents(Int_t sector, Bool_t force=kFALSE);
92
93     TVectorD*   GetEventTimes()     { return &fVEventTime;      }
94     TVectorD*   GetEventIds()       { return &fVEventNumber;    }
95
96     Short_t GetDebugLevel()     const { return fDebugLevel;    }
97     //
98     void  SetRangeTime (Int_t firstTimeBin, Int_t lastTimeBin) { fFirstTimeBin=firstTimeBin;   fLastTimeBin=lastTimeBin;  } //Set range in which the pulser signal is expected
99     //
100     void  SetRangeRefQ  (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsQ   = nBins; fXminQ   = xMin; fXmaxQ   = xMax; }   //Set range for Q reference histograms
101     void  SetRangeRefT0 (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsT0  = nBins; fXminT0  = xMin; fXmaxT0  = xMax; }   //Set range for T0 reference histograms
102     void  SetRangeRefRMS(Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsRMS = nBins; fXminRMS = xMin; fXmaxRMS = xMax; }   //Set range for T0 reference histograms
103     //
104     void  SetRangePeakDetection(Int_t minus, Int_t plus) { fPeakMinus=minus; fPeakPlus=plus;}
105     void  SetNnoiseThresholdMax(Float_t n) {fNoiseThresholdMax=n;}
106     void  SetNnoiseThresholdSum(Float_t n) {fNoiseThresholdSum=n;}
107     //
108     void  SetTimeStampEvent(Double_t timestamp){ fTimeStamp = timestamp; }
109     void  SetRunNumber(Double_t eventnumber){ fRunNumber = eventnumber; }
110
111     void  SetEventInfo(Double_t runNumber, Double_t timestamp, Double_t eventId){ fRunNumber=runNumber; fTimeStamp=timestamp; fEventId=eventId;}
112
113     void  SetDebugLevel(Short_t debug=1){ fDebugLevel = debug;}
114
115     void  SetPedestalDatabase(AliTPCCalPad *pedestalTPC, AliTPCCalPad *padNoiseTPC) {fPedestalTPC = pedestalTPC; fPadNoiseTPC = padNoiseTPC;}
116
117     void  SetIsZeroSuppressed(Bool_t zs=kTRUE) { fIsZeroSuppressed=zs; }
118
119     void  SetSecRejectRatio(Float_t ratio) { fSecRejectRatio=ratio; }
120
121     Int_t GetFirstTimeBin()   const { return fFirstTimeBin;  }
122     Int_t GetLastTimeBin()    const { return fLastTimeBin;   }
123
124     Int_t GetNeventsProcessed() const { return fNevents; }
125
126     Bool_t GetIsZeroSuppressed() const { return fIsZeroSuppressed; }
127
128     Float_t  GetSecRejectRatio() const { return fSecRejectRatio; }
129
130
131     void Merge(AliTPCCalibCE *ce);
132
133     TGraph *MakeGraphTimeCE(Int_t sector, Int_t xVariable=0, Int_t fitType=0, Int_t fitParameter=0);
134
135     void DumpToFile(const Char_t *filename, const Char_t *dir="", Bool_t append=kFALSE);
136
137 private:
138     Int_t fFirstTimeBin;              //  First Time bin needed for analysis
139     Int_t fLastTimeBin;               //  Last Time bin needed for analysis
140
141     // reference histogram ranges
142     Int_t   fNbinsT0;                 //  Number of bins for T0 reference histogram
143     Float_t fXminT0;                  //  xmin   of T0 reference histogram
144     Float_t fXmaxT0;                  //  xmax   of T0 reference histogram
145     Int_t   fNbinsQ;                  //  Number of bins for T0 reference histogram
146     Float_t fXminQ;                   //  xmin   of T0 reference histogram
147     Float_t fXmaxQ;                   //  xmax   of T0 reference histogram
148     Int_t   fNbinsRMS;                //  Number of bins for T0 reference histogram
149     Float_t fXminRMS;                 //  xmin   of T0 reference histogram
150     Float_t fXmaxRMS;                 //  xmax   of T0 reference histogram
151     Int_t   fPeakMinus;               //  Consecutive timebins on rising edge to be regarded as a signal
152     Int_t   fPeakPlus;                //  Consecutive timebins on falling edge to be regarded as a signal
153     Float_t fNoiseThresholdMax;       //  Analysis Treshold for signal finding: Max>fNoiseThresholdMax*PadNoise
154     Float_t fNoiseThresholdSum;       //  Analysis Treshold for signal finding: Sum>fNoiseThresholdSum*PadNoise
155
156     Bool_t  fIsZeroSuppressed;        //  If data is Zero Suppressed -> Don't subtrakt pedestals!
157
158     Int_t     fLastSector;            //! Last sector processed
159
160     Float_t   fSecRejectRatio;        //! Needed percentage of signals in one chamber. Below it will be rejected
161                                       //  This is neede if we do not process a laser event
162
163     AliTPCROC   *fROC;                //! ROC information
164     AliTPCAltroMapping **fMapping;    //! Altro Mapping object
165     AliTPCParam *fParam;              //! TPC information
166
167     AliTPCCalPad *fPedestalTPC;       //! Pedestal Information whole TPC
168     AliTPCCalPad *fPadNoiseTPC;       //! Pad noise Information whole TPC
169     AliTPCCalROC *fPedestalROC;       //! Pedestal Information for current ROC
170     AliTPCCalROC *fPadNoiseROC;       //! Pad noise Information for current ROC
171
172     TObjArray fCalRocArrayT0;         //  Array of AliTPCCalROC class for Time0 calibration
173     TObjArray fCalRocArrayT0Err;      //  Array of AliTPCCalROC class for the error (rms) of Time0 calibration
174     TObjArray fCalRocArrayQ;          //  Array of AliTPCCalROC class for Charge calibration
175     TObjArray fCalRocArrayRMS;        //  Array of AliTPCCalROC class for signal width calibration
176     TObjArray fCalRocArrayOutliers;   //  Array of AliTPCCalROC class for signal outliers
177
178     TObjArray fHistoQArray;           //  Calibration histograms for Charge distribution
179     TObjArray fHistoT0Array;          //  Calibration histograms for Time0  distribution
180     TObjArray fHistoRMSArray;         //  Calibration histograms for signal width distribution
181
182     Float_t   fMeanT0rms;             // mean of the rms of all pad T0  fits, used as error estimation of T0 results
183     Float_t   fMeanQrms;              // mean of the rms of all pad Q   fits, used as error estimation of Q results
184     Float_t   fMeanRMSrms;            // mean of the rms of all pad TMS fits, used as error estimation of RMS results
185
186     TObjArray fHistoTmean;            //! Calibration histograms of the mean CE position for all sectors
187
188     TObjArray fParamArrayEventPol1;   //  Store mean arrival time parameters for each sector event by event from global plane fit
189     TObjArray fParamArrayEventPol2;   //  Store mean arrival time parameters for each sector event by event from global parabola fit
190     TObjArray fTMeanArrayEvent;       //  Store mean arrival time for each sector event by event
191     TObjArray fQMeanArrayEvent;       //  Store mean arrival Charge for each sector event by event
192     TVectorD  fVEventTime;            //  Timestamps of the events
193     TVectorD  fVEventNumber;          //  Eventnumbers of the events
194 //    TVectorD  fVTime0Side[2];         //  Mean Time0 for each side for all events
195     Int_t     fNevents;               //  Event counter
196     Double_t  fTimeStamp;             //! Timestamp of the current event
197     Double_t  fEventId;               //! Event Id of the current event
198     Double_t  fRunNumber;             //! Run Number of the current event
199     Double_t  fOldRunNumber;          //! Old Run Number
200
201     TObjArray fPadTimesArrayEvent;    //! Pad Times for the event, before mean Time0 corrections
202     TObjArray fPadQArrayEvent;        //! Charge for the event, only needed for debugging streamer
203     TObjArray fPadRMSArrayEvent;      //! Signal width for the event, only needed for debugging streamer
204     TObjArray fPadPedestalArrayEvent; //! Signal width for the event, only needed for debugging streamer
205
206     Int_t     fCurrentChannel;        //! current channel processed
207     Int_t     fCurrentSector;         //! current sector processed
208     Int_t     fCurrentRow;            //! current row processed
209     Float_t   fMaxPadSignal;          //! maximum bin of current pad
210     Int_t     fMaxTimeBin;            //! time bin with maximum value
211     TVectorF  fPadSignal;             //! signal of current Pad
212     Float_t   fPadPedestal;           //! Pedestal Value of current pad
213     Float_t   fPadNoise;              //! Noise Value of current pad
214
215     TVectorD  fVTime0Offset;          //!  Time0 Offset for each sector;
216     TVectorD  fVTime0OffsetCounter;   //!  Time0 Offset counter for each sector;
217     TVectorD  fVMeanQ;                //!  Mean Q for each sector;
218     TVectorD  fVMeanQCounter;         //!  Mean Q counter for each sector;
219
220     Float_t   fCurrentCETimeRef;      //! Time refernce of the current sector  
221     //debugging
222 //    Int_t fEvent;
223     TTreeSRedirector *fDebugStreamer;  //! debug streamer
224     
225
226     Short_t fDebugLevel;              // debug level
227     //! debugging
228
229     void   FindPedestal(Float_t part=.6);
230     void   UpdateCETimeRef(); //Get the time reference of the last valid measurement in sector
231     void   FindCESignal(TVectorD &param, Float_t &qSum, const TVectorF maxima);
232     void   FindLocalMaxima(TVectorF &maxima);
233     Bool_t IsPeak(Int_t pos, Int_t tminus, Int_t tplus) const;
234
235     TH2S* GetHisto(Int_t sector, TObjArray *arr,
236                    Int_t nbinsY, Float_t ymin, Float_t ymax,
237                    const Char_t *type, Bool_t force);
238     TH1S* GetHisto(Int_t sector, TObjArray *arr,
239                    const Char_t *type, Bool_t force);
240
241     AliTPCCalROC* GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) const;
242
243     TVectorF* GetVectSector(Int_t sector, TObjArray *arr, UInt_t size, Bool_t force=kFALSE) const;
244     TVectorF* GetPadTimesEvent(Int_t sector, Bool_t force=kFALSE);
245
246     TObjArray* GetParamArray(Int_t sector, TObjArray *arr, Bool_t force=kFALSE) const;
247
248     void ResetEvent();
249     void ResetPad();
250     void ProcessPad();
251     void EndEvent();
252
253
254     //debug
255     TVectorF* GetPadQEvent(Int_t sector, Bool_t force=kFALSE);
256     TVectorF* GetPadRMSEvent(Int_t sector, Bool_t force=kFALSE);
257     TVectorF* GetPadPedestalEvent(Int_t sector, Bool_t force=kFALSE);
258
259     ClassDef(AliTPCCalibCE,7)  //Implementation of the TPC Central Electrode calibration
260
261 };
262
263
264
265 #endif
266