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