]>
Commit | Line | Data |
---|---|---|
1 | #ifndef ALITRDCALIBRAFILLHISTO_H | |
2 | #define ALITRDCALIBRAFILLHISTOs_H | |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | /* $Id$ */ | |
7 | ||
8 | /////////////////////////////////////////////////////////////////////////////// | |
9 | // // | |
10 | // TRD calibration class for the HLT parameters // | |
11 | // // | |
12 | /////////////////////////////////////////////////////////////////////////////// | |
13 | ||
14 | #ifndef ROOT_TObject | |
15 | # include <TObject.h> | |
16 | #endif | |
17 | #ifndef ROOT_TLinearFitter | |
18 | # include <TLinearFitter.h> | |
19 | #endif | |
20 | #ifndef ROOT_TProfile2D | |
21 | # include <TProfile2D.h> | |
22 | #endif | |
23 | #ifndef ROOT_TH2I | |
24 | # include <TH2I.h> | |
25 | #endif | |
26 | ||
27 | class TProfile2D; | |
28 | class TObjArray; | |
29 | class TH1F; | |
30 | class TH2I; | |
31 | class TH2F; | |
32 | class TH2; | |
33 | class TLinearFitter; | |
34 | class TTreeSRedirector; | |
35 | ||
36 | class AliLog; | |
37 | class AliRawReader; | |
38 | ||
39 | class AliTRDCalibraMode; | |
40 | class AliTRDCalibraVector; | |
41 | class AliTRDCalibraVdriftLinearFit; | |
42 | class AliTRDrawStreamBase; | |
43 | class AliTRDcluster; | |
44 | class AliTRDtrackV1; | |
45 | class AliTRDtrack; | |
46 | class AliTRDseedV1; | |
47 | class AliTRDgeometry; | |
48 | class AliTRDCalDet; | |
49 | class AliTRDCalROC; | |
50 | ||
51 | ||
52 | struct eventHeaderStruct; | |
53 | ||
54 | class AliTRDCalibraFillHisto : public TObject { | |
55 | ||
56 | public: | |
57 | ||
58 | // Instance | |
59 | static AliTRDCalibraFillHisto *Instance(); | |
60 | static void Terminate(); | |
61 | static void Destroy(); | |
62 | void DestroyDebugStreamer(); | |
63 | ||
64 | ||
65 | AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c); | |
66 | AliTRDCalibraFillHisto &operator=(const AliTRDCalibraFillHisto &) { return *this; } | |
67 | ||
68 | // Functions for initialising and filling with AliTRDtrackV1 | |
69 | Bool_t Init2Dhistos(); | |
70 | Bool_t UpdateHistograms(AliTRDtrack *t); | |
71 | Bool_t UpdateHistogramsV1(AliTRDtrackV1 *t); | |
72 | ||
73 | // Process events DAQ | |
74 | Int_t ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bool_t nocheck = kFALSE); | |
75 | Int_t ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck = kFALSE); | |
76 | Int_t ProcessEventDAQ(eventHeaderStruct *event, Bool_t nocheck = kFALSE); | |
77 | ||
78 | // Is Pad on | |
79 | Bool_t IsPadOn(Int_t detector, Int_t row, Int_t col) const; | |
80 | ||
81 | // Functions for write | |
82 | void Write2d(const Char_t *filename = "TRD.calibration.root", Bool_t append = kFALSE); | |
83 | ||
84 | //For the statistics | |
85 | Double_t *StatH(TH2 *ch, Int_t i); | |
86 | Double_t *GetMeanMedianRMSNumberCH(); | |
87 | Double_t *GetMeanMedianRMSNumberLinearFitter() const; | |
88 | // LinearFitter | |
89 | void AnalyseLinearFitter(); | |
90 | ||
91 | ||
92 | // | |
93 | // Set of Get the variables | |
94 | // | |
95 | ||
96 | void SetIsHLT(Bool_t isHLT = kTRUE) { fIsHLT = isHLT; } | |
97 | Bool_t IsHLT() const { return fIsHLT; } | |
98 | ||
99 | // Choice to fill or not the 2D | |
100 | void SetMcmCorrectAngle(Bool_t mcmcorrectangle = kTRUE) { fMcmCorrectAngle = mcmcorrectangle; } | |
101 | void SetPH2dOn(Bool_t ph2don = kTRUE) { fPH2dOn = ph2don; } | |
102 | void SetCH2dOn(Bool_t ch2don = kTRUE) { fCH2dOn = ch2don; } | |
103 | void SetPRF2dOn(Bool_t prf2don = kTRUE) { fPRF2dOn = prf2don; } | |
104 | void SetHisto2d(Bool_t histo2d = kTRUE) { fHisto2d = histo2d; } | |
105 | void SetVector2d(Bool_t vector2d = kTRUE) { fVector2d = vector2d; } | |
106 | void SetLinearFitterOn(Bool_t linearfitteron = kTRUE) { fLinearFitterOn = linearfitteron;} | |
107 | void SetLinearFitterDebugOn(Bool_t debug = kTRUE) { fLinearFitterDebugOn = debug; } | |
108 | ||
109 | ||
110 | Bool_t GetMcmCorrectAngle() const { return fMcmCorrectAngle; } | |
111 | Bool_t GetPH2dOn() const { return fPH2dOn; } | |
112 | Bool_t GetCH2dOn() const { return fCH2dOn; } | |
113 | Bool_t GetPRF2dOn() const { return fPRF2dOn; } | |
114 | Bool_t GetHisto2d() const { return fHisto2d; } | |
115 | Bool_t GetVector2d() const { return fVector2d; } | |
116 | Bool_t GetLinearFitterOn() const { return fLinearFitterOn; } | |
117 | Bool_t GetLinearFitterDebugOn() const { return fLinearFitterDebugOn; } | |
118 | ||
119 | ||
120 | // Get stuff that are filled | |
121 | TH2I *GetCH2d(); | |
122 | TProfile2D *GetPH2d(Int_t nbtimebin=24, Float_t samplefrequency= 10.0); | |
123 | TProfile2D *GetPRF2d() const { return fPRF2d; } | |
124 | TObjArray GetLinearFitterArray() const { return fLinearFitterArray; } | |
125 | TLinearFitter *GetLinearFitter(Int_t detector, Bool_t force=kFALSE); | |
126 | AliTRDCalibraVdriftLinearFit *GetVdriftLinearFit() const { return fLinearVdriftFit; } | |
127 | ||
128 | ||
129 | // How to fill the 2D | |
130 | void SetRelativeScale(Float_t relativeScale); | |
131 | void SetThresholdClusterPRF2(Float_t thresholdClusterPRF2) { fThresholdClusterPRF2 = thresholdClusterPRF2; } | |
132 | void SetLimitChargeIntegration(Bool_t limitChargeIntegration) { fLimitChargeIntegration = limitChargeIntegration; } | |
133 | void SetFillWithZero(Bool_t fillWithZero) { fFillWithZero = fillWithZero; } | |
134 | void SetNormalizeNbOfCluster(Bool_t normalizeNbOfCluster) { fNormalizeNbOfCluster = normalizeNbOfCluster; } | |
135 | void SetMaxCluster(Float_t maxCluster) { fMaxCluster = maxCluster; } | |
136 | void SetNbMaxCluster(Short_t nbMaxCluster) { fNbMaxCluster = nbMaxCluster; } | |
137 | void SetNz(Int_t i, Short_t nz); | |
138 | void SetNrphi(Int_t i, Short_t nrphi); | |
139 | void SetAllTogether(Int_t i); | |
140 | void SetPerSuperModule(Int_t i); | |
141 | void SetProcent(Float_t procent) { fProcent = procent; } | |
142 | void SetDifference(Short_t difference) { fDifference = difference; } | |
143 | void SetNumberClusters(Short_t numberClusters) { if(numberClusters > 0) fNumberClusters = numberClusters; } | |
144 | void SetNumberClustersf(Short_t numberClustersf) { fNumberClustersf = numberClustersf; } | |
145 | void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; } | |
146 | void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; } | |
147 | void SetNumberGroupsPRF(Short_t numberGroupsPRF); | |
148 | ||
149 | Float_t GetRelativeScale() const { return fRelativeScale; } | |
150 | Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; } | |
151 | Bool_t GetLimitChargeIntegration() const { return fLimitChargeIntegration; } | |
152 | Bool_t GetFillWithZero() const { return fFillWithZero; } | |
153 | Bool_t GetNormalizeNbOfCluster() const { return fNormalizeNbOfCluster; } | |
154 | Float_t GetMaxCluster() const { return fMaxCluster; } | |
155 | Short_t GetNbMaxCluster() const { return fNbMaxCluster; } | |
156 | Float_t GetProcent() const { return fProcent; } | |
157 | Short_t GetDifference() const { return fDifference; } | |
158 | Short_t GetNumberClusters() const { return fNumberClusters; } | |
159 | Short_t GetNumberClustersf() const { return fNumberClustersf; } | |
160 | Short_t GetNumberBinCharge() const { return fNumberBinCharge; } | |
161 | Short_t GetNumberBinPRF() const { return fNumberBinPRF; } | |
162 | Short_t GetNumberGroupsPRF() const { return fNgroupprf; } | |
163 | Int_t *GetEntriesLinearFitter() const { return fEntriesLinearFitter; } | |
164 | ||
165 | // Debug | |
166 | void SetDebugLevel(Short_t level) { fDebugLevel = level; } | |
167 | ||
168 | // Vector method | |
169 | AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; } | |
170 | ||
171 | protected: | |
172 | ||
173 | // Geometry | |
174 | AliTRDgeometry *fGeo; //! The TRD geometry | |
175 | ||
176 | // Is HLT | |
177 | Bool_t fIsHLT; // Now if HLT, the per detector | |
178 | ||
179 | // Choice to fill or not the 2D | |
180 | Bool_t fMcmCorrectAngle; // Apply correction due to the mcmtrackletangle in the z direction (only) assuming from vertex | |
181 | Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration | |
182 | Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0 | |
183 | Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration | |
184 | Bool_t fHisto2d; // Chose to fill the 2D histos | |
185 | Bool_t fVector2d; // Chose to fill vectors | |
186 | Bool_t fLinearFitterOn; // Method with linear fit for drift velocity | |
187 | Bool_t fLinearFitterDebugOn; // Method with linear fit for drift velocity | |
188 | ||
189 | // How to fill the 2D | |
190 | Float_t fRelativeScale; // Scale of the deposited charge | |
191 | Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals | |
192 | Bool_t fLimitChargeIntegration; // Integration range for the gain calibration | |
193 | Bool_t fFillWithZero; // Fill with zero or not the average pulse height | |
194 | Bool_t fNormalizeNbOfCluster; // Normalize with the number of cluster for the gain | |
195 | Float_t fMaxCluster; // Max amplitude of one cluster | |
196 | Short_t fNbMaxCluster; // Number of tb at the end | |
197 | // Calibration mode | |
198 | AliTRDCalibraMode *fCalibraMode; // Calibration mode | |
199 | ||
200 | //For debugging | |
201 | TTreeSRedirector *fDebugStreamer; //!Debug streamer | |
202 | Short_t fDebugLevel; // Flag for debugging | |
203 | // | |
204 | // Internal variables | |
205 | // | |
206 | ||
207 | // Fill the 2D histos in the offline tracking | |
208 | Int_t fDetectorPreviousTrack; // Change of detector | |
209 | Int_t fMCMPrevious; // Change of MCM | |
210 | Int_t fROBPrevious; // Change of ROB | |
211 | Short_t fNumberClusters; // Minimum number of clusters in the tracklets | |
212 | Short_t fNumberClustersf; // Maximum number of clusters in the tracklets | |
213 | Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH) | |
214 | Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH) | |
215 | Int_t fNumberTrack; // How many tracks could be used (Debug for the moment) | |
216 | Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent) | |
217 | Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference) | |
218 | Int_t fTimeMax; // Number of time bins | |
219 | Float_t fSf; // Sampling frequence | |
220 | Short_t fNumberBinCharge; // Number of bins for the gain factor | |
221 | Short_t fNumberBinPRF; // Number of bin for the PRF | |
222 | Short_t fNgroupprf; // Number of groups in tnp bins for PRF /2.0 | |
223 | ||
224 | // Variables per tracklet | |
225 | Float_t *fAmpTotal; // Energy deposited in the calibration group by the track | |
226 | Short_t *fPHPlace; // Calibration group of PH | |
227 | Float_t *fPHValue; // PH | |
228 | Bool_t fGoodTracklet; // Good tracklet | |
229 | TLinearFitter *fLinearFitterTracklet; // linear fitter tracklet | |
230 | //Statistics | |
231 | Int_t *fEntriesCH; // Number of entries CH | |
232 | Int_t *fEntriesLinearFitter; // Number of entries LinearFitter | |
233 | ||
234 | ||
235 | // | |
236 | // Vector method | |
237 | // | |
238 | ||
239 | AliTRDCalibraVector *fCalibraVector; // The vector object | |
240 | ||
241 | ||
242 | // Histograms to store the info from the digits, from the tracklets or from the tracks | |
243 | TProfile2D *fPH2d; // 2D average pulse height | |
244 | TProfile2D *fPRF2d; // 2D PRF | |
245 | TH2I *fCH2d; // 2D deposited charge | |
246 | TObjArray fLinearFitterArray; // TObjArray of Linear Fitters for the detectors | |
247 | AliTRDCalibraVdriftLinearFit *fLinearVdriftFit; // Info Linear Fit | |
248 | ||
249 | // Current calib object: to correct for the database used | |
250 | AliTRDCalDet *fCalDetGain; // Current calib object gain | |
251 | AliTRDCalROC *fCalROCGain; // Current calib object gain | |
252 | ||
253 | // | |
254 | // A lot of internal functions...... | |
255 | // | |
256 | // Create the 2D histo to be filled Online | |
257 | void CreateCH2d(Int_t nn); | |
258 | void CreatePH2d(Int_t nn); | |
259 | void CreatePRF2d(Int_t nn); | |
260 | ||
261 | // Calibration with AliTRDtrackV1 | |
262 | void FillTheInfoOfTheTrackPH(); | |
263 | void FillTheInfoOfTheTrackCH(Int_t nbclusters); | |
264 | Bool_t FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index0, Int_t index1); | |
265 | Bool_t FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters); | |
266 | Bool_t HandlePRFtracklet(AliTRDtrack *t, Int_t index0, Int_t index1); | |
267 | Bool_t HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters); | |
268 | void ResetfVariablestracklet(); | |
269 | void StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl, Int_t *group, Int_t row, Int_t col); | |
270 | void FillCH2d(Int_t x, Float_t y); | |
271 | ||
272 | // Calibration on DAQ | |
273 | ||
274 | Int_t FillDAQ(Double_t phvalue[16][144][36]); | |
275 | Bool_t UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins); | |
276 | ||
277 | // row col calibration groups stuff | |
278 | Bool_t LocalisationDetectorXbins(Int_t detector); | |
279 | Int_t CalculateTotalNumberOfBins(Int_t i); | |
280 | void CheckGoodTrackletV0(Int_t detector, Int_t row, Int_t col); | |
281 | void CheckGoodTrackletV1(AliTRDcluster *cl); | |
282 | Int_t CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const; | |
283 | ||
284 | // Clear | |
285 | void ClearHistos(); | |
286 | ||
287 | // Some basic geometry function | |
288 | virtual Int_t GetLayer(Int_t d) const; | |
289 | virtual Int_t GetStack(Int_t d) const; | |
290 | virtual Int_t GetSector(Int_t d) const; | |
291 | ||
292 | ||
293 | // Instance of this class and so on | |
294 | static AliTRDCalibraFillHisto *fgInstance; // Instance | |
295 | static Bool_t fgTerminated; // If terminated | |
296 | ||
297 | private: | |
298 | ||
299 | // This is a singleton, contructor is private! | |
300 | AliTRDCalibraFillHisto(); | |
301 | virtual ~AliTRDCalibraFillHisto(); | |
302 | ||
303 | ClassDef(AliTRDCalibraFillHisto,4) // TRD Calibration class | |
304 | ||
305 | }; | |
306 | ||
307 | #endif | |
308 | ||
309 |