]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCCalibCE.h
syst. check that reads the MC information for the case of TPC-only
[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     void  SetSecRejectRatio(Float_t ratio) { fSecRejectRatio=ratio; }
118
119     Int_t GetFirstTimeBin()   const { return fFirstTimeBin;  }
120     Int_t GetLastTimeBin()    const { return fLastTimeBin;   }
121
122     Int_t GetNeventsProcessed() const { return fNevents; }
123
124     Bool_t GetIsZeroSuppressed() const { return fIsZeroSuppressed; }
125
126     Float_t  GetSecRejectRatio() const { return fSecRejectRatio; }
127
128
129     void Merge(AliTPCCalibCE *ce);
130
131     TGraph *MakeGraphTimeCE(Int_t sector, Int_t xVariable=0, Int_t fitType=0, Int_t fitParameter=0);
132
133     void DumpToFile(const Char_t *filename, const Char_t *dir="", Bool_t append=kFALSE);
134
135 private:
136     Int_t fFirstTimeBin;              //  First Time bin needed for analysis
137     Int_t fLastTimeBin;               //  Last Time bin needed for analysis
138
139     // reference histogram ranges
140     Int_t   fNbinsT0;                 //  Number of bins for T0 reference histogram
141     Float_t fXminT0;                  //  xmin   of T0 reference histogram
142     Float_t fXmaxT0;                  //  xmax   of T0 reference histogram
143     Int_t   fNbinsQ;                  //  Number of bins for T0 reference histogram
144     Float_t fXminQ;                   //  xmin   of T0 reference histogram
145     Float_t fXmaxQ;                   //  xmax   of T0 reference histogram
146     Int_t   fNbinsRMS;                //  Number of bins for T0 reference histogram
147     Float_t fXminRMS;                 //  xmin   of T0 reference histogram
148     Float_t fXmaxRMS;                 //  xmax   of T0 reference histogram
149     Int_t   fPeakMinus;               //  Consecutive timebins on rising edge to be regarded as a signal
150     Int_t   fPeakPlus;                //  Consecutive timebins on falling edge to be regarded as a signal
151     Float_t fNoiseThresholdMax;       //  Analysis Treshold for signal finding: Max>fNoiseThresholdMax*PadNoise
152     Float_t fNoiseThresholdSum;       //  Analysis Treshold for signal finding: Sum>fNoiseThresholdSum*PadNoise
153
154     Bool_t  fIsZeroSuppressed;        //  If data is Zero Suppressed -> Don't subtrakt pedestals!
155
156     Int_t     fLastSector;            //! Last sector processed
157
158     Float_t   fSecRejectRatio;        //! Needed percentage of signals in one chamber. Below it will be rejected
159                                       //  This is neede if we do not process a laser event
160
161     AliTPCROC   *fROC;                //! ROC information
162     AliTPCAltroMapping **fMapping;    //! Altro Mapping object
163     AliTPCParam *fParam;              //! TPC information
164
165     AliTPCCalPad *fPedestalTPC;       //! Pedestal Information whole TPC
166     AliTPCCalPad *fPadNoiseTPC;       //! Pad noise Information whole TPC
167     AliTPCCalROC *fPedestalROC;       //! Pedestal Information for current ROC
168     AliTPCCalROC *fPadNoiseROC;       //! Pad noise Information for current ROC
169
170     TObjArray fCalRocArrayT0;         //  Array of AliTPCCalROC class for Time0 calibration
171     TObjArray fCalRocArrayT0Err;      //  Array of AliTPCCalROC class for the error (rms) of Time0 calibration
172     TObjArray fCalRocArrayQ;          //  Array of AliTPCCalROC class for Charge calibration
173     TObjArray fCalRocArrayRMS;        //  Array of AliTPCCalROC class for signal width calibration
174     TObjArray fCalRocArrayOutliers;   //  Array of AliTPCCalROC class for signal outliers
175
176     TObjArray fHistoQArray;           //  Calibration histograms for Charge distribution
177     TObjArray fHistoT0Array;          //  Calibration histograms for Time0  distribution
178     TObjArray fHistoRMSArray;         //  Calibration histograms for signal width distribution
179
180     Float_t   fMeanT0rms;             // mean of the rms of all pad T0  fits, used as error estimation of T0 results
181     Float_t   fMeanQrms;              // mean of the rms of all pad Q   fits, used as error estimation of Q results
182     Float_t   fMeanRMSrms;            // mean of the rms of all pad TMS fits, used as error estimation of RMS results
183
184     TObjArray fHistoTmean;            //! Calibration histograms of the mean CE position for all sectors
185
186     TObjArray fParamArrayEventPol1;   //  Store mean arrival time parameters for each sector event by event from global plane fit
187     TObjArray fParamArrayEventPol2;   //  Store mean arrival time parameters for each sector event by event from global parabola fit
188     TObjArray fTMeanArrayEvent;       //  Store mean arrival time for each sector event by event
189     TObjArray fQMeanArrayEvent;       //  Store mean arrival Charge for each sector event by event
190     TVectorD  fVEventTime;            //  Timestamps of the events
191     TVectorD  fVEventNumber;          //  Eventnumbers of the events
192 //    TVectorD  fVTime0Side[2];         //  Mean Time0 for each side for all events
193     Int_t     fNevents;               //  Event counter
194     Double_t  fTimeStamp;             //! Timestamp of the current event
195     Double_t  fEventId;               //! Event Id of the current event
196     Double_t  fRunNumber;             //! Run Number of the current event
197     Double_t  fOldRunNumber;          //! Old Run Number
198
199     TObjArray fPadTimesArrayEvent;    //! Pad Times for the event, before mean Time0 corrections
200     TObjArray fPadQArrayEvent;        //! Charge for the event, only needed for debugging streamer
201     TObjArray fPadRMSArrayEvent;      //! Signal width for the event, only needed for debugging streamer
202     TObjArray fPadPedestalArrayEvent; //! Signal width for the event, only needed for debugging streamer
203
204     Int_t     fCurrentChannel;        //! current channel processed
205     Int_t     fCurrentSector;         //! current sector processed
206     Int_t     fCurrentRow;            //! current row processed
207     Float_t   fMaxPadSignal;          //! maximum bin of current pad
208     Int_t     fMaxTimeBin;            //! time bin with maximum value
209     TVectorF  fPadSignal;             //! signal of current Pad
210     Float_t   fPadPedestal;           //! Pedestal Value of current pad
211     Float_t   fPadNoise;              //! Noise Value of current pad
212
213     TVectorD  fVTime0Offset;          //!  Time0 Offset for each sector;
214     TVectorD  fVTime0OffsetCounter;   //!  Time0 Offset counter for each sector;
215     TVectorD  fVMeanQ;                //!  Mean Q for each sector;
216     TVectorD  fVMeanQCounter;         //!  Mean Q counter for each sector;
217
218     //debugging
219 //    Int_t fEvent;
220     TTreeSRedirector *fDebugStreamer;  //! debug streamer
221
222     Short_t fDebugLevel;              // debug level
223     //! debugging
224
225     void   FindPedestal(Float_t part=.6);
226     void   FindCESignal(TVectorD &param, Float_t &qSum, const TVectorF maxima);
227     void   FindLocalMaxima(TVectorF &maxima);
228     Bool_t IsPeak(Int_t pos, Int_t tminus, Int_t tplus) const;
229
230     TH2S* GetHisto(Int_t sector, TObjArray *arr,
231                    Int_t nbinsY, Float_t ymin, Float_t ymax,
232                    Char_t *type, Bool_t force);
233     TH1S* GetHisto(Int_t sector, TObjArray *arr,
234                    Char_t *type, Bool_t force);
235
236     AliTPCCalROC* GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) const;
237
238     TVectorF* GetVectSector(Int_t sector, TObjArray *arr, UInt_t size, Bool_t force=kFALSE) const;
239     TVectorF* GetPadTimesEvent(Int_t sector, Bool_t force=kFALSE);
240
241     TObjArray* GetParamArray(Int_t sector, TObjArray *arr, Bool_t force=kFALSE) const;
242
243     void ResetEvent();
244     void ResetPad();
245     void ProcessPad();
246     void EndEvent();
247
248
249     //debug
250     TVectorF* GetPadQEvent(Int_t sector, Bool_t force=kFALSE);
251     TVectorF* GetPadRMSEvent(Int_t sector, Bool_t force=kFALSE);
252     TVectorF* GetPadPedestalEvent(Int_t sector, Bool_t force=kFALSE);
253
254     ClassDef(AliTPCCalibCE,7)  //Implementation of the TPC Central Electrode calibration
255
256 };
257
258
259
260 #endif
261