]>
Commit | Line | Data |
---|---|---|
8ec526a4 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
77566f2a | 17 | |
18 | ///////////////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // AliTRDCalibra | |
21 | // | |
22 | // This class is for the TRD calibration of the relative gain factor, the drift velocity, | |
23 | // the time 0 and the pad response function. | |
24 | // It can be used for the calibration per chamber but also per group of pads and eventually per pad. | |
25 | // The user has to choose with the functions SetNz and SetNrphi the precision of the calibration. | |
26 | //Begin_Html | |
8ec526a4 | 27 | /* |
28 | <br> | |
29 | <CENTER> | |
30 | <TABLE border=1> | |
31 | <TR><TD><center>Nz</center></TD><TD><center> 0 </center></TD><TD><center> 1 </center></TD><TD><center> 2 </center></TD><TD><center> 3 </center></TD><TD><center> 4 </center></TD></TR> | |
32 | <TR><TD><CENTER>group of row pads per detector</CENTER></TD><TD><CENTER>1</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>4</CENTER></TD><TD><CENTER>6(chamb2)<br> 8(others chambers)</CENTER></TD><TD><CENTER>12 (chamb2)<br> 16 (chamb0)</CENTER></TD></TR> | |
33 | <TR><TD><CENTER>row pads per group</CENTER></TD><TD><CENTER>12 (chamb2)<br> 16 (chamb0)</CENTER></TD><TD><CENTER>6 (chamb2)<br> 8 (chamb0)</CENTER></TD><TD><CENTER>3 (chamb2)<br> 4 (chamb0)</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>1</CENTER></TD></TR> | |
34 | <TR><TD><CENTER>~distance [cm]</CENTER></TD><TD><CENTER>106 (chamb2)<br> 130 (chamb0)</CENTER></TD><TD><CENTER>53 (chamb2)<br> 65 (chamb0)</CENTER></TD><TD><CENTER>26.5 (chamb2)<br> 32.5 (chamb0)</CENTER></TD><TD><CENTER>17 (chamb2)<br> 17 (chamb0)</CENTER></TD><TD><CENTER>9 (chamb2)<br> 9 (chamb0)</CENTER></TD></TR> | |
35 | <CAPTION>In the z direction</CAPTION> | |
36 | </TABLE> | |
37 | </CENTER> | |
38 | <CENTER> | |
39 | <br> | |
40 | <TABLE border=1> | |
41 | <TR><TD><center>Nrphi</center></TD><TD><center> 0 </center></TD><TD><center> 1 </center></TD><TD><center> 2 </center></TD><TD><center> 3 </center></TD><TD><center> 4 </center></TD><TD><center> 5 </center></TD><TD><center> 6 </center></TD></TR> | |
42 | <TR><TD><CENTER>group of col pads per detector</CENTER></TD><TD><CENTER>1</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>4</CENTER></TD><TD><CENTER>8</CENTER></TD><TD><CENTER>16</CENTER></TD><TD><center>36</center></TD><TD><center>144</center></TD></TR> | |
43 | <TR><TD><CENTER>col pads per group</CENTER></TD><TD><CENTER>144</CENTER></TD><TD><CENTER>72</CENTER></TD><TD><CENTER>36</CENTER></TD><TD><CENTER>18</CENTER></TD><TD><CENTER>9</CENTER></TD><TD><center>4</center></TD><TD><center>1</center></TD></TR> | |
44 | <TR><TD><CENTER>~distance [cm]</CENTER></TD><TD><CENTER>113.4</CENTER></TD><TD><CENTER>56.7</CENTER></TD><TD><CENTER>25.3</CENTER></TD><TD><CENTER>14.3</CENTER></TD><TD><CENTER>7.25</CENTER></TD><TD><center>3.2</center></TD><TD><center>0.8</center></TD></TR> | |
45 | <CAPTION>In the rphi direction</CAPTION> | |
46 | </TABLE> | |
47 | </CENTER> | |
48 | <br> | |
49 | */ | |
77566f2a | 50 | //End_Html |
51 | // | |
52 | // Fill histograms or vectors | |
53 | //---------------------------- | |
54 | // | |
55 | // 2D Histograms (Histo2d) or vectors (Vector2d), then converted in Trees, will be filled | |
56 | // from RAW DATA in a run or from reconstructed TRD tracks during the offline tracking | |
57 | // in the function "FollowBackProlongation" (AliTRDtracker) | |
58 | // Per default the functions to fill are off. | |
59 | // | |
60 | //Begin_Html | |
8ec526a4 | 61 | /* |
62 | Example of 2D histos for the relative gain (left) and the drift velocity (right) calibration of the sector 13 <br> | |
63 | <center> | |
64 | <img src="./gif/2dhisto.gif" width="600" height="350"><br> | |
65 | </center> | |
66 | */ | |
77566f2a | 67 | //End_Html |
68 | // | |
69 | // Fit the histograms to find the coefficients | |
70 | //--------------------------------------------- | |
71 | // | |
72 | // These 2D histograms or vectors (first converted in 1D histos) will be fitted | |
73 | // if they have enough entries, otherwise the (default) value of the choosen database | |
74 | // will be put. For the relative gain calibration the resulted factors will be globally | |
75 | // normalized to the gain factors of the choosen database. It unables to precise | |
76 | // previous calibration procedure. | |
77 | // The function SetDebug enables the user to see: | |
78 | // _fDebug = 0: nothing, only the values are written in the tree if wanted | |
79 | // _fDebug = 1: a comparaison of the coefficients found and the default values | |
80 | // in the choosen database. | |
81 | // fCoef , histogram of the coefs as function of the calibration group number | |
82 | // fDelta , histogram of the relative difference of the coef with the default | |
83 | // value in the database as function of the calibration group number | |
84 | // fError , dirstribution of this relative difference | |
85 | // _fDebug = 2: only the fit of the choosen calibration group fFitVoir (SetFitVoir) | |
86 | // _fDebug = 3: The coefficients in the choosen detector fDet (SetDet) as function of the | |
87 | // pad row and col number | |
88 | // _fDebug = 4; The coeffcicients in the choosen detector fDet (SetDet) like in the 3 but with | |
89 | // also the comparaison histograms of the 1 for this detector | |
90 | // | |
91 | //Begin_Html | |
8ec526a4 | 92 | /* |
93 | Example of fCoef for the relative gain calibration of the sector 13 <br> | |
94 | <center> | |
95 | <img src="./gif/coef.gif" width="400" height="460"> | |
96 | </center><br> | |
97 | Example of fDelta (right) and fError (left) for the relative gain calibration of the sector 13 <br> | |
98 | <center> | |
99 | <img src="./gif/detlaerror.gif" width="550" height="380"><br> | |
100 | </center> | |
101 | */ | |
77566f2a | 102 | //End_Html |
8ec526a4 | 103 | // |
77566f2a | 104 | // Author: |
105 | // R. Bailhache (R.Bailhache@gsi.de) | |
106 | // | |
107 | ////////////////////////////////////////////////////////////////////////////////////// | |
108 | ||
8ec526a4 | 109 | #include <TTree.h> |
110 | #include <TLine.h> | |
111 | #include <TH1I.h> | |
112 | #include <TStyle.h> | |
113 | #include <TProfile2D.h> | |
114 | #include <TFile.h> | |
115 | #include <TCanvas.h> | |
116 | #include <TGraphErrors.h> | |
117 | #include <TObjArray.h> | |
118 | #include <TChain.h> | |
119 | #include <TH1.h> | |
120 | #include <TH1I.h> | |
121 | #include <TH1F.h> | |
122 | #include <TF1.h> | |
123 | #include <TH2F.h> | |
124 | #include <TAxis.h> | |
125 | #include <TStopwatch.h> | |
126 | #include <TMath.h> | |
127 | #include <TLegend.h> | |
128 | #include <TDirectory.h> | |
129 | #include <TROOT.h> | |
130 | ||
131 | #include "AliLog.h" | |
132 | #include "AliCDBManager.h" | |
133 | #include "AliRun.h" | |
134 | #include "AliRunLoader.h" | |
135 | #include "AliLoader.h" | |
136 | #include "AliRawReaderFile.h" | |
137 | #include "AliRawReader.h" | |
77566f2a | 138 | |
139 | #include "AliTRDCalibra.h" | |
8ec526a4 | 140 | #include "AliTRDcalibDB.h" |
141 | #include "AliTRDCommonParam.h" | |
142 | #include "AliTRDmcmTracklet.h" | |
143 | #include "AliTRDpadPlane.h" | |
144 | #include "AliTRDcluster.h" | |
145 | #include "AliTRDtrack.h" | |
146 | #include "AliTRDdigit.h" | |
147 | #include "AliTRDdigitsManager.h" | |
148 | #include "AliTRD.h" | |
149 | #include "AliTRDgeometry.h" | |
150 | #include "./Cal/AliTRDCalROC.h" | |
151 | #include "./Cal/AliTRDCalPad.h" | |
152 | #include "./Cal/AliTRDCalDet.h" | |
153 | #include "AliTRDrawData.h" | |
77566f2a | 154 | |
155 | ClassImp(AliTRDCalibra) | |
156 | ||
157 | AliTRDCalibra* AliTRDCalibra::fgInstance = 0; | |
158 | Bool_t AliTRDCalibra::fgTerminated = kFALSE; | |
159 | ||
160 | //_____________singleton implementation_________________________________________________ | |
8ec526a4 | 161 | AliTRDCalibra *AliTRDCalibra::Instance() |
77566f2a | 162 | { |
163 | // | |
164 | // Singleton implementation | |
165 | // | |
166 | ||
8ec526a4 | 167 | if (fgTerminated != kFALSE) { |
77566f2a | 168 | return 0; |
8ec526a4 | 169 | } |
77566f2a | 170 | |
8ec526a4 | 171 | if (fgInstance == 0) { |
77566f2a | 172 | fgInstance = new AliTRDCalibra(); |
8ec526a4 | 173 | } |
77566f2a | 174 | |
175 | return fgInstance; | |
176 | ||
177 | } | |
178 | ||
179 | //______________________________________________________________________________________ | |
180 | void AliTRDCalibra::Terminate() | |
181 | { | |
182 | // | |
183 | // Singleton implementation | |
184 | // Deletes the instance of this class | |
185 | // | |
186 | ||
187 | fgTerminated = kTRUE; | |
188 | ||
189 | if (fgInstance != 0) { | |
190 | delete fgInstance; | |
191 | fgInstance = 0; | |
192 | } | |
193 | ||
194 | } | |
195 | ||
196 | //______________________________________________________________________________________ | |
197 | AliTRDCalibra::AliTRDCalibra() | |
198 | :TObject() | |
8ec526a4 | 199 | ,fMITracking(kFALSE) |
200 | ,fMcmTracking(kFALSE) | |
201 | ,fMcmCorrectAngle(kFALSE) | |
77566f2a | 202 | ,fCH2dOn(kFALSE) |
203 | ,fPH2dOn(kFALSE) | |
204 | ,fPRF2dOn(kFALSE) | |
205 | ,fHisto2d(kFALSE) | |
206 | ,fVector2d(kFALSE) | |
207 | ,fRelativeScale(0) | |
208 | ,fCountRelativeScale(0) | |
209 | ,fRelativeScaleAuto(kFALSE) | |
8ec526a4 | 210 | ,fThresholdDigit(0) |
77566f2a | 211 | ,fThresholdClusterPRF1(0.0) |
212 | ,fThresholdClusterPRF2(0.0) | |
213 | ,fCenterOfflineCluster(kFALSE) | |
214 | ,fTraMaxPad(kFALSE) | |
215 | ,fWriteNameCoef(0) | |
216 | ,fWriteName(0) | |
217 | ,fFitPHOn(kFALSE) | |
218 | ,fFitPHPeriode(0) | |
219 | ,fBeginFitCharge(0.0) | |
220 | ,fRangeFitPRF(0.0) | |
221 | ,fMeanChargeOn(kFALSE) | |
222 | ,fFitChargeBisOn(kFALSE) | |
223 | ,fT0Shift(0.0) | |
8ec526a4 | 224 | ,fAccCDB(kFALSE) |
225 | ,fNumberFit(0) | |
226 | ,fStatisticMean(0.0) | |
77566f2a | 227 | ,fDebug(0) |
228 | ,fFitVoir(0) | |
229 | ,fPRF(0) | |
230 | ,fGain(0) | |
231 | ,fT0(0) | |
232 | ,fVdrift(0) | |
233 | ,fVdriftDetector(0) | |
234 | ,fVdriftPad(0x0) | |
235 | ,fT0Detector(0) | |
236 | ,fT0Pad(0x0) | |
237 | ,fPRFDetector(0) | |
238 | ,fPRFPad(0x0) | |
8ec526a4 | 239 | ,fCoefCH(0x0) |
77566f2a | 240 | ,fDetectorAliTRDtrack(kFALSE) |
241 | ,fChamberAliTRDtrack(-1) | |
8ec526a4 | 242 | ,fDetectorPreviousTrack(-1) |
77566f2a | 243 | ,fGoodTrack(kTRUE) |
8ec526a4 | 244 | ,fAmpTotal(0x0) |
245 | ,fPHPlace(0x0) | |
246 | ,fPHValue(0x0) | |
77566f2a | 247 | ,fNumberClusters(0) |
8ec526a4 | 248 | ,fProcent(0.0) |
249 | ,fDifference(0) | |
250 | ,fNumberTrack(0) | |
77566f2a | 251 | ,fDeltaPRF(0) |
252 | ,fErrorPRF(0) | |
253 | ,fCoefPRFDB(0) | |
254 | ,fTimeMax(0) | |
255 | ,fSf(0.0) | |
8ec526a4 | 256 | ,fScaleFitFactor(0.0) |
77566f2a | 257 | ,fMinEntries(0) |
258 | ,fEntriesCurrent(0) | |
8ec526a4 | 259 | ,fL3P0(0.0) |
260 | ,fL3P2(0.0) | |
261 | ,fG3P2(0.0) | |
77566f2a | 262 | ,fVectorPH(0) |
263 | ,fPlaPH(0) | |
264 | ,fNumberBinCharge(0) | |
265 | ,fVectorCH(0) | |
266 | ,fPlaCH(0) | |
267 | ,fVectorFitCH(0) | |
268 | ,fNumberBinPRF(0) | |
269 | ,fVectorPRF(0) | |
270 | ,fPlaPRF(0) | |
271 | ,fPH2d(0x0) | |
272 | ,fPRF2d(0x0) | |
273 | ,fCH2d(0x0) | |
274 | ,fRebin(0) | |
275 | { | |
276 | // | |
277 | // Default constructor | |
278 | // | |
279 | ||
280 | for (Int_t i = 0; i < 3; i++) { | |
281 | fNz[i] = 0; | |
282 | fNrphi[i] = 0; | |
283 | } | |
284 | ||
285 | for (Int_t k = 0; k < 3; k++) { | |
286 | fNtotal[k] = 0; | |
8ec526a4 | 287 | fDetChamb2[k] = 0; |
288 | fDetChamb0[k] = 0; | |
77566f2a | 289 | } |
290 | ||
291 | // Write | |
292 | for (Int_t i = 0; i < 3; i++) { | |
293 | fWriteCoef[i] = kFALSE; | |
294 | fWrite[i] = kFALSE; | |
295 | } | |
296 | ||
297 | // Debug Mode | |
298 | for (Int_t k = 0; k < 3; k++) { | |
299 | fDet[k] = 0; | |
300 | } | |
301 | ||
302 | for (Int_t i = 0; i < 2; i++) { | |
303 | fPhd[i] = 0.0; | |
304 | } | |
77566f2a | 305 | |
306 | // Init | |
307 | Init(); | |
308 | ||
309 | } | |
310 | ||
311 | //______________________________________________________________________________________ | |
312 | AliTRDCalibra::AliTRDCalibra(const AliTRDCalibra &c) | |
313 | :TObject(c) | |
8ec526a4 | 314 | ,fMITracking(kFALSE) |
315 | ,fMcmTracking(kFALSE) | |
316 | ,fMcmCorrectAngle(kFALSE) | |
77566f2a | 317 | ,fCH2dOn(kFALSE) |
318 | ,fPH2dOn(kFALSE) | |
319 | ,fPRF2dOn(kFALSE) | |
320 | ,fHisto2d(kFALSE) | |
321 | ,fVector2d(kFALSE) | |
322 | ,fRelativeScale(0) | |
323 | ,fCountRelativeScale(0) | |
324 | ,fRelativeScaleAuto(kFALSE) | |
8ec526a4 | 325 | ,fThresholdDigit(0) |
77566f2a | 326 | ,fThresholdClusterPRF1(0.0) |
327 | ,fThresholdClusterPRF2(0.0) | |
328 | ,fCenterOfflineCluster(kFALSE) | |
329 | ,fTraMaxPad(kFALSE) | |
330 | ,fWriteNameCoef(0) | |
331 | ,fWriteName(0) | |
332 | ,fFitPHOn(kFALSE) | |
333 | ,fFitPHPeriode(0) | |
334 | ,fBeginFitCharge(0.0) | |
335 | ,fRangeFitPRF(0.0) | |
336 | ,fMeanChargeOn(kFALSE) | |
337 | ,fFitChargeBisOn(kFALSE) | |
338 | ,fT0Shift(0.0) | |
8ec526a4 | 339 | ,fAccCDB(kFALSE) |
340 | ,fNumberFit(0) | |
341 | ,fStatisticMean(0.0) | |
77566f2a | 342 | ,fDebug(0) |
343 | ,fFitVoir(0) | |
344 | ,fPRF(0) | |
345 | ,fGain(0) | |
346 | ,fT0(0) | |
347 | ,fVdrift(0) | |
348 | ,fVdriftDetector(0) | |
349 | ,fVdriftPad(0x0) | |
350 | ,fT0Detector(0) | |
351 | ,fT0Pad(0x0) | |
352 | ,fPRFDetector(0) | |
353 | ,fPRFPad(0x0) | |
8ec526a4 | 354 | ,fCoefCH(0x0) |
77566f2a | 355 | ,fDetectorAliTRDtrack(kFALSE) |
356 | ,fChamberAliTRDtrack(-1) | |
8ec526a4 | 357 | ,fDetectorPreviousTrack(-1) |
77566f2a | 358 | ,fGoodTrack(kTRUE) |
8ec526a4 | 359 | ,fAmpTotal(0x0) |
360 | ,fPHPlace(0x0) | |
361 | ,fPHValue(0x0) | |
77566f2a | 362 | ,fNumberClusters(0) |
8ec526a4 | 363 | ,fProcent(0.0) |
364 | ,fDifference(0) | |
365 | ,fNumberTrack(0) | |
77566f2a | 366 | ,fDeltaPRF(0) |
367 | ,fErrorPRF(0) | |
368 | ,fCoefPRFDB(0) | |
369 | ,fTimeMax(0) | |
370 | ,fSf(0.0) | |
8ec526a4 | 371 | ,fScaleFitFactor(0.0) |
77566f2a | 372 | ,fMinEntries(0) |
373 | ,fEntriesCurrent(0) | |
8ec526a4 | 374 | ,fL3P0(0.0) |
375 | ,fL3P2(0.0) | |
376 | ,fG3P2(0.0) | |
77566f2a | 377 | ,fVectorPH(0) |
378 | ,fPlaPH(0) | |
379 | ,fNumberBinCharge(0) | |
380 | ,fVectorCH(0) | |
381 | ,fPlaCH(0) | |
382 | ,fVectorFitCH(0) | |
383 | ,fNumberBinPRF(0) | |
384 | ,fVectorPRF(0) | |
385 | ,fPlaPRF(0) | |
386 | ,fPH2d(0x0) | |
387 | ,fPRF2d(0x0) | |
388 | ,fCH2d(0x0) | |
389 | ,fRebin(0) | |
390 | { | |
391 | // | |
392 | // Copy constructor | |
393 | // | |
394 | ||
395 | } | |
396 | ||
397 | //____________________________________________________________________________________ | |
398 | AliTRDCalibra::~AliTRDCalibra() | |
399 | { | |
400 | // | |
401 | // AliTRDCalibra destructor | |
402 | // | |
403 | ||
404 | ClearHistos(); | |
405 | ClearTree(); | |
77566f2a | 406 | |
407 | } | |
408 | ||
409 | //_____________________________________________________________________________ | |
410 | void AliTRDCalibra::Destroy() | |
411 | { | |
412 | // | |
8ec526a4 | 413 | // Delete instance |
77566f2a | 414 | // |
415 | ||
416 | if (fgInstance) { | |
77566f2a | 417 | delete fgInstance; |
418 | fgInstance = 0x0; | |
419 | } | |
8ec526a4 | 420 | |
77566f2a | 421 | } |
422 | ||
423 | //_____________________________________________________________________________ | |
424 | void AliTRDCalibra::ClearHistos() | |
425 | { | |
426 | // | |
8ec526a4 | 427 | // Delete the histos |
77566f2a | 428 | // |
429 | ||
8ec526a4 | 430 | if (fPH2d) { |
77566f2a | 431 | delete fPH2d; |
8ec526a4 | 432 | fPH2d = 0x0; |
77566f2a | 433 | } |
8ec526a4 | 434 | if (fCH2d) { |
77566f2a | 435 | delete fCH2d; |
8ec526a4 | 436 | fCH2d = 0x0; |
77566f2a | 437 | } |
8ec526a4 | 438 | if (fPRF2d) { |
77566f2a | 439 | delete fPRF2d; |
440 | fPRF2d = 0x0; | |
441 | } | |
442 | ||
443 | } | |
444 | ||
445 | //_____________________________________________________________________________ | |
446 | void AliTRDCalibra::ClearTree() | |
447 | { | |
448 | // | |
8ec526a4 | 449 | // Delete the trees |
77566f2a | 450 | // |
451 | ||
8ec526a4 | 452 | if (fPRF) { |
77566f2a | 453 | delete fPRF; |
8ec526a4 | 454 | fPRF = 0x0; |
77566f2a | 455 | } |
8ec526a4 | 456 | if (fGain) { |
77566f2a | 457 | delete fGain; |
8ec526a4 | 458 | fGain = 0x0; |
77566f2a | 459 | } |
8ec526a4 | 460 | if (fT0) { |
77566f2a | 461 | delete fT0; |
8ec526a4 | 462 | fT0 = 0x0; |
77566f2a | 463 | } |
8ec526a4 | 464 | if (fVdrift) { |
77566f2a | 465 | delete fVdrift; |
466 | fVdrift = 0x0; | |
467 | } | |
468 | ||
469 | } | |
470 | ||
471 | //_____________________________________________________________________________ | |
472 | void AliTRDCalibra::Init() | |
473 | { | |
474 | // | |
475 | // Init some default values | |
476 | // | |
477 | ||
8ec526a4 | 478 | // How to fill the 2D |
479 | fThresholdDigit = 5; | |
77566f2a | 480 | fThresholdClusterPRF1 = 2.0; |
481 | fThresholdClusterPRF2 = 20.0; | |
482 | ||
8ec526a4 | 483 | // Store the Info |
484 | fNumberBinCharge = 100; | |
485 | fNumberBinPRF = 20; | |
77566f2a | 486 | |
8ec526a4 | 487 | // Write |
488 | fWriteName = "TRD.calibration.root"; | |
489 | fWriteNameCoef = "TRD.coefficient.root"; | |
490 | ||
491 | // Fit | |
492 | fFitPHPeriode = 1; | |
493 | fBeginFitCharge = 3.5; | |
494 | fRangeFitPRF = 0.5; | |
495 | fMinEntries = 800; | |
496 | fT0Shift = 0.143397; | |
497 | ||
498 | // Internal variables | |
499 | ||
500 | // Fill the 2D histos in the offline tracking | |
501 | fDetectorPreviousTrack = -1; | |
502 | fChamberAliTRDtrack = -1; | |
503 | fGoodTrack = kTRUE; | |
504 | ||
505 | fProcent = 6.0; | |
506 | fDifference = 17; | |
507 | fNumberClusters = 18; | |
508 | fNumberTrack = 0; | |
509 | fNumberUsedCh[0] = 0; | |
510 | fNumberUsedCh[1] = 0; | |
511 | fNumberUsedPh[0] = 0; | |
512 | fNumberUsedPh[1] = 0; | |
513 | ||
514 | // Variables in the loop | |
515 | for (Int_t k = 0; k < 4; k++) { | |
77566f2a | 516 | fChargeCoef[k] = 1.0; |
517 | fVdriftCoef[k] = 1.5; | |
8ec526a4 | 518 | fT0Coef[k] = -1.0; |
77566f2a | 519 | } |
8ec526a4 | 520 | for (Int_t i = 0; i < 2; i++) { |
521 | fPRFCoef[i] = -1.0; | |
77566f2a | 522 | } |
523 | ||
8ec526a4 | 524 | // Pad calibration |
525 | for (Int_t i = 0; i < 3; i++) { | |
526 | fRowMin[i] = -1; | |
527 | fRowMax[i] = -1; | |
528 | fColMax[i] = -1; | |
529 | fColMin[i] = -1; | |
530 | fNnZ[i] = -1; | |
531 | fNnRphi[i] = -1; | |
532 | fNfragZ[i] = -1; | |
533 | fNfragRphi[i] = -1; | |
534 | fXbins[i] = -1; | |
535 | } | |
536 | ||
537 | // Local database to be changed | |
77566f2a | 538 | fRebin = 1; |
539 | ||
540 | } | |
541 | ||
8ec526a4 | 542 | //____________Functions fit Online CH2d________________________________________ |
543 | Bool_t AliTRDCalibra::FitCHOnline(TH2I *ch) | |
77566f2a | 544 | { |
545 | // | |
8ec526a4 | 546 | // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each |
547 | // calibration group normalized the resulted coefficients (to 1 normally) | |
548 | // and write the results in a tree | |
77566f2a | 549 | // |
77566f2a | 550 | |
8ec526a4 | 551 | // Number of Xbins (detectors or groups of pads) |
552 | TAxis *xch = ch->GetXaxis(); | |
553 | Int_t nbins = xch->GetNbins(); | |
554 | TAxis *yph = ch->GetYaxis(); | |
555 | Int_t nybins = yph->GetNbins(); | |
77566f2a | 556 | Double_t lowedge = xch->GetBinLowEdge(1); |
8ec526a4 | 557 | Double_t upedge = xch->GetBinUpEdge(xch->GetNbins()); |
558 | if (!InitFit(nbins,lowedge,upedge,0)) { | |
77566f2a | 559 | return kFALSE; |
560 | } | |
8ec526a4 | 561 | fStatisticMean = 0.0; |
562 | fNumberFit = 0; | |
77566f2a | 563 | |
8ec526a4 | 564 | // For memory |
565 | if (fVectorCH) { | |
566 | fVectorCH->Clear(); | |
567 | } | |
568 | if (fPlaCH) { | |
569 | fPlaCH->Clear(); | |
77566f2a | 570 | } |
77566f2a | 571 | |
8ec526a4 | 572 | // Init fCountDet and fCount |
573 | InitfCountDetAndfCount(0); | |
574 | ||
575 | // Beginning of the loop betwwen dect1 and dect2 | |
576 | for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) { | |
77566f2a | 577 | |
8ec526a4 | 578 | TH1I *projch = (TH1I *) ch->ProjectionY("projch",idect+1,idect+1,(Option_t *)"e"); |
77566f2a | 579 | projch->SetDirectory(0); |
580 | ||
8ec526a4 | 581 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
582 | UpdatefCountDetAndfCount(idect,0); | |
77566f2a | 583 | |
8ec526a4 | 584 | // Reconstruction of the row and pad group: rowmin, row max ... |
585 | ReconstructFitRowMinRowMax(idect, 0); | |
77566f2a | 586 | |
8ec526a4 | 587 | // Number of entries for this calibration group |
77566f2a | 588 | Double_t nentries = 0.0; |
8ec526a4 | 589 | for (Int_t k = 0; k < nybins; k++) { |
77566f2a | 590 | nentries += ch->GetBinContent(ch->GetBin(idect+1,k+1)); |
591 | } | |
592 | ||
8ec526a4 | 593 | // Rebin and statistic stuff |
594 | // Rebin | |
595 | if (fRebin > 1) { | |
596 | projch = ReBin((TH1I *) projch); | |
597 | } | |
598 | // This detector has not enough statistics or was off | |
599 | if (nentries < fMinEntries) { | |
600 | // Fill with the default infos | |
77566f2a | 601 | NotEnoughStatistic(idect,0); |
8ec526a4 | 602 | // Memory!!! |
603 | if (fDebug != 2) { | |
77566f2a | 604 | delete projch; |
605 | } | |
606 | continue; | |
607 | } | |
608 | ||
8ec526a4 | 609 | // Statistics of the group fitted |
610 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
611 | fStatisticMean += nentries; | |
612 | fNumberFit++; | |
77566f2a | 613 | |
8ec526a4 | 614 | // Method Mean and fit |
615 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
616 | FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
617 | // Method fit bis | |
618 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
619 | if (fFitChargeBisOn) { | |
620 | FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
77566f2a | 621 | } |
622 | ||
8ec526a4 | 623 | // Visualise the detector for fDebug 3 or 4 |
624 | // Here is the reconstruction of the pad and row group is used! | |
625 | if (fDebug >= 3) { | |
626 | FillCoefChargeDB(); | |
627 | } | |
628 | // Fill Infos Fit | |
77566f2a | 629 | FillInfosFit(idect,0); |
630 | ||
8ec526a4 | 631 | // Memory!!! |
632 | if (fDebug != 2) { | |
77566f2a | 633 | delete projch; |
634 | } | |
635 | ||
8ec526a4 | 636 | } // Boucle object |
77566f2a | 637 | |
8ec526a4 | 638 | // Normierungcharge |
639 | if (fDebug != 2) { | |
640 | NormierungCharge(); | |
641 | } | |
77566f2a | 642 | |
8ec526a4 | 643 | // Error |
644 | if ((fDebug == 1) || | |
645 | (fDebug == 4)) { | |
646 | ErrorCH(); | |
647 | } | |
77566f2a | 648 | |
8ec526a4 | 649 | // Plot |
650 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
651 | if ((fDebug == 1) || | |
652 | (fDebug == 4)) { | |
77566f2a | 653 | PlotCH(); |
8ec526a4 | 654 | } |
655 | if ((fDebug == 4) || | |
656 | (fDebug == 3)) { | |
77566f2a | 657 | PlotCHDB(); |
8ec526a4 | 658 | } |
77566f2a | 659 | |
8ec526a4 | 660 | // Mean Statistic |
661 | if (fNumberFit > 0) { | |
662 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean/fNumberFit)); | |
663 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 664 | } |
665 | else { | |
666 | AliInfo("There is no fit!"); | |
667 | } | |
668 | ||
8ec526a4 | 669 | // Write the things! |
77566f2a | 670 | ConvertVectorFitCHTree(); |
8ec526a4 | 671 | if (fWriteCoef[0]) { |
77566f2a | 672 | WriteFitInfos(0); |
673 | } | |
8ec526a4 | 674 | |
77566f2a | 675 | return kTRUE; |
676 | ||
677 | } | |
77566f2a | 678 | |
8ec526a4 | 679 | //____________Functions fit Online CH2d________________________________________ |
77566f2a | 680 | Bool_t AliTRDCalibra::FitCHOnline() |
681 | { | |
682 | // | |
8ec526a4 | 683 | // Reconstruct a 1D histo from the vectorCH for each calibration group, |
684 | // fit the histo, normalized the resulted coefficients (to 1 normally) | |
685 | // and write the results in a tree | |
77566f2a | 686 | // |
687 | ||
8ec526a4 | 688 | // Number of Xbins (detectors or groups of pads) |
689 | if (!InitFit(0,0,0,0)) { | |
77566f2a | 690 | return kFALSE; |
691 | } | |
8ec526a4 | 692 | fStatisticMean = 0.0; |
693 | fNumberFit = 0; | |
77566f2a | 694 | |
8ec526a4 | 695 | // Init fCountDet and fCount |
696 | InitfCountDetAndfCount(0); | |
77566f2a | 697 | |
8ec526a4 | 698 | // Beginning of the loop between dect1 and dect2 |
699 | for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) { | |
77566f2a | 700 | |
8ec526a4 | 701 | // Search if the group is in the VectorCH |
77566f2a | 702 | Int_t place = SearchInVector(idect,0); |
703 | ||
8ec526a4 | 704 | // Is in |
705 | TH1F *projch = 0x0; | |
77566f2a | 706 | TString name("CH"); |
707 | name += idect; | |
8ec526a4 | 708 | if (place != -1) { |
709 | // Variable | |
710 | AliTRDCTInfo *fCHInfo = new AliTRDCTInfo(); | |
711 | // Retrieve | |
712 | fCHInfo = ((AliTRDCTInfo *) fVectorCH->At(place)); | |
713 | projch = ConvertVectorCTHisto(fCHInfo,(const char *) name); | |
77566f2a | 714 | projch->SetDirectory(0); |
715 | delete fCHInfo; | |
716 | } | |
717 | ||
8ec526a4 | 718 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
719 | UpdatefCountDetAndfCount(idect,0); | |
77566f2a | 720 | |
8ec526a4 | 721 | // Reconstruction of the row and pad group: rowmin, row max ... |
722 | ReconstructFitRowMinRowMax(idect,0); | |
77566f2a | 723 | |
8ec526a4 | 724 | // Number of entries |
77566f2a | 725 | Double_t nentries = 0.0; |
9244c78b | 726 | if (projch) { |
727 | for (Int_t k = 0; k < fNumberBinCharge; k++) { | |
728 | nentries += projch->GetBinContent(k+1); | |
729 | } | |
77566f2a | 730 | } |
731 | ||
8ec526a4 | 732 | // Rebin and statistic stuff |
733 | // Rebin | |
734 | if ((fRebin > 1) && | |
735 | (place != -1)) { | |
736 | projch = ReBin((TH1F *) projch); | |
737 | } | |
77566f2a | 738 | |
8ec526a4 | 739 | // This detector has not enough statistics or was not found in VectorCH |
740 | if ((place == -1) || | |
741 | ((place != -1) && | |
742 | (nentries < fMinEntries))) { | |
77566f2a | 743 | |
8ec526a4 | 744 | // Fill with the default infos |
77566f2a | 745 | NotEnoughStatistic(idect,0); |
746 | ||
8ec526a4 | 747 | // Memory!!! |
748 | if (fDebug != 2) { | |
77566f2a | 749 | delete projch; |
750 | } | |
751 | ||
752 | continue; | |
8ec526a4 | 753 | |
77566f2a | 754 | } |
755 | ||
8ec526a4 | 756 | // Statistic of the histos fitted |
757 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
758 | fNumberFit++; | |
759 | fStatisticMean += nentries; | |
77566f2a | 760 | |
8ec526a4 | 761 | // Method Mean and fit |
762 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
763 | FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
77566f2a | 764 | |
8ec526a4 | 765 | // Method fit bis |
766 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
767 | if (fFitChargeBisOn) { | |
768 | FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
77566f2a | 769 | } |
770 | ||
8ec526a4 | 771 | // Visualise the detector for fDebug 3 or 4 |
772 | // Here is the reconstruction of the pad and row group is used! | |
773 | if (fDebug >= 3) { | |
774 | FillCoefChargeDB(); | |
775 | } | |
77566f2a | 776 | |
8ec526a4 | 777 | // Fill Infos Fit |
77566f2a | 778 | FillInfosFit(idect,0); |
779 | ||
8ec526a4 | 780 | // Memory!!! |
781 | if (fDebug != 2) { | |
77566f2a | 782 | delete projch; |
783 | } | |
77566f2a | 784 | |
8ec526a4 | 785 | } // Boucle object |
77566f2a | 786 | |
8ec526a4 | 787 | // Normierungcharge |
788 | if (fDebug != 2) { | |
789 | NormierungCharge(); | |
790 | } | |
77566f2a | 791 | |
8ec526a4 | 792 | // Error |
793 | if ((fDebug == 1) || | |
794 | (fDebug == 4)) { | |
795 | ErrorCH(); | |
796 | } | |
77566f2a | 797 | |
8ec526a4 | 798 | // Plot |
799 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
800 | if ((fDebug == 1) || | |
801 | (fDebug == 4)){ | |
77566f2a | 802 | PlotCH(); |
803 | } | |
8ec526a4 | 804 | if((fDebug == 4) || |
805 | (fDebug == 3)){ | |
77566f2a | 806 | PlotCHDB(); |
807 | } | |
808 | ||
8ec526a4 | 809 | // Mean Statistics |
810 | if (fNumberFit > 0) { | |
811 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
812 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 813 | } |
814 | else { | |
815 | AliInfo("There is no fit!"); | |
816 | } | |
817 | ||
8ec526a4 | 818 | // Write the things! |
77566f2a | 819 | ConvertVectorFitCHTree(); |
8ec526a4 | 820 | if (fWriteCoef[0]) { |
77566f2a | 821 | WriteFitInfos(0); |
822 | } | |
8ec526a4 | 823 | |
77566f2a | 824 | return kTRUE; |
825 | ||
826 | } | |
77566f2a | 827 | |
8ec526a4 | 828 | //____________Functions fit Online CH2d________________________________________ |
77566f2a | 829 | Bool_t AliTRDCalibra::FitCHOnline(TTree *tree) |
830 | { | |
831 | // | |
8ec526a4 | 832 | // Look if the calibration group can be found in the tree, if yes take the |
833 | // histo, fit it, normalized the resulted coefficients (to 1 normally) and | |
834 | // write the results in a tree | |
77566f2a | 835 | // |
836 | ||
8ec526a4 | 837 | // Number of Xbins (detectors or groups of pads) |
838 | if (!InitFit(0,0,0,0)) { | |
77566f2a | 839 | return kFALSE; |
840 | } | |
8ec526a4 | 841 | fStatisticMean = 0.0; |
842 | fNumberFit = 0; | |
77566f2a | 843 | |
8ec526a4 | 844 | // For memory |
845 | if (fVectorCH) { | |
846 | fVectorCH->Clear(); | |
77566f2a | 847 | } |
8ec526a4 | 848 | if (fPlaCH) { |
849 | fPlaCH->Clear(); | |
77566f2a | 850 | } |
8ec526a4 | 851 | |
852 | // Init fCountDet and fCount | |
853 | InitfCountDetAndfCount(0); | |
854 | TH1F *projch = 0x0; | |
77566f2a | 855 | tree->SetBranchAddress("histo",&projch); |
8ec526a4 | 856 | TObjArray *vectorplace = ConvertTreeVector(tree); |
77566f2a | 857 | |
8ec526a4 | 858 | // Beginning of the loop between dect1 and dect2 |
859 | for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) { | |
77566f2a | 860 | |
861 | //Search if the group is in the VectorCH | |
862 | Int_t place = SearchInTreeVector(vectorplace,idect); | |
863 | ||
8ec526a4 | 864 | // Is in |
865 | if (place != -1) { | |
866 | // Variable | |
77566f2a | 867 | tree->GetEntry(place); |
868 | } | |
869 | ||
8ec526a4 | 870 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
871 | UpdatefCountDetAndfCount(idect,0); | |
77566f2a | 872 | |
8ec526a4 | 873 | // Reconstruction of the row and pad group: rowmin, row max ... |
874 | ReconstructFitRowMinRowMax(idect,0); | |
77566f2a | 875 | |
8ec526a4 | 876 | // Number of entries |
77566f2a | 877 | Double_t nentries = 0.0; |
9244c78b | 878 | if (projch) { |
879 | for (Int_t k = 0; k < projch->GetXaxis()->GetNbins(); k++) { | |
880 | nentries += projch->GetBinContent(k+1); | |
881 | } | |
882 | } | |
883 | ||
8ec526a4 | 884 | // Rebin and statistic stuff |
885 | // Rebin | |
886 | if ((fRebin > 1) && | |
887 | (place != -1)) { | |
888 | projch = ReBin((TH1F *) projch); | |
889 | } | |
890 | ||
891 | // This detector has not enough statistics or was not found in VectorCH | |
892 | if((place == -1) || | |
893 | ((place != -1) && | |
894 | (nentries < fMinEntries))) { | |
77566f2a | 895 | |
8ec526a4 | 896 | // Fill with the default infos |
77566f2a | 897 | NotEnoughStatistic(idect,0); |
898 | ||
899 | continue; | |
8ec526a4 | 900 | |
77566f2a | 901 | } |
902 | ||
8ec526a4 | 903 | // Statistics of the group fitted |
904 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
905 | fNumberFit++; | |
906 | fStatisticMean += nentries; | |
77566f2a | 907 | |
8ec526a4 | 908 | // Method Mean and fit |
909 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
910 | FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
77566f2a | 911 | |
8ec526a4 | 912 | // Method fit bis |
913 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
914 | if (fFitChargeBisOn) { | |
915 | FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
77566f2a | 916 | } |
77566f2a | 917 | |
8ec526a4 | 918 | // Visualise the detector for fDebug 3 or 4 |
919 | // Here is the reconstruction of the pad and row group is used! | |
920 | if (fDebug >= 3) { | |
921 | FillCoefChargeDB(); | |
922 | } | |
923 | ||
924 | // Fill Infos Fit | |
77566f2a | 925 | FillInfosFit(idect,0); |
77566f2a | 926 | |
8ec526a4 | 927 | } // Boucle object |
77566f2a | 928 | |
8ec526a4 | 929 | // Normierungcharge |
930 | if (fDebug != 2) { | |
931 | NormierungCharge(); | |
932 | } | |
77566f2a | 933 | |
8ec526a4 | 934 | // Error |
935 | if ((fDebug == 1) || | |
936 | (fDebug == 4)) { | |
937 | ErrorCH(); | |
938 | } | |
77566f2a | 939 | |
8ec526a4 | 940 | // Plot |
941 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
942 | if ((fDebug == 1) || | |
943 | (fDebug == 4)){ | |
77566f2a | 944 | PlotCH(); |
8ec526a4 | 945 | } |
946 | if ((fDebug == 4) || | |
947 | (fDebug == 3)){ | |
77566f2a | 948 | PlotCHDB(); |
8ec526a4 | 949 | } |
77566f2a | 950 | |
8ec526a4 | 951 | // Mean Statistic |
952 | if (fNumberFit > 0) { | |
953 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
954 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 955 | } |
956 | else { | |
957 | AliInfo("There is no fit!"); | |
958 | } | |
959 | ||
8ec526a4 | 960 | // Write the things! |
77566f2a | 961 | ConvertVectorFitCHTree(); |
8ec526a4 | 962 | if (fWriteCoef[0]) { |
77566f2a | 963 | WriteFitInfos(0); |
964 | } | |
8ec526a4 | 965 | |
77566f2a | 966 | return kTRUE; |
967 | ||
968 | } | |
77566f2a | 969 | |
8ec526a4 | 970 | //________________functions fit Online PH2d____________________________________ |
971 | Bool_t AliTRDCalibra::FitPHOnline(TProfile2D *ph) | |
77566f2a | 972 | { |
973 | // | |
8ec526a4 | 974 | // Take the 1D profiles (average pulse height), projections of the 2D PH |
975 | // on the Xaxis, for each calibration group | |
976 | // Fit or use the slope of the average pulse height to reconstruct the | |
977 | // drift velocity write the results in a tree | |
77566f2a | 978 | // A first calibration of T0 is also made using the same method (slope method) |
979 | // | |
980 | ||
8ec526a4 | 981 | // Number of Xbins (detectors or groups of pads) |
982 | TAxis *xph = ph->GetXaxis(); | |
983 | TAxis *yph = ph->GetYaxis(); | |
984 | Int_t nbins = xph->GetNbins(); | |
985 | Int_t nybins = yph->GetNbins(); | |
77566f2a | 986 | Double_t lowedge = xph->GetBinLowEdge(1); |
8ec526a4 | 987 | Double_t upedge = xph->GetBinUpEdge(xph->GetNbins()); |
988 | if (!InitFit(nbins,lowedge,upedge,1)) { | |
77566f2a | 989 | return kFALSE; |
990 | } | |
8ec526a4 | 991 | fStatisticMean = 0.0; |
992 | fNumberFit = 0; | |
77566f2a | 993 | |
8ec526a4 | 994 | // For memory |
995 | if (fVectorPH) { | |
996 | fVectorPH->Clear(); | |
997 | } | |
998 | if (fPlaPH) { | |
999 | fPlaPH->Clear(); | |
77566f2a | 1000 | } |
77566f2a | 1001 | |
8ec526a4 | 1002 | // Init fCountDet and fCount |
1003 | InitfCountDetAndfCount(1); | |
1004 | ||
1005 | // Beginning of the loop | |
1006 | for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) { | |
77566f2a | 1007 | |
8ec526a4 | 1008 | TH1D *projph = (TH1D *) ph->ProjectionY("projph",idect+1,idect+1,(Option_t *) "e"); |
77566f2a | 1009 | projph->SetDirectory(0); |
1010 | ||
8ec526a4 | 1011 | // Number of entries for this calibration group |
77566f2a | 1012 | Double_t nentries = 0; |
8ec526a4 | 1013 | for (Int_t k = 0; k < nybins; k++) { |
1014 | nentries += ph->GetBinEntries(ph->GetBin(idect+1,k+1)); | |
77566f2a | 1015 | } |
1016 | ||
8ec526a4 | 1017 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1018 | UpdatefCountDetAndfCount(idect,1); | |
77566f2a | 1019 | |
8ec526a4 | 1020 | // Reconstruction of the row and pad group: rowmin, row max ... |
1021 | ReconstructFitRowMinRowMax(idect,1); | |
77566f2a | 1022 | |
8ec526a4 | 1023 | // Rebin and statistic stuff |
1024 | // This detector has not enough statistics or was off | |
1025 | if (nentries < fMinEntries) { | |
77566f2a | 1026 | |
8ec526a4 | 1027 | // Fill with the default values |
77566f2a | 1028 | NotEnoughStatistic(idect,1); |
1029 | ||
8ec526a4 | 1030 | // Memory!!! |
1031 | if (fDebug != 2) { | |
77566f2a | 1032 | delete projph; |
1033 | } | |
1034 | ||
1035 | continue; | |
8ec526a4 | 1036 | |
77566f2a | 1037 | } |
1038 | ||
8ec526a4 | 1039 | // Statistics of the histos fitted |
1040 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
1041 | fNumberFit++; | |
1042 | fStatisticMean += nentries; | |
77566f2a | 1043 | |
8ec526a4 | 1044 | // Calcul of "real" coef |
1045 | CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
1046 | CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
77566f2a | 1047 | |
8ec526a4 | 1048 | // Method Mean and fit |
1049 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1050 | FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1051 | |
8ec526a4 | 1052 | // Method fit bis |
1053 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1054 | if (fFitPHOn) { | |
1055 | FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1056 | } |
1057 | ||
8ec526a4 | 1058 | // Visualise the detector for fDebug 3 or 4 |
1059 | // Here is the reconstruction of the pad and row group is used! | |
1060 | if (fDebug >= 3) { | |
77566f2a | 1061 | FillCoefVdriftDB(); |
1062 | FillCoefT0DB(); | |
1063 | } | |
1064 | ||
8ec526a4 | 1065 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
1066 | FillInfosFit(idect,1); | |
77566f2a | 1067 | |
8ec526a4 | 1068 | // Memory!!! |
1069 | if (fDebug != 2) { | |
77566f2a | 1070 | delete projph; |
1071 | } | |
1072 | ||
8ec526a4 | 1073 | } // Boucle object |
77566f2a | 1074 | |
8ec526a4 | 1075 | // Error |
1076 | if ((fDebug == 1) || | |
1077 | (fDebug == 4)) { | |
77566f2a | 1078 | ErrorPH(); |
1079 | ErrorT0(); | |
1080 | } | |
1081 | ||
8ec526a4 | 1082 | // Plot |
1083 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
1084 | if ((fDebug == 1) || | |
1085 | (fDebug == 4)) { | |
77566f2a | 1086 | PlotPH(); |
1087 | PlotT0(); | |
8ec526a4 | 1088 | } |
1089 | if ((fDebug == 4) || | |
1090 | (fDebug == 3)) { | |
77566f2a | 1091 | PlotPHDB(); |
1092 | PlotT0DB(); | |
8ec526a4 | 1093 | } |
77566f2a | 1094 | |
8ec526a4 | 1095 | // Mean Statistic |
1096 | if (fNumberFit > 0) { | |
1097 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1098 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1099 | } |
1100 | else { | |
1101 | AliInfo("There is no fit!"); | |
1102 | } | |
1103 | ||
8ec526a4 | 1104 | // Write the things! |
1105 | if(fWriteCoef[1]) { | |
77566f2a | 1106 | WriteFitInfos(1); |
1107 | } | |
8ec526a4 | 1108 | |
77566f2a | 1109 | return kTRUE; |
1110 | ||
1111 | } | |
77566f2a | 1112 | |
8ec526a4 | 1113 | //____________Functions fit Online PH2d________________________________________ |
77566f2a | 1114 | Bool_t AliTRDCalibra::FitPHOnline() |
1115 | { | |
1116 | // | |
8ec526a4 | 1117 | // Reconstruct the average pulse height from the vectorPH for each |
1118 | // calibration group | |
1119 | // Fit or use the slope of the average pulse height to reconstruct the | |
1120 | // drift velocity write the results in a tree | |
77566f2a | 1121 | // A first calibration of T0 is also made using the same method (slope method) |
1122 | // | |
77566f2a | 1123 | |
8ec526a4 | 1124 | // Number of Xbins (detectors or groups of pads) |
1125 | if (!InitFit(0,0,0,1)) { | |
77566f2a | 1126 | return kFALSE; |
1127 | } | |
8ec526a4 | 1128 | fStatisticMean = 0.0; |
1129 | fNumberFit = 0; | |
77566f2a | 1130 | |
8ec526a4 | 1131 | // Init fCountDet and fCount |
1132 | InitfCountDetAndfCount(1); | |
77566f2a | 1133 | |
8ec526a4 | 1134 | // Beginning of the loop |
1135 | for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) { | |
77566f2a | 1136 | |
8ec526a4 | 1137 | // Search if the group is in the VectorCH |
77566f2a | 1138 | Int_t place = SearchInVector(idect,1); |
1139 | ||
8ec526a4 | 1140 | // Is in |
1141 | TH1F *projph = 0x0; | |
77566f2a | 1142 | TString name("PH"); |
1143 | name += idect; | |
8ec526a4 | 1144 | if (place != -1) { |
1145 | // Variable | |
1146 | AliTRDPInfo *fPHInfo = new AliTRDPInfo(); | |
1147 | // Retrieve | |
1148 | fPHInfo = (AliTRDPInfo *) fVectorPH->At(place); | |
1149 | projph = CorrectTheError((TGraphErrors *) ConvertVectorPHisto(fPHInfo,(const char *) name)); | |
77566f2a | 1150 | projph->SetDirectory(0); |
1151 | delete fPHInfo; | |
1152 | } | |
1153 | ||
8ec526a4 | 1154 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1155 | UpdatefCountDetAndfCount(idect,1); | |
77566f2a | 1156 | |
8ec526a4 | 1157 | // Reconstruction of the row and pad group: rowmin, row max ... |
1158 | ReconstructFitRowMinRowMax(idect,1); | |
77566f2a | 1159 | |
8ec526a4 | 1160 | // Rebin and statistic stuff |
1161 | // This detector has not enough statistics or was off | |
1162 | if ((place == -1) || | |
1163 | ((place != -1) && | |
1164 | (fEntriesCurrent < fMinEntries))) { | |
77566f2a | 1165 | |
8ec526a4 | 1166 | // Fill with the default values |
77566f2a | 1167 | NotEnoughStatistic(idect,1); |
1168 | ||
8ec526a4 | 1169 | // Memory!!! |
1170 | if (fDebug != 2) { | |
77566f2a | 1171 | delete projph; |
1172 | } | |
8ec526a4 | 1173 | |
77566f2a | 1174 | continue; |
8ec526a4 | 1175 | |
77566f2a | 1176 | } |
1177 | ||
8ec526a4 | 1178 | // Statistic of the histos fitted |
1179 | AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent)); | |
1180 | fNumberFit++; | |
1181 | fStatisticMean += fEntriesCurrent; | |
77566f2a | 1182 | |
8ec526a4 | 1183 | // Calcul of "real" coef |
1184 | CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
1185 | CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
77566f2a | 1186 | |
8ec526a4 | 1187 | // Method Mean and fit |
1188 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1189 | FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1190 | |
8ec526a4 | 1191 | // Method fit bis |
1192 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1193 | if (fFitPHOn) { | |
1194 | FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1195 | } |
1196 | ||
8ec526a4 | 1197 | // Visualise the detector for fDebug 3 or 4 |
1198 | // Here is the reconstruction of the pad and row group is used! | |
1199 | if (fDebug >= 3) { | |
77566f2a | 1200 | FillCoefVdriftDB(); |
1201 | FillCoefT0DB(); | |
1202 | } | |
1203 | ||
8ec526a4 | 1204 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1205 | FillInfosFit(idect,1); |
1206 | ||
8ec526a4 | 1207 | // Memory!!! |
1208 | if (fDebug != 2) { | |
77566f2a | 1209 | delete projph; |
1210 | } | |
1211 | ||
8ec526a4 | 1212 | } // Boucle object |
77566f2a | 1213 | |
8ec526a4 | 1214 | // Error |
1215 | if ((fDebug == 1) || | |
1216 | (fDebug == 4)) { | |
77566f2a | 1217 | ErrorPH(); |
1218 | ErrorT0(); | |
1219 | } | |
1220 | ||
8ec526a4 | 1221 | // Plot |
1222 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
1223 | if ((fDebug == 1) || | |
1224 | (fDebug == 4)) { | |
77566f2a | 1225 | PlotPH(); |
1226 | PlotT0(); | |
1227 | } | |
8ec526a4 | 1228 | if ((fDebug == 4) || |
1229 | (fDebug == 3)) { | |
77566f2a | 1230 | PlotPHDB(); |
1231 | PlotT0DB(); | |
1232 | } | |
1233 | ||
8ec526a4 | 1234 | // Mean Statistic |
1235 | if (fNumberFit > 0) { | |
1236 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1237 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1238 | } |
1239 | else { | |
1240 | AliInfo("There is no fit!"); | |
1241 | } | |
1242 | ||
8ec526a4 | 1243 | // Write the things! |
1244 | if (fWriteCoef[1]) { | |
77566f2a | 1245 | WriteFitInfos(1); |
1246 | } | |
8ec526a4 | 1247 | |
77566f2a | 1248 | return kTRUE; |
1249 | ||
1250 | } | |
1251 | ||
8ec526a4 | 1252 | //____________Functions fit Online PH2d________________________________________ |
77566f2a | 1253 | Bool_t AliTRDCalibra::FitPHOnline(TTree *tree) |
1254 | { | |
1255 | // | |
8ec526a4 | 1256 | // Look if the calibration group can be found in the tree, if yes take the |
1257 | // histo, fit it, and write the results in a tree | |
77566f2a | 1258 | // A first calibration of T0 is also made using the same method (slope method) |
1259 | // | |
77566f2a | 1260 | |
8ec526a4 | 1261 | // Number of Xbins (detectors or groups of pads) |
1262 | if (!InitFit(0,0,0,1)) { | |
77566f2a | 1263 | return kFALSE; |
1264 | } | |
8ec526a4 | 1265 | fStatisticMean = 0.0; |
1266 | fNumberFit = 0; | |
1267 | ||
1268 | // For memory | |
1269 | if (fVectorPH) { | |
1270 | fVectorPH->Clear(); | |
77566f2a | 1271 | } |
8ec526a4 | 1272 | if (fPlaPH) { |
1273 | fPlaPH->Clear(); | |
77566f2a | 1274 | } |
1275 | ||
8ec526a4 | 1276 | // Init fCountDet and fCount |
1277 | InitfCountDetAndfCount(1); | |
1278 | TGraphErrors *projphtree = 0x0; | |
77566f2a | 1279 | tree->SetBranchAddress("histo",&projphtree); |
8ec526a4 | 1280 | TObjArray *vectorplace = ConvertTreeVector(tree); |
77566f2a | 1281 | |
8ec526a4 | 1282 | // Beginning of the loop |
1283 | for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) { | |
77566f2a | 1284 | |
8ec526a4 | 1285 | // Search if the group is in the VectorCH |
77566f2a | 1286 | Int_t place = SearchInTreeVector(vectorplace,idect); |
1287 | ||
1288 | TH1F *projph = 0x0; | |
8ec526a4 | 1289 | // Is in |
1290 | if (place != -1) { | |
1291 | // Variable | |
77566f2a | 1292 | tree->GetEntry(place); |
1293 | projph = CorrectTheError(projphtree); | |
1294 | } | |
1295 | ||
8ec526a4 | 1296 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1297 | UpdatefCountDetAndfCount(idect,1); | |
77566f2a | 1298 | |
8ec526a4 | 1299 | // Reconstruction of the row and pad group: rowmin, row max ... |
1300 | ReconstructFitRowMinRowMax(idect,1); | |
77566f2a | 1301 | |
8ec526a4 | 1302 | // Rebin and statistic stuff |
1303 | // This detector has not enough statistics or was off | |
1304 | if((place == -1) || | |
1305 | ((place != -1) && | |
1306 | (fEntriesCurrent < fMinEntries))) { | |
77566f2a | 1307 | |
8ec526a4 | 1308 | // Fill with the default values |
77566f2a | 1309 | NotEnoughStatistic(idect,1); |
1310 | ||
8ec526a4 | 1311 | // Memory!!! |
1312 | if (fDebug != 2) { | |
77566f2a | 1313 | delete projph; |
1314 | } | |
1315 | ||
1316 | continue; | |
8ec526a4 | 1317 | |
77566f2a | 1318 | } |
1319 | ||
8ec526a4 | 1320 | // Statistics of the histos fitted |
1321 | AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent)); | |
1322 | fNumberFit++; | |
1323 | fStatisticMean += fEntriesCurrent; | |
77566f2a | 1324 | |
8ec526a4 | 1325 | // Calcul of "real" coef |
1326 | CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
1327 | CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
77566f2a | 1328 | |
8ec526a4 | 1329 | // Method Mean and fit |
1330 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1331 | FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
1332 | // Method fit bis | |
1333 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1334 | if (fFitPHOn) { | |
1335 | FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1336 | } |
1337 | ||
8ec526a4 | 1338 | // Visualise the detector for fDebug 3 or 4 |
1339 | // Here is the reconstruction of the pad and row group is used! | |
1340 | if (fDebug >= 3) { | |
77566f2a | 1341 | FillCoefVdriftDB(); |
1342 | FillCoefT0DB(); | |
1343 | } | |
1344 | ||
8ec526a4 | 1345 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1346 | FillInfosFit(idect,1); |
77566f2a | 1347 | |
8ec526a4 | 1348 | // Memory!!! |
1349 | if (fDebug != 2) { | |
77566f2a | 1350 | delete projph; |
1351 | } | |
77566f2a | 1352 | |
8ec526a4 | 1353 | } // Boucle object |
77566f2a | 1354 | |
8ec526a4 | 1355 | // Error |
1356 | if ((fDebug == 1) || | |
1357 | (fDebug == 4)) { | |
77566f2a | 1358 | ErrorPH(); |
1359 | ErrorT0(); | |
1360 | } | |
1361 | ||
8ec526a4 | 1362 | // Plot |
1363 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
1364 | if ((fDebug == 1) || | |
1365 | (fDebug == 4)){ | |
77566f2a | 1366 | PlotPH(); |
1367 | PlotT0(); | |
1368 | } | |
8ec526a4 | 1369 | if ((fDebug == 4) || |
1370 | (fDebug == 3)){ | |
77566f2a | 1371 | PlotPHDB(); |
1372 | PlotT0DB(); | |
1373 | } | |
1374 | ||
8ec526a4 | 1375 | // Mean Statistics |
1376 | if (fNumberFit > 0) { | |
1377 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1378 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1379 | } |
1380 | else { | |
1381 | AliInfo("There is no fit!"); | |
1382 | } | |
1383 | ||
8ec526a4 | 1384 | // Write the things! |
1385 | if (fWriteCoef[1]) { | |
77566f2a | 1386 | WriteFitInfos(1); |
1387 | } | |
8ec526a4 | 1388 | |
77566f2a | 1389 | return kTRUE; |
1390 | ||
1391 | } | |
77566f2a | 1392 | |
8ec526a4 | 1393 | //____________Functions fit Online PRF2d_______________________________________ |
1394 | Bool_t AliTRDCalibra::FitPRFOnline(TProfile2D *prf) | |
77566f2a | 1395 | { |
1396 | // | |
8ec526a4 | 1397 | // Take the 1D profiles (pad response function), projections of the 2D PRF |
1398 | // on the Xaxis, for each calibration group | |
1399 | // Fit with a gaussian to reconstruct the sigma of the pad response function | |
1400 | // write the results in a tree | |
77566f2a | 1401 | // |
1402 | ||
8ec526a4 | 1403 | // Number of Xbins (detectors or groups of pads) |
1404 | TAxis *xprf = prf->GetXaxis(); | |
1405 | TAxis *yprf = prf->GetYaxis(); | |
1406 | Int_t nybins = yprf->GetNbins(); | |
1407 | Int_t nbins = xprf->GetNbins(); | |
77566f2a | 1408 | Double_t lowedge = xprf->GetBinLowEdge(1); |
8ec526a4 | 1409 | Double_t upedge = xprf->GetBinUpEdge(xprf->GetNbins()); |
1410 | if (!InitFit(nbins,lowedge,upedge,2)) { | |
77566f2a | 1411 | return kFALSE; |
1412 | } | |
8ec526a4 | 1413 | fStatisticMean = 0.0; |
1414 | fNumberFit = 0; | |
77566f2a | 1415 | |
8ec526a4 | 1416 | // For memory |
1417 | if (fVectorPRF) { | |
1418 | fVectorPRF->Clear(); | |
1419 | } | |
1420 | if (fPlaPRF) { | |
1421 | fPlaPRF->Clear(); | |
77566f2a | 1422 | } |
77566f2a | 1423 | |
8ec526a4 | 1424 | // Init fCountDet and fCount |
1425 | InitfCountDetAndfCount(2); | |
77566f2a | 1426 | |
8ec526a4 | 1427 | // Beginning of the loop |
1428 | for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) { | |
77566f2a | 1429 | |
8ec526a4 | 1430 | TH1D *projprf = (TH1D *) prf->ProjectionY("projprf",idect+1,idect+1,(Option_t *) "e"); |
77566f2a | 1431 | projprf->SetDirectory(0); |
1432 | ||
8ec526a4 | 1433 | // Number of entries for this calibration group |
77566f2a | 1434 | Double_t nentries = 0; |
8ec526a4 | 1435 | for (Int_t k = 0; k < nybins; k++) { |
1436 | nentries += prf->GetBinEntries(prf->GetBin(idect+1,k+1)); | |
77566f2a | 1437 | } |
1438 | ||
8ec526a4 | 1439 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1440 | UpdatefCountDetAndfCount(idect,2); | |
77566f2a | 1441 | |
8ec526a4 | 1442 | // Reconstruction of the row and pad group: rowmin, row max ... |
1443 | ReconstructFitRowMinRowMax(idect,2); | |
77566f2a | 1444 | |
8ec526a4 | 1445 | // Rebin and statistic stuff |
1446 | // This detector has not enough statistics or was off | |
1447 | if (nentries < fMinEntries) { | |
77566f2a | 1448 | |
8ec526a4 | 1449 | // Fill with the default values |
77566f2a | 1450 | NotEnoughStatistic(idect,2); |
1451 | ||
8ec526a4 | 1452 | // Memory! |
1453 | if (fDebug != 2) { | |
77566f2a | 1454 | delete projprf; |
1455 | } | |
1456 | ||
1457 | continue; | |
8ec526a4 | 1458 | |
77566f2a | 1459 | } |
1460 | ||
8ec526a4 | 1461 | // Statistics of the histos fitted |
1462 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
1463 | fNumberFit++; | |
1464 | fStatisticMean += nentries; | |
77566f2a | 1465 | |
8ec526a4 | 1466 | // Calcul of "real" coef |
1467 | if ((fDebug == 1) || | |
1468 | (fDebug == 4)) { | |
1469 | CalculPRFCoefMean(fCountDet[2],(Int_t) (idect - fDect1[2])); | |
77566f2a | 1470 | } |
1471 | ||
8ec526a4 | 1472 | // Method Mean and fit |
1473 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1474 | FitPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2])); | |
77566f2a | 1475 | |
8ec526a4 | 1476 | // Visualise the detector for fDebug 3 or 4 |
1477 | // Here is the reconstruction of the pad and row group is used! | |
1478 | if (fDebug >= 3) { | |
1479 | FillCoefPRFDB(); | |
1480 | } | |
77566f2a | 1481 | |
8ec526a4 | 1482 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1483 | FillInfosFit(idect,2); |
1484 | ||
8ec526a4 | 1485 | // Memory!!! |
1486 | if (fDebug != 2) { | |
77566f2a | 1487 | delete projprf; |
1488 | } | |
1489 | ||
8ec526a4 | 1490 | } // Boucle object |
77566f2a | 1491 | |
8ec526a4 | 1492 | // Error |
1493 | if ((fDebug == 1) || | |
1494 | (fDebug == 4)) { | |
1495 | ErrorPRF(); | |
1496 | } | |
77566f2a | 1497 | |
8ec526a4 | 1498 | // Plot |
1499 | // No plot, 1 and 4 error plot, 3 and 4 DB plot | |
1500 | if ((fDebug == 1) || | |
1501 | (fDebug == 4)) { | |
77566f2a | 1502 | PlotPRF(); |
8ec526a4 | 1503 | } |
1504 | if ((fDebug == 4) || | |
1505 | (fDebug == 3)){ | |
77566f2a | 1506 | PlotPRFDB(); |
8ec526a4 | 1507 | } |
77566f2a | 1508 | |
8ec526a4 | 1509 | // Mean Statistic |
1510 | if (fNumberFit > 0) { | |
1511 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1512 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1513 | } |
1514 | else { | |
1515 | AliInfo("There is no fit!"); | |
1516 | } | |
1517 | ||
8ec526a4 | 1518 | // Write the things! |
1519 | if (fWriteCoef[2]) { | |
77566f2a | 1520 | WriteFitInfos(2); |
1521 | } | |
8ec526a4 | 1522 | |
77566f2a | 1523 | return kTRUE; |
1524 | ||
1525 | } | |
77566f2a | 1526 | |
8ec526a4 | 1527 | //____________Functions fit Online PRF2d_______________________________________ |
77566f2a | 1528 | Bool_t AliTRDCalibra::FitPRFOnline(TTree *tree) |
1529 | { | |
1530 | // | |
8ec526a4 | 1531 | // Look if the calibration group can be found in the tree, if yes take |
1532 | // the histo, fit it, and write the results in a tree | |
77566f2a | 1533 | // |
1534 | ||
8ec526a4 | 1535 | // Number of Xbins (detectors or groups of pads) |
1536 | if (!InitFit(0,0,0,2)) { | |
77566f2a | 1537 | return kFALSE; |
1538 | } | |
8ec526a4 | 1539 | fStatisticMean = 0.0; |
1540 | fNumberFit = 0; | |
77566f2a | 1541 | |
8ec526a4 | 1542 | // For memory |
1543 | if (fVectorPRF) { | |
1544 | fVectorPRF->Clear(); | |
1545 | } | |
1546 | if (fPlaPRF) { | |
1547 | fPlaPRF->Clear(); | |
77566f2a | 1548 | } |
1549 | ||
8ec526a4 | 1550 | // Init fCountDet and fCount |
1551 | InitfCountDetAndfCount(2); | |
1552 | TGraphErrors *projprftree = 0x0; | |
77566f2a | 1553 | tree->SetBranchAddress("histo",&projprftree); |
8ec526a4 | 1554 | TObjArray *vectorplace = ConvertTreeVector(tree); |
77566f2a | 1555 | |
8ec526a4 | 1556 | // Beginning of the loop |
1557 | for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) { | |
77566f2a | 1558 | |
8ec526a4 | 1559 | // Search if the group is in the VectorCH |
77566f2a | 1560 | Int_t place = SearchInTreeVector(vectorplace,idect); |
1561 | ||
8ec526a4 | 1562 | // Is in |
77566f2a | 1563 | TH1F *projprf = 0x0; |
8ec526a4 | 1564 | if (place != -1) { |
1565 | // Variable | |
77566f2a | 1566 | tree->GetEntry(place); |
1567 | projprf = CorrectTheError(projprftree); | |
1568 | } | |
1569 | ||
8ec526a4 | 1570 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1571 | UpdatefCountDetAndfCount(idect,2); | |
77566f2a | 1572 | |
8ec526a4 | 1573 | // Reconstruction of the row and pad group: rowmin, row max ... |
1574 | ReconstructFitRowMinRowMax(idect,2); | |
77566f2a | 1575 | |
8ec526a4 | 1576 | // Rebin and statistic stuff |
1577 | // This detector has not enough statistics or was off | |
1578 | if ((place == -1) || | |
1579 | ((place != -1) && | |
1580 | (fEntriesCurrent < fMinEntries))) { | |
77566f2a | 1581 | |
8ec526a4 | 1582 | // Fill with the default values |
77566f2a | 1583 | NotEnoughStatistic(idect,2); |
1584 | ||
8ec526a4 | 1585 | // Memory!!! |
1586 | if (fDebug != 2) { | |
77566f2a | 1587 | delete projprf; |
1588 | } | |
1589 | ||
1590 | continue; | |
8ec526a4 | 1591 | |
77566f2a | 1592 | } |
1593 | ||
8ec526a4 | 1594 | // Statistics of the histos fitted |
1595 | AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent)); | |
1596 | fNumberFit++; | |
1597 | fStatisticMean += fEntriesCurrent; | |
77566f2a | 1598 | |
8ec526a4 | 1599 | // Calcul of "real" coef |
1600 | if ((fDebug == 1) || | |
1601 | (fDebug == 4)){ | |
1602 | CalculPRFCoefMean(fCountDet[2],(Int_t) (idect - fDect1[2])); | |
1603 | } | |
1604 | ||
1605 | // Method Mean and fit | |
1606 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1607 | FitPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2])); | |
1608 | // Visualise the detector for fDebug 3 or 4 | |
1609 | // Here is the reconstruction of the pad and row group is used! | |
1610 | if (fDebug >= 3) { | |
1611 | FillCoefPRFDB(); | |
77566f2a | 1612 | } |
8ec526a4 | 1613 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1614 | FillInfosFit(idect,2); |
77566f2a | 1615 | |
8ec526a4 | 1616 | // Memory!!! |
1617 | if (fDebug != 2) { | |
77566f2a | 1618 | delete projprf; |
1619 | } | |
1620 | ||
8ec526a4 | 1621 | } // Boucle object |
77566f2a | 1622 | |
8ec526a4 | 1623 | // Error |
1624 | if ((fDebug == 1) || | |
1625 | (fDebug == 4)) { | |
1626 | ErrorPRF(); | |
1627 | } | |
77566f2a | 1628 | |
8ec526a4 | 1629 | // Plot |
1630 | // No plot, 1 and 4 error plot, 3 and 4 DB plot | |
1631 | if ((fDebug == 1) || | |
1632 | (fDebug == 4)){ | |
77566f2a | 1633 | PlotPRF(); |
1634 | } | |
8ec526a4 | 1635 | if ((fDebug == 4) || |
1636 | (fDebug == 3)){ | |
77566f2a | 1637 | PlotPRFDB(); |
1638 | } | |
1639 | ||
8ec526a4 | 1640 | // Mean Statistics |
1641 | if (fNumberFit > 0) { | |
1642 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1643 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1644 | } |
1645 | else { | |
1646 | AliInfo("There is no fit!"); | |
1647 | } | |
1648 | ||
8ec526a4 | 1649 | // Write the things! |
1650 | if (fWriteCoef[2]) { | |
77566f2a | 1651 | WriteFitInfos(2); |
1652 | } | |
8ec526a4 | 1653 | |
77566f2a | 1654 | return kTRUE; |
1655 | ||
1656 | } | |
77566f2a | 1657 | |
8ec526a4 | 1658 | //____________Functions fit Online PRF2d_______________________________________ |
77566f2a | 1659 | Bool_t AliTRDCalibra::FitPRFOnline() |
1660 | { | |
1661 | // | |
8ec526a4 | 1662 | // Reconstruct the 1D histo (pad response function) from the vectorPRD for |
1663 | // each calibration group | |
1664 | // Fit with a gaussian to reconstruct the sigma of the pad response function | |
1665 | // write the results in a tree | |
77566f2a | 1666 | // |
1667 | ||
8ec526a4 | 1668 | // Number of Xbins (detectors or groups of pads) |
1669 | if (!InitFit(0,0,0,2)) { | |
77566f2a | 1670 | return kFALSE; |
1671 | } | |
8ec526a4 | 1672 | fStatisticMean = 0.0; |
1673 | fNumberFit = 0; | |
77566f2a | 1674 | |
8ec526a4 | 1675 | // Init fCountDet and fCount |
1676 | InitfCountDetAndfCount(2); | |
77566f2a | 1677 | |
8ec526a4 | 1678 | // Beginning of the loop |
1679 | for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) { | |
77566f2a | 1680 | |
8ec526a4 | 1681 | // Search if the group is in the VectorCH |
77566f2a | 1682 | Int_t place = SearchInVector(idect,2); |
1683 | ||
8ec526a4 | 1684 | // Is in |
1685 | TH1F *projprf = 0x0; | |
77566f2a | 1686 | TString name("PRF"); |
1687 | name += idect; | |
8ec526a4 | 1688 | if (place != -1) { |
1689 | // Variable | |
1690 | AliTRDPInfo *fPRFInfo = new AliTRDPInfo(); | |
1691 | // Retrieve | |
1692 | fPRFInfo = (AliTRDPInfo *) fVectorPRF->At(place); | |
1693 | projprf = CorrectTheError((TGraphErrors *) ConvertVectorPHisto(fPRFInfo,(const char *)name)); | |
77566f2a | 1694 | projprf->SetDirectory(0); |
1695 | delete fPRFInfo; | |
1696 | } | |
1697 | ||
8ec526a4 | 1698 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1699 | UpdatefCountDetAndfCount(idect,2); | |
77566f2a | 1700 | |
8ec526a4 | 1701 | // Reconstruction of the row and pad group: rowmin, row max ... |
1702 | ReconstructFitRowMinRowMax(idect,2); | |
77566f2a | 1703 | |
8ec526a4 | 1704 | // Rebin and statistic stuff |
1705 | // This detector has not enough statistics or was off | |
1706 | if ((place == -1) || | |
1707 | ((place != -1) && | |
1708 | (fEntriesCurrent < fMinEntries))) { | |
77566f2a | 1709 | |
8ec526a4 | 1710 | // Fill with the default values |
77566f2a | 1711 | NotEnoughStatistic(idect,2); |
1712 | ||
8ec526a4 | 1713 | // Memory |
1714 | if (fDebug != 2) { | |
77566f2a | 1715 | delete projprf; |
1716 | } | |
77566f2a | 1717 | |
1718 | continue; | |
77566f2a | 1719 | |
8ec526a4 | 1720 | } |
77566f2a | 1721 | |
8ec526a4 | 1722 | // Statistic of the histos fitted |
1723 | AliInfo(Form("For the group number %d there are %d stats", idect,fEntriesCurrent)); | |
1724 | fNumberFit++; | |
1725 | fStatisticMean += fEntriesCurrent; | |
77566f2a | 1726 | |
8ec526a4 | 1727 | // Calcul of "real" coef |
1728 | if ((fDebug == 1) || | |
1729 | (fDebug == 4)) { | |
1730 | CalculPRFCoefMean(fCountDet[2],(Int_t) (idect-fDect1[2])); | |
1731 | } | |
77566f2a | 1732 | |
8ec526a4 | 1733 | // Method Mean and fit |
1734 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1735 | FitPRF((TH1 *) projprf,(Int_t) (idect-fDect1[2])); | |
1736 | // Visualise the detector for fDebug 3 or 4 | |
1737 | // Here is the reconstruction of the pad and row group is used! | |
1738 | if (fDebug >= 3) { | |
1739 | FillCoefPRFDB(); | |
77566f2a | 1740 | } |
8ec526a4 | 1741 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1742 | FillInfosFit(idect,2); |
1743 | ||
8ec526a4 | 1744 | // Memory!!! |
1745 | if (fDebug != 2) { | |
77566f2a | 1746 | delete projprf; |
1747 | } | |
1748 | ||
8ec526a4 | 1749 | } // Boucle object |
77566f2a | 1750 | |
8ec526a4 | 1751 | // Error |
1752 | if ((fDebug == 1) || | |
1753 | (fDebug == 4)) { | |
1754 | ErrorPRF(); | |
1755 | } | |
77566f2a | 1756 | |
8ec526a4 | 1757 | // Plot |
1758 | // No plot, 1 and 4 error plot, 3 and 4 DB plot | |
1759 | if ((fDebug == 1) || | |
1760 | (fDebug == 4)) { | |
77566f2a | 1761 | PlotPRF(); |
8ec526a4 | 1762 | } |
1763 | if ((fDebug == 4) || | |
1764 | (fDebug == 3)) { | |
77566f2a | 1765 | PlotPRFDB(); |
8ec526a4 | 1766 | } |
77566f2a | 1767 | |
8ec526a4 | 1768 | // Mean Statistics |
1769 | if (fNumberFit > 0) { | |
1770 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
77566f2a | 1771 | } |
1772 | else { | |
1773 | AliInfo("There is no fit!"); | |
1774 | } | |
1775 | ||
8ec526a4 | 1776 | // Write the things! |
1777 | if (fWriteCoef[2]) { | |
77566f2a | 1778 | WriteFitInfos(2); |
1779 | } | |
8ec526a4 | 1780 | |
77566f2a | 1781 | return kTRUE; |
1782 | ||
1783 | } | |
1784 | ||
8ec526a4 | 1785 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
77566f2a | 1786 | Bool_t AliTRDCalibra::Init2Dhistos() |
1787 | { | |
8ec526a4 | 1788 | // |
1789 | // For the offline tracking | |
1790 | // This function will be called in the function AliReconstruction::Run() | |
1791 | // Init the calibration mode (Nz, Nrphi), the 2D histograms if fHisto2d = kTRUE, | |
1792 | // | |
77566f2a | 1793 | |
8ec526a4 | 1794 | // DB Setting |
1795 | // Get cal | |
1796 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
77566f2a | 1797 | if (!cal) { |
1798 | AliInfo("Could not get calibDB"); | |
1799 | return kFALSE; | |
1800 | } | |
1801 | ||
77566f2a | 1802 | // Some parameters |
8ec526a4 | 1803 | fTimeMax = cal->GetNumberOfTimeBins(); |
1804 | fSf = cal->GetSamplingFrequency(); | |
1805 | if (fRelativeScaleAuto) { | |
1806 | fRelativeScale = 0; | |
1807 | } | |
1808 | else { | |
1809 | fRelativeScale = 20; | |
1810 | } | |
77566f2a | 1811 | |
8ec526a4 | 1812 | // Create the 2D histos corresponding to the pad groupCalibration mode |
1813 | if (fCH2dOn) { | |
77566f2a | 1814 | |
8ec526a4 | 1815 | AliInfo(Form("The pad calibration mode for the relative gain calibration: Nz %d, and Nrphi %d" |
1816 | ,fNz[0] | |
1817 | ,fNrphi[0])); | |
77566f2a | 1818 | |
8ec526a4 | 1819 | // Calcul the number of Xbins |
77566f2a | 1820 | fNtotal[0] = 0; |
1821 | ModePadCalibration(2,0); | |
1822 | ModePadFragmentation(0,2,0,0); | |
8ec526a4 | 1823 | fDetChamb2[0] = fNfragZ[0] * fNfragRphi[0]; |
1824 | if (fDebug == 4) { | |
1825 | AliInfo(Form("For the chamber 2: %d",fDetChamb2[0])); | |
77566f2a | 1826 | } |
8ec526a4 | 1827 | fNtotal[0] += 6 * 18 * fDetChamb2[0]; |
77566f2a | 1828 | ModePadCalibration(0,0); |
1829 | ModePadFragmentation(0,0,0,0); | |
8ec526a4 | 1830 | fDetChamb0[0] = fNfragZ[0] * fNfragRphi[0]; |
1831 | if (fDebug == 4) { | |
1832 | AliInfo(Form("For the other chamber 0: %d",fDetChamb0[0])); | |
77566f2a | 1833 | } |
8ec526a4 | 1834 | fNtotal[0] += 6 * 4 * 18 * fDetChamb0[0]; |
1835 | AliInfo(Form("Total number of Xbins: %d",fNtotal[0])); | |
77566f2a | 1836 | |
8ec526a4 | 1837 | // Create the 2D histo |
1838 | if (fHisto2d) { | |
1839 | CreateCH2d(fNtotal[0]); | |
1840 | } | |
1841 | if (fVector2d) { | |
1842 | fVectorCH = new TObjArray(); | |
1843 | fPlaCH = new TObjArray(); | |
1844 | } | |
77566f2a | 1845 | |
8ec526a4 | 1846 | // Variable |
1847 | fAmpTotal = new Float_t[TMath::Max(fDetChamb2[0],fDetChamb0[0])]; | |
1848 | for (Int_t k = 0; k < TMath::Max(fDetChamb2[0],fDetChamb0[0]); k++) { | |
1849 | fAmpTotal[k] = 0.0; | |
77566f2a | 1850 | } |
1851 | ||
77566f2a | 1852 | } |
1853 | ||
8ec526a4 | 1854 | if (fPH2dOn) { |
1855 | ||
1856 | AliInfo(Form("The pad calibration mode for the drift velocity calibration: Nz %d, and Nrphi %d" | |
1857 | ,fNz[1] | |
1858 | ,fNrphi[1])); | |
77566f2a | 1859 | |
8ec526a4 | 1860 | // Calcul the number of Xbins |
77566f2a | 1861 | fNtotal[1] = 0; |
1862 | ModePadCalibration(2,1); | |
1863 | ModePadFragmentation(0,2,0,1); | |
8ec526a4 | 1864 | fDetChamb2[1] = fNfragZ[1]*fNfragRphi[1]; |
1865 | if (fDebug == 4) { | |
1866 | AliInfo(Form("For the chamber 2: %d",fDetChamb2[1])); | |
77566f2a | 1867 | } |
8ec526a4 | 1868 | fNtotal[1] += 6 * 18 * fDetChamb2[1]; |
77566f2a | 1869 | ModePadCalibration(0,1); |
1870 | ModePadFragmentation(0,0,0,1); | |
8ec526a4 | 1871 | fDetChamb0[1] = fNfragZ[1] * fNfragRphi[1]; |
1872 | if (fDebug == 4) { | |
1873 | AliInfo(Form("For the chamber 0: %d",fDetChamb0[1])); | |
77566f2a | 1874 | } |
8ec526a4 | 1875 | fNtotal[1] += 6 * 4 * 18 * fDetChamb0[1]; |
1876 | AliInfo(Form("Total number of Xbins: %d",fNtotal[1])); | |
77566f2a | 1877 | |
8ec526a4 | 1878 | // Create the 2D histo |
1879 | if (fHisto2d) { | |
1880 | CreatePH2d(fNtotal[1]); | |
1881 | } | |
1882 | if (fVector2d) { | |
1883 | fVectorPH = new TObjArray(); | |
1884 | fPlaPH = new TObjArray(); | |
1885 | } | |
77566f2a | 1886 | |
8ec526a4 | 1887 | // Variable |
1888 | fPHPlace = new Short_t[fTimeMax]; | |
1889 | for (Int_t k = 0; k < fTimeMax; k++) { | |
1890 | fPHPlace[k] = -1; | |
77566f2a | 1891 | } |
8ec526a4 | 1892 | fPHValue = new Float_t[fTimeMax]; |
1893 | for (Int_t k = 0; k < fTimeMax; k++) { | |
1894 | fPHValue[k] = -1.0; | |
1895 | } | |
77566f2a | 1896 | |
1897 | } | |
1898 | ||
8ec526a4 | 1899 | if (fPRF2dOn) { |
1900 | ||
1901 | AliInfo(Form("The pad calibration mode for the PRF calibration: Nz %d, and Nrphi %d" | |
1902 | ,fNz[2] | |
1903 | ,fNrphi[2])); | |
77566f2a | 1904 | |
8ec526a4 | 1905 | // Calcul the number of Xbins |
77566f2a | 1906 | fNtotal[2] = 0; |
1907 | ModePadCalibration(2,2); | |
1908 | ModePadFragmentation(0,2,0,2); | |
8ec526a4 | 1909 | fDetChamb2[2] = fNfragZ[2] * fNfragRphi[2]; |
1910 | if (fDebug == 4) { | |
1911 | AliInfo(Form("For the chamber 2: %d",fDetChamb2[2])); | |
77566f2a | 1912 | } |
8ec526a4 | 1913 | fNtotal[2] += 6 * 18 * fDetChamb2[2]; |
77566f2a | 1914 | ModePadCalibration(0,2); |
1915 | ModePadFragmentation(0,0,0,2); | |
8ec526a4 | 1916 | fDetChamb0[2] = fNfragZ[2] * fNfragRphi[2]; |
1917 | if (fDebug == 4) { | |
1918 | AliInfo(Form("For the chamber 0: %d",fDetChamb0[2])); | |
77566f2a | 1919 | } |
8ec526a4 | 1920 | fNtotal[2] += 6 * 4 * 18 * fDetChamb0[2]; |
1921 | AliInfo(Form("Total number of Xbins: %d",fNtotal[2])); | |
77566f2a | 1922 | |
8ec526a4 | 1923 | // Create the 2D histo |
1924 | if (fHisto2d) { | |
1925 | CreatePRF2d(fNtotal[2]); | |
1926 | } | |
1927 | if (fVector2d) { | |
1928 | fVectorPRF = new TObjArray(); | |
1929 | fPlaPRF = new TObjArray(); | |
1930 | } | |
77566f2a | 1931 | |
1932 | } | |
1933 | ||
1934 | return kTRUE; | |
1935 | ||
1936 | } | |
1937 | ||
8ec526a4 | 1938 | //____________Functions for filling the histos in the code_____________________ |
77566f2a | 1939 | |
8ec526a4 | 1940 | //____________Offine tracking in the AliTRDtracker_____________________________ |
1941 | Bool_t AliTRDCalibra::ResetTrack() | |
77566f2a | 1942 | { |
1943 | // | |
8ec526a4 | 1944 | // For the offline tracking |
1945 | // This function will be called in the function | |
1946 | // AliTRDtracker::FollowBackPropagation() at the beginning | |
1947 | // Reset the parameter to know we have a new TRD track | |
77566f2a | 1948 | // |
1949 | ||
1950 | fDetectorAliTRDtrack = kFALSE; | |
1951 | return kTRUE; | |
77566f2a | 1952 | |
8ec526a4 | 1953 | } |
77566f2a | 1954 | |
8ec526a4 | 1955 | //____________Offline tracking in the AliTRDtracker____________________________ |
77566f2a | 1956 | Bool_t AliTRDCalibra::UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t) |
1957 | { | |
1958 | // | |
8ec526a4 | 1959 | // For the offline tracking |
1960 | // This function will be called in the function | |
1961 | // AliTRDtracker::FollowBackPropagation() in the loop over the clusters | |
1962 | // of TRD tracks | |
1963 | // Fill the 2D histos or the vectors with the info of the clusters at | |
1964 | // the end of a detectors if the track is "good" | |
77566f2a | 1965 | // |
1966 | ||
8ec526a4 | 1967 | // Get the parameter object |
77566f2a | 1968 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); |
1969 | if (!parCom) { | |
1970 | AliInfo("Could not get CommonParam"); | |
1971 | return kFALSE; | |
1972 | } | |
1973 | ||
1974 | // Get the parameter object | |
1975 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
1976 | if (!cal) { | |
1977 | AliInfo("Could not get calibDB"); | |
1978 | return kFALSE; | |
1979 | } | |
1980 | ||
8ec526a4 | 1981 | // Localisation of the detector |
77566f2a | 1982 | Int_t detector = cl->GetDetector(); |
8ec526a4 | 1983 | Int_t chamber = GetChamber(detector); |
1984 | Int_t plane = GetPlane(detector); | |
77566f2a | 1985 | |
8ec526a4 | 1986 | // Fill the infos for the previous clusters if not the same |
1987 | // detector anymore or if not the same track | |
1988 | if (((detector != fDetectorPreviousTrack) || (!fDetectorAliTRDtrack)) && | |
1989 | (fDetectorPreviousTrack != -1)) { | |
1990 | ||
1991 | fNumberTrack++; | |
77566f2a | 1992 | |
8ec526a4 | 1993 | // If the same track, then look if the previous detector is in |
1994 | // the same plane, if yes: not a good track | |
1995 | if (fDetectorAliTRDtrack && | |
1996 | (GetPlane(detector) <= GetPlane(fDetectorPreviousTrack))) { | |
77566f2a | 1997 | fGoodTrack = kFALSE; |
1998 | } | |
1999 | ||
8ec526a4 | 2000 | // Fill only if the track doesn't touch a masked pad or doesn't |
2001 | // appear in the middle (fGoodTrack) | |
2002 | if (fGoodTrack) { | |
77566f2a | 2003 | |
8ec526a4 | 2004 | // Gain calibration |
2005 | if (fCH2dOn) { | |
77566f2a | 2006 | FillTheInfoOfTheTrackCH(); |
8ec526a4 | 2007 | } |
77566f2a | 2008 | |
8ec526a4 | 2009 | // PH calibration |
2010 | if (fPH2dOn) { | |
77566f2a | 2011 | FillTheInfoOfTheTrackPH(); |
8ec526a4 | 2012 | } |
77566f2a | 2013 | |
8ec526a4 | 2014 | } // if a good track |
77566f2a | 2015 | |
8ec526a4 | 2016 | ResetfVariables(); |
77566f2a | 2017 | |
8ec526a4 | 2018 | } // Fill at the end the charge |
77566f2a | 2019 | |
8ec526a4 | 2020 | // Calcul the position of the detector |
2021 | if (detector != fDetectorPreviousTrack) { | |
2022 | LocalisationDetectorXbins(detector); | |
77566f2a | 2023 | } |
2024 | ||
8ec526a4 | 2025 | // Reset the good track for the PRF |
77566f2a | 2026 | Bool_t good = kTRUE; |
2027 | ||
8ec526a4 | 2028 | // Localisation of the cluster |
2029 | Double_t pos[3] = { 0.0, 0.0, 0.0 }; | |
77566f2a | 2030 | pos[0] = cl->GetX(); |
2031 | pos[1] = cl->GetY(); | |
2032 | pos[2] = cl->GetZ(); | |
8ec526a4 | 2033 | Int_t time = cl->GetLocalTimeBin(); |
2034 | ||
2035 | // Reset the detector | |
2036 | fDetectorPreviousTrack = detector; | |
2037 | fDetectorAliTRDtrack = kTRUE; | |
2038 | ||
2039 | // Position of the cluster | |
2040 | AliTRDpadPlane *padplane = parCom->GetPadPlane(plane,chamber); | |
2041 | Int_t row = padplane->GetPadRowNumber(pos[2]); | |
2042 | Double_t offsetz = padplane->GetPadRowOffset(row,pos[2]); | |
2043 | Double_t offsettilt = padplane->GetTiltOffset(offsetz); | |
2044 | Int_t col = padplane->GetPadColNumber(pos[1] + offsettilt,offsetz); | |
2045 | ||
2046 | // See if we are not near a masked pad | |
2047 | if (!IsPadOn(detector,col,row)) { | |
2048 | good = kFALSE; | |
77566f2a | 2049 | fGoodTrack = kFALSE; |
2050 | } | |
2051 | ||
8ec526a4 | 2052 | if (col > 0) { |
2053 | if (!IsPadOn(detector,col-1,row)) { | |
77566f2a | 2054 | fGoodTrack = kFALSE; |
8ec526a4 | 2055 | good = kFALSE; |
77566f2a | 2056 | } |
2057 | } | |
2058 | ||
8ec526a4 | 2059 | if (col < 143) { |
2060 | if (!IsPadOn(detector,col+1,row)) { | |
77566f2a | 2061 | fGoodTrack = kFALSE; |
8ec526a4 | 2062 | good = kFALSE; |
77566f2a | 2063 | } |
2064 | } | |
2065 | ||
8ec526a4 | 2066 | // Row of the cluster and position in the pad groups |
2067 | Int_t posr[3] = { 0, 0, 0 }; | |
2068 | if ((fCH2dOn) && (fNnZ[0] != 0)) { | |
2069 | posr[0] = (Int_t) row / fNnZ[0]; | |
2070 | } | |
2071 | if ((fPH2dOn) && (fNnZ[1] != 0)) { | |
2072 | posr[1] = (Int_t) row / fNnZ[1]; | |
2073 | } | |
2074 | if ((fPRF2dOn) && (fNnZ[2] != 0)) { | |
2075 | posr[2] = (Int_t) row / fNnZ[2]; | |
2076 | } | |
77566f2a | 2077 | |
8ec526a4 | 2078 | // Col of the cluster and position in the pad groups |
2079 | Int_t posc[3] = { 0, 0, 0 }; | |
2080 | if ((fCH2dOn) && (fNnRphi[0] != 0)) { | |
2081 | posc[0] = (Int_t) col / fNnRphi[0]; | |
2082 | } | |
2083 | if ((fPH2dOn) && (fNnRphi[1] != 0)) { | |
2084 | posc[1] = (Int_t) col / fNnRphi[1]; | |
2085 | } | |
2086 | if ((fPRF2dOn) && (fNnRphi[2] != 0)) { | |
2087 | posc[2] = (Int_t) col / fNnRphi[2]; | |
2088 | } | |
77566f2a | 2089 | |
8ec526a4 | 2090 | // Charge in the cluster |
2091 | // For the moment take the abs | |
2092 | Float_t q = TMath::Abs(cl->GetQ()); | |
2093 | Short_t *signals = cl->GetSignals(); | |
77566f2a | 2094 | |
8ec526a4 | 2095 | // Correction due to the track angle |
2096 | Float_t correction = 1.0; | |
77566f2a | 2097 | Float_t normalisation = 6.67; |
8ec526a4 | 2098 | if ((q >0) && (t->GetNdedx() > 0)) { |
2099 | correction = t->GetClusterdQdl((t->GetNdedx() - 1)) / (q * normalisation); | |
77566f2a | 2100 | } |
77566f2a | 2101 | |
8ec526a4 | 2102 | // Fill the fAmpTotal with the charge |
2103 | if (fCH2dOn) { | |
2104 | if (!fTraMaxPad){ | |
2105 | fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += q * correction; | |
2106 | } | |
2107 | else { | |
2108 | fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += ((Float_t) signals[3]) * correction; | |
2109 | } | |
2110 | } | |
2111 | ||
2112 | // Fill the fPHPlace and value | |
2113 | if (fPH2dOn) { | |
2114 | fPHPlace[time] = posc[1]*fNfragZ[1]+posr[1]; | |
2115 | if (!fTraMaxPad) { | |
2116 | fPHValue[time] = q * correction; | |
2117 | } | |
2118 | else { | |
2119 | fPHValue[time] = ((Float_t) signals[3]) * correction; | |
2120 | } | |
2121 | } | |
77566f2a | 2122 | |
8ec526a4 | 2123 | // Fill direct the PRF |
2124 | if ((fPRF2dOn) && (good)) { | |
77566f2a | 2125 | |
8ec526a4 | 2126 | Float_t yminus = 0.0; |
77566f2a | 2127 | Float_t xcenter = 0.0; |
2128 | Float_t ycenter = 0.0; | |
8ec526a4 | 2129 | Float_t ymax = 0.0; |
2130 | Bool_t echec = kFALSE; | |
77566f2a | 2131 | |
8ec526a4 | 2132 | if ((cl->From3pad()) && (!cl->IsUsed())) { |
77566f2a | 2133 | |
8ec526a4 | 2134 | // Center 3 balanced |
2135 | if ((((Float_t) signals[3]) > fThresholdClusterPRF2) && | |
2136 | (((Float_t) signals[2]) > fThresholdClusterPRF2) && | |
2137 | (((Float_t) signals[4]) > fThresholdClusterPRF2) && | |
2138 | (((Float_t) signals[1]) < fThresholdClusterPRF1) && | |
2139 | (((Float_t) signals[5]) < fThresholdClusterPRF1) && | |
2140 | (q * correction > 130.0)) { | |
2141 | // Col correspond to signals[3] | |
2142 | if (fCenterOfflineCluster) { | |
2143 | xcenter = cl->GetCenter(); | |
2144 | } | |
2145 | else { | |
2146 | // Security of the denomiateur is 0 | |
2147 | if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) / | |
2148 | ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) { | |
2149 | xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2])))) | |
2150 | / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) | |
2151 | / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4]))))); | |
2152 | } | |
2153 | else { | |
2154 | xcenter = -100.0; | |
77566f2a | 2155 | } |
77566f2a | 2156 | } |
8ec526a4 | 2157 | if ((xcenter > -0.5) && (xcenter < 0.5)) { |
2158 | ycenter = (Float_t) (((Float_t) signals[3]) | |
2159 | / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])))); | |
2160 | yminus = (Float_t) (((Float_t) signals[2]) | |
2161 | / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])))); | |
2162 | ymax = (Float_t) (((Float_t) signals[4]) | |
2163 | / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])))); | |
2164 | if ((ycenter > 0.485) && | |
2165 | (TMath::Abs(((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])) - q) < 8.0)) { | |
2166 | echec = kTRUE; | |
2167 | } | |
77566f2a | 2168 | } |
2169 | } | |
2170 | ||
8ec526a4 | 2171 | // Fill only if it is in the drift region! |
2172 | if ((((Float_t) (((Float_t) time) / fSf)) > 0.3) && (echec)) { | |
2173 | if (fHisto2d) { | |
2174 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),xcenter,ycenter); | |
2175 | if (xcenter < 0.0) { | |
2176 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),-(xcenter+1.0),yminus); | |
2177 | } | |
2178 | if (xcenter > 0.0) { | |
2179 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),1.0-xcenter,ymax); | |
2180 | } | |
77566f2a | 2181 | } |
8ec526a4 | 2182 | if (fVector2d) { |
2183 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],xcenter,ycenter); | |
2184 | if (xcenter < 0.0) { | |
2185 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],-(xcenter+1.0),yminus); | |
2186 | } | |
2187 | if (xcenter > 0.0) { | |
2188 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],1.0-xcenter,ymax); | |
2189 | } | |
77566f2a | 2190 | } |
8ec526a4 | 2191 | } // If in the drift region |
2192 | ||
2193 | } // Cluster isole | |
2194 | ||
2195 | } // PRF2dOn | |
77566f2a | 2196 | |
2197 | return kTRUE; | |
2198 | ||
2199 | } | |
2200 | ||
8ec526a4 | 2201 | //____________Online trackling in AliTRDtrigger________________________________ |
2202 | Bool_t AliTRDCalibra::UpdateHistogramcm(AliTRDmcmTracklet *trk) | |
77566f2a | 2203 | { |
2204 | // | |
8ec526a4 | 2205 | // For the tracking |
2206 | // This function will be called in the function AliTRDtrigger::TestTracklet | |
2207 | // before applying the pt cut on the tracklets | |
2208 | // Fill the infos for the tracklets fTrkTest if the tracklets is "good" | |
77566f2a | 2209 | // |
2210 | ||
8ec526a4 | 2211 | // Localisation of the Xbins involved |
2212 | Int_t idect = trk->GetDetector(); | |
2213 | LocalisationDetectorXbins(idect); | |
77566f2a | 2214 | |
2215 | // Get the parameter object | |
8ec526a4 | 2216 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 2217 | if (!cal) { |
2218 | AliInfo("Could not get calibDB"); | |
2219 | return kFALSE; | |
2220 | } | |
2221 | ||
8ec526a4 | 2222 | // Reset |
2223 | ResetfVariables(); | |
2224 | ||
2225 | // Row of the tracklet and position in the pad groups | |
2226 | Int_t row = trk->GetRow(); | |
2227 | Int_t posr[3] = { 0, 0, 0 }; | |
2228 | if ((fCH2dOn) && (fNnZ[0] != 0)) { | |
2229 | posr[0] = (Int_t) row / fNnZ[0]; | |
2230 | } | |
2231 | if ((fPH2dOn) && (fNnZ[1] != 0)) { | |
2232 | posr[1] = (Int_t) row / fNnZ[1]; | |
2233 | } | |
2234 | if ((fPRF2dOn) && (fNnZ[2] != 0)) { | |
2235 | posr[2] = (Int_t) row / fNnZ[2]; | |
2236 | } | |
2237 | ||
2238 | // Eventuelle correction due to track angle in z direction | |
77566f2a | 2239 | Float_t correction = 1.0; |
8ec526a4 | 2240 | if (fMcmCorrectAngle) { |
2241 | Float_t z = trk->GetRowz(); | |
2242 | Float_t r = trk->GetTime0(); | |
2243 | correction = r / TMath::Sqrt((r*r+z*z)); | |
77566f2a | 2244 | } |
8ec526a4 | 2245 | |
2246 | // Boucle sur les clusters | |
2247 | // Condition on number of cluster: don't come from the middle of the detector | |
2248 | if (trk->GetNclusters() >= fNumberClusters) { | |
2249 | ||
2250 | for (Int_t icl = 0; icl < trk->GetNclusters(); icl++) { | |
2251 | ||
2252 | Float_t amp[3] = { 0.0, 0.0, 0.0 }; | |
2253 | Int_t time = trk->GetClusterTime(icl); | |
2254 | Int_t col = trk->GetClusterCol(icl); | |
77566f2a | 2255 | |
8ec526a4 | 2256 | amp[0] = trk->GetClusterADC(icl)[0] * correction; |
2257 | amp[1] = trk->GetClusterADC(icl)[1] * correction; | |
2258 | amp[2] = trk->GetClusterADC(icl)[2] * correction; | |
77566f2a | 2259 | |
8ec526a4 | 2260 | if ((amp[0] < 0.0) || |
2261 | (amp[1] < 0.0) || | |
2262 | (amp[2] < 0.0)) { | |
2263 | continue; | |
2264 | } | |
2265 | ||
2266 | // Col of cluster and position in the pad groups | |
2267 | Int_t posc[3] = { 0, 0, 0 }; | |
2268 | if ((fCH2dOn) && (fNnRphi[0] != 0)) { | |
2269 | posc[0] = (Int_t) col / fNnRphi[0]; | |
2270 | } | |
2271 | if ((fPH2dOn) && (fNnRphi[1] != 0)) { | |
2272 | posc[1] = (Int_t) col / fNnRphi[1]; | |
2273 | } | |
2274 | if ((fPRF2dOn) && (fNnRphi[2] != 0)) { | |
2275 | posc[2] = (Int_t) col / fNnRphi[2]; | |
2276 | } | |
2277 | ||
2278 | // See if we are not near a masked pad | |
77566f2a | 2279 | Bool_t good = kTRUE; |
8ec526a4 | 2280 | if (!IsPadOn(idect,col,row)) { |
77566f2a | 2281 | fGoodTrack = kFALSE; |
8ec526a4 | 2282 | good = kFALSE; |
77566f2a | 2283 | } |
8ec526a4 | 2284 | |
2285 | if (col > 0) { | |
2286 | if (!IsPadOn(idect,col-1,row)) { | |
77566f2a | 2287 | fGoodTrack = kFALSE; |
8ec526a4 | 2288 | good = kFALSE; |
77566f2a | 2289 | } |
2290 | } | |
2291 | ||
8ec526a4 | 2292 | if (col < 143) { |
2293 | if (!IsPadOn(idect,col+1,row)) { | |
77566f2a | 2294 | fGoodTrack = kFALSE; |
8ec526a4 | 2295 | good = kFALSE; |
77566f2a | 2296 | } |
2297 | } | |
77566f2a | 2298 | |
8ec526a4 | 2299 | // Total spectrum |
2300 | if (fPH2dOn) { | |
2301 | fPHPlace[time] = posc[1] * fNfragZ[1] + posr[1]; | |
77566f2a | 2302 | } |
77566f2a | 2303 | |
8ec526a4 | 2304 | if (!fTraMaxPad) { |
2305 | if (fCH2dOn) { | |
2306 | fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += (Float_t) (amp[0]+amp[1]+amp[2]); | |
2307 | } | |
2308 | if (fPH2dOn) { | |
2309 | fPHValue[time] = (Float_t) (amp[0]+amp[1]+amp[2]); | |
2310 | } | |
2311 | } | |
2312 | else { | |
2313 | if (fCH2dOn) { | |
2314 | fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += (Float_t) amp[1]; | |
2315 | } | |
2316 | if (fPH2dOn) { | |
2317 | fPHValue[time] = amp[1]; | |
2318 | } | |
77566f2a | 2319 | } |
2320 | ||
8ec526a4 | 2321 | // Fill PRF direct |
2322 | if (fPRF2dOn && good) { | |
2323 | if ((amp[0] > fThresholdClusterPRF2) && | |
2324 | (amp[1] > fThresholdClusterPRF2) && | |
2325 | (amp[2] > fThresholdClusterPRF2) && | |
2326 | ((amp[0]+amp[1]+amp[2]) > 130.0)) { | |
2327 | // Security of the denomiateur is 0 | |
2328 | if ((((Float_t) (((Float_t) amp[1]) * ((Float_t) amp[1]))) | |
2329 | / ((Float_t) (((Float_t) amp[0]) * ((Float_t) amp[2])))) != 1.0) { | |
2330 | Float_t xcenter = 0.5 * (TMath::Log(amp[2] / amp[0])) | |
2331 | / (TMath::Log((amp[1]*amp[1]) / (amp[0]*amp[2]))); | |
2332 | Float_t ycenter = amp[1] / (amp[0] + amp[1] + amp[2]); | |
2333 | if ((xcenter > -0.5) && | |
2334 | (xcenter < 0.5) && | |
2335 | (ycenter > 0.485)) { | |
2336 | Float_t yminus = amp[0] / (amp[0]+amp[1]+amp[2]); | |
2337 | Float_t ymax = amp[2] / (amp[0]+amp[1]+amp[2]); | |
2338 | // Fill only if it is in the drift region! | |
2339 | if (((Float_t) time / fSf) > 0.3) { | |
2340 | if (fHisto2d) { | |
2341 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),xcenter,ycenter); | |
2342 | if (xcenter < 0.0) { | |
2343 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),-(xcenter+1.0),yminus); | |
2344 | } | |
2345 | if (xcenter > 0.0) { | |
2346 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),(1.0-xcenter),ymax); | |
2347 | } | |
2348 | } | |
2349 | if (fVector2d) { | |
2350 | UpdateVectorPRF((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]),xcenter,ycenter); | |
2351 | if (xcenter < 0.0) { | |
2352 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],-(xcenter+1.0),yminus); | |
2353 | } | |
2354 | if (xcenter > 0.0) { | |
2355 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],(1.0-xcenter),ymax); | |
77566f2a | 2356 | } |
77566f2a | 2357 | } |
2358 | } | |
2359 | } | |
2360 | } | |
2361 | } | |
2362 | } | |
2363 | ||
8ec526a4 | 2364 | } // Boucle clusters |
77566f2a | 2365 | |
8ec526a4 | 2366 | // Fill the charge |
2367 | if (fCH2dOn && fGoodTrack) { | |
77566f2a | 2368 | FillTheInfoOfTheTrackCH(); |
8ec526a4 | 2369 | } |
77566f2a | 2370 | |
8ec526a4 | 2371 | // PH calibration |
2372 | if (fPH2dOn && fGoodTrack) { | |
2373 | FillTheInfoOfTheTrackPH(); | |
2374 | } | |
77566f2a | 2375 | |
8ec526a4 | 2376 | } // Condition on number of clusters |
2377 | ||
77566f2a | 2378 | return kTRUE; |
2379 | ||
2380 | } | |
2381 | ||
8ec526a4 | 2382 | //____________Functions for seeing if the pad is really okey___________________ |
77566f2a | 2383 | |
8ec526a4 | 2384 | //_____________________________________________________________________________ |
2385 | Bool_t AliTRDCalibra::SetModeCalibrationFromTObject(TObject *object, Int_t i) | |
77566f2a | 2386 | { |
2387 | // | |
8ec526a4 | 2388 | // Set fNz[i] and fNrphi[i] of the AliTRDCalibra::Instance() |
2389 | // corresponding to the given TObject | |
77566f2a | 2390 | // |
8ec526a4 | 2391 | |
2392 | const char *nametitle = object->GetTitle(); | |
2393 | ||
2394 | // Some patterns | |
2395 | const Char_t *patternz0 = "Nz0"; | |
2396 | const Char_t *patternz1 = "Nz1"; | |
2397 | const Char_t *patternz2 = "Nz2"; | |
2398 | const Char_t *patternz3 = "Nz3"; | |
2399 | const Char_t *patternz4 = "Nz4"; | |
2400 | const Char_t *patternrphi0 = "Nrphi0"; | |
2401 | const Char_t *patternrphi1 = "Nrphi1"; | |
2402 | const Char_t *patternrphi2 = "Nrphi2"; | |
2403 | const Char_t *patternrphi3 = "Nrphi3"; | |
2404 | const Char_t *patternrphi4 = "Nrphi4"; | |
2405 | const Char_t *patternrphi5 = "Nrphi5"; | |
2406 | const Char_t *patternrphi6 = "Nrphi6"; | |
2407 | ||
2408 | UShort_t testz = 0; | |
2409 | UShort_t testrphi = 0; | |
2410 | ||
2411 | // Nz mode | |
2412 | if (strstr(nametitle,patternz0)) { | |
2413 | testz++; | |
2414 | fNz[i] = 0; | |
2415 | } | |
2416 | if (strstr(nametitle,patternz1)) { | |
2417 | testz++; | |
2418 | fNz[i] = 1; | |
2419 | } | |
2420 | if (strstr(nametitle,patternz2)) { | |
2421 | testz++; | |
2422 | fNz[i] = 2; | |
2423 | } | |
2424 | if (strstr(nametitle,patternz3)) { | |
2425 | testz++; | |
2426 | fNz[i] = 3; | |
2427 | } | |
2428 | if (strstr(nametitle,patternz4)) { | |
2429 | testz++; | |
2430 | fNz[i] = 4; | |
2431 | } | |
2432 | ||
2433 | // Nrphi mode | |
2434 | if (strstr(nametitle,patternrphi0)) { | |
2435 | testrphi++; | |
2436 | fNrphi[i] = 0; | |
2437 | } | |
2438 | if (strstr(nametitle,patternrphi1)) { | |
2439 | testrphi++; | |
2440 | fNrphi[i] = 1; | |
2441 | } | |
2442 | if (strstr(nametitle,patternrphi2)) { | |
2443 | testrphi++; | |
2444 | fNrphi[i] = 2; | |
2445 | } | |
2446 | if (strstr(nametitle,patternrphi3)) { | |
2447 | testrphi++; | |
2448 | fNrphi[i] = 3; | |
2449 | } | |
2450 | if (strstr(nametitle,patternrphi4)) { | |
2451 | testrphi++; | |
2452 | fNrphi[i] = 4; | |
2453 | } | |
2454 | if (strstr(nametitle,patternrphi5)) { | |
2455 | testrphi++; | |
2456 | fNrphi[i] = 5; | |
2457 | } | |
2458 | if (strstr(nametitle,patternrphi6)) { | |
2459 | testrphi++; | |
2460 | fNrphi[i] = 6; | |
2461 | } | |
2462 | ||
2463 | // Look if all is okey | |
2464 | if ((testz == 1) && | |
2465 | (testrphi == 1)) { | |
2466 | return kTRUE; | |
2467 | } | |
2468 | else { | |
2469 | fNrphi[i] = 0; | |
2470 | fNz[i] = 0; | |
2471 | return kFALSE; | |
2472 | } | |
77566f2a | 2473 | |
8ec526a4 | 2474 | } |
2475 | ||
2476 | //_____________________________________________________________________________ | |
2477 | Bool_t AliTRDCalibra::IsPadOn(Int_t detector, Int_t col, Int_t row) const | |
2478 | { | |
2479 | // | |
2480 | // Look in the choosen database if the pad is On. | |
2481 | // If no the track will be "not good" | |
2482 | // | |
77566f2a | 2483 | |
2484 | // Get the parameter object | |
8ec526a4 | 2485 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 2486 | if (!cal) { |
2487 | AliInfo("Could not get calibDB"); | |
2488 | return kFALSE; | |
2489 | } | |
2490 | ||
8ec526a4 | 2491 | Int_t npads = 18; |
2492 | Int_t colmcm = (Int_t) col / npads; | |
77566f2a | 2493 | |
8ec526a4 | 2494 | if (!cal->IsChamberInstalled(detector) || |
2495 | cal->IsChamberMasked(detector) || | |
2496 | cal->IsMCMMasked(detector,colmcm,row) || | |
2497 | cal->IsPadMasked(detector,col,row)) { | |
77566f2a | 2498 | return kFALSE; |
2499 | } | |
8ec526a4 | 2500 | else { |
2501 | return kTRUE; | |
2502 | } | |
77566f2a | 2503 | |
2504 | } | |
2505 | ||
8ec526a4 | 2506 | //____________Functions for plotting the 2D____________________________________ |
77566f2a | 2507 | |
8ec526a4 | 2508 | //_____________________________________________________________________________ |
77566f2a | 2509 | void AliTRDCalibra::Plot2d() |
2510 | { | |
2511 | // | |
2512 | // Plot the 2D histos | |
2513 | // | |
2514 | ||
8ec526a4 | 2515 | if (fCH2dOn) { |
2516 | PlotCH2d(); | |
2517 | } | |
2518 | if (fPH2dOn) { | |
2519 | PlotPH2d(); | |
2520 | } | |
2521 | if (fPRF2dOn) { | |
2522 | PlotPRF2d(); | |
2523 | } | |
77566f2a | 2524 | |
2525 | } | |
77566f2a | 2526 | |
8ec526a4 | 2527 | //____________Writing the 2D___________________________________________________ |
2528 | ||
2529 | //_____________________________________________________________________________ | |
77566f2a | 2530 | Bool_t AliTRDCalibra::Write2d() |
2531 | { | |
2532 | // | |
8ec526a4 | 2533 | // Write the 2D histograms or the vectors converted in trees in the file |
2534 | // "TRD.calibration.root" | |
77566f2a | 2535 | // |
2536 | ||
2537 | TFile *fout = TFile::Open(fWriteName,"RECREATE"); | |
8ec526a4 | 2538 | // Check if the file could be opened |
77566f2a | 2539 | if (!fout || !fout->IsOpen()) { |
2540 | AliInfo("No File found!"); | |
2541 | return kFALSE; | |
2542 | } | |
8ec526a4 | 2543 | AliInfo(Form("Numbertrack: %d Numberusedch[0]: %d, Numberusedch[1]: %d Numberusedph[0]: %d, Numberusedph[1]: %d" |
2544 | ,fNumberTrack | |
2545 | ,fNumberUsedCh[0] | |
2546 | ,fNumberUsedCh[1] | |
2547 | ,fNumberUsedPh[0] | |
2548 | ,fNumberUsedPh[1])); | |
77566f2a | 2549 | |
2550 | TStopwatch stopwatch; | |
2551 | stopwatch.Start(); | |
2552 | AliInfo("Write2d"); | |
8ec526a4 | 2553 | |
2554 | if ((fCH2dOn ) && (fWrite[0])) { | |
2555 | if (fHisto2d) { | |
2556 | fout->WriteTObject(fCH2d); | |
2557 | } | |
2558 | if (fVector2d) { | |
2559 | TString name("Nz"); | |
2560 | name += fNz[0]; | |
2561 | name += "Nrphi"; | |
2562 | name += fNrphi[0]; | |
2563 | TTree *treeCH2d = ConvertVectorCTTreeHisto(fVectorCH,fPlaCH,"treeCH2d",(const char *) name); | |
77566f2a | 2564 | fout->WriteTObject(treeCH2d); |
2565 | } | |
2566 | } | |
8ec526a4 | 2567 | if ((fPH2dOn ) && (fWrite[1])) { |
2568 | if (fHisto2d) { | |
2569 | fout->WriteTObject(fPH2d); | |
2570 | } | |
2571 | if (fVector2d) { | |
2572 | TString name("Nz"); | |
2573 | name += fNz[1]; | |
2574 | name += "Nrphi"; | |
2575 | name += fNrphi[1]; | |
2576 | TTree *treePH2d = ConvertVectorPTreeHisto(fVectorPH,fPlaPH,"treePH2d",(const char *) name); | |
77566f2a | 2577 | fout->WriteTObject(treePH2d); |
2578 | } | |
2579 | } | |
8ec526a4 | 2580 | if ((fPRF2dOn ) && (fWrite[2])) { |
2581 | if (fHisto2d) { | |
2582 | fout->WriteTObject(fPRF2d); | |
2583 | } | |
2584 | if (fVector2d) { | |
2585 | TString name("Nz"); | |
2586 | name += fNz[2]; | |
2587 | name += "Nrphi"; | |
2588 | name += fNrphi[2]; | |
2589 | TTree *treePRF2d = ConvertVectorPTreeHisto(fVectorPRF,fPlaPRF,"treePRF2d",(const char *) name); | |
77566f2a | 2590 | fout->WriteTObject(treePRF2d); |
2591 | } | |
2592 | } | |
2593 | ||
2594 | fout->Close(); | |
2595 | ||
8ec526a4 | 2596 | AliInfo(Form("Execution time Write2d: R:%.2fs C:%.2fs" |
2597 | ,stopwatch.RealTime(),stopwatch.CpuTime())); | |
2598 | ||
77566f2a | 2599 | return kTRUE; |
2600 | ||
2601 | } | |
8ec526a4 | 2602 | |
2603 | //_____________________________________________________________________________ | |
2604 | AliTRDCalDet *AliTRDCalibra::CreateDetObjectTree(TTree *tree, Int_t i) | |
77566f2a | 2605 | { |
2606 | // | |
8ec526a4 | 2607 | // It creates the AliTRDCalDet object from the tree of the coefficient |
2608 | // for the calibration i (i != 2) | |
77566f2a | 2609 | // It takes the mean value of the coefficients per detector |
2610 | // This object has to be written in the database | |
2611 | // | |
2612 | ||
8ec526a4 | 2613 | // Create the DetObject |
77566f2a | 2614 | AliTRDCalDet *object = 0x0; |
8ec526a4 | 2615 | if (i == 0) { |
2616 | object = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)"); | |
2617 | } | |
2618 | if (i == 1) { | |
2619 | object = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)"); | |
2620 | } | |
2621 | else { | |
2622 | object = new AliTRDCalDet("ChamberT0","T0 (detector value)"); | |
2623 | } | |
77566f2a | 2624 | |
8ec526a4 | 2625 | // Read the Tree |
2626 | Int_t detector = -1; | |
77566f2a | 2627 | Float_t values[2304]; |
2628 | tree->SetBranchAddress("detector",&detector); | |
8ec526a4 | 2629 | if (i == 0) { |
2630 | tree->SetBranchAddress("gainPad",values); | |
2631 | } | |
2632 | if (i == 1) { | |
2633 | tree->SetBranchAddress("vdrift" ,values); | |
2634 | } | |
2635 | if (i == 3) { | |
2636 | tree->SetBranchAddress("t0" ,values); | |
2637 | } | |
77566f2a | 2638 | |
8ec526a4 | 2639 | // For calculating the mean |
2640 | Float_t mean = 0.0; | |
2641 | Int_t nto = 0; | |
2642 | Int_t numberofentries = tree->GetEntries(); | |
77566f2a | 2643 | |
8ec526a4 | 2644 | if (numberofentries != 540) { |
2645 | AliInfo("The tree is not complete"); | |
2646 | } | |
77566f2a | 2647 | |
8ec526a4 | 2648 | for (Int_t det = 0; det < numberofentries; ++det) { |
77566f2a | 2649 | tree->GetEntry(det); |
8ec526a4 | 2650 | if (GetChamber(detector) == 2) { |
2651 | nto = 1728; | |
2652 | } | |
2653 | else { | |
2654 | nto = 2304; | |
2655 | } | |
77566f2a | 2656 | mean = 0.0; |
8ec526a4 | 2657 | for (Int_t k = 0; k < nto; k++) { |
2658 | mean += TMath::Abs(values[k]) / nto; | |
2659 | } | |
77566f2a | 2660 | object->SetValue(detector,mean); |
2661 | } | |
8ec526a4 | 2662 | |
77566f2a | 2663 | return object; |
8ec526a4 | 2664 | |
77566f2a | 2665 | } |
8ec526a4 | 2666 | |
2667 | //_____________________________________________________________________________ | |
2668 | TObject *AliTRDCalibra::CreatePadObjectTree(TTree *tree, Int_t i | |
2669 | , AliTRDCalDet *detobject) | |
77566f2a | 2670 | { |
2671 | // | |
8ec526a4 | 2672 | // It Creates the AliTRDCalPad object from the tree of the |
2673 | // coefficient for the calibration i (i != 2) | |
2674 | // You need first to create the object for the detectors, | |
2675 | // where the mean value is put. | |
77566f2a | 2676 | // This object has to be written in the database |
2677 | // | |
2678 | ||
8ec526a4 | 2679 | // Create the DetObject |
77566f2a | 2680 | AliTRDCalPad *object = 0x0; |
8ec526a4 | 2681 | if (i == 0) { |
2682 | object = new AliTRDCalPad("GainFactor","GainFactor (local variations)"); | |
2683 | } | |
2684 | if (i == 1) { | |
2685 | object = new AliTRDCalPad("LocalVdrift","TRD drift velocities (local variations)"); | |
2686 | } | |
2687 | else { | |
2688 | object = new AliTRDCalPad("LocalT0","T0 (local variations)"); | |
2689 | } | |
77566f2a | 2690 | |
8ec526a4 | 2691 | // Read the Tree |
2692 | Int_t detector = -1; | |
77566f2a | 2693 | Float_t values[2304]; |
2694 | tree->SetBranchAddress("detector",&detector); | |
8ec526a4 | 2695 | if (i == 0) { |
2696 | tree->SetBranchAddress("gainPad",values); | |
2697 | } | |
2698 | if (i == 1) { | |
2699 | tree->SetBranchAddress("vdrift" ,values); | |
2700 | } | |
2701 | if (i == 3) { | |
2702 | tree->SetBranchAddress("t0" ,values); | |
2703 | } | |
77566f2a | 2704 | |
8ec526a4 | 2705 | // Variables |
2706 | Float_t mean = 0.0; | |
2707 | Int_t numberofentries = tree->GetEntries(); | |
77566f2a | 2708 | |
8ec526a4 | 2709 | if (numberofentries != 540) { |
2710 | AliInfo("The tree is not complete"); | |
2711 | } | |
77566f2a | 2712 | |
8ec526a4 | 2713 | for (Int_t det = 0; det < numberofentries; ++det) { |
77566f2a | 2714 | tree->GetEntry(det); |
2715 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2716 | mean = detobject->GetValue(detector); | |
8ec526a4 | 2717 | if (mean == 0) { |
2718 | continue; | |
2719 | } | |
77566f2a | 2720 | Int_t rowMax = calROC->GetNrows(); |
2721 | Int_t colMax = calROC->GetNcols(); | |
8ec526a4 | 2722 | for (Int_t row = 0; row < rowMax; ++row) { |
2723 | for (Int_t col = 0; col < colMax; ++col) { | |
2724 | if (i == 0) { | |
2725 | calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])/mean); | |
2726 | } | |
2727 | if (i == 1) { | |
2728 | calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])/mean); | |
2729 | } | |
2730 | if (i == 3) { | |
2731 | if (values[(Int_t) (col*rowMax+row)]/mean < 0.0) { | |
2732 | calROC->SetValue(col,row,0.0); | |
2733 | } | |
2734 | if (values[(Int_t) (col*rowMax+row)]/mean >= 0.0) { | |
2735 | calROC->SetValue(col,row,values[(Int_t) (col*rowMax+row)]/mean); | |
2736 | } | |
2737 | } | |
2738 | } // Col | |
2739 | } // Row | |
77566f2a | 2740 | } |
8ec526a4 | 2741 | |
77566f2a | 2742 | return object; |
8ec526a4 | 2743 | |
77566f2a | 2744 | } |
8ec526a4 | 2745 | |
2746 | //_____________________________________________________________________________ | |
2747 | TObject *AliTRDCalibra::CreatePadObjectTree(TTree *tree) | |
77566f2a | 2748 | { |
2749 | // | |
8ec526a4 | 2750 | // It Creates the AliTRDCalPad object from the tree of the |
2751 | // coefficient for the calibration PRF (i = 2) | |
77566f2a | 2752 | // This object has to be written in the database |
2753 | // | |
2754 | ||
8ec526a4 | 2755 | // Create the DetObject |
77566f2a | 2756 | AliTRDCalPad *object = new AliTRDCalPad("PRFWidth","PRFWidth"); |
2757 | ||
8ec526a4 | 2758 | // Read the Tree |
2759 | Int_t detector = -1; | |
77566f2a | 2760 | Float_t values[2304]; |
2761 | tree->SetBranchAddress("detector",&detector); | |
8ec526a4 | 2762 | tree->SetBranchAddress("width" ,values); |
77566f2a | 2763 | |
8ec526a4 | 2764 | // Variables |
77566f2a | 2765 | Int_t numberofentries = tree->GetEntries(); |
2766 | ||
8ec526a4 | 2767 | if (numberofentries != 540) { |
2768 | AliInfo("The tree is not complete"); | |
2769 | } | |
77566f2a | 2770 | |
8ec526a4 | 2771 | for (Int_t det = 0; det < numberofentries; ++det) { |
77566f2a | 2772 | tree->GetEntry(det); |
2773 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2774 | Int_t rowMax = calROC->GetNrows(); | |
2775 | Int_t colMax = calROC->GetNcols(); | |
8ec526a4 | 2776 | for (Int_t row = 0; row < rowMax; ++row) { |
2777 | for (Int_t col = 0; col < colMax; ++col) { | |
77566f2a | 2778 | calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])); |
8ec526a4 | 2779 | } // Col |
2780 | } // Row | |
77566f2a | 2781 | } |
8ec526a4 | 2782 | |
77566f2a | 2783 | return object; |
8ec526a4 | 2784 | |
77566f2a | 2785 | } |
8ec526a4 | 2786 | |
2787 | //_____________________________________________________________________________ | |
2788 | void AliTRDCalibra::SetRelativeScale(Float_t RelativeScale) | |
77566f2a | 2789 | { |
2790 | // | |
8ec526a4 | 2791 | // Set the factor that will divide the deposited charge |
2792 | // to fit in the histo range [0,300] | |
77566f2a | 2793 | // |
77566f2a | 2794 | |
8ec526a4 | 2795 | if (RelativeScale > 0.0) { |
2796 | fRelativeScale = RelativeScale; | |
2797 | } | |
2798 | else { | |
2799 | AliInfo("RelativeScale must be strict positif!"); | |
2800 | } | |
2801 | ||
2802 | } | |
2803 | ||
2804 | //_____________________________________________________________________________ | |
2805 | void AliTRDCalibra::SetNz(Int_t i, Short_t Nz) | |
2806 | { | |
2807 | // | |
2808 | // Set the mode of calibration group in the z direction for the parameter i | |
2809 | // | |
2810 | ||
2811 | if ((Nz >= 0) && | |
2812 | (Nz < 5)) { | |
2813 | fNz[i] = Nz; | |
2814 | } | |
2815 | else { | |
2816 | AliInfo("You have to choose between 0 and 4"); | |
2817 | } | |
2818 | ||
2819 | } | |
2820 | ||
2821 | //_____________________________________________________________________________ | |
2822 | void AliTRDCalibra::SetNrphi(Int_t i, Short_t Nrphi) | |
2823 | { | |
2824 | // | |
2825 | // Set the mode of calibration group in the rphi direction for the parameter i | |
2826 | // | |
77566f2a | 2827 | |
8ec526a4 | 2828 | if ((Nrphi >= 0) && |
2829 | (Nrphi < 7)) { | |
2830 | fNrphi[i] = Nrphi; | |
2831 | } | |
2832 | else { | |
2833 | AliInfo("You have to choose between 0 and 6"); | |
2834 | } | |
2835 | ||
2836 | } | |
2837 | ||
2838 | //_____________________________________________________________________________ | |
2839 | void AliTRDCalibra::SetPeriodeFitPH(Int_t periodeFitPH) | |
2840 | { | |
2841 | // | |
2842 | // Set FitPH if 1 then each detector will be fitted | |
2843 | // | |
2844 | ||
2845 | if (periodeFitPH > 0) { | |
2846 | fFitPHPeriode = periodeFitPH; | |
2847 | } | |
2848 | else { | |
2849 | AliInfo("periodeFitPH must be higher than 0!"); | |
2850 | } | |
2851 | ||
2852 | } | |
2853 | ||
2854 | //_____________________________________________________________________________ | |
2855 | void AliTRDCalibra::SetBeginFitCharge(Float_t beginFitCharge) | |
2856 | { | |
2857 | // | |
2858 | // The fit of the deposited charge distribution begins at | |
2859 | // histo->Mean()/beginFitCharge | |
2860 | // You can here set beginFitCharge | |
2861 | // | |
2862 | ||
2863 | if (beginFitCharge > 0) { | |
2864 | fBeginFitCharge = beginFitCharge; | |
2865 | } | |
2866 | else { | |
2867 | AliInfo("beginFitCharge must be strict positif!"); | |
2868 | } | |
2869 | ||
2870 | } | |
2871 | ||
2872 | //_____________________________________________________________________________ | |
2873 | void AliTRDCalibra::SetT0Shift(Float_t t0Shift) | |
2874 | { | |
2875 | // | |
2876 | // The t0 calculated with the maximum positif slope is shift from t0Shift | |
2877 | // You can here set t0Shift | |
2878 | // | |
2879 | ||
2880 | if (t0Shift > 0) { | |
2881 | fT0Shift = t0Shift; | |
2882 | } | |
2883 | else { | |
2884 | AliInfo("t0Shift must be strict positif!"); | |
2885 | } | |
2886 | ||
2887 | } | |
2888 | ||
2889 | //_____________________________________________________________________________ | |
2890 | void AliTRDCalibra::SetRangeFitPRF(Float_t rangeFitPRF) | |
2891 | { | |
2892 | // | |
2893 | // The fit of the PRF is from -rangeFitPRF to rangeFitPRF | |
2894 | // You can here set rangeFitPRF | |
2895 | // | |
2896 | ||
2897 | if ((rangeFitPRF > 0) && | |
2898 | (rangeFitPRF <= 1.0)) { | |
2899 | fRangeFitPRF = rangeFitPRF; | |
2900 | } | |
2901 | else { | |
2902 | AliInfo("rangeFitPRF must be between 0 and 1.0"); | |
2903 | } | |
2904 | ||
2905 | } | |
2906 | ||
2907 | //_____________________________________________________________________________ | |
2908 | void AliTRDCalibra::SetRebin(Short_t rebin) | |
2909 | { | |
2910 | // | |
2911 | // Rebin with rebin time less bins the Ch histo | |
2912 | // You can set here rebin that should divide the number of bins of CH histo | |
2913 | // | |
2914 | ||
2915 | if (rebin > 0) { | |
2916 | fRebin = rebin; | |
2917 | AliInfo("You have to be sure that fRebin divides fNumberBinCharge used!"); | |
2918 | } | |
2919 | else { | |
2920 | AliInfo("You have to choose a positiv value!"); | |
2921 | } | |
2922 | ||
2923 | } | |
2924 | ||
2925 | //_____________________________________________________________________________ | |
2926 | TTree *AliTRDCalibra::Sum2Trees(const Char_t *filename1 | |
2927 | , const Char_t *filename2 | |
2928 | , const Char_t *variablecali) | |
2929 | { | |
2930 | // | |
2931 | // It returns the sum of two trees with the name variablecali | |
2932 | // in the files filenam1 and filename2 equivalent of merging two 2D histos | |
2933 | // The name of the resulting tree is the same as the two input trees | |
2934 | // variablecali can be treeCH2d, treePH2d or treePRF2d | |
2935 | // | |
2936 | ||
2937 | // Variables | |
2938 | TChain *treeChain = new TChain(variablecali); | |
2939 | TObjArray *vectorplace = new TObjArray(); | |
2940 | TObjArray *where = new TObjArray(); | |
77566f2a | 2941 | |
8ec526a4 | 2942 | // First tree |
2943 | // Take the tree | |
2944 | TFile *file1 = new TFile(filename1,"READ"); | |
77566f2a | 2945 | TTree *tree1 = (TTree *) file1->Get(variablecali); |
8ec526a4 | 2946 | |
2947 | gDirectory = gROOT; | |
2948 | ||
2949 | // Take the places | |
77566f2a | 2950 | vectorplace = ConvertTreeVector(tree1); |
8ec526a4 | 2951 | |
2952 | // Say where it is in tree 1 | |
2953 | for (Int_t jui = 0; jui < (Int_t) vectorplace->GetEntriesFast(); jui++) { | |
2954 | AliTRDPlace *placejui = new AliTRDPlace(); | |
2955 | placejui->SetPlace(jui); | |
2956 | TObjArray *chainplace = new TObjArray(); | |
2957 | chainplace->Add((TObject *) placejui); | |
2958 | where->Add((TObject *) chainplace); | |
77566f2a | 2959 | } |
8ec526a4 | 2960 | |
2961 | // Add to the chain | |
77566f2a | 2962 | treeChain->Add(filename1); |
2963 | delete file1; | |
77566f2a | 2964 | |
8ec526a4 | 2965 | // Second tree |
2966 | // Take the tree | |
2967 | TFile *file2 = new TFile(filename2,"READ"); | |
2968 | TTree *tree2 = (TTree *) file2->Get(variablecali); | |
77566f2a | 2969 | |
8ec526a4 | 2970 | gDirectory = gROOT; |
77566f2a | 2971 | |
8ec526a4 | 2972 | // Take the places |
2973 | TObjArray *vector2 = ConvertTreeVector(tree2); | |
77566f2a | 2974 | Int_t j = treeChain->GetEntries(); |
8ec526a4 | 2975 | |
2976 | for (Int_t jui = 0; jui < (Int_t) vector2->GetEntriesFast(); jui++) { | |
2977 | // Search if already found | |
2978 | Int_t place = SearchInTreeVector(vectorplace,((AliTRDPlace *) vector2->At(jui))->GetPlace()); | |
2979 | // Create a new element in the two std vectors | |
2980 | if (place == -1) { | |
2981 | AliTRDPlace *placejjui = new AliTRDPlace(); | |
2982 | placejjui->SetPlace((j+jui)); | |
2983 | TObjArray *chainplace = new TObjArray(); | |
2984 | chainplace->Add((TObject *) placejjui); | |
2985 | vectorplace->Add((TObject *) (vector2->At(jui))); | |
2986 | where->Add((TObject *) chainplace); | |
2987 | } | |
2988 | // Update the element at the place "place" in the std vector whereinthechain | |
77566f2a | 2989 | else { |
8ec526a4 | 2990 | AliTRDPlace *placejjui = new AliTRDPlace(); |
2991 | placejjui->SetPlace((j+jui)); | |
2992 | TObjArray *chainplace = ((TObjArray *) where->At(place)); | |
2993 | chainplace->Add((TObject *) placejjui); | |
2994 | where->AddAt((TObject *) chainplace,place); | |
77566f2a | 2995 | } |
2996 | } | |
8ec526a4 | 2997 | |
2998 | // Add to the Chain | |
77566f2a | 2999 | treeChain->Add(filename2); |
3000 | delete file2; | |
77566f2a | 3001 | |
8ec526a4 | 3002 | // Take care of the profile |
3003 | const Char_t *pattern = "P"; | |
77566f2a | 3004 | TTree *tree = 0x0; |
3005 | ||
8ec526a4 | 3006 | if (!strstr(variablecali,pattern)) { |
3007 | ||
3008 | // Ready to read the chain | |
77566f2a | 3009 | TH1F *his = 0x0; |
3010 | treeChain->SetBranchAddress("histo",&his); | |
8ec526a4 | 3011 | |
3012 | // Initialise the final tree | |
3013 | Int_t group = -1; | |
77566f2a | 3014 | TH1F *histsum = 0x0; |
3015 | ||
3016 | tree = new TTree(variablecali,variablecali); | |
3017 | tree->Branch("groupnumber",&group,"groupnumber/I"); | |
3018 | tree->Branch("histo","TH1F",&histsum,32000,0); | |
8ec526a4 | 3019 | |
3020 | // Init histsum | |
3021 | if (treeChain->GetEntries() < 1) { | |
3022 | return tree1; | |
3023 | } | |
77566f2a | 3024 | |
8ec526a4 | 3025 | for (Int_t h = 0; h < (Int_t) vectorplace->GetEntriesFast(); h++) { |
3026 | group = ((AliTRDPlace *) vectorplace->At(h))->GetPlace(); | |
3027 | TObjArray *chainplace = ((TObjArray *) where->At(h)); | |
3028 | treeChain->GetEntry(((AliTRDPlace *) chainplace->At(0))->GetPlace()); | |
77566f2a | 3029 | //Init for the first time |
8ec526a4 | 3030 | if (h == 0) { |
3031 | histsum = new TH1F("","",his->GetXaxis()->GetNbins() | |
3032 | ,his->GetXaxis()->GetBinLowEdge(1) | |
3033 | ,his->GetXaxis()->GetBinUpEdge(his->GetXaxis()->GetNbins())); | |
3034 | histsum->Sumw2(); | |
77566f2a | 3035 | } |
8ec526a4 | 3036 | // Reset for each new group |
77566f2a | 3037 | histsum->SetEntries(0.0); |
8ec526a4 | 3038 | for (Int_t l = 0; l <= histsum->GetXaxis()->GetNbins(); l++) { |
77566f2a | 3039 | histsum->SetBinContent(l,0.0); |
3040 | histsum->SetBinError(l,0.0); | |
3041 | } | |
3042 | histsum->Add(his,1); | |
8ec526a4 | 3043 | if ((Int_t) chainplace->GetEntriesFast() > 1) { |
3044 | for (Int_t s = 1; s < (Int_t) chainplace->GetEntriesFast(); s++) { | |
3045 | treeChain->GetEntry(((AliTRDPlace *) chainplace->At(s))->GetPlace()); | |
77566f2a | 3046 | histsum->Add(his,1); |
3047 | } | |
3048 | } | |
3049 | tree->Fill(); | |
3050 | } | |
8ec526a4 | 3051 | |
77566f2a | 3052 | } |
8ec526a4 | 3053 | else { |
3054 | ||
3055 | // Ready to read the chain | |
77566f2a | 3056 | TGraphErrors *his = 0x0; |
3057 | treeChain->SetBranchAddress("histo",&his); | |
3058 | ||
8ec526a4 | 3059 | // Initialise the final tree |
3060 | Int_t group = -1; | |
77566f2a | 3061 | TGraphErrors *histsum = 0x0; |
8ec526a4 | 3062 | Double_t *xref = 0x0; |
77566f2a | 3063 | |
3064 | tree = new TTree(variablecali,variablecali); | |
3065 | tree->Branch("groupnumber",&group,"groupnumber/I"); | |
3066 | tree->Branch("histo","TGraphErrors",&histsum,32000,0); | |
8ec526a4 | 3067 | |
3068 | // Init histsum | |
3069 | if (treeChain->GetEntries() < 1) { | |
3070 | return tree1; | |
3071 | } | |
3072 | ||
3073 | for (Int_t h = 0; h < (Int_t) vectorplace->GetEntriesFast(); h++) { | |
3074 | ||
3075 | group = ((AliTRDPlace *) vectorplace->At(h))->GetPlace(); | |
3076 | TObjArray *chainplace = ((TObjArray *) where->At(h)); | |
3077 | treeChain->GetEntry(((AliTRDPlace *) chainplace->At(0))->GetPlace()); | |
77566f2a | 3078 | //Init or reset for a new group |
3079 | Int_t nbins = his->GetN(); | |
3080 | Double_t *x; | |
8ec526a4 | 3081 | x = new Double_t[nbins]; |
77566f2a | 3082 | xref = his->GetX(); |
3083 | Double_t *ex; | |
8ec526a4 | 3084 | ex = new Double_t[nbins]; |
77566f2a | 3085 | Double_t *y; |
8ec526a4 | 3086 | y = new Double_t[nbins]; |
77566f2a | 3087 | Double_t *ey; |
8ec526a4 | 3088 | ey = new Double_t[nbins]; |
3089 | ||
3090 | for (Int_t lo = 0; lo < nbins; lo++) { | |
3091 | x[lo] = xref[lo]; | |
77566f2a | 3092 | ex[lo] = 0.0; |
3093 | y[lo] = 0.0; | |
3094 | ey[lo] = 0.0; | |
3095 | } | |
3096 | delete histsum; | |
3097 | histsum = new TGraphErrors(nbins,x,y,ex,ey); | |
8ec526a4 | 3098 | |
3099 | // Add the first | |
77566f2a | 3100 | histsum = AddProfiles(his,histsum); |
8ec526a4 | 3101 | if ((Int_t) chainplace->GetEntriesFast() > 1) { |
3102 | for (Int_t s = 1; s < (Int_t) chainplace->GetEntriesFast(); s++) { | |
3103 | treeChain->GetEntry(((AliTRDPlace *) chainplace->At(s))->GetPlace()); | |
77566f2a | 3104 | histsum = AddProfiles(his,histsum); |
3105 | } | |
3106 | } | |
8ec526a4 | 3107 | |
77566f2a | 3108 | tree->Fill(); |
8ec526a4 | 3109 | |
77566f2a | 3110 | } |
8ec526a4 | 3111 | |
77566f2a | 3112 | } |
8ec526a4 | 3113 | |
77566f2a | 3114 | return tree; |
8ec526a4 | 3115 | |
77566f2a | 3116 | } |
77566f2a | 3117 | |
8ec526a4 | 3118 | //____________Function fill 2D for the moment out of the code__________________ |
77566f2a | 3119 | |
8ec526a4 | 3120 | //____________Function fill 2D all objects from digits_________________________ |
3121 | Bool_t AliTRDCalibra::Create2DDiSimOnline(Int_t iev1, Int_t iev2) | |
77566f2a | 3122 | { |
3123 | // | |
8ec526a4 | 3124 | // Only for simulations, after the simulation, create the 2D histos |
3125 | // from the digits stored in the file "TRD.Digits.root" | |
77566f2a | 3126 | // Only for CH and PH |
3127 | // | |
77566f2a | 3128 | |
8ec526a4 | 3129 | const Int_t kNplan = 6; |
3130 | const Int_t kNcham = 5; | |
77566f2a | 3131 | |
8ec526a4 | 3132 | // RunLoader and so on |
77566f2a | 3133 | if (gAlice) { |
3134 | delete gAlice->GetRunLoader(); | |
3135 | delete gAlice; | |
8ec526a4 | 3136 | gAlice = 0; |
77566f2a | 3137 | } |
77566f2a | 3138 | |
8ec526a4 | 3139 | AliRunLoader *rl = AliRunLoader::Open("galice.root"); |
77566f2a | 3140 | if (!rl) { |
3141 | return kFALSE; | |
3142 | } | |
8ec526a4 | 3143 | |
77566f2a | 3144 | rl->LoadgAlice(); |
3145 | gAlice = rl->GetAliRun(); | |
3146 | if (!gAlice) { | |
3147 | return kFALSE; | |
3148 | } | |
3149 | ||
3150 | // Import the Trees for the event nEvent in the file | |
3151 | rl->LoadKinematics(); | |
3152 | rl->GetEvent(0); | |
3153 | rl->LoadHeader(); | |
3154 | ||
8ec526a4 | 3155 | AliLoader *loader = rl->GetLoader("TRDLoader"); |
77566f2a | 3156 | if (!loader) { |
3157 | AliInfo("No TRDLLoader found!"); | |
3158 | return kFALSE; | |
3159 | } | |
3160 | ||
3161 | // Get the pointer to the TRD detector | |
3162 | AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD"); | |
3163 | if (!trd) { | |
3164 | AliInfo("No TRD detector found"); | |
3165 | return kFALSE; | |
3166 | } | |
8ec526a4 | 3167 | |
77566f2a | 3168 | // Get the pointer to the geometry object |
3169 | AliTRDgeometry *geo; | |
3170 | if (trd) { | |
3171 | geo = trd->GetGeometry(); | |
3172 | } | |
3173 | else { | |
3174 | AliInfo("No TRD geometry found"); | |
3175 | return kFALSE; | |
3176 | } | |
3177 | ||
8ec526a4 | 3178 | // DB Setting |
77566f2a | 3179 | AliCDBManager *man = AliCDBManager::Instance(); |
3180 | if (!man) { | |
3181 | AliInfo("Could not get CDB Manager"); | |
3182 | return kFALSE; | |
3183 | } | |
3184 | ||
77566f2a | 3185 | // Get the parameter object |
3186 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
3187 | if (!parCom) { | |
3188 | AliInfo("Could not get CommonParam"); | |
3189 | return kFALSE; | |
3190 | } | |
3191 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
3192 | if (!cal) { | |
3193 | AliInfo("Could not get calibDB"); | |
3194 | return kFALSE; | |
3195 | } | |
3196 | ||
8ec526a4 | 3197 | // Some parameters |
3198 | fTimeMax = cal->GetNumberOfTimeBins(); | |
3199 | fSf = (Float_t) cal->GetSamplingFrequency(); | |
3200 | if (fRelativeScaleAuto) { | |
3201 | fRelativeScale = 0; | |
3202 | } | |
3203 | else { | |
3204 | if (fRelativeScale <= 0.0) { | |
3205 | AliInfo("You have to set the relativescale factor per hand!"); | |
3206 | return kFALSE; | |
3207 | } | |
3208 | } | |
77566f2a | 3209 | |
8ec526a4 | 3210 | // Create the 2D histos corresponding to the pad group calibration mode |
3211 | if (fCH2dOn) { | |
77566f2a | 3212 | |
8ec526a4 | 3213 | AliInfo(Form("We will fill the CH2d histo with the pad calibration mode: Nz %d, and Nrphi %d" |
3214 | ,fNz[0] | |
3215 | ,fNrphi[0])); | |
77566f2a | 3216 | |
8ec526a4 | 3217 | // Calcul the number of Xbins |
3218 | fNtotal[0] = 0; | |
77566f2a | 3219 | ModePadCalibration(2,0); |
3220 | ModePadFragmentation(0,2,0,0); | |
8ec526a4 | 3221 | fDetChamb2[0] = fNfragZ[0] * fNfragRphi[0]; |
3222 | fNtotal[0] += 6 * 18 * fDetChamb2[0]; | |
77566f2a | 3223 | ModePadCalibration(0,0); |
3224 | ModePadFragmentation(0,0,0,0); | |
8ec526a4 | 3225 | fDetChamb0[0] = fNfragZ[0] * fNfragRphi[0]; |
3226 | fNtotal[0] += 6 * 4 * 18 * fDetChamb0[0]; | |
3227 | AliInfo(Form("Total number of Xbins: %d",fNtotal[0])); | |
3228 | ||
3229 | // Create the 2D histo | |
3230 | if (fHisto2d) { | |
3231 | CreateCH2d(fNtotal[0]); | |
3232 | } | |
3233 | if (fVector2d) { | |
3234 | fVectorCH = new TObjArray(); | |
3235 | fPlaCH = new TObjArray(); | |
3236 | } | |
77566f2a | 3237 | |
3238 | } | |
3239 | ||
8ec526a4 | 3240 | if (fPH2dOn) { |
3241 | ||
3242 | AliInfo(Form("We will fill the PH2d histo with the pad calibration mode: Nz %d, and Nrphi %d" | |
3243 | ,fNz[1] | |
3244 | ,fNrphi[1])); | |
77566f2a | 3245 | |
8ec526a4 | 3246 | // Calcul the number of Xbins |
3247 | fNtotal[1] = 0; | |
77566f2a | 3248 | ModePadCalibration(2,1); |
3249 | ModePadFragmentation(0,2,0,1); | |
8ec526a4 | 3250 | fDetChamb2[1] = fNfragZ[1] * fNfragRphi[1]; |
3251 | fNtotal[1] += 6 * 18 * fDetChamb2[1]; | |
77566f2a | 3252 | ModePadCalibration(0,1); |
3253 | ModePadFragmentation(0,0,0,1); | |
8ec526a4 | 3254 | fDetChamb0[1] = fNfragZ[1] * fNfragRphi[1]; |
3255 | fNtotal[1] += 6 * 4 * 18 * fDetChamb0[1]; | |
3256 | AliInfo(Form("Total number of Xbins: %d",fNtotal[1])); | |
77566f2a | 3257 | |
8ec526a4 | 3258 | // Create the 2D histo |
3259 | if (fHisto2d) { | |
3260 | CreatePH2d(fNtotal[1]); | |
3261 | } | |
3262 | if (fVector2d) { | |
3263 | fVectorPH = new TObjArray(); | |
3264 | fPlaPH = new TObjArray(); | |
3265 | } | |
77566f2a | 3266 | |
3267 | } | |
3268 | ||
3269 | loader->LoadDigits(); | |
3270 | AliInfo("LoadDigits "); | |
3271 | AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(); | |
77566f2a | 3272 | |
8ec526a4 | 3273 | //iev2 egal to the max if 0 |
3274 | if (iev2 == 0) { | |
3275 | iev2 = rl->GetNumberOfEvents(); | |
3276 | AliInfo(Form("Total number of events: %d",iev2)); | |
3277 | } | |
3278 | ||
3279 | // Loop on event | |
77566f2a | 3280 | for (Int_t ievent = iev1; ievent < iev2; ievent++) { |
3281 | AliInfo(Form("Process event %d",ievent)); | |
3282 | rl->GetEvent(ievent); | |
8ec526a4 | 3283 | if (!loader->TreeD()) { |
77566f2a | 3284 | AliInfo("loader Loading Digits ... "); |
3285 | loader->LoadDigits(); | |
3286 | } | |
3287 | digitsManager->ReadDigits(loader->TreeD()); | |
3288 | AliInfo("digitsManager Read Digits Done"); | |
3289 | // Read the digits from the file | |
3290 | if (!(digitsManager->ReadDigits(loader->TreeD()))) { | |
3291 | return kFALSE; | |
3292 | } | |
3293 | ||
8ec526a4 | 3294 | // Loop on detector |
3295 | for (Int_t iSect = 0; iSect < 18; iSect++) { | |
3296 | for (Int_t iChamb = 0; iChamb < kNcham; iChamb++) { | |
3297 | for (Int_t iPlane = 0; iPlane < kNplan; iPlane++) { | |
77566f2a | 3298 | |
8ec526a4 | 3299 | // A little geometry: |
77566f2a | 3300 | Int_t iDet = geo->GetDetector(iPlane,iChamb,iSect); |
3301 | Int_t rowMax = parCom->GetRowMax(iPlane,iChamb,iSect); | |
3302 | Int_t colMax = parCom->GetColMax(iPlane); | |
3303 | ||
8ec526a4 | 3304 | // Variables for the group |
3305 | LocalisationDetectorXbins(iDet); | |
3306 | ||
3307 | // In the cas of charge | |
77566f2a | 3308 | Float_t *amptotal; |
8ec526a4 | 3309 | amptotal = new Float_t[fNfragRphi[0]*fNfragZ[0]]; |
3310 | if (fCH2dOn) { | |
3311 | for (Int_t k = 0; k < fNfragRphi[0]*fNfragZ[0]; k++) { | |
77566f2a | 3312 | amptotal[k] = 0.0; |
3313 | } | |
3314 | } | |
3315 | ||
8ec526a4 | 3316 | // Loop through the detector pixel |
77566f2a | 3317 | for (Int_t time = 0; time < fTimeMax; time++) { |
3318 | for (Int_t col = 0; col < colMax; col++) { | |
3319 | for (Int_t row = 0; row < rowMax; row++) { | |
77566f2a | 3320 | |
8ec526a4 | 3321 | // Amplitude and position in pad group |
3322 | AliTRDdigit *digit = digitsManager->GetDigit(row,col,time,iDet); | |
3323 | Int_t amp = digit->GetAmp(); | |
3324 | Int_t posr[2] = {0,0}; | |
3325 | Int_t posc[2] = {0,0}; | |
3326 | if ((fCH2dOn) && | |
3327 | (fNnZ[0] != 0)) { | |
3328 | posr[0] = (Int_t) row / fNnZ[0]; | |
3329 | } | |
3330 | if ((fCH2dOn) && | |
3331 | (fNnRphi[0] != 0)) { | |
3332 | posc[0] = (Int_t) col / fNnRphi[0]; | |
3333 | } | |
3334 | if ((fPH2dOn) && | |
3335 | (fNnZ[1] != 0)) { | |
3336 | posr[1] = (Int_t) row / fNnZ[1]; | |
3337 | } | |
3338 | if ((fPH2dOn) && | |
3339 | (fNnRphi[1] != 0)) { | |
3340 | posc[1] = (Int_t) col / fNnRphi[1]; | |
3341 | } | |
77566f2a | 3342 | |
77566f2a | 3343 | // Total spectrum |
8ec526a4 | 3344 | if (fCH2dOn) { |
3345 | if (amp < fThresholdDigit) { | |
3346 | amp = 0; | |
3347 | } | |
3348 | amptotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += amp; | |
77566f2a | 3349 | } |
8ec526a4 | 3350 | if (fPH2dOn) { |
3351 | if (fHisto2d) { | |
3352 | fPH2d->Fill((fXbins[1]+posc[1]*fNfragZ[1]+posr[1])+0.5,(Float_t) time/fSf,(Double_t) amp); | |
3353 | } | |
3354 | if (fVector2d) { | |
3355 | UpdateVectorPH((fXbins[1]+posc[1]*fNfragZ[1]+posr[1]),time,(Double_t) amp); | |
3356 | } | |
77566f2a | 3357 | } |
8ec526a4 | 3358 | |
3359 | // Memory stuff | |
77566f2a | 3360 | delete digit; |
77566f2a | 3361 | |
8ec526a4 | 3362 | } // Boucle row |
3363 | } // Boucle col | |
3364 | } // Boucle time | |
3365 | ||
3366 | if (fCH2dOn) { | |
77566f2a | 3367 | |
8ec526a4 | 3368 | // If automatic scale |
3369 | if ((fCountRelativeScale < 100) && (fRelativeScaleAuto)) { | |
3370 | // Take only the one zone track | |
3371 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3372 | if ((fCountRelativeScale < 100) && (amptotal[k] > 2.0)) { | |
3373 | fRelativeScale += amptotal[k]*0.014*0.01; | |
3374 | fCountRelativeScale++; | |
3375 | } | |
3376 | } | |
3377 | } | |
3378 | ||
3379 | // We fill the CH2d after having scale with the first 100 | |
3380 | if ((fCountRelativeScale >= 100) && (fRelativeScaleAuto)) { | |
3381 | // Case of | |
3382 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3383 | if (fHisto2d && | |
3384 | (amptotal[k] > 0.0)) { | |
3385 | fCH2d->Fill(fXbins[0]+k+0.5,amptotal[k]/fRelativeScale); | |
3386 | } | |
3387 | if (fVector2d && | |
3388 | (amptotal[k] > 0.0)) { | |
3389 | UpdateVectorCH(fXbins[0]+k ,amptotal[k]/fRelativeScale); | |
3390 | } | |
3391 | } | |
77566f2a | 3392 | } |
77566f2a | 3393 | |
8ec526a4 | 3394 | // No relative salce |
3395 | if (!fRelativeScaleAuto) { | |
3396 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3397 | if (fHisto2d && | |
3398 | (amptotal[k] > 0.0)) { | |
3399 | fCH2d->Fill(fXbins[0]+k+0.5, amptotal[k]/fRelativeScale); | |
3400 | } | |
3401 | if (fVector2d && | |
3402 | (amptotal[k] > 0.0)) { | |
3403 | UpdateVectorCH(fXbins[0]+k, amptotal[k]/fRelativeScale); | |
3404 | } | |
3405 | } | |
3406 | } | |
77566f2a | 3407 | |
8ec526a4 | 3408 | } |
3409 | ||
3410 | delete amptotal; | |
77566f2a | 3411 | |
8ec526a4 | 3412 | } // Boucle chamber |
3413 | } // Boucle plane | |
3414 | } // Boucle sect | |
77566f2a | 3415 | |
3416 | loader->UnloadDigits(); | |
3417 | ||
8ec526a4 | 3418 | } // Boucle event |
77566f2a | 3419 | |
8ec526a4 | 3420 | if (fDebug == 1) { |
3421 | if (fPH2dOn && fHisto2d) { | |
3422 | PlotPH2d(); | |
3423 | } | |
3424 | if (fCH2dOn && fHisto2d) { | |
3425 | PlotCH2d(); | |
3426 | } | |
77566f2a | 3427 | } |
3428 | ||
8ec526a4 | 3429 | if (fWrite[0] || fWrite[1]) { |
77566f2a | 3430 | |
8ec526a4 | 3431 | TFile *fout = TFile::Open(fWriteName,"RECREATE"); |
3432 | // Check if the file could be opened | |
77566f2a | 3433 | if (!fout || !fout->IsOpen()) { |
3434 | AliInfo("<No File found!"); | |
3435 | return kFALSE; | |
3436 | } | |
77566f2a | 3437 | |
8ec526a4 | 3438 | if (fCH2dOn && fHisto2d && fWrite[0]) { |
3439 | fout->WriteTObject(fCH2d); | |
3440 | } | |
3441 | if (fPH2dOn && fHisto2d && fWrite[1]) { | |
3442 | fout->WriteTObject(fPH2d); | |
3443 | } | |
77566f2a | 3444 | |
8ec526a4 | 3445 | if (fVector2d && fCH2dOn && fWrite[0]) { |
3446 | TString name("Nz"); | |
3447 | name += fNz[0]; | |
3448 | name += "Nrphi"; | |
3449 | name += fNrphi[0]; | |
3450 | TTree *treeCH2d = ConvertVectorCTTreeHisto(fVectorCH,fPlaCH,"treeCH2d",(const char *) name); | |
77566f2a | 3451 | fout->WriteTObject(treeCH2d); |
3452 | } | |
3453 | ||
8ec526a4 | 3454 | if (fVector2d && fPH2dOn && fWrite[1]) { |
3455 | TString name("Nz"); | |
3456 | name += fNz[1]; | |
3457 | name += "Nrphi"; | |
3458 | name += fNrphi[1]; | |
3459 | TTree *treePH2d = ConvertVectorPTreeHisto(fVectorPH,fPlaPH,"treePH2d",(const char *) name); | |
77566f2a | 3460 | fout->WriteTObject(treePH2d); |
3461 | } | |
8ec526a4 | 3462 | |
3463 | fout->Close(); | |
3464 | ||
77566f2a | 3465 | } |
3466 | ||
3467 | return kTRUE; | |
3468 | ||
3469 | } | |
77566f2a | 3470 | |
8ec526a4 | 3471 | //____________Function fill 2D all objects from Raw Data_______________________ |
77566f2a | 3472 | Bool_t AliTRDCalibra::Create2DRaDaOnline(Int_t iev1, Int_t iev2) |
3473 | { | |
3474 | // | |
8ec526a4 | 3475 | // After having written the RAW DATA in the current directory, create the |
3476 | // 2D histos from these RAW DATA | |
77566f2a | 3477 | // Only for CH and PH |
3478 | // | |
3479 | ||
8ec526a4 | 3480 | const Int_t kNplan = 6; |
3481 | const Int_t kNcham = 5; | |
77566f2a | 3482 | TString dirname("."); |
3483 | ||
8ec526a4 | 3484 | // DB Setting |
77566f2a | 3485 | AliCDBManager *man = AliCDBManager::Instance(); |
3486 | if (!man) { | |
3487 | AliInfo("Could not get CDB Manager"); | |
3488 | return kFALSE; | |
3489 | } | |
8ec526a4 | 3490 | |
77566f2a | 3491 | // Get the parameter object |
3492 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
3493 | if (!parCom) { | |
3494 | AliInfo("Could not get CommonParam"); | |
3495 | return kFALSE; | |
3496 | } | |
8ec526a4 | 3497 | |
77566f2a | 3498 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
3499 | if (!cal) { | |
3500 | AliInfo("Could not get calibDB"); | |
3501 | return kFALSE; | |
3502 | } | |
3503 | ||
77566f2a | 3504 | // Some parameters |
8ec526a4 | 3505 | fTimeMax = cal->GetNumberOfTimeBins(); |
3506 | fSf = (Float_t) cal->GetSamplingFrequency(); | |
3507 | if (fRelativeScaleAuto) { | |
3508 | fRelativeScale = 0; | |
3509 | } | |
3510 | else { | |
3511 | if (fRelativeScale <= 0.0) { | |
3512 | AliInfo("You have to set the relativescale factor per hand!"); | |
3513 | return kFALSE; | |
3514 | } | |
3515 | } | |
77566f2a | 3516 | |
8ec526a4 | 3517 | // Create the 2D histo corresponding to the pad group calibration mode |
3518 | if (fCH2dOn) { | |
77566f2a | 3519 | |
8ec526a4 | 3520 | AliInfo(Form("We will fill the CH2d histo with the pad calibration mode: Nz %d, and Nrphi %d" |
3521 | ,fNz[0] | |
3522 | ,fNrphi[0])); | |
77566f2a | 3523 | |
8ec526a4 | 3524 | // Calcul the number of Xbins |
3525 | fNtotal[0] = 0; | |
77566f2a | 3526 | ModePadCalibration(2,0); |
3527 | ModePadFragmentation(0,2,0,0); | |
8ec526a4 | 3528 | fDetChamb2[0] = fNfragZ[0] * fNfragRphi[0]; |
3529 | fNtotal[0] += 6 * 18 * fDetChamb2[0]; | |
77566f2a | 3530 | ModePadCalibration(0,0); |
3531 | ModePadFragmentation(0,0,0,0); | |
8ec526a4 | 3532 | fDetChamb0[0] = fNfragZ[0] * fNfragRphi[0]; |
3533 | fNtotal[0] += 6 * 4 * 18 * fDetChamb0[0]; | |
3534 | AliInfo(Form("Total number of Xbins: %d",fNtotal[0])); | |
77566f2a | 3535 | |
8ec526a4 | 3536 | // Create the 2D histo |
3537 | if (fHisto2d) { | |
3538 | CreateCH2d(fNtotal[0]); | |
3539 | } | |
3540 | if (fVector2d) { | |
3541 | fVectorCH = new TObjArray(); | |
3542 | fPlaCH = new TObjArray(); | |
3543 | } | |
3544 | ||
77566f2a | 3545 | } |
3546 | ||
3547 | if(fPH2dOn) { | |
8ec526a4 | 3548 | |
3549 | AliInfo(Form("We will fill the PH2d histo with the pad calibration mode: Nz %d, and Nrphi %d" | |
3550 | ,fNz[1] | |
3551 | ,fNrphi[1])); | |
77566f2a | 3552 | |
8ec526a4 | 3553 | // Calcul the number of Xbins |
3554 | fNtotal[1] = 0; | |
77566f2a | 3555 | ModePadCalibration(2,1); |
3556 | ModePadFragmentation(0,2,0,1); | |
8ec526a4 | 3557 | fDetChamb2[1] = fNfragZ[1] * fNfragRphi[1]; |
3558 | fNtotal[1] += 6 * 18 * fDetChamb2[1]; | |
77566f2a | 3559 | ModePadCalibration(0,1); |
3560 | ModePadFragmentation(0,0,0,1); | |
8ec526a4 | 3561 | fDetChamb0[1] = fNfragZ[1] * fNfragRphi[1]; |
3562 | fNtotal[1] += 6 * 4 * 18 * fDetChamb0[1]; | |
3563 | AliInfo(Form("Total number of Xbins: %d",fNtotal[1])); | |
77566f2a | 3564 | |
8ec526a4 | 3565 | // Create the 2D histo |
3566 | if (fHisto2d) { | |
3567 | CreatePH2d(fNtotal[1]); | |
3568 | } | |
3569 | if (fVector2d){ | |
3570 | fVectorPH = new TObjArray(); | |
3571 | fPlaPH = new TObjArray(); | |
3572 | } | |
77566f2a | 3573 | |
3574 | } | |
77566f2a | 3575 | |
3576 | AliTRDrawData *rawdata = new AliTRDrawData(); | |
3577 | AliInfo("AliTRDrawData object created "); | |
3578 | ||
8ec526a4 | 3579 | // Loop on events |
77566f2a | 3580 | for (Int_t ievent = iev1; ievent < iev2; ievent++) { |
77566f2a | 3581 | |
8ec526a4 | 3582 | // AliRawReaderFile |
77566f2a | 3583 | AliRawReaderFile *readerfile = new AliRawReaderFile(dirname,ievent); |
8ec526a4 | 3584 | if (!readerfile) { |
77566f2a | 3585 | AliInfo("No readerfile found!"); |
3586 | return kFALSE; | |
3587 | } | |
3588 | ||
77566f2a | 3589 | AliTRDdigitsManager *digitsManager = rawdata->Raw2Digits((AliRawReader *) readerfile); |
8ec526a4 | 3590 | if (!digitsManager) { |
77566f2a | 3591 | AliInfo("No DigitsManager done!"); |
3592 | return kFALSE; | |
3593 | } | |
3594 | ||
8ec526a4 | 3595 | // Loop on detectors |
3596 | for (Int_t iSect = 0; iSect < 18; iSect++) { | |
3597 | for (Int_t iPlane = 0; iPlane < kNplan; iPlane++) { | |
3598 | for (Int_t iChamb = 0; iChamb < kNcham; iChamb++) { | |
77566f2a | 3599 | |
8ec526a4 | 3600 | // A little geometry: |
77566f2a | 3601 | Int_t iDet = AliTRDgeometry::GetDetector(iPlane,iChamb,iSect); |
3602 | Int_t rowMax = parCom->GetRowMax(iPlane,iChamb,iSect); | |
3603 | Int_t colMax = parCom->GetColMax(iPlane); | |
3604 | ||
8ec526a4 | 3605 | // Variables for the group |
3606 | LocalisationDetectorXbins(iDet); | |
3607 | ||
3608 | // In the cas of charge | |
77566f2a | 3609 | Float_t *amptotal; |
8ec526a4 | 3610 | amptotal = new Float_t[fNfragRphi[0]*fNfragZ[0]]; |
3611 | if(fCH2dOn) { | |
3612 | for (Int_t k = 0; k < fNfragRphi[0]*fNfragZ[0]; k++) { | |
77566f2a | 3613 | amptotal[k] = 0.0; |
3614 | } | |
3615 | } | |
8ec526a4 | 3616 | |
3617 | // Loop through the detector pixel | |
77566f2a | 3618 | for (Int_t time = 0; time < fTimeMax; time++) { |
3619 | for (Int_t col = 0; col < colMax; col++) { | |
3620 | for (Int_t row = 0; row < rowMax; row++) { | |
3621 | ||
8ec526a4 | 3622 | // Amplitude and position of the digit |
3623 | AliTRDdigit *digit = digitsManager->GetDigit(row,col,time,iDet); | |
3624 | Int_t amp = digit->GetAmp(); | |
3625 | Int_t posr[2] = { 0, 0 }; | |
3626 | Int_t posc[2] = { 0, 0 }; | |
3627 | if ((fCH2dOn) && | |
3628 | (fNnZ[0] != 0)) { | |
3629 | posr[0] = (Int_t) row / fNnZ[0]; | |
3630 | } | |
3631 | if ((fCH2dOn) && | |
3632 | (fNnRphi[0] != 0)) { | |
3633 | posc[0] = (Int_t) col / fNnRphi[0]; | |
3634 | } | |
3635 | if ((fPH2dOn) && | |
3636 | (fNnZ[1] != 0)) { | |
3637 | posr[1] = (Int_t) row / fNnZ[1]; | |
3638 | } | |
3639 | if ((fPH2dOn) && | |
3640 | (fNnRphi[1] != 0)) { | |
3641 | posc[1] = (Int_t) col / fNnRphi[1]; | |
3642 | } | |
77566f2a | 3643 | |
3644 | // Total spectrum | |
8ec526a4 | 3645 | if (fCH2dOn) { |
3646 | if (amp < fThresholdDigit) { | |
3647 | amp = 0; | |
3648 | } | |
3649 | amptotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += amp; | |
77566f2a | 3650 | } |
3651 | ||
8ec526a4 | 3652 | if (fPH2dOn ) { |
3653 | if (fHisto2d) { | |
3654 | fPH2d->Fill((fXbins[1]+posc[1]*fNfragZ[1]+posr[1])+0.5,(Float_t)time/fSf,amp); | |
3655 | } | |
3656 | if (fVector2d) { | |
3657 | UpdateVectorPH(fXbins[1]+posc[1]*fNfragZ[1]+posr[1],time,amp); | |
3658 | } | |
3659 | } | |
77566f2a | 3660 | |
3661 | delete digit; | |
77566f2a | 3662 | |
8ec526a4 | 3663 | } // Boucle row |
3664 | } // Boucle col | |
3665 | } // Boucle time | |
77566f2a | 3666 | |
8ec526a4 | 3667 | if (fCH2dOn) { |
77566f2a | 3668 | |
8ec526a4 | 3669 | // If automatic scale |
3670 | if ((fCountRelativeScale < 100) && (fRelativeScaleAuto)) { | |
3671 | // Take only the one zone track | |
3672 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3673 | if ((fCountRelativeScale < 100) && (amptotal[k] > 2.0)) { | |
3674 | fRelativeScale += amptotal[k] * 0.014 * 0.01; | |
3675 | fCountRelativeScale++; | |
3676 | } | |
3677 | } | |
3678 | } | |
3679 | ||
3680 | // We fill the CH2d after having scale with the first 100 | |
3681 | if ((fCountRelativeScale >= 100) && (fRelativeScaleAuto)) { | |
3682 | // Case of | |
3683 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3684 | if (fHisto2d && (amptotal[k] > 0.0)) { | |
3685 | fCH2d->Fill(fXbins[0]+k+0.5,amptotal[k]/fRelativeScale); | |
3686 | } | |
3687 | if (fVector2d && (amptotal[k] > 0.0)) { | |
3688 | UpdateVectorCH(fXbins[0]+k, amptotal[k]/fRelativeScale); | |
3689 | } | |
3690 | } | |
3691 | } | |
3692 | ||
3693 | // No relative salce | |
3694 | if (!fRelativeScaleAuto) { | |
3695 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3696 | if (fHisto2d && | |
3697 | (amptotal[k] > 0.0)) { | |
3698 | fCH2d->Fill(fXbins[0]+k+0.5,amptotal[k]/fRelativeScale); | |
3699 | } | |
3700 | if (fVector2d && | |
3701 | (amptotal[k] > 0.0)) { | |
3702 | UpdateVectorCH(fXbins[0]+k, amptotal[k]/fRelativeScale); | |
3703 | } | |
3704 | } | |
77566f2a | 3705 | } |
77566f2a | 3706 | |
8ec526a4 | 3707 | } |
3708 | ||
77566f2a | 3709 | delete amptotal; |
3710 | ||
8ec526a4 | 3711 | } // Boucle chamber |
3712 | } // Boucle plane | |
3713 | } // Boucle sect | |
77566f2a | 3714 | |
3715 | delete digitsManager; | |
3716 | delete readerfile; | |
77566f2a | 3717 | |
8ec526a4 | 3718 | } // Boucle event |
3719 | ||
3720 | if (fDebug == 1) { | |
3721 | if (fPH2dOn && fHisto2d) { | |
3722 | PlotPH2d(); | |
3723 | } | |
3724 | if (fCH2dOn && fHisto2d) { | |
3725 | PlotCH2d(); | |
3726 | } | |
77566f2a | 3727 | } |
3728 | ||
8ec526a4 | 3729 | if (fWrite[0] || fWrite[1]) { |
77566f2a | 3730 | |
3731 | TFile *fout = TFile::Open(fWriteName,"UPDATE"); | |
8ec526a4 | 3732 | // Check if the file could be opened |
77566f2a | 3733 | if (!fout || !fout->IsOpen()) { |
3734 | AliInfo("<No File found!"); | |
3735 | return kFALSE; | |
3736 | } | |
77566f2a | 3737 | |
8ec526a4 | 3738 | if (fCH2dOn && fHisto2d && fWrite[0]) { |
3739 | fout->WriteTObject(fCH2d); | |
3740 | } | |
3741 | if (fPH2dOn && fHisto2d && fWrite[1]) { | |
3742 | fout->WriteTObject(fPH2d); | |
3743 | } | |
77566f2a | 3744 | |
8ec526a4 | 3745 | if (fVector2d && fCH2dOn && fWrite[0]) { |
3746 | TString name("Nz"); | |
3747 | name += fNz[0]; | |
3748 | name += "Nrphi"; | |
3749 | name += fNrphi[0]; | |
3750 | TTree *treeCH2d = ConvertVectorCTTreeHisto(fVectorCH,fPlaCH,"treeCH2d",(const Char_t *) name); | |
77566f2a | 3751 | fout->WriteTObject(treeCH2d); |
3752 | } | |
3753 | ||
8ec526a4 | 3754 | if (fVector2d && fPH2dOn && fWrite[1]) { |
3755 | TString name("Nz"); | |
3756 | name += fNz[1]; | |
3757 | name += "Nrphi"; | |
3758 | name += fNrphi[1]; | |
3759 | TTree *treePH2d = ConvertVectorPTreeHisto(fVectorPH,fPlaPH,"treePH2d",(const Char_t *) name); | |
77566f2a | 3760 | fout->WriteTObject(treePH2d); |
3761 | } | |
3762 | ||
3763 | } | |
3764 | ||
3765 | return kTRUE; | |
3766 | ||
3767 | } | |
77566f2a | 3768 | |
8ec526a4 | 3769 | //____________Pad Calibration Public___________________________________________ |
3770 | ||
3771 | //____________Define the number of pads per group for one detector and one calibration | |
77566f2a | 3772 | void AliTRDCalibra::ModePadCalibration(Int_t iChamb, Int_t i) |
3773 | { | |
3774 | // | |
3775 | // Definition of the calibration mode | |
3776 | // from Nz and Nrphi, the number of row and col pads per calibration groups are setted | |
3777 | // | |
3778 | ||
3779 | ||
8ec526a4 | 3780 | fNnZ[i] = 0; |
3781 | fNnRphi[i] = 0; | |
77566f2a | 3782 | |
8ec526a4 | 3783 | if ((fNz[i] == 0) && (iChamb == 2)) { |
3784 | fNnZ[i] = 12; | |
77566f2a | 3785 | } |
8ec526a4 | 3786 | if ((fNz[i] == 0) && (iChamb != 2)) { |
3787 | fNnZ[i] = 16; | |
77566f2a | 3788 | } |
8ec526a4 | 3789 | if ((fNz[i] == 1) && (iChamb == 2)) { |
3790 | fNnZ[i] = 6; | |
77566f2a | 3791 | } |
8ec526a4 | 3792 | if ((fNz[i] == 1) && (iChamb != 2)) { |
3793 | fNnZ[i] = 8; | |
77566f2a | 3794 | } |
8ec526a4 | 3795 | if ((fNz[i] == 2) && (iChamb == 2)) { |
3796 | fNnZ[i] = 3; | |
77566f2a | 3797 | } |
8ec526a4 | 3798 | if ((fNz[i] == 2) && (iChamb != 2)) { |
3799 | fNnZ[i] = 4; | |
77566f2a | 3800 | } |
8ec526a4 | 3801 | if (fNz[i] == 3) { |
3802 | fNnZ[i] = 2; | |
77566f2a | 3803 | } |
8ec526a4 | 3804 | if (fNz[i] == 4) { |
3805 | fNnZ[i] = 1; | |
77566f2a | 3806 | } |
3807 | ||
8ec526a4 | 3808 | if (fNrphi[i] == 0) { |
3809 | fNnRphi[i] = 144; | |
77566f2a | 3810 | } |
8ec526a4 | 3811 | if (fNrphi[i] == 1) { |
3812 | fNnRphi[i] = 72; | |
77566f2a | 3813 | } |
8ec526a4 | 3814 | if (fNrphi[i] == 2) { |
3815 | fNnRphi[i] = 36; | |
77566f2a | 3816 | } |
8ec526a4 | 3817 | if (fNrphi[i] == 3) { |
3818 | fNnRphi[i] = 18; | |
77566f2a | 3819 | } |
8ec526a4 | 3820 | if (fNrphi[i] == 4) { |
3821 | fNnRphi[i] = 9; | |
77566f2a | 3822 | } |
8ec526a4 | 3823 | if (fNrphi[i] == 5) { |
3824 | fNnRphi[i] = 4; | |
77566f2a | 3825 | } |
8ec526a4 | 3826 | if (fNrphi[i] == 6) { |
3827 | fNnRphi[i] = 1; | |
77566f2a | 3828 | } |
8ec526a4 | 3829 | |
77566f2a | 3830 | } |
8ec526a4 | 3831 | |
3832 | //____________Define the number of pad groups in one detector for one calibration | |
77566f2a | 3833 | Bool_t AliTRDCalibra::ModePadFragmentation(Int_t iPlane,Int_t iChamb, Int_t iSect, Int_t i) |
3834 | { | |
3835 | // | |
3836 | // Definition of the calibration mode | |
8ec526a4 | 3837 | // From the number of row and col pads per calibration groups the |
3838 | // number of calibration groups are setted | |
77566f2a | 3839 | // |
3840 | ||
8ec526a4 | 3841 | fNfragZ[i] = 0; |
3842 | fNfragRphi[i] = 0; | |
77566f2a | 3843 | |
3844 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
3845 | if (!parCom) { | |
3846 | AliInfo("Could not get CommonParam Manager"); | |
3847 | return kFALSE; | |
3848 | } | |
3849 | ||
8ec526a4 | 3850 | // A little geometry: |
77566f2a | 3851 | Int_t rowMax = parCom->GetRowMax(iPlane,iChamb,iSect); |
3852 | Int_t colMax = parCom->GetColMax(iPlane); | |
3853 | ||
8ec526a4 | 3854 | // The fragmentation |
3855 | if (fNnZ[i] != 0) { | |
3856 | fNfragZ[i] = (Int_t) rowMax / fNnZ[i]; | |
3857 | } | |
77566f2a | 3858 | |
8ec526a4 | 3859 | if (fNnRphi[i] != 0) { |
3860 | fNfragRphi[i] = (Int_t) colMax / fNnRphi[i]; | |
3861 | } | |
77566f2a | 3862 | |
3863 | return kTRUE; | |
77566f2a | 3864 | |
8ec526a4 | 3865 | } |
77566f2a | 3866 | |
8ec526a4 | 3867 | //____________Protected Functions______________________________________________ |
3868 | //____________Create the 2D histo to be filled online__________________________ | |
3869 | // | |
77566f2a | 3870 | |
8ec526a4 | 3871 | //_____________________________________________________________________________ |
3872 | void AliTRDCalibra::CreatePRF2d(Int_t nn) | |
77566f2a | 3873 | { |
3874 | // | |
3875 | // Create the 2D histos | |
3876 | // | |
3877 | ||
8ec526a4 | 3878 | TString name("Nz"); |
3879 | name += fNz[2]; | |
3880 | name += "Nrphi"; | |
3881 | name += fNrphi[2]; | |
3882 | ||
3883 | fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name | |
3884 | ,nn,0,nn,fNumberBinPRF,-1.0,1.0); | |
77566f2a | 3885 | fPRF2d->SetXTitle("Det/pad groups"); |
3886 | fPRF2d->SetYTitle("Position x/W [pad width units]"); | |
3887 | fPRF2d->SetZTitle("Q_{i}/Q_{total}"); | |
3888 | fPRF2d->SetStats(0); | |
77566f2a | 3889 | |
3890 | } | |
3891 | ||
8ec526a4 | 3892 | //_____________________________________________________________________________ |
3893 | void AliTRDCalibra::CreatePH2d(Int_t nn) | |
77566f2a | 3894 | { |
3895 | // | |
3896 | // Create the 2D histos | |
3897 | // | |
3898 | ||
8ec526a4 | 3899 | TString name("Nz"); |
3900 | name += fNz[1]; | |
3901 | name += "Nrphi"; | |
3902 | name += fNrphi[1]; | |
3903 | ||
3904 | fPH2d = new TProfile2D("PH2d",(const Char_t *) name | |
3905 | ,nn,0,nn,fTimeMax | |
3906 | ,-0.5/fSf,(Float_t) (fTimeMax-0.5)/fSf); | |
77566f2a | 3907 | fPH2d->SetXTitle("Det/pad groups"); |
3908 | fPH2d->SetYTitle("time [#mus]"); | |
3909 | fPH2d->SetZTitle("<PH> [a.u.]"); | |
3910 | fPH2d->SetStats(0); | |
77566f2a | 3911 | |
3912 | } | |
3913 | ||
8ec526a4 | 3914 | //_____________________________________________________________________________ |
3915 | void AliTRDCalibra::CreateCH2d(Int_t nn) | |
77566f2a | 3916 | { |
3917 | // | |
3918 | // Create the 2D histos | |
3919 | // | |
3920 | ||
8ec526a4 | 3921 | TString name("Nz"); |
3922 | name += fNz[0]; | |
3923 | name += "Nrphi"; | |
3924 | name += fNrphi[0]; | |
3925 | ||
3926 | fCH2d = new TH2I("CH2d",(const Char_t *) name | |
3927 | ,nn,0,nn,fNumberBinCharge,0,300); | |
77566f2a | 3928 | fCH2d->SetXTitle("Det/pad groups"); |
3929 | fCH2d->SetYTitle("charge deposit [a.u]"); | |
3930 | fCH2d->SetZTitle("counts"); | |
3931 | fCH2d->SetStats(0); | |
3932 | fCH2d->Sumw2(); | |
3933 | ||
3934 | } | |
8ec526a4 | 3935 | |
3936 | //____________Offine tracking in the AliTRDtracker_____________________________ | |
77566f2a | 3937 | void AliTRDCalibra::FillTheInfoOfTheTrackCH() |
3938 | { | |
3939 | // | |
3940 | // For the offline tracking or mcm tracklets | |
3941 | // This function will be called in the functions UpdateHistogram... | |
3942 | // to fill the info of a track for the relativ gain calibration | |
3943 | // | |
3944 | ||
8ec526a4 | 3945 | Int_t nb = 0; // Nombre de zones traversees |
3946 | Int_t fd = -1; // Premiere zone non nulle | |
77566f2a | 3947 | |
3948 | ||
8ec526a4 | 3949 | // See if the track goes through different zones |
3950 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3951 | if (fAmpTotal[k] > 0.0) { | |
3952 | nb++; | |
3953 | if (nb == 1) { | |
3954 | fd = k; | |
3955 | } | |
77566f2a | 3956 | } |
3957 | } | |
3958 | ||
8ec526a4 | 3959 | // If automatic scale |
3960 | if ((fCountRelativeScale < 100) && (fRelativeScaleAuto)) { | |
3961 | // Take only the one zone track | |
3962 | if (nb == 1) { | |
3963 | fRelativeScale += fAmpTotal[fd] * 0.014 * 0.01; | |
3964 | fCountRelativeScale++; | |
77566f2a | 3965 | } |
3966 | } | |
8ec526a4 | 3967 | |
3968 | // We fill the CH2d after having scale with the first 100 | |
3969 | if ((fCountRelativeScale >= 100) && (fRelativeScaleAuto)) { | |
3970 | // Case of track with only one zone | |
3971 | if (nb == 1) { | |
3972 | if (fHisto2d) { | |
3973 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
3974 | } | |
3975 | if (fVector2d) { | |
3976 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
3977 | } | |
3978 | } // Case 1 zone | |
3979 | // Case of track with two zones | |
3980 | if (nb == 2) { | |
3981 | // Two zones voisines sinon rien! | |
3982 | if ((fAmpTotal[fd] > 0.0) && | |
3983 | (fAmpTotal[fd+1] > 0.0)) { | |
3984 | // One of the two very big | |
3985 | if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) { | |
3986 | if (fHisto2d) { | |
3987 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
3988 | } | |
3989 | if (fVector2d) { | |
3990 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
3991 | } | |
77566f2a | 3992 | } |
8ec526a4 | 3993 | if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) { |
3994 | if (fHisto2d) { | |
3995 | fCH2d->Fill(fXbins[0]+fd+1.5,fAmpTotal[fd+1]/fRelativeScale); | |
3996 | } | |
3997 | if (fVector2d) { | |
3998 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd+1]/fRelativeScale); | |
3999 | } | |
77566f2a | 4000 | } |
4001 | } | |
8ec526a4 | 4002 | } // Case 2 zones |
4003 | } | |
4004 | ||
4005 | // Fill with no automatic scale | |
4006 | if (!fRelativeScaleAuto) { | |
4007 | // Case of track with only one zone | |
4008 | if (nb == 1) { | |
4009 | fNumberUsedCh[0]++; | |
4010 | if (fHisto2d) { | |
4011 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
4012 | } | |
4013 | if (fVector2d) { | |
4014 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
4015 | } | |
4016 | } // Case 1 zone | |
4017 | // Case of track with two zones | |
4018 | if (nb == 2) { | |
4019 | // Two zones voisines sinon rien! | |
4020 | // Case 1 | |
4021 | if ((fAmpTotal[fd] > 0.0) && | |
4022 | (fAmpTotal[fd+1] > 0.0)) { | |
4023 | // One of the two very big | |
4024 | if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) { | |
4025 | if (fHisto2d) { | |
4026 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
4027 | } | |
4028 | if (fVector2d) { | |
4029 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
4030 | } | |
4031 | fNumberUsedCh[1]++; | |
77566f2a | 4032 | } |
8ec526a4 | 4033 | if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) { |
4034 | if (fHisto2d) { | |
4035 | fCH2d->Fill(fXbins[0]+fd+1.5,fAmpTotal[fd+1]/fRelativeScale); | |
4036 | } | |
4037 | if (fVector2d) { | |
4038 | UpdateVectorCH(fXbins[0]+fd+1,fAmpTotal[fd+1]/fRelativeScale); | |
4039 | } | |
4040 | fNumberUsedCh[1]++; | |
77566f2a | 4041 | } |
4042 | } | |
8ec526a4 | 4043 | // Case 2 |
4044 | if (fNfragZ[0] > 1) { | |
4045 | if (fAmpTotal[fd] > 0.0) { | |
4046 | if ((fd+fNfragZ[0]) < (fNfragZ[0]*fNfragRphi[0])) { | |
4047 | if (fAmpTotal[fd+fNfragZ[0]] > 0.0) { | |
4048 | // One of the two very big | |
4049 | if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+fNfragZ[0]]) { | |
4050 | if (fHisto2d) { | |
4051 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
4052 | } | |
4053 | if (fVector2d) { | |
4054 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
4055 | } | |
4056 | fNumberUsedCh[1]++; | |
77566f2a | 4057 | } |
8ec526a4 | 4058 | if (fAmpTotal[fd+fNfragZ[0]] > fProcent*fAmpTotal[fd]) { |
4059 | if (fHisto2d) { | |
4060 | fCH2d->Fill(fXbins[0]+fd+fNfragZ[0]+0.5,fAmpTotal[fd+fNfragZ[0]]/fRelativeScale); | |
4061 | } | |
4062 | fNumberUsedCh[1]++; | |
4063 | if (fVector2d) { | |
4064 | UpdateVectorCH(fXbins[0]+fd+fNfragZ[0],fAmpTotal[fd+fNfragZ[0]]/fRelativeScale); | |
4065 | } | |
77566f2a | 4066 | } |
4067 | } | |
4068 | } | |
4069 | } | |
4070 | } | |
8ec526a4 | 4071 | } // Case 2 zones |
4072 | ||
77566f2a | 4073 | } |
8ec526a4 | 4074 | |
77566f2a | 4075 | } |
8ec526a4 | 4076 | |
4077 | //____________Offine tracking in the AliTRDtracker_____________________________ | |
4078 | void AliTRDCalibra::ResetfVariables() | |
77566f2a | 4079 | { |
4080 | // | |
8ec526a4 | 4081 | // Reset values of fAmpTotal, fPHValue and fPHPlace for |
4082 | // the updateHistogram... functions | |
77566f2a | 4083 | // |
4084 | ||
8ec526a4 | 4085 | // Reset the good track |
77566f2a | 4086 | fGoodTrack = kTRUE; |
4087 | ||
8ec526a4 | 4088 | // Reset the fAmpTotal where we put value |
4089 | if (fCH2dOn) { | |
4090 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
4091 | fAmpTotal[k] = 0.0; | |
4092 | } | |
4093 | } | |
4094 | ||
4095 | // Reset the fPHValue | |
4096 | if (fPH2dOn) { | |
4097 | for (Int_t k = 0; k < fTimeMax; k++) { | |
4098 | fPHValue[k] = -1.0; | |
4099 | fPHPlace[k] = -1; | |
4100 | } | |
4101 | } | |
4102 | ||
4103 | } | |
4104 | ||
4105 | //____________Offine tracking in the AliTRDtracker_____________________________ | |
77566f2a | 4106 | void AliTRDCalibra::FillTheInfoOfTheTrackPH() |
4107 | { | |
4108 | // | |
4109 | // For the offline tracking or mcm tracklets | |
4110 | // This function will be called in the functions UpdateHistogram... | |
4111 | // to fill the info of a track for the drift velocity calibration | |
4112 | // | |
4113 | ||
8ec526a4 | 4114 | Int_t nb = 1; // Nombre de zones traversees 1, 2 ou plus de 3 |
4115 | Int_t fd1 = -1; // Premiere zone non nulle | |
4116 | Int_t fd2 = -1; // Deuxieme zone non nulle | |
4117 | Int_t k1 = -1; // Debut de la premiere zone | |
4118 | Int_t k2 = -1; // Debut de la seconde zone | |
4119 | ||
4120 | // See if the track goes through different zones | |
4121 | for (Int_t k = 0; k < fTimeMax; k++) { | |
4122 | if (fPHValue[k] > 0.0) { | |
4123 | if (fd1 == -1) { | |
4124 | fd1 = fPHPlace[k]; | |
4125 | k1 = k; | |
77566f2a | 4126 | } |
8ec526a4 | 4127 | if (fPHPlace[k] != fd1) { |
4128 | if (fd2 == -1) { | |
4129 | k2 = k; | |
4130 | fd2 = fPHPlace[k]; | |
4131 | nb = 2; | |
4132 | } | |
4133 | if (fPHPlace[k] != fd2) { | |
4134 | nb = 3; | |
77566f2a | 4135 | } |
77566f2a | 4136 | } |
4137 | } | |
4138 | } | |
4139 | ||
8ec526a4 | 4140 | // Fill |
4141 | // Case of track with only one zone | |
4142 | if (nb == 1) { | |
4143 | fNumberUsedPh[0]++; | |
4144 | for (Int_t i = 0; i < fTimeMax; i++) { | |
4145 | if (fPHValue[i] > 0.0) { | |
4146 | if (fHisto2d) { | |
4147 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4148 | } | |
4149 | if (fDebug == 13) { | |
4150 | AliInfo(Form("WRITE nb %d ,place final: %d, fPHPlace[i]: %d, i: %d, fPHValue[i]: %f" | |
4151 | ,nb,fXbins[1]+fPHPlace[i],fPHPlace[i],i,fPHValue[i])); | |
4152 | } | |
4153 | if (fVector2d) { | |
4154 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
77566f2a | 4155 | } |
77566f2a | 4156 | } |
4157 | } | |
8ec526a4 | 4158 | } // Case 1 zone |
4159 | // Case of track with two zones | |
4160 | if (nb == 2) { | |
4161 | // Two zones voisines sinon rien! | |
4162 | // Case 1 | |
4163 | if ((fd1 == fd2+1) || | |
4164 | (fd2 == fd1+1)) { | |
4165 | // One of the two fast all the think | |
4166 | if (k2 > (k1+fDifference)) { | |
4167 | fNumberUsedPh[1]++; | |
4168 | for (Int_t i = k1; i < k2; i++) { | |
4169 | if (fPHValue[i] > 0.0) { | |
4170 | if (fHisto2d) { | |
4171 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4172 | } | |
4173 | if (fVector2d) { | |
4174 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4175 | } | |
77566f2a | 4176 | } |
4177 | } | |
4178 | } | |
8ec526a4 | 4179 | if ((k2+fDifference) < fTimeMax) { |
4180 | fNumberUsedPh[1]++; | |
4181 | for (Int_t i = k2; i < fTimeMax; i++) { | |
4182 | if (fPHValue[i] > 0.0) { | |
4183 | if (fHisto2d) { | |
4184 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4185 | } | |
4186 | if (fVector2d) { | |
4187 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4188 | } | |
77566f2a | 4189 | } |
4190 | } | |
4191 | } | |
4192 | } | |
8ec526a4 | 4193 | // Two zones voisines sinon rien! |
4194 | if (fNfragZ[1] > 1) { | |
4195 | // Case 2 | |
4196 | if ((fd1+fNfragZ[1]) < (fNfragZ[1]*fNfragRphi[1])) { | |
4197 | if (fd2 == (fd1+fNfragZ[1])) { | |
4198 | // One of the two fast all the think | |
4199 | if (k2 > (k1+fDifference)) { | |
4200 | fNumberUsedPh[1]++; | |
4201 | for (Int_t i = k1; i < k2; i++) { | |
4202 | if (fPHValue[i] > 0.0) { | |
4203 | if (fHisto2d) { | |
4204 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4205 | } | |
4206 | if (fVector2d) { | |
4207 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4208 | } | |
77566f2a | 4209 | } |
4210 | } | |
4211 | } | |
8ec526a4 | 4212 | if ((k2+fDifference) < fTimeMax) { |
4213 | fNumberUsedPh[1]++; | |
4214 | for (Int_t i = k2; i < fTimeMax; i++) { | |
4215 | if (fPHValue[i] > 0.0) { | |
4216 | if (fHisto2d) { | |
4217 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4218 | } | |
4219 | if (fVector2d) { | |
4220 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4221 | } | |
77566f2a | 4222 | } |
4223 | } | |
4224 | } | |
4225 | } | |
4226 | } | |
8ec526a4 | 4227 | // Two zones voisines sinon rien! |
4228 | // Case 3 | |
4229 | if ((fd1 - fNfragZ[1]) >= 0) { | |
4230 | if (fd2 == (fd1 - fNfragZ[1])) { | |
4231 | // One of the two fast all the think | |
4232 | if (k2 > (k1 + fDifference)) { | |
4233 | fNumberUsedPh[1]++; | |
4234 | for (Int_t i = k1; i < k2; i++) { | |
4235 | if (fPHValue[i] > 0.0) { | |
4236 | if (fHisto2d) { | |
4237 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4238 | } | |
4239 | if (fVector2d) { | |
4240 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4241 | } | |
77566f2a | 4242 | } |
4243 | } | |
4244 | } | |
8ec526a4 | 4245 | if ((k2+fDifference) < fTimeMax) { |
4246 | fNumberUsedPh[1]++; | |
4247 | for (Int_t i = k2; i < fTimeMax; i++) { | |
4248 | if (fPHValue[i] > 0.0) { | |
4249 | if (fHisto2d) { | |
4250 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4251 | } | |
4252 | if (fVector2d) { | |
4253 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4254 | } | |
77566f2a | 4255 | } |
4256 | } | |
4257 | } | |
4258 | } | |
4259 | } | |
4260 | } | |
77566f2a | 4261 | |
8ec526a4 | 4262 | } // case 2 zones |
4263 | ||
4264 | } | |
77566f2a | 4265 | |
8ec526a4 | 4266 | //____________Set the pad calibration variables for the detector_______________ |
4267 | Bool_t AliTRDCalibra::LocalisationDetectorXbins(Int_t detector) | |
77566f2a | 4268 | { |
4269 | // | |
8ec526a4 | 4270 | // For the detector calcul the first Xbins and set the number of row |
4271 | // and col pads per calibration groups, the number of calibration | |
4272 | // groups in the detector. | |
77566f2a | 4273 | // |
4274 | ||
8ec526a4 | 4275 | // first Xbins of the detector |
4276 | if (fCH2dOn) { | |
4277 | CalculXBins(detector,0); | |
4278 | } | |
4279 | if (fPH2dOn) { | |
4280 | CalculXBins(detector,1); | |
4281 | } | |
4282 | if (fPRF2dOn) { | |
4283 | CalculXBins(detector,2); | |
4284 | } | |
4285 | ||
4286 | // fragmentation of idect | |
4287 | for (Int_t i = 0; i < 3; i++) { | |
77566f2a | 4288 | ModePadCalibration((Int_t) GetChamber(detector),i); |
8ec526a4 | 4289 | ModePadFragmentation((Int_t) GetPlane(detector) |
4290 | , (Int_t) GetChamber(detector) | |
4291 | , (Int_t) GetSector(detector),i); | |
77566f2a | 4292 | } |
4293 | ||
4294 | return kTRUE; | |
8ec526a4 | 4295 | |
77566f2a | 4296 | } |
4297 | ||
8ec526a4 | 4298 | //____________Plot the 2D histos filled Online_________________________________ |
77566f2a | 4299 | |
8ec526a4 | 4300 | //_____________________________________________________________________________ |
77566f2a | 4301 | void AliTRDCalibra::PlotPH2d() |
4302 | { | |
4303 | // | |
4304 | // Plot the 2D histo | |
4305 | // | |
4306 | ||
4307 | TCanvas *cph2d = new TCanvas("cph2d","",50,50,600,800); | |
4308 | cph2d->cd(); | |
4309 | fPH2d->Draw("LEGO"); | |
4310 | ||
4311 | } | |
4312 | ||
8ec526a4 | 4313 | //_____________________________________________________________________________ |
77566f2a | 4314 | void AliTRDCalibra::PlotCH2d() |
4315 | { | |
4316 | // | |
4317 | // Plot the 2D histos | |
4318 | // | |
4319 | ||
4320 | TCanvas *cch2d = new TCanvas("cch2d","",50,50,600,800); | |
4321 | cch2d->cd(); | |
4322 | fCH2d->Draw("LEGO"); | |
4323 | ||
4324 | } | |
4325 | ||
8ec526a4 | 4326 | //_____________________________________________________________________________ |
77566f2a | 4327 | void AliTRDCalibra::PlotPRF2d() |
4328 | { | |
4329 | // | |
4330 | // Plot the 2D histos | |
4331 | // | |
4332 | ||
4333 | TCanvas *cPRF2d = new TCanvas("cPRF2d","",50,50,600,800); | |
4334 | cPRF2d->cd(); | |
4335 | fPRF2d->Draw("LEGO"); | |
4336 | ||
4337 | } | |
4338 | ||
8ec526a4 | 4339 | //____________Fit______________________________________________________________ |
77566f2a | 4340 | |
8ec526a4 | 4341 | //____________Create histos if fDebug == 1 or fDebug >= 3______________________ |
77566f2a | 4342 | |
8ec526a4 | 4343 | //_____________________________________________________________________________ |
4344 | void AliTRDCalibra::CreateFitHistoPH(Int_t nbins, Double_t low, Double_t high) | |
77566f2a | 4345 | { |
4346 | // | |
4347 | // Create the histos for fDebug = 1 and fDebug = 4 (Fit functions) | |
4348 | // | |
4349 | ||
8ec526a4 | 4350 | // Histograms to store the coef |
4351 | fCoefVdrift[0] = new TH1F("coefvdrift0" ,"",nbins,low ,high); | |
4352 | fCoefVdrift[1] = new TH1F("coefvdrift1" ,"",nbins,low ,high); | |
4353 | fCoefVdrift[2] = new TH1F("coefvdrift2" ,"",nbins,low ,high); | |
77566f2a | 4354 | |
8ec526a4 | 4355 | // Histograms for Debug |
4356 | fDeltaVdrift[0] = new TH1F("deltavdrift0","",nbins,low ,high); | |
4357 | fDeltaVdrift[1] = new TH1F("deltavdrift1","",nbins,low ,high); | |
4358 | fErrorVdrift[0] = new TH1I("errorvdrift0","",300 ,-0.5,0.5); | |
4359 | fErrorVdrift[1] = new TH1I("errorvdrift1","",300 ,-0.5,0.5); | |
77566f2a | 4360 | |
4361 | fCoefVdrift[0]->SetXTitle("Det/pad groups"); | |
4362 | fCoefVdrift[0]->SetYTitle("Vdrift [cm/#mus]"); | |
4363 | fCoefVdrift[1]->SetXTitle("Det/pad groups"); | |
4364 | fCoefVdrift[1]->SetYTitle("Vdrift [cm/#mus]"); | |
4365 | fCoefVdrift[2]->SetXTitle("Det/pad groups"); | |
4366 | fCoefVdrift[2]->SetYTitle("Vdrift [cm/#mus]"); | |
4367 | ||
77566f2a | 4368 | fDeltaVdrift[0]->SetXTitle("Det/pad groups"); |
4369 | fDeltaVdrift[0]->SetYTitle("#Deltav/v_{sim}"); | |
4370 | fDeltaVdrift[1]->SetXTitle("Det/pad groups"); | |
4371 | fDeltaVdrift[1]->SetYTitle("#Deltav/v_{sim}"); | |
4372 | ||
77566f2a | 4373 | fErrorVdrift[0]->SetXTitle("#Deltav/v_{sim}"); |
4374 | fErrorVdrift[0]->SetYTitle("counts"); | |
4375 | fErrorVdrift[1]->SetXTitle("#Deltav/v_{sim}"); | |
4376 | fErrorVdrift[1]->SetYTitle("counts"); | |
4377 | ||
77566f2a | 4378 | fCoefVdrift[0]->SetStats(0); |
4379 | fCoefVdrift[1]->SetStats(0); | |
4380 | fCoefVdrift[2]->SetStats(0); | |
4381 | fDeltaVdrift[0]->SetStats(0); | |
4382 | fDeltaVdrift[1]->SetStats(0); | |
4383 | fErrorVdrift[0]->SetStats(0); | |
4384 | fErrorVdrift[1]->SetStats(0); | |
4385 | ||
4386 | fCoefVdrift[0]->SetMarkerColor(6); | |
4387 | fCoefVdrift[0]->SetMarkerStyle(26); | |
4388 | fCoefVdrift[0]->SetLineColor(6); | |
4389 | fCoefVdrift[1]->SetMarkerColor(2); | |
4390 | fCoefVdrift[1]->SetMarkerStyle(24); | |
4391 | fCoefVdrift[1]->SetLineColor(2); | |
4392 | fCoefVdrift[2]->SetLineColor(4); | |
4393 | ||
77566f2a | 4394 | fDeltaVdrift[1]->SetMarkerColor(2); |
4395 | fDeltaVdrift[1]->SetMarkerStyle(24); | |
4396 | fDeltaVdrift[1]->SetLineColor(2); | |
4397 | fDeltaVdrift[0]->SetMarkerColor(6); | |
4398 | fDeltaVdrift[0]->SetMarkerStyle(26); | |
4399 | fDeltaVdrift[0]->SetLineColor(6); | |
4400 | ||
77566f2a | 4401 | fErrorVdrift[1]->SetLineColor(2); |
4402 | fErrorVdrift[1]->SetLineStyle(2); | |
4403 | fErrorVdrift[0]->SetLineColor(6); | |
4404 | fErrorVdrift[0]->SetLineStyle(1); | |
4405 | ||
77566f2a | 4406 | } |
8ec526a4 | 4407 | |
4408 | //_____________________________________________________________________________ | |
4409 | void AliTRDCalibra::CreateFitHistoT0(Int_t nbins, Double_t low, Double_t high) | |
77566f2a | 4410 | { |
4411 | // | |
4412 | // Create the histos for fDebug = 1 and fDebug = 4 (Fit functions) | |
4413 | // | |
4414 | ||
8ec526a4 | 4415 | // Histograms to store the coef |
4416 | fCoefT0[0] = new TH1F("coefT00" ,"",nbins,low ,high); | |
4417 | fCoefT0[1] = new TH1F("coefT01" ,"",nbins,low ,high); | |
4418 | fCoefT0[2] = new TH1F("coefT02" ,"",nbins,low ,high); | |
77566f2a | 4419 | |
8ec526a4 | 4420 | // Histograms for Debug |
4421 | fDeltaT0[0] = new TH1F("deltaT00","",nbins,low ,high); | |
4422 | fDeltaT0[1] = new TH1F("deltaT01","",nbins,low ,high); | |
4423 | fErrorT0[0] = new TH1I("errorT00","",300 ,-0.1,0.1); | |
4424 | fErrorT0[1] = new TH1I("errorT01","",300 ,-0.1,0.1); | |
77566f2a | 4425 | |
4426 | fCoefT0[0]->SetXTitle("Det/pad groups"); | |
9244c78b | 4427 | fCoefT0[0]->SetYTitle("t0 [timebin]"); |
77566f2a | 4428 | fCoefT0[1]->SetXTitle("Det/pad groups"); |
9244c78b | 4429 | fCoefT0[1]->SetYTitle("t0 [timebin]"); |
77566f2a | 4430 | fCoefT0[2]->SetXTitle("Det/pad groups"); |
9244c78b | 4431 | fCoefT0[2]->SetYTitle("t0 [timebin]"); |
77566f2a | 4432 | |
77566f2a | 4433 | fDeltaT0[0]->SetXTitle("Det/pad groups"); |
9244c78b | 4434 | fDeltaT0[0]->SetYTitle("#Deltat0 [timebin]"); |
77566f2a | 4435 | fDeltaT0[1]->SetXTitle("Det/pad groups"); |
9244c78b | 4436 | fDeltaT0[1]->SetYTitle("#Deltat0 [timebin]"); |
77566f2a | 4437 | |
9244c78b | 4438 | fErrorT0[0]->SetXTitle("#Deltat0 [timebin]"); |
77566f2a | 4439 | fErrorT0[0]->SetYTitle("counts"); |
9244c78b | 4440 | fErrorT0[1]->SetXTitle("#Deltat0 [timebin]"); |
77566f2a | 4441 | fErrorT0[1]->SetYTitle("counts"); |
4442 | ||
77566f2a | 4443 | fCoefT0[0]->SetStats(0); |
4444 | fCoefT0[1]->SetStats(0); | |
4445 | fCoefT0[2]->SetStats(0); | |
4446 | fDeltaT0[0]->SetStats(0); | |
4447 | fDeltaT0[1]->SetStats(0); | |
4448 | fErrorT0[0]->SetStats(0); | |
4449 | fErrorT0[1]->SetStats(0); | |
4450 | ||
4451 | fCoefT0[0]->SetMarkerColor(6); | |
4452 | fCoefT0[0]->SetMarkerStyle(26); | |
4453 | fCoefT0[0]->SetLineColor(6); | |
4454 | fCoefT0[1]->SetMarkerColor(2); | |
4455 | fCoefT0[1]->SetMarkerStyle(24); | |
4456 | fCoefT0[1]->SetLineColor(2); | |
4457 | fCoefT0[2]->SetLineColor(4); | |
4458 | ||
77566f2a | 4459 | fDeltaT0[1]->SetMarkerColor(2); |
4460 | fDeltaT0[1]->SetMarkerStyle(24); | |
4461 | fDeltaT0[1]->SetLineColor(2); | |
4462 | fDeltaT0[0]->SetMarkerColor(6); | |
4463 | fDeltaT0[0]->SetMarkerStyle(26); | |
4464 | fDeltaT0[0]->SetLineColor(6); | |
4465 | ||
77566f2a | 4466 | fErrorT0[1]->SetLineColor(2); |
4467 | fErrorT0[1]->SetLineStyle(2); | |
4468 | fErrorT0[0]->SetLineColor(6); | |
4469 | fErrorT0[0]->SetLineStyle(1); | |
8ec526a4 | 4470 | |
77566f2a | 4471 | } |
4472 | ||
8ec526a4 | 4473 | //_____________________________________________________________________________ |
4474 | void AliTRDCalibra::CreateFitHistoCH(Int_t nbins, Double_t low, Double_t high) | |
77566f2a | 4475 | { |
4476 | // | |
4477 | // Create the histos for fDebug = 1 and fDebug = 4 (Fit functions) | |
4478 | // | |
4479 | ||
8ec526a4 | 4480 | // Histograms to store the coef |
4481 | fCoefCharge[0] = new TH1F("coefcharge0" ,"",nbins,low ,high); | |
4482 | fCoefCharge[1] = new TH1F("coefcharge1" ,"",nbins,low ,high); | |
4483 | fCoefCharge[2] = new TH1F("coefcharge2" ,"",nbins,low ,high); | |
4484 | fCoefCharge[3] = new TH1F("coefcharge3" ,"",nbins,low ,high); | |
77566f2a | 4485 | |
8ec526a4 | 4486 | // Histograms for Debug |
4487 | fDeltaCharge[0] = new TH1F("deltacharge0","",nbins,low ,high); | |
4488 | fDeltaCharge[1] = new TH1F("deltacharge1","",nbins,low ,high); | |
4489 | fDeltaCharge[2] = new TH1F("deltacharge2","",nbins,low ,high); | |
77566f2a | 4490 | |
8ec526a4 | 4491 | fErrorCharge[0] = new TH1I("errorcharge0","",100 ,-0.5,0.5); |
4492 | fErrorCharge[1] = new TH1I("errorcharge1","",100 ,-0.5,0.5); | |
4493 | fErrorCharge[2] = new TH1I("errorcharge2","",100 ,-0.5,0.5); | |
77566f2a | 4494 | |
4495 | fCoefCharge[0]->SetXTitle("Det/Pad groups"); | |
4496 | fCoefCharge[0]->SetYTitle("gain factor"); | |
4497 | fCoefCharge[1]->SetXTitle("Det/Pad groups"); | |
4498 | fCoefCharge[1]->SetYTitle("gain factor"); | |
4499 | fCoefCharge[2]->SetXTitle("Det/Pad groups"); | |
4500 | fCoefCharge[2]->SetYTitle("gain factor"); | |
4501 | fCoefCharge[3]->SetXTitle("Det/Pad groups"); | |
4502 | fCoefCharge[3]->SetYTitle("gain factor"); | |
4503 | ||
4504 | fDeltaCharge[0]->SetXTitle("Det/Pad groups"); | |
4505 | fDeltaCharge[0]->SetYTitle("#Deltag/g_{sim}"); | |
4506 | fDeltaCharge[1]->SetXTitle("Det/Pad groups"); | |
4507 | fDeltaCharge[1]->SetYTitle("#Deltag/g_{sim}"); | |
4508 | fDeltaCharge[2]->SetXTitle("Det/Pad groups"); | |
4509 | fDeltaCharge[2]->SetYTitle("#Deltag/g_{sim}"); | |
4510 | fDeltaCharge[0]->SetAxisRange(-0.5,0.5,"Y"); | |
4511 | fDeltaCharge[1]->SetAxisRange(-0.5,0.5,"Y"); | |
4512 | fDeltaCharge[2]->SetAxisRange(-0.5,0.5,"Y"); | |
4513 | ||
4514 | fErrorCharge[0]->SetXTitle("#Deltag/g_{sim}"); | |
4515 | fErrorCharge[0]->SetYTitle("counts"); | |
4516 | fErrorCharge[1]->SetXTitle("#Deltag/g_{sim}"); | |
4517 | fErrorCharge[1]->SetYTitle("counts"); | |
4518 | fErrorCharge[2]->SetXTitle("#Deltag/g_{sim}"); | |
4519 | fErrorCharge[2]->SetYTitle("counts"); | |
77566f2a | 4520 | |
4521 | fDeltaCharge[1]->SetMarkerColor(2); | |
4522 | fDeltaCharge[1]->SetMarkerStyle(24); | |
4523 | fDeltaCharge[1]->SetLineColor(2); | |
4524 | fErrorCharge[1]->SetLineColor(2); | |
4525 | fErrorCharge[1]->SetLineStyle(2); | |
4526 | fDeltaCharge[2]->SetMarkerColor(8); | |
4527 | fDeltaCharge[2]->SetLineColor(8); | |
4528 | fDeltaCharge[2]->SetMarkerStyle(9); | |
4529 | fErrorCharge[2]->SetLineColor(8); | |
4530 | fErrorCharge[2]->SetLineStyle(5); | |
4531 | fDeltaCharge[0]->SetMarkerColor(6); | |
4532 | fDeltaCharge[0]->SetLineColor(6); | |
4533 | fDeltaCharge[0]->SetMarkerStyle(26); | |
4534 | fErrorCharge[0]->SetLineColor(6); | |
4535 | fErrorCharge[0]->SetLineStyle(1); | |
4536 | ||
4537 | fCoefCharge[3]->SetLineColor(4); | |
4538 | fCoefCharge[1]->SetMarkerColor(2); | |
4539 | fCoefCharge[1]->SetLineColor(2); | |
4540 | fCoefCharge[1]->SetMarkerStyle(24); | |
4541 | fCoefCharge[2]->SetMarkerColor(8); | |
4542 | fCoefCharge[2]->SetLineColor(8); | |
4543 | fCoefCharge[2]->SetMarkerStyle(9); | |
4544 | fCoefCharge[0]->SetMarkerColor(6); | |
4545 | fCoefCharge[0]->SetLineColor(6); | |
4546 | fCoefCharge[0]->SetMarkerStyle(26); | |
4547 | ||
4548 | fErrorCharge[2]->SetLineWidth(3); | |
4549 | ||
77566f2a | 4550 | fDeltaCharge[1]->SetStats(0); |
4551 | fDeltaCharge[2]->SetStats(0); | |
4552 | fDeltaCharge[0]->SetStats(0); | |
4553 | fErrorCharge[1]->SetStats(0); | |
4554 | fErrorCharge[2]->SetStats(0); | |
4555 | fErrorCharge[0]->SetStats(0); | |
4556 | fCoefCharge[1]->SetStats(0); | |
4557 | fCoefCharge[0]->SetStats(0); | |
4558 | fCoefCharge[3]->SetStats(0); | |
4559 | fCoefCharge[2]->SetStats(0); | |
77566f2a | 4560 | |
4561 | } | |
8ec526a4 | 4562 | |
4563 | //_____________________________________________________________________________ | |
4564 | void AliTRDCalibra::CreateFitHistoPRF(Int_t nbins, Double_t low, Double_t high) | |
77566f2a | 4565 | { |
4566 | // | |
4567 | // Create the histos for fDebug = 1 and fDebug = 4 (Fit functions) | |
4568 | // | |
4569 | ||
8ec526a4 | 4570 | // Histograms to store the coef |
4571 | fCoefPRF[0] = new TH1F("coefPRF0","",nbins,low ,high); | |
4572 | fCoefPRF[1] = new TH1F("coefPRF1","",nbins,low ,high); | |
77566f2a | 4573 | |
8ec526a4 | 4574 | // Histograms for Debug |
4575 | fDeltaPRF = new TH1F("deltaPRF","",nbins,low ,high); | |
4576 | fErrorPRF = new TH1I("errorPRF","",300 ,-0.5,0.5); | |
77566f2a | 4577 | |
77566f2a | 4578 | fDeltaPRF->SetMarkerColor(6); |
4579 | fDeltaPRF->SetMarkerStyle(26); | |
4580 | fDeltaPRF->SetLineColor(6); | |
4581 | fErrorPRF->SetLineColor(6); | |
4582 | fErrorPRF->SetLineStyle(2); | |
4583 | ||
4584 | fCoefPRF[1]->SetLineColor(4); | |
4585 | fCoefPRF[0]->SetMarkerColor(6); | |
4586 | fCoefPRF[0]->SetMarkerStyle(26); | |
4587 | fCoefPRF[0]->SetLineColor(6); | |
4588 | ||
4589 | fCoefPRF[0]->SetXTitle("Det/Pad groups"); | |
4590 | fCoefPRF[0]->SetYTitle("#sigma_{PRF}"); | |
4591 | fCoefPRF[1]->SetXTitle("Det/Pad groups"); | |
4592 | fCoefPRF[1]->SetYTitle("#sigma_{PRF}"); | |
4593 | ||
4594 | fDeltaPRF->SetXTitle("Det/Pad groups"); | |
4595 | fDeltaPRF->SetYTitle("#Delta#sigma/#sigma_{sim}"); | |
4596 | ||
4597 | fErrorPRF->SetXTitle("#Delta#sigma/#sigma_{sim}"); | |
4598 | fErrorPRF->SetYTitle("counts"); | |
77566f2a | 4599 | |
4600 | fDeltaPRF->SetStats(0); | |
4601 | fErrorPRF->SetStats(0); | |
4602 | fCoefPRF[1]->SetStats(0); | |
4603 | fCoefPRF[0]->SetStats(0); | |
4604 | ||
4605 | } | |
8ec526a4 | 4606 | |
4607 | //_____________________________________________________________________________ | |
77566f2a | 4608 | void AliTRDCalibra::CreateFitHistoPRFDB(Int_t rowMax, Int_t colMax) |
4609 | { | |
4610 | // | |
4611 | // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions) | |
4612 | // | |
8ec526a4 | 4613 | |
4614 | fCoefPRFDB = new TH2F("coefPRF","",rowMax,0,rowMax,colMax,0,colMax); | |
77566f2a | 4615 | |
4616 | fCoefPRFDB->SetStats(0); | |
4617 | fCoefPRFDB->SetXTitle("row Number"); | |
4618 | fCoefPRFDB->SetYTitle("col Number"); | |
4619 | fCoefPRFDB->SetZTitle("PRF width [pad width units]"); | |
77566f2a | 4620 | |
4621 | fCoefPRFDB->SetFillColor(6); | |
4622 | fCoefPRFDB->SetLineColor(6); | |
4623 | ||
77566f2a | 4624 | } |
4625 | ||
8ec526a4 | 4626 | //_____________________________________________________________________________ |
4627 | void AliTRDCalibra::CreateFitHistoCHDB(Int_t rowMax, Int_t colMax) | |
4628 | { | |
77566f2a | 4629 | // |
4630 | // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions) | |
4631 | // | |
4632 | ||
8ec526a4 | 4633 | fCoefChargeDB[0] = new TH2F("coefchargedb0","",rowMax,0,rowMax,colMax,0,colMax); |
4634 | fCoefChargeDB[1] = new TH2F("coefchargedb1","",rowMax,0,rowMax,colMax,0,colMax); | |
4635 | fCoefChargeDB[2] = new TH2F("coefchargedb2","",rowMax,0,rowMax,colMax,0,colMax); | |
77566f2a | 4636 | |
4637 | fCoefChargeDB[0]->SetStats(0); | |
4638 | fCoefChargeDB[1]->SetStats(0); | |
4639 | fCoefChargeDB[2]->SetStats(0); | |
4640 | fCoefChargeDB[0]->SetXTitle("row Number"); | |
4641 | fCoefChargeDB[0]->SetYTitle("col Number"); | |
4642 | fCoefChargeDB[1]->SetXTitle("row Number"); | |
4643 | fCoefChargeDB[1]->SetYTitle("col Number"); | |
4644 | fCoefChargeDB[2]->SetXTitle("row Number"); | |
4645 | fCoefChargeDB[2]->SetYTitle("col Number"); | |
4646 | fCoefChargeDB[0]->SetZTitle("f_{g} Fit method"); | |
4647 | fCoefChargeDB[1]->SetZTitle("f_{g} Mean method"); | |
4648 | fCoefChargeDB[2]->SetZTitle("f_{g} Fitbis method"); | |
77566f2a | 4649 | |
4650 | fCoefChargeDB[0]->SetFillColor(6); | |
4651 | fCoefChargeDB[0]->SetLineColor(6); | |
4652 | fCoefChargeDB[0]->SetLineColor(6); | |
4653 | fCoefChargeDB[1]->SetFillColor(2); | |
4654 | fCoefChargeDB[1]->SetLineColor(2); | |
4655 | fCoefChargeDB[1]->SetLineColor(2); | |
4656 | fCoefChargeDB[2]->SetFillColor(8); | |
4657 | fCoefChargeDB[2]->SetLineColor(8); | |
4658 | fCoefChargeDB[2]->SetLineColor(8); | |
4659 | ||
4660 | } | |
4661 | ||
8ec526a4 | 4662 | //_____________________________________________________________________________ |
77566f2a | 4663 | void AliTRDCalibra::CreateFitHistoPHDB(Int_t rowMax, Int_t colMax) |
4664 | { | |
4665 | // | |
4666 | // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions) | |
4667 | // | |
4668 | ||
8ec526a4 | 4669 | fCoefVdriftDB[0] = new TH2F("coefvdriftdb0","",rowMax,0,rowMax,colMax,0,colMax); |
4670 | fCoefVdriftDB[1] = new TH2F("coefvdriftdb1","",rowMax,0,rowMax,colMax,0,colMax); | |
77566f2a | 4671 | |
4672 | fCoefVdriftDB[0]->SetStats(0); | |
4673 | fCoefVdriftDB[1]->SetStats(0); | |
4674 | fCoefVdriftDB[0]->SetXTitle("row Number"); | |
4675 | fCoefVdriftDB[0]->SetYTitle("col Number"); | |
4676 | fCoefVdriftDB[1]->SetXTitle("row Number"); | |
4677 | fCoefVdriftDB[1]->SetYTitle("col Number"); | |
4678 | fCoefVdriftDB[0]->SetZTitle("v_{drift} Fit method"); | |
4679 | fCoefVdriftDB[1]->SetZTitle("v_{drift} slope method"); | |
4680 | ||
4681 | fCoefVdriftDB[0]->SetFillColor(6); | |
4682 | fCoefVdriftDB[0]->SetLineColor(6); | |
4683 | fCoefVdriftDB[0]->SetLineColor(6); | |
4684 | fCoefVdriftDB[1]->SetFillColor(2); | |
4685 | fCoefVdriftDB[1]->SetLineColor(2); | |
4686 | fCoefVdriftDB[1]->SetLineColor(2); | |
8ec526a4 | 4687 | |
77566f2a | 4688 | } |
8ec526a4 | 4689 | |
4690 | //_____________________________________________________________________________ | |
77566f2a | 4691 | void AliTRDCalibra::CreateFitHistoT0DB(Int_t rowMax, Int_t colMax) |
4692 | { | |
4693 | // | |
4694 | // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions) | |
4695 | // | |
4696 | ||
8ec526a4 | 4697 | fCoefT0DB[0] = new TH2F("coefT0db0","",rowMax,0,rowMax,colMax,0,colMax); |
4698 | fCoefT0DB[1] = new TH2F("coefT0db1","",rowMax,0,rowMax,colMax,0,colMax); | |
77566f2a | 4699 | |
4700 | fCoefT0DB[0]->SetStats(0); | |
4701 | fCoefT0DB[1]->SetStats(0); | |
4702 | fCoefT0DB[0]->SetXTitle("row Number"); | |
4703 | fCoefT0DB[0]->SetYTitle("col Number"); | |
4704 | fCoefT0DB[1]->SetXTitle("row Number"); | |
4705 | fCoefT0DB[1]->SetYTitle("col Number"); | |
4706 | fCoefT0DB[0]->SetZTitle("t0 Fit method"); | |
4707 | fCoefT0DB[1]->SetZTitle("t0 slope method"); | |
4708 | ||
4709 | fCoefT0DB[0]->SetFillColor(6); | |
4710 | fCoefT0DB[0]->SetLineColor(6); | |
4711 | fCoefT0DB[0]->SetLineColor(6); | |
4712 | fCoefT0DB[1]->SetFillColor(2); | |
4713 | fCoefT0DB[1]->SetLineColor(2); | |
4714 | fCoefT0DB[1]->SetLineColor(2); | |
4715 | ||
4716 | } | |
8ec526a4 | 4717 | |
77566f2a | 4718 | //_____________________________________________________________________________ |
4719 | Bool_t AliTRDCalibra::FillVectorFitCH(Int_t countdet) | |
4720 | { | |
4721 | // | |
4722 | // For the Fit functions fill the vector FitCH special for the gain calibration | |
4723 | // | |
8ec526a4 | 4724 | |
4725 | AliTRDFitCHInfo *fitCHInfo = new AliTRDFitCHInfo(); | |
4726 | ||
4727 | Int_t ntotal = 1; | |
4728 | if (GetChamber(countdet) == 2) { | |
4729 | ntotal = 1728; | |
4730 | } | |
4731 | else { | |
4732 | ntotal = 2304; | |
4733 | } | |
4734 | ||
4735 | Float_t *coef = new Float_t[ntotal]; | |
4736 | for (Int_t i = 0; i < ntotal; i++) { | |
4737 | coef[i] = fCoefCH[i]; | |
77566f2a | 4738 | } |
8ec526a4 | 4739 | |
4740 | Int_t detector = countdet; | |
4741 | // Set | |
4742 | fitCHInfo->SetCoef(coef); | |
4743 | fitCHInfo->SetDetector(detector); | |
4744 | fVectorFitCH->Add((TObject *) fitCHInfo); | |
77566f2a | 4745 | |
4746 | return kTRUE; | |
8ec526a4 | 4747 | |
77566f2a | 4748 | } |
77566f2a | 4749 | |
8ec526a4 | 4750 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
4751 | Bool_t AliTRDCalibra::InitFit(Int_t nbins, Double_t lowedge | |
4752 | , Double_t upedge, Int_t i) | |
77566f2a | 4753 | { |
4754 | // | |
8ec526a4 | 4755 | // Init the calibration mode (Nz, Nrphi), the histograms for |
4756 | // debugging the fit methods if fDebug > 0, | |
77566f2a | 4757 | // |
8ec526a4 | 4758 | |
77566f2a | 4759 | gStyle->SetPalette(1); |
4760 | gStyle->SetOptStat(1111); | |
4761 | gStyle->SetPadBorderMode(0); | |
4762 | gStyle->SetCanvasColor(10); | |
4763 | gStyle->SetPadLeftMargin(0.13); | |
4764 | gStyle->SetPadRightMargin(0.01); | |
8ec526a4 | 4765 | |
77566f2a | 4766 | // Get the parameter object |
4767 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
4768 | if (!parCom) { | |
8ec526a4 | 4769 | AliInfo("Could not get CommonParam"); |
77566f2a | 4770 | return kFALSE; |
4771 | } | |
8ec526a4 | 4772 | |
4773 | // Mode groups of pads: the total number of bins! | |
77566f2a | 4774 | Int_t numberofbinsexpected = 0; |
4775 | ModePadCalibration(2,i); | |
4776 | ModePadFragmentation(0,2,0,i); | |
8ec526a4 | 4777 | fDetChamb2[i] = fNfragZ[i] * fNfragRphi[i]; |
4778 | if (fDebug == 1) { | |
4779 | AliInfo(Form("For the chamber 2: %d",fDetChamb2[i])); | |
4780 | } | |
4781 | numberofbinsexpected += 6 * 18 * fDetChamb2[i]; | |
77566f2a | 4782 | ModePadCalibration(0,i); |
4783 | ModePadFragmentation(0,0,0,i); | |
8ec526a4 | 4784 | fDetChamb0[i] = fNfragZ[i] * fNfragRphi[i]; |
4785 | if (fDebug == 1) { | |
4786 | AliInfo(Form("For the other chamber 0: %d",fDetChamb0[i])); | |
4787 | } | |
4788 | numberofbinsexpected += 6 * 4 * 18 * fDetChamb0[i]; | |
77566f2a | 4789 | |
8ec526a4 | 4790 | // Quick verification that we have the good pad calibration mode if 2D histos! |
4791 | if (nbins != 0) { | |
4792 | if (numberofbinsexpected != nbins) { | |
77566f2a | 4793 | AliInfo("It doesn't correspond to the mode of pad group calibration!"); |
4794 | return kFALSE; | |
4795 | } | |
4796 | } | |
4797 | ||
8ec526a4 | 4798 | // Security for fDebug 3 and 4 |
4799 | if ((fDebug >= 3) && | |
4800 | ((fDet[0] > 5) || | |
4801 | (fDet[1] > 4) || | |
4802 | (fDet[2] > 17))) { | |
77566f2a | 4803 | AliInfo("This detector doesn't exit!"); |
4804 | return kFALSE; | |
77566f2a | 4805 | } |
8ec526a4 | 4806 | |
4807 | // Determine fDet1 and fDet2 | |
4808 | fDect1[i] = -1; | |
4809 | fDect2[i] = -1; | |
4810 | if (fDebug == 2) { | |
4811 | fDect1[i] = fFitVoir; | |
4812 | fDect2[i] = fDect1[i] +1; | |
77566f2a | 4813 | } |
8ec526a4 | 4814 | if (fDebug <= 1) { |
4815 | fDect1[i] = 0; | |
4816 | fDect2[i] = numberofbinsexpected; | |
77566f2a | 4817 | } |
8ec526a4 | 4818 | if (fDebug >= 3) { |
77566f2a | 4819 | CalculXBins(AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]),i); |
8ec526a4 | 4820 | fDect1[i] = fXbins[i]; |
77566f2a | 4821 | CalculXBins((AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2])+1),i); |
8ec526a4 | 4822 | fDect2[i] = fXbins[i]; |
4823 | } | |
4824 | ||
4825 | // Create the histos for debugging | |
4826 | // CH | |
4827 | if (i == 0) { | |
4828 | ||
4829 | gDirectory = gROOT; | |
4830 | // Init the VectorFitCH | |
4831 | fVectorFitCH = new TObjArray(); | |
4832 | fCoefCH = new Float_t[2304]; | |
4833 | for (Int_t k = 0; k < 2304; k++) { | |
4834 | fCoefCH[k] = 0.0; | |
4835 | } | |
4836 | fScaleFitFactor = 0.0; | |
4837 | ||
4838 | // Number of Xbins(detectors or groups of pads) if Vector2d | |
4839 | // Quick verification that we are not out of range! | |
4840 | if (fVectorCH && fPlaCH) { | |
4841 | if ((nbins == 0) && | |
4842 | (fVectorCH->GetEntriesFast() > 0) && | |
4843 | ((Int_t) fPlaCH->GetEntriesFast() > 0)) { | |
4844 | if ((Int_t) fVectorCH->GetEntriesFast() > numberofbinsexpected) { | |
4845 | AliInfo("ch doesn't correspond to the mode of pad group calibration!"); | |
4846 | return kFALSE; | |
4847 | } | |
4848 | if ((Int_t) fVectorCH->GetEntriesFast() != (Int_t) fPlaCH->GetEntriesFast()) { | |
4849 | AliInfo("VectorCH doesn't correspond to PlaCH!"); | |
4850 | return kFALSE; | |
4851 | } | |
77566f2a | 4852 | } |
4853 | } | |
8ec526a4 | 4854 | |
4855 | // | |
4856 | // Debugging: Create the histos | |
4857 | // | |
4858 | ||
4859 | // fDebug == 0 nothing | |
77566f2a | 4860 | |
8ec526a4 | 4861 | // fDebug == 1 |
4862 | if (fDebug == 1) { | |
4863 | if (nbins != 0) { | |
4864 | // Create the histos replique de ch if histos2D | |
4865 | CreateFitHistoCH(nbins,lowedge,upedge); | |
77566f2a | 4866 | } |
8ec526a4 | 4867 | else { |
4868 | // Ccreate the histos replique de ch vector2d | |
4869 | CreateFitHistoCH(numberofbinsexpected,0,numberofbinsexpected); | |
77566f2a | 4870 | } |
4871 | } | |
8ec526a4 | 4872 | |
4873 | // fDebug == 2 and fFitVoir no histo | |
4874 | if (fDebug == 2) { | |
4875 | if (fFitVoir < numberofbinsexpected) { | |
77566f2a | 4876 | AliInfo(Form("We will see the fit of the object %d",fFitVoir)); |
4877 | } | |
4878 | else { | |
4879 | AliInfo("fFitVoir is out of range of the histo!"); | |
4880 | return kFALSE; | |
4881 | } | |
4882 | } | |
8ec526a4 | 4883 | |
4884 | // fDebug == 3 or 4 and fDet | |
4885 | if (fDebug >= 3) { | |
4886 | if ((fNz[0] == 0) && (fNrphi[0] == 0)) { | |
77566f2a | 4887 | AliInfo("Do you really want to see one detector without pad groups?"); |
4888 | return kFALSE; | |
4889 | } | |
8ec526a4 | 4890 | else { |
4891 | AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d" | |
4892 | ,fDet[0],fDet[1],fDet[2])); | |
4893 | // A little geometry: | |
77566f2a | 4894 | Int_t rowMax = parCom->GetRowMax(fDet[0],fDet[1],fDet[2]); |
4895 | Int_t colMax = parCom->GetColMax(fDet[0]); | |
8ec526a4 | 4896 | // Create the histos to visualise |
4897 | CreateFitHistoCHDB(rowMax,colMax); | |
4898 | if (fDebug == 4) { | |
4899 | CreateFitHistoCH((Int_t) (fDect2[0]-fDect1[0]),fDect1[0],fDect2[0]); | |
4900 | } | |
77566f2a | 4901 | } |
4902 | } | |
8ec526a4 | 4903 | |
77566f2a | 4904 | } |
4905 | ||
8ec526a4 | 4906 | // PH and T0 |
4907 | if (i == 1) { | |
77566f2a | 4908 | |
8ec526a4 | 4909 | // Number of Xbins (detectors or groups of pads) if vector2d |
4910 | // Quick verification that we are not out of range! | |
4911 | if (fVectorPH && fPlaPH) { | |
4912 | if ((nbins == 0) && | |
4913 | (fVectorPH->GetEntriesFast() > 0) && | |
4914 | ((Int_t) fPlaPH->GetEntriesFast() > 0)) { | |
4915 | if ((Int_t) fVectorPH->GetEntriesFast() > numberofbinsexpected) { | |
4916 | AliInfo("ph doesn't correspond to the mode of pad group calibration!"); | |
4917 | return kFALSE; | |
4918 | } | |
4919 | if ((Int_t) fVectorPH->GetEntriesFast() != (Int_t) fPlaPH->GetEntriesFast()) { | |
4920 | AliInfo("VectorPH doesn't correspond to PlaPH!"); | |
4921 | return kFALSE; | |
4922 | } | |
77566f2a | 4923 | } |
4924 | } | |
4925 | ||
8ec526a4 | 4926 | // Init tree |
4927 | InitTreePH(); | |
4928 | InitTreeT0(); | |
4929 | ||
4930 | // | |
4931 | // Debugging: Create the histos | |
4932 | // | |
4933 | ||
4934 | // fDebug == 0 nothing | |
4935 | ||
4936 | // fDebug == 1 | |
4937 | if (fDebug == 1) { | |
4938 | if (nbins != 0) { | |
4939 | // Create the histos replique de ch | |
4940 | CreateFitHistoPH(nbins,lowedge,upedge); | |
4941 | CreateFitHistoT0(nbins,lowedge,upedge); | |
77566f2a | 4942 | } |
4943 | else { | |
8ec526a4 | 4944 | // Create the histos replique de ch if vector2d |
77566f2a | 4945 | CreateFitHistoPH(numberofbinsexpected,0,numberofbinsexpected); |
4946 | CreateFitHistoT0(numberofbinsexpected,0,numberofbinsexpected); | |
4947 | } | |
4948 | } | |
8ec526a4 | 4949 | |
4950 | // fDebug == 2 and fFitVoir no histo | |
4951 | if (fDebug == 2) { | |
4952 | if (fFitVoir < numberofbinsexpected) { | |
77566f2a | 4953 | AliInfo(Form("We will see the fit of the object %d",fFitVoir)); |
4954 | } | |
4955 | else { | |
4956 | AliInfo("fFitVoir is out of range of the histo!"); | |
4957 | return kFALSE; | |
4958 | } | |
4959 | } | |
8ec526a4 | 4960 | |
4961 | // fDebug == 3 or 4 and fDet | |
4962 | if (fDebug >= 3) { | |
4963 | if ((fNz[1] == 0) && | |
4964 | (fNrphi[1] == 0)) { | |
77566f2a | 4965 | AliInfo("Do you really want to see one detector without pad groups?"); |
4966 | return kFALSE; | |
4967 | } | |
4968 | else { | |
8ec526a4 | 4969 | AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d" |
4970 | ,fDet[0],fDet[1],fDet[2])); | |
4971 | // A little geometry: | |
77566f2a | 4972 | Int_t rowMax = parCom->GetRowMax(fDet[0],fDet[1],fDet[2]); |
4973 | Int_t colMax = parCom->GetColMax(fDet[0]); | |
8ec526a4 | 4974 | // Create the histos to visualise |
4975 | CreateFitHistoPHDB(rowMax,colMax); | |
4976 | CreateFitHistoT0DB(rowMax,colMax); | |
4977 | if (fDebug == 4) { | |
4978 | CreateFitHistoPH((Int_t) (fDect2[1]-fDect1[1]),fDect1[1],fDect2[1]); | |
4979 | CreateFitHistoT0((Int_t) (fDect2[1]-fDect1[1]),fDect1[1],fDect2[1]); | |
77566f2a | 4980 | } |
77566f2a | 4981 | } |
4982 | } | |
8ec526a4 | 4983 | |
77566f2a | 4984 | } |
8ec526a4 | 4985 | |
4986 | // PRF | |
4987 | if (i == 2) { | |
77566f2a | 4988 | |
8ec526a4 | 4989 | // Number of Xbins(detectors or groups of pads) if vector2d |
4990 | if (fVectorPRF && fPlaPRF){ | |
4991 | if ((nbins == 0) && | |
4992 | (fVectorPRF->GetEntriesFast() > 0) && | |
4993 | (fPlaPRF->GetEntriesFast() > 0)) { | |
4994 | // Quick verification that we are not out of range! | |
4995 | if ((Int_t) fVectorPRF->GetEntriesFast() > numberofbinsexpected) { | |
4996 | AliInfo("ch doesn't correspond to the mode of pad group calibration!"); | |
4997 | return kFALSE; | |
4998 | } | |
4999 | if ((Int_t) fVectorPRF->GetEntriesFast() != (Int_t) fPlaPRF->GetEntriesFast()) { | |
5000 | AliInfo("VectorPRF doesn't correspond to PlaCH!"); | |
5001 | return kFALSE; | |
5002 | } | |
77566f2a | 5003 | } |
5004 | } | |
5005 | ||
8ec526a4 | 5006 | // Init tree |
5007 | InitTreePRF(); | |
5008 | ||
5009 | // | |
5010 | // Debugging: Create the histos | |
5011 | // | |
5012 | ||
5013 | // fDebug == 0 nothing | |
5014 | ||
5015 | // fDebug == 1 | |
5016 | if (fDebug == 1) { | |
5017 | if (nbins != 0) { | |
5018 | // Create the histos replique de ch | |
5019 | CreateFitHistoPRF(nbins,lowedge,upedge); | |
77566f2a | 5020 | } |
5021 | else { | |
8ec526a4 | 5022 | // Create the histos replique de ch |
77566f2a | 5023 | CreateFitHistoPRF(numberofbinsexpected,0,numberofbinsexpected); |
5024 | } | |
5025 | } | |
5026 | ||
8ec526a4 | 5027 | // fDebug == 2 and fFitVoir no histo |
5028 | if (fDebug == 2) { | |
5029 | if (fFitVoir < numberofbinsexpected) { | |
77566f2a | 5030 | AliInfo(Form("We will see the fit of the object %d",fFitVoir)); |
5031 | } | |
5032 | else { | |
5033 | AliInfo("fFitVoir is out of range of the histo!"); | |
5034 | return kFALSE; | |
5035 | } | |
5036 | } | |
8ec526a4 | 5037 | |
5038 | // fDebug == 3 or 4 and fDet | |
5039 | if (fDebug >= 3) { | |
5040 | if ((fNz[2] == 0) && | |
5041 | (fNrphi[2] == 0)) { | |
77566f2a | 5042 | AliInfo("Do you really want to see one detector without pad groups?"); |
5043 | return kFALSE; | |
5044 | } | |
8ec526a4 | 5045 | else { |
5046 | AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d" | |
5047 | ,fDet[0],fDet[1],fDet[2])); | |
5048 | // A little geometry: | |
77566f2a | 5049 | Int_t rowMax = parCom->GetRowMax(fDet[0],fDet[1],fDet[2]); |
5050 | Int_t colMax = parCom->GetColMax(fDet[0]); | |
8ec526a4 | 5051 | // Create the histos to visualise |
5052 | CreateFitHistoPRFDB(rowMax,colMax); | |
5053 | if (fDebug == 4) { | |
5054 | CreateFitHistoPRF((Int_t) (fDect2[2]-fDect1[2]),fDect1[2],fDect2[2]); | |
5055 | } | |
77566f2a | 5056 | } |
5057 | } | |
8ec526a4 | 5058 | |
77566f2a | 5059 | } |
5060 | ||
5061 | return kTRUE; | |
5062 | ||
5063 | } | |
5064 | ||
8ec526a4 | 5065 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
5066 | void AliTRDCalibra::InitfCountDetAndfCount(Int_t i) | |
77566f2a | 5067 | { |
5068 | // | |
8ec526a4 | 5069 | // Init the current detector where we are fCountDet and the |
5070 | // next fCount for the functions Fit... | |
77566f2a | 5071 | // |
5072 | ||
8ec526a4 | 5073 | // Loop on the Xbins of ch!! |
5074 | fCountDet[i] = -1; // Current detector | |
5075 | fCount[i] = 0; // To find the next detector | |
77566f2a | 5076 | |
8ec526a4 | 5077 | // If fDebug >= 3 |
5078 | if (fDebug >= 3) { | |
5079 | ||
5080 | // Set countdet to the detector | |
5081 | fCountDet[i] = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]); | |
5082 | ||
5083 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
5084 | ModePadCalibration(fDet[1],i); | |
77566f2a | 5085 | ModePadFragmentation(fDet[0],fDet[1],fDet[2],i); |
5086 | ||
8ec526a4 | 5087 | // Set counter to write at the end of the detector |
5088 | fCount[i] = fDect1[i] + fNfragZ[i]*fNfragRphi[i]; | |
5089 | ||
77566f2a | 5090 | } |
77566f2a | 5091 | |
8ec526a4 | 5092 | } |
77566f2a | 5093 | |
8ec526a4 | 5094 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
5095 | void AliTRDCalibra::UpdatefCountDetAndfCount(Int_t idect, Int_t i) | |
77566f2a | 5096 | { |
5097 | // | |
8ec526a4 | 5098 | // See if we are in a new detector and update the |
5099 | // variables fNfragZ and fNfragRphi if yes | |
77566f2a | 5100 | // |
5101 | ||
8ec526a4 | 5102 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
5103 | // If fDebug == 1 or 0 | |
5104 | if ((fDebug == 0) || | |
5105 | (fDebug == 1)) { | |
5106 | ||
5107 | if (fCount[i] == idect) { | |
77566f2a | 5108 | |
8ec526a4 | 5109 | // On en est au detector |
5110 | fCountDet[i] += 1; | |
77566f2a | 5111 | |
8ec526a4 | 5112 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
5113 | ModePadCalibration((Int_t) GetChamber(fCountDet[i]),i); | |
5114 | ModePadFragmentation((Int_t) GetPlane(fCountDet[i]) | |
5115 | ,(Int_t) GetChamber(fCountDet[i]) | |
5116 | ,(Int_t) GetSector(fCountDet[i]),i); | |
5117 | ||
5118 | // Set for the next detector | |
5119 | fCount[i] += fNfragZ[i]*fNfragRphi[i]; | |
5120 | ||
77566f2a | 5121 | } |
8ec526a4 | 5122 | |
77566f2a | 5123 | } |
8ec526a4 | 5124 | |
77566f2a | 5125 | } |
77566f2a | 5126 | |
8ec526a4 | 5127 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
5128 | void AliTRDCalibra::ReconstructFitRowMinRowMax(Int_t idect, Int_t i) | |
77566f2a | 5129 | { |
5130 | // | |
8ec526a4 | 5131 | // Reconstruct the min pad row, max pad row, min pad col and |
5132 | // max pad col of the calibration group for the Fit functions | |
77566f2a | 5133 | // |
8ec526a4 | 5134 | |
5135 | if (fDebug < 2) { | |
5136 | ReconstructionRowPadGroup((Int_t) (idect-(fCount[i]-(fNfragZ[i]*fNfragRphi[i]))),i); | |
77566f2a | 5137 | } |
8ec526a4 | 5138 | if (fDebug >= 3) { |
5139 | ReconstructionRowPadGroup((Int_t) (idect-fDect1[i]),i); | |
77566f2a | 5140 | } |
77566f2a | 5141 | |
8ec526a4 | 5142 | } |
77566f2a | 5143 | |
8ec526a4 | 5144 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
77566f2a | 5145 | Bool_t AliTRDCalibra::NotEnoughStatistic(Int_t idect, Int_t i) |
5146 | { | |
5147 | // | |
8ec526a4 | 5148 | // For the case where there are not enough entries in the histograms |
5149 | // of the calibration group, the value present in the choosen database | |
5150 | // will be put. A negativ sign enables to know that a fit was not possible. | |
77566f2a | 5151 | // |
5152 | ||
77566f2a | 5153 | // Get the parameter object |
5154 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
5155 | if (!parCom) { | |
5156 | AliInfo("Could not get CommonParam Manager"); | |
5157 | return kFALSE; | |
5158 | } | |
5159 | ||
8ec526a4 | 5160 | // Get cal |
77566f2a | 5161 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
5162 | if (!cal) { | |
5163 | AliInfo("Could not get calibDB"); | |
5164 | return kFALSE; | |
5165 | } | |
5166 | ||
8ec526a4 | 5167 | if (fDebug != 2) { |
5168 | AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted" | |
5169 | ,idect-(fCount[i]-(fNfragZ[i]*fNfragRphi[i])),fCountDet[i])); | |
77566f2a | 5170 | } |
8ec526a4 | 5171 | if (fDebug == 2) { |
77566f2a | 5172 | AliInfo("The element has not enough statistic to be fitted"); |
5173 | } | |
5174 | ||
8ec526a4 | 5175 | if ((i == 0) && (fDebug != 2)) { |
77566f2a | 5176 | |
8ec526a4 | 5177 | // Calcul the coef from the database choosen |
5178 | CalculChargeCoefMean(fCountDet[0],(Int_t) (idect-fDect1[0]),kFALSE); | |
77566f2a | 5179 | |
8ec526a4 | 5180 | // Fill the coefCH[2304] with negative value to say: not fitted |
5181 | for (Int_t k = fRowMin[0]; k < fRowMax[0]; k++) { | |
5182 | for (Int_t j = fColMin[0]; j < fColMax[0]; j++) { | |
5183 | if (GetChamber(fCountDet[0]) == 2) { | |
5184 | fCoefCH[(Int_t)(j*12+k)] = -TMath::Abs(fChargeCoef[3]); | |
5185 | } | |
5186 | if (GetChamber(fCountDet[0]) != 2) { | |
5187 | fCoefCH[(Int_t)(j*16+k)] = -TMath::Abs(fChargeCoef[3]); | |
5188 | } | |
77566f2a | 5189 | } |
8ec526a4 | 5190 | } |
5191 | ||
5192 | // End of one detector | |
5193 | if ((idect == (fCount[0]-1))) { | |
5194 | FillVectorFitCH((Int_t) fCountDet[0]); | |
5195 | // Reset | |
5196 | for (Int_t k = 0; k < 2304; k++) { | |
5197 | fCoefCH[k] = 0.0; | |
77566f2a | 5198 | } |
5199 | } | |
8ec526a4 | 5200 | |
77566f2a | 5201 | } |
5202 | ||
8ec526a4 | 5203 | if ((i == 1) && (fDebug != 2)) { |
77566f2a | 5204 | |
8ec526a4 | 5205 | CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect-fDect1[1])); |
5206 | CalculT0CoefMean(fCountDet[1],(Int_t) (idect-fDect1[1])); | |
5207 | ||
5208 | // Put the default value | |
5209 | if ((fDebug == 1) || | |
5210 | (fDebug == 4)) { | |
5211 | ||
5212 | if (fFitPHOn) { | |
5213 | fCoefVdrift[0]->SetBinContent(idect-fDect1[1]+1,fVdriftCoef[2]); | |
5214 | fCoefT0[0]->SetBinContent(idect-fDect1[1]+1,fT0Coef[2]); | |
77566f2a | 5215 | } |
8ec526a4 | 5216 | |
5217 | fCoefVdrift[1]->SetBinContent(idect-fDect1[1]+1,fVdriftCoef[2]); | |
5218 | fCoefT0[1]->SetBinContent(idect-fDect1[1]+1,fT0Coef[2]); | |
5219 | ||
77566f2a | 5220 | } |
5221 | ||
8ec526a4 | 5222 | // Put the default value |
5223 | if (fDebug >= 3) { | |
77566f2a | 5224 | fVdriftCoef[0] = fVdriftCoef[2]; |
5225 | fVdriftCoef[1] = fVdriftCoef[2]; | |
5226 | FillCoefVdriftDB(); | |
8ec526a4 | 5227 | fT0Coef[0] = fT0Coef[2]; |
5228 | fT0Coef[1] = fT0Coef[2]; | |
77566f2a | 5229 | FillCoefT0DB(); |
5230 | } | |
77566f2a | 5231 | |
8ec526a4 | 5232 | // Fill the tree if end of a detector. |
5233 | // The pointer to the branch stays with the default value 1.5!!! | |
5234 | // PH | |
5235 | // Pointer to the branch | |
5236 | for (Int_t k = fRowMin[1]; k < fRowMax[1]; k++) { | |
5237 | for (Int_t j = fColMin[1]; j < fColMax[1]; j++) { | |
5238 | if (GetChamber(fCountDet[1]) == 2) { | |
5239 | fVdriftPad[(Int_t)(j*12+k)] = -TMath::Abs(fVdriftCoef[2]); | |
5240 | } | |
5241 | if (GetChamber(fCountDet[1]) != 2) { | |
5242 | fVdriftPad[(Int_t)(j*16+k)] = -TMath::Abs(fVdriftCoef[2]); | |
5243 | } | |
77566f2a | 5244 | } |
8ec526a4 | 5245 | } |
5246 | ||
5247 | // End of one detector | |
5248 | if ((idect == (fCount[1]-1)) && (fDebug != 2)) { | |
5249 | FillTreeVdrift((Int_t) fCountDet[1]); | |
5250 | } | |
5251 | ||
5252 | // T0 | |
5253 | // Fill the tree if end of a detector. | |
5254 | // The pointer to the branch stays with the default value 1.5!!! | |
5255 | // Pointer to the branch | |
5256 | for (Int_t k = fRowMin[1]; k < fRowMax[1]; k++) { | |
5257 | for (Int_t j = fColMin[1]; j < fColMax[1]; j++) { | |
5258 | if (GetChamber(fCountDet[1]) == 2) { | |
5259 | fT0Pad[(Int_t)(j*12+k)] = -TMath::Abs(fT0Coef[2]); | |
5260 | } | |
5261 | if (GetChamber(fCountDet[1]) != 2) { | |
5262 | fT0Pad[(Int_t)(j*16+k)] = -TMath::Abs(fT0Coef[2]); | |
5263 | } | |
77566f2a | 5264 | } |
8ec526a4 | 5265 | } |
5266 | ||
5267 | // End of one detector | |
5268 | if ((idect == (fCount[1]-1)) && (fDebug != 2)) { | |
5269 | FillTreeT0((Int_t) fCountDet[1]); | |
5270 | } | |
5271 | ||
77566f2a | 5272 | } |
77566f2a | 5273 | |
8ec526a4 | 5274 | if ((i == 2) && (fDebug != 2)) { |
5275 | ||
5276 | CalculPRFCoefMean(fCountDet[2],(Int_t) (idect-fDect1[2])); | |
77566f2a | 5277 | |
8ec526a4 | 5278 | if ((fDebug == 1) || |
5279 | (fDebug == 4)) { | |
5280 | fCoefPRF[0]->SetBinContent(idect-fDect1[2]+1,fPRFCoef[1]); | |
77566f2a | 5281 | } |
8ec526a4 | 5282 | |
5283 | if (fDebug >= 3){ | |
77566f2a | 5284 | fPRFCoef[0] = fPRFCoef[1]; |
5285 | FillCoefPRFDB(); | |
5286 | } | |
5287 | ||
8ec526a4 | 5288 | // Fill the tree if end of a detector. |
5289 | // The pointer to the branch stays with the default value 1.5!!! | |
5290 | // Pointer to the branch | |
5291 | for (Int_t k = fRowMin[2]; k < fRowMax[2]; k++) { | |
5292 | for (Int_t j = fColMin[2]; j < fColMax[2]; j++) { | |
5293 | if((parCom->GetColMax(GetPlane(fCountDet[2])) != (j+1)) && (j != 0)){ | |
5294 | if (GetChamber(fCountDet[2]) == 2) { | |
5295 | fPRFPad[(Int_t)(j*12+k)] = -fPRFCoef[1]; | |
5296 | } | |
5297 | if (GetChamber(fCountDet[2]) != 2) { | |
5298 | fPRFPad[(Int_t)(j*16+k)] = -fPRFCoef[1]; | |
5299 | } | |
77566f2a | 5300 | } |
8ec526a4 | 5301 | else { |
5302 | if (fAccCDB) { | |
5303 | if (GetChamber(fCountDet[2]) == 2) { | |
5304 | fPRFPad[(Int_t)(j*12+k)] = -((Float_t) cal->GetPRFWidth(fCountDet[2],j,k)); | |
5305 | } | |
5306 | if (GetChamber(fCountDet[2]) != 2) { | |
5307 | fPRFPad[(Int_t)(j*16+k)] = -((Float_t) cal->GetPRFWidth(fCountDet[2],j,k)); | |
5308 | } | |
5309 | } | |
5310 | if (!fAccCDB) { | |
5311 | if (GetChamber(fCountDet[2]) == 2) { | |
5312 | fPRFPad[(Int_t)(j*12+k)] = -((Float_t) GetPRFDefault(GetPlane(fCountDet[2]))); | |
5313 | } | |
5314 | if (GetChamber(fCountDet[2]) != 2) { | |
5315 | fPRFPad[(Int_t)(j*16+k)] = -((Float_t) GetPRFDefault(GetPlane(fCountDet[2]))); | |
5316 | } | |
5317 | } | |
77566f2a | 5318 | } |
5319 | } | |
8ec526a4 | 5320 | } |
5321 | ||
5322 | // End of one detector | |
5323 | if ((idect == (fCount[2]-1)) && (fDebug != 2)) { | |
5324 | FillTreePRF((Int_t) fCountDet[2]); | |
5325 | } | |
5326 | ||
77566f2a | 5327 | } |
5328 | ||
5329 | return kTRUE; | |
8ec526a4 | 5330 | |
77566f2a | 5331 | } |
5332 | ||
8ec526a4 | 5333 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
77566f2a | 5334 | Bool_t AliTRDCalibra::FillInfosFit(Int_t idect, Int_t i) |
5335 | { | |
5336 | // | |
8ec526a4 | 5337 | // Fill the coefficients found with the fits or other |
5338 | // methods from the Fit functions | |
77566f2a | 5339 | // |
77566f2a | 5340 | |
5341 | // Get the parameter object | |
5342 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
5343 | if (!parCom) { | |
5344 | AliInfo("Could not get CommonParam Manager"); | |
5345 | return kFALSE; | |
5346 | } | |
5347 | ||
8ec526a4 | 5348 | // Get cal |
77566f2a | 5349 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
5350 | if (!cal) { | |
5351 | AliInfo("Could not get calibDB"); | |
5352 | return kFALSE; | |
5353 | } | |
5354 | ||
8ec526a4 | 5355 | if ((i == 0) && (fDebug != 2)) { |
5356 | // Fill the coefCH[2304] with fChargeCoef[0] | |
5357 | // that would be negativ only if the fit failed totally | |
5358 | for (Int_t k = fRowMin[0]; k < fRowMax[0]; k++) { | |
5359 | for (Int_t j = fColMin[0]; j < fColMax[0]; j++) { | |
5360 | if (GetChamber(fCountDet[0]) == 2) { | |
5361 | fCoefCH[(Int_t)(j*12+k)] = fChargeCoef[0]; | |
5362 | } | |
5363 | if (GetChamber(fCountDet[0]) != 2) { | |
5364 | fCoefCH[(Int_t)(j*16+k)] = fChargeCoef[0]; | |
5365 | } | |
77566f2a | 5366 | } |
5367 | } | |
8ec526a4 | 5368 | // End of one detector |
5369 | if ((idect == (fCount[0]-1))) { | |
5370 | FillVectorFitCH((Int_t) fCountDet[0]); | |
5371 | // Reset | |
5372 | for (Int_t k = 0; k < 2304; k++) { | |
5373 | fCoefCH[k] = 0.0; | |
77566f2a | 5374 | } |
5375 | } | |
5376 | } | |
77566f2a | 5377 | |
8ec526a4 | 5378 | if ((i == 1) && (fDebug != 2)) { |
5379 | ||
5380 | // PH | |
5381 | // Pointer to the branch: fVdriftCoef[1] will ne negativ only if the fit failed totally | |
5382 | for (Int_t k = fRowMin[1]; k < fRowMax[1]; k++) { | |
5383 | for (Int_t j = fColMin[1]; j < fColMax[1]; j++) { | |
5384 | if (GetChamber(fCountDet[1]) == 2) { | |
5385 | fVdriftPad[(Int_t)(j*12+k)]=fVdriftCoef[1]; | |
5386 | } | |
5387 | if (GetChamber(fCountDet[1]) != 2) { | |
5388 | fVdriftPad[(Int_t)(j*16+k)]=fVdriftCoef[1]; | |
5389 | } | |
77566f2a | 5390 | } |
5391 | } | |
8ec526a4 | 5392 | // End of one detector |
5393 | if ((idect == (fCount[1]-1)) && (fDebug != 2)) { | |
5394 | FillTreeVdrift((Int_t) fCountDet[1]); | |
5395 | } | |
77566f2a | 5396 | |
8ec526a4 | 5397 | // T0 |
5398 | // Pointer to the branch: fT0Coef[1] will ne negativ only if the fit failed totally | |
5399 | for (Int_t k = fRowMin[1]; k < fRowMax[1]; k++) { | |
5400 | for (Int_t j = fColMin[1]; j < fColMax[1]; j++) { | |
5401 | if (GetChamber(fCountDet[1]) == 2) { | |
5402 | fT0Pad[(Int_t)(j*12+k)]=fT0Coef[1]; | |
5403 | } | |
5404 | if (GetChamber(fCountDet[1]) != 2) { | |
5405 | fT0Pad[(Int_t)(j*16+k)]=fT0Coef[1]; | |
5406 | } | |
77566f2a | 5407 | } |
5408 | } | |
8ec526a4 | 5409 | // End of one detector |
5410 | if ((idect == (fCount[1]-1)) && (fDebug != 2)) { | |
5411 | FillTreeT0((Int_t) fCountDet[1]); | |
5412 | } | |
5413 | ||
77566f2a | 5414 | } |
8ec526a4 | 5415 | |
5416 | if ((i == 2) && (fDebug != 2)) { | |
5417 | // Pointer to the branch | |
5418 | for (Int_t k = fRowMin[2]; k < fRowMax[2]; k++) { | |
5419 | for (Int_t j = fColMin[2]; j < fColMax[2]; j++) { | |
5420 | if ((parCom->GetColMax(GetPlane(fCountDet[2])) != (j+1)) && (j != 0)) { | |
5421 | if (GetChamber(fCountDet[2]) == 2) { | |
5422 | fPRFPad[(Int_t)(j*12+k)] = fPRFCoef[0]; | |
5423 | } | |
5424 | if (GetChamber(fCountDet[2]) != 2) { | |
5425 | fPRFPad[(Int_t)(j*16+k)] = fPRFCoef[0]; | |
5426 | } | |
5427 | } | |
5428 | else { | |
5429 | if (fAccCDB) { | |
5430 | if (GetChamber(fCountDet[2]) == 2) { | |
5431 | fPRFPad[(Int_t)(j*12+k)] = (Float_t) cal->GetPRFWidth(fCountDet[2],j,k); | |
5432 | } | |
5433 | if (GetChamber(fCountDet[2]) != 2) { | |
5434 | fPRFPad[(Int_t)(j*16+k)] = (Float_t) cal->GetPRFWidth(fCountDet[2],j,k); | |
5435 | } | |
5436 | } | |
5437 | if (!fAccCDB) { | |
5438 | if (GetChamber(fCountDet[2]) == 2) { | |
5439 | fPRFPad[(Int_t)(j*12+k)] = (Float_t) GetPRFDefault(GetPlane(fCountDet[2])); | |
5440 | } | |
5441 | if (GetChamber(fCountDet[2]) != 2) { | |
5442 | fPRFPad[(Int_t)(j*16+k)] = (Float_t) GetPRFDefault(GetPlane(fCountDet[2])); | |
5443 | } | |
77566f2a | 5444 | } |
77566f2a | 5445 | } |
8ec526a4 | 5446 | } |
5447 | } | |
5448 | // End of one detector | |
5449 | if ((idect == (fCount[2]-1)) && (fDebug != 2)) { | |
5450 | FillTreePRF((Int_t) fCountDet[2]); | |
5451 | } | |
77566f2a | 5452 | } |
8ec526a4 | 5453 | |
77566f2a | 5454 | return kTRUE; |
5455 | ||
5456 | } | |
77566f2a | 5457 | |
8ec526a4 | 5458 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
77566f2a | 5459 | Bool_t AliTRDCalibra::WriteFitInfos(Int_t i) |
5460 | { | |
5461 | // | |
8ec526a4 | 5462 | // In the case the user wants to write a file with a tree of the found |
5463 | // coefficients for the calibration before putting them in the database | |
77566f2a | 5464 | // |
5465 | ||
77566f2a | 5466 | TFile *fout = TFile::Open(fWriteNameCoef,"UPDATE"); |
8ec526a4 | 5467 | // Check if the file could be opened |
77566f2a | 5468 | if (!fout || !fout->IsOpen()) { |
5469 | AliInfo("No File found!"); | |
5470 | return kFALSE; | |
5471 | } | |
8ec526a4 | 5472 | |
5473 | if ((i == 0) && (fDebug != 2)) { | |
5474 | // The error stuff | |
5475 | if ((fDebug == 1) || | |
5476 | (fDebug == 4)) { | |
5477 | WriteCH(fout); | |
5478 | } | |
5479 | // The DB stuff | |
5480 | if ((fDebug == 4) || | |
5481 | (fDebug == 3)) { | |
5482 | WriteCHDB(fout); | |
5483 | } | |
5484 | // The tree | |
5485 | fout->WriteTObject(fGain,fGain->GetName(),(Option_t *) "writedelete"); | |
5486 | } | |
5487 | ||
5488 | if ((i == 1) && (fDebug != 2)) { | |
5489 | // PH | |
5490 | // The error stuff | |
5491 | if ((fDebug == 1) || | |
5492 | (fDebug == 4)) { | |
5493 | WritePH(fout); | |
5494 | } | |
5495 | // The DB stuff | |
5496 | if ((fDebug == 4) || | |
5497 | (fDebug == 3)) { | |
5498 | WritePHDB(fout); | |
5499 | } | |
5500 | // The tree | |
5501 | fout->WriteTObject(fVdrift,fVdrift->GetName(),(Option_t *) "writedelete"); | |
5502 | // T0 | |
5503 | // The error stuff | |
5504 | if ((fDebug == 1) || | |
5505 | (fDebug == 4)) { | |
5506 | WriteT0(fout); | |
5507 | } | |
5508 | // The DB stuff | |
5509 | if ((fDebug == 4) || | |
5510 | (fDebug == 3)) { | |
5511 | WriteT0DB(fout); | |
5512 | } | |
5513 | // The tree | |
5514 | fout->WriteTObject(fT0,fT0->GetName(),(Option_t *) "writedelete"); | |
5515 | } | |
5516 | ||
5517 | if ((i == 2) && (fDebug != 2)) { | |
5518 | // The error stuff | |
5519 | if ((fDebug == 1) || | |
5520 | (fDebug == 4)) { | |
5521 | WritePRF(fout); | |
5522 | } | |
5523 | // The DB stuff | |
5524 | if ((fDebug == 4) || | |
5525 | (fDebug == 3)) { | |
5526 | WritePRFDB(fout); | |
5527 | } | |
5528 | // The tree | |
5529 | fout->WriteTObject(fPRF,fPRF->GetName(),(Option_t *) "writedelete"); | |
77566f2a | 5530 | } |
8ec526a4 | 5531 | |
77566f2a | 5532 | fout->Close(); |
8ec526a4 | 5533 | |
77566f2a | 5534 | return kTRUE; |
8ec526a4 | 5535 | |
77566f2a | 5536 | } |
77566f2a | 5537 | |
8ec526a4 | 5538 | // |
5539 | //____________Fill the Error histos in case of fDebug == 1_____________________ | |
5540 | // | |
5541 | ||
5542 | //_____________________________________________________________________________ | |
77566f2a | 5543 | void AliTRDCalibra::ErrorPRF() |
5544 | { | |
5545 | // | |
5546 | // Fill the error histos for fDebug = 1 and fDebug = 4 from the delta histos | |
5547 | // | |
5548 | ||
8ec526a4 | 5549 | for (Int_t k= 0; k < fDeltaPRF->GetNbinsX(); k++) { |
5550 | if (fDeltaPRF->GetBinContent(k+1) != 0.0) { | |
5551 | fErrorPRF->Fill(fDeltaPRF->GetBinContent(k+1)); | |
5552 | } | |
77566f2a | 5553 | } |
5554 | ||
5555 | } | |
8ec526a4 | 5556 | |
5557 | //_____________________________________________________________________________ | |
77566f2a | 5558 | void AliTRDCalibra::ErrorCH() |
5559 | { | |
5560 | // | |
5561 | // Fill the error histos for fDebug = 1 and fDebug = 4 from the delta histos | |
5562 | // | |
8ec526a4 | 5563 | |
5564 | for (Int_t k= 0; k < fDeltaCharge[0]->GetNbinsX(); k++) { | |
5565 | if (fDeltaCharge[0]->GetBinContent(k+1) != 0.0) { | |
5566 | fErrorCharge[0]->Fill(fDeltaCharge[0]->GetBinContent(k+1)); | |
5567 | } | |
77566f2a | 5568 | } |
8ec526a4 | 5569 | if (fMeanChargeOn) { |
5570 | for (Int_t k= 0; k < fDeltaCharge[1]->GetNbinsX(); k++) { | |
5571 | if (fDeltaCharge[1]->GetBinContent(k+1) != 0.0) { | |
5572 | fErrorCharge[1]->Fill(fDeltaCharge[1]->GetBinContent(k+1)); | |
5573 | } | |
77566f2a | 5574 | } |
5575 | } | |
8ec526a4 | 5576 | if (fFitChargeBisOn ) { |
5577 | for (Int_t k= 0; k < fDeltaCharge[2]->GetNbinsX(); k++) { | |
5578 | if (fDeltaCharge[2]->GetBinContent(k+1) != 0.0) { | |
5579 | fErrorCharge[2]->Fill(fDeltaCharge[2]->GetBinContent(k+1)); | |
5580 | } | |
77566f2a | 5581 | } |
5582 | } | |
5583 | ||
5584 | } | |
8ec526a4 | 5585 | |
5586 | //_____________________________________________________________________________ | |
77566f2a | 5587 | void AliTRDCalibra::ErrorPH() |
5588 | { | |
5589 | // | |
5590 | // Fill the error histos for fDebug = 1 and fDebug = 4 from the delta histos | |
5591 | // | |
8ec526a4 | 5592 | |
5593 | if (fFitPHOn ) { | |
5594 | for (Int_t k = 0; k < fDeltaVdrift[0]->GetNbinsX(); k++) { | |
5595 | if (fDeltaVdrift[0]->GetBinContent(k+1) != 0.0) { | |
5596 | fErrorVdrift[0]->Fill(fDeltaVdrift[0]->GetBinContent(k+1)); | |
5597 | } | |
77566f2a | 5598 | } |
5599 | } | |
8ec526a4 | 5600 | for (Int_t k = 0; k < fDeltaVdrift[1]->GetNbinsX(); k++) { |
5601 | if (fDeltaVdrift[1]->GetBinContent(k+1) != 0.0) { | |
5602 | fErrorVdrift[1]->Fill(fDeltaVdrift[1]->GetBinContent(k+1)); | |
5603 | } | |
77566f2a | 5604 | } |
8ec526a4 | 5605 | |
77566f2a | 5606 | } |
8ec526a4 | 5607 | |
5608 | //_____________________________________________________________________________ | |
77566f2a | 5609 | void AliTRDCalibra::ErrorT0() |
5610 | { | |
5611 | // | |
5612 | // Fill the error histos for fDebug = 1 and fDebug = 4 from the delta histos | |
5613 | // | |
8ec526a4 | 5614 | |
5615 | if (fFitPHOn ) { | |
5616 | for (Int_t k = 0; k < fDeltaT0[0]->GetNbinsX(); k++) { | |
5617 | if (fDeltaT0[0]->GetBinContent(k+1) != 0.0) { | |
5618 | fErrorT0[0]->Fill(fDeltaT0[0]->GetBinContent(k+1)); | |
5619 | } | |
77566f2a | 5620 | } |
5621 | } | |
8ec526a4 | 5622 | for (Int_t k = 0; k < fDeltaT0[1]->GetNbinsX(); k++) { |
5623 | if (fDeltaT0[1]->GetBinContent(k+1) != 0.0) { | |
5624 | fErrorT0[1]->Fill(fDeltaT0[1]->GetBinContent(k+1)); | |
5625 | } | |
77566f2a | 5626 | } |
8ec526a4 | 5627 | |
77566f2a | 5628 | } |
77566f2a | 5629 | |
8ec526a4 | 5630 | // |
5631 | //____________Fill Coef DB in case of visualisation of one detector____________ | |
5632 | // | |
5633 | ||
5634 | //_____________________________________________________________________________ | |
77566f2a | 5635 | void AliTRDCalibra::FillCoefVdriftDB() |
5636 | { | |
5637 | // | |
5638 | // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5639 | // | |
5640 | ||
8ec526a4 | 5641 | for (Int_t row = fRowMin[1]; row < fRowMax[1]; row++) { |
5642 | for (Int_t col = fColMin[1]; col < fColMax[1]; col++) { | |
77566f2a | 5643 | fCoefVdriftDB[1]->SetBinContent(row+1,col+1,TMath::Abs(fVdriftCoef[1])); |
8ec526a4 | 5644 | if (fFitPHOn ) { |
5645 | fCoefVdriftDB[0]->SetBinContent(row+1,col+1,TMath::Abs(fVdriftCoef[0])); | |
5646 | } | |
77566f2a | 5647 | } |
5648 | } | |
8ec526a4 | 5649 | |
77566f2a | 5650 | } |
8ec526a4 | 5651 | |
5652 | //_____________________________________________________________________________ | |
77566f2a | 5653 | void AliTRDCalibra::FillCoefT0DB() |
5654 | { | |
5655 | // | |
5656 | // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5657 | // | |
5658 | ||
8ec526a4 | 5659 | for (Int_t row = fRowMin[1]; row < fRowMax[1]; row++) { |
5660 | for (Int_t col = fColMin[1]; col < fColMax[1]; col++) { | |
77566f2a | 5661 | fCoefT0DB[1]->SetBinContent(row+1,col+1,TMath::Abs(fT0Coef[1])); |
8ec526a4 | 5662 | if (fFitPHOn) { |
5663 | fCoefT0DB[0]->SetBinContent(row+1,col+1,TMath::Abs(fT0Coef[0])); | |
5664 | } | |
77566f2a | 5665 | } |
5666 | } | |
8ec526a4 | 5667 | |
77566f2a | 5668 | } |
8ec526a4 | 5669 | |
5670 | //_____________________________________________________________________________ | |
77566f2a | 5671 | void AliTRDCalibra::FillCoefChargeDB() |
5672 | { | |
5673 | // | |
5674 | // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5675 | // | |
5676 | ||
8ec526a4 | 5677 | for (Int_t row = fRowMin[0]; row < fRowMax[0]; row++) { |
5678 | for (Int_t col = fColMin[0]; col < fColMax[0]; col++) { | |
5679 | if (fMeanChargeOn) { | |
5680 | fCoefChargeDB[1]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[1])); | |
5681 | } | |
5682 | if (fFitChargeBisOn) { | |
5683 | fCoefChargeDB[2]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[2])); | |
5684 | } | |
77566f2a | 5685 | fCoefChargeDB[0]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[0])); |
5686 | } | |
8ec526a4 | 5687 | } |
5688 | ||
77566f2a | 5689 | } |
8ec526a4 | 5690 | |
5691 | //_____________________________________________________________________________ | |
77566f2a | 5692 | void AliTRDCalibra::FillCoefPRFDB() |
5693 | { | |
5694 | // | |
5695 | // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5696 | // | |
8ec526a4 | 5697 | |
5698 | for (Int_t row = fRowMin[2]; row < fRowMax[2]; row++) { | |
5699 | for (Int_t col = fColMin[2]; col < fColMax[2]; col++) { | |
77566f2a | 5700 | fCoefPRFDB->SetBinContent(row+1,col+1,fPRFCoef[0]); |
77566f2a | 5701 | } |
8ec526a4 | 5702 | } |
77566f2a | 5703 | |
8ec526a4 | 5704 | } |
77566f2a | 5705 | |
8ec526a4 | 5706 | // |
5707 | //____________Plot histos CoefPRF....__________________________________________ | |
5708 | // | |
77566f2a | 5709 | |
8ec526a4 | 5710 | //_____________________________________________________________________________ |
77566f2a | 5711 | void AliTRDCalibra::PlotCH() |
5712 | { | |
5713 | // | |
5714 | // Plot the histos for fDebug = 1 and fDebug = 4 for the errors | |
5715 | // | |
8ec526a4 | 5716 | |
77566f2a | 5717 | TCanvas *cch1 = new TCanvas("cch1","",50,50,600,800); |
5718 | cch1->cd(); | |
5719 | TLegend *legch1 = new TLegend(0.4,0.6,0.89,0.89); | |
5720 | legch1->AddEntry(fCoefCharge[3],"f_{g} simulated","l"); | |
8ec526a4 | 5721 | if (fMeanChargeOn) { |
5722 | legch1->AddEntry(fCoefCharge[1],"f_{g} mean","p"); | |
5723 | } | |
77566f2a | 5724 | legch1->AddEntry(fCoefCharge[0],"f_{g} fit","p"); |
8ec526a4 | 5725 | if (fFitChargeBisOn ) { |
5726 | legch1->AddEntry(fCoefCharge[2],"f_{g} fitbis","p"); | |
5727 | } | |
5728 | ||
77566f2a | 5729 | fCoefCharge[0]->Draw("E2"); |
8ec526a4 | 5730 | if (fMeanChargeOn) { |
5731 | fCoefCharge[1]->Draw("E2 same"); | |
5732 | } | |
5733 | if (fFitChargeBisOn ) { | |
5734 | fCoefCharge[2]->Draw("E2 same"); | |
5735 | } | |
77566f2a | 5736 | fCoefCharge[3]->Draw("same"); |
5737 | legch1->Draw("same"); | |
8ec526a4 | 5738 | |
77566f2a | 5739 | TCanvas *cch2 = new TCanvas("cch2","",50,50,600,800); |
5740 | cch2->Divide(2,1); | |
5741 | cch2->cd(1); | |
5742 | TLegend *legch2 = new TLegend(0.4,0.6,0.89,0.89); | |
8ec526a4 | 5743 | if (fMeanChargeOn) { |
5744 | legch2->AddEntry(fErrorCharge[1],"f_{g} mean","l"); | |
5745 | } | |
77566f2a | 5746 | legch2->AddEntry(fErrorCharge[0],"f_{g} fit","l"); |
8ec526a4 | 5747 | if (fFitChargeBisOn) { |
5748 | legch2->AddEntry(fErrorCharge[2],"f_{g} fitbis","l"); | |
5749 | } | |
77566f2a | 5750 | fErrorCharge[0]->Draw(); |
8ec526a4 | 5751 | if (fMeanChargeOn) { |
5752 | fErrorCharge[1]->Draw("same"); | |
5753 | } | |
5754 | if (fFitChargeBisOn) { | |
5755 | fErrorCharge[2]->Draw("same"); | |
5756 | } | |
77566f2a | 5757 | legch2->Draw("same"); |
5758 | cch2->cd(2); | |
5759 | TLegend *legch3 = new TLegend(0.4,0.6,0.89,0.89); | |
8ec526a4 | 5760 | if (fMeanChargeOn) { |
5761 | legch3->AddEntry(fDeltaCharge[1],"mean","p"); | |
5762 | } | |
77566f2a | 5763 | legch3->AddEntry(fDeltaCharge[0],"fit","p"); |
8ec526a4 | 5764 | if (fFitChargeBisOn) { |
5765 | legch3->AddEntry(fDeltaCharge[2],"fit","p"); | |
5766 | } | |
77566f2a | 5767 | fDeltaCharge[0]->Draw("E2"); |
8ec526a4 | 5768 | if (fMeanChargeOn) { |
5769 | fDeltaCharge[1]->Draw("E2 same"); | |
5770 | } | |
5771 | if (fFitChargeBisOn) { | |
5772 | fDeltaCharge[2]->Draw("E2 same"); | |
5773 | } | |
77566f2a | 5774 | legch3->Draw("same"); |
5775 | ||
5776 | } | |
8ec526a4 | 5777 | |
5778 | //_____________________________________________________________________________ | |
77566f2a | 5779 | void AliTRDCalibra::PlotPH() |
5780 | { | |
5781 | // | |
5782 | // Plot the histos for fDebug = 1 and fDebug = 4 for the errors | |
5783 | // | |
5784 | ||
5785 | TCanvas *cph1 = new TCanvas("cph1","",50,50,600,800); | |
5786 | cph1->cd(); | |
5787 | TLegend *legph1 = new TLegend(0.4,0.6,0.89,0.89); | |
5788 | legph1->AddEntry(fCoefVdrift[2],"v_{real} simulated","l"); | |
5789 | legph1->AddEntry(fCoefVdrift[1],"v_{sm} slope 1 method","p"); | |
5790 | ||
8ec526a4 | 5791 | if (fFitPHOn) { |
5792 | legph1->AddEntry(fCoefVdrift[0],"v_{fit} fit","p"); | |
5793 | } | |
77566f2a | 5794 | fCoefVdrift[1]->Draw("E2"); |
5795 | fCoefVdrift[2]->Draw("same"); | |
8ec526a4 | 5796 | if (fFitPHOn){ |
5797 | fCoefVdrift[0]->Draw("E2 same"); | |
5798 | } | |
77566f2a | 5799 | legph1->Draw("same"); |
77566f2a | 5800 | |
5801 | TCanvas *cph2 = new TCanvas("cph2","",50,50,600,800); | |
5802 | cph2->Divide(2,1); | |
5803 | cph2->cd(1); | |
5804 | TLegend *legph2 = new TLegend(0.4,0.6,0.89,0.89); | |
5805 | legph2->AddEntry(fErrorVdrift[1],"v_{sm} slope 1 method","l"); | |
8ec526a4 | 5806 | if (fFitPHOn) { |
5807 | legph2->AddEntry(fErrorVdrift[0],"v_{fit} fit","l"); | |
5808 | } | |
77566f2a | 5809 | fErrorVdrift[1]->Draw(); |
8ec526a4 | 5810 | if (fFitPHOn) { |
5811 | fErrorVdrift[0]->Draw("l,same"); | |
5812 | } | |
77566f2a | 5813 | legph2->Draw("same"); |
5814 | cph2->cd(2); | |
5815 | TLegend *legph3 = new TLegend(0.4,0.6,0.89,0.89); | |
5816 | legph3->AddEntry(fDeltaVdrift[1],"v_{sm} slope 1 method","p"); | |
8ec526a4 | 5817 | if (fFitPHOn) { |
5818 | legph3->AddEntry(fDeltaVdrift[0],"v_{fit} fit","p"); | |
5819 | } | |
77566f2a | 5820 | fDeltaVdrift[1]->Draw("E2"); |
8ec526a4 | 5821 | if (fFitPHOn) { |
5822 | fDeltaVdrift[0]->Draw("E2 same"); | |
5823 | } | |
77566f2a | 5824 | legph3->Draw("same"); |
8ec526a4 | 5825 | |
77566f2a | 5826 | } |
8ec526a4 | 5827 | |
5828 | //_____________________________________________________________________________ | |
77566f2a | 5829 | void AliTRDCalibra::PlotT0() |
5830 | { | |
5831 | // | |
5832 | // Plot the histos for fDebug = 1 and fDebug = 4 for the errors | |
5833 | // | |
5834 | ||
5835 | TCanvas *ct01 = new TCanvas("ct01","",50,50,600,800); | |
5836 | ct01->cd(); | |
5837 | TLegend *legt01 = new TLegend(0.4,0.6,0.89,0.89); | |
5838 | legt01->AddEntry(fCoefT0[2],"t0 simulated","l"); | |
5839 | legt01->AddEntry(fCoefT0[1],"t0 slope 1 method","p"); | |
5840 | ||
8ec526a4 | 5841 | if (fFitPHOn) { |
5842 | legt01->AddEntry(fCoefT0[0],"t0 fit","p"); | |
5843 | } | |
77566f2a | 5844 | fCoefT0[1]->Draw("E2"); |
5845 | fCoefT0[2]->Draw("same"); | |
8ec526a4 | 5846 | if (fFitPHOn){ |
5847 | fCoefT0[0]->Draw("E2 same"); | |
5848 | } | |
77566f2a | 5849 | legt01->Draw("same"); |
77566f2a | 5850 | |
5851 | TCanvas *ct02 = new TCanvas("ct02","",50,50,600,800); | |
5852 | ct02->Divide(2,1); | |
5853 | ct02->cd(1); | |
5854 | TLegend *legt02 = new TLegend(0.4,0.6,0.89,0.89); | |
5855 | legt02->AddEntry(fErrorT0[1],"t0 slope 1 method","l"); | |
8ec526a4 | 5856 | if (fFitPHOn) { |
5857 | legt02->AddEntry(fErrorT0[0],"t0 fit","l"); | |
5858 | } | |
77566f2a | 5859 | fErrorT0[1]->Draw(); |
8ec526a4 | 5860 | if (fFitPHOn) { |
5861 | fErrorT0[0]->Draw("l,same"); | |
5862 | } | |
77566f2a | 5863 | legt02->Draw("same"); |
5864 | ct02->cd(2); | |
5865 | TLegend *legt03 = new TLegend(0.4,0.6,0.89,0.89); | |
5866 | legt03->AddEntry(fDeltaT0[1],"t0 slope 1 method","p"); | |
8ec526a4 | 5867 | if (fFitPHOn) { |
5868 | legt03->AddEntry(fDeltaT0[0],"t0 fit","p"); | |
5869 | } | |
77566f2a | 5870 | fDeltaT0[1]->Draw("E2"); |
8ec526a4 | 5871 | if (fFitPHOn) { |
5872 | fDeltaT0[0]->Draw("E2 same"); | |
5873 | } | |
77566f2a | 5874 | legt03->Draw("same"); |
8ec526a4 | 5875 | |
77566f2a | 5876 | } |
5877 | ||
8ec526a4 | 5878 | //_____________________________________________________________________________ |
77566f2a | 5879 | void AliTRDCalibra::PlotPRF() |
5880 | { | |
5881 | // | |
5882 | // Plot the histos for fDebug = 1 and fDebug = 4 for the errors | |
5883 | // | |
5884 | ||
5885 | TCanvas *cprf1 = new TCanvas("cprf1","",50,50,600,800); | |
5886 | cprf1->cd(); | |
5887 | TLegend *legprf1 = new TLegend(0.4,0.6,0.89,0.89); | |
5888 | legprf1->AddEntry(fCoefPRF[1],"#sigma_{real} simulated","l"); | |
5889 | legprf1->AddEntry(fCoefPRF[0],"#sigma_{fit} reconstructed","p"); | |
5890 | ||
5891 | fCoefPRF[0]->Draw("E2"); | |
5892 | fCoefPRF[1]->Draw("same"); | |
5893 | legprf1->Draw("same"); | |
5894 | ||
77566f2a | 5895 | TCanvas *cprf2 = new TCanvas("cprf2","",50,50,600,800); |
5896 | cprf2->Divide(2,1); | |
5897 | cprf2->cd(1); | |
5898 | TLegend *legprf2 = new TLegend(0.4,0.6,0.89,0.89); | |
5899 | legprf2->AddEntry(fErrorPRF,"#sigma_{fit} reconstructed","l"); | |
5900 | fErrorPRF->Draw(""); | |
5901 | legprf2->Draw("same"); | |
5902 | cprf2->cd(2); | |
5903 | TLegend *legprf3 = new TLegend(0.4,0.6,0.89,0.89); | |
5904 | legprf3->AddEntry(fDeltaPRF,"#sigma_{fit} reconstructed","p"); | |
5905 | fDeltaPRF->Draw("E2"); | |
5906 | legprf3->Draw("same"); | |
5907 | ||
5908 | } | |
5909 | ||
8ec526a4 | 5910 | // |
5911 | //____________Plot histos DB___________________________________________________ | |
5912 | // | |
5913 | ||
5914 | //_____________________________________________________________________________ | |
77566f2a | 5915 | void AliTRDCalibra::PlotCHDB() |
5916 | { | |
5917 | // | |
5918 | // Plot the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5919 | // | |
5920 | ||
5921 | TCanvas *cchdb = new TCanvas("cchdb","",50,50,600,800); | |
8ec526a4 | 5922 | if ((fFitChargeBisOn) && (fMeanChargeOn)) { |
77566f2a | 5923 | cchdb->Divide(3,1); |
5924 | cchdb->cd(1); | |
5925 | fCoefChargeDB[0]->Draw("LEGO"); | |
5926 | cchdb->cd(2); | |
5927 | fCoefChargeDB[1]->Draw("LEGO"); | |
5928 | cchdb->cd(3); | |
5929 | fCoefChargeDB[2]->Draw("LEGO"); | |
5930 | } | |
8ec526a4 | 5931 | if ((!fFitChargeBisOn) && (fMeanChargeOn)) { |
77566f2a | 5932 | cchdb->Divide(2,1); |
5933 | cchdb->cd(1); | |
5934 | fCoefChargeDB[0]->Draw("LEGO"); | |
5935 | cchdb->cd(2); | |
5936 | fCoefChargeDB[1]->Draw("LEGO"); | |
5937 | } | |
8ec526a4 | 5938 | else { |
77566f2a | 5939 | cchdb->cd(); |
5940 | fCoefChargeDB[0]->Draw("LEGO"); | |
5941 | } | |
5942 | ||
5943 | } | |
77566f2a | 5944 | |
8ec526a4 | 5945 | //_____________________________________________________________________________ |
77566f2a | 5946 | void AliTRDCalibra::PlotPHDB() |
5947 | { | |
5948 | // | |
5949 | // Plot the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5950 | // | |
5951 | ||
5952 | TCanvas *cphdb = new TCanvas("cphdb","",50,50,600,800); | |
8ec526a4 | 5953 | if (fFitPHOn) { |
77566f2a | 5954 | cphdb->Divide(2,1); |
5955 | cphdb->cd(1); | |
5956 | fCoefVdriftDB[0]->Draw("LEGO"); | |
5957 | cphdb->cd(2); | |
5958 | fCoefVdriftDB[1]->Draw("LEGO"); | |
5959 | } | |
8ec526a4 | 5960 | else { |
77566f2a | 5961 | cphdb->cd(); |
5962 | fCoefVdriftDB[1]->Draw("LEGO"); | |
5963 | } | |
8ec526a4 | 5964 | |
77566f2a | 5965 | } |
77566f2a | 5966 | |
8ec526a4 | 5967 | //_____________________________________________________________________________ |
77566f2a | 5968 | void AliTRDCalibra::PlotT0DB() |
5969 | { | |
5970 | // | |
5971 | // Plot the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5972 | // | |
5973 | ||
5974 | TCanvas *ct0db = new TCanvas("ct0db","",50,50,600,800); | |
8ec526a4 | 5975 | if (fFitPHOn ) { |
77566f2a | 5976 | ct0db->Divide(2,1); |
5977 | ct0db->cd(1); | |
5978 | fCoefT0DB[0]->Draw("LEGO"); | |
5979 | ct0db->cd(2); | |
5980 | fCoefT0DB[1]->Draw("LEGO"); | |
5981 | } | |
8ec526a4 | 5982 | else { |
77566f2a | 5983 | ct0db->cd(); |
5984 | fCoefT0DB[1]->Draw("LEGO"); | |
5985 | } | |
8ec526a4 | 5986 | |
77566f2a | 5987 | } |
77566f2a | 5988 | |
8ec526a4 | 5989 | //_____________________________________________________________________________ |
77566f2a | 5990 | void AliTRDCalibra::PlotPRFDB() |
5991 | { | |
5992 | // | |
5993 | // Plot the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5994 | // | |
5995 | ||
5996 | TCanvas *cprfdb = new TCanvas("cprfdb","",50,50,600,800); | |
5997 | cprfdb->cd(); | |
5998 | fCoefPRFDB->Draw("LEGO"); | |
8ec526a4 | 5999 | |
77566f2a | 6000 | } |
6001 | ||
8ec526a4 | 6002 | // |
6003 | //____________Write histos Coef________________________________________________ | |
6004 | // | |
77566f2a | 6005 | |
8ec526a4 | 6006 | //_____________________________________________________________________________ |
77566f2a | 6007 | void AliTRDCalibra::WriteCH(TFile *fout) |
6008 | { | |
6009 | // | |
6010 | // If wanted, write the debug histos for fDebug = 1 and fDebug = 4 | |
6011 | // | |
6012 | ||
8ec526a4 | 6013 | fout->WriteTObject(fCoefCharge[0],fCoefCharge[0]->GetName(),(Option_t *) "OverWrite"); |
6014 | if (fMeanChargeOn) { | |
6015 | fout->WriteTObject(fCoefCharge[1],fCoefCharge[1]->GetName(),(Option_t *) "OverWrite"); | |
6016 | } | |
6017 | if (fFitChargeBisOn) { | |
6018 | fout->WriteTObject(fCoefCharge[2],fCoefCharge[2]->GetName(),(Option_t *) "OverWrite"); | |
6019 | } | |
6020 | ||
6021 | fout->WriteTObject(fCoefCharge[3],fCoefCharge[3]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6022 | |
8ec526a4 | 6023 | fout->WriteTObject(fDeltaCharge[0],fDeltaCharge[0]->GetName(),(Option_t *) "OverWrite"); |
6024 | if (fMeanChargeOn) { | |
6025 | fout->WriteTObject(fDeltaCharge[1],fDeltaCharge[1]->GetName(),(Option_t *) "OverWrite"); | |
6026 | } | |
6027 | if (fFitChargeBisOn) { | |
6028 | fout->WriteTObject(fDeltaCharge[2],fDeltaCharge[2]->GetName(),(Option_t *) "OverWrite"); | |
6029 | } | |
77566f2a | 6030 | |
8ec526a4 | 6031 | fout->WriteTObject(fErrorCharge[0],fErrorCharge[0]->GetName(),(Option_t *) "OverWrite"); |
6032 | if (fMeanChargeOn) { | |
6033 | fout->WriteTObject(fErrorCharge[1],fErrorCharge[1]->GetName(),(Option_t *) "OverWrite"); | |
6034 | } | |
6035 | if (fFitChargeBisOn) { | |
6036 | fout->WriteTObject(fErrorCharge[2],fErrorCharge[2]->GetName(),(Option_t *) "OverWrite"); | |
6037 | } | |
77566f2a | 6038 | |
6039 | } | |
8ec526a4 | 6040 | |
6041 | //_____________________________________________________________________________ | |
77566f2a | 6042 | void AliTRDCalibra::WritePH(TFile *fout) |
6043 | { | |
6044 | // | |
6045 | // If wanted, write the debug histos for fDebug = 1 and fDebug = 4 | |
6046 | // | |
6047 | ||
8ec526a4 | 6048 | if (fFitPHOn) { |
6049 | fout->WriteTObject(fCoefVdrift[0],fCoefVdrift[0]->GetName(),(Option_t *) "OverWrite"); | |
6050 | } | |
6051 | fout->WriteTObject(fCoefVdrift[1],fCoefVdrift[1]->GetName(),(Option_t *) "OverWrite"); | |
6052 | fout->WriteTObject(fCoefVdrift[2],fCoefVdrift[2]->GetName(),(Option_t *) "OverWrite"); | |
6053 | ||
6054 | if (fFitPHOn) { | |
6055 | fout->WriteTObject(fDeltaVdrift[0],fDeltaVdrift[0]->GetName(),(Option_t *) "OverWrite"); | |
6056 | } | |
6057 | fout->WriteTObject(fDeltaVdrift[1],fDeltaVdrift[1]->GetName(),(Option_t *) "OverWrite"); | |
6058 | ||
6059 | if (fFitPHOn) { | |
6060 | fout->WriteTObject(fErrorVdrift[0],fErrorVdrift[0]->GetName(),(Option_t *) "OverWrite"); | |
6061 | } | |
6062 | fout->WriteTObject(fErrorVdrift[1],fErrorVdrift[1]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6063 | |
77566f2a | 6064 | } |
8ec526a4 | 6065 | |
6066 | //_____________________________________________________________________________ | |
77566f2a | 6067 | void AliTRDCalibra::WriteT0(TFile *fout) |
6068 | { | |
6069 | // | |
6070 | // If wanted, write the debug histos for fDebug = 1 and fDebug = 4 | |
6071 | // | |
6072 | ||
8ec526a4 | 6073 | if (fFitPHOn) { |
6074 | fout->WriteTObject(fCoefT0[0],fCoefT0[0]->GetName(),(Option_t *) "OverWrite"); | |
6075 | } | |
6076 | fout->WriteTObject(fCoefT0[1],fCoefT0[1]->GetName(),(Option_t *) "OverWrite"); | |
6077 | fout->WriteTObject(fCoefT0[2],fCoefT0[2]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6078 | |
8ec526a4 | 6079 | if (fFitPHOn) { |
6080 | fout->WriteTObject(fDeltaT0[0],fDeltaT0[0]->GetName(),(Option_t *) "OverWrite"); | |
6081 | } | |
6082 | fout->WriteTObject(fDeltaT0[1],fDeltaT0[1]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6083 | |
8ec526a4 | 6084 | if (fFitPHOn) { |
6085 | fout->WriteTObject(fErrorT0[0],fErrorT0[0]->GetName(),(Option_t *) "OverWrite"); | |
6086 | } | |
6087 | fout->WriteTObject(fErrorT0[1],fErrorT0[1]->GetName(),(Option_t *) "OverWrite"); | |
6088 | ||
77566f2a | 6089 | } |
8ec526a4 | 6090 | |
77566f2a | 6091 | //________________________________________________________________________________ |
6092 | void AliTRDCalibra::WritePRF(TFile *fout) | |
6093 | { | |
6094 | // | |
6095 | // If wanted, write the debug histos for fDebug = 1 and fDebug = 4 | |
6096 | // | |
6097 | ||
8ec526a4 | 6098 | fout->WriteTObject(fCoefPRF[0],fCoefPRF[0]->GetName(),(Option_t *) "OverWrite"); |
6099 | fout->WriteTObject(fCoefPRF[1],fCoefPRF[1]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6100 | |
8ec526a4 | 6101 | fout->WriteTObject(fDeltaPRF,fDeltaPRF->GetName(), (Option_t *)"OverWrite"); |
6102 | fout->WriteTObject(fErrorPRF,fErrorPRF->GetName(), (Option_t *)"OverWrite"); | |
77566f2a | 6103 | |
8ec526a4 | 6104 | } |
77566f2a | 6105 | |
8ec526a4 | 6106 | // |
6107 | //____________Write DB Histos__________________________________________________ | |
6108 | // | |
77566f2a | 6109 | |
8ec526a4 | 6110 | //_____________________________________________________________________________ |
77566f2a | 6111 | void AliTRDCalibra::WriteCHDB(TFile *fout) |
6112 | { | |
6113 | // | |
6114 | // If wanted, write the debug histos for fDebug = 3 and fDebug = 4 | |
6115 | // | |
6116 | ||
8ec526a4 | 6117 | fout->WriteTObject(fCoefChargeDB[0],fCoefChargeDB[0]->GetName(),(Option_t *) "OverWrite"); |
6118 | if (fMeanChargeOn) { | |
6119 | fout->WriteTObject(fCoefChargeDB[1],fCoefChargeDB[1]->GetName(),(Option_t *) "OverWrite"); | |
6120 | } | |
6121 | if (fFitChargeBisOn ) { | |
6122 | fout->WriteTObject(fCoefChargeDB[2],fCoefChargeDB[2]->GetName(),(Option_t *) "OverWrite"); | |
6123 | } | |
77566f2a | 6124 | |
6125 | } | |
8ec526a4 | 6126 | |
6127 | //_____________________________________________________________________________ | |
77566f2a | 6128 | void AliTRDCalibra::WritePHDB(TFile *fout) |
6129 | { | |
6130 | // | |
6131 | // If wanted, write the debug histos for fDebug = 3 and fDebug = 4 | |
6132 | // | |
6133 | ||
8ec526a4 | 6134 | if (fFitPHOn) { |
6135 | fout->WriteTObject(fCoefVdriftDB[0],fCoefVdriftDB[0]->GetName(),(Option_t *) "OverWrite"); | |
6136 | } | |
6137 | fout->WriteTObject(fCoefVdriftDB[1],fCoefVdriftDB[1]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6138 | |
6139 | } | |
8ec526a4 | 6140 | |
6141 | //_____________________________________________________________________________ | |
77566f2a | 6142 | void AliTRDCalibra::WriteT0DB(TFile *fout) |
6143 | { | |
6144 | // | |
6145 | // If wanted, write the debug histos for fDebug = 3 and fDebug = 4 | |
6146 | // | |
6147 | ||
8ec526a4 | 6148 | if (fFitPHOn) { |
6149 | fout->WriteTObject(fCoefT0DB[0],fCoefT0DB[0]->GetName(),(Option_t *) "OverWrite"); | |
6150 | } | |
6151 | fout->WriteTObject(fCoefT0DB[1],fCoefT0DB[1]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6152 | |
6153 | } | |
8ec526a4 | 6154 | |
6155 | //_____________________________________________________________________________ | |
77566f2a | 6156 | void AliTRDCalibra::WritePRFDB(TFile *fout) |
6157 | { | |
6158 | // | |
6159 | // If wanted, write the debug histos for fDebug = 3 and fDebug = 4 | |
6160 | // | |
6161 | ||
8ec526a4 | 6162 | fout->WriteTObject(fCoefPRFDB,fCoefPRFDB->GetName(),(Option_t *) "OverWrite"); |
77566f2a | 6163 | |
6164 | } | |
6165 | ||
8ec526a4 | 6166 | // |
6167 | //____________Calcul Coef Mean_________________________________________________ | |
6168 | // | |
77566f2a | 6169 | |
8ec526a4 | 6170 | //_____________________________________________________________________________ |
6171 | Bool_t AliTRDCalibra::CalculT0CoefMean(Int_t dect, Int_t idect) | |
77566f2a | 6172 | { |
6173 | // | |
8ec526a4 | 6174 | // For the detector Dect calcul the mean time 0 |
6175 | // for the calibration group idect from the choosen database | |
77566f2a | 6176 | // |
6177 | ||
8ec526a4 | 6178 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 6179 | if (!cal) { |
6180 | AliInfo("Could not get calibDB Manager"); | |
6181 | return kFALSE; | |
6182 | } | |
6183 | ||
6184 | fT0Coef[2] = 0.0; | |
6185 | ||
8ec526a4 | 6186 | if ((fDebug != 2) && fAccCDB) { |
77566f2a | 6187 | |
8ec526a4 | 6188 | for (Int_t row = fRowMin[1]; row < fRowMax[1]; row++) { |
6189 | for (Int_t col = fColMin[1]; col < fColMax[1]; col++) { | |
6190 | // Groups of pads | |
6191 | if ((fNz[1] > 0) && | |
6192 | (fNrphi[1] > 0)) { | |
6193 | fT0Coef[2] += (Float_t) cal->GetT0(dect,col,row); | |
6194 | } | |
6195 | // Per detectors | |
6196 | else { | |
6197 | fT0Coef[2] += (Float_t) cal->GetT0Average(dect); | |
77566f2a | 6198 | } |
77566f2a | 6199 | } |
6200 | } | |
8ec526a4 | 6201 | |
6202 | fT0Coef[2] = fT0Coef[2] / ((fColMax[1]-fColMin[1])*(fRowMax[1]-fRowMin[1])); | |
6203 | if ((fDebug == 1) || | |
6204 | (fDebug == 4)) { | |
6205 | fCoefT0[2]->SetBinContent(idect+1,fT0Coef[2]); | |
6206 | } | |
6207 | ||
77566f2a | 6208 | } |
8ec526a4 | 6209 | |
77566f2a | 6210 | return kTRUE; |
6211 | ||
6212 | } | |
8ec526a4 | 6213 | |
6214 | //_____________________________________________________________________________ | |
6215 | Bool_t AliTRDCalibra::CalculChargeCoefMean(Int_t dect, Int_t idect, Bool_t vrai) | |
77566f2a | 6216 | { |
6217 | // | |
8ec526a4 | 6218 | // For the detector Dect calcul the mean gain factor |
6219 | // for the calibration group idect from the choosen database | |
77566f2a | 6220 | // |
6221 | ||
77566f2a | 6222 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
6223 | if (!cal) { | |
6224 | AliInfo("Could not get calibDB Manager"); | |
6225 | return kFALSE; | |
6226 | } | |
8ec526a4 | 6227 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); |
77566f2a | 6228 | if (!parCom) { |
6229 | AliInfo("Could not get CommonParam Manager"); | |
6230 | return kFALSE; | |
6231 | } | |
6232 | ||
6233 | fChargeCoef[3] = 0.0; | |
8ec526a4 | 6234 | |
6235 | if (fDebug != 2) { | |
6236 | ||
6237 | for (Int_t row = fRowMin[0]; row < fRowMax[0]; row++) { | |
6238 | for (Int_t col = fColMin[0]; col < fColMax[0]; col++) { | |
6239 | // Groups of pads | |
6240 | if ((fNz[0] > 0) || | |
6241 | (fNrphi[0] > 0)) { | |
6242 | if (fAccCDB) { | |
6243 | fChargeCoef[3] += (Float_t) cal->GetGainFactor(dect,col,row); | |
6244 | } | |
6245 | if (vrai && fAccCDB) { | |
6246 | fScaleFitFactor += (Float_t) cal->GetGainFactor(dect,col,row); | |
6247 | } | |
6248 | if (!fAccCDB) { | |
6249 | fChargeCoef[3] += 1.0; | |
6250 | } | |
6251 | if (vrai && (!fAccCDB)) { | |
6252 | fScaleFitFactor += 1.0; | |
6253 | } | |
77566f2a | 6254 | } |
8ec526a4 | 6255 | // Per detectors |
77566f2a | 6256 | else { |
8ec526a4 | 6257 | if (fAccCDB) { |
6258 | fChargeCoef[3] += (Float_t) cal->GetGainFactorAverage(dect); | |
6259 | } | |
6260 | if (vrai && fAccCDB) { | |
6261 | fScaleFitFactor += ((Float_t) cal->GetGainFactorAverage(dect)); | |
6262 | } | |
6263 | if (!fAccCDB) { | |
6264 | fChargeCoef[3] += 1.0; | |
6265 | } | |
6266 | if (vrai && (!fAccCDB)) { | |
6267 | fScaleFitFactor += 1.0; | |
6268 | } | |
77566f2a | 6269 | } |
6270 | } | |
6271 | } | |
8ec526a4 | 6272 | |
6273 | fChargeCoef[3] = fChargeCoef[3] / ((fColMax[0]-fColMin[0])*(fRowMax[0]-fRowMin[0])); | |
6274 | if ((fDebug == 1) || | |
6275 | (fDebug == 4)) { | |
6276 | fCoefCharge[3]->SetBinContent(idect+1,fChargeCoef[3]); | |
6277 | } | |
6278 | ||
77566f2a | 6279 | } |
77566f2a | 6280 | |
8ec526a4 | 6281 | return kTRUE; |
77566f2a | 6282 | |
6283 | } | |
8ec526a4 | 6284 | |
6285 | //_____________________________________________________________________________ | |
6286 | Bool_t AliTRDCalibra::CalculPRFCoefMean(Int_t dect, Int_t idect) | |
77566f2a | 6287 | { |
6288 | // | |
8ec526a4 | 6289 | // For the detector Dect calcul the mean sigma of pad response |
6290 | // function for the calibration group idect from the choosen database | |
77566f2a | 6291 | // |
6292 | ||
77566f2a | 6293 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
6294 | if (!cal) { | |
6295 | AliInfo("Could not get calibDB Manager"); | |
6296 | return kFALSE; | |
6297 | } | |
6298 | ||
8ec526a4 | 6299 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); |
77566f2a | 6300 | if (!parCom) { |
6301 | AliInfo("Could not get CommonParam Manager"); | |
6302 | return kFALSE; | |
6303 | } | |
6304 | ||
77566f2a | 6305 | fPRFCoef[1] = 0.0; |
6306 | Int_t cot = 0; | |
8ec526a4 | 6307 | |
6308 | if (fDebug != 2) { | |
77566f2a | 6309 | |
8ec526a4 | 6310 | for (Int_t row = fRowMin[2]; row < fRowMax[2]; row++) { |
6311 | for (Int_t col = fColMin[2]; col < fColMax[2]; col++) { | |
6312 | if ((parCom->GetColMax(GetPlane(dect)) != (col+1)) && (col != 0)) { | |
77566f2a | 6313 | cot++; |
8ec526a4 | 6314 | if (fAccCDB) { |
6315 | fPRFCoef[1] += (Float_t) cal->GetPRFWidth(dect,col,row); | |
6316 | } | |
6317 | if (!fAccCDB) { | |
6318 | fPRFCoef[1] += GetPRFDefault(GetPlane(dect)); | |
6319 | } | |
77566f2a | 6320 | } |
6321 | } | |
6322 | } | |
8ec526a4 | 6323 | |
6324 | if (cot > 0) { | |
77566f2a | 6325 | fPRFCoef[1] = fPRFCoef[1]/cot; |
8ec526a4 | 6326 | if ((fDebug == 1) || |
6327 | (fDebug == 4)) { | |
6328 | fCoefPRF[1]->SetBinContent(idect+1,fPRFCoef[1]); | |
6329 | } | |
77566f2a | 6330 | } |
8ec526a4 | 6331 | if (cot <= 0) { |
6332 | if ((fDebug == 1) || | |
6333 | (fDebug == 4)) { | |
6334 | if (fAccCDB) { | |
6335 | fCoefPRF[1]->SetBinContent(idect+1,cal->GetPRFWidth(dect,fColMin[2],fRowMin[2])); | |
6336 | } | |
6337 | if (!fAccCDB) { | |
6338 | fCoefPRF[1]->SetBinContent(idect+1,GetPRFDefault(GetPlane(dect))); | |
6339 | } | |
6340 | } | |
77566f2a | 6341 | } |
8ec526a4 | 6342 | |
77566f2a | 6343 | } |
8ec526a4 | 6344 | |
77566f2a | 6345 | return kTRUE; |
6346 | ||
6347 | } | |
8ec526a4 | 6348 | |
6349 | //_____________________________________________________________________________ | |
6350 | Bool_t AliTRDCalibra::CalculVdriftCoefMean(Int_t dect, Int_t idect) | |
77566f2a | 6351 | { |
6352 | // | |
8ec526a4 | 6353 | // For the detector dect calcul the mean drift velocity for the |
6354 | // calibration group idect from the choosen database | |
77566f2a | 6355 | // |
6356 | ||
8ec526a4 | 6357 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 6358 | if (!cal) { |
6359 | AliInfo("Could not get calibDB Manager"); | |
6360 | return kFALSE; | |
6361 | } | |
6362 | ||
77566f2a | 6363 | fVdriftCoef[2] = 0.0; |
6364 | ||
8ec526a4 | 6365 | if (fDebug != 2) { |
6366 | for (Int_t row = fRowMin[1]; row < fRowMax[1]; row++) { | |
6367 | for (Int_t col = fColMin[1]; col < fColMax[1]; col++) { | |
6368 | // Groups of pads | |
6369 | if ((fNz[1] > 0) || | |
6370 | (fNrphi[1] > 0)) { | |
6371 | if (fAccCDB) { | |
6372 | fVdriftCoef[2] += (Float_t) cal->GetVdrift(dect,col,row); | |
6373 | } | |
6374 | if (!fAccCDB) { | |
6375 | fVdriftCoef[2] += 1.5; | |
6376 | } | |
6377 | } | |
6378 | // Per detectors | |
6379 | else { | |
6380 | if (fAccCDB) { | |
6381 | fVdriftCoef[2] += (Float_t) cal->GetVdriftAverage(dect); | |
6382 | } | |
6383 | if (!fAccCDB) { | |
6384 | fVdriftCoef[2] += 1.5; | |
6385 | } | |
77566f2a | 6386 | } |
77566f2a | 6387 | } |
6388 | } | |
8ec526a4 | 6389 | fVdriftCoef[2] = fVdriftCoef[2] / ((fColMax[1]-fColMin[1])*(fRowMax[1]-fRowMin[1])); |
6390 | if ((fDebug == 1) || | |
6391 | (fDebug == 4)) { | |
6392 | fCoefVdrift[2]->SetBinContent(idect+1,fVdriftCoef[2]); | |
6393 | } | |
77566f2a | 6394 | } |
8ec526a4 | 6395 | |
77566f2a | 6396 | return kTRUE; |
6397 | ||
6398 | } | |
6399 | ||
8ec526a4 | 6400 | //_____________________________________________________________________________ |
6401 | Float_t AliTRDCalibra::GetPRFDefault(Int_t plane) const | |
6402 | { | |
6403 | // | |
6404 | // Default width of the PRF if there is no database as reference | |
6405 | // | |
6406 | ||
6407 | if (plane == 0) { | |
6408 | return 0.515; | |
6409 | } | |
6410 | if (plane == 1) { | |
6411 | return 0.502; | |
6412 | } | |
6413 | if (plane == 2) { | |
6414 | return 0.491; | |
6415 | } | |
6416 | if (plane == 3) { | |
6417 | return 0.481; | |
6418 | } | |
6419 | if (plane == 4) { | |
6420 | return 0.471; | |
6421 | } | |
6422 | if (plane == 5) { | |
6423 | return 0.463; | |
6424 | } | |
6425 | else { | |
6426 | return 0.0; | |
6427 | } | |
6428 | ||
6429 | } | |
6430 | ||
6431 | // | |
6432 | //____________Pad group calibration mode_______________________________________ | |
6433 | // | |
6434 | ||
6435 | //_____________________________________________________________________________ | |
77566f2a | 6436 | void AliTRDCalibra::ReconstructionRowPadGroup(Int_t idect, Int_t i) |
6437 | { | |
6438 | // | |
8ec526a4 | 6439 | // For the calibration group idect in a detector calculate the |
6440 | // first and last row pad and col pad. | |
77566f2a | 6441 | // The pads in the interval will have the same calibrated coefficients |
6442 | // | |
6443 | ||
77566f2a | 6444 | Int_t posc = -1; |
6445 | Int_t posr = -1; | |
8ec526a4 | 6446 | fRowMin[i] = -1; |
6447 | fRowMax[i] = -1; | |
6448 | fColMin[i] = -1; | |
6449 | fColMax[i] = -1; | |
77566f2a | 6450 | |
8ec526a4 | 6451 | if (fNfragZ[i] != 0) { |
6452 | posc = (Int_t) idect / fNfragZ[i]; | |
6453 | } | |
6454 | if (fNfragRphi[i] != 0) { | |
6455 | posr = (Int_t) idect % fNfragZ[i]; | |
6456 | } | |
6457 | fRowMin[i] = posr * fNnZ[i]; | |
6458 | fRowMax[i] = (posr+1) * fNnZ[i]; | |
6459 | fColMin[i] = posc * fNnRphi[i]; | |
6460 | fColMax[i] = (posc+1) * fNnRphi[i]; | |
6461 | ||
77566f2a | 6462 | } |
6463 | ||
6464 | //_____________________________________________________________________________ | |
6465 | void AliTRDCalibra::CalculXBins(Int_t idect, Int_t i) | |
6466 | { | |
6467 | // | |
6468 | // For the detector idect calcul the first Xbins | |
6469 | // | |
6470 | ||
77566f2a | 6471 | fXbins[i] = 0; |
8ec526a4 | 6472 | if (fDebug == 4) { |
77566f2a | 6473 | AliInfo(Form("detector: %d", idect)); |
6474 | } | |
6475 | ||
8ec526a4 | 6476 | // In which sector? |
77566f2a | 6477 | Int_t sector = GetSector(idect); |
8ec526a4 | 6478 | fXbins[i] += sector*(6*fDetChamb2[i]+6*4*fDetChamb0[i]); |
77566f2a | 6479 | |
8ec526a4 | 6480 | // In which chamber? |
77566f2a | 6481 | Int_t chamber = GetChamber(idect); |
8ec526a4 | 6482 | Int_t kc = 0; |
6483 | while (kc < chamber) { | |
6484 | if (kc == 2) { | |
6485 | fXbins[i] += 6 * fDetChamb2[i]; | |
6486 | } | |
6487 | else { | |
6488 | fXbins[i] += 6 * fDetChamb0[i]; | |
6489 | } | |
77566f2a | 6490 | kc ++; |
6491 | } | |
6492 | ||
8ec526a4 | 6493 | // In which plane? |
77566f2a | 6494 | Int_t plane = GetPlane(idect); |
8ec526a4 | 6495 | if (chamber == 2) { |
6496 | fXbins[i] += plane*fDetChamb2[i]; | |
6497 | } | |
6498 | else { | |
6499 | fXbins[i] += plane*fDetChamb0[i]; | |
6500 | } | |
77566f2a | 6501 | |
6502 | } | |
8ec526a4 | 6503 | |
77566f2a | 6504 | //_____________________________________________________________________________ |
8ec526a4 | 6505 | Int_t AliTRDCalibra::SearchInVector(Int_t group, Int_t i) const |
77566f2a | 6506 | { |
6507 | // | |
8ec526a4 | 6508 | // Search if the calibration group "group" has already been |
6509 | // initialised by a previous track in the vector | |
77566f2a | 6510 | // |
6511 | ||
8ec526a4 | 6512 | if (i == 0) { |
6513 | for (Int_t k = 0; k < (Int_t) fPlaCH->GetEntriesFast(); k++) { | |
6514 | if (((AliTRDPlace *) fPlaCH->At(k))->GetPlace() == group) { | |
6515 | return k; | |
6516 | } | |
77566f2a | 6517 | } |
6518 | return -1; | |
6519 | } | |
6520 | ||
8ec526a4 | 6521 | if (i == 1) { |
6522 | for (Int_t k = 0; k < (Int_t) fPlaPH->GetEntriesFast(); k++) { | |
6523 | if (((AliTRDPlace *) fPlaPH->At(k))->GetPlace() == group) { | |
6524 | return k; | |
6525 | } | |
77566f2a | 6526 | } |
6527 | return -1; | |
6528 | } | |
6529 | ||
8ec526a4 | 6530 | if (i == 2) { |
6531 | for (Int_t k = 0; k < (Int_t) fPlaPRF->GetEntriesFast(); k++) { | |
6532 | if (((AliTRDPlace *) fPlaPRF->At(k))->GetPlace() == group) { | |
6533 | return k; | |
6534 | } | |
77566f2a | 6535 | } |
6536 | return -1; | |
6537 | } | |
8ec526a4 | 6538 | |
77566f2a | 6539 | return -1; |
8ec526a4 | 6540 | |
77566f2a | 6541 | } |
8ec526a4 | 6542 | |
77566f2a | 6543 | //_____________________________________________________________________________ |
8ec526a4 | 6544 | Int_t AliTRDCalibra::SearchInTreeVector(TObjArray *vectorplace, Int_t group) const |
77566f2a | 6545 | { |
6546 | // | |
6547 | // Search if the calibration group "group" is present in the tree | |
6548 | // | |
6549 | ||
8ec526a4 | 6550 | for (Int_t k = 0; k < (Int_t) vectorplace->GetEntriesFast(); k++) { |
6551 | if (((AliTRDPlace *) vectorplace->At(k))->GetPlace() == group) { | |
6552 | return k; | |
6553 | } | |
77566f2a | 6554 | } |
8ec526a4 | 6555 | |
77566f2a | 6556 | return -1; |
6557 | ||
6558 | } | |
8ec526a4 | 6559 | |
77566f2a | 6560 | //_____________________________________________________________________________ |
8ec526a4 | 6561 | Int_t AliTRDCalibra::SearchBin(Float_t value, Int_t i) const |
77566f2a | 6562 | { |
6563 | // | |
6564 | // Search the bin | |
6565 | // | |
6566 | ||
8ec526a4 | 6567 | Int_t reponse = 0; |
6568 | Int_t fbinmin = 0; | |
6569 | Int_t fbinmax = (Int_t) value; | |
77566f2a | 6570 | Int_t fNumberOfBin = -1; |
6571 | ||
8ec526a4 | 6572 | // Charge |
6573 | if (i == 0) { | |
6574 | fbinmax = 300; | |
6575 | fbinmin = 0; | |
77566f2a | 6576 | fNumberOfBin = fNumberBinCharge; |
6577 | } | |
6578 | ||
8ec526a4 | 6579 | // PRF |
6580 | if (i == 2) { | |
6581 | fbinmax = 1; | |
6582 | fbinmin = -1; | |
77566f2a | 6583 | fNumberOfBin = fNumberBinPRF; |
6584 | } | |
6585 | ||
8ec526a4 | 6586 | // Return -1 if out |
6587 | if ((value >= fbinmax) || | |
6588 | (value < fbinmin)) { | |
6589 | return -1; | |
6590 | } | |
6591 | // Sinon | |
6592 | else { | |
6593 | reponse = (Int_t) ((fNumberOfBin*(value-fbinmin)) / (fbinmax-fbinmin)); | |
77566f2a | 6594 | } |
6595 | ||
6596 | return reponse; | |
8ec526a4 | 6597 | |
77566f2a | 6598 | } |
8ec526a4 | 6599 | |
77566f2a | 6600 | //_____________________________________________________________________________ |
6601 | Bool_t AliTRDCalibra::UpdateVectorCH(Int_t group, Float_t value) | |
6602 | { | |
6603 | // | |
8ec526a4 | 6604 | // Fill the vector if a new calibration group "group" or update the |
6605 | // values of the calibration group "group" if already here | |
77566f2a | 6606 | // |
6607 | ||
8ec526a4 | 6608 | // Search bin |
77566f2a | 6609 | Int_t bin = SearchBin(value,0); |
8ec526a4 | 6610 | // Out |
6611 | if ((bin < 0) || (bin >= fNumberBinCharge)) { | |
6612 | return kFALSE; | |
77566f2a | 6613 | } |
8ec526a4 | 6614 | |
6615 | // Search place | |
6616 | Int_t place = SearchInVector(group,0); | |
6617 | ||
6618 | // New group | |
6619 | if (place == -1) { | |
6620 | AliTRDPlace *placegroup = new AliTRDPlace(); | |
6621 | placegroup->SetPlace(group); | |
6622 | fPlaCH->Add((TObject *) placegroup); | |
6623 | // Variable | |
6624 | AliTRDCTInfo *fCHInfo = new AliTRDCTInfo(); | |
6625 | UShort_t *entries = new UShort_t[fNumberBinCharge]; | |
6626 | // Initialise first | |
6627 | for(Int_t k = 0; k < fNumberBinCharge; k++) { | |
6628 | entries[k] = 0; | |
6629 | } | |
6630 | // Add the value | |
6631 | entries[bin]= 1; | |
6632 | // Set | |
6633 | fCHInfo->SetEntries(entries); | |
6634 | // Set in the vector | |
6635 | fVectorCH->Add((TObject *) fCHInfo); | |
6636 | } | |
6637 | // Group already exits | |
6638 | else { | |
6639 | // Variable | |
6640 | AliTRDCTInfo *fCHInfo = new AliTRDCTInfo(); | |
6641 | // Retrieve | |
6642 | fCHInfo = ((AliTRDCTInfo *) fVectorCH->At(place)); | |
6643 | UShort_t *entries = fCHInfo->GetEntries(); | |
6644 | // Add | |
6645 | entries[bin]++; | |
6646 | // Set | |
6647 | fCHInfo->SetEntries(entries); | |
6648 | // Update the vector | |
6649 | fVectorCH->AddAt((TObject *) fCHInfo,place); | |
77566f2a | 6650 | } |
6651 | ||
6652 | return kTRUE; | |
8ec526a4 | 6653 | |
77566f2a | 6654 | } |
6655 | ||
6656 | //_____________________________________________________________________________ | |
6657 | Bool_t AliTRDCalibra::UpdateVectorPRF(Int_t group, Float_t x, Float_t y) | |
6658 | { | |
6659 | // | |
8ec526a4 | 6660 | // Fill the vector if a new calibration group "group" or update the |
6661 | // values of the calibration group "group" if already here | |
77566f2a | 6662 | // |
6663 | ||
8ec526a4 | 6664 | // Search bin |
77566f2a | 6665 | Int_t bin = SearchBin(x,2); |
8ec526a4 | 6666 | // Out |
6667 | if ((bin < 0) || (bin >= fNumberBinPRF)) { | |
6668 | return kFALSE; | |
6669 | } | |
6670 | ||
6671 | // Search place | |
77566f2a | 6672 | Int_t place = SearchInVector(group,2); |
8ec526a4 | 6673 | |
6674 | // New group | |
6675 | if (place == -1) { | |
6676 | ||
6677 | AliTRDPlace *placegroup = new AliTRDPlace(); | |
6678 | placegroup->SetPlace(group); | |
6679 | fPlaPRF->Add((TObject *) placegroup); | |
6680 | AliTRDPInfo *fPRFInfo = new AliTRDPInfo(); | |
6681 | ||
6682 | Float_t *sum = new Float_t[fNumberBinPRF]; | |
6683 | Float_t *sumsquare = new Float_t[fNumberBinPRF]; | |
6684 | UShort_t *entries = new UShort_t[fNumberBinPRF]; | |
6685 | ||
6686 | // Initialise first | |
6687 | for (Int_t k = 0; k < fNumberBinPRF; k++) { | |
6688 | sum[k] = 0.0; | |
6689 | sumsquare[k] = 0.0; | |
6690 | entries[k] = 0; | |
6691 | } | |
6692 | ||
6693 | // Add the value | |
6694 | sum[bin] += y; | |
6695 | sumsquare[bin] += y*y; | |
6696 | entries[bin]++; | |
6697 | ||
6698 | // Set | |
6699 | fPRFInfo->SetSum(sum); | |
6700 | fPRFInfo->SetSumSquare(sumsquare); | |
6701 | fPRFInfo->SetEntries(entries); | |
6702 | ||
6703 | // Set in the vector | |
6704 | fVectorPRF->Add((TObject *) fPRFInfo); | |
77566f2a | 6705 | |
6706 | } | |
8ec526a4 | 6707 | // Group already exits |
6708 | else { | |
6709 | ||
6710 | AliTRDPInfo *fPRFInfo = new AliTRDPInfo(); | |
6711 | // Retrieve | |
6712 | fPRFInfo = (AliTRDPInfo *) fVectorPRF->At(place); | |
6713 | ||
6714 | Float_t *sum = fPRFInfo->GetSum(); | |
6715 | Float_t *sumsquare = fPRFInfo->GetSumSquare(); | |
6716 | UShort_t *entries = fPRFInfo->GetEntries(); | |
6717 | ||
6718 | // Add | |
6719 | Double_t calcul = (((Double_t) fPRFInfo->GetEntries()[bin]) | |
6720 | * ((Double_t) fPRFInfo->GetSum()[bin]) + (Double_t) y) | |
6721 | / (((Double_t) fPRFInfo->GetEntries()[bin]) + 1); | |
6722 | sum[bin] = (Float_t) calcul; | |
6723 | Double_t calculsquare = (((Double_t) fPRFInfo->GetSumSquare()[bin]) | |
6724 | * ((Double_t) fPRFInfo->GetEntries()[bin]) + ((Double_t) y)*((Double_t) y)) | |
6725 | / (((Double_t) fPRFInfo->GetEntries()[bin]) + 1); | |
6726 | sumsquare[bin] = (Float_t) calculsquare; | |
6727 | entries[bin]++; | |
6728 | ||
6729 | // Set | |
6730 | fPRFInfo->SetSum(sum); | |
6731 | fPRFInfo->SetSumSquare(sumsquare); | |
6732 | fPRFInfo->SetEntries(entries); | |
6733 | ||
6734 | // Update the vector | |
6735 | fVectorPRF->AddAt((TObject *) fPRFInfo,place); | |
77566f2a | 6736 | |
6737 | } | |
6738 | ||
6739 | return kTRUE; | |
8ec526a4 | 6740 | |
77566f2a | 6741 | } |
6742 | ||
6743 | //_____________________________________________________________________________ | |
6744 | Bool_t AliTRDCalibra::UpdateVectorPH(Int_t group, Int_t time, Float_t value) | |
6745 | { | |
6746 | // | |
8ec526a4 | 6747 | // Fill the vector if a new calibration group "group" or update |
6748 | // the values of the calibration group "group" if already here | |
77566f2a | 6749 | // |
6750 | ||
8ec526a4 | 6751 | // Search bin |
77566f2a | 6752 | Int_t bin = time; |
8ec526a4 | 6753 | // Out |
6754 | if ((bin < 0) || | |
6755 | (bin >= fTimeMax)) { | |
6756 | return kFALSE; | |
6757 | } | |
6758 | ||
6759 | // Search place | |
77566f2a | 6760 | Int_t place = SearchInVector(group,1); |
8ec526a4 | 6761 | |
6762 | // New group | |
77566f2a | 6763 | if(place == -1){ |
8ec526a4 | 6764 | |
6765 | AliTRDPlace *placegroup = new AliTRDPlace(); | |
6766 | placegroup->SetPlace(group); | |
6767 | fPlaPH->Add((TObject *) placegroup); | |
6768 | AliTRDPInfo *fPHInfo = new AliTRDPInfo(); | |
6769 | ||
6770 | Float_t *sum = new Float_t[fTimeMax]; | |
6771 | Float_t *sumsquare = new Float_t[fTimeMax]; | |
6772 | UShort_t *entries = new UShort_t[fTimeMax]; | |
6773 | ||
6774 | // Initialise first | |
6775 | for (Int_t k = 0; k < fTimeMax; k++) { | |
6776 | sum[k] = 0.0; | |
6777 | sumsquare[k] = 0.0; | |
6778 | entries[k] = 0; | |
6779 | } | |
6780 | ||
6781 | // Add the value | |
6782 | sum[bin] += value; | |
6783 | sumsquare[bin] += value*value; | |
6784 | entries[bin]++; | |
6785 | ||
6786 | // Set | |
6787 | fPHInfo->SetSum(sum); | |
6788 | fPHInfo->SetSumSquare(sumsquare); | |
6789 | fPHInfo->SetEntries(entries); | |
6790 | ||
6791 | // Set in the vector | |
6792 | fVectorPH->Add((TObject *) fPHInfo); | |
6793 | ||
77566f2a | 6794 | } |
8ec526a4 | 6795 | // Group already exits |
6796 | else { | |
6797 | ||
6798 | AliTRDPInfo *fPHInfo = new AliTRDPInfo(); | |
6799 | // Retrieve | |
6800 | fPHInfo = (AliTRDPInfo *) fVectorPH->At(place); | |
6801 | ||
6802 | Float_t *sum = fPHInfo->GetSum(); | |
6803 | Float_t *sumsquare = fPHInfo->GetSumSquare(); | |
6804 | UShort_t *entries = fPHInfo->GetEntries(); | |
6805 | ||
6806 | // Add | |
6807 | Double_t calcul = (((Double_t) fPHInfo->GetEntries()[bin]) | |
6808 | * ((Double_t) fPHInfo->GetSum()[bin]) + (Double_t) value) | |
6809 | / (((Double_t) fPHInfo->GetEntries()[bin]) + 1); | |
6810 | sum[bin] = (Float_t) calcul; | |
6811 | Double_t calculsquare = ((((Double_t) fPHInfo->GetSumSquare()[bin]) | |
6812 | * ((Double_t) fPHInfo->GetEntries()[bin])) | |
6813 | + (((Double_t) value) * ((Double_t)value))) | |
6814 | / (((Double_t) fPHInfo->GetEntries()[bin]) + 1); | |
6815 | sumsquare[bin] = (Float_t) calculsquare; | |
6816 | entries[bin]++; | |
6817 | ||
6818 | // Set | |
6819 | fPHInfo->SetSum(sum); | |
6820 | fPHInfo->SetSumSquare(sumsquare); | |
6821 | fPHInfo->SetEntries(entries); | |
6822 | ||
6823 | // Update the vector | |
6824 | fVectorPH->AddAt((TObject *) fPHInfo,place); | |
6825 | ||
77566f2a | 6826 | } |
6827 | ||
6828 | return kTRUE; | |
6829 | ||
6830 | } | |
6831 | ||
6832 | //_____________________________________________________________________________ | |
8ec526a4 | 6833 | TGraphErrors *AliTRDCalibra::ConvertVectorPHisto(AliTRDPInfo *pInfo |
6834 | , const Char_t *name) const | |
77566f2a | 6835 | { |
6836 | // | |
8ec526a4 | 6837 | // Convert the PInfo in a 1D grapherror, name must contains "PRF" |
6838 | // if PRF calibration and not "PRF" for Vdrift calibration | |
77566f2a | 6839 | // |
6840 | ||
6841 | TGraphErrors *histo; | |
8ec526a4 | 6842 | const Char_t *pattern1 = "PRF"; |
77566f2a | 6843 | |
8ec526a4 | 6844 | // Axis |
77566f2a | 6845 | Double_t *x; |
6846 | Double_t *y; | |
6847 | Double_t *ex; | |
6848 | Double_t *ey; | |
6849 | Double_t step = 0.0; | |
8ec526a4 | 6850 | Double_t min = 0.0; |
77566f2a | 6851 | |
8ec526a4 | 6852 | // Ntimes |
6853 | Int_t ntimes = 0; | |
6854 | if (strstr(name,pattern1)) { | |
6855 | ntimes = fNumberBinPRF; | |
6856 | } | |
6857 | else { | |
6858 | ntimes = fTimeMax; | |
6859 | } | |
6860 | x = new Double_t[ntimes]; // Xaxis | |
6861 | y = new Double_t[ntimes]; // Mean | |
6862 | ex = new Double_t[ntimes]; // Nentries | |
6863 | ey = new Double_t[ntimes]; // Sum of square/nentries | |
77566f2a | 6864 | |
8ec526a4 | 6865 | // Init histo |
6866 | if (!strstr(name,pattern1)) { | |
6867 | step = 1.0 / fSf; | |
6868 | min = 0.0; | |
77566f2a | 6869 | } |
6870 | else { | |
8ec526a4 | 6871 | step = (1.0 - (-1.0)) / fNumberBinPRF; |
6872 | min = -1.0 + step / 2.0; | |
77566f2a | 6873 | } |
6874 | ||
8ec526a4 | 6875 | // Fill histo |
6876 | for (Int_t k = 0; k < ntimes; k++) { | |
6877 | x[k] = min + k*step; | |
6878 | y[k] = 0.0; | |
77566f2a | 6879 | ex[k] = 0.0; |
6880 | ey[k] = 0.0; | |
8ec526a4 | 6881 | // Fill only if there is more than 0 something |
6882 | if (pInfo->GetEntries()[k] > 0) { | |
6883 | ex[k] = pInfo->GetEntries()[k]; | |
6884 | y[k] = pInfo->GetSum()[k]; | |
6885 | ey[k] = pInfo->GetSumSquare()[k]; | |
77566f2a | 6886 | } |
77566f2a | 6887 | } |
6888 | ||
8ec526a4 | 6889 | // Define the TGraphErrors |
6890 | histo = new TGraphErrors(ntimes,x,y,ex,ey); | |
77566f2a | 6891 | histo->SetTitle(name); |
6892 | return histo; | |
6893 | ||
77566f2a | 6894 | } |
6895 | ||
77566f2a | 6896 | //_____________________________________________________________________________ |
8ec526a4 | 6897 | TH1F *AliTRDCalibra::ConvertVectorCTHisto(AliTRDCTInfo *cTInfo |
6898 | , const Char_t * name) const | |
77566f2a | 6899 | { |
6900 | // | |
6901 | // Convert the CTInfo in a 1D histo | |
6902 | // | |
6903 | ||
6904 | TH1F *histo; | |
6905 | ||
8ec526a4 | 6906 | Int_t ntimes = fNumberBinCharge; |
6907 | UShort_t *entries = cTInfo->GetEntries(); | |
77566f2a | 6908 | |
8ec526a4 | 6909 | // Init histo |
77566f2a | 6910 | histo = new TH1F(name,name,fNumberBinCharge,0,300); |
6911 | histo->Sumw2(); | |
8ec526a4 | 6912 | // Fill histo |
6913 | for (Int_t k = 0; k < ntimes; k++) { | |
6914 | histo->SetBinContent(k+1,entries[k]); | |
6915 | histo->SetBinError(k+1,TMath::Sqrt(TMath::Abs(entries[k]))); | |
77566f2a | 6916 | } |
8ec526a4 | 6917 | |
77566f2a | 6918 | return histo; |
6919 | ||
77566f2a | 6920 | } |
8ec526a4 | 6921 | |
77566f2a | 6922 | //_____________________________________________________________________________ |
8ec526a4 | 6923 | TTree *AliTRDCalibra::ConvertVectorCTTreeHisto(TObjArray *vVectorCT |
6924 | , TObjArray *pPlaCT | |
6925 | , const Char_t *name | |
6926 | , const Char_t *nametitle) const | |
77566f2a | 6927 | { |
6928 | // | |
8ec526a4 | 6929 | // Convert the vector in a tree with two branchs: the group number |
6930 | // and the TH1F histo reconstructed from the vector | |
77566f2a | 6931 | // |
6932 | ||
8ec526a4 | 6933 | // Size of the things |
6934 | Int_t ntotal = (Int_t) pPlaCT->GetEntriesFast(); | |
6935 | if (ntotal == 0) { | |
77566f2a | 6936 | AliInfo("nothing to write!"); |
8ec526a4 | 6937 | TTree *treeCT = new TTree(name,nametitle); |
6938 | return treeCT; | |
77566f2a | 6939 | } |
77566f2a | 6940 | |
8ec526a4 | 6941 | // Variable of the tree |
6942 | Int_t groupnumber = -1; // Group calibration | |
6943 | TH1F *histo = 0x0; | |
6944 | TObjArray vectorCT = *vVectorCT; | |
6945 | TObjArray plaCT = *pPlaCT; | |
77566f2a | 6946 | |
8ec526a4 | 6947 | // Init the tree |
6948 | TTree *treeCT = new TTree(name,nametitle); | |
6949 | treeCT->Branch("groupnumber",&groupnumber,"groupnumber/I"); | |
6950 | treeCT->Branch("histo","TH1F",&histo,32000,0); | |
6951 | ||
6952 | // Fill | |
77566f2a | 6953 | Int_t k = 0; |
8ec526a4 | 6954 | while (k < ntotal) { |
77566f2a | 6955 | TString nome(name); |
8ec526a4 | 6956 | groupnumber = ((AliTRDPlace *) plaCT.At(0))->GetPlace(); |
6957 | nome += groupnumber; | |
6958 | histo = ConvertVectorCTHisto(((AliTRDCTInfo *) vectorCT.At(0)),nome); | |
6959 | treeCT->Fill(); | |
6960 | vectorCT.RemoveAt(0); | |
6961 | vectorCT.Compress(); | |
6962 | plaCT.RemoveAt(0); | |
6963 | plaCT.Compress(); | |
77566f2a | 6964 | k++; |
77566f2a | 6965 | } |
6966 | ||
8ec526a4 | 6967 | return treeCT; |
77566f2a | 6968 | |
6969 | } | |
6970 | ||
6971 | //_____________________________________________________________________________ | |
8ec526a4 | 6972 | TTree *AliTRDCalibra::ConvertVectorPTreeHisto(TObjArray *vVectorP |
6973 | , TObjArray *pPlaP | |
6974 | , const Char_t *name | |
6975 | , const Char_t *nametitle) const | |
77566f2a | 6976 | { |
6977 | // | |
8ec526a4 | 6978 | // Convert the vector in a tree with two branchs: the group number |
6979 | // and the TGraphErrors histo reconstructed from the vector. | |
6980 | // The name must contain "PRF" for PRF calibration and not "PRF" | |
6981 | // for Vdrift calibration | |
77566f2a | 6982 | // |
6983 | ||
8ec526a4 | 6984 | // Size of the things |
6985 | Int_t ntotal = (Int_t) pPlaP->GetEntriesFast(); | |
6986 | if (ntotal == 0) { | |
77566f2a | 6987 | AliInfo("nothing to write!"); |
8ec526a4 | 6988 | TTree *treeP = new TTree(name,nametitle); |
6989 | return treeP; | |
77566f2a | 6990 | } |
6991 | ||
8ec526a4 | 6992 | // Variable of the tree |
6993 | Int_t groupnumber = -1; // Group calibration | |
6994 | TGraphErrors *histo = 0x0; | |
6995 | TObjArray vectorP = *vVectorP; | |
6996 | TObjArray plaP = *pPlaP; | |
77566f2a | 6997 | |
8ec526a4 | 6998 | // Init the tree |
6999 | TTree *treeP = new TTree(name,nametitle); | |
7000 | treeP->Branch("groupnumber",&groupnumber,"groupnumber/I"); | |
7001 | treeP->Branch("histo","TGraphErrors",&histo,32000,0); | |
77566f2a | 7002 | |
8ec526a4 | 7003 | // Fill |
77566f2a | 7004 | Int_t k = 0; |
8ec526a4 | 7005 | while (k < ntotal) { |
77566f2a | 7006 | TString nome(name); |
8ec526a4 | 7007 | groupnumber = ((AliTRDPlace *) plaP.At(0))->GetPlace(); |
7008 | nome += groupnumber; | |
7009 | histo = ConvertVectorPHisto((AliTRDPInfo *) vectorP.At(0),nome); | |
7010 | treeP->Fill(); | |
7011 | vectorP.RemoveAt(0); | |
7012 | vectorP.Compress(); | |
7013 | plaP.RemoveAt(0); | |
7014 | plaP.Compress(); | |
77566f2a | 7015 | k++; |
77566f2a | 7016 | } |
7017 | ||
8ec526a4 | 7018 | return treeP; |
77566f2a | 7019 | |
7020 | } | |
7021 | ||
7022 | //_____________________________________________________________________________ | |
8ec526a4 | 7023 | TObjArray *AliTRDCalibra::ConvertTreeVector(TTree *tree) const |
77566f2a | 7024 | { |
7025 | // | |
8ec526a4 | 7026 | // Convert the branch groupnumber of the tree taken from |
7027 | // TRD.calibration.root in case of vector method in a std::vector | |
7028 | // to be faster | |
77566f2a | 7029 | // |
7030 | ||
8ec526a4 | 7031 | // Initialise |
7032 | TObjArray *vectorplace = new TObjArray(); | |
77566f2a | 7033 | |
8ec526a4 | 7034 | // Variable of the tree |
7035 | Int_t groupnumber = -1; // Group calibration | |
77566f2a | 7036 | |
8ec526a4 | 7037 | // Set the branch |
77566f2a | 7038 | tree->SetBranchAddress("groupnumber",&groupnumber); |
8ec526a4 | 7039 | |
7040 | // Fill | |
7041 | Int_t ntotal = tree->GetEntries(); | |
7042 | for (Int_t k = 0; k < ntotal; k++) { | |
77566f2a | 7043 | tree->GetEntry(k); |
8ec526a4 | 7044 | AliTRDPlace *placegroupnumber = new AliTRDPlace(); |
7045 | placegroupnumber->SetPlace(groupnumber); | |
7046 | vectorplace->Add((TObject *) placegroupnumber); | |
7047 | } | |
7048 | ||
77566f2a | 7049 | return vectorplace; |
7050 | ||
7051 | } | |
7052 | ||
7053 | //_____________________________________________________________________________ | |
8ec526a4 | 7054 | Bool_t AliTRDCalibra::MergeVectorCT(TObjArray *vVectorCT2, TObjArray *pPlaCT2) |
77566f2a | 7055 | { |
7056 | // | |
7057 | // Add the two vectors and place the result in the first | |
7058 | // | |
7059 | ||
8ec526a4 | 7060 | if (((Int_t) pPlaCT2->GetEntriesFast()) != ((Int_t) vVectorCT2->GetEntriesFast())){ |
77566f2a | 7061 | AliInfo("VectorCT2 doesn't correspond to PlaCT2!"); |
7062 | return kFALSE; | |
7063 | } | |
77566f2a | 7064 | |
8ec526a4 | 7065 | // CH case |
7066 | for (Int_t k = 0; k < (Int_t) fPlaCH->GetEntriesFast(); k++) { | |
77566f2a | 7067 | |
8ec526a4 | 7068 | // Look if PlaCT1[k] it is also in the second vector |
77566f2a | 7069 | Int_t place = -1; |
8ec526a4 | 7070 | for (Int_t j = 0; j < (Int_t) pPlaCT2->GetEntriesFast(); j++) { |
7071 | if (((AliTRDPlace *) pPlaCT2->At(j))->GetPlace() == | |
7072 | ((AliTRDPlace *) fPlaCH->At(k))->GetPlace()) { | |
77566f2a | 7073 | place = j; |
7074 | break; | |
7075 | } | |
7076 | } | |
7077 | ||
8ec526a4 | 7078 | // If not in the second vector nothing to do |
7079 | ||
7080 | // If in the second vector | |
7081 | if (place != -1) { | |
77566f2a | 7082 | |
8ec526a4 | 7083 | AliTRDCTInfo *fCTInfo = new AliTRDCTInfo(); |
7084 | UShort_t *entries = new UShort_t[fNumberBinCharge]; | |
77566f2a | 7085 | |
8ec526a4 | 7086 | for (Int_t nu = 0; nu < fNumberBinCharge; nu++) { |
7087 | entries[nu] = ((AliTRDCTInfo *) fVectorCH->At(((AliTRDPlace *) fPlaCH->At(k))->GetPlace()))->GetEntries()[nu] | |
7088 | + ((AliTRDCTInfo *) vVectorCT2->At(((AliTRDPlace *) fPlaCH->At(k))->GetPlace()))->GetEntries()[nu]; | |
77566f2a | 7089 | } |
7090 | ||
8ec526a4 | 7091 | // Set |
7092 | fCTInfo->SetEntries(entries); | |
7093 | ||
7094 | // Nothing to do on PlaCT1 | |
77566f2a | 7095 | |
8ec526a4 | 7096 | // Update the vector |
7097 | fVectorCH->AddAt((TObject *) fCTInfo,((AliTRDPlace *) fPlaCH->At(k))->GetPlace()); | |
7098 | ||
77566f2a | 7099 | } |
7100 | ||
8ec526a4 | 7101 | } |
7102 | ||
7103 | // And at the end the vector in CT2 but not in CH1 | |
7104 | for (Int_t k = 0; k < (Int_t) pPlaCT2->GetEntriesFast(); k++) { | |
77566f2a | 7105 | |
8ec526a4 | 7106 | // Look if pPlaCT2[k] it is also in the second vector |
77566f2a | 7107 | Int_t place = -1; |
8ec526a4 | 7108 | for (Int_t j = 0; j < (Int_t) fPlaCH->GetEntriesFast(); j++) { |
7109 | if (((AliTRDPlace *) fPlaCH->At(j))->GetPlace() == ((AliTRDPlace *) pPlaCT2->At(k))->GetPlace()) { | |
77566f2a | 7110 | place = j; |
7111 | break; | |
7112 | } | |
7113 | } | |
8ec526a4 | 7114 | |
7115 | // If not in the first vector | |
7116 | if (place == -1) { | |
77566f2a | 7117 | |
8ec526a4 | 7118 | AliTRDCTInfo *fCTInfo = new AliTRDCTInfo(); |
7119 | fCTInfo = ((AliTRDCTInfo *) vVectorCT2->At(((AliTRDPlace *) pPlaCT2->At(k))->GetPlace())); | |
77566f2a | 7120 | |
8ec526a4 | 7121 | // Add at the end |
7122 | fPlaCH->Add((TObject *) (pPlaCT2->At(k))); | |
7123 | fVectorCH->Add((TObject *) fCTInfo); | |
7124 | ||
77566f2a | 7125 | } |
7126 | ||
7127 | } | |
77566f2a | 7128 | |
7129 | return kTRUE; | |
7130 | ||
77566f2a | 7131 | } |
7132 | ||
7133 | //_____________________________________________________________________________ | |
8ec526a4 | 7134 | Bool_t AliTRDCalibra::MergeVectorP(TObjArray *vVectorP2 |
7135 | , TObjArray *pPlaP2 | |
7136 | , Int_t i) | |
77566f2a | 7137 | { |
7138 | // | |
7139 | // Add the two vectors and place the result in the first | |
7140 | // | |
77566f2a | 7141 | |
8ec526a4 | 7142 | if (((Int_t) pPlaP2->GetEntriesFast()) != ((Int_t) vVectorP2->GetEntriesFast())) { |
7143 | AliInfo("VectorP2 doesn't correspond to PlaP2!"); | |
7144 | return kFALSE; | |
7145 | } | |
7146 | ||
7147 | // PH case | |
7148 | if (i == 1) { | |
77566f2a | 7149 | |
8ec526a4 | 7150 | for (Int_t k = 0; k < (Int_t) fPlaPH->GetEntriesFast(); k++) { |
77566f2a | 7151 | |
8ec526a4 | 7152 | // Look if fPlaPH[k] it is also in the second vector |
77566f2a | 7153 | Int_t place = -1; |
8ec526a4 | 7154 | for (Int_t j = 0; j < (Int_t) pPlaP2->GetEntriesFast(); j++) { |
7155 | if (((AliTRDPlace *) pPlaP2->At(j))->GetPlace() == ((AliTRDPlace *) fPlaPH->At(k))->GetPlace()) { | |
77566f2a | 7156 | place = j; |
7157 | break; | |
7158 | } | |
7159 | } | |
7160 | ||
8ec526a4 | 7161 | // If not in the second vector nothing to do |
7162 | ||
7163 | // If in the second vector | |
7164 | if (place != -1) { | |
7165 | ||
7166 | AliTRDPInfo *fPInfo = new AliTRDPInfo(); | |
7167 | UShort_t *entries = new UShort_t[fTimeMax]; | |
7168 | Float_t *sum = new Float_t[fTimeMax]; | |
7169 | Float_t *sumsquare = new Float_t[fTimeMax]; | |
7170 | ||
7171 | for (Int_t nu = 0; nu < fTimeMax; nu++) { | |
77566f2a | 7172 | |
8ec526a4 | 7173 | entries[nu] = ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu] |
7174 | + ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]; | |
77566f2a | 7175 | |
8ec526a4 | 7176 | Double_t calcul = ((((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSum()[nu]) |
7177 | * ((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu])) | |
7178 | + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSum()[nu]) | |
7179 | * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]))) | |
7180 | / ((Double_t) fPInfo->GetEntries()[nu]); | |
7181 | ||
7182 | sum[nu] = (Float_t) calcul; | |
77566f2a | 7183 | |
8ec526a4 | 7184 | Double_t calculsquare = ((((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSumSquare()[nu]) |
7185 | * ((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu])) | |
7186 | + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSumSquare()[nu]) | |
7187 | * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]))) | |
7188 | / ((Double_t) fPInfo->GetEntries()[nu]); | |
77566f2a | 7189 | |
7190 | ||
8ec526a4 | 7191 | sumsquare[nu] = calculsquare; |
7192 | ||
77566f2a | 7193 | } |
8ec526a4 | 7194 | |
7195 | // Set | |
7196 | fPInfo->SetSum(sum); | |
7197 | fPInfo->SetSumSquare(sumsquare); | |
7198 | fPInfo->SetEntries(entries); | |
77566f2a | 7199 | |
8ec526a4 | 7200 | // Nothing to do on PlaCT1 |
77566f2a | 7201 | |
8ec526a4 | 7202 | // Update the vector VectorCT1 |
7203 | fVectorPH->AddAt((TObject *) fPInfo,((AliTRDPlace *) fPlaPH->At(k))->GetPlace()); | |
77566f2a | 7204 | |
7205 | } | |
8ec526a4 | 7206 | |
77566f2a | 7207 | } |
8ec526a4 | 7208 | |
7209 | // And at the end the vector in P2 but not in CH1 | |
7210 | for (Int_t k = 0; k < (Int_t) pPlaP2->GetEntriesFast(); k++) { | |
77566f2a | 7211 | |
8ec526a4 | 7212 | // Look if PlaCT2[k] it is also in the second vector |
77566f2a | 7213 | Int_t place = -1; |
8ec526a4 | 7214 | for (Int_t j = 0; j < (Int_t) fPlaPH->GetEntriesFast(); j++) { |
7215 | if (((AliTRDPlace *) fPlaPH->At(j))->GetPlace() == ((AliTRDPlace *) pPlaP2->At(k))->GetPlace()) { | |
77566f2a | 7216 | place = j; |
7217 | break; | |
7218 | } | |
7219 | } | |
7220 | ||
8ec526a4 | 7221 | // If not in the first vector |
7222 | if (place == -1) { | |
77566f2a | 7223 | |
8ec526a4 | 7224 | AliTRDPInfo *fPInfo = new AliTRDPInfo(); |
7225 | fPInfo = (AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) pPlaP2->At(k))->GetPlace()); | |
77566f2a | 7226 | |
8ec526a4 | 7227 | // Add at the end of CH1 |
7228 | fPlaPH->Add(((TObject *) pPlaP2->At(k))); | |
7229 | fVectorPH->Add((TObject *) fPInfo); | |
7230 | ||
77566f2a | 7231 | } |
8ec526a4 | 7232 | |
77566f2a | 7233 | } |
8ec526a4 | 7234 | |
77566f2a | 7235 | } |
7236 | ||
7237 | ||
8ec526a4 | 7238 | // PRF case |
7239 | if (i == 1) { | |
7240 | ||
7241 | for (Int_t k = 0; k < (Int_t) fPlaPRF->GetEntriesFast(); k++) { | |
77566f2a | 7242 | |
8ec526a4 | 7243 | // Look if fPlaPRF[k] it is also in the second vector |
77566f2a | 7244 | Int_t place = -1; |
8ec526a4 | 7245 | for (Int_t j = 0; j < (Int_t) pPlaP2->GetEntriesFast(); j++) { |
7246 | if (((AliTRDPlace *) pPlaP2->At(j))->GetPlace() == ((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()) { | |
77566f2a | 7247 | place = j; |
7248 | break; | |
7249 | } | |
7250 | } | |
8ec526a4 | 7251 | |
7252 | // If not in the second vector nothing to do | |
7253 | ||
7254 | // If in the second vector | |
7255 | if (place != -1) { | |
77566f2a | 7256 | |
8ec526a4 | 7257 | AliTRDPInfo *fPInfo = new AliTRDPInfo(); |
7258 | UShort_t *entries = new UShort_t[fNumberBinPRF]; | |
7259 | Float_t *sum = new Float_t[fNumberBinPRF]; | |
7260 | Float_t *sumsquare = new Float_t[fNumberBinPRF]; | |
7261 | ||
7262 | for (Int_t nu = 0; nu < fNumberBinPRF; nu++) { | |
77566f2a | 7263 | |
8ec526a4 | 7264 | entries[nu] = ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu] |
7265 | + ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]; | |
77566f2a | 7266 | |
8ec526a4 | 7267 | Double_t calcul = ((((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSum()[nu]) |
7268 | * ((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu])) | |
7269 | + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSum()[nu]) | |
7270 | * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]))) | |
7271 | / ((Double_t) fPInfo->GetEntries()[nu]); | |
7272 | ||
7273 | sum[nu] = (Float_t) calcul; | |
77566f2a | 7274 | |
8ec526a4 | 7275 | Double_t calculsquare = ((((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSumSquare()[nu]) |
7276 | * ((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu])) | |
7277 | + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSumSquare()[nu]) | |
7278 | * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]))) | |
7279 | / ((Double_t) fPInfo->GetEntries()[nu]); | |
7280 | ||
7281 | sumsquare[nu] = calculsquare; | |
7282 | ||
77566f2a | 7283 | } |
8ec526a4 | 7284 | |
7285 | // Set | |
7286 | fPInfo->SetSum(sum); | |
7287 | fPInfo->SetSumSquare(sumsquare); | |
7288 | fPInfo->SetEntries(entries); | |
7289 | ||
7290 | // Nothing to do on PlaCT1 | |
77566f2a | 7291 | |
8ec526a4 | 7292 | // Update the vector VectorCT1 |
7293 | fVectorPRF->AddAt((TObject *) fPInfo,((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()); | |
77566f2a | 7294 | |
7295 | } | |
8ec526a4 | 7296 | |
77566f2a | 7297 | } |
8ec526a4 | 7298 | |
7299 | // And at the end the vector in P2 but not in CH1 | |
7300 | for (Int_t k = 0; k < (Int_t) pPlaP2->GetEntriesFast(); k++) { | |
77566f2a | 7301 | |
8ec526a4 | 7302 | // Look if PlaCT2[k] it is also in the second vector |
77566f2a | 7303 | Int_t place = -1; |
8ec526a4 | 7304 | for (Int_t j = 0; j < (Int_t) fPlaPRF->GetEntriesFast(); j++) { |
7305 | if (((AliTRDPlace *) fPlaPRF->At(j))->GetPlace() == ((AliTRDPlace *) pPlaP2->At(k))->GetPlace()) { | |
77566f2a | 7306 | place = j; |
7307 | break; | |
7308 | } | |
7309 | } | |
8ec526a4 | 7310 | |
7311 | // If not in the first vector | |
7312 | if (place == -1) { | |
7313 | ||
7314 | AliTRDPInfo *fPInfo = new AliTRDPInfo(); | |
7315 | fPInfo = (AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) pPlaP2->At(k))->GetPlace()); | |
7316 | ||
7317 | // Add at the end of CH1 | |
7318 | fPlaPRF->Add(((TObject *) pPlaP2->At(k))); | |
7319 | fVectorPRF->Add((TObject *) fPInfo); | |
7320 | ||
77566f2a | 7321 | } |
7322 | ||
7323 | } | |
8ec526a4 | 7324 | |
77566f2a | 7325 | } |
8ec526a4 | 7326 | |
77566f2a | 7327 | return kTRUE; |
8ec526a4 | 7328 | |
77566f2a | 7329 | } |
77566f2a | 7330 | |
8ec526a4 | 7331 | //____________Fit Methods______________________________________________________ |
7332 | ||
7333 | //_____________________________________________________________________________ | |
77566f2a | 7334 | void AliTRDCalibra::FitPente(TH1* projPH, Int_t idect) |
7335 | { | |
7336 | // | |
7337 | // Slope methode for the drift velocity | |
7338 | // | |
7339 | ||
8ec526a4 | 7340 | // Constants |
77566f2a | 7341 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); |
8ec526a4 | 7342 | Int_t binmax = 0; |
7343 | Int_t binmin = 0; | |
7344 | fPhd[0] = 0.0; | |
7345 | fPhd[1] = 0.0; | |
7346 | fPhd[2] = 0.0; | |
7347 | Int_t ju = 0; | |
77566f2a | 7348 | fVdriftCoef[1] = 0.0; |
8ec526a4 | 7349 | fT0Coef[1] = 0.0; |
77566f2a | 7350 | TLine *line = new TLine(); |
77566f2a | 7351 | |
8ec526a4 | 7352 | // Some variables |
7353 | TAxis *xpph = projPH->GetXaxis(); | |
7354 | Int_t nbins = xpph->GetNbins(); | |
7355 | Double_t lowedge = xpph->GetBinLowEdge(1); | |
7356 | Double_t upedge = xpph->GetBinUpEdge(xpph->GetNbins()); | |
7357 | Double_t widbins = (upedge - lowedge) / nbins; | |
7358 | Double_t limit = upedge + 0.5 * widbins; | |
7359 | ||
7360 | // Beginning of the signal | |
7361 | TH1D *pentea = new TH1D("pentea","pentea",projPH->GetNbinsX(),0,(Float_t) limit); | |
7362 | for (Int_t k = 1; k < projPH->GetNbinsX(); k++) { | |
7363 | pentea->SetBinContent(k,(Double_t) (projPH->GetBinContent(k+1) - projPH->GetBinContent(k))); | |
77566f2a | 7364 | } |
8ec526a4 | 7365 | |
7366 | binmax = (Int_t) pentea->GetMaximumBin(); | |
7367 | if (binmax == 1) { | |
77566f2a | 7368 | binmax = 2; |
7369 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
7370 | } | |
7371 | pentea->Fit("pol2","0MR","",TMath::Max(pentea->GetBinCenter(binmax-1),0.0),pentea->GetBinCenter(binmax+1)); | |
7372 | Float_t l3P1am = pentea->GetFunction("pol2")->GetParameter(1); | |
7373 | Float_t l3P2am = pentea->GetFunction("pol2")->GetParameter(2); | |
8ec526a4 | 7374 | if (l3P2am != 0) { |
7375 | fPhd[0] = -(l3P1am / (2 * l3P2am)); | |
7376 | } | |
77566f2a | 7377 | |
8ec526a4 | 7378 | // Amplification region |
77566f2a | 7379 | binmax = 0; |
8ec526a4 | 7380 | ju = 0; |
7381 | for (Int_t kbin = 1; kbin < projPH->GetNbinsX(); kbin ++) { | |
7382 | if (((projPH->GetBinContent(kbin+1) - projPH->GetBinContent(kbin)) <= 0.0) && (ju == 0)) { | |
77566f2a | 7383 | binmax = kbin; |
8ec526a4 | 7384 | ju = 1; |
77566f2a | 7385 | } |
7386 | } | |
8ec526a4 | 7387 | if (binmax == 1) { |
77566f2a | 7388 | binmax = 2; |
7389 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
7390 | } | |
7391 | projPH->Fit("pol2","0MR","",TMath::Max(projPH->GetBinCenter(binmax-1),0.0),projPH->GetBinCenter(binmax+1)); | |
7392 | Float_t l3P1amf = projPH->GetFunction("pol2")->GetParameter(1); | |
7393 | Float_t l3P2amf = projPH->GetFunction("pol2")->GetParameter(2); | |
7394 | ||
8ec526a4 | 7395 | if (l3P2amf != 0) { |
7396 | fPhd[1] = -(l3P1amf / (2 * l3P2amf)); | |
7397 | } | |
77566f2a | 7398 | |
8ec526a4 | 7399 | // Drift region |
7400 | TH1D *pente = new TH1D("pente","pente",projPH->GetNbinsX(),0,(Float_t) limit); | |
7401 | for (Int_t k = binmax+4; k < projPH->GetNbinsX(); k++) { | |
7402 | pente->SetBinContent(k,(Double_t) (projPH->GetBinContent(k+1) - projPH->GetBinContent(k))); | |
77566f2a | 7403 | } |
8ec526a4 | 7404 | binmin = (Int_t) pente->GetMinimumBin(); |
7405 | if (binmin == 1) { | |
77566f2a | 7406 | binmin = 2; |
7407 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
7408 | } | |
9244c78b | 7409 | pente->Fit("pol2" |
7410 | ,"0MR" | |
7411 | ,"" | |
7412 | ,TMath::Max(pente->GetBinCenter(binmin-1), 0.0) | |
7413 | ,TMath::Min(pente->GetBinCenter(binmin+2),(Double_t) limit)); | |
77566f2a | 7414 | Float_t l3P1dr = pente->GetFunction("pol2")->GetParameter(1); |
7415 | Float_t l3P2dr = pente->GetFunction("pol2")->GetParameter(2); | |
8ec526a4 | 7416 | if (l3P2dr != 0) { |
7417 | fPhd[2] = -(l3P1dr / (2 * l3P2dr)); | |
7418 | } | |
77566f2a | 7419 | |
8ec526a4 | 7420 | if ((fPhd[2] > fPhd[0]) && |
7421 | (fPhd[2] > fPhd[1]) && | |
7422 | (fPhd[1] > fPhd[0])) { | |
7423 | fVdriftCoef[1] = (kDrWidth) / (fPhd[2]-fPhd[1]); | |
7424 | if (fPhd[0] >= 0.0) { | |
9244c78b | 7425 | fT0Coef[1] = (fPhd[0] - fT0Shift) / widbins; |
7426 | if (fT0Coef[1] <= -1.0) { | |
7427 | fT0Coef[1] = - TMath::Abs(fT0Coef[2]); | |
7428 | } | |
8ec526a4 | 7429 | } |
7430 | else { | |
7431 | fT0Coef[1] = -TMath::Abs(fT0Coef[2]); | |
7432 | } | |
77566f2a | 7433 | } |
8ec526a4 | 7434 | else { |
77566f2a | 7435 | fVdriftCoef[1] = -TMath::Abs(fVdriftCoef[2]); |
8ec526a4 | 7436 | fT0Coef[1] = -TMath::Abs(fT0Coef[2]); |
77566f2a | 7437 | } |
77566f2a | 7438 | |
8ec526a4 | 7439 | if ((fDebug == 1) || |
7440 | (fDebug == 4)) { | |
77566f2a | 7441 | fCoefVdrift[1]->SetBinContent(idect+1,TMath::Abs(fVdriftCoef[1])); |
8ec526a4 | 7442 | fCoefT0[1]->SetBinContent(idect+1,fT0Coef[1]); |
7443 | if (fVdriftCoef[1] > 0.0) { | |
7444 | if (fVdriftCoef[2] != 0.0) { | |
7445 | fDeltaVdrift[1]->SetBinContent(idect+1,(fVdriftCoef[1] - fVdriftCoef[2]) / fVdriftCoef[2]); | |
7446 | } | |
7447 | fDeltaT0[1]->SetBinContent(idect+1,(fT0Coef[1] - fT0Coef[2])); | |
77566f2a | 7448 | } |
7449 | } | |
7450 | ||
8ec526a4 | 7451 | if (fDebug == 2) { |
77566f2a | 7452 | TCanvas *cpentei = new TCanvas("cpentei","cpentei",50,50,600,800); |
7453 | cpentei->cd(); | |
7454 | projPH->Draw(); | |
7455 | line->SetLineColor(2); | |
7456 | line->DrawLine(fPhd[0],0,fPhd[0],projPH->GetMaximum()); | |
7457 | line->DrawLine(fPhd[1],0,fPhd[1],projPH->GetMaximum()); | |
7458 | line->DrawLine(fPhd[2],0,fPhd[2],projPH->GetMaximum()); | |
8ec526a4 | 7459 | AliInfo(Form("fPhd[0] (beginning of the signal): %f" ,(Float_t) fPhd[0])); |
7460 | AliInfo(Form("fPhd[1] (end of the amplification region): %f" ,(Float_t) fPhd[1])); | |
7461 | AliInfo(Form("fPhd[2] (end of the drift region): %f" ,(Float_t) fPhd[2])); | |
7462 | AliInfo(Form("fVriftCoef[1] (with only the drift region(default)): %f",(Float_t) fVdriftCoef[1])); | |
77566f2a | 7463 | } |
8ec526a4 | 7464 | |
7465 | if (fDebug != 2) { | |
7466 | delete pentea; | |
7467 | } | |
7468 | if (fDebug != 2) { | |
7469 | delete pente; | |
7470 | } | |
7471 | ||
77566f2a | 7472 | } |
7473 | ||
8ec526a4 | 7474 | //_____________________________________________________________________________ |
77566f2a | 7475 | void AliTRDCalibra::FitPH(TH1* projPH, Int_t idect) |
7476 | { | |
7477 | // | |
7478 | // Fit methode for the drift velocity | |
7479 | // | |
7480 | ||
8ec526a4 | 7481 | // Constants |
7482 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); | |
7483 | ||
7484 | // Some variables | |
7485 | TAxis *xpph = projPH->GetXaxis(); | |
7486 | Double_t upedge = xpph->GetBinUpEdge(xpph->GetNbins()); | |
77566f2a | 7487 | |
8ec526a4 | 7488 | TF1 *fPH = new TF1("fPH",AliTRDCalibra::PH,-0.05,3.2,6); |
7489 | fPH->SetParameter(0,0.469); // Scaling | |
7490 | fPH->SetParameter(1,0.18); // Start | |
7491 | fPH->SetParameter(2,0.0857325); // AR | |
7492 | fPH->SetParameter(3,1.89); // DR | |
7493 | fPH->SetParameter(4,0.08); // QA/QD | |
7494 | fPH->SetParameter(5,0.0); // Baseline | |
77566f2a | 7495 | |
7496 | TLine *line = new TLine(); | |
7497 | ||
7498 | fVdriftCoef[0] = 0.0; | |
8ec526a4 | 7499 | fT0Coef[0] = 0.0; |
77566f2a | 7500 | |
8ec526a4 | 7501 | if (idect%fFitPHPeriode == 0) { |
7502 | ||
7503 | AliInfo(Form("<AliTRDCalibra::FitPH> The detector %d will be fitted",idect)); | |
7504 | fPH->SetParameter(0,(projPH->Integral()-(projPH->GetBinContent(1)*projPH->GetNbinsX())) * 0.00028); // Scaling | |
7505 | fPH->SetParameter(1,fPhd[0] - 0.1); // Start | |
7506 | fPH->SetParameter(2,fPhd[1] - fPhd[0]); // AR | |
7507 | fPH->SetParameter(3,fPhd[2] - fPhd[1]); // DR | |
7508 | fPH->SetParameter(4,0.225); // QA/QD | |
77566f2a | 7509 | fPH->SetParameter(5,(Float_t) projPH->GetBinContent(1)); |
7510 | ||
8ec526a4 | 7511 | if (fDebug != 2) { |
7512 | projPH->Fit(fPH,"0M","",0.0,upedge); | |
77566f2a | 7513 | } |
7514 | ||
8ec526a4 | 7515 | if (fDebug == 2) { |
77566f2a | 7516 | TCanvas *cpente = new TCanvas("cpente","cpente",50,50,600,800); |
7517 | cpente->cd(); | |
8ec526a4 | 7518 | projPH->Fit(fPH,"M+","",0.0,upedge); |
77566f2a | 7519 | projPH->Draw("E0"); |
7520 | line->SetLineColor(4); | |
8ec526a4 | 7521 | line->DrawLine(fPH->GetParameter(1) |
7522 | ,0 | |
7523 | ,fPH->GetParameter(1) | |
7524 | ,projPH->GetMaximum()); | |
7525 | line->DrawLine(fPH->GetParameter(1)+fPH->GetParameter(2) | |
7526 | ,0 | |
7527 | ,fPH->GetParameter(1)+fPH->GetParameter(2) | |
7528 | ,projPH->GetMaximum()); | |
7529 | line->DrawLine(fPH->GetParameter(1)+fPH->GetParameter(2)+fPH->GetParameter(3) | |
7530 | ,0 | |
7531 | ,fPH->GetParameter(1)+fPH->GetParameter(2)+fPH->GetParameter(3) | |
7532 | ,projPH->GetMaximum()); | |
7533 | } | |
7534 | ||
7535 | if (fPH->GetParameter(3) != 0) { | |
7536 | fVdriftCoef[0] = kDrWidth / (fPH->GetParameter(3)); | |
7537 | fT0Coef[0] = fPH->GetParameter(1); | |
77566f2a | 7538 | } |
7539 | else { | |
7540 | fVdriftCoef[0] = -TMath::Abs(fVdriftCoef[2]); | |
8ec526a4 | 7541 | fT0Coef[0] = -TMath::Abs(fT0Coef[2]); |
77566f2a | 7542 | } |
8ec526a4 | 7543 | |
7544 | if ((fDebug == 1) || | |
7545 | (fDebug == 4)) { | |
77566f2a | 7546 | fCoefVdrift[0]->SetBinContent(idect+1,TMath::Abs(fVdriftCoef[0])); |
7547 | fCoefT0[0]->SetBinContent(idect+1,TMath::Abs(fT0Coef[0])); | |
8ec526a4 | 7548 | if (fVdriftCoef[0] > 0.0){ |
7549 | if (fVdriftCoef[2] != 0.0) { | |
7550 | fDeltaVdrift[0]->SetBinContent(idect+1,(fVdriftCoef[0]-fVdriftCoef[2])/fVdriftCoef[2]); | |
7551 | } | |
77566f2a | 7552 | fDeltaT0[0]->SetBinContent(idect+1,(fT0Coef[0]-fT0Coef[2])); |
7553 | } | |
7554 | } | |
8ec526a4 | 7555 | if (fDebug == 2) { |
7556 | AliInfo(Form("fVdriftCoef[0]: %f",(Float_t) fVdriftCoef[0])); | |
77566f2a | 7557 | } |
8ec526a4 | 7558 | |
77566f2a | 7559 | } |
7560 | ||
8ec526a4 | 7561 | else { |
7562 | ||
7563 | // Put the default value | |
7564 | if ((fDebug <= 1) || | |
e3cd8b1a | 7565 | (fDebug == 4)) { |
77566f2a | 7566 | fCoefVdrift[0]->SetBinContent(idect+1,fVdriftCoef[2]); |
7567 | fCoefT0[0]->SetBinContent(idect+1,fT0Coef[2]); | |
7568 | } | |
7569 | ||
7570 | } | |
7571 | ||
8ec526a4 | 7572 | if (fDebug != 2) { |
7573 | delete fPH; | |
7574 | } | |
77566f2a | 7575 | |
7576 | } | |
8ec526a4 | 7577 | |
7578 | //_____________________________________________________________________________ | |
7579 | void AliTRDCalibra::FitPRF(TH1 *projPRF, Int_t idect) | |
77566f2a | 7580 | { |
7581 | // | |
7582 | // Fit methode for the sigma of the pad response function | |
7583 | // | |
7584 | ||
7585 | fPRFCoef[0] = 0.0; | |
7586 | ||
8ec526a4 | 7587 | if (fDebug != 2) { |
7588 | projPRF->Fit("gaus","0M","",-fRangeFitPRF,fRangeFitPRF); | |
77566f2a | 7589 | } |
7590 | ||
8ec526a4 | 7591 | if (fDebug == 2) { |
77566f2a | 7592 | TCanvas *cfit = new TCanvas("cfit","cfit",50,50,600,800); |
7593 | cfit->cd(); | |
8ec526a4 | 7594 | projPRF->Fit("gaus","M+","",-fRangeFitPRF,fRangeFitPRF); |
77566f2a | 7595 | projPRF->Draw(); |
77566f2a | 7596 | } |
8ec526a4 | 7597 | |
77566f2a | 7598 | fPRFCoef[0] = projPRF->GetFunction("gaus")->GetParameter(2); |
77566f2a | 7599 | |
8ec526a4 | 7600 | if ((fDebug == 1) || |
7601 | (fDebug == 4)) { | |
77566f2a | 7602 | fCoefPRF[0]->SetBinContent(idect+1,fPRFCoef[0]); |
8ec526a4 | 7603 | if (fPRFCoef[1] != 0.0) { |
77566f2a | 7604 | fDeltaPRF->SetBinContent(idect+1,(fPRFCoef[0]-fPRFCoef[1])/fPRFCoef[1]); |
7605 | } | |
7606 | } | |
8ec526a4 | 7607 | if (fDebug == 2) { |
7608 | AliInfo(Form("fPRFCoef[0]: %f",(Float_t) fPRFCoef[0])); | |
77566f2a | 7609 | } |
7610 | ||
7611 | } | |
8ec526a4 | 7612 | |
7613 | //_____________________________________________________________________________ | |
7614 | void AliTRDCalibra::FitCH(TH1 *projch, Int_t idect) | |
77566f2a | 7615 | { |
7616 | // | |
7617 | // Fit methode for the gain factor | |
7618 | // | |
7619 | ||
7620 | fChargeCoef[0] = 0.0; | |
7621 | fChargeCoef[1] = 0.0; | |
8ec526a4 | 7622 | TF1 *fLandauGaus = new TF1("fLandauGaus",FuncLandauGaus,0,300,5); |
77566f2a | 7623 | |
7624 | fChargeCoef[1] = projch->GetMean(); | |
8ec526a4 | 7625 | projch->Fit("landau","0","" |
7626 | ,(Float_t) fChargeCoef[1]/fBeginFitCharge | |
7627 | ,projch->GetBinCenter(projch->GetNbinsX())); | |
7628 | fL3P0 = projch->GetFunction("landau")->GetParameter(0); | |
77566f2a | 7629 | Double_t l3P1 = projch->GetFunction("landau")->GetParameter(1); |
8ec526a4 | 7630 | fL3P2 = projch->GetFunction("landau")->GetParameter(2); |
77566f2a | 7631 | |
8ec526a4 | 7632 | projch->Fit("gaus","0","" |
7633 | ,(Float_t) fChargeCoef[1]/fBeginFitCharge | |
7634 | ,projch->GetBinCenter(projch->GetNbinsX())); | |
77566f2a | 7635 | Double_t g3P0 = projch->GetFunction("gaus")->GetParameter(0); |
8ec526a4 | 7636 | fG3P2 = projch->GetFunction("gaus")->GetParameter(2); |
77566f2a | 7637 | |
8ec526a4 | 7638 | fLandauGaus->SetParameters(fL3P0,l3P1,fL3P2,g3P0,fG3P2); |
7639 | if ((fDebug <= 1) || | |
7640 | (fDebug >= 3)) { | |
7641 | projch->Fit("fLandauGaus","0","" | |
7642 | ,(Float_t) fChargeCoef[1]/fBeginFitCharge | |
7643 | ,projch->GetBinCenter(projch->GetNbinsX())); | |
77566f2a | 7644 | } |
8ec526a4 | 7645 | |
7646 | if (fDebug == 2) { | |
77566f2a | 7647 | TCanvas *cp = new TCanvas("cp","cp",50,50,600,800); |
7648 | cp->cd(); | |
8ec526a4 | 7649 | projch->Fit("fLandauGaus","+","" |
7650 | ,(Float_t) fChargeCoef[1]/fBeginFitCharge | |
7651 | ,projch->GetBinCenter(projch->GetNbinsX())); | |
77566f2a | 7652 | projch->Draw(); |
7653 | fLandauGaus->Draw("same"); | |
7654 | } | |
7655 | ||
8ec526a4 | 7656 | if (projch->GetFunction("fLandauGaus")->GetParameter(1) > 0) { |
7657 | // Calcul of "real" coef | |
7658 | CalculChargeCoefMean(fCountDet[0],(Int_t) idect,kTRUE); | |
7659 | fChargeCoef[0] = projch->GetFunction("fLandauGaus")->GetParameter(1); | |
7660 | } | |
77566f2a | 7661 | else { |
8ec526a4 | 7662 | // Calcul of "real" coef |
7663 | CalculChargeCoefMean(fCountDet[0],(Int_t) idect,kFALSE); | |
77566f2a | 7664 | fChargeCoef[0] = -TMath::Abs(fChargeCoef[3]); |
7665 | } | |
8ec526a4 | 7666 | |
7667 | if (fDebug == 2) { | |
7668 | AliInfo(Form("fChargeCoef[0]: %f",(Float_t) fChargeCoef[0])); | |
77566f2a | 7669 | AliInfo(Form("fChargeCoef[1]: %f",(Float_t) fChargeCoef[1])); |
7670 | } | |
7671 | ||
8ec526a4 | 7672 | if ((fDebug == 1) || |
7673 | (fDebug == 4)) { | |
7674 | if (fChargeCoef[0] > 0.0) { | |
77566f2a | 7675 | fCoefCharge[0]->SetBinContent(idect+1,fChargeCoef[0]); |
7676 | fCoefCharge[1]->SetBinContent(idect+1,fChargeCoef[1]); | |
7677 | fDeltaCharge[0]->SetBinContent(idect+1,fChargeCoef[0]); | |
7678 | fDeltaCharge[1]->SetBinContent(idect+1,fChargeCoef[1]); | |
7679 | } | |
7680 | } | |
8ec526a4 | 7681 | fL3P0 = fLandauGaus->Integral(0.3*projch->GetMean(),3*projch->GetMean()); |
7682 | fG3P2 = fLandauGaus->GetParameter(2); | |
7683 | fL3P2 = fLandauGaus->GetParameter(4); | |
77566f2a | 7684 | |
8ec526a4 | 7685 | if (fDebug != 2) { |
7686 | delete fLandauGaus; | |
7687 | } | |
7688 | ||
77566f2a | 7689 | } |
8ec526a4 | 7690 | |
7691 | //_____________________________________________________________________________ | |
7692 | void AliTRDCalibra::FitBisCH(TH1* projch, Int_t idect) | |
77566f2a | 7693 | { |
7694 | // | |
7695 | // Fit methode for the gain factor more time consuming | |
7696 | // | |
77566f2a | 7697 | |
77566f2a | 7698 | // Setting fit range and start values |
7699 | Double_t fr[2]; | |
8ec526a4 | 7700 | //Double_t sv[4] = { l3P2, fChargeCoef[1], projch->Integral("width"), fG3P2 }; |
7701 | Double_t sv[4] = { fL3P2, fChargeCoef[1], fL3P0, fG3P2 }; | |
7702 | Double_t pllo[4] = { 0.001, 0.001, 0.001, 0.001 }; | |
7703 | Double_t plhi[4] = { 300.0, 300.0, 100000000.0, 300.0 }; | |
7704 | Double_t fp[4] = { 1.0, 1.0, 1.0, 1.0 }; | |
7705 | Double_t fpe[4] = { 1.0, 1.0, 1.0, 1.0 }; | |
7706 | fr[0] = 0.3 * projch->GetMean(); | |
7707 | fr[1] = 3.0 * projch->GetMean(); | |
7708 | fChargeCoef[2] = 0.0; | |
7709 | ||
77566f2a | 7710 | Double_t chisqr; |
7711 | Int_t ndf; | |
8ec526a4 | 7712 | TF1 *fitsnr = LanGauFit(projch,&fr[0],&sv[0] |
7713 | ,&pllo[0],&plhi[0] | |
7714 | ,&fp[0],&fpe[0] | |
7715 | ,&chisqr,&ndf); | |
77566f2a | 7716 | |
8ec526a4 | 7717 | Double_t projchPeak; |
7718 | Double_t projchFWHM; | |
7719 | LanGauPro(fp,projchPeak,projchFWHM); | |
7720 | ||
7721 | if (fp[1] > 0) { | |
7722 | fChargeCoef[2] = fp[1]; | |
7723 | } | |
7724 | else { | |
7725 | fChargeCoef[2] = -TMath::Abs(fChargeCoef[3]); | |
7726 | } | |
77566f2a | 7727 | |
8ec526a4 | 7728 | if (fDebug == 2) { |
7729 | AliInfo(Form("fChargeCoef[2]: %f",(Float_t) fChargeCoef[2])); | |
77566f2a | 7730 | TCanvas *cpy = new TCanvas("cpy","cpy",50,50,600,800); |
7731 | cpy->cd(); | |
7732 | projch->Draw(); | |
7733 | fitsnr->Draw("same"); | |
7734 | } | |
8ec526a4 | 7735 | |
7736 | if ((fDebug == 1) || | |
7737 | (fDebug == 4)) { | |
7738 | if (fChargeCoef[2] > 0.0) { | |
77566f2a | 7739 | fCoefCharge[2]->SetBinContent(idect+1,fChargeCoef[2]); |
7740 | fDeltaCharge[2]->SetBinContent(idect+1,fChargeCoef[2]); | |
7741 | } | |
7742 | } | |
8ec526a4 | 7743 | |
7744 | if (fDebug != 2) { | |
7745 | delete fitsnr; | |
7746 | } | |
7747 | ||
77566f2a | 7748 | } |
8ec526a4 | 7749 | |
7750 | //_____________________________________________________________________________ | |
77566f2a | 7751 | void AliTRDCalibra::NormierungCharge() |
7752 | { | |
7753 | // | |
8ec526a4 | 7754 | // Normalisation of the gain factor resulting for the fits |
77566f2a | 7755 | // |
7756 | ||
8ec526a4 | 7757 | // Calcul of the mean of the fit |
7758 | Double_t sum = 0.0; | |
7759 | Float_t scalefactor = 1.0; | |
7760 | for (Int_t k = 0; k < (Int_t) fVectorFitCH->GetEntriesFast(); k++) { | |
7761 | Int_t total = 0; | |
7762 | Int_t detector = ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetDetector(); | |
7763 | Float_t *coef = ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetCoef(); | |
7764 | if (GetChamber(detector) == 2) { | |
7765 | total = 1728; | |
7766 | } | |
7767 | if (GetChamber(detector) != 2) { | |
7768 | total = 2304; | |
7769 | } | |
7770 | for (Int_t j = 0; j < total; j++) { | |
7771 | if (coef[j] >= 0) { | |
7772 | sum += coef[j]; | |
77566f2a | 7773 | } |
7774 | } | |
7775 | } | |
8ec526a4 | 7776 | |
7777 | if (sum > 0) { | |
7778 | fScaleFitFactor = fScaleFitFactor / sum; | |
7779 | } | |
7780 | else { | |
7781 | fScaleFitFactor = 1.0; | |
7782 | } | |
7783 | ||
7784 | // Scale the histo | |
7785 | if ((fDebug == 1) || | |
7786 | (fDebug == 4)) { | |
7787 | if ((fCoefCharge[0]->GetEntries() > 0.0) && | |
7788 | (fCoefCharge[0]->GetSumOfWeights() > 0.0)) { | |
7789 | scalefactor = fCoefCharge[0]->GetEntries() / fCoefCharge[0]->GetSumOfWeights(); | |
77566f2a | 7790 | fCoefCharge[0]->Scale(scalefactor); |
7791 | fDeltaCharge[0]->Scale(scalefactor); | |
7792 | } | |
8ec526a4 | 7793 | if ((fMeanChargeOn) && |
7794 | (fCoefCharge[1]->GetEntries() > 0.0) && | |
7795 | (fCoefCharge[1]->GetSumOfWeights() > 0.0)) { | |
7796 | fCoefCharge[1]->Scale(fCoefCharge[1]->GetEntries() / fCoefCharge[1]->GetSumOfWeights()); | |
77566f2a | 7797 | } |
8ec526a4 | 7798 | if ((fFitChargeBisOn) && |
7799 | (fCoefCharge[2]->GetEntries() > 0.0) && | |
7800 | (fCoefCharge[2]->GetSumOfWeights() > 0.0)) { | |
7801 | fCoefCharge[2]->Scale(fCoefCharge[2]->GetEntries() / fCoefCharge[2]->GetSumOfWeights()); | |
77566f2a | 7802 | } |
8ec526a4 | 7803 | if ((fMeanChargeOn) && |
7804 | (fDeltaCharge[1]->GetEntries() > 0.0) && | |
7805 | (fDeltaCharge[1]->GetSumOfWeights() > 0.0)) { | |
7806 | fDeltaCharge[1]->Scale(fDeltaCharge[1]->GetEntries() / fDeltaCharge[1]->GetSumOfWeights()); | |
77566f2a | 7807 | } |
8ec526a4 | 7808 | if ((fFitChargeBisOn) && |
7809 | (fDeltaCharge[2]->GetEntries() > 0.0) && | |
7810 | (fDeltaCharge[2]->GetSumOfWeights() > 0.0)) { | |
7811 | fDeltaCharge[2]->Scale(fDeltaCharge[2]->GetEntries() / fDeltaCharge[2]->GetSumOfWeights()); | |
77566f2a | 7812 | } |
77566f2a | 7813 | } |
7814 | ||
8ec526a4 | 7815 | if ((fDebug == 3) || |
7816 | (fDebug == 4)) { | |
77566f2a | 7817 | fCoefChargeDB[0]->Scale(scalefactor); |
8ec526a4 | 7818 | if ((fMeanChargeOn) && |
7819 | (fCoefChargeDB[1]->GetEntries() > 0.0) && | |
7820 | (fCoefChargeDB[1]->GetSumOfWeights() > 0.0)) { | |
7821 | fCoefChargeDB[1]->Scale(fCoefChargeDB[1]->GetEntries() / fCoefChargeDB[1]->GetSumOfWeights()); | |
7822 | } | |
7823 | if ((fFitChargeBisOn) && | |
7824 | (fCoefChargeDB[2]->GetEntries() > 0.0) && | |
7825 | (fCoefChargeDB[2]->GetSumOfWeights() > 0.0)) { | |
7826 | fCoefChargeDB[2]->Scale(fCoefChargeDB[2]->GetEntries() / fCoefChargeDB[2]->GetSumOfWeights()); | |
7827 | } | |
77566f2a | 7828 | } |
8ec526a4 | 7829 | |
7830 | if ((fDebug == 1) || | |
7831 | (fDebug == 4)) { | |
77566f2a | 7832 | |
77566f2a | 7833 | fDeltaCharge[0]->Add(fCoefCharge[3],-1); |
7834 | fDeltaCharge[0]->Divide(fCoefCharge[3]); | |
7835 | ||
8ec526a4 | 7836 | if (fMeanChargeOn) { |
7837 | fDeltaCharge[1]->Add(fCoefCharge[3],-1); | |
7838 | } | |
7839 | if (fMeanChargeOn) { | |
7840 | fDeltaCharge[1]->Divide(fCoefCharge[3]); | |
7841 | } | |
77566f2a | 7842 | |
8ec526a4 | 7843 | if (fFitChargeBisOn) { |
7844 | fDeltaCharge[2]->Add(fCoefCharge[3],-1); | |
7845 | } | |
7846 | if (fFitChargeBisOn) { | |
7847 | fDeltaCharge[2]->Divide(fCoefCharge[3]); | |
7848 | } | |
7849 | ||
77566f2a | 7850 | } |
7851 | ||
7852 | } | |
7853 | ||
8ec526a4 | 7854 | //_____________________________________________________________________________ |
7855 | TH1I *AliTRDCalibra::ReBin(TH1I *hist) const | |
77566f2a | 7856 | { |
7857 | // | |
7858 | // Rebin of the 1D histo for the gain calibration if needed. | |
7859 | // you have to choose fRebin, divider of fNumberBinCharge | |
7860 | // | |
7861 | ||
8ec526a4 | 7862 | TAxis *xhist = hist->GetXaxis(); |
7863 | TH1I *rehist = new TH1I("projrebin","",(Int_t) xhist->GetNbins()/fRebin | |
7864 | ,xhist->GetBinLowEdge(1) | |
7865 | ,xhist->GetBinUpEdge(xhist->GetNbins())); | |
7866 | ||
7867 | AliInfo(Form("fRebin: %d",fRebin)); | |
77566f2a | 7868 | Int_t i = 1; |
8ec526a4 | 7869 | for (Int_t k = 1; k <= (Int_t) xhist->GetNbins()/fRebin; k++) { |
77566f2a | 7870 | Double_t sum = 0.0; |
8ec526a4 | 7871 | for (Int_t ji = i; ji < i+fRebin; ji++) { |
77566f2a | 7872 | sum += hist->GetBinContent(ji); |
7873 | } | |
8ec526a4 | 7874 | sum = sum / fRebin; |
77566f2a | 7875 | rehist->SetBinContent(k,sum); |
8ec526a4 | 7876 | i += fRebin; |
77566f2a | 7877 | } |
8ec526a4 | 7878 | |
7879 | if (fDebug == 2) { | |
77566f2a | 7880 | TCanvas *crebin = new TCanvas("crebin","",50,50,600,800); |
7881 | crebin->cd(); | |
7882 | rehist->Draw(); | |
7883 | } | |
8ec526a4 | 7884 | |
77566f2a | 7885 | return rehist; |
7886 | ||
7887 | } | |
7888 | ||
8ec526a4 | 7889 | //_____________________________________________________________________________ |
7890 | TH1F *AliTRDCalibra::ReBin(TH1F *hist) const | |
77566f2a | 7891 | { |
7892 | // | |
7893 | // Rebin of the 1D histo for the gain calibration if needed | |
7894 | // you have to choose fRebin divider of fNumberBinCharge | |
7895 | // | |
7896 | ||
8ec526a4 | 7897 | TAxis *xhist = hist->GetXaxis(); |
7898 | TH1F *rehist = new TH1F("projrebin","",(Int_t) xhist->GetNbins()/fRebin | |
7899 | ,xhist->GetBinLowEdge(1) | |
7900 | ,xhist->GetBinUpEdge(xhist->GetNbins())); | |
7901 | ||
7902 | AliInfo(Form("fRebin: %d",fRebin)); | |
77566f2a | 7903 | Int_t i = 1; |
8ec526a4 | 7904 | for (Int_t k = 1; k <= (Int_t) xhist->GetNbins()/fRebin; k++) { |
77566f2a | 7905 | Double_t sum = 0.0; |
8ec526a4 | 7906 | for (Int_t ji = i; ji < i+fRebin; ji++) { |
77566f2a | 7907 | sum += hist->GetBinContent(ji); |
7908 | } | |
7909 | sum = sum/fRebin; | |
7910 | rehist->SetBinContent(k,sum); | |
8ec526a4 | 7911 | i += fRebin; |
77566f2a | 7912 | } |
8ec526a4 | 7913 | |
7914 | if (fDebug == 2) { | |
77566f2a | 7915 | TCanvas *crebin = new TCanvas("crebin","",50,50,600,800); |
7916 | crebin->cd(); | |
7917 | rehist->Draw(); | |
7918 | } | |
7919 | ||
7920 | return rehist; | |
7921 | ||
7922 | } | |
8ec526a4 | 7923 | |
7924 | //_____________________________________________________________________________ | |
77566f2a | 7925 | TH1F *AliTRDCalibra::CorrectTheError(TGraphErrors *hist) |
7926 | { | |
7927 | // | |
7928 | // In the case of the vectors method the trees contains TGraphErrors for PH and PRF | |
7929 | // to be able to add them after | |
7930 | // We convert it to a TH1F to be able to applied the same fit function method | |
7931 | // After having called this function you can not add the statistics anymore | |
7932 | // | |
7933 | ||
8ec526a4 | 7934 | TH1F *rehist = 0x0; |
77566f2a | 7935 | |
8ec526a4 | 7936 | Int_t nbins = hist->GetN(); |
7937 | Double_t *x = hist->GetX(); | |
77566f2a | 7938 | Double_t *entries = hist->GetEX(); |
8ec526a4 | 7939 | Double_t *mean = hist->GetY(); |
7940 | Double_t *square = hist->GetEY(); | |
7941 | fEntriesCurrent = 0; | |
77566f2a | 7942 | |
8ec526a4 | 7943 | if (nbins < 2) { |
7944 | return rehist; | |
7945 | } | |
77566f2a | 7946 | |
8ec526a4 | 7947 | Double_t step = x[1] - x[0]; |
7948 | Double_t minvalue = x[0] - step/2; | |
7949 | Double_t maxvalue = x[(nbins-1)] + step/2; | |
77566f2a | 7950 | |
7951 | rehist = new TH1F("projcorrecterror","",nbins,minvalue,maxvalue); | |
7952 | ||
8ec526a4 | 7953 | for (Int_t k = 0; k < nbins; k++) { |
77566f2a | 7954 | rehist->SetBinContent(k+1,mean[k]); |
8ec526a4 | 7955 | if (entries[k] > 0.0) { |
77566f2a | 7956 | fEntriesCurrent += (Int_t) entries[k]; |
8ec526a4 | 7957 | Double_t d = TMath::Abs(square[k] - (mean[k]*mean[k])); |
77566f2a | 7958 | rehist->SetBinError(k+1,TMath::Sqrt(d/entries[k])); |
7959 | } | |
8ec526a4 | 7960 | else { |
7961 | rehist->SetBinError(k+1,0.0); | |
7962 | } | |
77566f2a | 7963 | } |
8ec526a4 | 7964 | |
7965 | return rehist; | |
77566f2a | 7966 | |
7967 | } | |
8ec526a4 | 7968 | |
7969 | //_____________________________________________________________________________ | |
7970 | TGraphErrors *AliTRDCalibra::AddProfiles(TGraphErrors *hist1 | |
7971 | , TGraphErrors *hist2) const | |
77566f2a | 7972 | { |
7973 | // | |
7974 | // In the case of the vectors method we use TGraphErrors for PH and PRF | |
7975 | // to be able to add the them after | |
7976 | // Here we add the TGraphErrors | |
8ec526a4 | 7977 | // |
77566f2a | 7978 | |
8ec526a4 | 7979 | // First TGraphErrors |
7980 | Int_t nbins1 = hist1->GetN(); | |
7981 | Double_t *x1 = hist1->GetX(); | |
7982 | Double_t *ex1 = hist1->GetEX(); | |
7983 | Double_t *y1 = hist1->GetY(); | |
7984 | Double_t *ey1 = hist1->GetEY(); | |
77566f2a | 7985 | |
8ec526a4 | 7986 | TGraphErrors *rehist = new TGraphErrors(nbins1); |
77566f2a | 7987 | |
8ec526a4 | 7988 | // Second TGraphErrors |
7989 | Double_t *ex2 = hist2->GetEX(); | |
7990 | Double_t *y2 = hist2->GetY(); | |
7991 | Double_t *ey2 = hist2->GetEY(); | |
77566f2a | 7992 | |
8ec526a4 | 7993 | // Define the Variables for the new TGraphErrors |
7994 | Double_t x; | |
7995 | Double_t ex; | |
7996 | Double_t y; | |
7997 | Double_t ey; | |
7998 | ||
7999 | for (Int_t k = 0; k < nbins1; k++) { | |
8000 | Double_t nentries = 0.0; | |
8001 | x = x1[k]; | |
8002 | y = 0.0; | |
8003 | ey = 0.0; | |
8004 | ex = 0.0; | |
8005 | if ((ex2[k] == 0.0) && | |
8006 | (ex1[k] == 0.0)) { | |
8007 | nentries = 0.0; | |
8008 | } | |
8009 | if ((ex2[k] == 0.0) && | |
8010 | (ex1[k] > 0.0)) { | |
8011 | nentries = ex1[k]; | |
8012 | y = y1[k]; | |
8013 | ey = ey1[k]; | |
8014 | ex = ex1[k]; | |
8015 | } | |
8016 | if ((ex2[k] > 0.0) && | |
8017 | (ex1[k] == 0.0)) { | |
8018 | nentries = ex2[k]; | |
8019 | y = y2[k]; | |
8020 | ey = ey2[k]; | |
8021 | ex = ex2[k]; | |
8022 | } | |
8023 | if ((ex2[k] > 0.0) && | |
8024 | (ex1[k] > 0.0)) { | |
8025 | nentries = ex1[k] + ex2[k]; | |
8026 | y = ( y1[k]*ex1[k]+ y2[k]*ex2[k]) / nentries; | |
8027 | ey = (ey1[k]*ex1[k]+ey2[k]*ex2[k]) / nentries; | |
77566f2a | 8028 | ex = nentries; |
8029 | } | |
8030 | rehist->SetPoint(k,x,y); | |
8031 | rehist->SetPointError(k,ex,ey); | |
77566f2a | 8032 | } |
8033 | ||
77566f2a | 8034 | return rehist; |
77566f2a | 8035 | |
8ec526a4 | 8036 | } |
77566f2a | 8037 | |
8ec526a4 | 8038 | // |
8039 | //____________Some basic geometry function_____________________________________ | |
8040 | // | |
77566f2a | 8041 | |
8042 | //_____________________________________________________________________________ | |
8043 | Int_t AliTRDCalibra::GetPlane(Int_t d) const | |
8044 | { | |
8045 | // | |
8ec526a4 | 8046 | // Reconstruct the plane number from the detector number |
77566f2a | 8047 | // |
8048 | ||
8049 | return ((Int_t) (d % 6)); | |
8050 | ||
8051 | } | |
8052 | ||
8053 | //_____________________________________________________________________________ | |
8054 | Int_t AliTRDCalibra::GetChamber(Int_t d) const | |
8055 | { | |
8056 | // | |
8ec526a4 | 8057 | // Reconstruct the chamber number from the detector number |
77566f2a | 8058 | // |
8059 | Int_t fgkNplan = 6; | |
8060 | ||
8061 | return ((Int_t) (d % 30) / fgkNplan); | |
8062 | ||
8063 | } | |
8064 | ||
8065 | //_____________________________________________________________________________ | |
8066 | Int_t AliTRDCalibra::GetSector(Int_t d) const | |
8067 | { | |
8068 | // | |
8ec526a4 | 8069 | // Reconstruct the sector number from the detector number |
77566f2a | 8070 | // |
8071 | Int_t fg = 30; | |
8072 | ||
8073 | return ((Int_t) (d / fg)); | |
8074 | ||
8075 | } | |
8076 | ||
8ec526a4 | 8077 | // |
8078 | //____________Fill and Init tree Gain, PRF, Vdrift and T0______________________ | |
8079 | // | |
77566f2a | 8080 | |
8081 | //_____________________________________________________________________________ | |
8ec526a4 | 8082 | void AliTRDCalibra::InitTreePRF() |
77566f2a | 8083 | { |
8084 | // | |
8085 | // Init the tree where the coefficients from the fit methods can be stored | |
8086 | // | |
8ec526a4 | 8087 | |
8088 | gDirectory = gROOT; | |
8089 | fPRFPad = new Float_t[2304]; | |
8090 | fPRF = new TTree("PRF","PRF"); | |
77566f2a | 8091 | fPRF->Branch("detector",&fPRFDetector,"detector/I"); |
8ec526a4 | 8092 | fPRF->Branch("width" ,fPRFPad ,"width[2304]/F"); |
8093 | ||
8094 | // Set to default value for the plane 0 supposed to be the first one | |
8095 | for (Int_t k = 0; k < 2304; k++) { | |
77566f2a | 8096 | fPRFPad[k] = 0.515; |
8097 | } | |
8098 | fPRFDetector = -1; | |
8099 | ||
77566f2a | 8100 | } |
8ec526a4 | 8101 | |
77566f2a | 8102 | //_____________________________________________________________________________ |
8ec526a4 | 8103 | void AliTRDCalibra::FillTreePRF(Int_t countdet) |
77566f2a | 8104 | { |
8105 | // | |
8106 | // Fill the tree with the sigma of the pad response function for the detector countdet | |
8107 | // | |
8108 | ||
8109 | Int_t numberofgroup = 0; | |
8110 | fPRFDetector = countdet; | |
8111 | fPRF->Fill(); | |
8ec526a4 | 8112 | |
8113 | if (GetChamber((Int_t)(countdet+1)) == 2) { | |
8114 | numberofgroup = 1728; | |
8115 | } | |
8116 | else { | |
8117 | numberofgroup = 2304; | |
8118 | } | |
8119 | ||
8120 | // Reset to default value for the next | |
8121 | for (Int_t k = 0; k < numberofgroup; k++) { | |
8122 | if (GetPlane((Int_t) (countdet+1)) == 0) { | |
8123 | fPRFPad[k] = 0.515; | |
8124 | } | |
8125 | if (GetPlane((Int_t) (countdet+1)) == 1) { | |
8126 | fPRFPad[k] = 0.502; | |
8127 | } | |
8128 | if (GetPlane((Int_t) (countdet+1)) == 2) { | |
8129 | fPRFPad[k] = 0.491; | |
8130 | } | |
8131 | if (GetPlane((Int_t) (countdet+1)) == 3) { | |
8132 | fPRFPad[k] = 0.481; | |
8133 | } | |
8134 | if (GetPlane((Int_t) (countdet+1)) == 4) { | |
8135 | fPRFPad[k] = 0.471; | |
8136 | } | |
8137 | if (GetPlane((Int_t) (countdet+1)) == 5) { | |
8138 | fPRFPad[k] = 0.463; | |
8139 | } | |
77566f2a | 8140 | } |
8ec526a4 | 8141 | |
77566f2a | 8142 | fPRFDetector = -1; |
8143 | ||
8144 | } | |
8145 | ||
8146 | //_____________________________________________________________________________ | |
8147 | void AliTRDCalibra::ConvertVectorFitCHTree() | |
8148 | { | |
8149 | // | |
8ec526a4 | 8150 | // Convert the vector stuff to a tree of 1D histos if the user |
8151 | // want to write it after the fill functions | |
77566f2a | 8152 | // |
8ec526a4 | 8153 | |
8154 | Int_t detector = -1; | |
8155 | Int_t numberofgroup = 1; | |
77566f2a | 8156 | Float_t gainPad[2304]; |
8ec526a4 | 8157 | |
77566f2a | 8158 | fGain = new TTree("Gain","Gain"); |
8159 | fGain->Branch("detector",&detector,"detector/I"); | |
8ec526a4 | 8160 | fGain->Branch("gainPad" ,gainPad ,"gainPad[2304]/F"); |
8161 | ||
8162 | Int_t loop = (Int_t) fVectorFitCH->GetEntriesFast(); | |
8163 | for (Int_t k = 0; k < loop; k++) { | |
8164 | detector = ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetDetector(); | |
8165 | if (GetChamber((Int_t) ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetDetector()) == 2) { | |
8166 | numberofgroup = 1728; | |
8167 | } | |
8168 | else { | |
8169 | numberofgroup = 2304; | |
8170 | } | |
8171 | for (Int_t i = 0; i < numberofgroup; i++) { | |
8172 | if (((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetCoef()[i] >= 0) { | |
8173 | gainPad[i] = ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetCoef()[i] * fScaleFitFactor; | |
8174 | } | |
77566f2a | 8175 | else { |
8ec526a4 | 8176 | gainPad[i] = (Float_t) ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetCoef()[i]; |
77566f2a | 8177 | } |
8178 | } | |
8179 | fGain->Fill(); | |
8180 | } | |
77566f2a | 8181 | |
8182 | } | |
8ec526a4 | 8183 | |
77566f2a | 8184 | //_____________________________________________________________________________ |
8ec526a4 | 8185 | void AliTRDCalibra::FillTreeVdrift(Int_t countdet) |
77566f2a | 8186 | { |
8187 | // | |
8188 | // Fill the tree with the drift velocities for the detector countdet | |
8189 | // | |
8ec526a4 | 8190 | |
77566f2a | 8191 | Int_t numberofgroup = 0; |
8192 | fVdriftDetector = countdet; | |
8ec526a4 | 8193 | |
8194 | for (Int_t k = 0; k < 2304; k++) { | |
8195 | // ???? | |
77566f2a | 8196 | } |
8197 | fVdrift->Fill(); | |
8ec526a4 | 8198 | if (GetChamber((Int_t)(countdet+1)) == 2) { |
8199 | numberofgroup = 1728; | |
8200 | } | |
8201 | else { | |
8202 | numberofgroup = 2304; | |
8203 | } | |
8204 | // Reset to default value the gain coef | |
8205 | for (Int_t k = 0; k < numberofgroup; k++) { | |
77566f2a | 8206 | fVdriftPad[k] = -1.5; |
8207 | } | |
8208 | fVdriftDetector = -1; | |
8209 | ||
8210 | } | |
8211 | ||
8212 | //_____________________________________________________________________________ | |
8ec526a4 | 8213 | void AliTRDCalibra::InitTreePH() |
77566f2a | 8214 | { |
8215 | // | |
8216 | // Init the tree where the coefficients from the fit methods can be stored | |
8217 | // | |
8218 | ||
8ec526a4 | 8219 | gDirectory = gROOT; |
77566f2a | 8220 | fVdriftPad = new Float_t[2304]; |
8ec526a4 | 8221 | fVdrift = new TTree("Vdrift","Vdrift"); |
77566f2a | 8222 | fVdrift->Branch("detector",&fVdriftDetector,"detector/I"); |
8ec526a4 | 8223 | fVdrift->Branch("vdrift" ,fVdriftPad ,"vdrift[2304]/F"); |
8224 | // Set to default value for the plane 0 supposed to be the first one | |
8225 | for (Int_t k = 0; k < 2304; k++) { | |
77566f2a | 8226 | fVdriftPad[k] = -1.5; |
8227 | } | |
8228 | fVdriftDetector = -1; | |
8229 | ||
8230 | } | |
8ec526a4 | 8231 | |
77566f2a | 8232 | //_____________________________________________________________________________ |
8ec526a4 | 8233 | void AliTRDCalibra::FillTreeT0(Int_t countdet) |
77566f2a | 8234 | { |
8235 | // | |
8236 | // Fill the tree with the t0 value for the detector countdet | |
8237 | // | |
8ec526a4 | 8238 | |
77566f2a | 8239 | Int_t numberofgroup = 0; |
8ec526a4 | 8240 | |
77566f2a | 8241 | fT0Detector = countdet; |
8ec526a4 | 8242 | for (Int_t k = 0; k < 2304; k++) { |
8243 | // ???? | |
77566f2a | 8244 | } |
8245 | fT0->Fill(); | |
8ec526a4 | 8246 | if (GetChamber((Int_t) (countdet+1)) == 2) { |
8247 | numberofgroup = 1728; | |
8248 | } | |
8249 | else { | |
8250 | numberofgroup = 2304; | |
8251 | } | |
8252 | // Reset to default value the gain coef | |
8253 | for (Int_t k = 0; k < numberofgroup; k++) { | |
77566f2a | 8254 | fT0Pad[k] = 0.0; |
8255 | } | |
8256 | fT0Detector = -1; | |
8257 | ||
8258 | } | |
8259 | ||
8260 | //_____________________________________________________________________________ | |
8ec526a4 | 8261 | void AliTRDCalibra::InitTreeT0() |
77566f2a | 8262 | { |
8263 | // | |
8264 | // Init the tree where the coefficients from the fit methods can be stored | |
8265 | // | |
8266 | ||
8ec526a4 | 8267 | gDirectory = gROOT; |
77566f2a | 8268 | fT0Pad = new Float_t[2304]; |
8269 | fT0 = new TTree("T0","T0"); | |
8270 | fT0->Branch("detector",&fT0Detector,"detector/I"); | |
8271 | fT0->Branch("t0",fT0Pad,"t0[2304]/F"); | |
8272 | //Set to default value for the plane 0 supposed to be the first one | |
8273 | for(Int_t k = 0; k < 2304; k++){ | |
8274 | fT0Pad[k] = 0.0; | |
8275 | } | |
8276 | fT0Detector = -1; | |
8277 | ||
8278 | } | |
8279 | ||
8ec526a4 | 8280 | // |
8281 | //____________Private Functions________________________________________________ | |
8282 | // | |
77566f2a | 8283 | |
8ec526a4 | 8284 | //_____________________________________________________________________________ |
8285 | Double_t AliTRDCalibra::PH(Double_t *x, Double_t *par) | |
77566f2a | 8286 | { |
8287 | // | |
8288 | // Function for the fit | |
8289 | // | |
8290 | ||
8ec526a4 | 8291 | //TF1 *fAsymmGauss = new TF1("fAsymmGauss",AsymmGauss,0,4,6); |
77566f2a | 8292 | |
8293 | //PARAMETERS FOR FIT PH | |
8294 | // PASAv.4 | |
8ec526a4 | 8295 | //fAsymmGauss->SetParameter(0,0.113755); |
8296 | //fAsymmGauss->SetParameter(1,0.350706); | |
8297 | //fAsymmGauss->SetParameter(2,0.0604244); | |
8298 | //fAsymmGauss->SetParameter(3,7.65596); | |
8299 | //fAsymmGauss->SetParameter(4,1.00124); | |
8300 | //fAsymmGauss->SetParameter(5,0.870597); // No tail cancelation | |
77566f2a | 8301 | |
8302 | Double_t xx = x[0]; | |
8303 | ||
8ec526a4 | 8304 | if (xx < par[1]) { |
8305 | return par[5]; | |
8306 | } | |
8307 | ||
8308 | Double_t dx = 0.005; | |
8309 | Double_t xs = par[1]; | |
8310 | Double_t ss = 0.0; | |
8311 | Double_t paras[2] = { 0.0, 0.0 }; | |
77566f2a | 8312 | |
77566f2a | 8313 | while (xs < xx) { |
8ec526a4 | 8314 | if ((xs >= par[1]) && |
8315 | (xs < (par[1]+par[2]))) { | |
77566f2a | 8316 | //fAsymmGauss->SetParameter(0,par[0]); |
8317 | //fAsymmGauss->SetParameter(1,xs); | |
8318 | //ss += fAsymmGauss->Eval(xx); | |
8319 | paras[0] = par[0]; | |
8320 | paras[1] = xs; | |
8321 | ss += AsymmGauss(&xx,paras); | |
8322 | } | |
8ec526a4 | 8323 | if ((xs >= (par[1]+par[2])) && |
8324 | (xs < (par[1]+par[2]+par[3]))) { | |
77566f2a | 8325 | //fAsymmGauss->SetParameter(0,par[0]*par[4]); |
8326 | //fAsymmGauss->SetParameter(1,xs); | |
8327 | //ss += fAsymmGauss->Eval(xx); | |
8328 | paras[0] = par[0]*par[4]; | |
8329 | paras[1] = xs; | |
8330 | ss += AsymmGauss(&xx,paras); | |
8331 | } | |
8332 | xs += dx; | |
8333 | } | |
8334 | ||
8ec526a4 | 8335 | return ss + par[5]; |
77566f2a | 8336 | |
8337 | } | |
8338 | ||
8ec526a4 | 8339 | //_____________________________________________________________________________ |
8340 | Double_t AliTRDCalibra::AsymmGauss(Double_t *x, Double_t *par) | |
77566f2a | 8341 | { |
8342 | // | |
8343 | // Function for the fit | |
8344 | // | |
8345 | ||
8346 | //par[0] = normalization | |
8347 | //par[1] = mean | |
8348 | //par[2] = sigma | |
8349 | //norm0 = 1 | |
8350 | //par[3] = lambda0 | |
8351 | //par[4] = norm1 | |
8352 | //par[5] = lambda1 | |
77566f2a | 8353 | |
8354 | Double_t par1save = par[1]; | |
8355 | //Double_t par2save = par[2]; | |
8356 | Double_t par2save = 0.0604244; | |
8357 | //Double_t par3save = par[3]; | |
8358 | Double_t par3save = 7.65596; | |
8359 | //Double_t par5save = par[5]; | |
8360 | Double_t par5save = 0.870597; | |
8ec526a4 | 8361 | Double_t dx = x[0] - par1save; |
77566f2a | 8362 | |
8ec526a4 | 8363 | Double_t sigma2 = par2save*par2save; |
8364 | Double_t sqrt2 = TMath::Sqrt(2.0); | |
8365 | Double_t exp1 = par3save * TMath::Exp(-par3save * (dx - 0.5 * par3save * sigma2)) | |
8366 | * (1.0 - TMath::Erf((par3save * sigma2 - dx) / (sqrt2 * par2save))); | |
8367 | Double_t exp2 = par5save * TMath::Exp(-par5save * (dx - 0.5 * par5save * sigma2)) | |
8368 | * (1.0 - TMath::Erf((par5save * sigma2 - dx) / (sqrt2 * par2save))); | |
77566f2a | 8369 | |
8370 | //return par[0]*(exp1+par[4]*exp2); | |
8ec526a4 | 8371 | return par[0] * (exp1 + 1.00124 * exp2); |
77566f2a | 8372 | |
8ec526a4 | 8373 | } |
77566f2a | 8374 | |
8ec526a4 | 8375 | //_____________________________________________________________________________ |
8376 | Double_t AliTRDCalibra::FuncLandauGaus(Double_t *x, Double_t *par) | |
77566f2a | 8377 | { |
8378 | // | |
8ec526a4 | 8379 | // Sum Landau + Gaus with identical mean |
77566f2a | 8380 | // |
8381 | ||
8ec526a4 | 8382 | Double_t valLandau = par[0] * TMath::Landau(x[0],par[1],par[2]); |
8383 | //Double_t valGaus = par[3] * TMath::Gaus(x[0],par[4],par[5]); | |
8384 | Double_t valGaus = par[3] * TMath::Gaus(x[0],par[1],par[4]); | |
8385 | Double_t val = valLandau + valGaus; | |
77566f2a | 8386 | |
77566f2a | 8387 | return val; |
8ec526a4 | 8388 | |
77566f2a | 8389 | } |
8ec526a4 | 8390 | |
8391 | //_____________________________________________________________________________ | |
8392 | Double_t AliTRDCalibra::LanGauFun(Double_t *x, Double_t *par) | |
77566f2a | 8393 | { |
8394 | // | |
8395 | // Function for the fit | |
8396 | // | |
8ec526a4 | 8397 | // Fit parameters: |
8398 | // par[0]=Width (scale) parameter of Landau density | |
8399 | // par[1]=Most Probable (MP, location) parameter of Landau density | |
8400 | // par[2]=Total area (integral -inf to inf, normalization constant) | |
8401 | // par[3]=Width (sigma) of convoluted Gaussian function | |
77566f2a | 8402 | // |
8ec526a4 | 8403 | // In the Landau distribution (represented by the CERNLIB approximation), |
8404 | // the maximum is located at x=-0.22278298 with the location parameter=0. | |
8405 | // This shift is corrected within this function, so that the actual | |
8406 | // maximum is identical to the MP parameter. | |
8407 | // | |
8408 | ||
77566f2a | 8409 | // Numeric constants |
8410 | Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2) | |
8411 | Double_t mpshift = -0.22278298; // Landau maximum location | |
8412 | ||
8413 | // Control constants | |
8ec526a4 | 8414 | Double_t np = 100.0; // Number of convolution steps |
8415 | Double_t sc = 5.0; // Convolution extends to +-sc Gaussian sigmas | |
77566f2a | 8416 | |
8417 | // Variables | |
8418 | Double_t xx; | |
8419 | Double_t mpc; | |
8420 | Double_t fland; | |
8421 | Double_t sum = 0.0; | |
8ec526a4 | 8422 | Double_t xlow; |
8423 | Double_t xupp; | |
77566f2a | 8424 | Double_t step; |
8425 | Double_t i; | |
8426 | ||
77566f2a | 8427 | // MP shift correction |
8428 | mpc = par[1] - mpshift * par[0]; | |
8ec526a4 | 8429 | |
77566f2a | 8430 | // Range of convolution integral |
8431 | xlow = x[0] - sc * par[3]; | |
8432 | xupp = x[0] + sc * par[3]; | |
8433 | ||
8ec526a4 | 8434 | step = (xupp - xlow) / np; |
8435 | ||
77566f2a | 8436 | // Convolution integral of Landau and Gaussian by sum |
8ec526a4 | 8437 | for (i = 1.0; i <= np/2; i++) { |
8438 | ||
8439 | xx = xlow + (i-.5) * step; | |
77566f2a | 8440 | fland = TMath::Landau(xx,mpc,par[0]) / par[0]; |
8ec526a4 | 8441 | sum += fland * TMath::Gaus(x[0],xx,par[3]); |
77566f2a | 8442 | |
8ec526a4 | 8443 | xx = xupp - (i-.5) * step; |
77566f2a | 8444 | fland = TMath::Landau(xx,mpc,par[0]) / par[0]; |
8ec526a4 | 8445 | sum += fland * TMath::Gaus(x[0],xx,par[3]); |
8446 | ||
77566f2a | 8447 | } |
8ec526a4 | 8448 | |
77566f2a | 8449 | return (par[2] * step * sum * invsq2pi / par[3]); |
8ec526a4 | 8450 | |
77566f2a | 8451 | } |
8ec526a4 | 8452 | |
8453 | //_____________________________________________________________________________ | |
8454 | TF1 *AliTRDCalibra::LanGauFit(TH1 *his, Double_t *fitrange, Double_t *startvalues | |
8455 | , Double_t *parlimitslo, Double_t *parlimitshi | |
8456 | , Double_t *fitparams, Double_t *fiterrors | |
8457 | , Double_t *chiSqr, Int_t *ndf) | |
77566f2a | 8458 | { |
8459 | // | |
8460 | // Function for the fit | |
8461 | // | |
8462 | ||
77566f2a | 8463 | Int_t i; |
8ec526a4 | 8464 | Char_t funname[100]; |
77566f2a | 8465 | |
8ec526a4 | 8466 | AliInfo(Form(funname,"Fitfcn_%s",his->GetName())); |
77566f2a | 8467 | |
8ec526a4 | 8468 | TF1 *ffitold = (TF1 *) gROOT->GetListOfFunctions()->FindObject(funname); |
8469 | if (ffitold) { | |
8470 | delete ffitold; | |
8471 | } | |
8472 | ||
8473 | TF1 *ffit = new TF1(funname,LanGauFun,fitrange[0],fitrange[1],4); | |
77566f2a | 8474 | ffit->SetParameters(startvalues); |
8475 | ffit->SetParNames("Width","MP","Area","GSigma"); | |
8476 | ||
8ec526a4 | 8477 | for (i = 0; i < 4; i++) { |
8478 | ffit->SetParLimits(i,parlimitslo[i],parlimitshi[i]); | |
77566f2a | 8479 | } |
8480 | ||
8ec526a4 | 8481 | his->Fit(funname,"RB0"); // Fit within specified range, use ParLimits, do not plot |
77566f2a | 8482 | |
8ec526a4 | 8483 | ffit->GetParameters(fitparams); // Obtain fit parameters |
8484 | for (i = 0; i < 4; i++) { | |
8485 | fiterrors[i] = ffit->GetParError(i); // Obtain fit parameter errors | |
8486 | } | |
8487 | chiSqr[0] = ffit->GetChisquare(); // Obtain chi^2 | |
8488 | ndf[0] = ffit->GetNDF(); // Obtain ndf | |
77566f2a | 8489 | |
8ec526a4 | 8490 | return (ffit); // Return fit function |
77566f2a | 8491 | |
8492 | } | |
8ec526a4 | 8493 | |
8494 | //_____________________________________________________________________________ | |
8495 | Int_t AliTRDCalibra::LanGauPro(Double_t *params, Double_t &maxx, Double_t &fwhm) | |
8496 | { | |
77566f2a | 8497 | // |
8498 | // Function for the fit | |
8499 | // | |
8ec526a4 | 8500 | |
8501 | Double_t p; | |
8502 | Double_t x; | |
8503 | Double_t fy; | |
8504 | Double_t fxr; | |
8505 | Double_t fxl; | |
77566f2a | 8506 | Double_t step; |
8ec526a4 | 8507 | Double_t l; |
8508 | Double_t lold; | |
8509 | ||
8510 | Int_t i = 0; | |
8511 | Int_t maxcalls = 10000; | |
77566f2a | 8512 | |
8513 | // Search for maximum | |
8ec526a4 | 8514 | p = params[1] - 0.1 * params[0]; |
77566f2a | 8515 | step = 0.05 * params[0]; |
8516 | lold = -2.0; | |
8517 | l = -1.0; | |
8518 | ||
8ec526a4 | 8519 | while ((l != lold) && (i < maxcalls)) { |
77566f2a | 8520 | i++; |
77566f2a | 8521 | lold = l; |
8ec526a4 | 8522 | x = p + step; |
8523 | l = LanGauFun(&x,params); | |
8524 | if (l < lold) { | |
8525 | step = -step / 10.0; | |
8526 | } | |
77566f2a | 8527 | p += step; |
8528 | } | |
8529 | ||
8ec526a4 | 8530 | if (i == maxcalls) { |
77566f2a | 8531 | return (-1); |
8ec526a4 | 8532 | } |
77566f2a | 8533 | maxx = x; |
8ec526a4 | 8534 | fy = l / 2.0; |
77566f2a | 8535 | |
8ec526a4 | 8536 | // Search for right x location of fy |
8537 | p = maxx + params[0]; | |
77566f2a | 8538 | step = params[0]; |
8539 | lold = -2.0; | |
8540 | l = -1e300; | |
8541 | i = 0; | |
8542 | ||
8ec526a4 | 8543 | while ( (l != lold) && (i < maxcalls) ) { |
77566f2a | 8544 | i++; |
8545 | ||
8546 | lold = l; | |
8547 | x = p + step; | |
8ec526a4 | 8548 | l = TMath::Abs(LanGauFun(&x,params) - fy); |
77566f2a | 8549 | |
8550 | if (l > lold) | |
8551 | step = -step/10; | |
8552 | ||
8553 | p += step; | |
8554 | } | |
8555 | ||
8ec526a4 | 8556 | if (i == maxcalls) |
77566f2a | 8557 | return (-2); |
8558 | ||
8559 | fxr = x; | |
8560 | ||
8561 | ||
8562 | // Search for left x location of fy | |
8563 | ||
8564 | p = maxx - 0.5 * params[0]; | |
8565 | step = -params[0]; | |
8566 | lold = -2.0; | |
8ec526a4 | 8567 | l = -1.0e300; |
77566f2a | 8568 | i = 0; |
8569 | ||
8ec526a4 | 8570 | while ((l != lold) && (i < maxcalls)) { |
77566f2a | 8571 | i++; |
77566f2a | 8572 | lold = l; |
8ec526a4 | 8573 | x = p + step; |
8574 | l = TMath::Abs(LanGauFun(&x,params) - fy); | |
8575 | if (l > lold) { | |
8576 | step = -step / 10.0; | |
8577 | } | |
77566f2a | 8578 | p += step; |
8579 | } | |
8580 | ||
8ec526a4 | 8581 | if (i == maxcalls) { |
8582 | return (-3); | |
8583 | } | |
77566f2a | 8584 | |
8ec526a4 | 8585 | fxl = x; |
8586 | fwhm = fxr - fxl; | |
77566f2a | 8587 | |
8ec526a4 | 8588 | return (0); |
77566f2a | 8589 | |
8ec526a4 | 8590 | } |