]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCCalibPulser.h
ea6a2068a67d04e0049edf72ebff2a3e991e0aef
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibPulser.h
1 #ifndef ALITPCCALIBPULSER_H
2 #define ALITPCCALIBPULSER_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 pulser calibration                       //
9 //                                                                                     //
10 /////////////////////////////////////////////////////////////////////////////////////////
11
12 #include <TVectorT.h>
13 class TObjArray;
14 class TH2S;
15 class TTreeSRedirector;
16 class AliTPCCalPad;
17 class AliTPCROC;
18 class AliTPCCalROC;
19 class AliTPCParam;
20 class AliRawReader;
21 class AliTPCRawStream;
22 class AliTPCRawStreamFast;
23 struct eventHeaderStruct;
24
25 class AliTPCCalibPulser : public TObject {
26
27 public:
28     AliTPCCalibPulser();
29     AliTPCCalibPulser(const AliTPCCalibPulser &sig);
30     virtual ~AliTPCCalibPulser();
31
32     void Reset();
33
34     AliTPCCalibPulser& operator = (const  AliTPCCalibPulser &source);
35
36     Bool_t ProcessEventFast(AliTPCRawStreamFast *rawStreamFast);
37     Bool_t ProcessEventFast(AliRawReader            *rawReader);
38
39
40     Bool_t ProcessEvent(AliTPCRawStream *rawStream);
41     Bool_t ProcessEvent(AliRawReader    *rawReader);
42     Bool_t ProcessEvent(eventHeaderStruct   *event);
43
44     Int_t Update(const Int_t isector, const Int_t iRow, const Int_t iPad,
45                const Int_t iTimeBin, const Float_t signal);
46     void Analyse();
47     //
48     AliTPCCalROC* GetCalRocT0 (Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
49     AliTPCCalROC* GetCalRocQ  (Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
50     AliTPCCalROC* GetCalRocRMS(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
51     AliTPCCalROC* GetCalRocOutliers(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
52
53     const TObjArray* GetCalPadT0()  const { return &fCalRocArrayT0; }      // get calibration object
54     const TObjArray* GetCalPadQ()   const { return &fCalRocArrayQ;  }      // get calibration object
55     const TObjArray* GetCalPadRMS() const{ return &fCalRocArrayRMS;}      // get calibration object
56     const TObjArray* GetCalPadOutliers() const { return &fCalRocArrayOutliers;}      // get calibration object
57
58     TH2S* GetHistoQ  (Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
59     TH2S* GetHistoT0 (Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
60     TH2S* GetHistoRMS(Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
61
62     Short_t GetDebugLevel()     const { return fDebugLevel;    }
63     //
64     void  SetRangeTime (Int_t firstTimeBin, Int_t lastTimeBin) { fFirstTimeBin=firstTimeBin;   fLastTimeBin=lastTimeBin;  } //Set range in which the pulser signal is expected
65     //
66     void  SetRangeRefQ  (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsQ   = nBins; fXminQ   = xMin; fXmaxQ   = xMax; }   //Set range for Q reference histograms
67     void  SetRangeRefT0 (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsT0  = nBins; fXminT0  = xMin; fXmaxT0  = xMax; }   //Set range for T0 reference histograms
68     void  SetRangeRefRMS(Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsRMS = nBins; fXminRMS = xMin; fXmaxRMS = xMax; }   //Set range for T0 reference histograms
69
70     void  SetOldRCUformat(Bool_t format=kTRUE){ fOldRCUformat = format; }
71
72     void  SetDebugLevel(Short_t debug=1){ fDebugLevel = debug;}
73
74     void  SetPedestalDatabase(AliTPCCalPad *pedestalTPC, AliTPCCalPad *padNoiseTPC) {fPedestalTPC = pedestalTPC; fPadNoiseTPC = padNoiseTPC;}
75     void  SetOutliers(AliTPCCalPad *outliers)  {fOutliers = outliers;}
76
77     Int_t GetFirstTimeBin()   const { return fFirstTimeBin;  }
78     Int_t GetLastTimeBin()    const { return fLastTimeBin;   }
79
80     void Merge(AliTPCCalibPulser *sig);
81
82     void DumpToFile(const Char_t *filename, const Char_t *dir="", Bool_t append=kFALSE);
83     //
84     // Test functions
85     TObjArray* TestBinning();
86
87 private:
88     Int_t fFirstTimeBin;              //  First Time bin needed for analysis
89     Int_t fLastTimeBin;               //  Last Time bin needed for analysis
90
91     // reference histogram ranges
92     Int_t   fNbinsT0;                 //  Number of bins for T0 reference histogram
93     Float_t fXminT0;                  //  xmin   of T0 reference histogram
94     Float_t fXmaxT0;                  //  xmax   of T0 reference histogram
95     Int_t   fNbinsQ;                  //  Number of bins for T0 reference histogram
96     Float_t fXminQ;                   //  xmin   of T0 reference histogram
97     Float_t fXmaxQ;                   //  xmax   of T0 reference histogram
98     Int_t   fNbinsRMS;                //  Number of bins for T0 reference histogram
99     Float_t fXminRMS;                 //  xmin   of T0 reference histogram
100     Float_t fXmaxRMS;                 //  xmax   of T0 reference histogram
101
102     Int_t     fLastSector;            //! Last sector processed
103
104     Bool_t  fOldRCUformat;            //! Should we use the old RCU format for data reading
105
106     AliTPCROC   *fROC;                //! ROC information
107     AliTPCParam *fParam;              //! TPC information
108
109     AliTPCCalPad *fPedestalTPC;       //! Pedestal Information
110     AliTPCCalPad *fPadNoiseTPC;       //! Pad noise Information whole TPC
111     AliTPCCalPad *fOutliers;          //! Outlier information. Those will not be used for calculating the T0
112     AliTPCCalROC *fPedestalROC;       //! Pedestal Information for current ROC
113     AliTPCCalROC *fPadNoiseROC;       //! Pad noise Information for current ROC
114 //    Bool_t fBpedestal;                //! are we running with pedestal substraction
115
116
117     TObjArray fCalRocArrayT0;         //  Array of AliTPCCalROC class for Time0 calibration
118     TObjArray fCalRocArrayQ;          //  Array of AliTPCCalROC class for Charge calibration
119     TObjArray fCalRocArrayRMS;        //  Array of AliTPCCalROC class for signal width calibration
120     TObjArray fCalRocArrayOutliers;  //  Array of AliTPCCalROC class for signal outliers
121
122     TObjArray fHistoQArray;           //  Calibration histograms for Charge distribution
123     TObjArray fHistoT0Array;          //  Calibration histograms for Time0  distribution
124     TObjArray fHistoRMSArray;         //  Calibration histograms for signal width distribution
125
126     TObjArray fPadTimesArrayEvent;    //! Pad Times for the event, before mean Time0 corrections
127     TObjArray fPadQArrayEvent;        //! Charge for the event, only needed for debugging streamer
128     TObjArray fPadRMSArrayEvent;      //! Signal width for the event, only needed for debugging streamer
129     TObjArray fPadPedestalArrayEvent; //! Signal width for the event, only needed for debugging streamer
130
131     Int_t     fCurrentChannel;         //! current channel processed
132     Int_t     fCurrentSector;          //! current sector processed
133     Int_t     fCurrentRow;             //! current row processed
134     Float_t   fMaxPadSignal;           //! maximum bin of current pad
135     Int_t     fMaxTimeBin;             //! time bin with maximum value
136     TVectorF  fPadSignal;              //! signal of current Pad
137     Float_t   fPadPedestal;            //! Pedestal Value of current pad
138     Float_t   fPadNoise;               //! Noise Value of current pad
139
140     TVectorF  fVTime0Offset;          //!  Time0 Offset from preprocessing for each sector;
141     TVectorF  fVTime0OffsetCounter;   //!  Time0 Offset from preprocessing for each sector;
142
143     //debugging
144 //    Int_t fEvent;                      //  Number of events processed
145     TTreeSRedirector *fDebugStreamer;  //! debug streamer
146
147     Short_t fDebugLevel;               //  debug Level
148     //! debugging
149
150     void   FindPedestal(Float_t part=.6);
151     void FindPulserSignal(TVectorD &param, Float_t &qSum);
152
153     TH2S* GetHisto(Int_t sector, TObjArray *arr,
154                    Int_t nbinsY, Float_t ymin, Float_t ymax,
155                    Char_t *type, Bool_t force);
156
157
158     AliTPCCalROC* GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) const;
159
160     TVectorF* GetPadTimesEvent(Int_t sector, Bool_t force=kFALSE);
161
162     void ResetEvent();
163     void ResetPad();
164     void ProcessPad();
165     void EndEvent();
166
167
168     //debug
169     TVectorF* GetPadInfoEvent(Int_t sector, TObjArray *arr, Bool_t force=kFALSE);
170     TVectorF* GetPadQEvent(Int_t sector, Bool_t force=kFALSE);
171     TVectorF* GetPadRMSEvent(Int_t sector, Bool_t force=kFALSE);
172     TVectorF* GetPadPedestalEvent(Int_t sector, Bool_t force=kFALSE);
173
174
175   ClassDef(AliTPCCalibPulser,1)           //Implementation of the TPC pulser calibration
176 };
177
178
179
180 #endif
181