]>
Commit | Line | Data |
---|---|---|
77566f2a | 1 | #ifndef ALITRDCALIBRA_H |
2 | #define ALITRDCALIBRA_H | |
3 | ||
4 | #include <Riostream.h> | |
5 | #include <vector> | |
6 | ||
7 | #include <TProfile2D.h> | |
8 | #include <TF1.h> | |
9 | #include <TFile.h> | |
10 | #include <TROOT.h> | |
11 | #include <TLegend.h> | |
12 | #include <TMath.h> | |
13 | #include <TH2F.h> | |
14 | #include <TH1F.h> | |
15 | #include <TH1I.h> | |
16 | #include <TH2I.h> | |
17 | #include <TCanvas.h> | |
18 | #include <TAxis.h> | |
19 | #include <TLine.h> | |
20 | #include <TSystem.h> | |
21 | #include <TStyle.h> | |
22 | #include <TObject.h> | |
23 | #include <TLatex.h> | |
24 | #include <TChain.h> | |
25 | #include <TTree.h> | |
26 | #include <TObjArray.h> | |
27 | #include <TBranch.h> | |
28 | #include <TGraph.h> | |
29 | #include <TGraphErrors.h> | |
30 | #include <TObject.h> | |
31 | #include <TStopwatch.h> | |
32 | #include <TList.h> | |
33 | #include <TCollection.h> | |
34 | ||
35 | #include "AliRun.h" | |
36 | #include "AliRunLoader.h" | |
37 | #include "AliLoader.h" | |
38 | #include "AliCDBManager.h" | |
39 | #include "AliCDBEntry.h" | |
40 | #include "AliCDBId.h" | |
41 | #include "AliCDBMetaData.h" | |
42 | #include "AliCDBStorage.h" | |
43 | #include "AliRawReader.h" | |
44 | #include "../RAW/AliRawReaderFile.h" | |
45 | ||
46 | #include "AliTRD.h" | |
47 | #include "AliTRDgeometry.h" | |
48 | #include "AliTRDSimParam.h" | |
49 | #include "AliTRDCommonParam.h" | |
50 | #include "AliTRDcalibDB.h" | |
51 | #include "AliTRDdigitsManager.h" | |
52 | #include "AliTRDdigit.h" | |
53 | #include "AliTRDcluster.h" | |
54 | #include "AliTRDtrack.h" | |
55 | #include "AliTRDpadPlane.h" | |
56 | #include "AliTRDrawData.h" | |
57 | #include "AliTRDmcmTracklet.h" | |
58 | #include "../TRD/Cal/AliTRDCalDet.h" | |
59 | #include "../TRD/Cal/AliTRDCalDet.h" | |
60 | #include "../TRD/Cal/AliTRDCalPad.h" | |
61 | #include "../TRD/Cal/AliTRDCalROC.h" | |
62 | ||
63 | class TPInfo; | |
64 | class TCTInfo; | |
65 | class TFitCHInfo; | |
66 | ||
67 | class AliTRDCalibra : public TObject { | |
68 | public: | |
69 | ||
70 | // Instance | |
71 | static AliTRDCalibra* Instance(); | |
72 | static void Terminate(); | |
73 | static void Destroy(); | |
74 | ||
75 | AliTRDCalibra(const AliTRDCalibra &c); | |
76 | AliTRDCalibra &operator=(const AliTRDCalibra &) { return *this; } | |
77 | ||
78 | ||
79 | // Functions fit online | |
80 | Bool_t FitCHOnline(TH2I *ch); | |
81 | Bool_t FitCHOnline(); | |
82 | Bool_t FitCHOnline(TTree *tree); | |
83 | Bool_t FitPHOnline(TProfile2D *PH); | |
84 | Bool_t FitPHOnline(); | |
85 | Bool_t FitPHOnline(TTree *tree); | |
86 | Bool_t FitPRFOnline(TProfile2D *Prf); | |
87 | Bool_t FitPRFOnline(); | |
88 | Bool_t FitPRFOnline(TTree *tree); | |
89 | ||
90 | ||
91 | // Functions for initialising the AliTRDCalibra in the code | |
92 | Bool_t Init2Dhistos(); | |
93 | ||
94 | ||
95 | // Functions for filling the histos in the code | |
96 | Bool_t Resettrack(); | |
97 | Bool_t UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t); | |
98 | Bool_t UpdateHistogramcm(AliTRDmcmTracklet *fTrk); | |
99 | ||
100 | ||
101 | // Is Pad on | |
102 | Bool_t IsPadOn(Int_t detector, Int_t col, Int_t row); | |
103 | ||
104 | // Functions for plotting the 2D | |
105 | void Plot2d(); | |
106 | ||
107 | // Functions for writting the 2D | |
108 | Bool_t Write2d(); | |
109 | ||
110 | ||
111 | // Function fill 2D for the moment out of the code | |
112 | Bool_t Create2DDiSimOnline(Int_t iev1, Int_t iev2); | |
113 | Bool_t Create2DRaDaOnline(Int_t iev1, Int_t iev2); | |
114 | ||
115 | ||
116 | // Pad Calibration | |
117 | // From Nnz and Nnrphi calculates fNfragz and fNfragrphi | |
118 | Bool_t ModePadFragmentation(Int_t iPlane,Int_t iChamb, Int_t iSect, Int_t i); | |
119 | // From Nz and Nrphi calculates Nnz and Nnrphi | |
120 | void ModePadCalibration(Int_t iChamb, Int_t i); | |
121 | ||
122 | ||
123 | // Fill the database | |
124 | TObject* CreatePadObjectTree(TTree *tree); | |
125 | TObject* CreatePadObjectTree(TTree *tree, Int_t i, AliTRDCalDet *detobject); | |
126 | AliTRDCalDet* CreateDetObjectTree(TTree *tree, Int_t i); | |
127 | ||
128 | // Correct the error | |
129 | TH1F* CorrectTheError(TGraphErrors *hist); | |
130 | TGraphErrors* AddProfiles(TGraphErrors *hist1, TGraphErrors *hist2); | |
131 | ||
132 | // Add two trees | |
133 | TTree* Sum2Trees(const char* filename1, const char* filename2, const char *variablecali); | |
134 | ||
135 | ||
136 | // Set of Get the variables******************************************************************************* | |
137 | ||
138 | // Choice to fill or not the 2D | |
139 | void SetMItracking() { fMItracking = kTRUE; } | |
140 | void Setmcmtracking() { fmcmtracking = kTRUE; } | |
141 | void Setmcmcorrectangle() { fmcmcorrectangle = kTRUE; } | |
142 | void SetPH2dOn() { fPH2dOn = kTRUE; } | |
143 | void SetCH2dOn() { fCH2dOn = kTRUE; } | |
144 | void SetPRF2dOn() { fPRF2dOn = kTRUE; } | |
145 | void SetHisto2d() { fHisto2d = kTRUE; } | |
146 | void SetVector2d() { fVector2d = kTRUE; } | |
147 | ||
148 | Bool_t GetMItracking() const { return fMItracking; } | |
149 | Bool_t Getmcmtracking() const { return fmcmtracking; } | |
150 | Bool_t Getmcmcorrectangle() const { return fmcmcorrectangle; } | |
151 | Bool_t GetPH2dOn() const { return fPH2dOn; } | |
152 | Bool_t GetCH2dOn() const { return fCH2dOn; } | |
153 | Bool_t GetPRF2dOn() const { return fPRF2dOn; } | |
154 | Bool_t GetHisto2d() const { return fHisto2d; } | |
155 | Bool_t GetVector2d() const { return fVector2d; } | |
156 | TH2I *GetCH2d() const { return fCH2d; } | |
157 | TProfile2D *GetPH2d() const { return fPH2d; } | |
158 | TProfile2D *GetPRF2d() const { return fPRF2d; } | |
159 | ||
160 | ||
161 | ||
162 | // How to fill the 2D | |
163 | void SetRelativeScaleAuto() { fRelativeScaleAuto = kTRUE; } | |
164 | void SetRelativeScale(Float_t RelativeScale) { if (RelativeScale > 0.0) { | |
165 | fRelativeScale = RelativeScale; | |
166 | } | |
167 | else { | |
168 | AliInfo("RelativeScale must be strict positif!"); | |
169 | } } | |
170 | void SetThresholdDigit(Int_t digitthreshold) { fThresholddigit = digitthreshold; } | |
171 | void SetThresholdClusterPRF1(Float_t ThresholdClusterPRF1) { fThresholdClusterPRF1 = ThresholdClusterPRF1; } | |
172 | void SetThresholdClusterPRF2(Float_t ThresholdClusterPRF2) { fThresholdClusterPRF2 = ThresholdClusterPRF2; } | |
173 | void SetCenterOfflineCluster() { fCenterOfflineCluster = kTRUE; } | |
174 | void SetTraMaxPad() { fTraMaxPad = kTRUE; } | |
175 | void SetNz(Int_t i, Short_t Nz) { if ((Nz >= 0) && (Nz < 5)) { | |
176 | fNz[i] = Nz; | |
177 | } | |
178 | else { | |
179 | AliInfo("You have to choose between 0 and 4"); | |
180 | } } | |
181 | void SetNrphi(Int_t i, Short_t Nrphi) { if ((Nrphi >= 0) && (Nrphi < 7)) { | |
182 | fNrphi[i] = Nrphi; | |
183 | } | |
184 | else { | |
185 | AliInfo("You have to choose between 0 and 6"); | |
186 | } } | |
187 | void SetProcent(Float_t procent) { fprocent = procent; } | |
188 | void SetDifference(Short_t difference) { fdifference = difference; } | |
189 | void SetNumberClusters(Short_t NumberClusters) { fNumberClusters = NumberClusters; } | |
190 | void SetNumberBinCharge(Short_t NumberBinCharge) { fNumberBinCharge = NumberBinCharge; } | |
191 | void SetNumberBinPRF(Short_t NumberBinPRF) { fNumberBinPRF = NumberBinPRF; } | |
192 | ||
193 | Float_t GetRelativeScale() const { return fRelativeScale; } | |
194 | Bool_t GetRelativeScaleAuto() const { return fRelativeScaleAuto; } | |
195 | Int_t GetThresholdDigit() const { return fThresholddigit; } | |
196 | Float_t GetThresholdClusterPRF1() const { return fThresholdClusterPRF1; } | |
197 | Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; } | |
198 | Bool_t GetTraMaxPad()const { return fTraMaxPad; } | |
199 | Short_t GetNz(Int_t i) const { return fNz[i]; } | |
200 | Short_t GetNrphi(Int_t i) const { return fNrphi[i]; } | |
201 | Float_t GetProcent() const { return fprocent; } | |
202 | Short_t GetDifference() const { return fdifference; } | |
203 | Short_t GetNumberClusters() const { return fNumberClusters; } | |
204 | Short_t GetNumberBinCharge() const { return fNumberBinCharge; } | |
205 | Short_t GetNumberBinPRF() const { return fNumberBinPRF; } | |
206 | ||
207 | ||
208 | // Write | |
209 | void SetWriteCoef(Int_t i) { fWriteCoef[i] = kTRUE; } | |
210 | void SetWriteNameCoef(TString WriteNameCoef) { fWriteNameCoef = WriteNameCoef; } | |
211 | void SetWrite(Int_t i) { fWrite[i] = kTRUE; } | |
212 | void SetWriteName(TString WriteName) { fWriteName = WriteName; } | |
213 | ||
214 | Bool_t GetWriteCoef(Int_t i) const { return fWriteCoef[i]; } | |
215 | TString GetWriteNameCoef() const { return fWriteNameCoef; } | |
216 | Bool_t GetWrite(Int_t i) const { return fWrite[i]; } | |
217 | TString GetWriteName() const { return fWriteName; } | |
218 | ||
219 | ||
220 | // Fit | |
221 | void SetFitPHOn() { fFitPHOn = kTRUE;} | |
222 | void SetPeriodeFitPH(Int_t PeriodeFitPH) { if (PeriodeFitPH > 0) { | |
223 | fFitPHPeriode = PeriodeFitPH; | |
224 | } | |
225 | else { | |
226 | AliInfo("PeriodeFitPH must be higher than 0!"); | |
227 | } } | |
228 | void SetBeginFitCharge(Float_t BeginFitCharge) { if (BeginFitCharge > 0) { | |
229 | fBeginFitCharge = BeginFitCharge; | |
230 | } | |
231 | else { | |
232 | AliInfo("BeginFitCharge must be strict positif!"); | |
233 | } } | |
234 | void SetT0Shift(Float_t T0Shift) { if (T0Shift > 0) { | |
235 | fT0Shift = T0Shift; | |
236 | } | |
237 | else { | |
238 | AliInfo("T0Shift must be strict positif!"); | |
239 | } } | |
240 | void SetRangeFitPRF(Float_t RangeFitPRF) { if ((RangeFitPRF > 0) && | |
241 | (RangeFitPRF <= 1.0)) { | |
242 | fRangeFitPRF = RangeFitPRF; | |
243 | } | |
244 | else { | |
245 | AliInfo("RangeFitPRF must be between 0 and 1.0"); | |
246 | } } | |
247 | void SetMeanChargeOn() { fMeanChargeOn = kTRUE;} | |
248 | void SetFitChargeBisOn() { fFitChargeBisOn = kTRUE;} | |
249 | void SetMinEntries(Int_t MinEntries) { fMinEntries = MinEntries;} | |
250 | ||
251 | Bool_t GetFitPHOn() const { return fFitPHOn; } | |
252 | Int_t GetPeriodeFitPH() const { return fFitPHPeriode; } | |
253 | Float_t GetBeginFitCharge() const { return fBeginFitCharge; } | |
254 | Float_t GetT0Shift() const { return fT0Shift; } | |
255 | Float_t GetRangeFitPRF() const { return fRangeFitPRF; } | |
256 | Bool_t GetMeanChargeOn() const { return fMeanChargeOn; } | |
257 | Bool_t GetFitChargeBisOn() const { return fFitChargeBisOn; } | |
258 | Int_t GetMinEntries() const { return fMinEntries; } | |
259 | ||
260 | // Debug | |
261 | void SetDebug(Short_t Debug) { fDebug = Debug; } | |
262 | void SetDet(Int_t iPlane, Int_t iChamb, Int_t iSect) { fDet[0] = iPlane; | |
263 | fDet[1] = iChamb; | |
264 | fDet[2] = iSect; } | |
265 | void SetFitVoir(Int_t FitVoir) { fFitVoir = FitVoir; } | |
266 | ||
267 | Short_t GetDebug() const { return fDebug; } | |
268 | Int_t GetDet(Int_t i) const { return fDet[i]; } | |
269 | Int_t GetFitVoir() const { return fFitVoir; } | |
270 | ||
271 | // Internal variables to be sure!***************************************** | |
272 | ||
273 | // Pad calibration | |
274 | Short_t GetNnz(Int_t i) const { return fNnz[i]; } | |
275 | Short_t GetNnrphi(Int_t i) const { return fNnrphi[i]; } | |
276 | Short_t GetNfragz(Int_t i) const { return fNfragz[i]; } | |
277 | Short_t GetNfragrphi(Int_t i) const { return fNfragrphi[i]; } | |
278 | ||
279 | ||
280 | void SetRebin(Short_t Rebin) { if (Rebin > 0) { | |
281 | fRebin = Rebin; | |
282 | AliInfo("You have to be sure that fRebin divides fNumberBinCharge used!"); | |
283 | } | |
284 | else { | |
285 | AliInfo("You have to choose a positiv value!"); | |
286 | } } | |
287 | ||
288 | Short_t GetRebin() const { return fRebin; } | |
289 | ||
290 | // Getter for the coefficient trees*********************************** | |
291 | ||
292 | TTree *GetPRF() const { return fPRF; } | |
293 | TTree *GetGain() const { return fGain; } | |
294 | TTree *GetT0() const { return fT0; } | |
295 | TTree *GetVdrift() const { return fVdrift; } | |
296 | ||
297 | protected: | |
298 | ||
299 | // Instance of this class and so on | |
300 | static AliTRDCalibra* fgInstance; // Instance | |
301 | static Bool_t fgTerminated; | |
302 | ||
303 | ||
304 | // Choice to fill or not the 2D | |
305 | Bool_t fMItracking; // Chose to fill the 2D histos or vectors during the offline MI tracking | |
306 | Bool_t fmcmtracking; // Chose to fill the 2D histos or vectors during the tracking with tracklets | |
307 | Bool_t fmcmcorrectangle; // Apply correction due to the mcmtrackletangle in the z direction (only) assuming from vertex | |
308 | Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration | |
309 | Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0 | |
310 | Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration | |
311 | Bool_t fHisto2d; // Chose to fill the 2D histos | |
312 | Bool_t fVector2d; // Chose to fill vectors | |
313 | ||
314 | ||
315 | // How to fill the 2D | |
316 | Float_t fRelativeScale; // Scale of the deposited charge | |
317 | Int_t fCountRelativeScale; // fCountRelativeScale first data used for the scaling | |
318 | Bool_t fRelativeScaleAuto; // Scaling with the first fCountRelativeScale objects | |
319 | Int_t fThresholddigit; // Threshold on RawData | |
320 | Float_t fThresholdClusterPRF1; // Threshold on cluster pad signals for PRF peripherique | |
321 | Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals for PRF peripherique | |
322 | Bool_t fCenterOfflineCluster; // Choose to use the offline determination of the center of the cluster | |
323 | Bool_t fTraMaxPad; // Take the Max Pad for the gain calibration and PH | |
324 | Short_t fNz[3]; // Mode of calibration | |
325 | Short_t fNrphi[3]; // Mode of calibration | |
326 | Int_t fNtotal[3]; // Total number of Xbins | |
327 | ||
328 | ||
329 | // Write | |
330 | Bool_t fWriteCoef[3]; // Do you want to write the result in a file? | |
331 | TString fWriteNameCoef; // Where the coef Det are written | |
332 | Bool_t fWrite[3]; // Do you want to write the 2D histo or vectors converted in a tree | |
333 | TString fWriteName; // Where the 2D or trees are written | |
334 | ||
335 | ||
336 | // Fit | |
337 | Bool_t fFitPHOn; // The fit PH On | |
338 | Int_t fFitPHPeriode; // Periode of the fit PH | |
339 | Float_t fBeginFitCharge; // The fit begins at mean/fBeginFitCharge for the gain calibration | |
340 | Float_t fRangeFitPRF; // The fit range for the PRF is -fRangeFitPRF +fRangeFitPRF | |
341 | Bool_t fMeanChargeOn; // Mean Charge on | |
342 | Bool_t fFitChargeBisOn; // For an other fit function (convolution and not sum, more time consuming) | |
343 | Float_t fT0Shift; // T0 Shift with the actual method | |
344 | ||
345 | ||
346 | // Debug Mode | |
347 | Short_t fDebug; // For debugging 0 rien, 1 errors, 2 one fit alone, 3 one detector, 4 one detector with errors | |
348 | Int_t fDet[3]; // Detector visualised (plane,chamb,sect) si debugging == 3 or 4 | |
349 | Int_t fFitVoir; // Fit visualised si debugging == 2 | |
350 | ||
351 | ||
352 | // Internal variables************************************************* | |
353 | ||
354 | // Storage of coef | |
355 | TTree *fPRF; // Tree of the sigma of PRD | |
356 | TTree *fGain; // Tree of the gain factor | |
357 | TTree *fT0; // Tree of the time0 | |
358 | TTree *fVdrift; // Tree of the drift velocity | |
359 | ||
360 | // "Pointer" of the branch of the tree | |
361 | Int_t fVdriftDetector; // Branch of Vdrift | |
362 | Float_t *fVdriftPad; // Branch of Vdrift | |
363 | Int_t fT0Detector; // Branch of t0 | |
364 | Float_t *fT0Pad; // Branch of t0 | |
365 | Int_t fPRFDetector; // Branch of PRF | |
366 | Float_t *fPRFPad; // Branch of PRF | |
367 | Float_t *fcoefCH; // Branch relative gain | |
368 | ||
369 | // Fill the 2D histos in the offline tracking | |
370 | Bool_t fDetectorAliTRDtrack; // Change of track | |
371 | Int_t fChamberAliTRDtrack; // Change of chamber | |
372 | Int_t fDetectorprevioustrack; // Change of detector | |
373 | Bool_t fGoodTrack; // If goes through a kaputt pad | |
374 | Float_t *famptotal; // Energy deposited in the calibration group by the track | |
375 | Short_t *fPHplace; // Calibration group of PH | |
376 | Float_t *fPHvalue; // PH | |
377 | Short_t fNumberClusters; // Minimum number of clusters in the tracklets | |
378 | Float_t fprocent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH) | |
379 | Short_t fdifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH) | |
380 | Int_t fNumbertrack; // How many tracks could be used (Debug for the moment) | |
381 | Int_t fNumberusedch[2]; // How many tracks have been really used for the gain (0, strict; 1 with fprocent) | |
382 | Int_t fNumberusedph[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fdifference) | |
383 | ||
384 | ||
385 | // For debugging | |
386 | ||
387 | // Histograms to store the coef | |
388 | TH1F *fCoefCharge[4]; // Replica des 2D but in coefs resulting from the fit for the gain | |
389 | TH1F *fCoefVdrift[3]; // Replica des 2D but in coefs resulting from the fit for the drift velocity | |
390 | TH1F *fCoefPRF[2]; // Replica des 2D but in coefs resulting from the fit for the pad response function | |
391 | TH1F *fCoefT0[3]; // Replica des 2D but in coefs resulting from the fit for time 0 | |
392 | TH1F *fDeltaCharge[3]; // Replica des 2D but in errors for each detector resulting from the fit for the gain | |
393 | TH1F *fDeltaVdrift[2]; // Replica des 2D but in errors for each detector resulting from the fit for the drift velocity | |
394 | TH1F *fDeltaT0[2]; // Replica des 2D but in errors for each detector resulting from the fit for time 0 | |
395 | TH1F *fDeltaPRF; // Replica des 2D but in errors for each detector resulting from the fit for the pad response function | |
396 | TH1I *fErrorCharge[3]; // Replica des 2D but in errors resulting from the fit for the gain | |
397 | TH1I *fErrorVdrift[2]; // Replica des 2D but in errors resulting from the fit for the drift velocity | |
398 | TH1I *fErrorT0[2]; // Replica des 2D but in errors resulting from the fit for time 0 | |
399 | TH1I *fErrorPRF; // Replica des 2D but in errors resulting from the fit for the pad response function | |
400 | TH2F *fCoefChargeDB[3]; // Visualisation of the coef of the detecteur fDet for the gain | |
401 | TH2F *fCoefVdriftDB[2]; // Visualisation of the coef of the detecteur fDet for the drift velocity | |
402 | TH2F *fCoefT0DB[2]; // Visualisation of the coef of the detecteur fDet for time 0 | |
403 | TH2F *fCoefPRFDB; // Visualisation of the coef of the detecteur fDet for the pad response function | |
404 | ||
405 | ||
406 | // Variables in the loop for the coef or more general | |
407 | Float_t fChargeCoef[4]; // 3 database value, 0 fit, 1 mean, 2 fit time consuming | |
408 | Float_t fVdriftCoef[3]; // 2 database value, 1 slope method, 0 fit | |
409 | Float_t fPRFCoef[2]; // 1 database, 0 fit | |
410 | Float_t fT0Coef[3]; // 3 database, 1 slope method, 0 fit | |
411 | Float_t fPhd[3]; // Begin AR and DR | |
412 | Int_t fTimeMax; // Number of time bins | |
413 | Float_t fSf; // Sampling frequence | |
414 | Int_t fdect1[3]; // First calibration group that will be called to be maybe fitted | |
415 | Int_t fdect2[3]; // Last calibration group that will be called to be maybe fitted | |
416 | Double_t fScalefitfactor; // Scale factor of the fit results for the gain | |
417 | Int_t fMinEntries; // Min Entries to fit the histo | |
418 | Int_t fEntriesCurrent; // Entries in the current histo | |
419 | Int_t fcountdet[3]; // Current detector | |
420 | Int_t fcount[3]; // When the next detector comes | |
421 | Float_t fl3P0; // ???? | |
422 | Float_t fl3P2; // ???? | |
423 | Float_t fg3P2; // ???? | |
424 | ||
425 | ||
426 | // Pad Calibration | |
427 | Short_t fNnz[3]; // Number of pad rows in a group | |
428 | Short_t fNnrphi[3]; // Number of pad cols in a group | |
429 | Short_t fNfragz[3]; // Number of pad row group | |
430 | Short_t fNfragrphi[3]; // Number of pad col group | |
431 | Short_t frowmin[3]; // Limits of the group in pad row | |
432 | Short_t frowmax[3]; // Limits of the group in pad row | |
433 | Short_t fcolmin[3]; // Limits of the group in pad col | |
434 | Short_t fcolmax[3]; // Limits of the group in pad col | |
435 | Int_t fXbins[3]; // First Xbins of the detector | |
436 | Short_t fdetChamb0[3]; // Number of XBins for chamber != 2 | |
437 | Short_t fdetChamb2[3]; // Number of Xbins fir chamber 2 | |
438 | ||
439 | ||
440 | // Methode Alexandru store info | |
441 | class TCTInfo : public TObject { | |
442 | public: | |
443 | ||
444 | TCTInfo() | |
445 | :TObject() | |
446 | ,fentries(0x0) { } | |
447 | ||
448 | TCTInfo(const TCTInfo &i) | |
449 | :TObject(i) | |
450 | ,fentries(0x0) { } | |
451 | ||
452 | TCTInfo &operator=(const TCTInfo&) { return *this; } | |
453 | ||
454 | UShort_t *fentries; // ???? | |
455 | ||
456 | }; | |
457 | ||
458 | class TFitCHInfo : public TObject { | |
459 | public: | |
460 | ||
461 | TFitCHInfo() | |
462 | :TObject() | |
463 | ,fcoef(0x0) | |
464 | ,fDetector(-1) { } | |
465 | ||
466 | TFitCHInfo(const TFitCHInfo &i) | |
467 | :TObject(i) | |
468 | ,fcoef(0x0) | |
469 | ,fDetector(-1) { } | |
470 | ||
471 | TFitCHInfo &operator=(const TFitCHInfo&) { return *this; } | |
472 | ||
473 | Float_t *fcoef; // ???? | |
474 | Int_t fDetector; // ???? | |
475 | ||
476 | }; | |
477 | ||
478 | class TPInfo : public TObject { | |
479 | public: | |
480 | ||
481 | TPInfo() | |
482 | :TObject() | |
483 | ,fsum(0x0) | |
484 | ,fsumsquare(0x0) | |
485 | ,fentries(0x0) { } | |
486 | ||
487 | TPInfo(const TPInfo &i) | |
488 | :TObject(i) | |
489 | ,fsum(0x0) | |
490 | ,fsumsquare(0x0) | |
491 | ,fentries(0x0) { } | |
492 | ||
493 | TPInfo &operator=(const TPInfo&) { return *this; } | |
494 | ||
495 | Float_t *fsum; // ???? | |
496 | Float_t *fsumsquare; // ???? | |
497 | UShort_t *fentries; // ???? | |
498 | ||
499 | }; | |
500 | ||
501 | ||
502 | // PH | |
503 | // fTimeMax will define the size of fcharge | |
504 | std::vector<TPInfo *> fVectorPH; // Vectors to fill | |
505 | std::vector<Int_t> fPlaPH; // Vectors to fill | |
506 | // CH | |
507 | Short_t fNumberBinCharge; // Number of bins for the gain factor | |
508 | std::vector<TCTInfo *> fVectorCH; // Vectors to fill | |
509 | std::vector<Int_t> fPlaCH; // Vectors to fill | |
510 | // FitCH | |
511 | std::vector<TFitCHInfo *> fVectorFitCH; // Vectors to fit | |
512 | // PRF | |
513 | Short_t fNumberBinPRF; // Number of bin for the PRF | |
514 | std::vector<TPInfo *> fVectorPRF; // Vectors to fill | |
515 | std::vector<Int_t> fPlaPRF; // Vectors to fill | |
516 | ||
517 | ||
518 | // Histograms to store the info from the digits, from the tracklets or from the tracks | |
519 | TProfile2D *fPH2d; // 2D average pulse height | |
520 | TProfile2D *fPRF2d; // 2D PRF | |
521 | TH2I *fCH2d; // 2D deposited charge | |
522 | ||
523 | Short_t fRebin; // If you want to rebin the histo for the gain calibration | |
524 | ||
525 | ||
526 | // A lot of internal functions......************************************************* | |
527 | ||
528 | // Init AliTRDCalibra | |
529 | void Init(); | |
530 | ||
531 | ||
532 | // Create the 2D histo to be filled Online | |
533 | void CreateCH2d(Int_t Nn); | |
534 | void CreatePH2d(Int_t Nn); | |
535 | void CreatePRF2d(Int_t Nn); | |
536 | ||
537 | ||
538 | // Fill the 2D from mcmtracklet from the TRD.Track.root file and not yet in the code | |
539 | void FillTheInfoOfTheTrackPH(); | |
540 | void FillTheInfoOfTheTrackCH(); | |
541 | void Resetfvariables(); | |
542 | Bool_t LocalisationdetectorXbins(Int_t detector); | |
543 | ||
544 | ||
545 | // Plot the 2D | |
546 | void PlotCH2d(); | |
547 | void PlotPH2d(); | |
548 | void PlotPRF2d(); | |
549 | ||
550 | ||
551 | // Fit************************************************** | |
552 | ||
553 | // Create histos if fDebug == 1 or fDebug >=3 | |
554 | void CreateFitHistoPHDB(Int_t rowMax, Int_t colMax); | |
555 | void CreateFitHistoT0DB(Int_t rowMax, Int_t colMax); | |
556 | void CreateFitHistoCHDB(Int_t rowMax, Int_t colMax); | |
557 | void CreateFitHistoPRFDB(Int_t rowMax, Int_t colMax); | |
558 | void CreateFitHistoCH(Int_t Nbins, Double_t Low, Double_t High); | |
559 | void CreateFitHistoPH(Int_t Nbins, Double_t Low, Double_t High); | |
560 | void CreateFitHistoT0(Int_t Nbins, Double_t Low, Double_t High); | |
561 | void CreateFitHistoPRF(Int_t Nbins, Double_t Low, Double_t High); | |
562 | ||
563 | // CHFit functions | |
564 | Bool_t FillVectorFitCH(Int_t countdet); | |
565 | Bool_t InitFit(Int_t Nbins, Double_t lowedge, Double_t upedge, Int_t i); | |
566 | void Initfcountdetandfcount(Int_t i); | |
567 | void Updatefcountdetandfcount(Int_t idect, Int_t i); | |
568 | void Reconstructfitrowminrowmax(Int_t idect, Int_t i); | |
569 | Bool_t NotEnoughStatistic(Int_t idect, Int_t i); | |
570 | Bool_t FillInfosFit(Int_t idect, Int_t i); | |
571 | Bool_t WriteFitInfos(Int_t i); | |
572 | void NormierungCharge(); | |
573 | ||
574 | ||
575 | // Fill histos Errors from the delta histos | |
576 | void ErrorPH(); | |
577 | void ErrorT0(); | |
578 | void ErrorCH(); | |
579 | void ErrorPRF(); | |
580 | ||
581 | ||
582 | // Fill histos DB from the Coef histos | |
583 | void FillCoefChargeDB(); | |
584 | void FillCoefVdriftDB(); | |
585 | void FillCoefT0DB(); | |
586 | void FillCoefPRFDB(); | |
587 | ||
588 | ||
589 | // Plot histos CoefPRF Coef.... | |
590 | void PlotPH(); | |
591 | void PlotT0(); | |
592 | void PlotCH(); | |
593 | void PlotPRF(); | |
594 | ||
595 | ||
596 | // Plot histos DB | |
597 | void PlotPHDB(); | |
598 | void PlotT0DB(); | |
599 | void PlotCHDB(); | |
600 | void PlotPRFDB(); | |
601 | ||
602 | ||
603 | // Write the Coef, delta and error histos | |
604 | void WritePH(TFile *fout); | |
605 | void WriteT0(TFile *fout); | |
606 | void WriteCH(TFile *fout); | |
607 | void WritePRF(TFile *fout); | |
608 | ||
609 | ||
610 | //Write the DB histos | |
611 | void WritePHDB(TFile *fout); | |
612 | void WriteT0DB(TFile *fout); | |
613 | void WriteCHDB(TFile *fout); | |
614 | void WritePRFDB(TFile *fout); | |
615 | ||
616 | ||
617 | // Calculate the mean coefs from the database | |
618 | Bool_t CalculVdriftCoefMean(Int_t Dect, Int_t idect); | |
619 | Bool_t CalculChargeCoefMean(Int_t Dect, Int_t idect, Bool_t vrai); | |
620 | Bool_t CalculPRFCoefMean(Int_t Dect, Int_t idect); | |
621 | Bool_t CalculT0CoefMean(Int_t Dect, Int_t idect); | |
622 | ||
623 | ||
624 | // Pad group calibration mode | |
625 | void ReconstructionRowPadGroup(Int_t idect, Int_t i); | |
626 | void CalculXBins(Int_t idect, Int_t i); | |
627 | ||
628 | ||
629 | // Convertion vector, tree, histos.... | |
630 | Int_t SearchInVector(Int_t group, Int_t i); | |
631 | Int_t SearchInTreeVector(std::vector<Int_t> vectorplace, Int_t group); | |
632 | Int_t SearchBin(Float_t value, Int_t i); | |
633 | Bool_t UpdateVectorCH(Int_t group, Float_t value); | |
634 | Bool_t UpdateVectorPRF(Int_t group, Float_t x, Float_t y); | |
635 | Bool_t UpdateVectorPH(Int_t group, Int_t time, Float_t value); | |
636 | Bool_t UpdateVectorT0(Int_t group, Int_t time); | |
637 | TGraphErrors *ConvertVectorPHisto(TPInfo *fPInfo, const char* name); | |
638 | TH1F *ConvertVectorCTHisto(TCTInfo *fCTInfo, const char* name); | |
639 | TTree *ConvertVectorCTTreeHisto(std::vector<TCTInfo *> VectorCT, std::vector<Int_t> PlaCT, const char* name); | |
640 | TTree *ConvertVectorPTreeHisto(std::vector<TPInfo *> VectorP, std::vector<Int_t> PlaP, const char* name); | |
641 | std::vector<Int_t> ConvertTreeVector(TTree *tree); | |
642 | Bool_t MergeVectorCT(std::vector<TCTInfo* > VectorCT2, std::vector<Int_t> PlaCT2); | |
643 | Bool_t MergeVectorP(std::vector<TPInfo* > VectorP2, std::vector<Int_t> PlaP2, Int_t i); | |
644 | ||
645 | ||
646 | // Fit methods | |
647 | void FitBisCH(TH1* projch, Int_t idect); | |
648 | void FitCH(TH1* projch, Int_t idect); | |
649 | void FitPH(TH1* projPH, Int_t idect); | |
650 | void FitPRF(TH1* projPRF, Int_t idect); | |
651 | void FitPente(TH1* projPH, Int_t idect); | |
652 | TH1I *ReBin(TH1I* hist); | |
653 | TH1F *ReBin(TH1F* hist); | |
654 | ||
655 | ||
656 | // Clear | |
657 | void ClearHistos(); | |
658 | void ClearTree(); | |
c3ca0d98 | 659 | void ClearFile(){} |
77566f2a | 660 | |
661 | ||
662 | // Some basic geometry function | |
663 | virtual Int_t GetPlane(Int_t d) const; | |
664 | virtual Int_t GetChamber(Int_t d) const; | |
665 | virtual Int_t GetSector(Int_t d) const; | |
666 | ||
667 | // Init, Fill and Reset the variables to default value tree Gain, PRF, Vdrift and T0 | |
668 | void InittreePH(); | |
669 | void FilltreeVdrift(Int_t countdet); | |
670 | void InittreeT0(); | |
671 | void FilltreeT0(Int_t countdet); | |
672 | void InittreePRF(); | |
673 | void FilltreePRF(Int_t countdet); | |
674 | void ConvertVectorFitCHTree(); | |
675 | ||
676 | ||
677 | private: | |
678 | ||
679 | static Double_t PH(Double_t* x, Double_t* par); | |
680 | static Double_t AsymmGauss(Double_t* x, Double_t* par); | |
681 | static Double_t funcLandauGaus(Double_t* x, Double_t* par); | |
682 | static Double_t langaufun(Double_t *x, Double_t *par); | |
683 | TF1 *langaufit(TH1 *his, Double_t *fitrange, Double_t *startvalues | |
684 | , Double_t *parlimitslo, Double_t *parlimitshi, Double_t *fitparams | |
685 | , Double_t *fiterrors, Double_t *ChiSqr, Int_t *NDF); | |
686 | Int_t langaupro(Double_t *params, Double_t &maxx, Double_t &FWHM); | |
687 | ||
688 | // This is a singleton, contructor is private! | |
689 | AliTRDCalibra(); | |
690 | virtual ~AliTRDCalibra(); | |
691 | ||
692 | ClassDef(AliTRDCalibra, 1) // TRD Calibration class | |
693 | ||
694 | }; | |
695 | ||
696 | #endif | |
697 | ||
698 |