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