]>
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> | |
9f4780aa | 117 | #include <TGraph.h> |
8ec526a4 | 118 | #include <TObjArray.h> |
119 | #include <TChain.h> | |
120 | #include <TH1.h> | |
121 | #include <TH1I.h> | |
122 | #include <TH1F.h> | |
123 | #include <TF1.h> | |
124 | #include <TH2F.h> | |
125 | #include <TAxis.h> | |
126 | #include <TStopwatch.h> | |
127 | #include <TMath.h> | |
128 | #include <TLegend.h> | |
129 | #include <TDirectory.h> | |
130 | #include <TROOT.h> | |
131 | ||
132 | #include "AliLog.h" | |
133 | #include "AliCDBManager.h" | |
134 | #include "AliRun.h" | |
135 | #include "AliRunLoader.h" | |
136 | #include "AliLoader.h" | |
137 | #include "AliRawReaderFile.h" | |
138 | #include "AliRawReader.h" | |
77566f2a | 139 | |
140 | #include "AliTRDCalibra.h" | |
8ec526a4 | 141 | #include "AliTRDcalibDB.h" |
142 | #include "AliTRDCommonParam.h" | |
143 | #include "AliTRDmcmTracklet.h" | |
144 | #include "AliTRDpadPlane.h" | |
145 | #include "AliTRDcluster.h" | |
146 | #include "AliTRDtrack.h" | |
147 | #include "AliTRDdigit.h" | |
148 | #include "AliTRDdigitsManager.h" | |
149 | #include "AliTRD.h" | |
150 | #include "AliTRDgeometry.h" | |
151 | #include "./Cal/AliTRDCalROC.h" | |
152 | #include "./Cal/AliTRDCalPad.h" | |
153 | #include "./Cal/AliTRDCalDet.h" | |
154 | #include "AliTRDrawData.h" | |
77566f2a | 155 | |
156 | ClassImp(AliTRDCalibra) | |
157 | ||
158 | AliTRDCalibra* AliTRDCalibra::fgInstance = 0; | |
159 | Bool_t AliTRDCalibra::fgTerminated = kFALSE; | |
160 | ||
161 | //_____________singleton implementation_________________________________________________ | |
8ec526a4 | 162 | AliTRDCalibra *AliTRDCalibra::Instance() |
77566f2a | 163 | { |
164 | // | |
165 | // Singleton implementation | |
166 | // | |
167 | ||
8ec526a4 | 168 | if (fgTerminated != kFALSE) { |
77566f2a | 169 | return 0; |
8ec526a4 | 170 | } |
77566f2a | 171 | |
8ec526a4 | 172 | if (fgInstance == 0) { |
77566f2a | 173 | fgInstance = new AliTRDCalibra(); |
8ec526a4 | 174 | } |
77566f2a | 175 | |
176 | return fgInstance; | |
177 | ||
178 | } | |
179 | ||
180 | //______________________________________________________________________________________ | |
181 | void AliTRDCalibra::Terminate() | |
182 | { | |
183 | // | |
184 | // Singleton implementation | |
185 | // Deletes the instance of this class | |
186 | // | |
187 | ||
188 | fgTerminated = kTRUE; | |
189 | ||
190 | if (fgInstance != 0) { | |
191 | delete fgInstance; | |
192 | fgInstance = 0; | |
193 | } | |
194 | ||
195 | } | |
196 | ||
197 | //______________________________________________________________________________________ | |
198 | AliTRDCalibra::AliTRDCalibra() | |
199 | :TObject() | |
8ec526a4 | 200 | ,fMITracking(kFALSE) |
201 | ,fMcmTracking(kFALSE) | |
202 | ,fMcmCorrectAngle(kFALSE) | |
77566f2a | 203 | ,fCH2dOn(kFALSE) |
204 | ,fPH2dOn(kFALSE) | |
205 | ,fPRF2dOn(kFALSE) | |
206 | ,fHisto2d(kFALSE) | |
207 | ,fVector2d(kFALSE) | |
208 | ,fRelativeScale(0) | |
209 | ,fCountRelativeScale(0) | |
210 | ,fRelativeScaleAuto(kFALSE) | |
8ec526a4 | 211 | ,fThresholdDigit(0) |
77566f2a | 212 | ,fThresholdClusterPRF1(0.0) |
213 | ,fThresholdClusterPRF2(0.0) | |
214 | ,fCenterOfflineCluster(kFALSE) | |
215 | ,fTraMaxPad(kFALSE) | |
216 | ,fWriteNameCoef(0) | |
217 | ,fWriteName(0) | |
218 | ,fFitPHOn(kFALSE) | |
219 | ,fFitPHPeriode(0) | |
220 | ,fBeginFitCharge(0.0) | |
221 | ,fRangeFitPRF(0.0) | |
222 | ,fMeanChargeOn(kFALSE) | |
223 | ,fFitChargeBisOn(kFALSE) | |
224 | ,fT0Shift(0.0) | |
8ec526a4 | 225 | ,fAccCDB(kFALSE) |
226 | ,fNumberFit(0) | |
e5c60cc7 | 227 | ,fNumberEnt(0) |
8ec526a4 | 228 | ,fStatisticMean(0.0) |
77566f2a | 229 | ,fDebug(0) |
230 | ,fFitVoir(0) | |
231 | ,fPRF(0) | |
232 | ,fGain(0) | |
233 | ,fT0(0) | |
234 | ,fVdrift(0) | |
235 | ,fVdriftDetector(0) | |
236 | ,fVdriftPad(0x0) | |
237 | ,fT0Detector(0) | |
238 | ,fT0Pad(0x0) | |
239 | ,fPRFDetector(0) | |
240 | ,fPRFPad(0x0) | |
8ec526a4 | 241 | ,fCoefCH(0x0) |
77566f2a | 242 | ,fDetectorAliTRDtrack(kFALSE) |
243 | ,fChamberAliTRDtrack(-1) | |
8ec526a4 | 244 | ,fDetectorPreviousTrack(-1) |
77566f2a | 245 | ,fGoodTrack(kTRUE) |
8ec526a4 | 246 | ,fAmpTotal(0x0) |
247 | ,fPHPlace(0x0) | |
248 | ,fPHValue(0x0) | |
77566f2a | 249 | ,fNumberClusters(0) |
8ec526a4 | 250 | ,fProcent(0.0) |
251 | ,fDifference(0) | |
252 | ,fNumberTrack(0) | |
9f4780aa | 253 | ,fCoefPRFE(0) |
77566f2a | 254 | ,fCoefPRFDB(0) |
255 | ,fTimeMax(0) | |
256 | ,fSf(0.0) | |
8ec526a4 | 257 | ,fScaleFitFactor(0.0) |
77566f2a | 258 | ,fMinEntries(0) |
259 | ,fEntriesCurrent(0) | |
8ec526a4 | 260 | ,fL3P0(0.0) |
261 | ,fL3P2(0.0) | |
262 | ,fG3P2(0.0) | |
77566f2a | 263 | ,fVectorPH(0) |
264 | ,fPlaPH(0) | |
265 | ,fNumberBinCharge(0) | |
266 | ,fVectorCH(0) | |
267 | ,fPlaCH(0) | |
268 | ,fVectorFitCH(0) | |
269 | ,fNumberBinPRF(0) | |
270 | ,fVectorPRF(0) | |
271 | ,fPlaPRF(0) | |
272 | ,fPH2d(0x0) | |
273 | ,fPRF2d(0x0) | |
274 | ,fCH2d(0x0) | |
275 | ,fRebin(0) | |
276 | { | |
277 | // | |
278 | // Default constructor | |
279 | // | |
280 | ||
281 | for (Int_t i = 0; i < 3; i++) { | |
282 | fNz[i] = 0; | |
283 | fNrphi[i] = 0; | |
284 | } | |
285 | ||
286 | for (Int_t k = 0; k < 3; k++) { | |
287 | fNtotal[k] = 0; | |
8ec526a4 | 288 | fDetChamb2[k] = 0; |
289 | fDetChamb0[k] = 0; | |
77566f2a | 290 | } |
291 | ||
292 | // Write | |
293 | for (Int_t i = 0; i < 3; i++) { | |
294 | fWriteCoef[i] = kFALSE; | |
295 | fWrite[i] = kFALSE; | |
296 | } | |
297 | ||
298 | // Debug Mode | |
299 | for (Int_t k = 0; k < 3; k++) { | |
300 | fDet[k] = 0; | |
301 | } | |
302 | ||
e5c60cc7 | 303 | for (Int_t i = 0; i < 3; i++) { |
77566f2a | 304 | fPhd[i] = 0.0; |
305 | } | |
77566f2a | 306 | |
307 | // Init | |
308 | Init(); | |
309 | ||
310 | } | |
311 | ||
312 | //______________________________________________________________________________________ | |
313 | AliTRDCalibra::AliTRDCalibra(const AliTRDCalibra &c) | |
314 | :TObject(c) | |
8ec526a4 | 315 | ,fMITracking(kFALSE) |
316 | ,fMcmTracking(kFALSE) | |
317 | ,fMcmCorrectAngle(kFALSE) | |
77566f2a | 318 | ,fCH2dOn(kFALSE) |
319 | ,fPH2dOn(kFALSE) | |
320 | ,fPRF2dOn(kFALSE) | |
321 | ,fHisto2d(kFALSE) | |
322 | ,fVector2d(kFALSE) | |
323 | ,fRelativeScale(0) | |
324 | ,fCountRelativeScale(0) | |
325 | ,fRelativeScaleAuto(kFALSE) | |
8ec526a4 | 326 | ,fThresholdDigit(0) |
77566f2a | 327 | ,fThresholdClusterPRF1(0.0) |
328 | ,fThresholdClusterPRF2(0.0) | |
329 | ,fCenterOfflineCluster(kFALSE) | |
330 | ,fTraMaxPad(kFALSE) | |
331 | ,fWriteNameCoef(0) | |
332 | ,fWriteName(0) | |
333 | ,fFitPHOn(kFALSE) | |
334 | ,fFitPHPeriode(0) | |
335 | ,fBeginFitCharge(0.0) | |
336 | ,fRangeFitPRF(0.0) | |
337 | ,fMeanChargeOn(kFALSE) | |
338 | ,fFitChargeBisOn(kFALSE) | |
339 | ,fT0Shift(0.0) | |
8ec526a4 | 340 | ,fAccCDB(kFALSE) |
341 | ,fNumberFit(0) | |
e5c60cc7 | 342 | ,fNumberEnt(0) |
8ec526a4 | 343 | ,fStatisticMean(0.0) |
77566f2a | 344 | ,fDebug(0) |
345 | ,fFitVoir(0) | |
346 | ,fPRF(0) | |
347 | ,fGain(0) | |
348 | ,fT0(0) | |
349 | ,fVdrift(0) | |
350 | ,fVdriftDetector(0) | |
351 | ,fVdriftPad(0x0) | |
352 | ,fT0Detector(0) | |
353 | ,fT0Pad(0x0) | |
354 | ,fPRFDetector(0) | |
355 | ,fPRFPad(0x0) | |
8ec526a4 | 356 | ,fCoefCH(0x0) |
77566f2a | 357 | ,fDetectorAliTRDtrack(kFALSE) |
358 | ,fChamberAliTRDtrack(-1) | |
8ec526a4 | 359 | ,fDetectorPreviousTrack(-1) |
77566f2a | 360 | ,fGoodTrack(kTRUE) |
8ec526a4 | 361 | ,fAmpTotal(0x0) |
362 | ,fPHPlace(0x0) | |
363 | ,fPHValue(0x0) | |
77566f2a | 364 | ,fNumberClusters(0) |
8ec526a4 | 365 | ,fProcent(0.0) |
366 | ,fDifference(0) | |
367 | ,fNumberTrack(0) | |
9f4780aa | 368 | ,fCoefPRFE(0) |
77566f2a | 369 | ,fCoefPRFDB(0) |
370 | ,fTimeMax(0) | |
371 | ,fSf(0.0) | |
8ec526a4 | 372 | ,fScaleFitFactor(0.0) |
77566f2a | 373 | ,fMinEntries(0) |
374 | ,fEntriesCurrent(0) | |
8ec526a4 | 375 | ,fL3P0(0.0) |
376 | ,fL3P2(0.0) | |
377 | ,fG3P2(0.0) | |
77566f2a | 378 | ,fVectorPH(0) |
379 | ,fPlaPH(0) | |
380 | ,fNumberBinCharge(0) | |
381 | ,fVectorCH(0) | |
382 | ,fPlaCH(0) | |
383 | ,fVectorFitCH(0) | |
384 | ,fNumberBinPRF(0) | |
385 | ,fVectorPRF(0) | |
386 | ,fPlaPRF(0) | |
387 | ,fPH2d(0x0) | |
388 | ,fPRF2d(0x0) | |
389 | ,fCH2d(0x0) | |
390 | ,fRebin(0) | |
391 | { | |
392 | // | |
393 | // Copy constructor | |
394 | // | |
395 | ||
396 | } | |
397 | ||
398 | //____________________________________________________________________________________ | |
399 | AliTRDCalibra::~AliTRDCalibra() | |
400 | { | |
401 | // | |
402 | // AliTRDCalibra destructor | |
403 | // | |
404 | ||
405 | ClearHistos(); | |
406 | ClearTree(); | |
77566f2a | 407 | |
408 | } | |
409 | ||
410 | //_____________________________________________________________________________ | |
411 | void AliTRDCalibra::Destroy() | |
412 | { | |
413 | // | |
8ec526a4 | 414 | // Delete instance |
77566f2a | 415 | // |
416 | ||
417 | if (fgInstance) { | |
77566f2a | 418 | delete fgInstance; |
419 | fgInstance = 0x0; | |
420 | } | |
8ec526a4 | 421 | |
77566f2a | 422 | } |
423 | ||
424 | //_____________________________________________________________________________ | |
425 | void AliTRDCalibra::ClearHistos() | |
426 | { | |
427 | // | |
8ec526a4 | 428 | // Delete the histos |
77566f2a | 429 | // |
430 | ||
8ec526a4 | 431 | if (fPH2d) { |
77566f2a | 432 | delete fPH2d; |
8ec526a4 | 433 | fPH2d = 0x0; |
77566f2a | 434 | } |
8ec526a4 | 435 | if (fCH2d) { |
77566f2a | 436 | delete fCH2d; |
8ec526a4 | 437 | fCH2d = 0x0; |
77566f2a | 438 | } |
8ec526a4 | 439 | if (fPRF2d) { |
77566f2a | 440 | delete fPRF2d; |
441 | fPRF2d = 0x0; | |
442 | } | |
443 | ||
444 | } | |
445 | ||
446 | //_____________________________________________________________________________ | |
447 | void AliTRDCalibra::ClearTree() | |
448 | { | |
449 | // | |
8ec526a4 | 450 | // Delete the trees |
77566f2a | 451 | // |
452 | ||
8ec526a4 | 453 | if (fPRF) { |
77566f2a | 454 | delete fPRF; |
8ec526a4 | 455 | fPRF = 0x0; |
77566f2a | 456 | } |
8ec526a4 | 457 | if (fGain) { |
77566f2a | 458 | delete fGain; |
8ec526a4 | 459 | fGain = 0x0; |
77566f2a | 460 | } |
8ec526a4 | 461 | if (fT0) { |
77566f2a | 462 | delete fT0; |
8ec526a4 | 463 | fT0 = 0x0; |
77566f2a | 464 | } |
8ec526a4 | 465 | if (fVdrift) { |
77566f2a | 466 | delete fVdrift; |
467 | fVdrift = 0x0; | |
468 | } | |
469 | ||
470 | } | |
471 | ||
472 | //_____________________________________________________________________________ | |
473 | void AliTRDCalibra::Init() | |
474 | { | |
475 | // | |
476 | // Init some default values | |
477 | // | |
478 | ||
8ec526a4 | 479 | // How to fill the 2D |
480 | fThresholdDigit = 5; | |
77566f2a | 481 | fThresholdClusterPRF1 = 2.0; |
482 | fThresholdClusterPRF2 = 20.0; | |
483 | ||
8ec526a4 | 484 | // Store the Info |
485 | fNumberBinCharge = 100; | |
486 | fNumberBinPRF = 20; | |
77566f2a | 487 | |
8ec526a4 | 488 | // Write |
489 | fWriteName = "TRD.calibration.root"; | |
490 | fWriteNameCoef = "TRD.coefficient.root"; | |
491 | ||
492 | // Fit | |
493 | fFitPHPeriode = 1; | |
494 | fBeginFitCharge = 3.5; | |
495 | fRangeFitPRF = 0.5; | |
496 | fMinEntries = 800; | |
497 | fT0Shift = 0.143397; | |
498 | ||
499 | // Internal variables | |
500 | ||
501 | // Fill the 2D histos in the offline tracking | |
502 | fDetectorPreviousTrack = -1; | |
503 | fChamberAliTRDtrack = -1; | |
504 | fGoodTrack = kTRUE; | |
505 | ||
506 | fProcent = 6.0; | |
507 | fDifference = 17; | |
508 | fNumberClusters = 18; | |
509 | fNumberTrack = 0; | |
510 | fNumberUsedCh[0] = 0; | |
511 | fNumberUsedCh[1] = 0; | |
512 | fNumberUsedPh[0] = 0; | |
513 | fNumberUsedPh[1] = 0; | |
514 | ||
515 | // Variables in the loop | |
516 | for (Int_t k = 0; k < 4; k++) { | |
77566f2a | 517 | fChargeCoef[k] = 1.0; |
518 | fVdriftCoef[k] = 1.5; | |
8ec526a4 | 519 | fT0Coef[k] = -1.0; |
77566f2a | 520 | } |
8ec526a4 | 521 | for (Int_t i = 0; i < 2; i++) { |
522 | fPRFCoef[i] = -1.0; | |
77566f2a | 523 | } |
524 | ||
8ec526a4 | 525 | // Pad calibration |
526 | for (Int_t i = 0; i < 3; i++) { | |
527 | fRowMin[i] = -1; | |
528 | fRowMax[i] = -1; | |
529 | fColMax[i] = -1; | |
530 | fColMin[i] = -1; | |
531 | fNnZ[i] = -1; | |
532 | fNnRphi[i] = -1; | |
533 | fNfragZ[i] = -1; | |
534 | fNfragRphi[i] = -1; | |
535 | fXbins[i] = -1; | |
536 | } | |
537 | ||
538 | // Local database to be changed | |
77566f2a | 539 | fRebin = 1; |
540 | ||
541 | } | |
542 | ||
8ec526a4 | 543 | //____________Functions fit Online CH2d________________________________________ |
544 | Bool_t AliTRDCalibra::FitCHOnline(TH2I *ch) | |
77566f2a | 545 | { |
546 | // | |
8ec526a4 | 547 | // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each |
548 | // calibration group normalized the resulted coefficients (to 1 normally) | |
549 | // and write the results in a tree | |
77566f2a | 550 | // |
77566f2a | 551 | |
8ec526a4 | 552 | // Number of Xbins (detectors or groups of pads) |
553 | TAxis *xch = ch->GetXaxis(); | |
554 | Int_t nbins = xch->GetNbins(); | |
555 | TAxis *yph = ch->GetYaxis(); | |
556 | Int_t nybins = yph->GetNbins(); | |
9f4780aa | 557 | if (!InitFit(nbins,0)) { |
77566f2a | 558 | return kFALSE; |
559 | } | |
8ec526a4 | 560 | fStatisticMean = 0.0; |
561 | fNumberFit = 0; | |
e5c60cc7 | 562 | fNumberEnt = 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 | } | |
e5c60cc7 | 592 | if (nentries > 0) { |
593 | fNumberEnt++; | |
594 | } | |
595 | ||
8ec526a4 | 596 | // Rebin and statistic stuff |
597 | // Rebin | |
598 | if (fRebin > 1) { | |
599 | projch = ReBin((TH1I *) projch); | |
600 | } | |
601 | // This detector has not enough statistics or was off | |
602 | if (nentries < fMinEntries) { | |
603 | // Fill with the default infos | |
77566f2a | 604 | NotEnoughStatistic(idect,0); |
8ec526a4 | 605 | // Memory!!! |
606 | if (fDebug != 2) { | |
77566f2a | 607 | delete projch; |
608 | } | |
609 | continue; | |
610 | } | |
611 | ||
8ec526a4 | 612 | // Statistics of the group fitted |
613 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
614 | fStatisticMean += nentries; | |
615 | fNumberFit++; | |
77566f2a | 616 | |
8ec526a4 | 617 | // Method Mean and fit |
618 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
619 | FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
620 | // Method fit bis | |
621 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
622 | if (fFitChargeBisOn) { | |
623 | FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
77566f2a | 624 | } |
625 | ||
8ec526a4 | 626 | // Visualise the detector for fDebug 3 or 4 |
627 | // Here is the reconstruction of the pad and row group is used! | |
628 | if (fDebug >= 3) { | |
629 | FillCoefChargeDB(); | |
630 | } | |
631 | // Fill Infos Fit | |
77566f2a | 632 | FillInfosFit(idect,0); |
633 | ||
8ec526a4 | 634 | // Memory!!! |
635 | if (fDebug != 2) { | |
77566f2a | 636 | delete projch; |
637 | } | |
638 | ||
8ec526a4 | 639 | } // Boucle object |
77566f2a | 640 | |
8ec526a4 | 641 | // Normierungcharge |
642 | if (fDebug != 2) { | |
643 | NormierungCharge(); | |
644 | } | |
77566f2a | 645 | |
8ec526a4 | 646 | // Plot |
647 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
648 | if ((fDebug == 1) || | |
649 | (fDebug == 4)) { | |
9f4780aa | 650 | PlotWriteCH(); |
8ec526a4 | 651 | } |
652 | if ((fDebug == 4) || | |
653 | (fDebug == 3)) { | |
77566f2a | 654 | PlotCHDB(); |
8ec526a4 | 655 | } |
77566f2a | 656 | |
8ec526a4 | 657 | // Mean Statistic |
658 | if (fNumberFit > 0) { | |
659 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean/fNumberFit)); | |
660 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 661 | } |
662 | else { | |
663 | AliInfo("There is no fit!"); | |
664 | } | |
665 | ||
8ec526a4 | 666 | // Write the things! |
77566f2a | 667 | ConvertVectorFitCHTree(); |
8ec526a4 | 668 | if (fWriteCoef[0]) { |
77566f2a | 669 | WriteFitInfos(0); |
670 | } | |
8ec526a4 | 671 | |
77566f2a | 672 | return kTRUE; |
673 | ||
674 | } | |
77566f2a | 675 | |
8ec526a4 | 676 | //____________Functions fit Online CH2d________________________________________ |
77566f2a | 677 | Bool_t AliTRDCalibra::FitCHOnline() |
678 | { | |
679 | // | |
8ec526a4 | 680 | // Reconstruct a 1D histo from the vectorCH for each calibration group, |
681 | // fit the histo, normalized the resulted coefficients (to 1 normally) | |
682 | // and write the results in a tree | |
77566f2a | 683 | // |
684 | ||
8ec526a4 | 685 | // Number of Xbins (detectors or groups of pads) |
9f4780aa | 686 | if (!InitFit(0,0)) { |
77566f2a | 687 | return kFALSE; |
688 | } | |
8ec526a4 | 689 | fStatisticMean = 0.0; |
690 | fNumberFit = 0; | |
e5c60cc7 | 691 | fNumberEnt = 0; |
77566f2a | 692 | |
8ec526a4 | 693 | // Init fCountDet and fCount |
694 | InitfCountDetAndfCount(0); | |
77566f2a | 695 | |
8ec526a4 | 696 | // Beginning of the loop between dect1 and dect2 |
697 | for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) { | |
77566f2a | 698 | |
8ec526a4 | 699 | // Search if the group is in the VectorCH |
77566f2a | 700 | Int_t place = SearchInVector(idect,0); |
701 | ||
8ec526a4 | 702 | // Is in |
703 | TH1F *projch = 0x0; | |
77566f2a | 704 | TString name("CH"); |
705 | name += idect; | |
8ec526a4 | 706 | if (place != -1) { |
707 | // Variable | |
708 | AliTRDCTInfo *fCHInfo = new AliTRDCTInfo(); | |
709 | // Retrieve | |
710 | fCHInfo = ((AliTRDCTInfo *) fVectorCH->At(place)); | |
711 | projch = ConvertVectorCTHisto(fCHInfo,(const char *) name); | |
77566f2a | 712 | projch->SetDirectory(0); |
713 | delete fCHInfo; | |
714 | } | |
715 | ||
8ec526a4 | 716 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
717 | UpdatefCountDetAndfCount(idect,0); | |
77566f2a | 718 | |
8ec526a4 | 719 | // Reconstruction of the row and pad group: rowmin, row max ... |
720 | ReconstructFitRowMinRowMax(idect,0); | |
77566f2a | 721 | |
8ec526a4 | 722 | // Number of entries |
77566f2a | 723 | Double_t nentries = 0.0; |
9244c78b | 724 | if (projch) { |
725 | for (Int_t k = 0; k < fNumberBinCharge; k++) { | |
726 | nentries += projch->GetBinContent(k+1); | |
727 | } | |
77566f2a | 728 | } |
e5c60cc7 | 729 | if (nentries > 0) { |
730 | fNumberEnt++; | |
731 | } | |
77566f2a | 732 | |
8ec526a4 | 733 | // Rebin and statistic stuff |
734 | // Rebin | |
735 | if ((fRebin > 1) && | |
736 | (place != -1)) { | |
737 | projch = ReBin((TH1F *) projch); | |
738 | } | |
77566f2a | 739 | |
8ec526a4 | 740 | // This detector has not enough statistics or was not found in VectorCH |
741 | if ((place == -1) || | |
742 | ((place != -1) && | |
743 | (nentries < fMinEntries))) { | |
77566f2a | 744 | |
8ec526a4 | 745 | // Fill with the default infos |
77566f2a | 746 | NotEnoughStatistic(idect,0); |
747 | ||
8ec526a4 | 748 | // Memory!!! |
749 | if (fDebug != 2) { | |
77566f2a | 750 | delete projch; |
751 | } | |
752 | ||
753 | continue; | |
8ec526a4 | 754 | |
77566f2a | 755 | } |
756 | ||
8ec526a4 | 757 | // Statistic of the histos fitted |
758 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
759 | fNumberFit++; | |
760 | fStatisticMean += nentries; | |
77566f2a | 761 | |
8ec526a4 | 762 | // Method Mean and fit |
763 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
764 | FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
77566f2a | 765 | |
8ec526a4 | 766 | // Method fit bis |
767 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
768 | if (fFitChargeBisOn) { | |
769 | FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0])); | |
77566f2a | 770 | } |
771 | ||
8ec526a4 | 772 | // Visualise the detector for fDebug 3 or 4 |
773 | // Here is the reconstruction of the pad and row group is used! | |
774 | if (fDebug >= 3) { | |
775 | FillCoefChargeDB(); | |
776 | } | |
77566f2a | 777 | |
8ec526a4 | 778 | // Fill Infos Fit |
77566f2a | 779 | FillInfosFit(idect,0); |
780 | ||
8ec526a4 | 781 | // Memory!!! |
782 | if (fDebug != 2) { | |
77566f2a | 783 | delete projch; |
784 | } | |
77566f2a | 785 | |
8ec526a4 | 786 | } // Boucle object |
77566f2a | 787 | |
8ec526a4 | 788 | // Normierungcharge |
789 | if (fDebug != 2) { | |
790 | NormierungCharge(); | |
791 | } | |
9f4780aa | 792 | |
77566f2a | 793 | |
8ec526a4 | 794 | // Plot |
795 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
796 | if ((fDebug == 1) || | |
797 | (fDebug == 4)){ | |
9f4780aa | 798 | PlotWriteCH(); |
77566f2a | 799 | } |
8ec526a4 | 800 | if((fDebug == 4) || |
801 | (fDebug == 3)){ | |
77566f2a | 802 | PlotCHDB(); |
803 | } | |
804 | ||
8ec526a4 | 805 | // Mean Statistics |
806 | if (fNumberFit > 0) { | |
807 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
808 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 809 | } |
810 | else { | |
811 | AliInfo("There is no fit!"); | |
812 | } | |
813 | ||
8ec526a4 | 814 | // Write the things! |
77566f2a | 815 | ConvertVectorFitCHTree(); |
8ec526a4 | 816 | if (fWriteCoef[0]) { |
77566f2a | 817 | WriteFitInfos(0); |
818 | } | |
8ec526a4 | 819 | |
77566f2a | 820 | return kTRUE; |
821 | ||
822 | } | |
77566f2a | 823 | |
8ec526a4 | 824 | //____________Functions fit Online CH2d________________________________________ |
77566f2a | 825 | Bool_t AliTRDCalibra::FitCHOnline(TTree *tree) |
826 | { | |
827 | // | |
8ec526a4 | 828 | // Look if the calibration group can be found in the tree, if yes take the |
829 | // histo, fit it, normalized the resulted coefficients (to 1 normally) and | |
830 | // write the results in a tree | |
77566f2a | 831 | // |
832 | ||
8ec526a4 | 833 | // Number of Xbins (detectors or groups of pads) |
9f4780aa | 834 | if (!InitFit(0,0)) { |
77566f2a | 835 | return kFALSE; |
836 | } | |
8ec526a4 | 837 | fStatisticMean = 0.0; |
838 | fNumberFit = 0; | |
e5c60cc7 | 839 | fNumberEnt = 0; |
77566f2a | 840 | |
8ec526a4 | 841 | // For memory |
842 | if (fVectorCH) { | |
843 | fVectorCH->Clear(); | |
77566f2a | 844 | } |
8ec526a4 | 845 | if (fPlaCH) { |
846 | fPlaCH->Clear(); | |
77566f2a | 847 | } |
8ec526a4 | 848 | |
849 | // Init fCountDet and fCount | |
850 | InitfCountDetAndfCount(0); | |
851 | TH1F *projch = 0x0; | |
77566f2a | 852 | tree->SetBranchAddress("histo",&projch); |
8ec526a4 | 853 | TObjArray *vectorplace = ConvertTreeVector(tree); |
77566f2a | 854 | |
8ec526a4 | 855 | // Beginning of the loop between dect1 and dect2 |
856 | for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) { | |
77566f2a | 857 | |
858 | //Search if the group is in the VectorCH | |
859 | Int_t place = SearchInTreeVector(vectorplace,idect); | |
860 | ||
8ec526a4 | 861 | // Is in |
862 | if (place != -1) { | |
863 | // Variable | |
77566f2a | 864 | tree->GetEntry(place); |
865 | } | |
866 | ||
8ec526a4 | 867 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
868 | UpdatefCountDetAndfCount(idect,0); | |
77566f2a | 869 | |
8ec526a4 | 870 | // Reconstruction of the row and pad group: rowmin, row max ... |
871 | ReconstructFitRowMinRowMax(idect,0); | |
77566f2a | 872 | |
8ec526a4 | 873 | // Number of entries |
77566f2a | 874 | Double_t nentries = 0.0; |
9244c78b | 875 | if (projch) { |
876 | for (Int_t k = 0; k < projch->GetXaxis()->GetNbins(); k++) { | |
877 | nentries += projch->GetBinContent(k+1); | |
878 | } | |
e5c60cc7 | 879 | } |
880 | if (nentries > 0) { | |
881 | fNumberEnt++; | |
882 | } | |
9244c78b | 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 | |
77566f2a | 934 | |
8ec526a4 | 935 | // Plot |
936 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
937 | if ((fDebug == 1) || | |
938 | (fDebug == 4)){ | |
9f4780aa | 939 | PlotWriteCH(); |
8ec526a4 | 940 | } |
941 | if ((fDebug == 4) || | |
942 | (fDebug == 3)){ | |
77566f2a | 943 | PlotCHDB(); |
8ec526a4 | 944 | } |
77566f2a | 945 | |
8ec526a4 | 946 | // Mean Statistic |
947 | if (fNumberFit > 0) { | |
948 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
949 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 950 | } |
951 | else { | |
952 | AliInfo("There is no fit!"); | |
953 | } | |
954 | ||
8ec526a4 | 955 | // Write the things! |
77566f2a | 956 | ConvertVectorFitCHTree(); |
8ec526a4 | 957 | if (fWriteCoef[0]) { |
77566f2a | 958 | WriteFitInfos(0); |
959 | } | |
8ec526a4 | 960 | |
77566f2a | 961 | return kTRUE; |
962 | ||
963 | } | |
77566f2a | 964 | |
8ec526a4 | 965 | //________________functions fit Online PH2d____________________________________ |
966 | Bool_t AliTRDCalibra::FitPHOnline(TProfile2D *ph) | |
77566f2a | 967 | { |
968 | // | |
8ec526a4 | 969 | // Take the 1D profiles (average pulse height), projections of the 2D PH |
970 | // on the Xaxis, for each calibration group | |
971 | // Fit or use the slope of the average pulse height to reconstruct the | |
972 | // drift velocity write the results in a tree | |
77566f2a | 973 | // A first calibration of T0 is also made using the same method (slope method) |
974 | // | |
975 | ||
8ec526a4 | 976 | // Number of Xbins (detectors or groups of pads) |
977 | TAxis *xph = ph->GetXaxis(); | |
978 | TAxis *yph = ph->GetYaxis(); | |
979 | Int_t nbins = xph->GetNbins(); | |
980 | Int_t nybins = yph->GetNbins(); | |
9f4780aa | 981 | if (!InitFit(nbins,1)) { |
77566f2a | 982 | return kFALSE; |
983 | } | |
8ec526a4 | 984 | fStatisticMean = 0.0; |
985 | fNumberFit = 0; | |
e5c60cc7 | 986 | fNumberEnt = 0; |
77566f2a | 987 | |
8ec526a4 | 988 | // For memory |
989 | if (fVectorPH) { | |
990 | fVectorPH->Clear(); | |
991 | } | |
992 | if (fPlaPH) { | |
993 | fPlaPH->Clear(); | |
77566f2a | 994 | } |
77566f2a | 995 | |
8ec526a4 | 996 | // Init fCountDet and fCount |
997 | InitfCountDetAndfCount(1); | |
998 | ||
999 | // Beginning of the loop | |
1000 | for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) { | |
77566f2a | 1001 | |
8ec526a4 | 1002 | TH1D *projph = (TH1D *) ph->ProjectionY("projph",idect+1,idect+1,(Option_t *) "e"); |
77566f2a | 1003 | projph->SetDirectory(0); |
1004 | ||
8ec526a4 | 1005 | // Number of entries for this calibration group |
77566f2a | 1006 | Double_t nentries = 0; |
8ec526a4 | 1007 | for (Int_t k = 0; k < nybins; k++) { |
1008 | nentries += ph->GetBinEntries(ph->GetBin(idect+1,k+1)); | |
77566f2a | 1009 | } |
e5c60cc7 | 1010 | if (nentries > 0) { |
1011 | fNumberEnt++; | |
1012 | } | |
1013 | ||
8ec526a4 | 1014 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1015 | UpdatefCountDetAndfCount(idect,1); | |
77566f2a | 1016 | |
8ec526a4 | 1017 | // Reconstruction of the row and pad group: rowmin, row max ... |
1018 | ReconstructFitRowMinRowMax(idect,1); | |
77566f2a | 1019 | |
8ec526a4 | 1020 | // Rebin and statistic stuff |
1021 | // This detector has not enough statistics or was off | |
1022 | if (nentries < fMinEntries) { | |
77566f2a | 1023 | |
8ec526a4 | 1024 | // Fill with the default values |
77566f2a | 1025 | NotEnoughStatistic(idect,1); |
1026 | ||
8ec526a4 | 1027 | // Memory!!! |
1028 | if (fDebug != 2) { | |
77566f2a | 1029 | delete projph; |
1030 | } | |
1031 | ||
1032 | continue; | |
8ec526a4 | 1033 | |
77566f2a | 1034 | } |
1035 | ||
8ec526a4 | 1036 | // Statistics of the histos fitted |
1037 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
1038 | fNumberFit++; | |
1039 | fStatisticMean += nentries; | |
77566f2a | 1040 | |
8ec526a4 | 1041 | // Calcul of "real" coef |
1042 | CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
1043 | CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
77566f2a | 1044 | |
8ec526a4 | 1045 | // Method Mean and fit |
1046 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1047 | FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1048 | |
8ec526a4 | 1049 | // Method fit bis |
1050 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1051 | if (fFitPHOn) { | |
1052 | FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1053 | } |
1054 | ||
8ec526a4 | 1055 | // Visualise the detector for fDebug 3 or 4 |
1056 | // Here is the reconstruction of the pad and row group is used! | |
1057 | if (fDebug >= 3) { | |
77566f2a | 1058 | FillCoefVdriftDB(); |
1059 | FillCoefT0DB(); | |
1060 | } | |
1061 | ||
8ec526a4 | 1062 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
1063 | FillInfosFit(idect,1); | |
77566f2a | 1064 | |
8ec526a4 | 1065 | // Memory!!! |
1066 | if (fDebug != 2) { | |
77566f2a | 1067 | delete projph; |
1068 | } | |
1069 | ||
8ec526a4 | 1070 | } // Boucle object |
77566f2a | 1071 | |
9f4780aa | 1072 | |
8ec526a4 | 1073 | // Plot |
1074 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
1075 | if ((fDebug == 1) || | |
1076 | (fDebug == 4)) { | |
9f4780aa | 1077 | PlotWritePH(); |
1078 | PlotWriteT0(); | |
8ec526a4 | 1079 | } |
1080 | if ((fDebug == 4) || | |
1081 | (fDebug == 3)) { | |
77566f2a | 1082 | PlotPHDB(); |
1083 | PlotT0DB(); | |
8ec526a4 | 1084 | } |
77566f2a | 1085 | |
8ec526a4 | 1086 | // Mean Statistic |
1087 | if (fNumberFit > 0) { | |
1088 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1089 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1090 | } |
1091 | else { | |
1092 | AliInfo("There is no fit!"); | |
1093 | } | |
1094 | ||
8ec526a4 | 1095 | // Write the things! |
1096 | if(fWriteCoef[1]) { | |
77566f2a | 1097 | WriteFitInfos(1); |
1098 | } | |
8ec526a4 | 1099 | |
77566f2a | 1100 | return kTRUE; |
1101 | ||
1102 | } | |
77566f2a | 1103 | |
8ec526a4 | 1104 | //____________Functions fit Online PH2d________________________________________ |
77566f2a | 1105 | Bool_t AliTRDCalibra::FitPHOnline() |
1106 | { | |
1107 | // | |
8ec526a4 | 1108 | // Reconstruct the average pulse height from the vectorPH for each |
1109 | // calibration group | |
1110 | // Fit or use the slope of the average pulse height to reconstruct the | |
1111 | // drift velocity write the results in a tree | |
77566f2a | 1112 | // A first calibration of T0 is also made using the same method (slope method) |
1113 | // | |
77566f2a | 1114 | |
8ec526a4 | 1115 | // Number of Xbins (detectors or groups of pads) |
9f4780aa | 1116 | if (!InitFit(0,1)) { |
77566f2a | 1117 | return kFALSE; |
1118 | } | |
8ec526a4 | 1119 | fStatisticMean = 0.0; |
1120 | fNumberFit = 0; | |
e5c60cc7 | 1121 | fNumberEnt = 0; |
77566f2a | 1122 | |
8ec526a4 | 1123 | // Init fCountDet and fCount |
1124 | InitfCountDetAndfCount(1); | |
77566f2a | 1125 | |
8ec526a4 | 1126 | // Beginning of the loop |
1127 | for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) { | |
77566f2a | 1128 | |
8ec526a4 | 1129 | // Search if the group is in the VectorCH |
77566f2a | 1130 | Int_t place = SearchInVector(idect,1); |
1131 | ||
8ec526a4 | 1132 | // Is in |
1133 | TH1F *projph = 0x0; | |
77566f2a | 1134 | TString name("PH"); |
1135 | name += idect; | |
8ec526a4 | 1136 | if (place != -1) { |
e5c60cc7 | 1137 | //Entries |
1138 | fNumberEnt++; | |
8ec526a4 | 1139 | // Variable |
1140 | AliTRDPInfo *fPHInfo = new AliTRDPInfo(); | |
1141 | // Retrieve | |
1142 | fPHInfo = (AliTRDPInfo *) fVectorPH->At(place); | |
1143 | projph = CorrectTheError((TGraphErrors *) ConvertVectorPHisto(fPHInfo,(const char *) name)); | |
77566f2a | 1144 | projph->SetDirectory(0); |
1145 | delete fPHInfo; | |
1146 | } | |
1147 | ||
8ec526a4 | 1148 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1149 | UpdatefCountDetAndfCount(idect,1); | |
77566f2a | 1150 | |
8ec526a4 | 1151 | // Reconstruction of the row and pad group: rowmin, row max ... |
1152 | ReconstructFitRowMinRowMax(idect,1); | |
77566f2a | 1153 | |
8ec526a4 | 1154 | // Rebin and statistic stuff |
1155 | // This detector has not enough statistics or was off | |
1156 | if ((place == -1) || | |
1157 | ((place != -1) && | |
1158 | (fEntriesCurrent < fMinEntries))) { | |
77566f2a | 1159 | |
8ec526a4 | 1160 | // Fill with the default values |
77566f2a | 1161 | NotEnoughStatistic(idect,1); |
1162 | ||
8ec526a4 | 1163 | // Memory!!! |
1164 | if (fDebug != 2) { | |
77566f2a | 1165 | delete projph; |
1166 | } | |
8ec526a4 | 1167 | |
77566f2a | 1168 | continue; |
8ec526a4 | 1169 | |
77566f2a | 1170 | } |
1171 | ||
8ec526a4 | 1172 | // Statistic of the histos fitted |
1173 | AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent)); | |
1174 | fNumberFit++; | |
1175 | fStatisticMean += fEntriesCurrent; | |
77566f2a | 1176 | |
8ec526a4 | 1177 | // Calcul of "real" coef |
1178 | CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
1179 | CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
77566f2a | 1180 | |
8ec526a4 | 1181 | // Method Mean and fit |
1182 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1183 | FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1184 | |
8ec526a4 | 1185 | // Method fit bis |
1186 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1187 | if (fFitPHOn) { | |
1188 | FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1189 | } |
1190 | ||
8ec526a4 | 1191 | // Visualise the detector for fDebug 3 or 4 |
1192 | // Here is the reconstruction of the pad and row group is used! | |
1193 | if (fDebug >= 3) { | |
77566f2a | 1194 | FillCoefVdriftDB(); |
1195 | FillCoefT0DB(); | |
1196 | } | |
1197 | ||
8ec526a4 | 1198 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1199 | FillInfosFit(idect,1); |
1200 | ||
8ec526a4 | 1201 | // Memory!!! |
1202 | if (fDebug != 2) { | |
77566f2a | 1203 | delete projph; |
1204 | } | |
1205 | ||
8ec526a4 | 1206 | } // Boucle object |
77566f2a | 1207 | |
9f4780aa | 1208 | |
8ec526a4 | 1209 | // Plot |
1210 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
1211 | if ((fDebug == 1) || | |
1212 | (fDebug == 4)) { | |
9f4780aa | 1213 | PlotWritePH(); |
1214 | PlotWriteT0(); | |
77566f2a | 1215 | } |
8ec526a4 | 1216 | if ((fDebug == 4) || |
1217 | (fDebug == 3)) { | |
77566f2a | 1218 | PlotPHDB(); |
1219 | PlotT0DB(); | |
1220 | } | |
1221 | ||
8ec526a4 | 1222 | // Mean Statistic |
1223 | if (fNumberFit > 0) { | |
1224 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1225 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1226 | } |
1227 | else { | |
1228 | AliInfo("There is no fit!"); | |
1229 | } | |
1230 | ||
8ec526a4 | 1231 | // Write the things! |
1232 | if (fWriteCoef[1]) { | |
77566f2a | 1233 | WriteFitInfos(1); |
1234 | } | |
8ec526a4 | 1235 | |
77566f2a | 1236 | return kTRUE; |
1237 | ||
1238 | } | |
1239 | ||
8ec526a4 | 1240 | //____________Functions fit Online PH2d________________________________________ |
77566f2a | 1241 | Bool_t AliTRDCalibra::FitPHOnline(TTree *tree) |
1242 | { | |
1243 | // | |
8ec526a4 | 1244 | // Look if the calibration group can be found in the tree, if yes take the |
1245 | // histo, fit it, and write the results in a tree | |
77566f2a | 1246 | // A first calibration of T0 is also made using the same method (slope method) |
1247 | // | |
77566f2a | 1248 | |
8ec526a4 | 1249 | // Number of Xbins (detectors or groups of pads) |
9f4780aa | 1250 | if (!InitFit(0,1)) { |
77566f2a | 1251 | return kFALSE; |
1252 | } | |
8ec526a4 | 1253 | fStatisticMean = 0.0; |
1254 | fNumberFit = 0; | |
e5c60cc7 | 1255 | fNumberEnt = 0; |
8ec526a4 | 1256 | |
1257 | // For memory | |
1258 | if (fVectorPH) { | |
1259 | fVectorPH->Clear(); | |
77566f2a | 1260 | } |
8ec526a4 | 1261 | if (fPlaPH) { |
1262 | fPlaPH->Clear(); | |
77566f2a | 1263 | } |
1264 | ||
8ec526a4 | 1265 | // Init fCountDet and fCount |
1266 | InitfCountDetAndfCount(1); | |
1267 | TGraphErrors *projphtree = 0x0; | |
77566f2a | 1268 | tree->SetBranchAddress("histo",&projphtree); |
8ec526a4 | 1269 | TObjArray *vectorplace = ConvertTreeVector(tree); |
77566f2a | 1270 | |
8ec526a4 | 1271 | // Beginning of the loop |
1272 | for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) { | |
77566f2a | 1273 | |
8ec526a4 | 1274 | // Search if the group is in the VectorCH |
77566f2a | 1275 | Int_t place = SearchInTreeVector(vectorplace,idect); |
1276 | ||
1277 | TH1F *projph = 0x0; | |
8ec526a4 | 1278 | // Is in |
1279 | if (place != -1) { | |
e5c60cc7 | 1280 | //Entries |
1281 | fNumberEnt++; | |
8ec526a4 | 1282 | // Variable |
77566f2a | 1283 | tree->GetEntry(place); |
1284 | projph = CorrectTheError(projphtree); | |
1285 | } | |
1286 | ||
8ec526a4 | 1287 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1288 | UpdatefCountDetAndfCount(idect,1); | |
77566f2a | 1289 | |
8ec526a4 | 1290 | // Reconstruction of the row and pad group: rowmin, row max ... |
1291 | ReconstructFitRowMinRowMax(idect,1); | |
77566f2a | 1292 | |
8ec526a4 | 1293 | // Rebin and statistic stuff |
1294 | // This detector has not enough statistics or was off | |
1295 | if((place == -1) || | |
1296 | ((place != -1) && | |
1297 | (fEntriesCurrent < fMinEntries))) { | |
77566f2a | 1298 | |
8ec526a4 | 1299 | // Fill with the default values |
77566f2a | 1300 | NotEnoughStatistic(idect,1); |
1301 | ||
8ec526a4 | 1302 | // Memory!!! |
1303 | if (fDebug != 2) { | |
77566f2a | 1304 | delete projph; |
1305 | } | |
1306 | ||
1307 | continue; | |
8ec526a4 | 1308 | |
77566f2a | 1309 | } |
1310 | ||
8ec526a4 | 1311 | // Statistics of the histos fitted |
1312 | AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent)); | |
1313 | fNumberFit++; | |
1314 | fStatisticMean += fEntriesCurrent; | |
77566f2a | 1315 | |
8ec526a4 | 1316 | // Calcul of "real" coef |
1317 | CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
1318 | CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1])); | |
77566f2a | 1319 | |
8ec526a4 | 1320 | // Method Mean and fit |
1321 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1322 | FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
1323 | // Method fit bis | |
1324 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1325 | if (fFitPHOn) { | |
1326 | FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1])); | |
77566f2a | 1327 | } |
1328 | ||
8ec526a4 | 1329 | // Visualise the detector for fDebug 3 or 4 |
1330 | // Here is the reconstruction of the pad and row group is used! | |
1331 | if (fDebug >= 3) { | |
77566f2a | 1332 | FillCoefVdriftDB(); |
1333 | FillCoefT0DB(); | |
1334 | } | |
1335 | ||
8ec526a4 | 1336 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1337 | FillInfosFit(idect,1); |
77566f2a | 1338 | |
8ec526a4 | 1339 | // Memory!!! |
1340 | if (fDebug != 2) { | |
77566f2a | 1341 | delete projph; |
1342 | } | |
77566f2a | 1343 | |
8ec526a4 | 1344 | } // Boucle object |
77566f2a | 1345 | |
8ec526a4 | 1346 | // Plot |
1347 | // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot | |
1348 | if ((fDebug == 1) || | |
1349 | (fDebug == 4)){ | |
9f4780aa | 1350 | PlotWritePH(); |
1351 | PlotWriteT0(); | |
77566f2a | 1352 | } |
8ec526a4 | 1353 | if ((fDebug == 4) || |
1354 | (fDebug == 3)){ | |
77566f2a | 1355 | PlotPHDB(); |
1356 | PlotT0DB(); | |
1357 | } | |
1358 | ||
8ec526a4 | 1359 | // Mean Statistics |
1360 | if (fNumberFit > 0) { | |
1361 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1362 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1363 | } |
1364 | else { | |
1365 | AliInfo("There is no fit!"); | |
1366 | } | |
1367 | ||
8ec526a4 | 1368 | // Write the things! |
1369 | if (fWriteCoef[1]) { | |
77566f2a | 1370 | WriteFitInfos(1); |
1371 | } | |
8ec526a4 | 1372 | |
77566f2a | 1373 | return kTRUE; |
1374 | ||
1375 | } | |
77566f2a | 1376 | |
8ec526a4 | 1377 | //____________Functions fit Online PRF2d_______________________________________ |
1378 | Bool_t AliTRDCalibra::FitPRFOnline(TProfile2D *prf) | |
77566f2a | 1379 | { |
1380 | // | |
8ec526a4 | 1381 | // Take the 1D profiles (pad response function), projections of the 2D PRF |
1382 | // on the Xaxis, for each calibration group | |
1383 | // Fit with a gaussian to reconstruct the sigma of the pad response function | |
1384 | // write the results in a tree | |
77566f2a | 1385 | // |
1386 | ||
8ec526a4 | 1387 | // Number of Xbins (detectors or groups of pads) |
1388 | TAxis *xprf = prf->GetXaxis(); | |
1389 | TAxis *yprf = prf->GetYaxis(); | |
1390 | Int_t nybins = yprf->GetNbins(); | |
1391 | Int_t nbins = xprf->GetNbins(); | |
9f4780aa | 1392 | if (!InitFit(nbins,2)) { |
77566f2a | 1393 | return kFALSE; |
1394 | } | |
8ec526a4 | 1395 | fStatisticMean = 0.0; |
1396 | fNumberFit = 0; | |
e5c60cc7 | 1397 | fNumberEnt = 0; |
77566f2a | 1398 | |
8ec526a4 | 1399 | // For memory |
1400 | if (fVectorPRF) { | |
1401 | fVectorPRF->Clear(); | |
1402 | } | |
1403 | if (fPlaPRF) { | |
1404 | fPlaPRF->Clear(); | |
77566f2a | 1405 | } |
77566f2a | 1406 | |
8ec526a4 | 1407 | // Init fCountDet and fCount |
1408 | InitfCountDetAndfCount(2); | |
77566f2a | 1409 | |
8ec526a4 | 1410 | // Beginning of the loop |
1411 | for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) { | |
77566f2a | 1412 | |
8ec526a4 | 1413 | TH1D *projprf = (TH1D *) prf->ProjectionY("projprf",idect+1,idect+1,(Option_t *) "e"); |
77566f2a | 1414 | projprf->SetDirectory(0); |
1415 | ||
8ec526a4 | 1416 | // Number of entries for this calibration group |
77566f2a | 1417 | Double_t nentries = 0; |
8ec526a4 | 1418 | for (Int_t k = 0; k < nybins; k++) { |
1419 | nentries += prf->GetBinEntries(prf->GetBin(idect+1,k+1)); | |
77566f2a | 1420 | } |
e5c60cc7 | 1421 | if(nentries > 0) fNumberEnt++; |
77566f2a | 1422 | |
8ec526a4 | 1423 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1424 | UpdatefCountDetAndfCount(idect,2); | |
77566f2a | 1425 | |
8ec526a4 | 1426 | // Reconstruction of the row and pad group: rowmin, row max ... |
1427 | ReconstructFitRowMinRowMax(idect,2); | |
77566f2a | 1428 | |
8ec526a4 | 1429 | // Rebin and statistic stuff |
1430 | // This detector has not enough statistics or was off | |
1431 | if (nentries < fMinEntries) { | |
77566f2a | 1432 | |
8ec526a4 | 1433 | // Fill with the default values |
77566f2a | 1434 | NotEnoughStatistic(idect,2); |
1435 | ||
8ec526a4 | 1436 | // Memory! |
1437 | if (fDebug != 2) { | |
77566f2a | 1438 | delete projprf; |
1439 | } | |
1440 | ||
1441 | continue; | |
8ec526a4 | 1442 | |
77566f2a | 1443 | } |
1444 | ||
8ec526a4 | 1445 | // Statistics of the histos fitted |
1446 | AliInfo(Form("For the group number %d there are %f stats",idect,nentries)); | |
1447 | fNumberFit++; | |
1448 | fStatisticMean += nentries; | |
77566f2a | 1449 | |
8ec526a4 | 1450 | // Calcul of "real" coef |
1451 | if ((fDebug == 1) || | |
1452 | (fDebug == 4)) { | |
1453 | CalculPRFCoefMean(fCountDet[2],(Int_t) (idect - fDect1[2])); | |
77566f2a | 1454 | } |
1455 | ||
8ec526a4 | 1456 | // Method Mean and fit |
1457 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1458 | FitPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2])); | |
77566f2a | 1459 | |
8ec526a4 | 1460 | // Visualise the detector for fDebug 3 or 4 |
1461 | // Here is the reconstruction of the pad and row group is used! | |
1462 | if (fDebug >= 3) { | |
1463 | FillCoefPRFDB(); | |
1464 | } | |
77566f2a | 1465 | |
8ec526a4 | 1466 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1467 | FillInfosFit(idect,2); |
1468 | ||
8ec526a4 | 1469 | // Memory!!! |
1470 | if (fDebug != 2) { | |
77566f2a | 1471 | delete projprf; |
1472 | } | |
1473 | ||
8ec526a4 | 1474 | } // Boucle object |
77566f2a | 1475 | |
8ec526a4 | 1476 | // Plot |
1477 | // No plot, 1 and 4 error plot, 3 and 4 DB plot | |
1478 | if ((fDebug == 1) || | |
1479 | (fDebug == 4)) { | |
9f4780aa | 1480 | PlotWritePRF(); |
8ec526a4 | 1481 | } |
1482 | if ((fDebug == 4) || | |
1483 | (fDebug == 3)){ | |
77566f2a | 1484 | PlotPRFDB(); |
8ec526a4 | 1485 | } |
77566f2a | 1486 | |
8ec526a4 | 1487 | // Mean Statistic |
1488 | if (fNumberFit > 0) { | |
1489 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1490 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1491 | } |
1492 | else { | |
1493 | AliInfo("There is no fit!"); | |
1494 | } | |
1495 | ||
8ec526a4 | 1496 | // Write the things! |
1497 | if (fWriteCoef[2]) { | |
77566f2a | 1498 | WriteFitInfos(2); |
1499 | } | |
8ec526a4 | 1500 | |
77566f2a | 1501 | return kTRUE; |
1502 | ||
1503 | } | |
77566f2a | 1504 | |
8ec526a4 | 1505 | //____________Functions fit Online PRF2d_______________________________________ |
77566f2a | 1506 | Bool_t AliTRDCalibra::FitPRFOnline(TTree *tree) |
1507 | { | |
1508 | // | |
8ec526a4 | 1509 | // Look if the calibration group can be found in the tree, if yes take |
1510 | // the histo, fit it, and write the results in a tree | |
77566f2a | 1511 | // |
1512 | ||
8ec526a4 | 1513 | // Number of Xbins (detectors or groups of pads) |
9f4780aa | 1514 | if (!InitFit(0,2)) { |
77566f2a | 1515 | return kFALSE; |
1516 | } | |
8ec526a4 | 1517 | fStatisticMean = 0.0; |
1518 | fNumberFit = 0; | |
e5c60cc7 | 1519 | fNumberEnt = 0; |
77566f2a | 1520 | |
8ec526a4 | 1521 | // For memory |
1522 | if (fVectorPRF) { | |
1523 | fVectorPRF->Clear(); | |
1524 | } | |
1525 | if (fPlaPRF) { | |
1526 | fPlaPRF->Clear(); | |
77566f2a | 1527 | } |
1528 | ||
8ec526a4 | 1529 | // Init fCountDet and fCount |
1530 | InitfCountDetAndfCount(2); | |
1531 | TGraphErrors *projprftree = 0x0; | |
77566f2a | 1532 | tree->SetBranchAddress("histo",&projprftree); |
8ec526a4 | 1533 | TObjArray *vectorplace = ConvertTreeVector(tree); |
77566f2a | 1534 | |
8ec526a4 | 1535 | // Beginning of the loop |
1536 | for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) { | |
77566f2a | 1537 | |
8ec526a4 | 1538 | // Search if the group is in the VectorCH |
77566f2a | 1539 | Int_t place = SearchInTreeVector(vectorplace,idect); |
1540 | ||
8ec526a4 | 1541 | // Is in |
77566f2a | 1542 | TH1F *projprf = 0x0; |
8ec526a4 | 1543 | if (place != -1) { |
e5c60cc7 | 1544 | //Entries |
1545 | fNumberEnt++; | |
8ec526a4 | 1546 | // Variable |
77566f2a | 1547 | tree->GetEntry(place); |
1548 | projprf = CorrectTheError(projprftree); | |
1549 | } | |
1550 | ||
8ec526a4 | 1551 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1552 | UpdatefCountDetAndfCount(idect,2); | |
77566f2a | 1553 | |
8ec526a4 | 1554 | // Reconstruction of the row and pad group: rowmin, row max ... |
1555 | ReconstructFitRowMinRowMax(idect,2); | |
77566f2a | 1556 | |
8ec526a4 | 1557 | // Rebin and statistic stuff |
1558 | // This detector has not enough statistics or was off | |
1559 | if ((place == -1) || | |
1560 | ((place != -1) && | |
1561 | (fEntriesCurrent < fMinEntries))) { | |
77566f2a | 1562 | |
8ec526a4 | 1563 | // Fill with the default values |
77566f2a | 1564 | NotEnoughStatistic(idect,2); |
1565 | ||
8ec526a4 | 1566 | // Memory!!! |
1567 | if (fDebug != 2) { | |
77566f2a | 1568 | delete projprf; |
1569 | } | |
1570 | ||
1571 | continue; | |
8ec526a4 | 1572 | |
77566f2a | 1573 | } |
1574 | ||
8ec526a4 | 1575 | // Statistics of the histos fitted |
1576 | AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent)); | |
1577 | fNumberFit++; | |
1578 | fStatisticMean += fEntriesCurrent; | |
77566f2a | 1579 | |
8ec526a4 | 1580 | // Calcul of "real" coef |
1581 | if ((fDebug == 1) || | |
1582 | (fDebug == 4)){ | |
1583 | CalculPRFCoefMean(fCountDet[2],(Int_t) (idect - fDect1[2])); | |
1584 | } | |
1585 | ||
1586 | // Method Mean and fit | |
1587 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1588 | FitPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2])); | |
1589 | // Visualise the detector for fDebug 3 or 4 | |
1590 | // Here is the reconstruction of the pad and row group is used! | |
1591 | if (fDebug >= 3) { | |
1592 | FillCoefPRFDB(); | |
77566f2a | 1593 | } |
8ec526a4 | 1594 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1595 | FillInfosFit(idect,2); |
77566f2a | 1596 | |
8ec526a4 | 1597 | // Memory!!! |
1598 | if (fDebug != 2) { | |
77566f2a | 1599 | delete projprf; |
1600 | } | |
1601 | ||
8ec526a4 | 1602 | } // Boucle object |
77566f2a | 1603 | |
8ec526a4 | 1604 | // Plot |
1605 | // No plot, 1 and 4 error plot, 3 and 4 DB plot | |
1606 | if ((fDebug == 1) || | |
1607 | (fDebug == 4)){ | |
9f4780aa | 1608 | PlotWritePRF(); |
77566f2a | 1609 | } |
8ec526a4 | 1610 | if ((fDebug == 4) || |
1611 | (fDebug == 3)){ | |
77566f2a | 1612 | PlotPRFDB(); |
1613 | } | |
1614 | ||
8ec526a4 | 1615 | // Mean Statistics |
1616 | if (fNumberFit > 0) { | |
1617 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
1618 | fStatisticMean = fStatisticMean / fNumberFit; | |
77566f2a | 1619 | } |
1620 | else { | |
1621 | AliInfo("There is no fit!"); | |
1622 | } | |
1623 | ||
8ec526a4 | 1624 | // Write the things! |
1625 | if (fWriteCoef[2]) { | |
77566f2a | 1626 | WriteFitInfos(2); |
1627 | } | |
8ec526a4 | 1628 | |
77566f2a | 1629 | return kTRUE; |
1630 | ||
1631 | } | |
77566f2a | 1632 | |
8ec526a4 | 1633 | //____________Functions fit Online PRF2d_______________________________________ |
77566f2a | 1634 | Bool_t AliTRDCalibra::FitPRFOnline() |
1635 | { | |
1636 | // | |
8ec526a4 | 1637 | // Reconstruct the 1D histo (pad response function) from the vectorPRD for |
1638 | // each calibration group | |
1639 | // Fit with a gaussian to reconstruct the sigma of the pad response function | |
1640 | // write the results in a tree | |
77566f2a | 1641 | // |
1642 | ||
8ec526a4 | 1643 | // Number of Xbins (detectors or groups of pads) |
9f4780aa | 1644 | if (!InitFit(0,2)) { |
77566f2a | 1645 | return kFALSE; |
1646 | } | |
8ec526a4 | 1647 | fStatisticMean = 0.0; |
1648 | fNumberFit = 0; | |
e5c60cc7 | 1649 | fNumberEnt = 0; |
77566f2a | 1650 | |
8ec526a4 | 1651 | // Init fCountDet and fCount |
1652 | InitfCountDetAndfCount(2); | |
77566f2a | 1653 | |
8ec526a4 | 1654 | // Beginning of the loop |
1655 | for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) { | |
77566f2a | 1656 | |
8ec526a4 | 1657 | // Search if the group is in the VectorCH |
77566f2a | 1658 | Int_t place = SearchInVector(idect,2); |
1659 | ||
8ec526a4 | 1660 | // Is in |
1661 | TH1F *projprf = 0x0; | |
77566f2a | 1662 | TString name("PRF"); |
1663 | name += idect; | |
8ec526a4 | 1664 | if (place != -1) { |
e5c60cc7 | 1665 | //Entries |
1666 | fNumberEnt++; | |
8ec526a4 | 1667 | // Variable |
1668 | AliTRDPInfo *fPRFInfo = new AliTRDPInfo(); | |
1669 | // Retrieve | |
1670 | fPRFInfo = (AliTRDPInfo *) fVectorPRF->At(place); | |
1671 | projprf = CorrectTheError((TGraphErrors *) ConvertVectorPHisto(fPRFInfo,(const char *)name)); | |
77566f2a | 1672 | projprf->SetDirectory(0); |
1673 | delete fPRFInfo; | |
1674 | } | |
1675 | ||
8ec526a4 | 1676 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
1677 | UpdatefCountDetAndfCount(idect,2); | |
77566f2a | 1678 | |
8ec526a4 | 1679 | // Reconstruction of the row and pad group: rowmin, row max ... |
1680 | ReconstructFitRowMinRowMax(idect,2); | |
77566f2a | 1681 | |
8ec526a4 | 1682 | // Rebin and statistic stuff |
1683 | // This detector has not enough statistics or was off | |
1684 | if ((place == -1) || | |
1685 | ((place != -1) && | |
1686 | (fEntriesCurrent < fMinEntries))) { | |
77566f2a | 1687 | |
8ec526a4 | 1688 | // Fill with the default values |
77566f2a | 1689 | NotEnoughStatistic(idect,2); |
1690 | ||
8ec526a4 | 1691 | // Memory |
1692 | if (fDebug != 2) { | |
77566f2a | 1693 | delete projprf; |
1694 | } | |
77566f2a | 1695 | |
1696 | continue; | |
77566f2a | 1697 | |
8ec526a4 | 1698 | } |
77566f2a | 1699 | |
8ec526a4 | 1700 | // Statistic of the histos fitted |
1701 | AliInfo(Form("For the group number %d there are %d stats", idect,fEntriesCurrent)); | |
1702 | fNumberFit++; | |
1703 | fStatisticMean += fEntriesCurrent; | |
77566f2a | 1704 | |
8ec526a4 | 1705 | // Calcul of "real" coef |
1706 | if ((fDebug == 1) || | |
1707 | (fDebug == 4)) { | |
1708 | CalculPRFCoefMean(fCountDet[2],(Int_t) (idect-fDect1[2])); | |
1709 | } | |
77566f2a | 1710 | |
8ec526a4 | 1711 | // Method Mean and fit |
1712 | // idect is egal for fDebug = 0 and 2, only to fill the hist | |
1713 | FitPRF((TH1 *) projprf,(Int_t) (idect-fDect1[2])); | |
1714 | // Visualise the detector for fDebug 3 or 4 | |
1715 | // Here is the reconstruction of the pad and row group is used! | |
1716 | if (fDebug >= 3) { | |
1717 | FillCoefPRFDB(); | |
77566f2a | 1718 | } |
8ec526a4 | 1719 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
77566f2a | 1720 | FillInfosFit(idect,2); |
1721 | ||
8ec526a4 | 1722 | // Memory!!! |
1723 | if (fDebug != 2) { | |
77566f2a | 1724 | delete projprf; |
1725 | } | |
1726 | ||
8ec526a4 | 1727 | } // Boucle object |
77566f2a | 1728 | |
8ec526a4 | 1729 | // Plot |
1730 | // No plot, 1 and 4 error plot, 3 and 4 DB plot | |
1731 | if ((fDebug == 1) || | |
1732 | (fDebug == 4)) { | |
9f4780aa | 1733 | PlotWritePRF(); |
8ec526a4 | 1734 | } |
1735 | if ((fDebug == 4) || | |
1736 | (fDebug == 3)) { | |
77566f2a | 1737 | PlotPRFDB(); |
8ec526a4 | 1738 | } |
77566f2a | 1739 | |
8ec526a4 | 1740 | // Mean Statistics |
1741 | if (fNumberFit > 0) { | |
1742 | AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit)); | |
77566f2a | 1743 | } |
1744 | else { | |
1745 | AliInfo("There is no fit!"); | |
1746 | } | |
1747 | ||
8ec526a4 | 1748 | // Write the things! |
1749 | if (fWriteCoef[2]) { | |
77566f2a | 1750 | WriteFitInfos(2); |
1751 | } | |
8ec526a4 | 1752 | |
77566f2a | 1753 | return kTRUE; |
1754 | ||
1755 | } | |
1756 | ||
8ec526a4 | 1757 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
77566f2a | 1758 | Bool_t AliTRDCalibra::Init2Dhistos() |
1759 | { | |
8ec526a4 | 1760 | // |
1761 | // For the offline tracking | |
1762 | // This function will be called in the function AliReconstruction::Run() | |
1763 | // Init the calibration mode (Nz, Nrphi), the 2D histograms if fHisto2d = kTRUE, | |
1764 | // | |
77566f2a | 1765 | |
8ec526a4 | 1766 | // DB Setting |
1767 | // Get cal | |
9f4780aa | 1768 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 1769 | if (!cal) { |
1770 | AliInfo("Could not get calibDB"); | |
1771 | return kFALSE; | |
1772 | } | |
b43a3e17 | 1773 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); |
1774 | if (!parCom) { | |
1775 | AliInfo("Could not get CommonParam"); | |
1776 | return kFALSE; | |
1777 | } | |
77566f2a | 1778 | |
77566f2a | 1779 | // Some parameters |
8ec526a4 | 1780 | fTimeMax = cal->GetNumberOfTimeBins(); |
b43a3e17 | 1781 | fSf = parCom->GetSamplingFrequency(); |
8ec526a4 | 1782 | if (fRelativeScaleAuto) { |
1783 | fRelativeScale = 0; | |
1784 | } | |
1785 | else { | |
1786 | fRelativeScale = 20; | |
1787 | } | |
77566f2a | 1788 | |
8ec526a4 | 1789 | // Create the 2D histos corresponding to the pad groupCalibration mode |
1790 | if (fCH2dOn) { | |
77566f2a | 1791 | |
8ec526a4 | 1792 | AliInfo(Form("The pad calibration mode for the relative gain calibration: Nz %d, and Nrphi %d" |
1793 | ,fNz[0] | |
1794 | ,fNrphi[0])); | |
77566f2a | 1795 | |
8ec526a4 | 1796 | // Calcul the number of Xbins |
77566f2a | 1797 | fNtotal[0] = 0; |
1798 | ModePadCalibration(2,0); | |
1799 | ModePadFragmentation(0,2,0,0); | |
8ec526a4 | 1800 | fDetChamb2[0] = fNfragZ[0] * fNfragRphi[0]; |
1801 | if (fDebug == 4) { | |
1802 | AliInfo(Form("For the chamber 2: %d",fDetChamb2[0])); | |
77566f2a | 1803 | } |
8ec526a4 | 1804 | fNtotal[0] += 6 * 18 * fDetChamb2[0]; |
77566f2a | 1805 | ModePadCalibration(0,0); |
1806 | ModePadFragmentation(0,0,0,0); | |
8ec526a4 | 1807 | fDetChamb0[0] = fNfragZ[0] * fNfragRphi[0]; |
1808 | if (fDebug == 4) { | |
1809 | AliInfo(Form("For the other chamber 0: %d",fDetChamb0[0])); | |
77566f2a | 1810 | } |
8ec526a4 | 1811 | fNtotal[0] += 6 * 4 * 18 * fDetChamb0[0]; |
1812 | AliInfo(Form("Total number of Xbins: %d",fNtotal[0])); | |
77566f2a | 1813 | |
8ec526a4 | 1814 | // Create the 2D histo |
1815 | if (fHisto2d) { | |
1816 | CreateCH2d(fNtotal[0]); | |
1817 | } | |
1818 | if (fVector2d) { | |
1819 | fVectorCH = new TObjArray(); | |
1820 | fPlaCH = new TObjArray(); | |
1821 | } | |
77566f2a | 1822 | |
8ec526a4 | 1823 | // Variable |
1824 | fAmpTotal = new Float_t[TMath::Max(fDetChamb2[0],fDetChamb0[0])]; | |
1825 | for (Int_t k = 0; k < TMath::Max(fDetChamb2[0],fDetChamb0[0]); k++) { | |
1826 | fAmpTotal[k] = 0.0; | |
77566f2a | 1827 | } |
1828 | ||
77566f2a | 1829 | } |
1830 | ||
8ec526a4 | 1831 | if (fPH2dOn) { |
1832 | ||
1833 | AliInfo(Form("The pad calibration mode for the drift velocity calibration: Nz %d, and Nrphi %d" | |
1834 | ,fNz[1] | |
1835 | ,fNrphi[1])); | |
77566f2a | 1836 | |
8ec526a4 | 1837 | // Calcul the number of Xbins |
77566f2a | 1838 | fNtotal[1] = 0; |
1839 | ModePadCalibration(2,1); | |
1840 | ModePadFragmentation(0,2,0,1); | |
8ec526a4 | 1841 | fDetChamb2[1] = fNfragZ[1]*fNfragRphi[1]; |
1842 | if (fDebug == 4) { | |
1843 | AliInfo(Form("For the chamber 2: %d",fDetChamb2[1])); | |
77566f2a | 1844 | } |
8ec526a4 | 1845 | fNtotal[1] += 6 * 18 * fDetChamb2[1]; |
77566f2a | 1846 | ModePadCalibration(0,1); |
1847 | ModePadFragmentation(0,0,0,1); | |
8ec526a4 | 1848 | fDetChamb0[1] = fNfragZ[1] * fNfragRphi[1]; |
1849 | if (fDebug == 4) { | |
1850 | AliInfo(Form("For the chamber 0: %d",fDetChamb0[1])); | |
77566f2a | 1851 | } |
8ec526a4 | 1852 | fNtotal[1] += 6 * 4 * 18 * fDetChamb0[1]; |
1853 | AliInfo(Form("Total number of Xbins: %d",fNtotal[1])); | |
77566f2a | 1854 | |
8ec526a4 | 1855 | // Create the 2D histo |
1856 | if (fHisto2d) { | |
1857 | CreatePH2d(fNtotal[1]); | |
1858 | } | |
1859 | if (fVector2d) { | |
1860 | fVectorPH = new TObjArray(); | |
1861 | fPlaPH = new TObjArray(); | |
1862 | } | |
77566f2a | 1863 | |
8ec526a4 | 1864 | // Variable |
1865 | fPHPlace = new Short_t[fTimeMax]; | |
1866 | for (Int_t k = 0; k < fTimeMax; k++) { | |
1867 | fPHPlace[k] = -1; | |
77566f2a | 1868 | } |
8ec526a4 | 1869 | fPHValue = new Float_t[fTimeMax]; |
1870 | for (Int_t k = 0; k < fTimeMax; k++) { | |
1871 | fPHValue[k] = -1.0; | |
1872 | } | |
77566f2a | 1873 | |
1874 | } | |
1875 | ||
8ec526a4 | 1876 | if (fPRF2dOn) { |
1877 | ||
1878 | AliInfo(Form("The pad calibration mode for the PRF calibration: Nz %d, and Nrphi %d" | |
1879 | ,fNz[2] | |
1880 | ,fNrphi[2])); | |
77566f2a | 1881 | |
8ec526a4 | 1882 | // Calcul the number of Xbins |
77566f2a | 1883 | fNtotal[2] = 0; |
1884 | ModePadCalibration(2,2); | |
1885 | ModePadFragmentation(0,2,0,2); | |
8ec526a4 | 1886 | fDetChamb2[2] = fNfragZ[2] * fNfragRphi[2]; |
1887 | if (fDebug == 4) { | |
1888 | AliInfo(Form("For the chamber 2: %d",fDetChamb2[2])); | |
77566f2a | 1889 | } |
8ec526a4 | 1890 | fNtotal[2] += 6 * 18 * fDetChamb2[2]; |
77566f2a | 1891 | ModePadCalibration(0,2); |
1892 | ModePadFragmentation(0,0,0,2); | |
8ec526a4 | 1893 | fDetChamb0[2] = fNfragZ[2] * fNfragRphi[2]; |
1894 | if (fDebug == 4) { | |
1895 | AliInfo(Form("For the chamber 0: %d",fDetChamb0[2])); | |
77566f2a | 1896 | } |
8ec526a4 | 1897 | fNtotal[2] += 6 * 4 * 18 * fDetChamb0[2]; |
1898 | AliInfo(Form("Total number of Xbins: %d",fNtotal[2])); | |
77566f2a | 1899 | |
8ec526a4 | 1900 | // Create the 2D histo |
1901 | if (fHisto2d) { | |
1902 | CreatePRF2d(fNtotal[2]); | |
1903 | } | |
1904 | if (fVector2d) { | |
1905 | fVectorPRF = new TObjArray(); | |
1906 | fPlaPRF = new TObjArray(); | |
1907 | } | |
77566f2a | 1908 | |
1909 | } | |
1910 | ||
1911 | return kTRUE; | |
1912 | ||
1913 | } | |
1914 | ||
8ec526a4 | 1915 | //____________Functions for filling the histos in the code_____________________ |
77566f2a | 1916 | |
8ec526a4 | 1917 | //____________Offine tracking in the AliTRDtracker_____________________________ |
1918 | Bool_t AliTRDCalibra::ResetTrack() | |
77566f2a | 1919 | { |
1920 | // | |
8ec526a4 | 1921 | // For the offline tracking |
1922 | // This function will be called in the function | |
1923 | // AliTRDtracker::FollowBackPropagation() at the beginning | |
1924 | // Reset the parameter to know we have a new TRD track | |
77566f2a | 1925 | // |
1926 | ||
1927 | fDetectorAliTRDtrack = kFALSE; | |
1928 | return kTRUE; | |
77566f2a | 1929 | |
8ec526a4 | 1930 | } |
77566f2a | 1931 | |
8ec526a4 | 1932 | //____________Offline tracking in the AliTRDtracker____________________________ |
77566f2a | 1933 | Bool_t AliTRDCalibra::UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t) |
1934 | { | |
1935 | // | |
8ec526a4 | 1936 | // For the offline tracking |
1937 | // This function will be called in the function | |
1938 | // AliTRDtracker::FollowBackPropagation() in the loop over the clusters | |
1939 | // of TRD tracks | |
1940 | // Fill the 2D histos or the vectors with the info of the clusters at | |
1941 | // the end of a detectors if the track is "good" | |
77566f2a | 1942 | // |
1943 | ||
8ec526a4 | 1944 | // Get the parameter object |
77566f2a | 1945 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); |
1946 | if (!parCom) { | |
1947 | AliInfo("Could not get CommonParam"); | |
1948 | return kFALSE; | |
1949 | } | |
1950 | ||
1951 | // Get the parameter object | |
1952 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
1953 | if (!cal) { | |
1954 | AliInfo("Could not get calibDB"); | |
1955 | return kFALSE; | |
1956 | } | |
1957 | ||
8ec526a4 | 1958 | // Localisation of the detector |
77566f2a | 1959 | Int_t detector = cl->GetDetector(); |
8ec526a4 | 1960 | Int_t chamber = GetChamber(detector); |
1961 | Int_t plane = GetPlane(detector); | |
77566f2a | 1962 | |
8ec526a4 | 1963 | // Fill the infos for the previous clusters if not the same |
1964 | // detector anymore or if not the same track | |
1965 | if (((detector != fDetectorPreviousTrack) || (!fDetectorAliTRDtrack)) && | |
1966 | (fDetectorPreviousTrack != -1)) { | |
1967 | ||
1968 | fNumberTrack++; | |
77566f2a | 1969 | |
8ec526a4 | 1970 | // If the same track, then look if the previous detector is in |
1971 | // the same plane, if yes: not a good track | |
1972 | if (fDetectorAliTRDtrack && | |
1973 | (GetPlane(detector) <= GetPlane(fDetectorPreviousTrack))) { | |
77566f2a | 1974 | fGoodTrack = kFALSE; |
1975 | } | |
1976 | ||
8ec526a4 | 1977 | // Fill only if the track doesn't touch a masked pad or doesn't |
1978 | // appear in the middle (fGoodTrack) | |
1979 | if (fGoodTrack) { | |
77566f2a | 1980 | |
8ec526a4 | 1981 | // Gain calibration |
1982 | if (fCH2dOn) { | |
77566f2a | 1983 | FillTheInfoOfTheTrackCH(); |
8ec526a4 | 1984 | } |
77566f2a | 1985 | |
8ec526a4 | 1986 | // PH calibration |
1987 | if (fPH2dOn) { | |
77566f2a | 1988 | FillTheInfoOfTheTrackPH(); |
8ec526a4 | 1989 | } |
77566f2a | 1990 | |
8ec526a4 | 1991 | } // if a good track |
77566f2a | 1992 | |
8ec526a4 | 1993 | ResetfVariables(); |
77566f2a | 1994 | |
8ec526a4 | 1995 | } // Fill at the end the charge |
77566f2a | 1996 | |
8ec526a4 | 1997 | // Calcul the position of the detector |
1998 | if (detector != fDetectorPreviousTrack) { | |
1999 | LocalisationDetectorXbins(detector); | |
77566f2a | 2000 | } |
2001 | ||
8ec526a4 | 2002 | // Reset the good track for the PRF |
77566f2a | 2003 | Bool_t good = kTRUE; |
2004 | ||
8ec526a4 | 2005 | // Localisation of the cluster |
2006 | Double_t pos[3] = { 0.0, 0.0, 0.0 }; | |
77566f2a | 2007 | pos[0] = cl->GetX(); |
2008 | pos[1] = cl->GetY(); | |
2009 | pos[2] = cl->GetZ(); | |
8ec526a4 | 2010 | Int_t time = cl->GetLocalTimeBin(); |
2011 | ||
2012 | // Reset the detector | |
2013 | fDetectorPreviousTrack = detector; | |
2014 | fDetectorAliTRDtrack = kTRUE; | |
2015 | ||
2016 | // Position of the cluster | |
2017 | AliTRDpadPlane *padplane = parCom->GetPadPlane(plane,chamber); | |
2018 | Int_t row = padplane->GetPadRowNumber(pos[2]); | |
2019 | Double_t offsetz = padplane->GetPadRowOffset(row,pos[2]); | |
2020 | Double_t offsettilt = padplane->GetTiltOffset(offsetz); | |
2021 | Int_t col = padplane->GetPadColNumber(pos[1] + offsettilt,offsetz); | |
2022 | ||
2023 | // See if we are not near a masked pad | |
2024 | if (!IsPadOn(detector,col,row)) { | |
2025 | good = kFALSE; | |
77566f2a | 2026 | fGoodTrack = kFALSE; |
2027 | } | |
2028 | ||
8ec526a4 | 2029 | if (col > 0) { |
2030 | if (!IsPadOn(detector,col-1,row)) { | |
77566f2a | 2031 | fGoodTrack = kFALSE; |
8ec526a4 | 2032 | good = kFALSE; |
77566f2a | 2033 | } |
2034 | } | |
2035 | ||
8ec526a4 | 2036 | if (col < 143) { |
2037 | if (!IsPadOn(detector,col+1,row)) { | |
77566f2a | 2038 | fGoodTrack = kFALSE; |
8ec526a4 | 2039 | good = kFALSE; |
77566f2a | 2040 | } |
2041 | } | |
2042 | ||
8ec526a4 | 2043 | // Row of the cluster and position in the pad groups |
2044 | Int_t posr[3] = { 0, 0, 0 }; | |
2045 | if ((fCH2dOn) && (fNnZ[0] != 0)) { | |
2046 | posr[0] = (Int_t) row / fNnZ[0]; | |
2047 | } | |
2048 | if ((fPH2dOn) && (fNnZ[1] != 0)) { | |
2049 | posr[1] = (Int_t) row / fNnZ[1]; | |
2050 | } | |
2051 | if ((fPRF2dOn) && (fNnZ[2] != 0)) { | |
2052 | posr[2] = (Int_t) row / fNnZ[2]; | |
2053 | } | |
77566f2a | 2054 | |
8ec526a4 | 2055 | // Col of the cluster and position in the pad groups |
2056 | Int_t posc[3] = { 0, 0, 0 }; | |
2057 | if ((fCH2dOn) && (fNnRphi[0] != 0)) { | |
2058 | posc[0] = (Int_t) col / fNnRphi[0]; | |
2059 | } | |
2060 | if ((fPH2dOn) && (fNnRphi[1] != 0)) { | |
2061 | posc[1] = (Int_t) col / fNnRphi[1]; | |
2062 | } | |
2063 | if ((fPRF2dOn) && (fNnRphi[2] != 0)) { | |
2064 | posc[2] = (Int_t) col / fNnRphi[2]; | |
2065 | } | |
77566f2a | 2066 | |
8ec526a4 | 2067 | // Charge in the cluster |
2068 | // For the moment take the abs | |
2069 | Float_t q = TMath::Abs(cl->GetQ()); | |
2070 | Short_t *signals = cl->GetSignals(); | |
77566f2a | 2071 | |
8ec526a4 | 2072 | // Correction due to the track angle |
2073 | Float_t correction = 1.0; | |
77566f2a | 2074 | Float_t normalisation = 6.67; |
8ec526a4 | 2075 | if ((q >0) && (t->GetNdedx() > 0)) { |
2076 | correction = t->GetClusterdQdl((t->GetNdedx() - 1)) / (q * normalisation); | |
77566f2a | 2077 | } |
77566f2a | 2078 | |
8ec526a4 | 2079 | // Fill the fAmpTotal with the charge |
2080 | if (fCH2dOn) { | |
2081 | if (!fTraMaxPad){ | |
2082 | fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += q * correction; | |
2083 | } | |
2084 | else { | |
2085 | fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += ((Float_t) signals[3]) * correction; | |
2086 | } | |
2087 | } | |
2088 | ||
2089 | // Fill the fPHPlace and value | |
2090 | if (fPH2dOn) { | |
2091 | fPHPlace[time] = posc[1]*fNfragZ[1]+posr[1]; | |
2092 | if (!fTraMaxPad) { | |
2093 | fPHValue[time] = q * correction; | |
2094 | } | |
2095 | else { | |
2096 | fPHValue[time] = ((Float_t) signals[3]) * correction; | |
2097 | } | |
2098 | } | |
77566f2a | 2099 | |
8ec526a4 | 2100 | // Fill direct the PRF |
2101 | if ((fPRF2dOn) && (good)) { | |
77566f2a | 2102 | |
8ec526a4 | 2103 | Float_t yminus = 0.0; |
77566f2a | 2104 | Float_t xcenter = 0.0; |
2105 | Float_t ycenter = 0.0; | |
8ec526a4 | 2106 | Float_t ymax = 0.0; |
2107 | Bool_t echec = kFALSE; | |
77566f2a | 2108 | |
8ec526a4 | 2109 | if ((cl->From3pad()) && (!cl->IsUsed())) { |
77566f2a | 2110 | |
8ec526a4 | 2111 | // Center 3 balanced |
2112 | if ((((Float_t) signals[3]) > fThresholdClusterPRF2) && | |
2113 | (((Float_t) signals[2]) > fThresholdClusterPRF2) && | |
2114 | (((Float_t) signals[4]) > fThresholdClusterPRF2) && | |
2115 | (((Float_t) signals[1]) < fThresholdClusterPRF1) && | |
2116 | (((Float_t) signals[5]) < fThresholdClusterPRF1) && | |
2117 | (q * correction > 130.0)) { | |
2118 | // Col correspond to signals[3] | |
2119 | if (fCenterOfflineCluster) { | |
2120 | xcenter = cl->GetCenter(); | |
2121 | } | |
2122 | else { | |
2123 | // Security of the denomiateur is 0 | |
2124 | if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) / | |
2125 | ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) { | |
2126 | xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2])))) | |
2127 | / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) | |
2128 | / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4]))))); | |
2129 | } | |
2130 | else { | |
2131 | xcenter = -100.0; | |
77566f2a | 2132 | } |
77566f2a | 2133 | } |
8ec526a4 | 2134 | if ((xcenter > -0.5) && (xcenter < 0.5)) { |
2135 | ycenter = (Float_t) (((Float_t) signals[3]) | |
2136 | / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])))); | |
2137 | yminus = (Float_t) (((Float_t) signals[2]) | |
2138 | / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])))); | |
2139 | ymax = (Float_t) (((Float_t) signals[4]) | |
2140 | / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])))); | |
2141 | if ((ycenter > 0.485) && | |
2142 | (TMath::Abs(((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])) - q) < 8.0)) { | |
2143 | echec = kTRUE; | |
2144 | } | |
77566f2a | 2145 | } |
2146 | } | |
2147 | ||
8ec526a4 | 2148 | // Fill only if it is in the drift region! |
2149 | if ((((Float_t) (((Float_t) time) / fSf)) > 0.3) && (echec)) { | |
2150 | if (fHisto2d) { | |
2151 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),xcenter,ycenter); | |
2152 | if (xcenter < 0.0) { | |
2153 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),-(xcenter+1.0),yminus); | |
2154 | } | |
2155 | if (xcenter > 0.0) { | |
2156 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),1.0-xcenter,ymax); | |
2157 | } | |
77566f2a | 2158 | } |
8ec526a4 | 2159 | if (fVector2d) { |
2160 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],xcenter,ycenter); | |
2161 | if (xcenter < 0.0) { | |
2162 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],-(xcenter+1.0),yminus); | |
2163 | } | |
2164 | if (xcenter > 0.0) { | |
2165 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],1.0-xcenter,ymax); | |
2166 | } | |
77566f2a | 2167 | } |
8ec526a4 | 2168 | } // If in the drift region |
2169 | ||
2170 | } // Cluster isole | |
2171 | ||
2172 | } // PRF2dOn | |
77566f2a | 2173 | |
2174 | return kTRUE; | |
2175 | ||
2176 | } | |
2177 | ||
8ec526a4 | 2178 | //____________Online trackling in AliTRDtrigger________________________________ |
2179 | Bool_t AliTRDCalibra::UpdateHistogramcm(AliTRDmcmTracklet *trk) | |
77566f2a | 2180 | { |
2181 | // | |
8ec526a4 | 2182 | // For the tracking |
2183 | // This function will be called in the function AliTRDtrigger::TestTracklet | |
2184 | // before applying the pt cut on the tracklets | |
2185 | // Fill the infos for the tracklets fTrkTest if the tracklets is "good" | |
77566f2a | 2186 | // |
2187 | ||
8ec526a4 | 2188 | // Localisation of the Xbins involved |
2189 | Int_t idect = trk->GetDetector(); | |
2190 | LocalisationDetectorXbins(idect); | |
77566f2a | 2191 | |
2192 | // Get the parameter object | |
8ec526a4 | 2193 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 2194 | if (!cal) { |
2195 | AliInfo("Could not get calibDB"); | |
2196 | return kFALSE; | |
2197 | } | |
2198 | ||
8ec526a4 | 2199 | // Reset |
2200 | ResetfVariables(); | |
2201 | ||
2202 | // Row of the tracklet and position in the pad groups | |
2203 | Int_t row = trk->GetRow(); | |
2204 | Int_t posr[3] = { 0, 0, 0 }; | |
2205 | if ((fCH2dOn) && (fNnZ[0] != 0)) { | |
2206 | posr[0] = (Int_t) row / fNnZ[0]; | |
2207 | } | |
2208 | if ((fPH2dOn) && (fNnZ[1] != 0)) { | |
2209 | posr[1] = (Int_t) row / fNnZ[1]; | |
2210 | } | |
2211 | if ((fPRF2dOn) && (fNnZ[2] != 0)) { | |
2212 | posr[2] = (Int_t) row / fNnZ[2]; | |
2213 | } | |
2214 | ||
2215 | // Eventuelle correction due to track angle in z direction | |
77566f2a | 2216 | Float_t correction = 1.0; |
8ec526a4 | 2217 | if (fMcmCorrectAngle) { |
2218 | Float_t z = trk->GetRowz(); | |
2219 | Float_t r = trk->GetTime0(); | |
2220 | correction = r / TMath::Sqrt((r*r+z*z)); | |
77566f2a | 2221 | } |
8ec526a4 | 2222 | |
2223 | // Boucle sur les clusters | |
2224 | // Condition on number of cluster: don't come from the middle of the detector | |
2225 | if (trk->GetNclusters() >= fNumberClusters) { | |
2226 | ||
2227 | for (Int_t icl = 0; icl < trk->GetNclusters(); icl++) { | |
2228 | ||
2229 | Float_t amp[3] = { 0.0, 0.0, 0.0 }; | |
2230 | Int_t time = trk->GetClusterTime(icl); | |
2231 | Int_t col = trk->GetClusterCol(icl); | |
77566f2a | 2232 | |
8ec526a4 | 2233 | amp[0] = trk->GetClusterADC(icl)[0] * correction; |
2234 | amp[1] = trk->GetClusterADC(icl)[1] * correction; | |
2235 | amp[2] = trk->GetClusterADC(icl)[2] * correction; | |
77566f2a | 2236 | |
8ec526a4 | 2237 | if ((amp[0] < 0.0) || |
2238 | (amp[1] < 0.0) || | |
2239 | (amp[2] < 0.0)) { | |
2240 | continue; | |
2241 | } | |
2242 | ||
2243 | // Col of cluster and position in the pad groups | |
2244 | Int_t posc[3] = { 0, 0, 0 }; | |
2245 | if ((fCH2dOn) && (fNnRphi[0] != 0)) { | |
2246 | posc[0] = (Int_t) col / fNnRphi[0]; | |
2247 | } | |
2248 | if ((fPH2dOn) && (fNnRphi[1] != 0)) { | |
2249 | posc[1] = (Int_t) col / fNnRphi[1]; | |
2250 | } | |
2251 | if ((fPRF2dOn) && (fNnRphi[2] != 0)) { | |
2252 | posc[2] = (Int_t) col / fNnRphi[2]; | |
2253 | } | |
2254 | ||
2255 | // See if we are not near a masked pad | |
77566f2a | 2256 | Bool_t good = kTRUE; |
8ec526a4 | 2257 | if (!IsPadOn(idect,col,row)) { |
77566f2a | 2258 | fGoodTrack = kFALSE; |
8ec526a4 | 2259 | good = kFALSE; |
77566f2a | 2260 | } |
8ec526a4 | 2261 | |
2262 | if (col > 0) { | |
2263 | if (!IsPadOn(idect,col-1,row)) { | |
77566f2a | 2264 | fGoodTrack = kFALSE; |
8ec526a4 | 2265 | good = kFALSE; |
77566f2a | 2266 | } |
2267 | } | |
2268 | ||
8ec526a4 | 2269 | if (col < 143) { |
2270 | if (!IsPadOn(idect,col+1,row)) { | |
77566f2a | 2271 | fGoodTrack = kFALSE; |
8ec526a4 | 2272 | good = kFALSE; |
77566f2a | 2273 | } |
2274 | } | |
77566f2a | 2275 | |
8ec526a4 | 2276 | // Total spectrum |
2277 | if (fPH2dOn) { | |
2278 | fPHPlace[time] = posc[1] * fNfragZ[1] + posr[1]; | |
77566f2a | 2279 | } |
77566f2a | 2280 | |
8ec526a4 | 2281 | if (!fTraMaxPad) { |
2282 | if (fCH2dOn) { | |
2283 | fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += (Float_t) (amp[0]+amp[1]+amp[2]); | |
2284 | } | |
2285 | if (fPH2dOn) { | |
2286 | fPHValue[time] = (Float_t) (amp[0]+amp[1]+amp[2]); | |
2287 | } | |
2288 | } | |
2289 | else { | |
2290 | if (fCH2dOn) { | |
2291 | fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += (Float_t) amp[1]; | |
2292 | } | |
2293 | if (fPH2dOn) { | |
2294 | fPHValue[time] = amp[1]; | |
2295 | } | |
77566f2a | 2296 | } |
2297 | ||
8ec526a4 | 2298 | // Fill PRF direct |
2299 | if (fPRF2dOn && good) { | |
2300 | if ((amp[0] > fThresholdClusterPRF2) && | |
2301 | (amp[1] > fThresholdClusterPRF2) && | |
2302 | (amp[2] > fThresholdClusterPRF2) && | |
2303 | ((amp[0]+amp[1]+amp[2]) > 130.0)) { | |
2304 | // Security of the denomiateur is 0 | |
2305 | if ((((Float_t) (((Float_t) amp[1]) * ((Float_t) amp[1]))) | |
2306 | / ((Float_t) (((Float_t) amp[0]) * ((Float_t) amp[2])))) != 1.0) { | |
2307 | Float_t xcenter = 0.5 * (TMath::Log(amp[2] / amp[0])) | |
2308 | / (TMath::Log((amp[1]*amp[1]) / (amp[0]*amp[2]))); | |
2309 | Float_t ycenter = amp[1] / (amp[0] + amp[1] + amp[2]); | |
2310 | if ((xcenter > -0.5) && | |
2311 | (xcenter < 0.5) && | |
2312 | (ycenter > 0.485)) { | |
2313 | Float_t yminus = amp[0] / (amp[0]+amp[1]+amp[2]); | |
2314 | Float_t ymax = amp[2] / (amp[0]+amp[1]+amp[2]); | |
2315 | // Fill only if it is in the drift region! | |
2316 | if (((Float_t) time / fSf) > 0.3) { | |
2317 | if (fHisto2d) { | |
2318 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),xcenter,ycenter); | |
2319 | if (xcenter < 0.0) { | |
2320 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),-(xcenter+1.0),yminus); | |
2321 | } | |
2322 | if (xcenter > 0.0) { | |
2323 | fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),(1.0-xcenter),ymax); | |
2324 | } | |
2325 | } | |
2326 | if (fVector2d) { | |
2327 | UpdateVectorPRF((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]),xcenter,ycenter); | |
2328 | if (xcenter < 0.0) { | |
2329 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],-(xcenter+1.0),yminus); | |
2330 | } | |
2331 | if (xcenter > 0.0) { | |
2332 | UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],(1.0-xcenter),ymax); | |
77566f2a | 2333 | } |
77566f2a | 2334 | } |
2335 | } | |
2336 | } | |
2337 | } | |
2338 | } | |
2339 | } | |
2340 | ||
8ec526a4 | 2341 | } // Boucle clusters |
77566f2a | 2342 | |
8ec526a4 | 2343 | // Fill the charge |
2344 | if (fCH2dOn && fGoodTrack) { | |
77566f2a | 2345 | FillTheInfoOfTheTrackCH(); |
8ec526a4 | 2346 | } |
77566f2a | 2347 | |
8ec526a4 | 2348 | // PH calibration |
2349 | if (fPH2dOn && fGoodTrack) { | |
2350 | FillTheInfoOfTheTrackPH(); | |
2351 | } | |
77566f2a | 2352 | |
8ec526a4 | 2353 | } // Condition on number of clusters |
2354 | ||
77566f2a | 2355 | return kTRUE; |
2356 | ||
2357 | } | |
2358 | ||
8ec526a4 | 2359 | //____________Functions for seeing if the pad is really okey___________________ |
77566f2a | 2360 | |
8ec526a4 | 2361 | //_____________________________________________________________________________ |
2362 | Bool_t AliTRDCalibra::SetModeCalibrationFromTObject(TObject *object, Int_t i) | |
77566f2a | 2363 | { |
2364 | // | |
8ec526a4 | 2365 | // Set fNz[i] and fNrphi[i] of the AliTRDCalibra::Instance() |
2366 | // corresponding to the given TObject | |
77566f2a | 2367 | // |
8ec526a4 | 2368 | |
2369 | const char *nametitle = object->GetTitle(); | |
2370 | ||
2371 | // Some patterns | |
2372 | const Char_t *patternz0 = "Nz0"; | |
2373 | const Char_t *patternz1 = "Nz1"; | |
2374 | const Char_t *patternz2 = "Nz2"; | |
2375 | const Char_t *patternz3 = "Nz3"; | |
2376 | const Char_t *patternz4 = "Nz4"; | |
2377 | const Char_t *patternrphi0 = "Nrphi0"; | |
2378 | const Char_t *patternrphi1 = "Nrphi1"; | |
2379 | const Char_t *patternrphi2 = "Nrphi2"; | |
2380 | const Char_t *patternrphi3 = "Nrphi3"; | |
2381 | const Char_t *patternrphi4 = "Nrphi4"; | |
2382 | const Char_t *patternrphi5 = "Nrphi5"; | |
2383 | const Char_t *patternrphi6 = "Nrphi6"; | |
2384 | ||
2385 | UShort_t testz = 0; | |
2386 | UShort_t testrphi = 0; | |
2387 | ||
2388 | // Nz mode | |
2389 | if (strstr(nametitle,patternz0)) { | |
2390 | testz++; | |
2391 | fNz[i] = 0; | |
2392 | } | |
2393 | if (strstr(nametitle,patternz1)) { | |
2394 | testz++; | |
2395 | fNz[i] = 1; | |
2396 | } | |
2397 | if (strstr(nametitle,patternz2)) { | |
2398 | testz++; | |
2399 | fNz[i] = 2; | |
2400 | } | |
2401 | if (strstr(nametitle,patternz3)) { | |
2402 | testz++; | |
2403 | fNz[i] = 3; | |
2404 | } | |
2405 | if (strstr(nametitle,patternz4)) { | |
2406 | testz++; | |
2407 | fNz[i] = 4; | |
2408 | } | |
2409 | ||
2410 | // Nrphi mode | |
2411 | if (strstr(nametitle,patternrphi0)) { | |
2412 | testrphi++; | |
2413 | fNrphi[i] = 0; | |
2414 | } | |
2415 | if (strstr(nametitle,patternrphi1)) { | |
2416 | testrphi++; | |
2417 | fNrphi[i] = 1; | |
2418 | } | |
2419 | if (strstr(nametitle,patternrphi2)) { | |
2420 | testrphi++; | |
2421 | fNrphi[i] = 2; | |
2422 | } | |
2423 | if (strstr(nametitle,patternrphi3)) { | |
2424 | testrphi++; | |
2425 | fNrphi[i] = 3; | |
2426 | } | |
2427 | if (strstr(nametitle,patternrphi4)) { | |
2428 | testrphi++; | |
2429 | fNrphi[i] = 4; | |
2430 | } | |
2431 | if (strstr(nametitle,patternrphi5)) { | |
2432 | testrphi++; | |
2433 | fNrphi[i] = 5; | |
2434 | } | |
2435 | if (strstr(nametitle,patternrphi6)) { | |
2436 | testrphi++; | |
2437 | fNrphi[i] = 6; | |
2438 | } | |
2439 | ||
2440 | // Look if all is okey | |
2441 | if ((testz == 1) && | |
2442 | (testrphi == 1)) { | |
2443 | return kTRUE; | |
2444 | } | |
2445 | else { | |
2446 | fNrphi[i] = 0; | |
2447 | fNz[i] = 0; | |
2448 | return kFALSE; | |
2449 | } | |
77566f2a | 2450 | |
8ec526a4 | 2451 | } |
2452 | ||
2453 | //_____________________________________________________________________________ | |
2454 | Bool_t AliTRDCalibra::IsPadOn(Int_t detector, Int_t col, Int_t row) const | |
2455 | { | |
2456 | // | |
2457 | // Look in the choosen database if the pad is On. | |
2458 | // If no the track will be "not good" | |
2459 | // | |
77566f2a | 2460 | |
2461 | // Get the parameter object | |
8ec526a4 | 2462 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 2463 | if (!cal) { |
2464 | AliInfo("Could not get calibDB"); | |
2465 | return kFALSE; | |
2466 | } | |
2467 | ||
8ec526a4 | 2468 | if (!cal->IsChamberInstalled(detector) || |
9f4780aa | 2469 | cal->IsChamberMasked(detector) || |
8ec526a4 | 2470 | cal->IsPadMasked(detector,col,row)) { |
77566f2a | 2471 | return kFALSE; |
2472 | } | |
8ec526a4 | 2473 | else { |
2474 | return kTRUE; | |
2475 | } | |
77566f2a | 2476 | |
2477 | } | |
2478 | ||
8ec526a4 | 2479 | //____________Functions for plotting the 2D____________________________________ |
77566f2a | 2480 | |
8ec526a4 | 2481 | //_____________________________________________________________________________ |
77566f2a | 2482 | void AliTRDCalibra::Plot2d() |
2483 | { | |
2484 | // | |
2485 | // Plot the 2D histos | |
2486 | // | |
2487 | ||
8ec526a4 | 2488 | if (fCH2dOn) { |
2489 | PlotCH2d(); | |
2490 | } | |
2491 | if (fPH2dOn) { | |
2492 | PlotPH2d(); | |
2493 | } | |
2494 | if (fPRF2dOn) { | |
2495 | PlotPRF2d(); | |
2496 | } | |
77566f2a | 2497 | |
2498 | } | |
77566f2a | 2499 | |
8ec526a4 | 2500 | //____________Writing the 2D___________________________________________________ |
2501 | ||
2502 | //_____________________________________________________________________________ | |
77566f2a | 2503 | Bool_t AliTRDCalibra::Write2d() |
2504 | { | |
2505 | // | |
8ec526a4 | 2506 | // Write the 2D histograms or the vectors converted in trees in the file |
2507 | // "TRD.calibration.root" | |
77566f2a | 2508 | // |
2509 | ||
2510 | TFile *fout = TFile::Open(fWriteName,"RECREATE"); | |
8ec526a4 | 2511 | // Check if the file could be opened |
77566f2a | 2512 | if (!fout || !fout->IsOpen()) { |
2513 | AliInfo("No File found!"); | |
2514 | return kFALSE; | |
2515 | } | |
8ec526a4 | 2516 | AliInfo(Form("Numbertrack: %d Numberusedch[0]: %d, Numberusedch[1]: %d Numberusedph[0]: %d, Numberusedph[1]: %d" |
2517 | ,fNumberTrack | |
2518 | ,fNumberUsedCh[0] | |
2519 | ,fNumberUsedCh[1] | |
2520 | ,fNumberUsedPh[0] | |
2521 | ,fNumberUsedPh[1])); | |
77566f2a | 2522 | |
2523 | TStopwatch stopwatch; | |
2524 | stopwatch.Start(); | |
2525 | AliInfo("Write2d"); | |
8ec526a4 | 2526 | |
2527 | if ((fCH2dOn ) && (fWrite[0])) { | |
2528 | if (fHisto2d) { | |
2529 | fout->WriteTObject(fCH2d); | |
2530 | } | |
2531 | if (fVector2d) { | |
2532 | TString name("Nz"); | |
2533 | name += fNz[0]; | |
2534 | name += "Nrphi"; | |
2535 | name += fNrphi[0]; | |
2536 | TTree *treeCH2d = ConvertVectorCTTreeHisto(fVectorCH,fPlaCH,"treeCH2d",(const char *) name); | |
77566f2a | 2537 | fout->WriteTObject(treeCH2d); |
2538 | } | |
2539 | } | |
8ec526a4 | 2540 | if ((fPH2dOn ) && (fWrite[1])) { |
2541 | if (fHisto2d) { | |
2542 | fout->WriteTObject(fPH2d); | |
2543 | } | |
2544 | if (fVector2d) { | |
2545 | TString name("Nz"); | |
2546 | name += fNz[1]; | |
2547 | name += "Nrphi"; | |
2548 | name += fNrphi[1]; | |
2549 | TTree *treePH2d = ConvertVectorPTreeHisto(fVectorPH,fPlaPH,"treePH2d",(const char *) name); | |
77566f2a | 2550 | fout->WriteTObject(treePH2d); |
2551 | } | |
2552 | } | |
8ec526a4 | 2553 | if ((fPRF2dOn ) && (fWrite[2])) { |
2554 | if (fHisto2d) { | |
2555 | fout->WriteTObject(fPRF2d); | |
2556 | } | |
2557 | if (fVector2d) { | |
2558 | TString name("Nz"); | |
2559 | name += fNz[2]; | |
2560 | name += "Nrphi"; | |
2561 | name += fNrphi[2]; | |
2562 | TTree *treePRF2d = ConvertVectorPTreeHisto(fVectorPRF,fPlaPRF,"treePRF2d",(const char *) name); | |
77566f2a | 2563 | fout->WriteTObject(treePRF2d); |
2564 | } | |
2565 | } | |
2566 | ||
2567 | fout->Close(); | |
2568 | ||
8ec526a4 | 2569 | AliInfo(Form("Execution time Write2d: R:%.2fs C:%.2fs" |
2570 | ,stopwatch.RealTime(),stopwatch.CpuTime())); | |
2571 | ||
77566f2a | 2572 | return kTRUE; |
2573 | ||
2574 | } | |
8ec526a4 | 2575 | |
2576 | //_____________________________________________________________________________ | |
2577 | AliTRDCalDet *AliTRDCalibra::CreateDetObjectTree(TTree *tree, Int_t i) | |
77566f2a | 2578 | { |
2579 | // | |
8ec526a4 | 2580 | // It creates the AliTRDCalDet object from the tree of the coefficient |
2581 | // for the calibration i (i != 2) | |
77566f2a | 2582 | // It takes the mean value of the coefficients per detector |
2583 | // This object has to be written in the database | |
2584 | // | |
2585 | ||
8ec526a4 | 2586 | // Create the DetObject |
77566f2a | 2587 | AliTRDCalDet *object = 0x0; |
8ec526a4 | 2588 | if (i == 0) { |
2589 | object = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)"); | |
2590 | } | |
2591 | if (i == 1) { | |
2592 | object = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)"); | |
2593 | } | |
2594 | else { | |
2595 | object = new AliTRDCalDet("ChamberT0","T0 (detector value)"); | |
2596 | } | |
77566f2a | 2597 | |
8ec526a4 | 2598 | // Read the Tree |
2599 | Int_t detector = -1; | |
77566f2a | 2600 | Float_t values[2304]; |
2601 | tree->SetBranchAddress("detector",&detector); | |
8ec526a4 | 2602 | if (i == 0) { |
2603 | tree->SetBranchAddress("gainPad",values); | |
2604 | } | |
2605 | if (i == 1) { | |
2606 | tree->SetBranchAddress("vdrift" ,values); | |
2607 | } | |
2608 | if (i == 3) { | |
2609 | tree->SetBranchAddress("t0" ,values); | |
2610 | } | |
77566f2a | 2611 | |
8ec526a4 | 2612 | // For calculating the mean |
2613 | Float_t mean = 0.0; | |
2614 | Int_t nto = 0; | |
2615 | Int_t numberofentries = tree->GetEntries(); | |
77566f2a | 2616 | |
8ec526a4 | 2617 | if (numberofentries != 540) { |
2618 | AliInfo("The tree is not complete"); | |
2619 | } | |
77566f2a | 2620 | |
8ec526a4 | 2621 | for (Int_t det = 0; det < numberofentries; ++det) { |
77566f2a | 2622 | tree->GetEntry(det); |
8ec526a4 | 2623 | if (GetChamber(detector) == 2) { |
2624 | nto = 1728; | |
2625 | } | |
2626 | else { | |
2627 | nto = 2304; | |
2628 | } | |
77566f2a | 2629 | mean = 0.0; |
9f4780aa | 2630 | if(i != 3){ |
2631 | for (Int_t k = 0; k < nto; k++) { | |
2632 | mean += TMath::Abs(values[k]) / nto; | |
2633 | } | |
2634 | } | |
2635 | else { | |
2636 | for (Int_t k = 0; k < nto; k++) { | |
2637 | mean += values[k] / nto; | |
2638 | } | |
8ec526a4 | 2639 | } |
77566f2a | 2640 | object->SetValue(detector,mean); |
2641 | } | |
8ec526a4 | 2642 | |
77566f2a | 2643 | return object; |
8ec526a4 | 2644 | |
77566f2a | 2645 | } |
8ec526a4 | 2646 | |
2647 | //_____________________________________________________________________________ | |
2648 | TObject *AliTRDCalibra::CreatePadObjectTree(TTree *tree, Int_t i | |
2649 | , AliTRDCalDet *detobject) | |
77566f2a | 2650 | { |
2651 | // | |
8ec526a4 | 2652 | // It Creates the AliTRDCalPad object from the tree of the |
2653 | // coefficient for the calibration i (i != 2) | |
2654 | // You need first to create the object for the detectors, | |
2655 | // where the mean value is put. | |
77566f2a | 2656 | // This object has to be written in the database |
2657 | // | |
2658 | ||
8ec526a4 | 2659 | // Create the DetObject |
77566f2a | 2660 | AliTRDCalPad *object = 0x0; |
8ec526a4 | 2661 | if (i == 0) { |
2662 | object = new AliTRDCalPad("GainFactor","GainFactor (local variations)"); | |
2663 | } | |
2664 | if (i == 1) { | |
2665 | object = new AliTRDCalPad("LocalVdrift","TRD drift velocities (local variations)"); | |
2666 | } | |
2667 | else { | |
2668 | object = new AliTRDCalPad("LocalT0","T0 (local variations)"); | |
2669 | } | |
77566f2a | 2670 | |
8ec526a4 | 2671 | // Read the Tree |
2672 | Int_t detector = -1; | |
77566f2a | 2673 | Float_t values[2304]; |
2674 | tree->SetBranchAddress("detector",&detector); | |
8ec526a4 | 2675 | if (i == 0) { |
2676 | tree->SetBranchAddress("gainPad",values); | |
2677 | } | |
2678 | if (i == 1) { | |
2679 | tree->SetBranchAddress("vdrift" ,values); | |
2680 | } | |
2681 | if (i == 3) { | |
2682 | tree->SetBranchAddress("t0" ,values); | |
2683 | } | |
77566f2a | 2684 | |
8ec526a4 | 2685 | // Variables |
2686 | Float_t mean = 0.0; | |
2687 | Int_t numberofentries = tree->GetEntries(); | |
77566f2a | 2688 | |
8ec526a4 | 2689 | if (numberofentries != 540) { |
2690 | AliInfo("The tree is not complete"); | |
2691 | } | |
77566f2a | 2692 | |
8ec526a4 | 2693 | for (Int_t det = 0; det < numberofentries; ++det) { |
77566f2a | 2694 | tree->GetEntry(det); |
2695 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2696 | mean = detobject->GetValue(detector); | |
8ec526a4 | 2697 | if (mean == 0) { |
2698 | continue; | |
2699 | } | |
77566f2a | 2700 | Int_t rowMax = calROC->GetNrows(); |
2701 | Int_t colMax = calROC->GetNcols(); | |
8ec526a4 | 2702 | for (Int_t row = 0; row < rowMax; ++row) { |
2703 | for (Int_t col = 0; col < colMax; ++col) { | |
9f4780aa | 2704 | if(i != 3) calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])/mean); |
2705 | else calROC->SetValue(col,row,values[(Int_t) (col*rowMax+row)]/mean); | |
e5c60cc7 | 2706 | |
8ec526a4 | 2707 | } // Col |
2708 | } // Row | |
77566f2a | 2709 | } |
8ec526a4 | 2710 | |
77566f2a | 2711 | return object; |
8ec526a4 | 2712 | |
77566f2a | 2713 | } |
8ec526a4 | 2714 | |
2715 | //_____________________________________________________________________________ | |
2716 | TObject *AliTRDCalibra::CreatePadObjectTree(TTree *tree) | |
77566f2a | 2717 | { |
2718 | // | |
8ec526a4 | 2719 | // It Creates the AliTRDCalPad object from the tree of the |
2720 | // coefficient for the calibration PRF (i = 2) | |
77566f2a | 2721 | // This object has to be written in the database |
2722 | // | |
2723 | ||
8ec526a4 | 2724 | // Create the DetObject |
77566f2a | 2725 | AliTRDCalPad *object = new AliTRDCalPad("PRFWidth","PRFWidth"); |
2726 | ||
8ec526a4 | 2727 | // Read the Tree |
2728 | Int_t detector = -1; | |
77566f2a | 2729 | Float_t values[2304]; |
2730 | tree->SetBranchAddress("detector",&detector); | |
8ec526a4 | 2731 | tree->SetBranchAddress("width" ,values); |
77566f2a | 2732 | |
8ec526a4 | 2733 | // Variables |
77566f2a | 2734 | Int_t numberofentries = tree->GetEntries(); |
2735 | ||
8ec526a4 | 2736 | if (numberofentries != 540) { |
2737 | AliInfo("The tree is not complete"); | |
2738 | } | |
77566f2a | 2739 | |
8ec526a4 | 2740 | for (Int_t det = 0; det < numberofentries; ++det) { |
77566f2a | 2741 | tree->GetEntry(det); |
2742 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2743 | Int_t rowMax = calROC->GetNrows(); | |
2744 | Int_t colMax = calROC->GetNcols(); | |
8ec526a4 | 2745 | for (Int_t row = 0; row < rowMax; ++row) { |
2746 | for (Int_t col = 0; col < colMax; ++col) { | |
77566f2a | 2747 | calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])); |
8ec526a4 | 2748 | } // Col |
2749 | } // Row | |
77566f2a | 2750 | } |
8ec526a4 | 2751 | |
77566f2a | 2752 | return object; |
8ec526a4 | 2753 | |
77566f2a | 2754 | } |
8ec526a4 | 2755 | |
2756 | //_____________________________________________________________________________ | |
2757 | void AliTRDCalibra::SetRelativeScale(Float_t RelativeScale) | |
77566f2a | 2758 | { |
2759 | // | |
8ec526a4 | 2760 | // Set the factor that will divide the deposited charge |
2761 | // to fit in the histo range [0,300] | |
77566f2a | 2762 | // |
77566f2a | 2763 | |
8ec526a4 | 2764 | if (RelativeScale > 0.0) { |
2765 | fRelativeScale = RelativeScale; | |
2766 | } | |
2767 | else { | |
2768 | AliInfo("RelativeScale must be strict positif!"); | |
2769 | } | |
2770 | ||
2771 | } | |
2772 | ||
2773 | //_____________________________________________________________________________ | |
2774 | void AliTRDCalibra::SetNz(Int_t i, Short_t Nz) | |
2775 | { | |
2776 | // | |
2777 | // Set the mode of calibration group in the z direction for the parameter i | |
2778 | // | |
2779 | ||
2780 | if ((Nz >= 0) && | |
2781 | (Nz < 5)) { | |
2782 | fNz[i] = Nz; | |
2783 | } | |
2784 | else { | |
2785 | AliInfo("You have to choose between 0 and 4"); | |
2786 | } | |
2787 | ||
2788 | } | |
2789 | ||
2790 | //_____________________________________________________________________________ | |
2791 | void AliTRDCalibra::SetNrphi(Int_t i, Short_t Nrphi) | |
2792 | { | |
2793 | // | |
2794 | // Set the mode of calibration group in the rphi direction for the parameter i | |
2795 | // | |
77566f2a | 2796 | |
8ec526a4 | 2797 | if ((Nrphi >= 0) && |
2798 | (Nrphi < 7)) { | |
2799 | fNrphi[i] = Nrphi; | |
2800 | } | |
2801 | else { | |
2802 | AliInfo("You have to choose between 0 and 6"); | |
2803 | } | |
2804 | ||
2805 | } | |
2806 | ||
2807 | //_____________________________________________________________________________ | |
2808 | void AliTRDCalibra::SetPeriodeFitPH(Int_t periodeFitPH) | |
2809 | { | |
2810 | // | |
2811 | // Set FitPH if 1 then each detector will be fitted | |
2812 | // | |
2813 | ||
2814 | if (periodeFitPH > 0) { | |
2815 | fFitPHPeriode = periodeFitPH; | |
2816 | } | |
2817 | else { | |
2818 | AliInfo("periodeFitPH must be higher than 0!"); | |
2819 | } | |
2820 | ||
2821 | } | |
2822 | ||
2823 | //_____________________________________________________________________________ | |
2824 | void AliTRDCalibra::SetBeginFitCharge(Float_t beginFitCharge) | |
2825 | { | |
2826 | // | |
2827 | // The fit of the deposited charge distribution begins at | |
2828 | // histo->Mean()/beginFitCharge | |
2829 | // You can here set beginFitCharge | |
2830 | // | |
2831 | ||
2832 | if (beginFitCharge > 0) { | |
2833 | fBeginFitCharge = beginFitCharge; | |
2834 | } | |
2835 | else { | |
2836 | AliInfo("beginFitCharge must be strict positif!"); | |
2837 | } | |
2838 | ||
2839 | } | |
2840 | ||
2841 | //_____________________________________________________________________________ | |
2842 | void AliTRDCalibra::SetT0Shift(Float_t t0Shift) | |
2843 | { | |
2844 | // | |
2845 | // The t0 calculated with the maximum positif slope is shift from t0Shift | |
2846 | // You can here set t0Shift | |
2847 | // | |
2848 | ||
2849 | if (t0Shift > 0) { | |
2850 | fT0Shift = t0Shift; | |
2851 | } | |
2852 | else { | |
2853 | AliInfo("t0Shift must be strict positif!"); | |
2854 | } | |
2855 | ||
2856 | } | |
2857 | ||
2858 | //_____________________________________________________________________________ | |
2859 | void AliTRDCalibra::SetRangeFitPRF(Float_t rangeFitPRF) | |
2860 | { | |
2861 | // | |
2862 | // The fit of the PRF is from -rangeFitPRF to rangeFitPRF | |
2863 | // You can here set rangeFitPRF | |
2864 | // | |
2865 | ||
2866 | if ((rangeFitPRF > 0) && | |
2867 | (rangeFitPRF <= 1.0)) { | |
2868 | fRangeFitPRF = rangeFitPRF; | |
2869 | } | |
2870 | else { | |
2871 | AliInfo("rangeFitPRF must be between 0 and 1.0"); | |
2872 | } | |
2873 | ||
2874 | } | |
2875 | ||
2876 | //_____________________________________________________________________________ | |
2877 | void AliTRDCalibra::SetRebin(Short_t rebin) | |
2878 | { | |
2879 | // | |
2880 | // Rebin with rebin time less bins the Ch histo | |
2881 | // You can set here rebin that should divide the number of bins of CH histo | |
2882 | // | |
2883 | ||
2884 | if (rebin > 0) { | |
2885 | fRebin = rebin; | |
2886 | AliInfo("You have to be sure that fRebin divides fNumberBinCharge used!"); | |
2887 | } | |
2888 | else { | |
2889 | AliInfo("You have to choose a positiv value!"); | |
2890 | } | |
2891 | ||
2892 | } | |
2893 | ||
2894 | //_____________________________________________________________________________ | |
2895 | TTree *AliTRDCalibra::Sum2Trees(const Char_t *filename1 | |
2896 | , const Char_t *filename2 | |
2897 | , const Char_t *variablecali) | |
2898 | { | |
2899 | // | |
2900 | // It returns the sum of two trees with the name variablecali | |
2901 | // in the files filenam1 and filename2 equivalent of merging two 2D histos | |
2902 | // The name of the resulting tree is the same as the two input trees | |
2903 | // variablecali can be treeCH2d, treePH2d or treePRF2d | |
2904 | // | |
2905 | ||
2906 | // Variables | |
2907 | TChain *treeChain = new TChain(variablecali); | |
2908 | TObjArray *vectorplace = new TObjArray(); | |
2909 | TObjArray *where = new TObjArray(); | |
77566f2a | 2910 | |
8ec526a4 | 2911 | // First tree |
2912 | // Take the tree | |
2913 | TFile *file1 = new TFile(filename1,"READ"); | |
77566f2a | 2914 | TTree *tree1 = (TTree *) file1->Get(variablecali); |
8ec526a4 | 2915 | |
2916 | gDirectory = gROOT; | |
2917 | ||
2918 | // Take the places | |
77566f2a | 2919 | vectorplace = ConvertTreeVector(tree1); |
8ec526a4 | 2920 | |
2921 | // Say where it is in tree 1 | |
2922 | for (Int_t jui = 0; jui < (Int_t) vectorplace->GetEntriesFast(); jui++) { | |
2923 | AliTRDPlace *placejui = new AliTRDPlace(); | |
2924 | placejui->SetPlace(jui); | |
2925 | TObjArray *chainplace = new TObjArray(); | |
2926 | chainplace->Add((TObject *) placejui); | |
2927 | where->Add((TObject *) chainplace); | |
77566f2a | 2928 | } |
8ec526a4 | 2929 | |
2930 | // Add to the chain | |
77566f2a | 2931 | treeChain->Add(filename1); |
2932 | delete file1; | |
77566f2a | 2933 | |
8ec526a4 | 2934 | // Second tree |
2935 | // Take the tree | |
2936 | TFile *file2 = new TFile(filename2,"READ"); | |
2937 | TTree *tree2 = (TTree *) file2->Get(variablecali); | |
77566f2a | 2938 | |
8ec526a4 | 2939 | gDirectory = gROOT; |
77566f2a | 2940 | |
8ec526a4 | 2941 | // Take the places |
2942 | TObjArray *vector2 = ConvertTreeVector(tree2); | |
77566f2a | 2943 | Int_t j = treeChain->GetEntries(); |
8ec526a4 | 2944 | |
2945 | for (Int_t jui = 0; jui < (Int_t) vector2->GetEntriesFast(); jui++) { | |
2946 | // Search if already found | |
2947 | Int_t place = SearchInTreeVector(vectorplace,((AliTRDPlace *) vector2->At(jui))->GetPlace()); | |
2948 | // Create a new element in the two std vectors | |
2949 | if (place == -1) { | |
2950 | AliTRDPlace *placejjui = new AliTRDPlace(); | |
2951 | placejjui->SetPlace((j+jui)); | |
2952 | TObjArray *chainplace = new TObjArray(); | |
2953 | chainplace->Add((TObject *) placejjui); | |
2954 | vectorplace->Add((TObject *) (vector2->At(jui))); | |
2955 | where->Add((TObject *) chainplace); | |
2956 | } | |
2957 | // Update the element at the place "place" in the std vector whereinthechain | |
77566f2a | 2958 | else { |
8ec526a4 | 2959 | AliTRDPlace *placejjui = new AliTRDPlace(); |
2960 | placejjui->SetPlace((j+jui)); | |
2961 | TObjArray *chainplace = ((TObjArray *) where->At(place)); | |
2962 | chainplace->Add((TObject *) placejjui); | |
2963 | where->AddAt((TObject *) chainplace,place); | |
77566f2a | 2964 | } |
2965 | } | |
8ec526a4 | 2966 | |
2967 | // Add to the Chain | |
77566f2a | 2968 | treeChain->Add(filename2); |
2969 | delete file2; | |
77566f2a | 2970 | |
8ec526a4 | 2971 | // Take care of the profile |
2972 | const Char_t *pattern = "P"; | |
77566f2a | 2973 | TTree *tree = 0x0; |
2974 | ||
8ec526a4 | 2975 | if (!strstr(variablecali,pattern)) { |
2976 | ||
2977 | // Ready to read the chain | |
77566f2a | 2978 | TH1F *his = 0x0; |
2979 | treeChain->SetBranchAddress("histo",&his); | |
8ec526a4 | 2980 | |
2981 | // Initialise the final tree | |
2982 | Int_t group = -1; | |
77566f2a | 2983 | TH1F *histsum = 0x0; |
2984 | ||
2985 | tree = new TTree(variablecali,variablecali); | |
2986 | tree->Branch("groupnumber",&group,"groupnumber/I"); | |
2987 | tree->Branch("histo","TH1F",&histsum,32000,0); | |
8ec526a4 | 2988 | |
2989 | // Init histsum | |
2990 | if (treeChain->GetEntries() < 1) { | |
2991 | return tree1; | |
2992 | } | |
77566f2a | 2993 | |
8ec526a4 | 2994 | for (Int_t h = 0; h < (Int_t) vectorplace->GetEntriesFast(); h++) { |
2995 | group = ((AliTRDPlace *) vectorplace->At(h))->GetPlace(); | |
2996 | TObjArray *chainplace = ((TObjArray *) where->At(h)); | |
2997 | treeChain->GetEntry(((AliTRDPlace *) chainplace->At(0))->GetPlace()); | |
77566f2a | 2998 | //Init for the first time |
8ec526a4 | 2999 | if (h == 0) { |
3000 | histsum = new TH1F("","",his->GetXaxis()->GetNbins() | |
3001 | ,his->GetXaxis()->GetBinLowEdge(1) | |
3002 | ,his->GetXaxis()->GetBinUpEdge(his->GetXaxis()->GetNbins())); | |
3003 | histsum->Sumw2(); | |
77566f2a | 3004 | } |
8ec526a4 | 3005 | // Reset for each new group |
77566f2a | 3006 | histsum->SetEntries(0.0); |
8ec526a4 | 3007 | for (Int_t l = 0; l <= histsum->GetXaxis()->GetNbins(); l++) { |
77566f2a | 3008 | histsum->SetBinContent(l,0.0); |
3009 | histsum->SetBinError(l,0.0); | |
3010 | } | |
3011 | histsum->Add(his,1); | |
8ec526a4 | 3012 | if ((Int_t) chainplace->GetEntriesFast() > 1) { |
3013 | for (Int_t s = 1; s < (Int_t) chainplace->GetEntriesFast(); s++) { | |
3014 | treeChain->GetEntry(((AliTRDPlace *) chainplace->At(s))->GetPlace()); | |
77566f2a | 3015 | histsum->Add(his,1); |
3016 | } | |
3017 | } | |
3018 | tree->Fill(); | |
3019 | } | |
8ec526a4 | 3020 | |
77566f2a | 3021 | } |
8ec526a4 | 3022 | else { |
3023 | ||
3024 | // Ready to read the chain | |
77566f2a | 3025 | TGraphErrors *his = 0x0; |
3026 | treeChain->SetBranchAddress("histo",&his); | |
3027 | ||
8ec526a4 | 3028 | // Initialise the final tree |
3029 | Int_t group = -1; | |
77566f2a | 3030 | TGraphErrors *histsum = 0x0; |
8ec526a4 | 3031 | Double_t *xref = 0x0; |
77566f2a | 3032 | |
3033 | tree = new TTree(variablecali,variablecali); | |
3034 | tree->Branch("groupnumber",&group,"groupnumber/I"); | |
3035 | tree->Branch("histo","TGraphErrors",&histsum,32000,0); | |
8ec526a4 | 3036 | |
3037 | // Init histsum | |
3038 | if (treeChain->GetEntries() < 1) { | |
3039 | return tree1; | |
3040 | } | |
3041 | ||
3042 | for (Int_t h = 0; h < (Int_t) vectorplace->GetEntriesFast(); h++) { | |
3043 | ||
3044 | group = ((AliTRDPlace *) vectorplace->At(h))->GetPlace(); | |
3045 | TObjArray *chainplace = ((TObjArray *) where->At(h)); | |
3046 | treeChain->GetEntry(((AliTRDPlace *) chainplace->At(0))->GetPlace()); | |
77566f2a | 3047 | //Init or reset for a new group |
3048 | Int_t nbins = his->GetN(); | |
3049 | Double_t *x; | |
8ec526a4 | 3050 | x = new Double_t[nbins]; |
77566f2a | 3051 | xref = his->GetX(); |
3052 | Double_t *ex; | |
8ec526a4 | 3053 | ex = new Double_t[nbins]; |
77566f2a | 3054 | Double_t *y; |
8ec526a4 | 3055 | y = new Double_t[nbins]; |
77566f2a | 3056 | Double_t *ey; |
8ec526a4 | 3057 | ey = new Double_t[nbins]; |
3058 | ||
3059 | for (Int_t lo = 0; lo < nbins; lo++) { | |
3060 | x[lo] = xref[lo]; | |
77566f2a | 3061 | ex[lo] = 0.0; |
3062 | y[lo] = 0.0; | |
3063 | ey[lo] = 0.0; | |
3064 | } | |
3065 | delete histsum; | |
3066 | histsum = new TGraphErrors(nbins,x,y,ex,ey); | |
8ec526a4 | 3067 | |
3068 | // Add the first | |
77566f2a | 3069 | histsum = AddProfiles(his,histsum); |
8ec526a4 | 3070 | if ((Int_t) chainplace->GetEntriesFast() > 1) { |
3071 | for (Int_t s = 1; s < (Int_t) chainplace->GetEntriesFast(); s++) { | |
3072 | treeChain->GetEntry(((AliTRDPlace *) chainplace->At(s))->GetPlace()); | |
77566f2a | 3073 | histsum = AddProfiles(his,histsum); |
3074 | } | |
3075 | } | |
8ec526a4 | 3076 | |
77566f2a | 3077 | tree->Fill(); |
8ec526a4 | 3078 | |
77566f2a | 3079 | } |
8ec526a4 | 3080 | |
77566f2a | 3081 | } |
8ec526a4 | 3082 | |
77566f2a | 3083 | return tree; |
8ec526a4 | 3084 | |
77566f2a | 3085 | } |
77566f2a | 3086 | |
8ec526a4 | 3087 | //____________Function fill 2D for the moment out of the code__________________ |
77566f2a | 3088 | |
8ec526a4 | 3089 | //____________Function fill 2D all objects from digits_________________________ |
3090 | Bool_t AliTRDCalibra::Create2DDiSimOnline(Int_t iev1, Int_t iev2) | |
77566f2a | 3091 | { |
3092 | // | |
8ec526a4 | 3093 | // Only for simulations, after the simulation, create the 2D histos |
3094 | // from the digits stored in the file "TRD.Digits.root" | |
77566f2a | 3095 | // Only for CH and PH |
3096 | // | |
77566f2a | 3097 | |
8ec526a4 | 3098 | const Int_t kNplan = 6; |
3099 | const Int_t kNcham = 5; | |
77566f2a | 3100 | |
8ec526a4 | 3101 | // RunLoader and so on |
77566f2a | 3102 | if (gAlice) { |
3103 | delete gAlice->GetRunLoader(); | |
3104 | delete gAlice; | |
8ec526a4 | 3105 | gAlice = 0; |
77566f2a | 3106 | } |
77566f2a | 3107 | |
8ec526a4 | 3108 | AliRunLoader *rl = AliRunLoader::Open("galice.root"); |
77566f2a | 3109 | if (!rl) { |
3110 | return kFALSE; | |
3111 | } | |
8ec526a4 | 3112 | |
77566f2a | 3113 | rl->LoadgAlice(); |
3114 | gAlice = rl->GetAliRun(); | |
3115 | if (!gAlice) { | |
3116 | return kFALSE; | |
3117 | } | |
3118 | ||
3119 | // Import the Trees for the event nEvent in the file | |
3120 | rl->LoadKinematics(); | |
3121 | rl->GetEvent(0); | |
3122 | rl->LoadHeader(); | |
3123 | ||
8ec526a4 | 3124 | AliLoader *loader = rl->GetLoader("TRDLoader"); |
77566f2a | 3125 | if (!loader) { |
3126 | AliInfo("No TRDLLoader found!"); | |
3127 | return kFALSE; | |
3128 | } | |
3129 | ||
3130 | // Get the pointer to the TRD detector | |
3131 | AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD"); | |
3132 | if (!trd) { | |
3133 | AliInfo("No TRD detector found"); | |
3134 | return kFALSE; | |
3135 | } | |
8ec526a4 | 3136 | |
77566f2a | 3137 | // Get the pointer to the geometry object |
3138 | AliTRDgeometry *geo; | |
3139 | if (trd) { | |
3140 | geo = trd->GetGeometry(); | |
3141 | } | |
3142 | else { | |
3143 | AliInfo("No TRD geometry found"); | |
3144 | return kFALSE; | |
3145 | } | |
3146 | ||
8ec526a4 | 3147 | // DB Setting |
77566f2a | 3148 | AliCDBManager *man = AliCDBManager::Instance(); |
3149 | if (!man) { | |
3150 | AliInfo("Could not get CDB Manager"); | |
3151 | return kFALSE; | |
3152 | } | |
3153 | ||
77566f2a | 3154 | // Get the parameter object |
3155 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
3156 | if (!parCom) { | |
3157 | AliInfo("Could not get CommonParam"); | |
3158 | return kFALSE; | |
3159 | } | |
3160 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
3161 | if (!cal) { | |
3162 | AliInfo("Could not get calibDB"); | |
3163 | return kFALSE; | |
3164 | } | |
3165 | ||
8ec526a4 | 3166 | // Some parameters |
3167 | fTimeMax = cal->GetNumberOfTimeBins(); | |
b43a3e17 | 3168 | fSf = (Float_t) parCom->GetSamplingFrequency(); |
8ec526a4 | 3169 | if (fRelativeScaleAuto) { |
3170 | fRelativeScale = 0; | |
3171 | } | |
3172 | else { | |
3173 | if (fRelativeScale <= 0.0) { | |
3174 | AliInfo("You have to set the relativescale factor per hand!"); | |
3175 | return kFALSE; | |
3176 | } | |
3177 | } | |
77566f2a | 3178 | |
8ec526a4 | 3179 | // Create the 2D histos corresponding to the pad group calibration mode |
3180 | if (fCH2dOn) { | |
77566f2a | 3181 | |
8ec526a4 | 3182 | AliInfo(Form("We will fill the CH2d histo with the pad calibration mode: Nz %d, and Nrphi %d" |
3183 | ,fNz[0] | |
3184 | ,fNrphi[0])); | |
77566f2a | 3185 | |
8ec526a4 | 3186 | // Calcul the number of Xbins |
3187 | fNtotal[0] = 0; | |
77566f2a | 3188 | ModePadCalibration(2,0); |
3189 | ModePadFragmentation(0,2,0,0); | |
8ec526a4 | 3190 | fDetChamb2[0] = fNfragZ[0] * fNfragRphi[0]; |
3191 | fNtotal[0] += 6 * 18 * fDetChamb2[0]; | |
77566f2a | 3192 | ModePadCalibration(0,0); |
3193 | ModePadFragmentation(0,0,0,0); | |
8ec526a4 | 3194 | fDetChamb0[0] = fNfragZ[0] * fNfragRphi[0]; |
3195 | fNtotal[0] += 6 * 4 * 18 * fDetChamb0[0]; | |
3196 | AliInfo(Form("Total number of Xbins: %d",fNtotal[0])); | |
3197 | ||
3198 | // Create the 2D histo | |
3199 | if (fHisto2d) { | |
3200 | CreateCH2d(fNtotal[0]); | |
3201 | } | |
3202 | if (fVector2d) { | |
3203 | fVectorCH = new TObjArray(); | |
3204 | fPlaCH = new TObjArray(); | |
3205 | } | |
77566f2a | 3206 | |
3207 | } | |
3208 | ||
8ec526a4 | 3209 | if (fPH2dOn) { |
3210 | ||
3211 | AliInfo(Form("We will fill the PH2d histo with the pad calibration mode: Nz %d, and Nrphi %d" | |
3212 | ,fNz[1] | |
3213 | ,fNrphi[1])); | |
77566f2a | 3214 | |
8ec526a4 | 3215 | // Calcul the number of Xbins |
3216 | fNtotal[1] = 0; | |
77566f2a | 3217 | ModePadCalibration(2,1); |
3218 | ModePadFragmentation(0,2,0,1); | |
8ec526a4 | 3219 | fDetChamb2[1] = fNfragZ[1] * fNfragRphi[1]; |
3220 | fNtotal[1] += 6 * 18 * fDetChamb2[1]; | |
77566f2a | 3221 | ModePadCalibration(0,1); |
3222 | ModePadFragmentation(0,0,0,1); | |
8ec526a4 | 3223 | fDetChamb0[1] = fNfragZ[1] * fNfragRphi[1]; |
3224 | fNtotal[1] += 6 * 4 * 18 * fDetChamb0[1]; | |
3225 | AliInfo(Form("Total number of Xbins: %d",fNtotal[1])); | |
77566f2a | 3226 | |
8ec526a4 | 3227 | // Create the 2D histo |
3228 | if (fHisto2d) { | |
3229 | CreatePH2d(fNtotal[1]); | |
3230 | } | |
3231 | if (fVector2d) { | |
3232 | fVectorPH = new TObjArray(); | |
3233 | fPlaPH = new TObjArray(); | |
3234 | } | |
77566f2a | 3235 | |
3236 | } | |
3237 | ||
3238 | loader->LoadDigits(); | |
3239 | AliInfo("LoadDigits "); | |
3240 | AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(); | |
77566f2a | 3241 | |
8ec526a4 | 3242 | //iev2 egal to the max if 0 |
3243 | if (iev2 == 0) { | |
3244 | iev2 = rl->GetNumberOfEvents(); | |
3245 | AliInfo(Form("Total number of events: %d",iev2)); | |
3246 | } | |
3247 | ||
3248 | // Loop on event | |
77566f2a | 3249 | for (Int_t ievent = iev1; ievent < iev2; ievent++) { |
3250 | AliInfo(Form("Process event %d",ievent)); | |
3251 | rl->GetEvent(ievent); | |
8ec526a4 | 3252 | if (!loader->TreeD()) { |
77566f2a | 3253 | AliInfo("loader Loading Digits ... "); |
3254 | loader->LoadDigits(); | |
3255 | } | |
3256 | digitsManager->ReadDigits(loader->TreeD()); | |
3257 | AliInfo("digitsManager Read Digits Done"); | |
3258 | // Read the digits from the file | |
3259 | if (!(digitsManager->ReadDigits(loader->TreeD()))) { | |
3260 | return kFALSE; | |
3261 | } | |
3262 | ||
8ec526a4 | 3263 | // Loop on detector |
3264 | for (Int_t iSect = 0; iSect < 18; iSect++) { | |
3265 | for (Int_t iChamb = 0; iChamb < kNcham; iChamb++) { | |
3266 | for (Int_t iPlane = 0; iPlane < kNplan; iPlane++) { | |
77566f2a | 3267 | |
8ec526a4 | 3268 | // A little geometry: |
77566f2a | 3269 | Int_t iDet = geo->GetDetector(iPlane,iChamb,iSect); |
3270 | Int_t rowMax = parCom->GetRowMax(iPlane,iChamb,iSect); | |
3271 | Int_t colMax = parCom->GetColMax(iPlane); | |
3272 | ||
8ec526a4 | 3273 | // Variables for the group |
3274 | LocalisationDetectorXbins(iDet); | |
3275 | ||
3276 | // In the cas of charge | |
77566f2a | 3277 | Float_t *amptotal; |
8ec526a4 | 3278 | amptotal = new Float_t[fNfragRphi[0]*fNfragZ[0]]; |
3279 | if (fCH2dOn) { | |
3280 | for (Int_t k = 0; k < fNfragRphi[0]*fNfragZ[0]; k++) { | |
77566f2a | 3281 | amptotal[k] = 0.0; |
3282 | } | |
3283 | } | |
3284 | ||
8ec526a4 | 3285 | // Loop through the detector pixel |
77566f2a | 3286 | for (Int_t time = 0; time < fTimeMax; time++) { |
3287 | for (Int_t col = 0; col < colMax; col++) { | |
3288 | for (Int_t row = 0; row < rowMax; row++) { | |
77566f2a | 3289 | |
8ec526a4 | 3290 | // Amplitude and position in pad group |
3291 | AliTRDdigit *digit = digitsManager->GetDigit(row,col,time,iDet); | |
3292 | Int_t amp = digit->GetAmp(); | |
3293 | Int_t posr[2] = {0,0}; | |
3294 | Int_t posc[2] = {0,0}; | |
3295 | if ((fCH2dOn) && | |
3296 | (fNnZ[0] != 0)) { | |
3297 | posr[0] = (Int_t) row / fNnZ[0]; | |
3298 | } | |
3299 | if ((fCH2dOn) && | |
3300 | (fNnRphi[0] != 0)) { | |
3301 | posc[0] = (Int_t) col / fNnRphi[0]; | |
3302 | } | |
3303 | if ((fPH2dOn) && | |
3304 | (fNnZ[1] != 0)) { | |
3305 | posr[1] = (Int_t) row / fNnZ[1]; | |
3306 | } | |
3307 | if ((fPH2dOn) && | |
3308 | (fNnRphi[1] != 0)) { | |
3309 | posc[1] = (Int_t) col / fNnRphi[1]; | |
3310 | } | |
77566f2a | 3311 | |
77566f2a | 3312 | // Total spectrum |
8ec526a4 | 3313 | if (fCH2dOn) { |
3314 | if (amp < fThresholdDigit) { | |
3315 | amp = 0; | |
3316 | } | |
3317 | amptotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += amp; | |
77566f2a | 3318 | } |
8ec526a4 | 3319 | if (fPH2dOn) { |
3320 | if (fHisto2d) { | |
3321 | fPH2d->Fill((fXbins[1]+posc[1]*fNfragZ[1]+posr[1])+0.5,(Float_t) time/fSf,(Double_t) amp); | |
3322 | } | |
3323 | if (fVector2d) { | |
3324 | UpdateVectorPH((fXbins[1]+posc[1]*fNfragZ[1]+posr[1]),time,(Double_t) amp); | |
3325 | } | |
77566f2a | 3326 | } |
8ec526a4 | 3327 | |
3328 | // Memory stuff | |
77566f2a | 3329 | delete digit; |
77566f2a | 3330 | |
8ec526a4 | 3331 | } // Boucle row |
3332 | } // Boucle col | |
3333 | } // Boucle time | |
3334 | ||
3335 | if (fCH2dOn) { | |
77566f2a | 3336 | |
8ec526a4 | 3337 | // If automatic scale |
3338 | if ((fCountRelativeScale < 100) && (fRelativeScaleAuto)) { | |
3339 | // Take only the one zone track | |
3340 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3341 | if ((fCountRelativeScale < 100) && (amptotal[k] > 2.0)) { | |
3342 | fRelativeScale += amptotal[k]*0.014*0.01; | |
3343 | fCountRelativeScale++; | |
3344 | } | |
3345 | } | |
3346 | } | |
3347 | ||
3348 | // We fill the CH2d after having scale with the first 100 | |
3349 | if ((fCountRelativeScale >= 100) && (fRelativeScaleAuto)) { | |
3350 | // Case of | |
3351 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3352 | if (fHisto2d && | |
3353 | (amptotal[k] > 0.0)) { | |
3354 | fCH2d->Fill(fXbins[0]+k+0.5,amptotal[k]/fRelativeScale); | |
3355 | } | |
3356 | if (fVector2d && | |
3357 | (amptotal[k] > 0.0)) { | |
3358 | UpdateVectorCH(fXbins[0]+k ,amptotal[k]/fRelativeScale); | |
3359 | } | |
3360 | } | |
77566f2a | 3361 | } |
77566f2a | 3362 | |
8ec526a4 | 3363 | // No relative salce |
3364 | if (!fRelativeScaleAuto) { | |
3365 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3366 | if (fHisto2d && | |
3367 | (amptotal[k] > 0.0)) { | |
3368 | fCH2d->Fill(fXbins[0]+k+0.5, amptotal[k]/fRelativeScale); | |
3369 | } | |
3370 | if (fVector2d && | |
3371 | (amptotal[k] > 0.0)) { | |
3372 | UpdateVectorCH(fXbins[0]+k, amptotal[k]/fRelativeScale); | |
3373 | } | |
3374 | } | |
3375 | } | |
77566f2a | 3376 | |
8ec526a4 | 3377 | } |
3378 | ||
3379 | delete amptotal; | |
77566f2a | 3380 | |
8ec526a4 | 3381 | } // Boucle chamber |
3382 | } // Boucle plane | |
3383 | } // Boucle sect | |
77566f2a | 3384 | |
3385 | loader->UnloadDigits(); | |
3386 | ||
8ec526a4 | 3387 | } // Boucle event |
77566f2a | 3388 | |
8ec526a4 | 3389 | if (fDebug == 1) { |
3390 | if (fPH2dOn && fHisto2d) { | |
3391 | PlotPH2d(); | |
3392 | } | |
3393 | if (fCH2dOn && fHisto2d) { | |
3394 | PlotCH2d(); | |
3395 | } | |
77566f2a | 3396 | } |
3397 | ||
8ec526a4 | 3398 | if (fWrite[0] || fWrite[1]) { |
77566f2a | 3399 | |
8ec526a4 | 3400 | TFile *fout = TFile::Open(fWriteName,"RECREATE"); |
3401 | // Check if the file could be opened | |
77566f2a | 3402 | if (!fout || !fout->IsOpen()) { |
3403 | AliInfo("<No File found!"); | |
3404 | return kFALSE; | |
3405 | } | |
77566f2a | 3406 | |
8ec526a4 | 3407 | if (fCH2dOn && fHisto2d && fWrite[0]) { |
3408 | fout->WriteTObject(fCH2d); | |
3409 | } | |
3410 | if (fPH2dOn && fHisto2d && fWrite[1]) { | |
3411 | fout->WriteTObject(fPH2d); | |
3412 | } | |
77566f2a | 3413 | |
8ec526a4 | 3414 | if (fVector2d && fCH2dOn && fWrite[0]) { |
3415 | TString name("Nz"); | |
3416 | name += fNz[0]; | |
3417 | name += "Nrphi"; | |
3418 | name += fNrphi[0]; | |
3419 | TTree *treeCH2d = ConvertVectorCTTreeHisto(fVectorCH,fPlaCH,"treeCH2d",(const char *) name); | |
77566f2a | 3420 | fout->WriteTObject(treeCH2d); |
3421 | } | |
3422 | ||
8ec526a4 | 3423 | if (fVector2d && fPH2dOn && fWrite[1]) { |
3424 | TString name("Nz"); | |
3425 | name += fNz[1]; | |
3426 | name += "Nrphi"; | |
3427 | name += fNrphi[1]; | |
3428 | TTree *treePH2d = ConvertVectorPTreeHisto(fVectorPH,fPlaPH,"treePH2d",(const char *) name); | |
77566f2a | 3429 | fout->WriteTObject(treePH2d); |
3430 | } | |
8ec526a4 | 3431 | |
3432 | fout->Close(); | |
3433 | ||
77566f2a | 3434 | } |
3435 | ||
3436 | return kTRUE; | |
3437 | ||
3438 | } | |
77566f2a | 3439 | |
8ec526a4 | 3440 | //____________Function fill 2D all objects from Raw Data_______________________ |
77566f2a | 3441 | Bool_t AliTRDCalibra::Create2DRaDaOnline(Int_t iev1, Int_t iev2) |
3442 | { | |
3443 | // | |
8ec526a4 | 3444 | // After having written the RAW DATA in the current directory, create the |
3445 | // 2D histos from these RAW DATA | |
77566f2a | 3446 | // Only for CH and PH |
3447 | // | |
3448 | ||
8ec526a4 | 3449 | const Int_t kNplan = 6; |
3450 | const Int_t kNcham = 5; | |
77566f2a | 3451 | TString dirname("."); |
3452 | ||
8ec526a4 | 3453 | // DB Setting |
77566f2a | 3454 | AliCDBManager *man = AliCDBManager::Instance(); |
3455 | if (!man) { | |
3456 | AliInfo("Could not get CDB Manager"); | |
3457 | return kFALSE; | |
3458 | } | |
8ec526a4 | 3459 | |
77566f2a | 3460 | // Get the parameter object |
3461 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
3462 | if (!parCom) { | |
3463 | AliInfo("Could not get CommonParam"); | |
3464 | return kFALSE; | |
3465 | } | |
8ec526a4 | 3466 | |
77566f2a | 3467 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
3468 | if (!cal) { | |
3469 | AliInfo("Could not get calibDB"); | |
3470 | return kFALSE; | |
3471 | } | |
3472 | ||
77566f2a | 3473 | // Some parameters |
8ec526a4 | 3474 | fTimeMax = cal->GetNumberOfTimeBins(); |
b43a3e17 | 3475 | fSf = (Float_t) parCom->GetSamplingFrequency(); |
8ec526a4 | 3476 | if (fRelativeScaleAuto) { |
3477 | fRelativeScale = 0; | |
3478 | } | |
3479 | else { | |
3480 | if (fRelativeScale <= 0.0) { | |
3481 | AliInfo("You have to set the relativescale factor per hand!"); | |
3482 | return kFALSE; | |
3483 | } | |
3484 | } | |
77566f2a | 3485 | |
8ec526a4 | 3486 | // Create the 2D histo corresponding to the pad group calibration mode |
3487 | if (fCH2dOn) { | |
77566f2a | 3488 | |
8ec526a4 | 3489 | AliInfo(Form("We will fill the CH2d histo with the pad calibration mode: Nz %d, and Nrphi %d" |
3490 | ,fNz[0] | |
3491 | ,fNrphi[0])); | |
77566f2a | 3492 | |
8ec526a4 | 3493 | // Calcul the number of Xbins |
3494 | fNtotal[0] = 0; | |
77566f2a | 3495 | ModePadCalibration(2,0); |
3496 | ModePadFragmentation(0,2,0,0); | |
8ec526a4 | 3497 | fDetChamb2[0] = fNfragZ[0] * fNfragRphi[0]; |
3498 | fNtotal[0] += 6 * 18 * fDetChamb2[0]; | |
77566f2a | 3499 | ModePadCalibration(0,0); |
3500 | ModePadFragmentation(0,0,0,0); | |
8ec526a4 | 3501 | fDetChamb0[0] = fNfragZ[0] * fNfragRphi[0]; |
3502 | fNtotal[0] += 6 * 4 * 18 * fDetChamb0[0]; | |
3503 | AliInfo(Form("Total number of Xbins: %d",fNtotal[0])); | |
77566f2a | 3504 | |
8ec526a4 | 3505 | // Create the 2D histo |
3506 | if (fHisto2d) { | |
3507 | CreateCH2d(fNtotal[0]); | |
3508 | } | |
3509 | if (fVector2d) { | |
3510 | fVectorCH = new TObjArray(); | |
3511 | fPlaCH = new TObjArray(); | |
3512 | } | |
3513 | ||
77566f2a | 3514 | } |
3515 | ||
3516 | if(fPH2dOn) { | |
8ec526a4 | 3517 | |
3518 | AliInfo(Form("We will fill the PH2d histo with the pad calibration mode: Nz %d, and Nrphi %d" | |
3519 | ,fNz[1] | |
3520 | ,fNrphi[1])); | |
77566f2a | 3521 | |
8ec526a4 | 3522 | // Calcul the number of Xbins |
3523 | fNtotal[1] = 0; | |
77566f2a | 3524 | ModePadCalibration(2,1); |
3525 | ModePadFragmentation(0,2,0,1); | |
8ec526a4 | 3526 | fDetChamb2[1] = fNfragZ[1] * fNfragRphi[1]; |
3527 | fNtotal[1] += 6 * 18 * fDetChamb2[1]; | |
77566f2a | 3528 | ModePadCalibration(0,1); |
3529 | ModePadFragmentation(0,0,0,1); | |
8ec526a4 | 3530 | fDetChamb0[1] = fNfragZ[1] * fNfragRphi[1]; |
3531 | fNtotal[1] += 6 * 4 * 18 * fDetChamb0[1]; | |
3532 | AliInfo(Form("Total number of Xbins: %d",fNtotal[1])); | |
77566f2a | 3533 | |
8ec526a4 | 3534 | // Create the 2D histo |
3535 | if (fHisto2d) { | |
3536 | CreatePH2d(fNtotal[1]); | |
3537 | } | |
3538 | if (fVector2d){ | |
3539 | fVectorPH = new TObjArray(); | |
3540 | fPlaPH = new TObjArray(); | |
3541 | } | |
77566f2a | 3542 | |
3543 | } | |
77566f2a | 3544 | |
3545 | AliTRDrawData *rawdata = new AliTRDrawData(); | |
3546 | AliInfo("AliTRDrawData object created "); | |
3547 | ||
8ec526a4 | 3548 | // Loop on events |
77566f2a | 3549 | for (Int_t ievent = iev1; ievent < iev2; ievent++) { |
77566f2a | 3550 | |
8ec526a4 | 3551 | // AliRawReaderFile |
77566f2a | 3552 | AliRawReaderFile *readerfile = new AliRawReaderFile(dirname,ievent); |
8ec526a4 | 3553 | if (!readerfile) { |
77566f2a | 3554 | AliInfo("No readerfile found!"); |
3555 | return kFALSE; | |
3556 | } | |
3557 | ||
77566f2a | 3558 | AliTRDdigitsManager *digitsManager = rawdata->Raw2Digits((AliRawReader *) readerfile); |
8ec526a4 | 3559 | if (!digitsManager) { |
77566f2a | 3560 | AliInfo("No DigitsManager done!"); |
3561 | return kFALSE; | |
3562 | } | |
3563 | ||
8ec526a4 | 3564 | // Loop on detectors |
3565 | for (Int_t iSect = 0; iSect < 18; iSect++) { | |
3566 | for (Int_t iPlane = 0; iPlane < kNplan; iPlane++) { | |
3567 | for (Int_t iChamb = 0; iChamb < kNcham; iChamb++) { | |
77566f2a | 3568 | |
8ec526a4 | 3569 | // A little geometry: |
77566f2a | 3570 | Int_t iDet = AliTRDgeometry::GetDetector(iPlane,iChamb,iSect); |
3571 | Int_t rowMax = parCom->GetRowMax(iPlane,iChamb,iSect); | |
3572 | Int_t colMax = parCom->GetColMax(iPlane); | |
3573 | ||
8ec526a4 | 3574 | // Variables for the group |
3575 | LocalisationDetectorXbins(iDet); | |
3576 | ||
3577 | // In the cas of charge | |
77566f2a | 3578 | Float_t *amptotal; |
8ec526a4 | 3579 | amptotal = new Float_t[fNfragRphi[0]*fNfragZ[0]]; |
3580 | if(fCH2dOn) { | |
3581 | for (Int_t k = 0; k < fNfragRphi[0]*fNfragZ[0]; k++) { | |
77566f2a | 3582 | amptotal[k] = 0.0; |
3583 | } | |
3584 | } | |
8ec526a4 | 3585 | |
3586 | // Loop through the detector pixel | |
77566f2a | 3587 | for (Int_t time = 0; time < fTimeMax; time++) { |
3588 | for (Int_t col = 0; col < colMax; col++) { | |
3589 | for (Int_t row = 0; row < rowMax; row++) { | |
3590 | ||
8ec526a4 | 3591 | // Amplitude and position of the digit |
3592 | AliTRDdigit *digit = digitsManager->GetDigit(row,col,time,iDet); | |
3593 | Int_t amp = digit->GetAmp(); | |
3594 | Int_t posr[2] = { 0, 0 }; | |
3595 | Int_t posc[2] = { 0, 0 }; | |
3596 | if ((fCH2dOn) && | |
3597 | (fNnZ[0] != 0)) { | |
3598 | posr[0] = (Int_t) row / fNnZ[0]; | |
3599 | } | |
3600 | if ((fCH2dOn) && | |
3601 | (fNnRphi[0] != 0)) { | |
3602 | posc[0] = (Int_t) col / fNnRphi[0]; | |
3603 | } | |
3604 | if ((fPH2dOn) && | |
3605 | (fNnZ[1] != 0)) { | |
3606 | posr[1] = (Int_t) row / fNnZ[1]; | |
3607 | } | |
3608 | if ((fPH2dOn) && | |
3609 | (fNnRphi[1] != 0)) { | |
3610 | posc[1] = (Int_t) col / fNnRphi[1]; | |
3611 | } | |
77566f2a | 3612 | |
3613 | // Total spectrum | |
8ec526a4 | 3614 | if (fCH2dOn) { |
3615 | if (amp < fThresholdDigit) { | |
3616 | amp = 0; | |
3617 | } | |
3618 | amptotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += amp; | |
77566f2a | 3619 | } |
3620 | ||
8ec526a4 | 3621 | if (fPH2dOn ) { |
3622 | if (fHisto2d) { | |
3623 | fPH2d->Fill((fXbins[1]+posc[1]*fNfragZ[1]+posr[1])+0.5,(Float_t)time/fSf,amp); | |
3624 | } | |
3625 | if (fVector2d) { | |
3626 | UpdateVectorPH(fXbins[1]+posc[1]*fNfragZ[1]+posr[1],time,amp); | |
3627 | } | |
3628 | } | |
77566f2a | 3629 | |
3630 | delete digit; | |
77566f2a | 3631 | |
8ec526a4 | 3632 | } // Boucle row |
3633 | } // Boucle col | |
3634 | } // Boucle time | |
77566f2a | 3635 | |
8ec526a4 | 3636 | if (fCH2dOn) { |
77566f2a | 3637 | |
8ec526a4 | 3638 | // If automatic scale |
3639 | if ((fCountRelativeScale < 100) && (fRelativeScaleAuto)) { | |
3640 | // Take only the one zone track | |
3641 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3642 | if ((fCountRelativeScale < 100) && (amptotal[k] > 2.0)) { | |
3643 | fRelativeScale += amptotal[k] * 0.014 * 0.01; | |
3644 | fCountRelativeScale++; | |
3645 | } | |
3646 | } | |
3647 | } | |
3648 | ||
3649 | // We fill the CH2d after having scale with the first 100 | |
3650 | if ((fCountRelativeScale >= 100) && (fRelativeScaleAuto)) { | |
3651 | // Case of | |
3652 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3653 | if (fHisto2d && (amptotal[k] > 0.0)) { | |
3654 | fCH2d->Fill(fXbins[0]+k+0.5,amptotal[k]/fRelativeScale); | |
3655 | } | |
3656 | if (fVector2d && (amptotal[k] > 0.0)) { | |
3657 | UpdateVectorCH(fXbins[0]+k, amptotal[k]/fRelativeScale); | |
3658 | } | |
3659 | } | |
3660 | } | |
3661 | ||
3662 | // No relative salce | |
3663 | if (!fRelativeScaleAuto) { | |
3664 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3665 | if (fHisto2d && | |
3666 | (amptotal[k] > 0.0)) { | |
3667 | fCH2d->Fill(fXbins[0]+k+0.5,amptotal[k]/fRelativeScale); | |
3668 | } | |
3669 | if (fVector2d && | |
3670 | (amptotal[k] > 0.0)) { | |
3671 | UpdateVectorCH(fXbins[0]+k, amptotal[k]/fRelativeScale); | |
3672 | } | |
3673 | } | |
77566f2a | 3674 | } |
77566f2a | 3675 | |
8ec526a4 | 3676 | } |
3677 | ||
77566f2a | 3678 | delete amptotal; |
3679 | ||
8ec526a4 | 3680 | } // Boucle chamber |
3681 | } // Boucle plane | |
3682 | } // Boucle sect | |
77566f2a | 3683 | |
3684 | delete digitsManager; | |
3685 | delete readerfile; | |
77566f2a | 3686 | |
8ec526a4 | 3687 | } // Boucle event |
3688 | ||
3689 | if (fDebug == 1) { | |
3690 | if (fPH2dOn && fHisto2d) { | |
3691 | PlotPH2d(); | |
3692 | } | |
3693 | if (fCH2dOn && fHisto2d) { | |
3694 | PlotCH2d(); | |
3695 | } | |
77566f2a | 3696 | } |
3697 | ||
8ec526a4 | 3698 | if (fWrite[0] || fWrite[1]) { |
77566f2a | 3699 | |
3700 | TFile *fout = TFile::Open(fWriteName,"UPDATE"); | |
8ec526a4 | 3701 | // Check if the file could be opened |
77566f2a | 3702 | if (!fout || !fout->IsOpen()) { |
3703 | AliInfo("<No File found!"); | |
3704 | return kFALSE; | |
3705 | } | |
77566f2a | 3706 | |
8ec526a4 | 3707 | if (fCH2dOn && fHisto2d && fWrite[0]) { |
3708 | fout->WriteTObject(fCH2d); | |
3709 | } | |
3710 | if (fPH2dOn && fHisto2d && fWrite[1]) { | |
3711 | fout->WriteTObject(fPH2d); | |
3712 | } | |
77566f2a | 3713 | |
8ec526a4 | 3714 | if (fVector2d && fCH2dOn && fWrite[0]) { |
3715 | TString name("Nz"); | |
3716 | name += fNz[0]; | |
3717 | name += "Nrphi"; | |
3718 | name += fNrphi[0]; | |
3719 | TTree *treeCH2d = ConvertVectorCTTreeHisto(fVectorCH,fPlaCH,"treeCH2d",(const Char_t *) name); | |
77566f2a | 3720 | fout->WriteTObject(treeCH2d); |
3721 | } | |
3722 | ||
8ec526a4 | 3723 | if (fVector2d && fPH2dOn && fWrite[1]) { |
3724 | TString name("Nz"); | |
3725 | name += fNz[1]; | |
3726 | name += "Nrphi"; | |
3727 | name += fNrphi[1]; | |
3728 | TTree *treePH2d = ConvertVectorPTreeHisto(fVectorPH,fPlaPH,"treePH2d",(const Char_t *) name); | |
77566f2a | 3729 | fout->WriteTObject(treePH2d); |
3730 | } | |
3731 | ||
3732 | } | |
3733 | ||
3734 | return kTRUE; | |
3735 | ||
3736 | } | |
77566f2a | 3737 | |
8ec526a4 | 3738 | //____________Pad Calibration Public___________________________________________ |
3739 | ||
3740 | //____________Define the number of pads per group for one detector and one calibration | |
77566f2a | 3741 | void AliTRDCalibra::ModePadCalibration(Int_t iChamb, Int_t i) |
3742 | { | |
3743 | // | |
3744 | // Definition of the calibration mode | |
3745 | // from Nz and Nrphi, the number of row and col pads per calibration groups are setted | |
3746 | // | |
3747 | ||
3748 | ||
8ec526a4 | 3749 | fNnZ[i] = 0; |
3750 | fNnRphi[i] = 0; | |
77566f2a | 3751 | |
8ec526a4 | 3752 | if ((fNz[i] == 0) && (iChamb == 2)) { |
3753 | fNnZ[i] = 12; | |
77566f2a | 3754 | } |
8ec526a4 | 3755 | if ((fNz[i] == 0) && (iChamb != 2)) { |
3756 | fNnZ[i] = 16; | |
77566f2a | 3757 | } |
8ec526a4 | 3758 | if ((fNz[i] == 1) && (iChamb == 2)) { |
3759 | fNnZ[i] = 6; | |
77566f2a | 3760 | } |
8ec526a4 | 3761 | if ((fNz[i] == 1) && (iChamb != 2)) { |
3762 | fNnZ[i] = 8; | |
77566f2a | 3763 | } |
8ec526a4 | 3764 | if ((fNz[i] == 2) && (iChamb == 2)) { |
3765 | fNnZ[i] = 3; | |
77566f2a | 3766 | } |
8ec526a4 | 3767 | if ((fNz[i] == 2) && (iChamb != 2)) { |
3768 | fNnZ[i] = 4; | |
77566f2a | 3769 | } |
8ec526a4 | 3770 | if (fNz[i] == 3) { |
3771 | fNnZ[i] = 2; | |
77566f2a | 3772 | } |
8ec526a4 | 3773 | if (fNz[i] == 4) { |
3774 | fNnZ[i] = 1; | |
77566f2a | 3775 | } |
3776 | ||
8ec526a4 | 3777 | if (fNrphi[i] == 0) { |
3778 | fNnRphi[i] = 144; | |
77566f2a | 3779 | } |
8ec526a4 | 3780 | if (fNrphi[i] == 1) { |
3781 | fNnRphi[i] = 72; | |
77566f2a | 3782 | } |
8ec526a4 | 3783 | if (fNrphi[i] == 2) { |
3784 | fNnRphi[i] = 36; | |
77566f2a | 3785 | } |
8ec526a4 | 3786 | if (fNrphi[i] == 3) { |
3787 | fNnRphi[i] = 18; | |
77566f2a | 3788 | } |
8ec526a4 | 3789 | if (fNrphi[i] == 4) { |
3790 | fNnRphi[i] = 9; | |
77566f2a | 3791 | } |
8ec526a4 | 3792 | if (fNrphi[i] == 5) { |
3793 | fNnRphi[i] = 4; | |
77566f2a | 3794 | } |
8ec526a4 | 3795 | if (fNrphi[i] == 6) { |
3796 | fNnRphi[i] = 1; | |
77566f2a | 3797 | } |
8ec526a4 | 3798 | |
77566f2a | 3799 | } |
8ec526a4 | 3800 | |
3801 | //____________Define the number of pad groups in one detector for one calibration | |
77566f2a | 3802 | Bool_t AliTRDCalibra::ModePadFragmentation(Int_t iPlane,Int_t iChamb, Int_t iSect, Int_t i) |
3803 | { | |
3804 | // | |
3805 | // Definition of the calibration mode | |
8ec526a4 | 3806 | // From the number of row and col pads per calibration groups the |
3807 | // number of calibration groups are setted | |
77566f2a | 3808 | // |
3809 | ||
8ec526a4 | 3810 | fNfragZ[i] = 0; |
3811 | fNfragRphi[i] = 0; | |
77566f2a | 3812 | |
3813 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
3814 | if (!parCom) { | |
3815 | AliInfo("Could not get CommonParam Manager"); | |
3816 | return kFALSE; | |
3817 | } | |
3818 | ||
8ec526a4 | 3819 | // A little geometry: |
77566f2a | 3820 | Int_t rowMax = parCom->GetRowMax(iPlane,iChamb,iSect); |
3821 | Int_t colMax = parCom->GetColMax(iPlane); | |
3822 | ||
8ec526a4 | 3823 | // The fragmentation |
3824 | if (fNnZ[i] != 0) { | |
3825 | fNfragZ[i] = (Int_t) rowMax / fNnZ[i]; | |
3826 | } | |
77566f2a | 3827 | |
8ec526a4 | 3828 | if (fNnRphi[i] != 0) { |
3829 | fNfragRphi[i] = (Int_t) colMax / fNnRphi[i]; | |
3830 | } | |
77566f2a | 3831 | |
3832 | return kTRUE; | |
77566f2a | 3833 | |
8ec526a4 | 3834 | } |
77566f2a | 3835 | |
8ec526a4 | 3836 | //____________Protected Functions______________________________________________ |
3837 | //____________Create the 2D histo to be filled online__________________________ | |
3838 | // | |
77566f2a | 3839 | |
8ec526a4 | 3840 | //_____________________________________________________________________________ |
3841 | void AliTRDCalibra::CreatePRF2d(Int_t nn) | |
77566f2a | 3842 | { |
3843 | // | |
3844 | // Create the 2D histos | |
3845 | // | |
3846 | ||
8ec526a4 | 3847 | TString name("Nz"); |
3848 | name += fNz[2]; | |
3849 | name += "Nrphi"; | |
3850 | name += fNrphi[2]; | |
3851 | ||
3852 | fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name | |
3853 | ,nn,0,nn,fNumberBinPRF,-1.0,1.0); | |
77566f2a | 3854 | fPRF2d->SetXTitle("Det/pad groups"); |
3855 | fPRF2d->SetYTitle("Position x/W [pad width units]"); | |
3856 | fPRF2d->SetZTitle("Q_{i}/Q_{total}"); | |
3857 | fPRF2d->SetStats(0); | |
77566f2a | 3858 | |
3859 | } | |
3860 | ||
8ec526a4 | 3861 | //_____________________________________________________________________________ |
3862 | void AliTRDCalibra::CreatePH2d(Int_t nn) | |
77566f2a | 3863 | { |
3864 | // | |
3865 | // Create the 2D histos | |
3866 | // | |
3867 | ||
8ec526a4 | 3868 | TString name("Nz"); |
3869 | name += fNz[1]; | |
3870 | name += "Nrphi"; | |
3871 | name += fNrphi[1]; | |
3872 | ||
3873 | fPH2d = new TProfile2D("PH2d",(const Char_t *) name | |
3874 | ,nn,0,nn,fTimeMax | |
3875 | ,-0.5/fSf,(Float_t) (fTimeMax-0.5)/fSf); | |
77566f2a | 3876 | fPH2d->SetXTitle("Det/pad groups"); |
3877 | fPH2d->SetYTitle("time [#mus]"); | |
3878 | fPH2d->SetZTitle("<PH> [a.u.]"); | |
3879 | fPH2d->SetStats(0); | |
77566f2a | 3880 | |
3881 | } | |
3882 | ||
8ec526a4 | 3883 | //_____________________________________________________________________________ |
3884 | void AliTRDCalibra::CreateCH2d(Int_t nn) | |
77566f2a | 3885 | { |
3886 | // | |
3887 | // Create the 2D histos | |
3888 | // | |
3889 | ||
8ec526a4 | 3890 | TString name("Nz"); |
3891 | name += fNz[0]; | |
3892 | name += "Nrphi"; | |
3893 | name += fNrphi[0]; | |
3894 | ||
3895 | fCH2d = new TH2I("CH2d",(const Char_t *) name | |
3896 | ,nn,0,nn,fNumberBinCharge,0,300); | |
77566f2a | 3897 | fCH2d->SetXTitle("Det/pad groups"); |
3898 | fCH2d->SetYTitle("charge deposit [a.u]"); | |
3899 | fCH2d->SetZTitle("counts"); | |
3900 | fCH2d->SetStats(0); | |
3901 | fCH2d->Sumw2(); | |
3902 | ||
3903 | } | |
8ec526a4 | 3904 | |
3905 | //____________Offine tracking in the AliTRDtracker_____________________________ | |
77566f2a | 3906 | void AliTRDCalibra::FillTheInfoOfTheTrackCH() |
3907 | { | |
3908 | // | |
3909 | // For the offline tracking or mcm tracklets | |
3910 | // This function will be called in the functions UpdateHistogram... | |
3911 | // to fill the info of a track for the relativ gain calibration | |
3912 | // | |
3913 | ||
8ec526a4 | 3914 | Int_t nb = 0; // Nombre de zones traversees |
3915 | Int_t fd = -1; // Premiere zone non nulle | |
77566f2a | 3916 | |
3917 | ||
8ec526a4 | 3918 | // See if the track goes through different zones |
3919 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
3920 | if (fAmpTotal[k] > 0.0) { | |
3921 | nb++; | |
3922 | if (nb == 1) { | |
3923 | fd = k; | |
3924 | } | |
77566f2a | 3925 | } |
3926 | } | |
3927 | ||
8ec526a4 | 3928 | // If automatic scale |
3929 | if ((fCountRelativeScale < 100) && (fRelativeScaleAuto)) { | |
3930 | // Take only the one zone track | |
3931 | if (nb == 1) { | |
3932 | fRelativeScale += fAmpTotal[fd] * 0.014 * 0.01; | |
3933 | fCountRelativeScale++; | |
77566f2a | 3934 | } |
3935 | } | |
8ec526a4 | 3936 | |
3937 | // We fill the CH2d after having scale with the first 100 | |
3938 | if ((fCountRelativeScale >= 100) && (fRelativeScaleAuto)) { | |
3939 | // Case of track with only one zone | |
3940 | if (nb == 1) { | |
3941 | if (fHisto2d) { | |
3942 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
3943 | } | |
3944 | if (fVector2d) { | |
3945 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
3946 | } | |
3947 | } // Case 1 zone | |
3948 | // Case of track with two zones | |
3949 | if (nb == 2) { | |
3950 | // Two zones voisines sinon rien! | |
3951 | if ((fAmpTotal[fd] > 0.0) && | |
3952 | (fAmpTotal[fd+1] > 0.0)) { | |
3953 | // One of the two very big | |
3954 | if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) { | |
3955 | if (fHisto2d) { | |
3956 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
3957 | } | |
3958 | if (fVector2d) { | |
3959 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
3960 | } | |
77566f2a | 3961 | } |
8ec526a4 | 3962 | if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) { |
3963 | if (fHisto2d) { | |
3964 | fCH2d->Fill(fXbins[0]+fd+1.5,fAmpTotal[fd+1]/fRelativeScale); | |
3965 | } | |
3966 | if (fVector2d) { | |
3967 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd+1]/fRelativeScale); | |
3968 | } | |
77566f2a | 3969 | } |
3970 | } | |
8ec526a4 | 3971 | } // Case 2 zones |
3972 | } | |
3973 | ||
3974 | // Fill with no automatic scale | |
3975 | if (!fRelativeScaleAuto) { | |
3976 | // Case of track with only one zone | |
3977 | if (nb == 1) { | |
3978 | fNumberUsedCh[0]++; | |
3979 | if (fHisto2d) { | |
3980 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
3981 | } | |
3982 | if (fVector2d) { | |
3983 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
3984 | } | |
3985 | } // Case 1 zone | |
3986 | // Case of track with two zones | |
3987 | if (nb == 2) { | |
3988 | // Two zones voisines sinon rien! | |
3989 | // Case 1 | |
3990 | if ((fAmpTotal[fd] > 0.0) && | |
3991 | (fAmpTotal[fd+1] > 0.0)) { | |
3992 | // One of the two very big | |
3993 | if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) { | |
3994 | if (fHisto2d) { | |
3995 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
3996 | } | |
3997 | if (fVector2d) { | |
3998 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
3999 | } | |
4000 | fNumberUsedCh[1]++; | |
77566f2a | 4001 | } |
8ec526a4 | 4002 | if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) { |
4003 | if (fHisto2d) { | |
4004 | fCH2d->Fill(fXbins[0]+fd+1.5,fAmpTotal[fd+1]/fRelativeScale); | |
4005 | } | |
4006 | if (fVector2d) { | |
4007 | UpdateVectorCH(fXbins[0]+fd+1,fAmpTotal[fd+1]/fRelativeScale); | |
4008 | } | |
4009 | fNumberUsedCh[1]++; | |
77566f2a | 4010 | } |
4011 | } | |
8ec526a4 | 4012 | // Case 2 |
4013 | if (fNfragZ[0] > 1) { | |
4014 | if (fAmpTotal[fd] > 0.0) { | |
4015 | if ((fd+fNfragZ[0]) < (fNfragZ[0]*fNfragRphi[0])) { | |
4016 | if (fAmpTotal[fd+fNfragZ[0]] > 0.0) { | |
4017 | // One of the two very big | |
4018 | if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+fNfragZ[0]]) { | |
4019 | if (fHisto2d) { | |
4020 | fCH2d->Fill(fXbins[0]+fd+0.5,fAmpTotal[fd]/fRelativeScale); | |
4021 | } | |
4022 | if (fVector2d) { | |
4023 | UpdateVectorCH(fXbins[0]+fd,fAmpTotal[fd]/fRelativeScale); | |
4024 | } | |
4025 | fNumberUsedCh[1]++; | |
77566f2a | 4026 | } |
8ec526a4 | 4027 | if (fAmpTotal[fd+fNfragZ[0]] > fProcent*fAmpTotal[fd]) { |
4028 | if (fHisto2d) { | |
4029 | fCH2d->Fill(fXbins[0]+fd+fNfragZ[0]+0.5,fAmpTotal[fd+fNfragZ[0]]/fRelativeScale); | |
4030 | } | |
4031 | fNumberUsedCh[1]++; | |
4032 | if (fVector2d) { | |
4033 | UpdateVectorCH(fXbins[0]+fd+fNfragZ[0],fAmpTotal[fd+fNfragZ[0]]/fRelativeScale); | |
4034 | } | |
77566f2a | 4035 | } |
4036 | } | |
4037 | } | |
4038 | } | |
4039 | } | |
8ec526a4 | 4040 | } // Case 2 zones |
4041 | ||
77566f2a | 4042 | } |
8ec526a4 | 4043 | |
77566f2a | 4044 | } |
8ec526a4 | 4045 | |
4046 | //____________Offine tracking in the AliTRDtracker_____________________________ | |
4047 | void AliTRDCalibra::ResetfVariables() | |
77566f2a | 4048 | { |
4049 | // | |
8ec526a4 | 4050 | // Reset values of fAmpTotal, fPHValue and fPHPlace for |
4051 | // the updateHistogram... functions | |
77566f2a | 4052 | // |
4053 | ||
8ec526a4 | 4054 | // Reset the good track |
77566f2a | 4055 | fGoodTrack = kTRUE; |
4056 | ||
8ec526a4 | 4057 | // Reset the fAmpTotal where we put value |
4058 | if (fCH2dOn) { | |
4059 | for (Int_t k = 0; k < fNfragZ[0]*fNfragRphi[0]; k++) { | |
4060 | fAmpTotal[k] = 0.0; | |
4061 | } | |
4062 | } | |
4063 | ||
4064 | // Reset the fPHValue | |
4065 | if (fPH2dOn) { | |
4066 | for (Int_t k = 0; k < fTimeMax; k++) { | |
4067 | fPHValue[k] = -1.0; | |
4068 | fPHPlace[k] = -1; | |
4069 | } | |
4070 | } | |
4071 | ||
4072 | } | |
4073 | ||
4074 | //____________Offine tracking in the AliTRDtracker_____________________________ | |
77566f2a | 4075 | void AliTRDCalibra::FillTheInfoOfTheTrackPH() |
4076 | { | |
4077 | // | |
4078 | // For the offline tracking or mcm tracklets | |
4079 | // This function will be called in the functions UpdateHistogram... | |
4080 | // to fill the info of a track for the drift velocity calibration | |
4081 | // | |
4082 | ||
8ec526a4 | 4083 | Int_t nb = 1; // Nombre de zones traversees 1, 2 ou plus de 3 |
4084 | Int_t fd1 = -1; // Premiere zone non nulle | |
4085 | Int_t fd2 = -1; // Deuxieme zone non nulle | |
4086 | Int_t k1 = -1; // Debut de la premiere zone | |
4087 | Int_t k2 = -1; // Debut de la seconde zone | |
4088 | ||
4089 | // See if the track goes through different zones | |
4090 | for (Int_t k = 0; k < fTimeMax; k++) { | |
4091 | if (fPHValue[k] > 0.0) { | |
4092 | if (fd1 == -1) { | |
4093 | fd1 = fPHPlace[k]; | |
4094 | k1 = k; | |
77566f2a | 4095 | } |
8ec526a4 | 4096 | if (fPHPlace[k] != fd1) { |
4097 | if (fd2 == -1) { | |
4098 | k2 = k; | |
4099 | fd2 = fPHPlace[k]; | |
4100 | nb = 2; | |
4101 | } | |
4102 | if (fPHPlace[k] != fd2) { | |
4103 | nb = 3; | |
77566f2a | 4104 | } |
77566f2a | 4105 | } |
4106 | } | |
4107 | } | |
4108 | ||
8ec526a4 | 4109 | // Fill |
4110 | // Case of track with only one zone | |
4111 | if (nb == 1) { | |
4112 | fNumberUsedPh[0]++; | |
4113 | for (Int_t i = 0; i < fTimeMax; i++) { | |
4114 | if (fPHValue[i] > 0.0) { | |
4115 | if (fHisto2d) { | |
4116 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4117 | } | |
4118 | if (fDebug == 13) { | |
4119 | AliInfo(Form("WRITE nb %d ,place final: %d, fPHPlace[i]: %d, i: %d, fPHValue[i]: %f" | |
4120 | ,nb,fXbins[1]+fPHPlace[i],fPHPlace[i],i,fPHValue[i])); | |
4121 | } | |
4122 | if (fVector2d) { | |
4123 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
77566f2a | 4124 | } |
77566f2a | 4125 | } |
4126 | } | |
8ec526a4 | 4127 | } // Case 1 zone |
4128 | // Case of track with two zones | |
4129 | if (nb == 2) { | |
4130 | // Two zones voisines sinon rien! | |
4131 | // Case 1 | |
4132 | if ((fd1 == fd2+1) || | |
4133 | (fd2 == fd1+1)) { | |
4134 | // One of the two fast all the think | |
4135 | if (k2 > (k1+fDifference)) { | |
4136 | fNumberUsedPh[1]++; | |
4137 | for (Int_t i = k1; i < k2; i++) { | |
4138 | if (fPHValue[i] > 0.0) { | |
4139 | if (fHisto2d) { | |
4140 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4141 | } | |
4142 | if (fVector2d) { | |
4143 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4144 | } | |
77566f2a | 4145 | } |
4146 | } | |
4147 | } | |
8ec526a4 | 4148 | if ((k2+fDifference) < fTimeMax) { |
4149 | fNumberUsedPh[1]++; | |
4150 | for (Int_t i = k2; i < fTimeMax; i++) { | |
4151 | if (fPHValue[i] > 0.0) { | |
4152 | if (fHisto2d) { | |
4153 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4154 | } | |
4155 | if (fVector2d) { | |
4156 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4157 | } | |
77566f2a | 4158 | } |
4159 | } | |
4160 | } | |
4161 | } | |
8ec526a4 | 4162 | // Two zones voisines sinon rien! |
4163 | if (fNfragZ[1] > 1) { | |
4164 | // Case 2 | |
4165 | if ((fd1+fNfragZ[1]) < (fNfragZ[1]*fNfragRphi[1])) { | |
4166 | if (fd2 == (fd1+fNfragZ[1])) { | |
4167 | // One of the two fast all the think | |
4168 | if (k2 > (k1+fDifference)) { | |
4169 | fNumberUsedPh[1]++; | |
4170 | for (Int_t i = k1; i < k2; i++) { | |
4171 | if (fPHValue[i] > 0.0) { | |
4172 | if (fHisto2d) { | |
4173 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4174 | } | |
4175 | if (fVector2d) { | |
4176 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4177 | } | |
77566f2a | 4178 | } |
4179 | } | |
4180 | } | |
8ec526a4 | 4181 | if ((k2+fDifference) < fTimeMax) { |
4182 | fNumberUsedPh[1]++; | |
4183 | for (Int_t i = k2; i < fTimeMax; i++) { | |
4184 | if (fPHValue[i] > 0.0) { | |
4185 | if (fHisto2d) { | |
4186 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4187 | } | |
4188 | if (fVector2d) { | |
4189 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4190 | } | |
77566f2a | 4191 | } |
4192 | } | |
4193 | } | |
4194 | } | |
4195 | } | |
8ec526a4 | 4196 | // Two zones voisines sinon rien! |
4197 | // Case 3 | |
4198 | if ((fd1 - fNfragZ[1]) >= 0) { | |
4199 | if (fd2 == (fd1 - fNfragZ[1])) { | |
4200 | // One of the two fast all the think | |
4201 | if (k2 > (k1 + fDifference)) { | |
4202 | fNumberUsedPh[1]++; | |
4203 | for (Int_t i = k1; i < k2; i++) { | |
4204 | if (fPHValue[i] > 0.0) { | |
4205 | if (fHisto2d) { | |
4206 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4207 | } | |
4208 | if (fVector2d) { | |
4209 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4210 | } | |
77566f2a | 4211 | } |
4212 | } | |
4213 | } | |
8ec526a4 | 4214 | if ((k2+fDifference) < fTimeMax) { |
4215 | fNumberUsedPh[1]++; | |
4216 | for (Int_t i = k2; i < fTimeMax; i++) { | |
4217 | if (fPHValue[i] > 0.0) { | |
4218 | if (fHisto2d) { | |
4219 | fPH2d->Fill((fXbins[1]+fPHPlace[i])+0.5,(Float_t) i/fSf,(Float_t) fPHValue[i]); | |
4220 | } | |
4221 | if (fVector2d) { | |
4222 | UpdateVectorPH(fXbins[1]+fPHPlace[i],i,fPHValue[i]); | |
4223 | } | |
77566f2a | 4224 | } |
4225 | } | |
4226 | } | |
4227 | } | |
4228 | } | |
4229 | } | |
77566f2a | 4230 | |
8ec526a4 | 4231 | } // case 2 zones |
4232 | ||
4233 | } | |
77566f2a | 4234 | |
8ec526a4 | 4235 | //____________Set the pad calibration variables for the detector_______________ |
4236 | Bool_t AliTRDCalibra::LocalisationDetectorXbins(Int_t detector) | |
77566f2a | 4237 | { |
4238 | // | |
8ec526a4 | 4239 | // For the detector calcul the first Xbins and set the number of row |
4240 | // and col pads per calibration groups, the number of calibration | |
4241 | // groups in the detector. | |
77566f2a | 4242 | // |
4243 | ||
8ec526a4 | 4244 | // first Xbins of the detector |
4245 | if (fCH2dOn) { | |
4246 | CalculXBins(detector,0); | |
4247 | } | |
4248 | if (fPH2dOn) { | |
4249 | CalculXBins(detector,1); | |
4250 | } | |
4251 | if (fPRF2dOn) { | |
4252 | CalculXBins(detector,2); | |
4253 | } | |
4254 | ||
4255 | // fragmentation of idect | |
4256 | for (Int_t i = 0; i < 3; i++) { | |
77566f2a | 4257 | ModePadCalibration((Int_t) GetChamber(detector),i); |
8ec526a4 | 4258 | ModePadFragmentation((Int_t) GetPlane(detector) |
4259 | , (Int_t) GetChamber(detector) | |
4260 | , (Int_t) GetSector(detector),i); | |
77566f2a | 4261 | } |
4262 | ||
4263 | return kTRUE; | |
8ec526a4 | 4264 | |
77566f2a | 4265 | } |
4266 | ||
8ec526a4 | 4267 | //____________Plot the 2D histos filled Online_________________________________ |
77566f2a | 4268 | |
8ec526a4 | 4269 | //_____________________________________________________________________________ |
77566f2a | 4270 | void AliTRDCalibra::PlotPH2d() |
4271 | { | |
4272 | // | |
4273 | // Plot the 2D histo | |
4274 | // | |
4275 | ||
4276 | TCanvas *cph2d = new TCanvas("cph2d","",50,50,600,800); | |
4277 | cph2d->cd(); | |
4278 | fPH2d->Draw("LEGO"); | |
4279 | ||
4280 | } | |
4281 | ||
8ec526a4 | 4282 | //_____________________________________________________________________________ |
77566f2a | 4283 | void AliTRDCalibra::PlotCH2d() |
4284 | { | |
4285 | // | |
4286 | // Plot the 2D histos | |
4287 | // | |
4288 | ||
4289 | TCanvas *cch2d = new TCanvas("cch2d","",50,50,600,800); | |
4290 | cch2d->cd(); | |
4291 | fCH2d->Draw("LEGO"); | |
4292 | ||
4293 | } | |
4294 | ||
8ec526a4 | 4295 | //_____________________________________________________________________________ |
77566f2a | 4296 | void AliTRDCalibra::PlotPRF2d() |
4297 | { | |
4298 | // | |
4299 | // Plot the 2D histos | |
4300 | // | |
4301 | ||
4302 | TCanvas *cPRF2d = new TCanvas("cPRF2d","",50,50,600,800); | |
4303 | cPRF2d->cd(); | |
4304 | fPRF2d->Draw("LEGO"); | |
4305 | ||
4306 | } | |
4307 | ||
8ec526a4 | 4308 | //____________Fit______________________________________________________________ |
77566f2a | 4309 | |
8ec526a4 | 4310 | //____________Create histos if fDebug == 1 or fDebug >= 3______________________ |
77566f2a | 4311 | |
8ec526a4 | 4312 | //_____________________________________________________________________________ |
9f4780aa | 4313 | void AliTRDCalibra::InitArrayFitPH() |
77566f2a | 4314 | { |
4315 | // | |
9f4780aa | 4316 | // Initialise fCoefVdrift[3] and fCoefVdriftE[2] to the right dimension |
4317 | // | |
4318 | ||
4319 | Int_t nbins = fDect2[1]-fDect1[1]; | |
4320 | ||
4321 | //Init the pointer to nbins | |
4322 | fCoefVdrift[0] = new Double_t[nbins]; | |
4323 | fCoefVdrift[1] = new Double_t[nbins]; | |
4324 | fCoefVdrift[2] = new Double_t[nbins]; | |
77566f2a | 4325 | |
9f4780aa | 4326 | fCoefVdriftE[0] = new Double_t[nbins]; |
4327 | fCoefVdriftE[1] = new Double_t[nbins]; | |
4328 | ||
4329 | for(Int_t k = 0; k < nbins; k++){ | |
4330 | fCoefVdriftE[0][k] = 0.0; | |
4331 | fCoefVdriftE[1][k] = 0.0; | |
4332 | } | |
4333 | ||
77566f2a | 4334 | } |
8ec526a4 | 4335 | |
4336 | //_____________________________________________________________________________ | |
9f4780aa | 4337 | void AliTRDCalibra::InitArrayFitT0() |
77566f2a | 4338 | { |
4339 | // | |
9f4780aa | 4340 | // Initialise fCoefT0[3] and fCoefT0E[2] to the right dimension |
4341 | // | |
4342 | ||
4343 | Int_t nbins = fDect2[1]-fDect1[1]; | |
4344 | ||
4345 | //Init the pointer to nbins | |
4346 | fCoefT0[0] = new Double_t[nbins]; | |
4347 | fCoefT0[1] = new Double_t[nbins]; | |
4348 | fCoefT0[2] = new Double_t[nbins]; | |
4349 | ||
4350 | fCoefT0E[0] = new Double_t[nbins]; | |
4351 | fCoefT0E[1] = new Double_t[nbins]; | |
8ec526a4 | 4352 | |
9f4780aa | 4353 | for(Int_t k = 0; k < nbins; k++){ |
4354 | fCoefT0E[0][k] = 0.0; | |
4355 | fCoefT0E[1][k] = 0.0; | |
4356 | } | |
4357 | ||
77566f2a | 4358 | } |
4359 | ||
8ec526a4 | 4360 | //_____________________________________________________________________________ |
9f4780aa | 4361 | void AliTRDCalibra::InitArrayFitCH() |
77566f2a | 4362 | { |
4363 | // | |
9f4780aa | 4364 | // Initialise fCoefCharge[4] and fCoefChargeE[3] to the right dimension |
77566f2a | 4365 | // |
4366 | ||
9f4780aa | 4367 | Int_t nbins = fDect2[0]-fDect1[0]; |
77566f2a | 4368 | |
9f4780aa | 4369 | //Init the pointer to nbins |
4370 | fCoefCharge[0] = new Double_t[nbins]; | |
4371 | fCoefCharge[1] = new Double_t[nbins]; | |
4372 | fCoefCharge[2] = new Double_t[nbins]; | |
4373 | fCoefCharge[3] = new Double_t[nbins]; | |
4374 | ||
4375 | fCoefChargeE[0] = new Double_t[nbins]; | |
4376 | fCoefChargeE[1] = new Double_t[nbins]; | |
4377 | fCoefChargeE[2] = new Double_t[nbins]; | |
4378 | ||
4379 | for(Int_t k = 0; k < nbins; k++){ | |
4380 | fCoefChargeE[0][k] = 0.0; | |
4381 | fCoefChargeE[1][k] = 0.0; | |
4382 | fCoefChargeE[2][k] = 0.0; | |
4383 | } | |
77566f2a | 4384 | |
9f4780aa | 4385 | |
77566f2a | 4386 | } |
8ec526a4 | 4387 | |
4388 | //_____________________________________________________________________________ | |
9f4780aa | 4389 | void AliTRDCalibra::InitArrayFitPRF() |
77566f2a | 4390 | { |
4391 | // | |
9f4780aa | 4392 | // Initialise fCoefPRF[2] and fCoefPRFE to the right dimension |
77566f2a | 4393 | // |
4394 | ||
9f4780aa | 4395 | Int_t nbins = fDect2[2]-fDect1[2]; |
77566f2a | 4396 | |
9f4780aa | 4397 | //Init the pointer to nbins |
4398 | fCoefPRF[0] = new Double_t[nbins]; | |
4399 | fCoefPRF[1] = new Double_t[nbins]; | |
4400 | ||
4401 | fCoefPRFE = new Double_t[nbins]; | |
4402 | ||
4403 | for(Int_t k = 0; k < nbins; k++){ | |
4404 | fCoefPRFE[k] = 0.0; | |
4405 | } | |
4406 | ||
77566f2a | 4407 | } |
8ec526a4 | 4408 | |
4409 | //_____________________________________________________________________________ | |
77566f2a | 4410 | void AliTRDCalibra::CreateFitHistoPRFDB(Int_t rowMax, Int_t colMax) |
4411 | { | |
4412 | // | |
4413 | // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions) | |
4414 | // | |
8ec526a4 | 4415 | |
4416 | fCoefPRFDB = new TH2F("coefPRF","",rowMax,0,rowMax,colMax,0,colMax); | |
77566f2a | 4417 | |
4418 | fCoefPRFDB->SetStats(0); | |
4419 | fCoefPRFDB->SetXTitle("row Number"); | |
4420 | fCoefPRFDB->SetYTitle("col Number"); | |
4421 | fCoefPRFDB->SetZTitle("PRF width [pad width units]"); | |
77566f2a | 4422 | |
4423 | fCoefPRFDB->SetFillColor(6); | |
4424 | fCoefPRFDB->SetLineColor(6); | |
4425 | ||
77566f2a | 4426 | } |
4427 | ||
8ec526a4 | 4428 | //_____________________________________________________________________________ |
4429 | void AliTRDCalibra::CreateFitHistoCHDB(Int_t rowMax, Int_t colMax) | |
4430 | { | |
77566f2a | 4431 | // |
4432 | // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions) | |
4433 | // | |
4434 | ||
8ec526a4 | 4435 | fCoefChargeDB[0] = new TH2F("coefchargedb0","",rowMax,0,rowMax,colMax,0,colMax); |
4436 | fCoefChargeDB[1] = new TH2F("coefchargedb1","",rowMax,0,rowMax,colMax,0,colMax); | |
4437 | fCoefChargeDB[2] = new TH2F("coefchargedb2","",rowMax,0,rowMax,colMax,0,colMax); | |
77566f2a | 4438 | |
4439 | fCoefChargeDB[0]->SetStats(0); | |
4440 | fCoefChargeDB[1]->SetStats(0); | |
4441 | fCoefChargeDB[2]->SetStats(0); | |
4442 | fCoefChargeDB[0]->SetXTitle("row Number"); | |
4443 | fCoefChargeDB[0]->SetYTitle("col Number"); | |
4444 | fCoefChargeDB[1]->SetXTitle("row Number"); | |
4445 | fCoefChargeDB[1]->SetYTitle("col Number"); | |
4446 | fCoefChargeDB[2]->SetXTitle("row Number"); | |
4447 | fCoefChargeDB[2]->SetYTitle("col Number"); | |
4448 | fCoefChargeDB[0]->SetZTitle("f_{g} Fit method"); | |
4449 | fCoefChargeDB[1]->SetZTitle("f_{g} Mean method"); | |
4450 | fCoefChargeDB[2]->SetZTitle("f_{g} Fitbis method"); | |
77566f2a | 4451 | |
4452 | fCoefChargeDB[0]->SetFillColor(6); | |
4453 | fCoefChargeDB[0]->SetLineColor(6); | |
4454 | fCoefChargeDB[0]->SetLineColor(6); | |
4455 | fCoefChargeDB[1]->SetFillColor(2); | |
4456 | fCoefChargeDB[1]->SetLineColor(2); | |
4457 | fCoefChargeDB[1]->SetLineColor(2); | |
4458 | fCoefChargeDB[2]->SetFillColor(8); | |
4459 | fCoefChargeDB[2]->SetLineColor(8); | |
4460 | fCoefChargeDB[2]->SetLineColor(8); | |
4461 | ||
4462 | } | |
4463 | ||
8ec526a4 | 4464 | //_____________________________________________________________________________ |
77566f2a | 4465 | void AliTRDCalibra::CreateFitHistoPHDB(Int_t rowMax, Int_t colMax) |
4466 | { | |
4467 | // | |
4468 | // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions) | |
4469 | // | |
4470 | ||
8ec526a4 | 4471 | fCoefVdriftDB[0] = new TH2F("coefvdriftdb0","",rowMax,0,rowMax,colMax,0,colMax); |
4472 | fCoefVdriftDB[1] = new TH2F("coefvdriftdb1","",rowMax,0,rowMax,colMax,0,colMax); | |
77566f2a | 4473 | |
4474 | fCoefVdriftDB[0]->SetStats(0); | |
4475 | fCoefVdriftDB[1]->SetStats(0); | |
4476 | fCoefVdriftDB[0]->SetXTitle("row Number"); | |
4477 | fCoefVdriftDB[0]->SetYTitle("col Number"); | |
4478 | fCoefVdriftDB[1]->SetXTitle("row Number"); | |
4479 | fCoefVdriftDB[1]->SetYTitle("col Number"); | |
4480 | fCoefVdriftDB[0]->SetZTitle("v_{drift} Fit method"); | |
4481 | fCoefVdriftDB[1]->SetZTitle("v_{drift} slope method"); | |
4482 | ||
4483 | fCoefVdriftDB[0]->SetFillColor(6); | |
4484 | fCoefVdriftDB[0]->SetLineColor(6); | |
4485 | fCoefVdriftDB[0]->SetLineColor(6); | |
4486 | fCoefVdriftDB[1]->SetFillColor(2); | |
4487 | fCoefVdriftDB[1]->SetLineColor(2); | |
4488 | fCoefVdriftDB[1]->SetLineColor(2); | |
8ec526a4 | 4489 | |
77566f2a | 4490 | } |
8ec526a4 | 4491 | |
4492 | //_____________________________________________________________________________ | |
77566f2a | 4493 | void AliTRDCalibra::CreateFitHistoT0DB(Int_t rowMax, Int_t colMax) |
4494 | { | |
4495 | // | |
4496 | // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions) | |
4497 | // | |
4498 | ||
8ec526a4 | 4499 | fCoefT0DB[0] = new TH2F("coefT0db0","",rowMax,0,rowMax,colMax,0,colMax); |
4500 | fCoefT0DB[1] = new TH2F("coefT0db1","",rowMax,0,rowMax,colMax,0,colMax); | |
77566f2a | 4501 | |
4502 | fCoefT0DB[0]->SetStats(0); | |
4503 | fCoefT0DB[1]->SetStats(0); | |
4504 | fCoefT0DB[0]->SetXTitle("row Number"); | |
4505 | fCoefT0DB[0]->SetYTitle("col Number"); | |
4506 | fCoefT0DB[1]->SetXTitle("row Number"); | |
4507 | fCoefT0DB[1]->SetYTitle("col Number"); | |
4508 | fCoefT0DB[0]->SetZTitle("t0 Fit method"); | |
4509 | fCoefT0DB[1]->SetZTitle("t0 slope method"); | |
4510 | ||
4511 | fCoefT0DB[0]->SetFillColor(6); | |
4512 | fCoefT0DB[0]->SetLineColor(6); | |
4513 | fCoefT0DB[0]->SetLineColor(6); | |
4514 | fCoefT0DB[1]->SetFillColor(2); | |
4515 | fCoefT0DB[1]->SetLineColor(2); | |
4516 | fCoefT0DB[1]->SetLineColor(2); | |
4517 | ||
4518 | } | |
8ec526a4 | 4519 | |
77566f2a | 4520 | //_____________________________________________________________________________ |
4521 | Bool_t AliTRDCalibra::FillVectorFitCH(Int_t countdet) | |
4522 | { | |
4523 | // | |
4524 | // For the Fit functions fill the vector FitCH special for the gain calibration | |
4525 | // | |
8ec526a4 | 4526 | |
4527 | AliTRDFitCHInfo *fitCHInfo = new AliTRDFitCHInfo(); | |
4528 | ||
4529 | Int_t ntotal = 1; | |
4530 | if (GetChamber(countdet) == 2) { | |
4531 | ntotal = 1728; | |
4532 | } | |
4533 | else { | |
4534 | ntotal = 2304; | |
4535 | } | |
4536 | ||
4537 | Float_t *coef = new Float_t[ntotal]; | |
4538 | for (Int_t i = 0; i < ntotal; i++) { | |
4539 | coef[i] = fCoefCH[i]; | |
77566f2a | 4540 | } |
8ec526a4 | 4541 | |
4542 | Int_t detector = countdet; | |
4543 | // Set | |
4544 | fitCHInfo->SetCoef(coef); | |
4545 | fitCHInfo->SetDetector(detector); | |
4546 | fVectorFitCH->Add((TObject *) fitCHInfo); | |
77566f2a | 4547 | |
4548 | return kTRUE; | |
8ec526a4 | 4549 | |
77566f2a | 4550 | } |
77566f2a | 4551 | |
8ec526a4 | 4552 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
9f4780aa | 4553 | Bool_t AliTRDCalibra::InitFit(Int_t nbins, Int_t i) |
77566f2a | 4554 | { |
4555 | // | |
8ec526a4 | 4556 | // Init the calibration mode (Nz, Nrphi), the histograms for |
4557 | // debugging the fit methods if fDebug > 0, | |
77566f2a | 4558 | // |
8ec526a4 | 4559 | |
77566f2a | 4560 | gStyle->SetPalette(1); |
4561 | gStyle->SetOptStat(1111); | |
4562 | gStyle->SetPadBorderMode(0); | |
4563 | gStyle->SetCanvasColor(10); | |
4564 | gStyle->SetPadLeftMargin(0.13); | |
4565 | gStyle->SetPadRightMargin(0.01); | |
8ec526a4 | 4566 | |
77566f2a | 4567 | // Get the parameter object |
4568 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
4569 | if (!parCom) { | |
8ec526a4 | 4570 | AliInfo("Could not get CommonParam"); |
77566f2a | 4571 | return kFALSE; |
4572 | } | |
8ec526a4 | 4573 | |
4574 | // Mode groups of pads: the total number of bins! | |
77566f2a | 4575 | Int_t numberofbinsexpected = 0; |
4576 | ModePadCalibration(2,i); | |
4577 | ModePadFragmentation(0,2,0,i); | |
8ec526a4 | 4578 | fDetChamb2[i] = fNfragZ[i] * fNfragRphi[i]; |
4579 | if (fDebug == 1) { | |
4580 | AliInfo(Form("For the chamber 2: %d",fDetChamb2[i])); | |
4581 | } | |
4582 | numberofbinsexpected += 6 * 18 * fDetChamb2[i]; | |
77566f2a | 4583 | ModePadCalibration(0,i); |
4584 | ModePadFragmentation(0,0,0,i); | |
8ec526a4 | 4585 | fDetChamb0[i] = fNfragZ[i] * fNfragRphi[i]; |
4586 | if (fDebug == 1) { | |
4587 | AliInfo(Form("For the other chamber 0: %d",fDetChamb0[i])); | |
4588 | } | |
4589 | numberofbinsexpected += 6 * 4 * 18 * fDetChamb0[i]; | |
77566f2a | 4590 | |
8ec526a4 | 4591 | // Quick verification that we have the good pad calibration mode if 2D histos! |
4592 | if (nbins != 0) { | |
4593 | if (numberofbinsexpected != nbins) { | |
77566f2a | 4594 | AliInfo("It doesn't correspond to the mode of pad group calibration!"); |
4595 | return kFALSE; | |
4596 | } | |
4597 | } | |
4598 | ||
8ec526a4 | 4599 | // Security for fDebug 3 and 4 |
4600 | if ((fDebug >= 3) && | |
4601 | ((fDet[0] > 5) || | |
4602 | (fDet[1] > 4) || | |
4603 | (fDet[2] > 17))) { | |
77566f2a | 4604 | AliInfo("This detector doesn't exit!"); |
4605 | return kFALSE; | |
77566f2a | 4606 | } |
8ec526a4 | 4607 | |
4608 | // Determine fDet1 and fDet2 | |
4609 | fDect1[i] = -1; | |
4610 | fDect2[i] = -1; | |
4611 | if (fDebug == 2) { | |
4612 | fDect1[i] = fFitVoir; | |
4613 | fDect2[i] = fDect1[i] +1; | |
77566f2a | 4614 | } |
8ec526a4 | 4615 | if (fDebug <= 1) { |
4616 | fDect1[i] = 0; | |
4617 | fDect2[i] = numberofbinsexpected; | |
77566f2a | 4618 | } |
8ec526a4 | 4619 | if (fDebug >= 3) { |
77566f2a | 4620 | CalculXBins(AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]),i); |
8ec526a4 | 4621 | fDect1[i] = fXbins[i]; |
77566f2a | 4622 | CalculXBins((AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2])+1),i); |
8ec526a4 | 4623 | fDect2[i] = fXbins[i]; |
4624 | } | |
4625 | ||
4626 | // Create the histos for debugging | |
4627 | // CH | |
4628 | if (i == 0) { | |
4629 | ||
4630 | gDirectory = gROOT; | |
4631 | // Init the VectorFitCH | |
4632 | fVectorFitCH = new TObjArray(); | |
4633 | fCoefCH = new Float_t[2304]; | |
4634 | for (Int_t k = 0; k < 2304; k++) { | |
4635 | fCoefCH[k] = 0.0; | |
4636 | } | |
4637 | fScaleFitFactor = 0.0; | |
4638 | ||
4639 | // Number of Xbins(detectors or groups of pads) if Vector2d | |
4640 | // Quick verification that we are not out of range! | |
4641 | if (fVectorCH && fPlaCH) { | |
4642 | if ((nbins == 0) && | |
4643 | (fVectorCH->GetEntriesFast() > 0) && | |
4644 | ((Int_t) fPlaCH->GetEntriesFast() > 0)) { | |
4645 | if ((Int_t) fVectorCH->GetEntriesFast() > numberofbinsexpected) { | |
4646 | AliInfo("ch doesn't correspond to the mode of pad group calibration!"); | |
4647 | return kFALSE; | |
4648 | } | |
4649 | if ((Int_t) fVectorCH->GetEntriesFast() != (Int_t) fPlaCH->GetEntriesFast()) { | |
4650 | AliInfo("VectorCH doesn't correspond to PlaCH!"); | |
4651 | return kFALSE; | |
4652 | } | |
77566f2a | 4653 | } |
4654 | } | |
8ec526a4 | 4655 | |
4656 | // | |
4657 | // Debugging: Create the histos | |
4658 | // | |
4659 | ||
4660 | // fDebug == 0 nothing | |
77566f2a | 4661 | |
8ec526a4 | 4662 | // fDebug == 1 |
4663 | if (fDebug == 1) { | |
9f4780aa | 4664 | InitArrayFitCH(); |
77566f2a | 4665 | } |
8ec526a4 | 4666 | |
4667 | // fDebug == 2 and fFitVoir no histo | |
4668 | if (fDebug == 2) { | |
4669 | if (fFitVoir < numberofbinsexpected) { | |
77566f2a | 4670 | AliInfo(Form("We will see the fit of the object %d",fFitVoir)); |
4671 | } | |
4672 | else { | |
4673 | AliInfo("fFitVoir is out of range of the histo!"); | |
4674 | return kFALSE; | |
4675 | } | |
4676 | } | |
8ec526a4 | 4677 | |
4678 | // fDebug == 3 or 4 and fDet | |
4679 | if (fDebug >= 3) { | |
4680 | if ((fNz[0] == 0) && (fNrphi[0] == 0)) { | |
77566f2a | 4681 | AliInfo("Do you really want to see one detector without pad groups?"); |
4682 | return kFALSE; | |
4683 | } | |
8ec526a4 | 4684 | else { |
4685 | AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d" | |
4686 | ,fDet[0],fDet[1],fDet[2])); | |
4687 | // A little geometry: | |
77566f2a | 4688 | Int_t rowMax = parCom->GetRowMax(fDet[0],fDet[1],fDet[2]); |
4689 | Int_t colMax = parCom->GetColMax(fDet[0]); | |
8ec526a4 | 4690 | // Create the histos to visualise |
4691 | CreateFitHistoCHDB(rowMax,colMax); | |
4692 | if (fDebug == 4) { | |
9f4780aa | 4693 | InitArrayFitCH(); |
8ec526a4 | 4694 | } |
77566f2a | 4695 | } |
4696 | } | |
8ec526a4 | 4697 | |
77566f2a | 4698 | } |
4699 | ||
8ec526a4 | 4700 | // PH and T0 |
4701 | if (i == 1) { | |
77566f2a | 4702 | |
8ec526a4 | 4703 | // Number of Xbins (detectors or groups of pads) if vector2d |
4704 | // Quick verification that we are not out of range! | |
4705 | if (fVectorPH && fPlaPH) { | |
4706 | if ((nbins == 0) && | |
4707 | (fVectorPH->GetEntriesFast() > 0) && | |
4708 | ((Int_t) fPlaPH->GetEntriesFast() > 0)) { | |
4709 | if ((Int_t) fVectorPH->GetEntriesFast() > numberofbinsexpected) { | |
4710 | AliInfo("ph doesn't correspond to the mode of pad group calibration!"); | |
4711 | return kFALSE; | |
4712 | } | |
4713 | if ((Int_t) fVectorPH->GetEntriesFast() != (Int_t) fPlaPH->GetEntriesFast()) { | |
4714 | AliInfo("VectorPH doesn't correspond to PlaPH!"); | |
4715 | return kFALSE; | |
4716 | } | |
77566f2a | 4717 | } |
4718 | } | |
4719 | ||
8ec526a4 | 4720 | // Init tree |
4721 | InitTreePH(); | |
4722 | InitTreeT0(); | |
4723 | ||
4724 | // | |
4725 | // Debugging: Create the histos | |
4726 | // | |
4727 | ||
4728 | // fDebug == 0 nothing | |
4729 | ||
4730 | // fDebug == 1 | |
4731 | if (fDebug == 1) { | |
9f4780aa | 4732 | // Create the histos replique de ph |
4733 | InitArrayFitPH(); | |
4734 | InitArrayFitT0(); | |
77566f2a | 4735 | } |
8ec526a4 | 4736 | |
4737 | // fDebug == 2 and fFitVoir no histo | |
4738 | if (fDebug == 2) { | |
4739 | if (fFitVoir < numberofbinsexpected) { | |
77566f2a | 4740 | AliInfo(Form("We will see the fit of the object %d",fFitVoir)); |
4741 | } | |
4742 | else { | |
4743 | AliInfo("fFitVoir is out of range of the histo!"); | |
4744 | return kFALSE; | |
4745 | } | |
4746 | } | |
8ec526a4 | 4747 | |
4748 | // fDebug == 3 or 4 and fDet | |
4749 | if (fDebug >= 3) { | |
4750 | if ((fNz[1] == 0) && | |
4751 | (fNrphi[1] == 0)) { | |
77566f2a | 4752 | AliInfo("Do you really want to see one detector without pad groups?"); |
4753 | return kFALSE; | |
4754 | } | |
4755 | else { | |
8ec526a4 | 4756 | AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d" |
4757 | ,fDet[0],fDet[1],fDet[2])); | |
4758 | // A little geometry: | |
77566f2a | 4759 | Int_t rowMax = parCom->GetRowMax(fDet[0],fDet[1],fDet[2]); |
4760 | Int_t colMax = parCom->GetColMax(fDet[0]); | |
8ec526a4 | 4761 | // Create the histos to visualise |
4762 | CreateFitHistoPHDB(rowMax,colMax); | |
4763 | CreateFitHistoT0DB(rowMax,colMax); | |
4764 | if (fDebug == 4) { | |
9f4780aa | 4765 | InitArrayFitPH(); |
4766 | InitArrayFitT0(); | |
77566f2a | 4767 | } |
77566f2a | 4768 | } |
4769 | } | |
8ec526a4 | 4770 | |
77566f2a | 4771 | } |
8ec526a4 | 4772 | |
4773 | // PRF | |
4774 | if (i == 2) { | |
77566f2a | 4775 | |
8ec526a4 | 4776 | // Number of Xbins(detectors or groups of pads) if vector2d |
4777 | if (fVectorPRF && fPlaPRF){ | |
4778 | if ((nbins == 0) && | |
4779 | (fVectorPRF->GetEntriesFast() > 0) && | |
4780 | (fPlaPRF->GetEntriesFast() > 0)) { | |
4781 | // Quick verification that we are not out of range! | |
4782 | if ((Int_t) fVectorPRF->GetEntriesFast() > numberofbinsexpected) { | |
4783 | AliInfo("ch doesn't correspond to the mode of pad group calibration!"); | |
4784 | return kFALSE; | |
4785 | } | |
4786 | if ((Int_t) fVectorPRF->GetEntriesFast() != (Int_t) fPlaPRF->GetEntriesFast()) { | |
4787 | AliInfo("VectorPRF doesn't correspond to PlaCH!"); | |
4788 | return kFALSE; | |
4789 | } | |
77566f2a | 4790 | } |
4791 | } | |
4792 | ||
8ec526a4 | 4793 | // Init tree |
4794 | InitTreePRF(); | |
4795 | ||
4796 | // | |
4797 | // Debugging: Create the histos | |
4798 | // | |
4799 | ||
4800 | // fDebug == 0 nothing | |
4801 | ||
4802 | // fDebug == 1 | |
4803 | if (fDebug == 1) { | |
9f4780aa | 4804 | // Create the histos replique de ch |
4805 | InitArrayFitPRF(); | |
77566f2a | 4806 | } |
4807 | ||
8ec526a4 | 4808 | // fDebug == 2 and fFitVoir no histo |
4809 | if (fDebug == 2) { | |
4810 | if (fFitVoir < numberofbinsexpected) { | |
77566f2a | 4811 | AliInfo(Form("We will see the fit of the object %d",fFitVoir)); |
4812 | } | |
4813 | else { | |
4814 | AliInfo("fFitVoir is out of range of the histo!"); | |
4815 | return kFALSE; | |
4816 | } | |
4817 | } | |
8ec526a4 | 4818 | |
4819 | // fDebug == 3 or 4 and fDet | |
4820 | if (fDebug >= 3) { | |
4821 | if ((fNz[2] == 0) && | |
4822 | (fNrphi[2] == 0)) { | |
77566f2a | 4823 | AliInfo("Do you really want to see one detector without pad groups?"); |
4824 | return kFALSE; | |
4825 | } | |
8ec526a4 | 4826 | else { |
4827 | AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d" | |
4828 | ,fDet[0],fDet[1],fDet[2])); | |
4829 | // A little geometry: | |
77566f2a | 4830 | Int_t rowMax = parCom->GetRowMax(fDet[0],fDet[1],fDet[2]); |
4831 | Int_t colMax = parCom->GetColMax(fDet[0]); | |
8ec526a4 | 4832 | // Create the histos to visualise |
4833 | CreateFitHistoPRFDB(rowMax,colMax); | |
4834 | if (fDebug == 4) { | |
9f4780aa | 4835 | InitArrayFitPRF(); |
8ec526a4 | 4836 | } |
77566f2a | 4837 | } |
4838 | } | |
8ec526a4 | 4839 | |
77566f2a | 4840 | } |
4841 | ||
4842 | return kTRUE; | |
4843 | ||
4844 | } | |
4845 | ||
8ec526a4 | 4846 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
4847 | void AliTRDCalibra::InitfCountDetAndfCount(Int_t i) | |
77566f2a | 4848 | { |
4849 | // | |
8ec526a4 | 4850 | // Init the current detector where we are fCountDet and the |
4851 | // next fCount for the functions Fit... | |
77566f2a | 4852 | // |
4853 | ||
8ec526a4 | 4854 | // Loop on the Xbins of ch!! |
4855 | fCountDet[i] = -1; // Current detector | |
4856 | fCount[i] = 0; // To find the next detector | |
77566f2a | 4857 | |
8ec526a4 | 4858 | // If fDebug >= 3 |
4859 | if (fDebug >= 3) { | |
4860 | ||
4861 | // Set countdet to the detector | |
4862 | fCountDet[i] = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]); | |
4863 | ||
4864 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
4865 | ModePadCalibration(fDet[1],i); | |
77566f2a | 4866 | ModePadFragmentation(fDet[0],fDet[1],fDet[2],i); |
4867 | ||
8ec526a4 | 4868 | // Set counter to write at the end of the detector |
4869 | fCount[i] = fDect1[i] + fNfragZ[i]*fNfragRphi[i]; | |
4870 | ||
77566f2a | 4871 | } |
77566f2a | 4872 | |
8ec526a4 | 4873 | } |
77566f2a | 4874 | |
8ec526a4 | 4875 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
4876 | void AliTRDCalibra::UpdatefCountDetAndfCount(Int_t idect, Int_t i) | |
77566f2a | 4877 | { |
4878 | // | |
8ec526a4 | 4879 | // See if we are in a new detector and update the |
4880 | // variables fNfragZ and fNfragRphi if yes | |
77566f2a | 4881 | // |
4882 | ||
8ec526a4 | 4883 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
4884 | // If fDebug == 1 or 0 | |
4885 | if ((fDebug == 0) || | |
4886 | (fDebug == 1)) { | |
4887 | ||
4888 | if (fCount[i] == idect) { | |
77566f2a | 4889 | |
8ec526a4 | 4890 | // On en est au detector |
4891 | fCountDet[i] += 1; | |
77566f2a | 4892 | |
8ec526a4 | 4893 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi |
4894 | ModePadCalibration((Int_t) GetChamber(fCountDet[i]),i); | |
4895 | ModePadFragmentation((Int_t) GetPlane(fCountDet[i]) | |
4896 | ,(Int_t) GetChamber(fCountDet[i]) | |
4897 | ,(Int_t) GetSector(fCountDet[i]),i); | |
4898 | ||
4899 | // Set for the next detector | |
4900 | fCount[i] += fNfragZ[i]*fNfragRphi[i]; | |
4901 | ||
77566f2a | 4902 | } |
8ec526a4 | 4903 | |
77566f2a | 4904 | } |
8ec526a4 | 4905 | |
77566f2a | 4906 | } |
77566f2a | 4907 | |
8ec526a4 | 4908 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
4909 | void AliTRDCalibra::ReconstructFitRowMinRowMax(Int_t idect, Int_t i) | |
77566f2a | 4910 | { |
4911 | // | |
8ec526a4 | 4912 | // Reconstruct the min pad row, max pad row, min pad col and |
4913 | // max pad col of the calibration group for the Fit functions | |
77566f2a | 4914 | // |
8ec526a4 | 4915 | |
4916 | if (fDebug < 2) { | |
4917 | ReconstructionRowPadGroup((Int_t) (idect-(fCount[i]-(fNfragZ[i]*fNfragRphi[i]))),i); | |
77566f2a | 4918 | } |
8ec526a4 | 4919 | if (fDebug >= 3) { |
4920 | ReconstructionRowPadGroup((Int_t) (idect-fDect1[i]),i); | |
77566f2a | 4921 | } |
77566f2a | 4922 | |
8ec526a4 | 4923 | } |
77566f2a | 4924 | |
8ec526a4 | 4925 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
77566f2a | 4926 | Bool_t AliTRDCalibra::NotEnoughStatistic(Int_t idect, Int_t i) |
4927 | { | |
4928 | // | |
8ec526a4 | 4929 | // For the case where there are not enough entries in the histograms |
4930 | // of the calibration group, the value present in the choosen database | |
4931 | // will be put. A negativ sign enables to know that a fit was not possible. | |
77566f2a | 4932 | // |
4933 | ||
77566f2a | 4934 | // Get the parameter object |
4935 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
4936 | if (!parCom) { | |
4937 | AliInfo("Could not get CommonParam Manager"); | |
4938 | return kFALSE; | |
4939 | } | |
4940 | ||
8ec526a4 | 4941 | // Get cal |
77566f2a | 4942 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
4943 | if (!cal) { | |
4944 | AliInfo("Could not get calibDB"); | |
4945 | return kFALSE; | |
4946 | } | |
4947 | ||
8ec526a4 | 4948 | if (fDebug != 2) { |
4949 | AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted" | |
4950 | ,idect-(fCount[i]-(fNfragZ[i]*fNfragRphi[i])),fCountDet[i])); | |
77566f2a | 4951 | } |
8ec526a4 | 4952 | if (fDebug == 2) { |
77566f2a | 4953 | AliInfo("The element has not enough statistic to be fitted"); |
4954 | } | |
4955 | ||
8ec526a4 | 4956 | if ((i == 0) && (fDebug != 2)) { |
77566f2a | 4957 | |
8ec526a4 | 4958 | // Calcul the coef from the database choosen |
4959 | CalculChargeCoefMean(fCountDet[0],(Int_t) (idect-fDect1[0]),kFALSE); | |
77566f2a | 4960 | |
8ec526a4 | 4961 | // Fill the coefCH[2304] with negative value to say: not fitted |
4962 | for (Int_t k = fRowMin[0]; k < fRowMax[0]; k++) { | |
4963 | for (Int_t j = fColMin[0]; j < fColMax[0]; j++) { | |
4964 | if (GetChamber(fCountDet[0]) == 2) { | |
4965 | fCoefCH[(Int_t)(j*12+k)] = -TMath::Abs(fChargeCoef[3]); | |
4966 | } | |
4967 | if (GetChamber(fCountDet[0]) != 2) { | |
4968 | fCoefCH[(Int_t)(j*16+k)] = -TMath::Abs(fChargeCoef[3]); | |
4969 | } | |
77566f2a | 4970 | } |
8ec526a4 | 4971 | } |
9f4780aa | 4972 | |
4973 | // Put the default value negative | |
4974 | if ((fDebug == 1) || | |
4975 | (fDebug == 4)) { | |
4976 | ||
4977 | if (fFitChargeBisOn) { | |
4978 | fCoefCharge[2][idect-fDect1[0]]=-TMath::Abs(fChargeCoef[3]); | |
4979 | } | |
4980 | if (fMeanChargeOn) { | |
4981 | fCoefCharge[1][idect-fDect1[0]]=-TMath::Abs(fChargeCoef[3]); | |
4982 | } | |
4983 | ||
4984 | fCoefCharge[0][idect-fDect1[0]]=-TMath::Abs(fChargeCoef[3]); | |
4985 | ||
4986 | } | |
8ec526a4 | 4987 | |
4988 | // End of one detector | |
4989 | if ((idect == (fCount[0]-1))) { | |
4990 | FillVectorFitCH((Int_t) fCountDet[0]); | |
4991 | // Reset | |
4992 | for (Int_t k = 0; k < 2304; k++) { | |
4993 | fCoefCH[k] = 0.0; | |
77566f2a | 4994 | } |
4995 | } | |
8ec526a4 | 4996 | |
77566f2a | 4997 | } |
4998 | ||
8ec526a4 | 4999 | if ((i == 1) && (fDebug != 2)) { |
77566f2a | 5000 | |
8ec526a4 | 5001 | CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect-fDect1[1])); |
5002 | CalculT0CoefMean(fCountDet[1],(Int_t) (idect-fDect1[1])); | |
5003 | ||
9f4780aa | 5004 | // Put the default value (time0 can be negativ, so we stay with + ) |
8ec526a4 | 5005 | if ((fDebug == 1) || |
5006 | (fDebug == 4)) { | |
5007 | ||
5008 | if (fFitPHOn) { | |
9f4780aa | 5009 | fCoefVdrift[0][(idect-fDect1[1])] = -fVdriftCoef[2]; |
5010 | fCoefT0[0][(idect-fDect1[1])] = fT0Coef[2]; | |
77566f2a | 5011 | } |
8ec526a4 | 5012 | |
9f4780aa | 5013 | fCoefVdrift[1][(idect-fDect1[1])] = -fVdriftCoef[2]; |
5014 | fCoefT0[1][(idect-fDect1[1])] = fT0Coef[2]; | |
8ec526a4 | 5015 | |
77566f2a | 5016 | } |
5017 | ||
8ec526a4 | 5018 | // Put the default value |
5019 | if (fDebug >= 3) { | |
77566f2a | 5020 | fVdriftCoef[0] = fVdriftCoef[2]; |
5021 | fVdriftCoef[1] = fVdriftCoef[2]; | |
5022 | FillCoefVdriftDB(); | |
8ec526a4 | 5023 | fT0Coef[0] = fT0Coef[2]; |
5024 | fT0Coef[1] = fT0Coef[2]; | |
77566f2a | 5025 | FillCoefT0DB(); |
5026 | } | |
77566f2a | 5027 | |
8ec526a4 | 5028 | // Fill the tree if end of a detector. |
9f4780aa | 5029 | // The pointer to the branch stays with the default value negative!!! |
8ec526a4 | 5030 | // PH |
5031 | // Pointer to the branch | |
5032 | for (Int_t k = fRowMin[1]; k < fRowMax[1]; k++) { | |
5033 | for (Int_t j = fColMin[1]; j < fColMax[1]; j++) { | |
5034 | if (GetChamber(fCountDet[1]) == 2) { | |
5035 | fVdriftPad[(Int_t)(j*12+k)] = -TMath::Abs(fVdriftCoef[2]); | |
5036 | } | |
5037 | if (GetChamber(fCountDet[1]) != 2) { | |
5038 | fVdriftPad[(Int_t)(j*16+k)] = -TMath::Abs(fVdriftCoef[2]); | |
5039 | } | |
77566f2a | 5040 | } |
8ec526a4 | 5041 | } |
5042 | ||
5043 | // End of one detector | |
5044 | if ((idect == (fCount[1]-1)) && (fDebug != 2)) { | |
5045 | FillTreeVdrift((Int_t) fCountDet[1]); | |
5046 | } | |
5047 | ||
5048 | // T0 | |
5049 | // Fill the tree if end of a detector. | |
9f4780aa | 5050 | // The pointer to the branch stays with the default value positive!!! |
8ec526a4 | 5051 | // Pointer to the branch |
5052 | for (Int_t k = fRowMin[1]; k < fRowMax[1]; k++) { | |
5053 | for (Int_t j = fColMin[1]; j < fColMax[1]; j++) { | |
5054 | if (GetChamber(fCountDet[1]) == 2) { | |
9f4780aa | 5055 | fT0Pad[(Int_t)(j*12+k)] = fT0Coef[2]; |
8ec526a4 | 5056 | } |
5057 | if (GetChamber(fCountDet[1]) != 2) { | |
9f4780aa | 5058 | fT0Pad[(Int_t)(j*16+k)] = fT0Coef[2]; |
8ec526a4 | 5059 | } |
77566f2a | 5060 | } |
8ec526a4 | 5061 | } |
5062 | ||
5063 | // End of one detector | |
5064 | if ((idect == (fCount[1]-1)) && (fDebug != 2)) { | |
5065 | FillTreeT0((Int_t) fCountDet[1]); | |
5066 | } | |
5067 | ||
77566f2a | 5068 | } |
77566f2a | 5069 | |
8ec526a4 | 5070 | if ((i == 2) && (fDebug != 2)) { |
5071 | ||
5072 | CalculPRFCoefMean(fCountDet[2],(Int_t) (idect-fDect1[2])); | |
77566f2a | 5073 | |
8ec526a4 | 5074 | if ((fDebug == 1) || |
5075 | (fDebug == 4)) { | |
9f4780aa | 5076 | fCoefPRF[0][(idect-fDect1[2])] = -fPRFCoef[1]; |
77566f2a | 5077 | } |
8ec526a4 | 5078 | |
5079 | if (fDebug >= 3){ | |
77566f2a | 5080 | fPRFCoef[0] = fPRFCoef[1]; |
5081 | FillCoefPRFDB(); | |
5082 | } | |
5083 | ||
8ec526a4 | 5084 | // Fill the tree if end of a detector. |
5085 | // The pointer to the branch stays with the default value 1.5!!! | |
5086 | // Pointer to the branch | |
5087 | for (Int_t k = fRowMin[2]; k < fRowMax[2]; k++) { | |
5088 | for (Int_t j = fColMin[2]; j < fColMax[2]; j++) { | |
5089 | if((parCom->GetColMax(GetPlane(fCountDet[2])) != (j+1)) && (j != 0)){ | |
5090 | if (GetChamber(fCountDet[2]) == 2) { | |
5091 | fPRFPad[(Int_t)(j*12+k)] = -fPRFCoef[1]; | |
5092 | } | |
5093 | if (GetChamber(fCountDet[2]) != 2) { | |
5094 | fPRFPad[(Int_t)(j*16+k)] = -fPRFCoef[1]; | |
5095 | } | |
77566f2a | 5096 | } |
8ec526a4 | 5097 | else { |
5098 | if (fAccCDB) { | |
5099 | if (GetChamber(fCountDet[2]) == 2) { | |
5100 | fPRFPad[(Int_t)(j*12+k)] = -((Float_t) cal->GetPRFWidth(fCountDet[2],j,k)); | |
5101 | } | |
5102 | if (GetChamber(fCountDet[2]) != 2) { | |
5103 | fPRFPad[(Int_t)(j*16+k)] = -((Float_t) cal->GetPRFWidth(fCountDet[2],j,k)); | |
5104 | } | |
5105 | } | |
5106 | if (!fAccCDB) { | |
5107 | if (GetChamber(fCountDet[2]) == 2) { | |
5108 | fPRFPad[(Int_t)(j*12+k)] = -((Float_t) GetPRFDefault(GetPlane(fCountDet[2]))); | |
5109 | } | |
5110 | if (GetChamber(fCountDet[2]) != 2) { | |
5111 | fPRFPad[(Int_t)(j*16+k)] = -((Float_t) GetPRFDefault(GetPlane(fCountDet[2]))); | |
5112 | } | |
5113 | } | |
77566f2a | 5114 | } |
5115 | } | |
8ec526a4 | 5116 | } |
5117 | ||
5118 | // End of one detector | |
5119 | if ((idect == (fCount[2]-1)) && (fDebug != 2)) { | |
5120 | FillTreePRF((Int_t) fCountDet[2]); | |
5121 | } | |
5122 | ||
77566f2a | 5123 | } |
5124 | ||
5125 | return kTRUE; | |
8ec526a4 | 5126 | |
77566f2a | 5127 | } |
5128 | ||
8ec526a4 | 5129 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
77566f2a | 5130 | Bool_t AliTRDCalibra::FillInfosFit(Int_t idect, Int_t i) |
5131 | { | |
5132 | // | |
8ec526a4 | 5133 | // Fill the coefficients found with the fits or other |
5134 | // methods from the Fit functions | |
77566f2a | 5135 | // |
77566f2a | 5136 | |
5137 | // Get the parameter object | |
5138 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
5139 | if (!parCom) { | |
5140 | AliInfo("Could not get CommonParam Manager"); | |
5141 | return kFALSE; | |
5142 | } | |
5143 | ||
8ec526a4 | 5144 | // Get cal |
77566f2a | 5145 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
5146 | if (!cal) { | |
5147 | AliInfo("Could not get calibDB"); | |
5148 | return kFALSE; | |
5149 | } | |
5150 | ||
8ec526a4 | 5151 | if ((i == 0) && (fDebug != 2)) { |
5152 | // Fill the coefCH[2304] with fChargeCoef[0] | |
5153 | // that would be negativ only if the fit failed totally | |
5154 | for (Int_t k = fRowMin[0]; k < fRowMax[0]; k++) { | |
5155 | for (Int_t j = fColMin[0]; j < fColMax[0]; j++) { | |
5156 | if (GetChamber(fCountDet[0]) == 2) { | |
5157 | fCoefCH[(Int_t)(j*12+k)] = fChargeCoef[0]; | |
5158 | } | |
5159 | if (GetChamber(fCountDet[0]) != 2) { | |
5160 | fCoefCH[(Int_t)(j*16+k)] = fChargeCoef[0]; | |
5161 | } | |
77566f2a | 5162 | } |
5163 | } | |
8ec526a4 | 5164 | // End of one detector |
5165 | if ((idect == (fCount[0]-1))) { | |
5166 | FillVectorFitCH((Int_t) fCountDet[0]); | |
5167 | // Reset | |
5168 | for (Int_t k = 0; k < 2304; k++) { | |
5169 | fCoefCH[k] = 0.0; | |
77566f2a | 5170 | } |
5171 | } | |
5172 | } | |
77566f2a | 5173 | |
8ec526a4 | 5174 | if ((i == 1) && (fDebug != 2)) { |
5175 | ||
5176 | // PH | |
5177 | // Pointer to the branch: fVdriftCoef[1] will ne negativ only if the fit failed totally | |
5178 | for (Int_t k = fRowMin[1]; k < fRowMax[1]; k++) { | |
5179 | for (Int_t j = fColMin[1]; j < fColMax[1]; j++) { | |
5180 | if (GetChamber(fCountDet[1]) == 2) { | |
5181 | fVdriftPad[(Int_t)(j*12+k)]=fVdriftCoef[1]; | |
5182 | } | |
5183 | if (GetChamber(fCountDet[1]) != 2) { | |
5184 | fVdriftPad[(Int_t)(j*16+k)]=fVdriftCoef[1]; | |
5185 | } | |
77566f2a | 5186 | } |
5187 | } | |
8ec526a4 | 5188 | // End of one detector |
5189 | if ((idect == (fCount[1]-1)) && (fDebug != 2)) { | |
5190 | FillTreeVdrift((Int_t) fCountDet[1]); | |
5191 | } | |
77566f2a | 5192 | |
8ec526a4 | 5193 | // T0 |
5194 | // Pointer to the branch: fT0Coef[1] will ne negativ only if the fit failed totally | |
5195 | for (Int_t k = fRowMin[1]; k < fRowMax[1]; k++) { | |
5196 | for (Int_t j = fColMin[1]; j < fColMax[1]; j++) { | |
5197 | if (GetChamber(fCountDet[1]) == 2) { | |
5198 | fT0Pad[(Int_t)(j*12+k)]=fT0Coef[1]; | |
5199 | } | |
5200 | if (GetChamber(fCountDet[1]) != 2) { | |
5201 | fT0Pad[(Int_t)(j*16+k)]=fT0Coef[1]; | |
5202 | } | |
77566f2a | 5203 | } |
5204 | } | |
8ec526a4 | 5205 | // End of one detector |
5206 | if ((idect == (fCount[1]-1)) && (fDebug != 2)) { | |
5207 | FillTreeT0((Int_t) fCountDet[1]); | |
5208 | } | |
5209 | ||
77566f2a | 5210 | } |
8ec526a4 | 5211 | |
5212 | if ((i == 2) && (fDebug != 2)) { | |
5213 | // Pointer to the branch | |
5214 | for (Int_t k = fRowMin[2]; k < fRowMax[2]; k++) { | |
5215 | for (Int_t j = fColMin[2]; j < fColMax[2]; j++) { | |
5216 | if ((parCom->GetColMax(GetPlane(fCountDet[2])) != (j+1)) && (j != 0)) { | |
5217 | if (GetChamber(fCountDet[2]) == 2) { | |
5218 | fPRFPad[(Int_t)(j*12+k)] = fPRFCoef[0]; | |
5219 | } | |
5220 | if (GetChamber(fCountDet[2]) != 2) { | |
5221 | fPRFPad[(Int_t)(j*16+k)] = fPRFCoef[0]; | |
5222 | } | |
5223 | } | |
5224 | else { | |
5225 | if (fAccCDB) { | |
5226 | if (GetChamber(fCountDet[2]) == 2) { | |
5227 | fPRFPad[(Int_t)(j*12+k)] = (Float_t) cal->GetPRFWidth(fCountDet[2],j,k); | |
5228 | } | |
5229 | if (GetChamber(fCountDet[2]) != 2) { | |
5230 | fPRFPad[(Int_t)(j*16+k)] = (Float_t) cal->GetPRFWidth(fCountDet[2],j,k); | |
5231 | } | |
5232 | } | |
5233 | if (!fAccCDB) { | |
5234 | if (GetChamber(fCountDet[2]) == 2) { | |
5235 | fPRFPad[(Int_t)(j*12+k)] = (Float_t) GetPRFDefault(GetPlane(fCountDet[2])); | |
5236 | } | |
5237 | if (GetChamber(fCountDet[2]) != 2) { | |
5238 | fPRFPad[(Int_t)(j*16+k)] = (Float_t) GetPRFDefault(GetPlane(fCountDet[2])); | |
5239 | } | |
77566f2a | 5240 | } |
77566f2a | 5241 | } |
8ec526a4 | 5242 | } |
5243 | } | |
5244 | // End of one detector | |
5245 | if ((idect == (fCount[2]-1)) && (fDebug != 2)) { | |
5246 | FillTreePRF((Int_t) fCountDet[2]); | |
5247 | } | |
77566f2a | 5248 | } |
8ec526a4 | 5249 | |
77566f2a | 5250 | return kTRUE; |
5251 | ||
5252 | } | |
77566f2a | 5253 | |
8ec526a4 | 5254 | //____________Functions for initialising the AliTRDCalibra in the code_________ |
77566f2a | 5255 | Bool_t AliTRDCalibra::WriteFitInfos(Int_t i) |
5256 | { | |
5257 | // | |
8ec526a4 | 5258 | // In the case the user wants to write a file with a tree of the found |
5259 | // coefficients for the calibration before putting them in the database | |
77566f2a | 5260 | // |
5261 | ||
77566f2a | 5262 | TFile *fout = TFile::Open(fWriteNameCoef,"UPDATE"); |
8ec526a4 | 5263 | // Check if the file could be opened |
77566f2a | 5264 | if (!fout || !fout->IsOpen()) { |
5265 | AliInfo("No File found!"); | |
5266 | return kFALSE; | |
5267 | } | |
8ec526a4 | 5268 | |
5269 | if ((i == 0) && (fDebug != 2)) { | |
8ec526a4 | 5270 | // The DB stuff |
5271 | if ((fDebug == 4) || | |
5272 | (fDebug == 3)) { | |
5273 | WriteCHDB(fout); | |
5274 | } | |
5275 | // The tree | |
5276 | fout->WriteTObject(fGain,fGain->GetName(),(Option_t *) "writedelete"); | |
5277 | } | |
5278 | ||
5279 | if ((i == 1) && (fDebug != 2)) { | |
8ec526a4 | 5280 | // The DB stuff |
5281 | if ((fDebug == 4) || | |
5282 | (fDebug == 3)) { | |
5283 | WritePHDB(fout); | |
5284 | } | |
5285 | // The tree | |
5286 | fout->WriteTObject(fVdrift,fVdrift->GetName(),(Option_t *) "writedelete"); | |
8ec526a4 | 5287 | // The DB stuff |
5288 | if ((fDebug == 4) || | |
5289 | (fDebug == 3)) { | |
5290 | WriteT0DB(fout); | |
5291 | } | |
5292 | // The tree | |
5293 | fout->WriteTObject(fT0,fT0->GetName(),(Option_t *) "writedelete"); | |
5294 | } | |
5295 | ||
5296 | if ((i == 2) && (fDebug != 2)) { | |
8ec526a4 | 5297 | // The DB stuff |
5298 | if ((fDebug == 4) || | |
5299 | (fDebug == 3)) { | |
5300 | WritePRFDB(fout); | |
5301 | } | |
5302 | // The tree | |
5303 | fout->WriteTObject(fPRF,fPRF->GetName(),(Option_t *) "writedelete"); | |
77566f2a | 5304 | } |
8ec526a4 | 5305 | |
77566f2a | 5306 | fout->Close(); |
8ec526a4 | 5307 | |
77566f2a | 5308 | return kTRUE; |
8ec526a4 | 5309 | |
77566f2a | 5310 | } |
77566f2a | 5311 | |
8ec526a4 | 5312 | // |
5313 | //____________Fill Coef DB in case of visualisation of one detector____________ | |
5314 | // | |
5315 | ||
5316 | //_____________________________________________________________________________ | |
77566f2a | 5317 | void AliTRDCalibra::FillCoefVdriftDB() |
5318 | { | |
5319 | // | |
5320 | // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5321 | // | |
5322 | ||
8ec526a4 | 5323 | for (Int_t row = fRowMin[1]; row < fRowMax[1]; row++) { |
5324 | for (Int_t col = fColMin[1]; col < fColMax[1]; col++) { | |
77566f2a | 5325 | fCoefVdriftDB[1]->SetBinContent(row+1,col+1,TMath::Abs(fVdriftCoef[1])); |
8ec526a4 | 5326 | if (fFitPHOn ) { |
5327 | fCoefVdriftDB[0]->SetBinContent(row+1,col+1,TMath::Abs(fVdriftCoef[0])); | |
5328 | } | |
77566f2a | 5329 | } |
5330 | } | |
8ec526a4 | 5331 | |
77566f2a | 5332 | } |
8ec526a4 | 5333 | |
5334 | //_____________________________________________________________________________ | |
77566f2a | 5335 | void AliTRDCalibra::FillCoefT0DB() |
5336 | { | |
5337 | // | |
5338 | // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5339 | // | |
5340 | ||
8ec526a4 | 5341 | for (Int_t row = fRowMin[1]; row < fRowMax[1]; row++) { |
5342 | for (Int_t col = fColMin[1]; col < fColMax[1]; col++) { | |
77566f2a | 5343 | fCoefT0DB[1]->SetBinContent(row+1,col+1,TMath::Abs(fT0Coef[1])); |
8ec526a4 | 5344 | if (fFitPHOn) { |
5345 | fCoefT0DB[0]->SetBinContent(row+1,col+1,TMath::Abs(fT0Coef[0])); | |
5346 | } | |
77566f2a | 5347 | } |
5348 | } | |
8ec526a4 | 5349 | |
77566f2a | 5350 | } |
8ec526a4 | 5351 | |
5352 | //_____________________________________________________________________________ | |
77566f2a | 5353 | void AliTRDCalibra::FillCoefChargeDB() |
5354 | { | |
5355 | // | |
5356 | // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5357 | // | |
5358 | ||
8ec526a4 | 5359 | for (Int_t row = fRowMin[0]; row < fRowMax[0]; row++) { |
5360 | for (Int_t col = fColMin[0]; col < fColMax[0]; col++) { | |
5361 | if (fMeanChargeOn) { | |
5362 | fCoefChargeDB[1]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[1])); | |
5363 | } | |
5364 | if (fFitChargeBisOn) { | |
5365 | fCoefChargeDB[2]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[2])); | |
5366 | } | |
77566f2a | 5367 | fCoefChargeDB[0]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[0])); |
5368 | } | |
8ec526a4 | 5369 | } |
5370 | ||
77566f2a | 5371 | } |
8ec526a4 | 5372 | |
5373 | //_____________________________________________________________________________ | |
77566f2a | 5374 | void AliTRDCalibra::FillCoefPRFDB() |
5375 | { | |
5376 | // | |
5377 | // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
5378 | // | |
8ec526a4 | 5379 | |
5380 | for (Int_t row = fRowMin[2]; row < fRowMax[2]; row++) { | |
5381 | for (Int_t col = fColMin[2]; col < fColMax[2]; col++) { | |
77566f2a | 5382 | fCoefPRFDB->SetBinContent(row+1,col+1,fPRFCoef[0]); |
77566f2a | 5383 | } |
8ec526a4 | 5384 | } |
77566f2a | 5385 | |
8ec526a4 | 5386 | } |
77566f2a | 5387 | |
8ec526a4 | 5388 | // |
5389 | //____________Plot histos CoefPRF....__________________________________________ | |
5390 | // | |
77566f2a | 5391 | |
8ec526a4 | 5392 | //_____________________________________________________________________________ |
9f4780aa | 5393 | void AliTRDCalibra::PlotWriteCH() |
77566f2a | 5394 | { |
5395 | // | |
9f4780aa | 5396 | // Scale the coefficients to one, create the graph errors and write them if wanted |
77566f2a | 5397 | // |
8ec526a4 | 5398 | |
9f4780aa | 5399 | //TObjArray of the grapherrors and so on |
5400 | TObjArray *listofgraphs = new TObjArray(); | |
5401 | ||
5402 | Int_t nbins = fDect2[0]-fDect1[0]; | |
5403 | ||
5404 | //Scale the coefs | |
5405 | ||
5406 | //counter | |
5407 | Int_t counter[3]; | |
5408 | counter[0] = 0; | |
5409 | counter[1] = 0; | |
5410 | counter[2] = 0; | |
5411 | Double_t sum = 0.0; | |
5412 | Double_t scale = 1.0; | |
5413 | ||
5414 | // Scale the histo | |
5415 | Double_t *xValuesFitted = new Double_t[nbins]; | |
5416 | Double_t *xValuesFittedMean = new Double_t[nbins]; | |
5417 | Double_t *xValuesFittedBis = new Double_t[nbins]; | |
5418 | for(Int_t k = 0; k < nbins; k ++){ | |
5419 | xValuesFitted[k] = -1; | |
5420 | xValuesFittedMean[k] = -1; | |
5421 | xValuesFittedBis[k] = -1; | |
5422 | } | |
5423 | ||
5424 | for(Int_t l = 0; l < nbins; l++){ | |
5425 | if(fCoefCharge[0][l] > 0){ | |
5426 | fCoefCharge[0][l]=fCoefCharge[0][l]*fScaleFitFactor; | |
5427 | fCoefChargeE[0][l]=fCoefChargeE[0][l]*fScaleFitFactor; | |
5428 | xValuesFitted[counter[0]]=l; | |
5429 | counter[0]++; | |
5430 | } | |
5431 | } | |
5432 | if(fMeanChargeOn){ | |
5433 | sum = 0.0; | |
5434 | for(Int_t l = 0; l < nbins; l++){ | |
5435 | if(fCoefCharge[1][l] > 0){ | |
5436 | sum += fCoefCharge[1][l]; | |
5437 | xValuesFittedMean[counter[1]]= l; | |
5438 | counter[1]++; | |
5439 | } | |
5440 | } | |
5441 | scale = 1.0; | |
5442 | if(sum > 0.0) scale = counter[1]/sum; | |
5443 | for(Int_t l = 0; l < nbins; l++){ | |
5444 | if(fCoefCharge[1][l] > 0){ | |
5445 | fCoefCharge[1][l]=fCoefCharge[1][l]*scale; | |
5446 | fCoefChargeE[1][l]=fCoefChargeE[1][l]*scale; | |
5447 | } | |
5448 | } | |
5449 | } | |
5450 | if(fFitChargeBisOn){ | |
5451 | sum = 0.0; | |
5452 | for(Int_t l = 0; l < nbins; l++){ | |
5453 | if(fCoefCharge[2][l] > 0){ | |
5454 | fCoefCharge[2][l]=fCoefCharge[2][l]*fScaleFitFactor; | |
5455 | fCoefChargeE[2][l]=fCoefChargeE[2][l]*fScaleFitFactor; | |
5456 | sum += fCoefCharge[2][l]; | |
5457 | xValuesFittedBis[counter[2]]= l; | |
5458 | counter[2]++; | |
5459 | } | |
5460 | } | |
5461 | scale = 1.0; | |
5462 | if(sum > 0.0) scale = counter[2]/sum; | |
5463 | for(Int_t l = 0; l < nbins; l++){ | |
5464 | if(fCoefCharge[2][l] > 0){ | |
5465 | fCoefCharge[2][l]=fCoefCharge[2][l]*scale; | |
5466 | fCoefChargeE[2][l]=fCoefChargeE[2][l]*scale; | |
5467 | if(fCoefCharge[2][l] > 1.0) printf("for the group %d, I have the coef %f with the error %f\n",l,fCoefCharge[2][l],fCoefChargeE[2][l]); | |
5468 | } | |
5469 | } | |
5470 | } | |
5471 | ||
5472 | //Create the X and Xerror | |
5473 | Double_t *xValues = new Double_t[nbins]; | |
5474 | Double_t *xValuesE = new Double_t[nbins]; | |
5475 | for(Int_t k = 0; k < nbins; k ++){ | |
5476 | xValues[k] = k; | |
5477 | xValuesE[k] = 0.0; | |
5478 | } | |
5479 | ||
5480 | //Create the graph erros and plot them | |
5481 | TGraph *graphCharge3 = new TGraph(nbins,xValues,fCoefCharge[3]); | |
5482 | graphCharge3->SetName("coefcharge3"); | |
5483 | graphCharge3->SetTitle(""); | |
5484 | graphCharge3->GetXaxis()->SetTitle("Det/Pad groups"); | |
5485 | graphCharge3->GetYaxis()->SetTitle("gain factor"); | |
5486 | graphCharge3->SetLineColor(4); | |
5487 | listofgraphs->Add((TObject *)graphCharge3); | |
5488 | TGraphErrors *graphCharge0 = new TGraphErrors(nbins,xValues,fCoefCharge[0],xValuesE,fCoefChargeE[0]); | |
5489 | graphCharge0->SetName("coefcharge0"); | |
5490 | graphCharge0->SetTitle(""); | |
5491 | graphCharge0->GetXaxis()->SetTitle("Det/Pad groups"); | |
5492 | graphCharge0->GetYaxis()->SetTitle("gain factor"); | |
5493 | graphCharge0->SetMarkerColor(6); | |
5494 | graphCharge0->SetLineColor(6); | |
5495 | graphCharge0->SetMarkerStyle(26); | |
5496 | listofgraphs->Add((TObject *)graphCharge0); | |
77566f2a | 5497 | TCanvas *cch1 = new TCanvas("cch1","",50,50,600,800); |
5498 | cch1->cd(); | |
5499 | TLegend *legch1 = new TLegend(0.4,0.6,0.89,0.89); | |
9f4780aa | 5500 | legch1->AddEntry(graphCharge3,"f_{g} simulated","l"); |
5501 | legch1->AddEntry(graphCharge0,"f_{g} fit","p"); | |
5502 | graphCharge0->Draw("AP"); | |
5503 | //graphCharge3->Draw("AL"); | |
8ec526a4 | 5504 | if (fMeanChargeOn) { |
9f4780aa | 5505 | TGraphErrors *graphCharge1 = new TGraphErrors(nbins,xValues,fCoefCharge[1],xValuesE,fCoefChargeE[1]); |
5506 | graphCharge1->SetName("coefcharge1"); | |
5507 | graphCharge1->GetXaxis()->SetTitle("Det/Pad groups"); | |
5508 | graphCharge1->GetYaxis()->SetTitle("gain factor"); | |
5509 | graphCharge1->SetTitle(""); | |
5510 | graphCharge1->SetMarkerColor(2); | |
5511 | graphCharge1->SetLineColor(2); | |
5512 | graphCharge1->SetMarkerStyle(24); | |
5513 | legch1->AddEntry(graphCharge1,"f_{g} mean","p"); | |
5514 | graphCharge1->Draw("P"); | |
5515 | listofgraphs->Add((TObject *)graphCharge1); | |
8ec526a4 | 5516 | } |
8ec526a4 | 5517 | if (fFitChargeBisOn ) { |
9f4780aa | 5518 | TGraphErrors *graphCharge2 = new TGraphErrors(nbins,xValues,fCoefCharge[2],xValuesE,fCoefChargeE[2]); |
5519 | graphCharge2->SetName("coefcharge2"); | |
5520 | graphCharge2->SetTitle(""); | |
5521 | graphCharge2->GetXaxis()->SetTitle("Det/Pad groups"); | |
5522 | graphCharge2->GetYaxis()->SetTitle("gain factor"); | |
5523 | graphCharge2->SetMarkerColor(8); | |
5524 | graphCharge2->SetLineColor(8); | |
5525 | graphCharge2->SetMarkerStyle(25); | |
5526 | legch1->AddEntry(graphCharge2,"f_{g} fitbis","p"); | |
5527 | graphCharge2->Draw("P"); | |
5528 | listofgraphs->Add((TObject *)graphCharge2); | |
5529 | } | |
77566f2a | 5530 | legch1->Draw("same"); |
8ec526a4 | 5531 | |
9f4780aa | 5532 | |
5533 | //Create the arrays and the graphs for the delta | |
77566f2a | 5534 | TCanvas *cch2 = new TCanvas("cch2","",50,50,600,800); |
5535 | cch2->Divide(2,1); | |
77566f2a | 5536 | cch2->cd(2); |
9f4780aa | 5537 | Double_t *yValuesDelta = new Double_t[counter[0]]; |
5538 | for(Int_t k = 0; k < counter[0]; k++){ | |
5539 | if(fCoefCharge[3][(Int_t)(xValuesFitted[k])] > 0.0) { | |
5540 | yValuesDelta[k] = (fCoefCharge[0][(Int_t)xValuesFitted[k]]-fCoefCharge[3][(Int_t)xValuesFitted[k]])/fCoefCharge[3][(Int_t)xValuesFitted[k]]; | |
5541 | } | |
5542 | else yValuesDelta[k] = 0.0; | |
5543 | } | |
5544 | TGraph *graphDeltaCharge0 = new TGraph(counter[0],&xValuesFitted[0],yValuesDelta); | |
5545 | graphDeltaCharge0->SetName("deltacharge0"); | |
5546 | graphDeltaCharge0->GetXaxis()->SetTitle("Det/Pad groups"); | |
5547 | graphDeltaCharge0->GetYaxis()->SetTitle("#Deltag/g_{sim}"); | |
5548 | graphDeltaCharge0->SetMarkerColor(6); | |
5549 | graphDeltaCharge0->SetTitle(""); | |
5550 | graphDeltaCharge0->SetLineColor(6); | |
5551 | graphDeltaCharge0->SetMarkerStyle(26); | |
5552 | listofgraphs->Add((TObject *)graphDeltaCharge0); | |
77566f2a | 5553 | TLegend *legch3 = new TLegend(0.4,0.6,0.89,0.89); |
9f4780aa | 5554 | legch3->AddEntry(graphDeltaCharge0,"fit","p"); |
5555 | graphDeltaCharge0->Draw("AP"); | |
5556 | cch2->cd(1); | |
5557 | TH1I *histoErrorCharge0 = new TH1I("errorcharge0","",100 ,-0.3,0.3); | |
5558 | histoErrorCharge0->SetXTitle("#Deltag/g_{sim}"); | |
5559 | histoErrorCharge0->SetYTitle("counts"); | |
5560 | histoErrorCharge0->SetLineColor(6); | |
5561 | histoErrorCharge0->SetLineStyle(1); | |
5562 | histoErrorCharge0->SetStats(0); | |
5563 | for(Int_t k = 0; k < counter[0]; k++){ | |
5564 | histoErrorCharge0->Fill(yValuesDelta[k]); | |
8ec526a4 | 5565 | } |
9f4780aa | 5566 | TLegend *legch2 = new TLegend(0.4,0.6,0.89,0.89); |
5567 | legch2->AddEntry(histoErrorCharge0,"f_{g} fit","l"); | |
5568 | histoErrorCharge0->Draw(); | |
5569 | listofgraphs->Add((TObject *)histoErrorCharge0); | |
8ec526a4 | 5570 | if (fMeanChargeOn) { |
9f4780aa | 5571 | cch2->cd(2); |
5572 | Double_t *yValuesDeltaMean = new Double_t[counter[1]]; | |
5573 | for(Int_t k = 0; k < counter[1]; k++){ | |
5574 | if(fCoefCharge[3][(Int_t)xValuesFittedMean[k]] > 0.0) { | |
5575 | yValuesDeltaMean[k] = (fCoefCharge[1][(Int_t)xValuesFittedMean[k]]-fCoefCharge[3][(Int_t)xValuesFittedMean[k]])/fCoefCharge[3][(Int_t)xValuesFittedMean[k]]; | |
5576 | } | |
5577 | else yValuesDeltaMean[k] = 0.0; | |
5578 | } | |
5579 | TGraph *graphDeltaCharge1 = new TGraph(counter[1],&xValuesFittedMean[0],yValuesDeltaMean); | |
5580 | graphDeltaCharge1->SetName("deltacharge1"); | |
5581 | graphDeltaCharge1->GetXaxis()->SetTitle("Det/Pad groups"); | |
5582 | graphDeltaCharge1->GetYaxis()->SetTitle("#Deltag/g_{sim}"); | |
5583 | graphDeltaCharge1->SetMarkerColor(2); | |
5584 | graphDeltaCharge1->SetMarkerStyle(24); | |
5585 | graphDeltaCharge1->SetLineColor(2); | |
5586 | graphDeltaCharge1->SetTitle(""); | |
5587 | legch3->AddEntry(graphDeltaCharge1,"mean","p"); | |
5588 | graphDeltaCharge1->Draw("P"); | |
5589 | listofgraphs->Add((TObject *)graphDeltaCharge1); | |
5590 | cch2->cd(1); | |
5591 | TH1I *histoErrorCharge1 = new TH1I("errorcharge1","",100 ,-0.3,0.3); | |
5592 | histoErrorCharge1->SetXTitle("#Deltag/g_{sim}"); | |
5593 | histoErrorCharge1->SetYTitle("counts"); | |
5594 | histoErrorCharge1->SetLineColor(2); | |
5595 | histoErrorCharge1->SetLineStyle(2); | |
5596 | histoErrorCharge1->SetStats(0); | |
5597 | for(Int_t k = 0; k < counter[1]; k++){ | |
5598 | histoErrorCharge1->Fill(yValuesDeltaMean[k]); | |
5599 | } | |
5600 | legch2->AddEntry(histoErrorCharge1,"f_{g} mean","l"); | |
5601 | histoErrorCharge1->Draw("same"); | |
5602 | listofgraphs->Add((TObject *)histoErrorCharge1); | |
8ec526a4 | 5603 | } |
9f4780aa | 5604 | |
8ec526a4 | 5605 | if (fFitChargeBisOn) { |
9f4780aa | 5606 | cch2->cd(2); |
5607 | Double_t *yValuesDeltaBis = new Double_t[counter[2]]; | |
5608 | for(Int_t k = 0; k < counter[2]; k++){ | |
5609 | if(fCoefCharge[3][(Int_t)xValuesFittedBis[k]] > 0.0) { | |
5610 | yValuesDeltaBis[k] = (fCoefCharge[2][(Int_t)xValuesFittedBis[k]]-fCoefCharge[3][(Int_t)xValuesFittedBis[k]])/fCoefCharge[3][(Int_t)xValuesFittedBis[k]]; | |
5611 | } | |
5612 | else yValuesDeltaBis[k] = 0.0; | |
5613 | } | |
5614 | TGraph *graphDeltaCharge2 = new TGraph(counter[2],&xValuesFittedBis[0],yValuesDeltaBis); | |
5615 | graphDeltaCharge2->SetName("deltacharge2"); | |
5616 | graphDeltaCharge2->GetXaxis()->SetTitle("Det/Pad groups"); | |
5617 | graphDeltaCharge2->GetYaxis()->SetTitle("#Deltag/g_{sim}"); | |
5618 | graphDeltaCharge2->SetMarkerColor(8); | |
5619 | graphDeltaCharge2->SetLineColor(8); | |
5620 | graphDeltaCharge2->SetMarkerStyle(25); | |
5621 | legch3->AddEntry(graphDeltaCharge2,"fit","p"); | |
5622 | graphDeltaCharge2->SetTitle(""); | |
5623 | graphDeltaCharge2->Draw("P"); | |
5624 | listofgraphs->Add((TObject *)graphDeltaCharge2); | |
5625 | cch2->cd(1); | |
5626 | TH1I *histoErrorCharge2 = new TH1I("errorcharge2","",100 ,-0.3,0.3); | |
5627 | histoErrorCharge2->SetXTitle("#Deltag/g_{sim}"); | |
5628 | histoErrorCharge2->SetYTitle("counts"); | |
5629 | histoErrorCharge2->SetLineColor(8); | |
5630 | histoErrorCharge2->SetLineStyle(5); | |
5631 | histoErrorCharge2->SetLineWidth(3); | |
5632 | histoErrorCharge2->SetStats(0); | |
5633 | for(Int_t k = 0; k < counter[2]; k++){ | |
5634 | histoErrorCharge2->Fill(yValuesDeltaBis[k]); | |
5635 | } | |
5636 | legch2->AddEntry(histoErrorCharge2,"f_{g} fitbis","l"); | |
5637 | histoErrorCharge2->Draw("same"); | |
5638 | listofgraphs->Add((TObject *)histoErrorCharge2); | |
8ec526a4 | 5639 | } |
9f4780aa | 5640 | cch2->cd(2); |
77566f2a | 5641 | legch3->Draw("same"); |
9f4780aa | 5642 | cch2->cd(1); |
5643 | legch2->Draw("same"); | |
5644 | ||
5645 | ||
5646 | //Write if wanted | |
5647 | if (fWriteCoef[0]){ | |
5648 | TFile *fout = TFile::Open(fWriteNameCoef,"UPDATE"); | |
5649 | // Check if the file could be opened | |
5650 | if (!fout || !fout->IsOpen()) { | |
5651 | AliInfo("No File found!"); | |
5652 | } | |
5653 | ||
5654 | else{ | |
5655 | for(Int_t k = 0; k < listofgraphs->GetEntriesFast(); k++){ | |
5656 | fout->WriteTObject((TObject *) listofgraphs->At(k),((TObject *)listofgraphs->At(k))->GetName(),(Option_t *) "OverWrite"); | |
5657 | } | |
5658 | } | |
5659 | fout->Close(); | |
5660 | } | |
5661 | ||
77566f2a | 5662 | } |
8ec526a4 | 5663 | |
5664 | //_____________________________________________________________________________ | |
9f4780aa | 5665 | void AliTRDCalibra::PlotWritePH() |
77566f2a | 5666 | { |
5667 | // | |
9f4780aa | 5668 | // create the graph errors and write them if wanted |
77566f2a | 5669 | // |
5670 | ||
9f4780aa | 5671 | //TObjArray of the grapherrors and so on |
5672 | TObjArray *listofgraphs = new TObjArray(); | |
5673 | ||
5674 | Int_t nbins = fDect2[1]-fDect1[1]; | |
5675 | ||
5676 | //See the number of fitted for delta | |
5677 | ||
5678 | //counter | |
5679 | Int_t counter[2]; | |
5680 | counter[0] = 0; | |
5681 | counter[1] = 0; | |
5682 | ||
5683 | Double_t *xValuesFitted = new Double_t[nbins]; | |
5684 | Double_t *xValuesFittedPH = new Double_t[nbins]; | |
5685 | for(Int_t k = 0; k < nbins; k ++){ | |
5686 | xValuesFitted[k] = -1; | |
5687 | xValuesFittedPH[k] = -1; | |
5688 | } | |
5689 | ||
5690 | for(Int_t l = 0; l < nbins; l++){ | |
5691 | if(fCoefVdrift[1][l] > 0){ | |
5692 | xValuesFitted[counter[1]]=l; | |
5693 | counter[1]++; | |
5694 | } | |
5695 | } | |
5696 | if(fFitPHOn){ | |
5697 | for(Int_t l = 0; l < nbins; l++){ | |
5698 | if(fCoefVdrift[0][l] > 0){ | |
5699 | xValuesFittedPH[counter[0]]= l; | |
5700 | counter[0]++; | |
5701 | } | |
5702 | } | |
5703 | } | |
5704 | ||
5705 | ||
5706 | //Create the X and Xerror | |
5707 | Double_t *xValues = new Double_t[nbins]; | |
5708 | Double_t *xValuesE = new Double_t[nbins]; | |
5709 | for(Int_t k = 0; k < nbins; k ++){ | |
5710 | xValues[k] = k; | |
5711 | xValuesE[k] = 0.0; | |
5712 | } | |
5713 | ||
5714 | //Create the graph erros and plot them | |
5715 | TGraph *graphVdrift2 = new TGraph(nbins,xValues,fCoefVdrift[2]); | |
5716 | graphVdrift2->SetName("coefvdrift2"); | |
5717 | graphVdrift2->SetTitle(""); | |
5718 | graphVdrift2->GetXaxis()->SetTitle("Det/Pad groups"); | |
5719 | graphVdrift2->GetYaxis()->SetTitle("Vdrift [cm/#mus]"); | |
5720 | graphVdrift2->SetLineColor(4); | |
5721 | listofgraphs->Add((TObject *)graphVdrift2); | |
5722 | TGraphErrors *graphVdrift1 = new TGraphErrors(nbins,xValues,fCoefVdrift[1],xValuesE,fCoefVdriftE[1]); | |
5723 | graphVdrift1->SetName("coefvdrift1"); | |
5724 | graphVdrift1->SetTitle(""); | |
5725 | graphVdrift1->GetXaxis()->SetTitle("Det/Pad groups"); | |
5726 | graphVdrift1->GetYaxis()->SetTitle("Vdrift [cm/#mus]"); | |
5727 | graphVdrift1->SetMarkerColor(6); | |
5728 | graphVdrift1->SetLineColor(6); | |
5729 | graphVdrift1->SetMarkerStyle(26); | |
5730 | listofgraphs->Add((TObject *)graphVdrift1); | |
77566f2a | 5731 | TCanvas *cph1 = new TCanvas("cph1","",50,50,600,800); |
5732 | cph1->cd(); | |
5733 | TLegend *legph1 = new TLegend(0.4,0.6,0.89,0.89); | |
9f4780aa | 5734 | legph1->AddEntry(graphVdrift2,"Vdrift simulated","l"); |
5735 | legph1->AddEntry(graphVdrift1,"Vdrift fit","p"); | |
5736 | graphVdrift2->Draw("AL"); | |
5737 | graphVdrift1->Draw("P"); | |
8ec526a4 | 5738 | if (fFitPHOn) { |
9f4780aa | 5739 | TGraphErrors *graphVdrift0 = new TGraphErrors(nbins,xValues,fCoefVdrift[0],xValuesE,fCoefVdriftE[0]); |
5740 | graphVdrift0->SetName("coefVdrift0"); | |
5741 | graphVdrift0->GetXaxis()->SetTitle("Det/Pad groups"); | |
5742 | graphVdrift0->GetYaxis()->SetTitle("Vdrift [cm/#mus]"); | |
5743 | graphVdrift0->SetTitle(""); | |
5744 | graphVdrift0->SetMarkerColor(2); | |
5745 | graphVdrift0->SetLineColor(2); | |
5746 | graphVdrift0->SetMarkerStyle(24); | |
5747 | legph1->AddEntry(graphVdrift0,"v_{fit PH}","p"); | |
5748 | graphVdrift0->Draw("P"); | |
5749 | listofgraphs->Add((TObject *)graphVdrift0); | |
5750 | } | |
77566f2a | 5751 | legph1->Draw("same"); |
77566f2a | 5752 | |
9f4780aa | 5753 | |
5754 | //Create the arrays and the graphs for the delta | |
77566f2a | 5755 | TCanvas *cph2 = new TCanvas("cph2","",50,50,600,800); |
5756 | cph2->Divide(2,1); | |
77566f2a | 5757 | cph2->cd(2); |
9f4780aa | 5758 | Double_t *yValuesDelta = new Double_t[counter[1]]; |
5759 | for(Int_t k = 0; k < counter[1]; k++){ | |
5760 | if(fCoefVdrift[2][(Int_t)(xValuesFitted[k])] > 0.0) { | |
5761 | yValuesDelta[k] = (fCoefVdrift[1][(Int_t)xValuesFitted[k]]-fCoefVdrift[2][(Int_t)xValuesFitted[k]])/fCoefVdrift[2][(Int_t)xValuesFitted[k]]; | |
5762 | } | |
5763 | else yValuesDelta[k] = 0.0; | |
5764 | } | |
5765 | TGraph *graphDeltaVdrift1 = new TGraph(counter[1],&xValuesFitted[0],yValuesDelta); | |
5766 | graphDeltaVdrift1->SetName("deltavdrift1"); | |
5767 | graphDeltaVdrift1->GetXaxis()->SetTitle("Det/Pad groups"); | |
5768 | graphDeltaVdrift1->GetYaxis()->SetTitle("#Deltav/v_{sim}"); | |
5769 | graphDeltaVdrift1->SetMarkerColor(6); | |
5770 | graphDeltaVdrift1->SetTitle(""); | |
5771 | graphDeltaVdrift1->SetLineColor(6); | |
5772 | graphDeltaVdrift1->SetMarkerStyle(26); | |
5773 | listofgraphs->Add((TObject *)graphDeltaVdrift1); | |
77566f2a | 5774 | TLegend *legph3 = new TLegend(0.4,0.6,0.89,0.89); |
9f4780aa | 5775 | legph3->AddEntry(graphDeltaVdrift1,"v_{slope method}","p"); |
5776 | graphDeltaVdrift1->Draw("AP"); | |
5777 | cph2->cd(1); | |
5778 | TH1I *histoErrorVdrift1 = new TH1I("errorvdrift1","",100 ,-0.05,0.05); | |
5779 | histoErrorVdrift1->SetXTitle("#Deltav/v_{sim}"); | |
5780 | histoErrorVdrift1->SetYTitle("counts"); | |
5781 | histoErrorVdrift1->SetLineColor(6); | |
5782 | histoErrorVdrift1->SetLineStyle(1); | |
5783 | histoErrorVdrift1->SetStats(0); | |
5784 | for(Int_t k = 0; k < counter[1]; k++){ | |
5785 | histoErrorVdrift1->Fill(yValuesDelta[k]); | |
8ec526a4 | 5786 | } |
9f4780aa | 5787 | TLegend *legph2 = new TLegend(0.4,0.6,0.89,0.89); |
5788 | legph2->AddEntry(histoErrorVdrift1,"v_{slope method}","l"); | |
5789 | histoErrorVdrift1->Draw(); | |
5790 | listofgraphs->Add((TObject *)histoErrorVdrift1); | |
8ec526a4 | 5791 | if (fFitPHOn) { |
9f4780aa | 5792 | cph2->cd(2); |
5793 | Double_t *yValuesDeltaPH = new Double_t[counter[0]]; | |
5794 | for(Int_t k = 0; k < counter[0]; k++){ | |
5795 | if(fCoefVdrift[2][(Int_t)xValuesFittedPH[k]] > 0.0) { | |
5796 | yValuesDeltaPH[k] = (fCoefVdrift[0][(Int_t)xValuesFittedPH[k]]-fCoefVdrift[2][(Int_t)xValuesFittedPH[k]])/fCoefVdrift[2][(Int_t)xValuesFittedPH[k]]; | |
5797 | } | |
5798 | else yValuesDeltaPH[k] = 0.0; | |
5799 | } | |
5800 | TGraph *graphDeltaVdrift0 = new TGraph(counter[0],&xValuesFittedPH[0],yValuesDeltaPH); | |
5801 | graphDeltaVdrift0->SetName("deltavdrift0"); | |
5802 | graphDeltaVdrift0->GetXaxis()->SetTitle("Det/Pad groups"); | |
5803 | graphDeltaVdrift0->GetYaxis()->SetTitle("#Deltav/v_{sim}"); | |
5804 | graphDeltaVdrift0->SetMarkerColor(2); | |
5805 | graphDeltaVdrift0->SetMarkerStyle(24); | |
5806 | graphDeltaVdrift0->SetLineColor(2); | |
5807 | graphDeltaVdrift0->SetTitle(""); | |
5808 | legph3->AddEntry(graphDeltaVdrift0,"v_{fit PH}","p"); | |
5809 | graphDeltaVdrift0->Draw("P"); | |
5810 | listofgraphs->Add((TObject *)graphDeltaVdrift0); | |
5811 | cph2->cd(1); | |
5812 | TH1I *histoErrorVdrift0 = new TH1I("errorvdrift0","",100 ,-0.05,0.05); | |
5813 | histoErrorVdrift0->SetXTitle("#Deltav/v_{sim}"); | |
5814 | histoErrorVdrift0->SetYTitle("counts"); | |
5815 | histoErrorVdrift0->SetLineColor(2); | |
5816 | histoErrorVdrift0->SetLineStyle(2); | |
5817 | histoErrorVdrift0->SetStats(0); | |
5818 | for(Int_t k = 0; k < counter[0]; k++){ | |
5819 | histoErrorVdrift0->Fill(yValuesDeltaPH[k]); | |
5820 | } | |
5821 | legph2->AddEntry(histoErrorVdrift0,"v_{fit PH}","l"); | |
5822 | histoErrorVdrift0->Draw("same"); | |
5823 | listofgraphs->Add((TObject *)histoErrorVdrift0); | |
8ec526a4 | 5824 | } |
9f4780aa | 5825 | cph2->cd(2); |
77566f2a | 5826 | legph3->Draw("same"); |
9f4780aa | 5827 | cph2->cd(1); |
5828 | legph2->Draw("same"); | |
5829 | ||
5830 | ||
5831 | //Write if wanted | |
5832 | if (fWriteCoef[1]){ | |
5833 | TFile *fout = TFile::Open(fWriteNameCoef,"UPDATE"); | |
5834 | // Check if the file could be opened | |
5835 | if (!fout || !fout->IsOpen()) { | |
5836 | AliInfo("No File found!"); | |
5837 | } | |
5838 | ||
5839 | else{ | |
5840 | for(Int_t k = 0; k < listofgraphs->GetEntriesFast(); k++){ | |
5841 | fout->WriteTObject((TObject *) listofgraphs->At(k),((TObject *)listofgraphs->At(k))->GetName(),(Option_t *) "OverWrite"); | |
5842 | } | |
5843 | } | |
5844 | fout->Close(); | |
5845 | } | |
8ec526a4 | 5846 | |
77566f2a | 5847 | } |
8ec526a4 | 5848 | |
5849 | //_____________________________________________________________________________ | |
9f4780aa | 5850 | void AliTRDCalibra::PlotWriteT0() |
77566f2a | 5851 | { |
5852 | // | |
9f4780aa | 5853 | // create the graph errors and write them if wanted |
77566f2a | 5854 | // |
5855 | ||
9f4780aa | 5856 | //TObjArray of the grapherrors and so on |
5857 | TObjArray *listofgraphs = new TObjArray(); | |
5858 | ||
5859 | Int_t nbins = fDect2[1]-fDect1[1]; | |
5860 | ||
5861 | //See the number of fitted for delta: here T0 can be negative, we don't use the sign but the error | |
5862 | //and the grapherrors of the coefficients contained the no fitted with error 0.0 | |
5863 | ||
5864 | //counter | |
5865 | Int_t counter[2]; | |
5866 | counter[0] = 0; | |
5867 | counter[1] = 0; | |
5868 | ||
5869 | Double_t *xValuesFitted = new Double_t[nbins]; | |
5870 | Double_t *xValuesFittedPH = new Double_t[nbins]; | |
5871 | for(Int_t k = 0; k < nbins; k ++){ | |
5872 | xValuesFitted[k] = -1; | |
5873 | xValuesFittedPH[k] = -1; | |
5874 | } | |
5875 | ||
5876 | for(Int_t l = 0; l < nbins; l++){ | |
5877 | if(fCoefT0E[1][l] != 0.0){ | |
5878 | xValuesFitted[counter[1]]=l; | |
5879 | counter[1]++; | |
5880 | } | |
5881 | } | |
5882 | if(fFitPHOn){ | |
5883 | for(Int_t l = 0; l < nbins; l++){ | |
5884 | if(fCoefT0E[0][l] != 0.0){ | |
5885 | xValuesFittedPH[counter[0]]= l; | |
5886 | counter[0]++; | |
5887 | } | |
5888 | } | |
5889 | } | |
5890 | ||
5891 | ||
5892 | //Create the X and Xerror | |
5893 | Double_t *xValues = new Double_t[nbins]; | |
5894 | Double_t *xValuesE = new Double_t[nbins]; | |
5895 | for(Int_t k = 0; k < nbins; k ++){ | |
5896 | xValues[k] = k; | |
5897 | xValuesE[k] = 0.0; | |
5898 | } | |
5899 | ||
5900 | //Create the graph erros and plot them | |
5901 | TGraph *graphT02 = new TGraph(nbins,xValues,fCoefT0[2]); | |
5902 | graphT02->SetName("coeft02"); | |
5903 | graphT02->SetTitle(""); | |
5904 | graphT02->GetXaxis()->SetTitle("Det/Pad groups"); | |
5905 | graphT02->GetYaxis()->SetTitle("T0 [time bins]"); | |
5906 | graphT02->SetLineColor(4); | |
5907 | listofgraphs->Add((TObject *)graphT02); | |
5908 | TGraphErrors *graphT01 = new TGraphErrors(nbins,xValues,fCoefT0[1],xValuesE,fCoefT0E[1]); | |
5909 | graphT01->SetName("coeft01"); | |
5910 | graphT01->SetTitle(""); | |
5911 | graphT01->GetXaxis()->SetTitle("Det/Pad groups"); | |
5912 | graphT01->GetYaxis()->SetTitle("T0 [time bins]"); | |
5913 | graphT01->SetMarkerColor(6); | |
5914 | graphT01->SetLineColor(6); | |
5915 | graphT01->SetMarkerStyle(26); | |
5916 | listofgraphs->Add((TObject *)graphT01); | |
77566f2a | 5917 | TCanvas *ct01 = new TCanvas("ct01","",50,50,600,800); |
5918 | ct01->cd(); | |
5919 | TLegend *legt01 = new TLegend(0.4,0.6,0.89,0.89); | |
9f4780aa | 5920 | legt01->AddEntry(graphT02,"T0 simulated","l"); |
5921 | legt01->AddEntry(graphT01,"T0 slope method","p"); | |
5922 | graphT02->Draw("AL"); | |
5923 | graphT01->Draw("P"); | |
8ec526a4 | 5924 | if (fFitPHOn) { |
9f4780aa | 5925 | TGraphErrors *graphT00 = new TGraphErrors(nbins,xValues,fCoefT0[0],xValuesE,fCoefT0E[0]); |
5926 | graphT00->SetName("coeft00"); | |
5927 | graphT00->GetXaxis()->SetTitle("Det/Pad groups"); | |
5928 | graphT00->GetYaxis()->SetTitle("T0 [time bins]"); | |
5929 | graphT00->SetTitle(""); | |
5930 | graphT00->SetMarkerColor(2); | |
5931 | graphT00->SetLineColor(2); | |
5932 | graphT00->SetMarkerStyle(24); | |
5933 | legt01->AddEntry(graphT00,"T0 fit","p"); | |
5934 | graphT00->Draw("P"); | |
5935 | listofgraphs->Add((TObject *)graphT00); | |
5936 | } | |
77566f2a | 5937 | legt01->Draw("same"); |
77566f2a | 5938 | |
9f4780aa | 5939 | |
5940 | //Create the arrays and the graphs for the delta | |
77566f2a | 5941 | TCanvas *ct02 = new TCanvas("ct02","",50,50,600,800); |
5942 | ct02->Divide(2,1); | |
77566f2a | 5943 | ct02->cd(2); |
9f4780aa | 5944 | Double_t *yValuesDelta = new Double_t[counter[1]]; |
5945 | for(Int_t k = 0; k < counter[1]; k++){ | |
5946 | yValuesDelta[k] = (fCoefT0[1][(Int_t)xValuesFitted[k]]-fCoefT0[2][(Int_t)xValuesFitted[k]]); | |
5947 | } | |
5948 | TGraph *graphDeltaT01 = new TGraph(counter[1],&xValuesFitted[0],yValuesDelta); | |
5949 | graphDeltaT01->SetName("deltat01"); | |
5950 | graphDeltaT01->GetXaxis()->SetTitle("Det/Pad groups"); | |
5951 | graphDeltaT01->GetYaxis()->SetTitle("#Deltat0 [time bins]"); | |
5952 | graphDeltaT01->SetMarkerColor(6); | |
5953 | graphDeltaT01->SetTitle(""); | |
5954 | graphDeltaT01->SetLineColor(6); | |
5955 | graphDeltaT01->SetMarkerStyle(26); | |
5956 | listofgraphs->Add((TObject *)graphDeltaT01); | |
77566f2a | 5957 | TLegend *legt03 = new TLegend(0.4,0.6,0.89,0.89); |
9f4780aa | 5958 | legt03->AddEntry(graphDeltaT01,"T0_{slope method}","p"); |
5959 | graphDeltaT01->Draw("AP"); | |
5960 | ct02->cd(1); | |
5961 | TH1I *histoErrorT01 = new TH1I("errort01","",100 ,-0.05,0.05); | |
5962 | histoErrorT01->SetXTitle("#Deltat0 [time bins]"); | |
5963 | histoErrorT01->SetYTitle("counts"); | |
5964 | histoErrorT01->SetLineColor(6); | |
5965 | histoErrorT01->SetLineStyle(1); | |
5966 | histoErrorT01->SetStats(0); | |
5967 | for(Int_t k = 0; k < counter[1]; k++){ | |
5968 | histoErrorT01->Fill(yValuesDelta[k]); | |
8ec526a4 | 5969 | } |
9f4780aa | 5970 | TLegend *legt02 = new TLegend(0.4,0.6,0.89,0.89); |
5971 | legt02->AddEntry(histoErrorT01,"T0_{slope method}","l"); | |
5972 | histoErrorT01->Draw(); | |
5973 | listofgraphs->Add((TObject *)histoErrorT01); | |
8ec526a4 | 5974 | if (fFitPHOn) { |
9f4780aa | 5975 | ct02->cd(2); |
5976 | Double_t *yValuesDeltaPH = new Double_t[counter[0]]; | |
5977 | for(Int_t k = 0; k < counter[0]; k++){ | |
5978 | yValuesDeltaPH[k] = (fCoefT0[0][(Int_t)xValuesFittedPH[k]]-fCoefT0[2][(Int_t)xValuesFittedPH[k]]); | |
5979 | } | |
5980 | TGraph *graphDeltaT00 = new TGraph(counter[0],&xValuesFittedPH[0],yValuesDeltaPH); | |
5981 | graphDeltaT00->SetName("deltat00"); | |
5982 | graphDeltaT00->GetXaxis()->SetTitle("Det/Pad groups"); | |
5983 | graphDeltaT00->GetYaxis()->SetTitle("#Deltat0 [time bins]"); | |
5984 | graphDeltaT00->SetMarkerColor(2); | |
5985 | graphDeltaT00->SetMarkerStyle(24); | |
5986 | graphDeltaT00->SetLineColor(2); | |
5987 | graphDeltaT00->SetTitle(""); | |
5988 | legt03->AddEntry(graphDeltaT00,"T0_{fit PH}","p"); | |
5989 | graphDeltaT00->Draw("P"); | |
5990 | listofgraphs->Add((TObject *)graphDeltaT00); | |
5991 | ct02->cd(1); | |
5992 | TH1I *histoErrorT00 = new TH1I("errort00","",100 ,-0.05,0.05); | |
5993 | histoErrorT00->SetXTitle("#Deltat0 [time bins]"); | |
5994 | histoErrorT00->SetYTitle("counts"); | |
5995 | histoErrorT00->SetLineColor(2); | |
5996 | histoErrorT00->SetLineStyle(2); | |
5997 | histoErrorT00->SetStats(0); | |
5998 | for(Int_t k = 0; k < counter[0]; k++){ | |
5999 | histoErrorT00->Fill(yValuesDeltaPH[k]); | |
6000 | } | |
6001 | legt02->AddEntry(histoErrorT00,"T0_{fit PH}","l"); | |
6002 | histoErrorT00->Draw("same"); | |
6003 | listofgraphs->Add((TObject *)histoErrorT00); | |
8ec526a4 | 6004 | } |
9f4780aa | 6005 | ct02->cd(2); |
77566f2a | 6006 | legt03->Draw("same"); |
9f4780aa | 6007 | ct02->cd(1); |
6008 | legt02->Draw("same"); | |
6009 | ||
6010 | ||
6011 | //Write if wanted | |
6012 | if (fWriteCoef[1]){ | |
6013 | TFile *fout = TFile::Open(fWriteNameCoef,"UPDATE"); | |
6014 | // Check if the file could be opened | |
6015 | if (!fout || !fout->IsOpen()) { | |
6016 | AliInfo("No File found!"); | |
6017 | } | |
6018 | ||
6019 | else{ | |
6020 | for(Int_t k = 0; k < listofgraphs->GetEntriesFast(); k++){ | |
6021 | fout->WriteTObject((TObject *) listofgraphs->At(k),((TObject *)listofgraphs->At(k))->GetName(),(Option_t *) "OverWrite"); | |
6022 | } | |
6023 | } | |
6024 | fout->Close(); | |
6025 | } | |
8ec526a4 | 6026 | |
77566f2a | 6027 | } |
6028 | ||
8ec526a4 | 6029 | //_____________________________________________________________________________ |
9f4780aa | 6030 | void AliTRDCalibra::PlotWritePRF() |
77566f2a | 6031 | { |
6032 | // | |
9f4780aa | 6033 | // create the graph errors and write them if wanted |
77566f2a | 6034 | // |
6035 | ||
9f4780aa | 6036 | //TObjArray of the grapherrors and so on |
6037 | TObjArray *listofgraphs = new TObjArray(); | |
6038 | ||
6039 | Int_t nbins = fDect2[2]-fDect1[2]; | |
6040 | ||
6041 | //See the number of fitted for delta | |
6042 | ||
6043 | //counter | |
6044 | Int_t counter = 0; | |
6045 | ||
6046 | Double_t *xValuesFitted = new Double_t[nbins]; | |
6047 | for(Int_t k = 0; k < nbins; k ++){ | |
6048 | xValuesFitted[k] = -1; | |
6049 | } | |
6050 | ||
6051 | for(Int_t l = 0; l < nbins; l++){ | |
6052 | if(fCoefPRF[0][l] > 0){ | |
6053 | xValuesFitted[counter]=l; | |
6054 | counter++; | |
6055 | } | |
6056 | } | |
6057 | ||
6058 | ||
6059 | ||
6060 | //Create the X and Xerror | |
6061 | Double_t *xValues = new Double_t[nbins]; | |
6062 | Double_t *xValuesE = new Double_t[nbins]; | |
6063 | for(Int_t k = 0; k < nbins; k ++){ | |
6064 | xValues[k] = k; | |
6065 | xValuesE[k] = 0.0; | |
6066 | } | |
6067 | ||
6068 | //Create the graph erros and plot them | |
6069 | TGraph *graphPRF1 = new TGraph(nbins,xValues,fCoefPRF[1]); | |
6070 | graphPRF1->SetName("coefprf1"); | |
6071 | graphPRF1->SetTitle(""); | |
6072 | graphPRF1->GetXaxis()->SetTitle("Det/Pad groups"); | |
6073 | graphPRF1->GetYaxis()->SetTitle("PRF width [p.u]"); | |
6074 | graphPRF1->SetLineColor(4); | |
6075 | graphPRF1->SetMarkerColor(4); | |
6076 | graphPRF1->SetMarkerStyle(25); | |
6077 | graphPRF1->SetMarkerSize(0.7); | |
6078 | listofgraphs->Add((TObject *)graphPRF1); | |
6079 | TGraphErrors *graphPRF0 = new TGraphErrors(nbins,xValues,fCoefPRF[0],xValuesE,fCoefPRFE); | |
6080 | graphPRF0->SetName("coefprf0"); | |
6081 | graphPRF0->SetTitle(""); | |
6082 | graphPRF0->GetXaxis()->SetTitle("Det/Pad groups"); | |
6083 | graphPRF0->GetYaxis()->SetTitle("PRF Width [p.u]"); | |
6084 | graphPRF0->SetMarkerColor(6); | |
6085 | graphPRF0->SetLineColor(6); | |
6086 | graphPRF0->SetMarkerStyle(26); | |
6087 | listofgraphs->Add((TObject *)graphPRF0); | |
77566f2a | 6088 | TCanvas *cprf1 = new TCanvas("cprf1","",50,50,600,800); |
6089 | cprf1->cd(); | |
6090 | TLegend *legprf1 = new TLegend(0.4,0.6,0.89,0.89); | |
9f4780aa | 6091 | legprf1->AddEntry(graphPRF1,"PRF width simulated","p"); |
6092 | legprf1->AddEntry(graphPRF0,"PRF fit","p"); | |
6093 | graphPRF1->Draw("AP"); | |
6094 | graphPRF0->Draw("P"); | |
77566f2a | 6095 | legprf1->Draw("same"); |
9f4780aa | 6096 | |
77566f2a | 6097 | |
9f4780aa | 6098 | //Create the arrays and the graphs for the delta |
77566f2a | 6099 | TCanvas *cprf2 = new TCanvas("cprf2","",50,50,600,800); |
6100 | cprf2->Divide(2,1); | |
77566f2a | 6101 | cprf2->cd(2); |
9f4780aa | 6102 | Double_t *yValuesDelta = new Double_t[counter]; |
6103 | for(Int_t k = 0; k < counter; k++){ | |
6104 | if(fCoefPRF[1][(Int_t)xValuesFitted[k]] > 0.0){ | |
6105 | yValuesDelta[k] = (fCoefPRF[0][(Int_t)xValuesFitted[k]]-fCoefPRF[1][(Int_t)xValuesFitted[k]])/(fCoefPRF[1][(Int_t)xValuesFitted[k]]); | |
6106 | } | |
6107 | } | |
6108 | TGraph *graphDeltaPRF = new TGraph(counter,&xValuesFitted[0],yValuesDelta); | |
6109 | graphDeltaPRF->SetName("deltaprf"); | |
6110 | graphDeltaPRF->GetXaxis()->SetTitle("Det/Pad groups"); | |
6111 | graphDeltaPRF->GetYaxis()->SetTitle("#Delta#sigma/#sigma_{sim}"); | |
6112 | graphDeltaPRF->SetMarkerColor(6); | |
6113 | graphDeltaPRF->SetTitle(""); | |
6114 | graphDeltaPRF->SetLineColor(6); | |
6115 | graphDeltaPRF->SetMarkerStyle(26); | |
6116 | listofgraphs->Add((TObject *)graphDeltaPRF); | |
77566f2a | 6117 | TLegend *legprf3 = new TLegend(0.4,0.6,0.89,0.89); |
9f4780aa | 6118 | legprf3->AddEntry(graphDeltaPRF,"#sigma_{fit}","p"); |
6119 | graphDeltaPRF->Draw("AP"); | |
6120 | cprf2->cd(1); | |
6121 | TH1I *histoErrorPRF = new TH1I("errorprf1","",100 ,-0.5,0.5); | |
6122 | histoErrorPRF->SetXTitle("#Delta#sigma/#sigma_{sim}"); | |
6123 | histoErrorPRF->SetYTitle("counts"); | |
6124 | histoErrorPRF->SetLineColor(6); | |
6125 | histoErrorPRF->SetLineStyle(1); | |
6126 | histoErrorPRF->SetStats(0); | |
6127 | for(Int_t k = 0; k < counter; k++){ | |
6128 | histoErrorPRF->Fill(yValuesDelta[k]); | |
6129 | } | |
6130 | TLegend *legprf2 = new TLegend(0.4,0.6,0.89,0.89); | |
6131 | legprf2->AddEntry(histoErrorPRF,"#sigma_{fit}","l"); | |
6132 | histoErrorPRF->Draw(); | |
6133 | listofgraphs->Add((TObject *)histoErrorPRF); | |
6134 | cprf2->cd(2); | |
77566f2a | 6135 | legprf3->Draw("same"); |
9f4780aa | 6136 | cprf2->cd(1); |
6137 | legprf2->Draw("same"); | |
6138 | ||
77566f2a | 6139 | |
9f4780aa | 6140 | //Write if wanted |
6141 | if (fWriteCoef[2]){ | |
6142 | TFile *fout = TFile::Open(fWriteNameCoef,"UPDATE"); | |
6143 | // Check if the file could be opened | |
6144 | if (!fout || !fout->IsOpen()) { | |
6145 | AliInfo("No File found!"); | |
6146 | } | |
6147 | ||
6148 | else{ | |
6149 | for(Int_t k = 0; k < listofgraphs->GetEntriesFast(); k++){ | |
6150 | fout->WriteTObject((TObject *) listofgraphs->At(k),((TObject *)listofgraphs->At(k))->GetName(),(Option_t *) "OverWrite"); | |
6151 | } | |
6152 | } | |
6153 | fout->Close(); | |
6154 | } | |
6155 | ||
77566f2a | 6156 | } |
6157 | ||
8ec526a4 | 6158 | // |
6159 | //____________Plot histos DB___________________________________________________ | |
6160 | // | |
6161 | ||
6162 | //_____________________________________________________________________________ | |
77566f2a | 6163 | void AliTRDCalibra::PlotCHDB() |
6164 | { | |
6165 | // | |
6166 | // Plot the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
6167 | // | |
6168 | ||
6169 | TCanvas *cchdb = new TCanvas("cchdb","",50,50,600,800); | |
8ec526a4 | 6170 | if ((fFitChargeBisOn) && (fMeanChargeOn)) { |
77566f2a | 6171 | cchdb->Divide(3,1); |
6172 | cchdb->cd(1); | |
6173 | fCoefChargeDB[0]->Draw("LEGO"); | |
6174 | cchdb->cd(2); | |
6175 | fCoefChargeDB[1]->Draw("LEGO"); | |
6176 | cchdb->cd(3); | |
6177 | fCoefChargeDB[2]->Draw("LEGO"); | |
6178 | } | |
8ec526a4 | 6179 | if ((!fFitChargeBisOn) && (fMeanChargeOn)) { |
77566f2a | 6180 | cchdb->Divide(2,1); |
6181 | cchdb->cd(1); | |
6182 | fCoefChargeDB[0]->Draw("LEGO"); | |
6183 | cchdb->cd(2); | |
6184 | fCoefChargeDB[1]->Draw("LEGO"); | |
6185 | } | |
8ec526a4 | 6186 | else { |
77566f2a | 6187 | cchdb->cd(); |
6188 | fCoefChargeDB[0]->Draw("LEGO"); | |
6189 | } | |
6190 | ||
6191 | } | |
77566f2a | 6192 | |
8ec526a4 | 6193 | //_____________________________________________________________________________ |
77566f2a | 6194 | void AliTRDCalibra::PlotPHDB() |
6195 | { | |
6196 | // | |
6197 | // Plot the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
6198 | // | |
6199 | ||
6200 | TCanvas *cphdb = new TCanvas("cphdb","",50,50,600,800); | |
8ec526a4 | 6201 | if (fFitPHOn) { |
77566f2a | 6202 | cphdb->Divide(2,1); |
6203 | cphdb->cd(1); | |
6204 | fCoefVdriftDB[0]->Draw("LEGO"); | |
6205 | cphdb->cd(2); | |
6206 | fCoefVdriftDB[1]->Draw("LEGO"); | |
6207 | } | |
8ec526a4 | 6208 | else { |
77566f2a | 6209 | cphdb->cd(); |
6210 | fCoefVdriftDB[1]->Draw("LEGO"); | |
6211 | } | |
8ec526a4 | 6212 | |
77566f2a | 6213 | } |
77566f2a | 6214 | |
8ec526a4 | 6215 | //_____________________________________________________________________________ |
77566f2a | 6216 | void AliTRDCalibra::PlotT0DB() |
6217 | { | |
6218 | // | |
6219 | // Plot the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
6220 | // | |
6221 | ||
6222 | TCanvas *ct0db = new TCanvas("ct0db","",50,50,600,800); | |
8ec526a4 | 6223 | if (fFitPHOn ) { |
77566f2a | 6224 | ct0db->Divide(2,1); |
6225 | ct0db->cd(1); | |
6226 | fCoefT0DB[0]->Draw("LEGO"); | |
6227 | ct0db->cd(2); | |
6228 | fCoefT0DB[1]->Draw("LEGO"); | |
6229 | } | |
8ec526a4 | 6230 | else { |
77566f2a | 6231 | ct0db->cd(); |
6232 | fCoefT0DB[1]->Draw("LEGO"); | |
6233 | } | |
8ec526a4 | 6234 | |
77566f2a | 6235 | } |
77566f2a | 6236 | |
8ec526a4 | 6237 | //_____________________________________________________________________________ |
77566f2a | 6238 | void AliTRDCalibra::PlotPRFDB() |
6239 | { | |
6240 | // | |
6241 | // Plot the histos for fDebug = 3 and fDebug = 4 to visualise the detector | |
6242 | // | |
6243 | ||
6244 | TCanvas *cprfdb = new TCanvas("cprfdb","",50,50,600,800); | |
6245 | cprfdb->cd(); | |
6246 | fCoefPRFDB->Draw("LEGO"); | |
8ec526a4 | 6247 | |
77566f2a | 6248 | } |
6249 | ||
8ec526a4 | 6250 | // |
6251 | //____________Write DB Histos__________________________________________________ | |
6252 | // | |
77566f2a | 6253 | |
8ec526a4 | 6254 | //_____________________________________________________________________________ |
77566f2a | 6255 | void AliTRDCalibra::WriteCHDB(TFile *fout) |
6256 | { | |
6257 | // | |
6258 | // If wanted, write the debug histos for fDebug = 3 and fDebug = 4 | |
6259 | // | |
6260 | ||
8ec526a4 | 6261 | fout->WriteTObject(fCoefChargeDB[0],fCoefChargeDB[0]->GetName(),(Option_t *) "OverWrite"); |
6262 | if (fMeanChargeOn) { | |
6263 | fout->WriteTObject(fCoefChargeDB[1],fCoefChargeDB[1]->GetName(),(Option_t *) "OverWrite"); | |
6264 | } | |
6265 | if (fFitChargeBisOn ) { | |
6266 | fout->WriteTObject(fCoefChargeDB[2],fCoefChargeDB[2]->GetName(),(Option_t *) "OverWrite"); | |
6267 | } | |
77566f2a | 6268 | |
6269 | } | |
8ec526a4 | 6270 | |
6271 | //_____________________________________________________________________________ | |
77566f2a | 6272 | void AliTRDCalibra::WritePHDB(TFile *fout) |
6273 | { | |
6274 | // | |
6275 | // If wanted, write the debug histos for fDebug = 3 and fDebug = 4 | |
6276 | // | |
6277 | ||
8ec526a4 | 6278 | if (fFitPHOn) { |
6279 | fout->WriteTObject(fCoefVdriftDB[0],fCoefVdriftDB[0]->GetName(),(Option_t *) "OverWrite"); | |
6280 | } | |
6281 | fout->WriteTObject(fCoefVdriftDB[1],fCoefVdriftDB[1]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6282 | |
6283 | } | |
8ec526a4 | 6284 | |
6285 | //_____________________________________________________________________________ | |
77566f2a | 6286 | void AliTRDCalibra::WriteT0DB(TFile *fout) |
6287 | { | |
6288 | // | |
6289 | // If wanted, write the debug histos for fDebug = 3 and fDebug = 4 | |
6290 | // | |
6291 | ||
8ec526a4 | 6292 | if (fFitPHOn) { |
6293 | fout->WriteTObject(fCoefT0DB[0],fCoefT0DB[0]->GetName(),(Option_t *) "OverWrite"); | |
6294 | } | |
6295 | fout->WriteTObject(fCoefT0DB[1],fCoefT0DB[1]->GetName(),(Option_t *) "OverWrite"); | |
77566f2a | 6296 | |
6297 | } | |
8ec526a4 | 6298 | |
6299 | //_____________________________________________________________________________ | |
77566f2a | 6300 | void AliTRDCalibra::WritePRFDB(TFile *fout) |
6301 | { | |
6302 | // | |
6303 | // If wanted, write the debug histos for fDebug = 3 and fDebug = 4 | |
6304 | // | |
6305 | ||
8ec526a4 | 6306 | fout->WriteTObject(fCoefPRFDB,fCoefPRFDB->GetName(),(Option_t *) "OverWrite"); |
77566f2a | 6307 | |
6308 | } | |
6309 | ||
8ec526a4 | 6310 | // |
6311 | //____________Calcul Coef Mean_________________________________________________ | |
6312 | // | |
77566f2a | 6313 | |
8ec526a4 | 6314 | //_____________________________________________________________________________ |
6315 | Bool_t AliTRDCalibra::CalculT0CoefMean(Int_t dect, Int_t idect) | |
77566f2a | 6316 | { |
6317 | // | |
8ec526a4 | 6318 | // For the detector Dect calcul the mean time 0 |
6319 | // for the calibration group idect from the choosen database | |
77566f2a | 6320 | // |
6321 | ||
8ec526a4 | 6322 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 6323 | if (!cal) { |
6324 | AliInfo("Could not get calibDB Manager"); | |
6325 | return kFALSE; | |
6326 | } | |
6327 | ||
6328 | fT0Coef[2] = 0.0; | |
6329 | ||
8ec526a4 | 6330 | if ((fDebug != 2) && fAccCDB) { |
77566f2a | 6331 | |
8ec526a4 | 6332 | for (Int_t row = fRowMin[1]; row < fRowMax[1]; row++) { |
6333 | for (Int_t col = fColMin[1]; col < fColMax[1]; col++) { | |
6334 | // Groups of pads | |
6335 | if ((fNz[1] > 0) && | |
6336 | (fNrphi[1] > 0)) { | |
6337 | fT0Coef[2] += (Float_t) cal->GetT0(dect,col,row); | |
6338 | } | |
6339 | // Per detectors | |
6340 | else { | |
6341 | fT0Coef[2] += (Float_t) cal->GetT0Average(dect); | |
77566f2a | 6342 | } |
77566f2a | 6343 | } |
6344 | } | |
8ec526a4 | 6345 | |
6346 | fT0Coef[2] = fT0Coef[2] / ((fColMax[1]-fColMin[1])*(fRowMax[1]-fRowMin[1])); | |
6347 | if ((fDebug == 1) || | |
6348 | (fDebug == 4)) { | |
9f4780aa | 6349 | fCoefT0[2][idect] = fT0Coef[2]; |
8ec526a4 | 6350 | } |
6351 | ||
77566f2a | 6352 | } |
8ec526a4 | 6353 | |
77566f2a | 6354 | return kTRUE; |
6355 | ||
6356 | } | |
8ec526a4 | 6357 | |
6358 | //_____________________________________________________________________________ | |
6359 | Bool_t AliTRDCalibra::CalculChargeCoefMean(Int_t dect, Int_t idect, Bool_t vrai) | |
77566f2a | 6360 | { |
6361 | // | |
8ec526a4 | 6362 | // For the detector Dect calcul the mean gain factor |
6363 | // for the calibration group idect from the choosen database | |
77566f2a | 6364 | // |
6365 | ||
77566f2a | 6366 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
6367 | if (!cal) { | |
6368 | AliInfo("Could not get calibDB Manager"); | |
6369 | return kFALSE; | |
6370 | } | |
8ec526a4 | 6371 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); |
77566f2a | 6372 | if (!parCom) { |
6373 | AliInfo("Could not get CommonParam Manager"); | |
6374 | return kFALSE; | |
6375 | } | |
6376 | ||
6377 | fChargeCoef[3] = 0.0; | |
8ec526a4 | 6378 | |
6379 | if (fDebug != 2) { | |
6380 | ||
6381 | for (Int_t row = fRowMin[0]; row < fRowMax[0]; row++) { | |
6382 | for (Int_t col = fColMin[0]; col < fColMax[0]; col++) { | |
6383 | // Groups of pads | |
6384 | if ((fNz[0] > 0) || | |
6385 | (fNrphi[0] > 0)) { | |
6386 | if (fAccCDB) { | |
6387 | fChargeCoef[3] += (Float_t) cal->GetGainFactor(dect,col,row); | |
6388 | } | |
6389 | if (vrai && fAccCDB) { | |
6390 | fScaleFitFactor += (Float_t) cal->GetGainFactor(dect,col,row); | |
6391 | } | |
6392 | if (!fAccCDB) { | |
6393 | fChargeCoef[3] += 1.0; | |
6394 | } | |
6395 | if (vrai && (!fAccCDB)) { | |
6396 | fScaleFitFactor += 1.0; | |
6397 | } | |
77566f2a | 6398 | } |
8ec526a4 | 6399 | // Per detectors |
77566f2a | 6400 | else { |
8ec526a4 | 6401 | if (fAccCDB) { |
6402 | fChargeCoef[3] += (Float_t) cal->GetGainFactorAverage(dect); | |
6403 | } | |
6404 | if (vrai && fAccCDB) { | |
6405 | fScaleFitFactor += ((Float_t) cal->GetGainFactorAverage(dect)); | |
6406 | } | |
6407 | if (!fAccCDB) { | |
6408 | fChargeCoef[3] += 1.0; | |
6409 | } | |
6410 | if (vrai && (!fAccCDB)) { | |
6411 | fScaleFitFactor += 1.0; | |
6412 | } | |
77566f2a | 6413 | } |
6414 | } | |
6415 | } | |
8ec526a4 | 6416 | |
6417 | fChargeCoef[3] = fChargeCoef[3] / ((fColMax[0]-fColMin[0])*(fRowMax[0]-fRowMin[0])); | |
6418 | if ((fDebug == 1) || | |
6419 | (fDebug == 4)) { | |
9f4780aa | 6420 | fCoefCharge[3][idect]=fChargeCoef[3]; |
8ec526a4 | 6421 | } |
6422 | ||
77566f2a | 6423 | } |
77566f2a | 6424 | |
8ec526a4 | 6425 | return kTRUE; |
77566f2a | 6426 | |
6427 | } | |
8ec526a4 | 6428 | |
6429 | //_____________________________________________________________________________ | |
6430 | Bool_t AliTRDCalibra::CalculPRFCoefMean(Int_t dect, Int_t idect) | |
77566f2a | 6431 | { |
6432 | // | |
8ec526a4 | 6433 | // For the detector Dect calcul the mean sigma of pad response |
6434 | // function for the calibration group idect from the choosen database | |
77566f2a | 6435 | // |
6436 | ||
77566f2a | 6437 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
6438 | if (!cal) { | |
6439 | AliInfo("Could not get calibDB Manager"); | |
6440 | return kFALSE; | |
6441 | } | |
6442 | ||
8ec526a4 | 6443 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); |
77566f2a | 6444 | if (!parCom) { |
6445 | AliInfo("Could not get CommonParam Manager"); | |
6446 | return kFALSE; | |
6447 | } | |
6448 | ||
77566f2a | 6449 | fPRFCoef[1] = 0.0; |
6450 | Int_t cot = 0; | |
8ec526a4 | 6451 | |
6452 | if (fDebug != 2) { | |
77566f2a | 6453 | |
8ec526a4 | 6454 | for (Int_t row = fRowMin[2]; row < fRowMax[2]; row++) { |
6455 | for (Int_t col = fColMin[2]; col < fColMax[2]; col++) { | |
6456 | if ((parCom->GetColMax(GetPlane(dect)) != (col+1)) && (col != 0)) { | |
77566f2a | 6457 | cot++; |
8ec526a4 | 6458 | if (fAccCDB) { |
6459 | fPRFCoef[1] += (Float_t) cal->GetPRFWidth(dect,col,row); | |
6460 | } | |
6461 | if (!fAccCDB) { | |
6462 | fPRFCoef[1] += GetPRFDefault(GetPlane(dect)); | |
6463 | } | |
77566f2a | 6464 | } |
6465 | } | |
6466 | } | |
8ec526a4 | 6467 | |
6468 | if (cot > 0) { | |
77566f2a | 6469 | fPRFCoef[1] = fPRFCoef[1]/cot; |
8ec526a4 | 6470 | if ((fDebug == 1) || |
6471 | (fDebug == 4)) { | |
9f4780aa | 6472 | fCoefPRF[1][idect] = fPRFCoef[1]; |
8ec526a4 | 6473 | } |
77566f2a | 6474 | } |
8ec526a4 | 6475 | if (cot <= 0) { |
6476 | if ((fDebug == 1) || | |
6477 | (fDebug == 4)) { | |
6478 | if (fAccCDB) { | |
9f4780aa | 6479 | fCoefPRF[1][idect] = cal->GetPRFWidth(dect,fColMin[2],fRowMin[2]); |
8ec526a4 | 6480 | } |
6481 | if (!fAccCDB) { | |
9f4780aa | 6482 | fCoefPRF[1][idect] = GetPRFDefault(GetPlane(dect)); |
8ec526a4 | 6483 | } |
6484 | } | |
77566f2a | 6485 | } |
8ec526a4 | 6486 | |
77566f2a | 6487 | } |
8ec526a4 | 6488 | |
77566f2a | 6489 | return kTRUE; |
6490 | ||
6491 | } | |
8ec526a4 | 6492 | |
6493 | //_____________________________________________________________________________ | |
6494 | Bool_t AliTRDCalibra::CalculVdriftCoefMean(Int_t dect, Int_t idect) | |
77566f2a | 6495 | { |
6496 | // | |
8ec526a4 | 6497 | // For the detector dect calcul the mean drift velocity for the |
6498 | // calibration group idect from the choosen database | |
77566f2a | 6499 | // |
6500 | ||
8ec526a4 | 6501 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
77566f2a | 6502 | if (!cal) { |
6503 | AliInfo("Could not get calibDB Manager"); | |
6504 | return kFALSE; | |
6505 | } | |
6506 | ||
77566f2a | 6507 | fVdriftCoef[2] = 0.0; |
6508 | ||
8ec526a4 | 6509 | if (fDebug != 2) { |
6510 | for (Int_t row = fRowMin[1]; row < fRowMax[1]; row++) { | |
6511 | for (Int_t col = fColMin[1]; col < fColMax[1]; col++) { | |
6512 | // Groups of pads | |
6513 | if ((fNz[1] > 0) || | |
6514 | (fNrphi[1] > 0)) { | |
6515 | if (fAccCDB) { | |
6516 | fVdriftCoef[2] += (Float_t) cal->GetVdrift(dect,col,row); | |
6517 | } | |
6518 | if (!fAccCDB) { | |
6519 | fVdriftCoef[2] += 1.5; | |
6520 | } | |
6521 | } | |
6522 | // Per detectors | |
6523 | else { | |
6524 | if (fAccCDB) { | |
6525 | fVdriftCoef[2] += (Float_t) cal->GetVdriftAverage(dect); | |
6526 | } | |
6527 | if (!fAccCDB) { | |
6528 | fVdriftCoef[2] += 1.5; | |
6529 | } | |
77566f2a | 6530 | } |
77566f2a | 6531 | } |
6532 | } | |
8ec526a4 | 6533 | fVdriftCoef[2] = fVdriftCoef[2] / ((fColMax[1]-fColMin[1])*(fRowMax[1]-fRowMin[1])); |
6534 | if ((fDebug == 1) || | |
6535 | (fDebug == 4)) { | |
9f4780aa | 6536 | fCoefVdrift[2][idect] = fVdriftCoef[2]; |
8ec526a4 | 6537 | } |
77566f2a | 6538 | } |
8ec526a4 | 6539 | |
77566f2a | 6540 | return kTRUE; |
6541 | ||
6542 | } | |
6543 | ||
8ec526a4 | 6544 | //_____________________________________________________________________________ |
6545 | Float_t AliTRDCalibra::GetPRFDefault(Int_t plane) const | |
6546 | { | |
6547 | // | |
6548 | // Default width of the PRF if there is no database as reference | |
6549 | // | |
6550 | ||
6551 | if (plane == 0) { | |
6552 | return 0.515; | |
6553 | } | |
6554 | if (plane == 1) { | |
6555 | return 0.502; | |
6556 | } | |
6557 | if (plane == 2) { | |
6558 | return 0.491; | |
6559 | } | |
6560 | if (plane == 3) { | |
6561 | return 0.481; | |
6562 | } | |
6563 | if (plane == 4) { | |
6564 | return 0.471; | |
6565 | } | |
6566 | if (plane == 5) { | |
6567 | return 0.463; | |
6568 | } | |
6569 | else { | |
6570 | return 0.0; | |
6571 | } | |
6572 | ||
6573 | } | |
6574 | ||
6575 | // | |
6576 | //____________Pad group calibration mode_______________________________________ | |
6577 | // | |
6578 | ||
6579 | //_____________________________________________________________________________ | |
77566f2a | 6580 | void AliTRDCalibra::ReconstructionRowPadGroup(Int_t idect, Int_t i) |
6581 | { | |
6582 | // | |
8ec526a4 | 6583 | // For the calibration group idect in a detector calculate the |
6584 | // first and last row pad and col pad. | |
77566f2a | 6585 | // The pads in the interval will have the same calibrated coefficients |
6586 | // | |
6587 | ||
77566f2a | 6588 | Int_t posc = -1; |
6589 | Int_t posr = -1; | |
8ec526a4 | 6590 | fRowMin[i] = -1; |
6591 | fRowMax[i] = -1; | |
6592 | fColMin[i] = -1; | |
6593 | fColMax[i] = -1; | |
77566f2a | 6594 | |
8ec526a4 | 6595 | if (fNfragZ[i] != 0) { |
6596 | posc = (Int_t) idect / fNfragZ[i]; | |
6597 | } | |
6598 | if (fNfragRphi[i] != 0) { | |
6599 | posr = (Int_t) idect % fNfragZ[i]; | |
6600 | } | |
6601 | fRowMin[i] = posr * fNnZ[i]; | |
6602 | fRowMax[i] = (posr+1) * fNnZ[i]; | |
6603 | fColMin[i] = posc * fNnRphi[i]; | |
6604 | fColMax[i] = (posc+1) * fNnRphi[i]; | |
6605 | ||
77566f2a | 6606 | } |
6607 | ||
6608 | //_____________________________________________________________________________ | |
6609 | void AliTRDCalibra::CalculXBins(Int_t idect, Int_t i) | |
6610 | { | |
6611 | // | |
6612 | // For the detector idect calcul the first Xbins | |
6613 | // | |
6614 | ||
77566f2a | 6615 | fXbins[i] = 0; |
8ec526a4 | 6616 | if (fDebug == 4) { |
77566f2a | 6617 | AliInfo(Form("detector: %d", idect)); |
6618 | } | |
6619 | ||
8ec526a4 | 6620 | // In which sector? |
77566f2a | 6621 | Int_t sector = GetSector(idect); |
8ec526a4 | 6622 | fXbins[i] += sector*(6*fDetChamb2[i]+6*4*fDetChamb0[i]); |
77566f2a | 6623 | |
8ec526a4 | 6624 | // In which chamber? |
77566f2a | 6625 | Int_t chamber = GetChamber(idect); |
8ec526a4 | 6626 | Int_t kc = 0; |
6627 | while (kc < chamber) { | |
6628 | if (kc == 2) { | |
6629 | fXbins[i] += 6 * fDetChamb2[i]; | |
6630 | } | |
6631 | else { | |
6632 | fXbins[i] += 6 * fDetChamb0[i]; | |
6633 | } | |
77566f2a | 6634 | kc ++; |
6635 | } | |
6636 | ||
8ec526a4 | 6637 | // In which plane? |
77566f2a | 6638 | Int_t plane = GetPlane(idect); |
8ec526a4 | 6639 | if (chamber == 2) { |
6640 | fXbins[i] += plane*fDetChamb2[i]; | |
6641 | } | |
6642 | else { | |
6643 | fXbins[i] += plane*fDetChamb0[i]; | |
6644 | } | |
77566f2a | 6645 | |
6646 | } | |
8ec526a4 | 6647 | |
77566f2a | 6648 | //_____________________________________________________________________________ |
8ec526a4 | 6649 | Int_t AliTRDCalibra::SearchInVector(Int_t group, Int_t i) const |
77566f2a | 6650 | { |
6651 | // | |
8ec526a4 | 6652 | // Search if the calibration group "group" has already been |
6653 | // initialised by a previous track in the vector | |
77566f2a | 6654 | // |
6655 | ||
8ec526a4 | 6656 | if (i == 0) { |
6657 | for (Int_t k = 0; k < (Int_t) fPlaCH->GetEntriesFast(); k++) { | |
6658 | if (((AliTRDPlace *) fPlaCH->At(k))->GetPlace() == group) { | |
6659 | return k; | |
6660 | } | |
77566f2a | 6661 | } |
6662 | return -1; | |
6663 | } | |
6664 | ||
8ec526a4 | 6665 | if (i == 1) { |
6666 | for (Int_t k = 0; k < (Int_t) fPlaPH->GetEntriesFast(); k++) { | |
6667 | if (((AliTRDPlace *) fPlaPH->At(k))->GetPlace() == group) { | |
6668 | return k; | |
6669 | } | |
77566f2a | 6670 | } |
6671 | return -1; | |
6672 | } | |
6673 | ||
8ec526a4 | 6674 | if (i == 2) { |
6675 | for (Int_t k = 0; k < (Int_t) fPlaPRF->GetEntriesFast(); k++) { | |
6676 | if (((AliTRDPlace *) fPlaPRF->At(k))->GetPlace() == group) { | |
6677 | return k; | |
6678 | } | |
77566f2a | 6679 | } |
6680 | return -1; | |
6681 | } | |
8ec526a4 | 6682 | |
77566f2a | 6683 | return -1; |
8ec526a4 | 6684 | |
77566f2a | 6685 | } |
8ec526a4 | 6686 | |
77566f2a | 6687 | //_____________________________________________________________________________ |
8ec526a4 | 6688 | Int_t AliTRDCalibra::SearchInTreeVector(TObjArray *vectorplace, Int_t group) const |
77566f2a | 6689 | { |
6690 | // | |
6691 | // Search if the calibration group "group" is present in the tree | |
6692 | // | |
6693 | ||
8ec526a4 | 6694 | for (Int_t k = 0; k < (Int_t) vectorplace->GetEntriesFast(); k++) { |
6695 | if (((AliTRDPlace *) vectorplace->At(k))->GetPlace() == group) { | |
6696 | return k; | |
6697 | } | |
77566f2a | 6698 | } |
8ec526a4 | 6699 | |
77566f2a | 6700 | return -1; |
6701 | ||
6702 | } | |
8ec526a4 | 6703 | |
77566f2a | 6704 | //_____________________________________________________________________________ |
8ec526a4 | 6705 | Int_t AliTRDCalibra::SearchBin(Float_t value, Int_t i) const |
77566f2a | 6706 | { |
6707 | // | |
6708 | // Search the bin | |
6709 | // | |
6710 | ||
8ec526a4 | 6711 | Int_t reponse = 0; |
6712 | Int_t fbinmin = 0; | |
6713 | Int_t fbinmax = (Int_t) value; | |
77566f2a | 6714 | Int_t fNumberOfBin = -1; |
6715 | ||
8ec526a4 | 6716 | // Charge |
6717 | if (i == 0) { | |
6718 | fbinmax = 300; | |
6719 | fbinmin = 0; | |
77566f2a | 6720 | fNumberOfBin = fNumberBinCharge; |
6721 | } | |
6722 | ||
8ec526a4 | 6723 | // PRF |
6724 | if (i == 2) { | |
6725 | fbinmax = 1; | |
6726 | fbinmin = -1; | |
77566f2a | 6727 | fNumberOfBin = fNumberBinPRF; |
6728 | } | |
6729 | ||
8ec526a4 | 6730 | // Return -1 if out |
6731 | if ((value >= fbinmax) || | |
6732 | (value < fbinmin)) { | |
6733 | return -1; | |
6734 | } | |
6735 | // Sinon | |
6736 | else { | |
6737 | reponse = (Int_t) ((fNumberOfBin*(value-fbinmin)) / (fbinmax-fbinmin)); | |
77566f2a | 6738 | } |
6739 | ||
6740 | return reponse; | |
8ec526a4 | 6741 | |
77566f2a | 6742 | } |
8ec526a4 | 6743 | |
77566f2a | 6744 | //_____________________________________________________________________________ |
6745 | Bool_t AliTRDCalibra::UpdateVectorCH(Int_t group, Float_t value) | |
6746 | { | |
6747 | // | |
8ec526a4 | 6748 | // Fill the vector if a new calibration group "group" or update the |
6749 | // values of the calibration group "group" if already here | |
77566f2a | 6750 | // |
6751 | ||
8ec526a4 | 6752 | // Search bin |
77566f2a | 6753 | Int_t bin = SearchBin(value,0); |
8ec526a4 | 6754 | // Out |
6755 | if ((bin < 0) || (bin >= fNumberBinCharge)) { | |
6756 | return kFALSE; | |
77566f2a | 6757 | } |
8ec526a4 | 6758 | |
6759 | // Search place | |
6760 | Int_t place = SearchInVector(group,0); | |
6761 | ||
6762 | // New group | |
6763 | if (place == -1) { | |
6764 | AliTRDPlace *placegroup = new AliTRDPlace(); | |
6765 | placegroup->SetPlace(group); | |
6766 | fPlaCH->Add((TObject *) placegroup); | |
6767 | // Variable | |
6768 | AliTRDCTInfo *fCHInfo = new AliTRDCTInfo(); | |
6769 | UShort_t *entries = new UShort_t[fNumberBinCharge]; | |
6770 | // Initialise first | |
6771 | for(Int_t k = 0; k < fNumberBinCharge; k++) { | |
6772 | entries[k] = 0; | |
6773 | } | |
6774 | // Add the value | |
6775 | entries[bin]= 1; | |
6776 | // Set | |
6777 | fCHInfo->SetEntries(entries); | |
6778 | // Set in the vector | |
6779 | fVectorCH->Add((TObject *) fCHInfo); | |
6780 | } | |
6781 | // Group already exits | |
6782 | else { | |
6783 | // Variable | |
6784 | AliTRDCTInfo *fCHInfo = new AliTRDCTInfo(); | |
6785 | // Retrieve | |
6786 | fCHInfo = ((AliTRDCTInfo *) fVectorCH->At(place)); | |
6787 | UShort_t *entries = fCHInfo->GetEntries(); | |
6788 | // Add | |
6789 | entries[bin]++; | |
6790 | // Set | |
6791 | fCHInfo->SetEntries(entries); | |
6792 | // Update the vector | |
6793 | fVectorCH->AddAt((TObject *) fCHInfo,place); | |
77566f2a | 6794 | } |
6795 | ||
6796 | return kTRUE; | |
8ec526a4 | 6797 | |
77566f2a | 6798 | } |
6799 | ||
6800 | //_____________________________________________________________________________ | |
6801 | Bool_t AliTRDCalibra::UpdateVectorPRF(Int_t group, Float_t x, Float_t y) | |
6802 | { | |
6803 | // | |
8ec526a4 | 6804 | // Fill the vector if a new calibration group "group" or update the |
6805 | // values of the calibration group "group" if already here | |
77566f2a | 6806 | // |
6807 | ||
8ec526a4 | 6808 | // Search bin |
77566f2a | 6809 | Int_t bin = SearchBin(x,2); |
8ec526a4 | 6810 | // Out |
6811 | if ((bin < 0) || (bin >= fNumberBinPRF)) { | |
6812 | return kFALSE; | |
6813 | } | |
6814 | ||
6815 | // Search place | |
77566f2a | 6816 | Int_t place = SearchInVector(group,2); |
8ec526a4 | 6817 | |
6818 | // New group | |
6819 | if (place == -1) { | |
6820 | ||
6821 | AliTRDPlace *placegroup = new AliTRDPlace(); | |
6822 | placegroup->SetPlace(group); | |
6823 | fPlaPRF->Add((TObject *) placegroup); | |
6824 | AliTRDPInfo *fPRFInfo = new AliTRDPInfo(); | |
6825 | ||
6826 | Float_t *sum = new Float_t[fNumberBinPRF]; | |
6827 | Float_t *sumsquare = new Float_t[fNumberBinPRF]; | |
6828 | UShort_t *entries = new UShort_t[fNumberBinPRF]; | |
6829 | ||
6830 | // Initialise first | |
6831 | for (Int_t k = 0; k < fNumberBinPRF; k++) { | |
6832 | sum[k] = 0.0; | |
6833 | sumsquare[k] = 0.0; | |
6834 | entries[k] = 0; | |
6835 | } | |
6836 | ||
6837 | // Add the value | |
6838 | sum[bin] += y; | |
6839 | sumsquare[bin] += y*y; | |
6840 | entries[bin]++; | |
6841 | ||
6842 | // Set | |
6843 | fPRFInfo->SetSum(sum); | |
6844 | fPRFInfo->SetSumSquare(sumsquare); | |
6845 | fPRFInfo->SetEntries(entries); | |
6846 | ||
6847 | // Set in the vector | |
6848 | fVectorPRF->Add((TObject *) fPRFInfo); | |
77566f2a | 6849 | |
6850 | } | |
8ec526a4 | 6851 | // Group already exits |
6852 | else { | |
6853 | ||
6854 | AliTRDPInfo *fPRFInfo = new AliTRDPInfo(); | |
6855 | // Retrieve | |
6856 | fPRFInfo = (AliTRDPInfo *) fVectorPRF->At(place); | |
6857 | ||
6858 | Float_t *sum = fPRFInfo->GetSum(); | |
6859 | Float_t *sumsquare = fPRFInfo->GetSumSquare(); | |
6860 | UShort_t *entries = fPRFInfo->GetEntries(); | |
6861 | ||
6862 | // Add | |
6863 | Double_t calcul = (((Double_t) fPRFInfo->GetEntries()[bin]) | |
6864 | * ((Double_t) fPRFInfo->GetSum()[bin]) + (Double_t) y) | |
6865 | / (((Double_t) fPRFInfo->GetEntries()[bin]) + 1); | |
6866 | sum[bin] = (Float_t) calcul; | |
6867 | Double_t calculsquare = (((Double_t) fPRFInfo->GetSumSquare()[bin]) | |
6868 | * ((Double_t) fPRFInfo->GetEntries()[bin]) + ((Double_t) y)*((Double_t) y)) | |
6869 | / (((Double_t) fPRFInfo->GetEntries()[bin]) + 1); | |
6870 | sumsquare[bin] = (Float_t) calculsquare; | |
6871 | entries[bin]++; | |
6872 | ||
6873 | // Set | |
6874 | fPRFInfo->SetSum(sum); | |
6875 | fPRFInfo->SetSumSquare(sumsquare); | |
6876 | fPRFInfo->SetEntries(entries); | |
6877 | ||
6878 | // Update the vector | |
6879 | fVectorPRF->AddAt((TObject *) fPRFInfo,place); | |
77566f2a | 6880 | |
6881 | } | |
6882 | ||
6883 | return kTRUE; | |
8ec526a4 | 6884 | |
77566f2a | 6885 | } |
6886 | ||
6887 | //_____________________________________________________________________________ | |
6888 | Bool_t AliTRDCalibra::UpdateVectorPH(Int_t group, Int_t time, Float_t value) | |
6889 | { | |
6890 | // | |
8ec526a4 | 6891 | // Fill the vector if a new calibration group "group" or update |
6892 | // the values of the calibration group "group" if already here | |
77566f2a | 6893 | // |
6894 | ||
8ec526a4 | 6895 | // Search bin |
77566f2a | 6896 | Int_t bin = time; |
8ec526a4 | 6897 | // Out |
6898 | if ((bin < 0) || | |
6899 | (bin >= fTimeMax)) { | |
6900 | return kFALSE; | |
6901 | } | |
6902 | ||
6903 | // Search place | |
77566f2a | 6904 | Int_t place = SearchInVector(group,1); |
8ec526a4 | 6905 | |
6906 | // New group | |
77566f2a | 6907 | if(place == -1){ |
8ec526a4 | 6908 | |
6909 | AliTRDPlace *placegroup = new AliTRDPlace(); | |
6910 | placegroup->SetPlace(group); | |
6911 | fPlaPH->Add((TObject *) placegroup); | |
6912 | AliTRDPInfo *fPHInfo = new AliTRDPInfo(); | |
6913 | ||
6914 | Float_t *sum = new Float_t[fTimeMax]; | |
6915 | Float_t *sumsquare = new Float_t[fTimeMax]; | |
6916 | UShort_t *entries = new UShort_t[fTimeMax]; | |
6917 | ||
6918 | // Initialise first | |
6919 | for (Int_t k = 0; k < fTimeMax; k++) { | |
6920 | sum[k] = 0.0; | |
6921 | sumsquare[k] = 0.0; | |
6922 | entries[k] = 0; | |
6923 | } | |
6924 | ||
6925 | // Add the value | |
6926 | sum[bin] += value; | |
6927 | sumsquare[bin] += value*value; | |
6928 | entries[bin]++; | |
6929 | ||
6930 | // Set | |
6931 | fPHInfo->SetSum(sum); | |
6932 | fPHInfo->SetSumSquare(sumsquare); | |
6933 | fPHInfo->SetEntries(entries); | |
6934 | ||
6935 | // Set in the vector | |
6936 | fVectorPH->Add((TObject *) fPHInfo); | |
6937 | ||
77566f2a | 6938 | } |
8ec526a4 | 6939 | // Group already exits |
6940 | else { | |
6941 | ||
6942 | AliTRDPInfo *fPHInfo = new AliTRDPInfo(); | |
6943 | // Retrieve | |
6944 | fPHInfo = (AliTRDPInfo *) fVectorPH->At(place); | |
6945 | ||
6946 | Float_t *sum = fPHInfo->GetSum(); | |
6947 | Float_t *sumsquare = fPHInfo->GetSumSquare(); | |
6948 | UShort_t *entries = fPHInfo->GetEntries(); | |
6949 | ||
6950 | // Add | |
6951 | Double_t calcul = (((Double_t) fPHInfo->GetEntries()[bin]) | |
6952 | * ((Double_t) fPHInfo->GetSum()[bin]) + (Double_t) value) | |
6953 | / (((Double_t) fPHInfo->GetEntries()[bin]) + 1); | |
6954 | sum[bin] = (Float_t) calcul; | |
6955 | Double_t calculsquare = ((((Double_t) fPHInfo->GetSumSquare()[bin]) | |
6956 | * ((Double_t) fPHInfo->GetEntries()[bin])) | |
6957 | + (((Double_t) value) * ((Double_t)value))) | |
6958 | / (((Double_t) fPHInfo->GetEntries()[bin]) + 1); | |
6959 | sumsquare[bin] = (Float_t) calculsquare; | |
6960 | entries[bin]++; | |
6961 | ||
6962 | // Set | |
6963 | fPHInfo->SetSum(sum); | |
6964 | fPHInfo->SetSumSquare(sumsquare); | |
6965 | fPHInfo->SetEntries(entries); | |
6966 | ||
6967 | // Update the vector | |
6968 | fVectorPH->AddAt((TObject *) fPHInfo,place); | |
6969 | ||
77566f2a | 6970 | } |
6971 | ||
6972 | return kTRUE; | |
6973 | ||
6974 | } | |
6975 | ||
6976 | //_____________________________________________________________________________ | |
8ec526a4 | 6977 | TGraphErrors *AliTRDCalibra::ConvertVectorPHisto(AliTRDPInfo *pInfo |
6978 | , const Char_t *name) const | |
77566f2a | 6979 | { |
6980 | // | |
8ec526a4 | 6981 | // Convert the PInfo in a 1D grapherror, name must contains "PRF" |
6982 | // if PRF calibration and not "PRF" for Vdrift calibration | |
77566f2a | 6983 | // |
6984 | ||
6985 | TGraphErrors *histo; | |
8ec526a4 | 6986 | const Char_t *pattern1 = "PRF"; |
77566f2a | 6987 | |
8ec526a4 | 6988 | // Axis |
77566f2a | 6989 | Double_t *x; |
6990 | Double_t *y; | |
6991 | Double_t *ex; | |
6992 | Double_t *ey; | |
6993 | Double_t step = 0.0; | |
8ec526a4 | 6994 | Double_t min = 0.0; |
77566f2a | 6995 | |
8ec526a4 | 6996 | // Ntimes |
6997 | Int_t ntimes = 0; | |
6998 | if (strstr(name,pattern1)) { | |
6999 | ntimes = fNumberBinPRF; | |
7000 | } | |
7001 | else { | |
7002 | ntimes = fTimeMax; | |
7003 | } | |
7004 | x = new Double_t[ntimes]; // Xaxis | |
7005 | y = new Double_t[ntimes]; // Mean | |
7006 | ex = new Double_t[ntimes]; // Nentries | |
7007 | ey = new Double_t[ntimes]; // Sum of square/nentries | |
77566f2a | 7008 | |
8ec526a4 | 7009 | // Init histo |
7010 | if (!strstr(name,pattern1)) { | |
7011 | step = 1.0 / fSf; | |
7012 | min = 0.0; | |
77566f2a | 7013 | } |
7014 | else { | |
8ec526a4 | 7015 | step = (1.0 - (-1.0)) / fNumberBinPRF; |
7016 | min = -1.0 + step / 2.0; | |
77566f2a | 7017 | } |
7018 | ||
8ec526a4 | 7019 | // Fill histo |
7020 | for (Int_t k = 0; k < ntimes; k++) { | |
7021 | x[k] = min + k*step; | |
7022 | y[k] = 0.0; | |
77566f2a | 7023 | ex[k] = 0.0; |
7024 | ey[k] = 0.0; | |
8ec526a4 | 7025 | // Fill only if there is more than 0 something |
7026 | if (pInfo->GetEntries()[k] > 0) { | |
7027 | ex[k] = pInfo->GetEntries()[k]; | |
7028 | y[k] = pInfo->GetSum()[k]; | |
7029 | ey[k] = pInfo->GetSumSquare()[k]; | |
77566f2a | 7030 | } |
77566f2a | 7031 | } |
7032 | ||
8ec526a4 | 7033 | // Define the TGraphErrors |
7034 | histo = new TGraphErrors(ntimes,x,y,ex,ey); | |
77566f2a | 7035 | histo->SetTitle(name); |
7036 | return histo; | |
7037 | ||
77566f2a | 7038 | } |
7039 | ||
77566f2a | 7040 | //_____________________________________________________________________________ |
8ec526a4 | 7041 | TH1F *AliTRDCalibra::ConvertVectorCTHisto(AliTRDCTInfo *cTInfo |
7042 | , const Char_t * name) const | |
77566f2a | 7043 | { |
7044 | // | |
7045 | // Convert the CTInfo in a 1D histo | |
7046 | // | |
7047 | ||
7048 | TH1F *histo; | |
7049 | ||
8ec526a4 | 7050 | Int_t ntimes = fNumberBinCharge; |
7051 | UShort_t *entries = cTInfo->GetEntries(); | |
77566f2a | 7052 | |
8ec526a4 | 7053 | // Init histo |
77566f2a | 7054 | histo = new TH1F(name,name,fNumberBinCharge,0,300); |
7055 | histo->Sumw2(); | |
8ec526a4 | 7056 | // Fill histo |
7057 | for (Int_t k = 0; k < ntimes; k++) { | |
7058 | histo->SetBinContent(k+1,entries[k]); | |
7059 | histo->SetBinError(k+1,TMath::Sqrt(TMath::Abs(entries[k]))); | |
77566f2a | 7060 | } |
8ec526a4 | 7061 | |
77566f2a | 7062 | return histo; |
7063 | ||
77566f2a | 7064 | } |
8ec526a4 | 7065 | |
77566f2a | 7066 | //_____________________________________________________________________________ |
8ec526a4 | 7067 | TTree *AliTRDCalibra::ConvertVectorCTTreeHisto(TObjArray *vVectorCT |
7068 | , TObjArray *pPlaCT | |
7069 | , const Char_t *name | |
7070 | , const Char_t *nametitle) const | |
77566f2a | 7071 | { |
7072 | // | |
8ec526a4 | 7073 | // Convert the vector in a tree with two branchs: the group number |
7074 | // and the TH1F histo reconstructed from the vector | |
77566f2a | 7075 | // |
7076 | ||
8ec526a4 | 7077 | // Size of the things |
7078 | Int_t ntotal = (Int_t) pPlaCT->GetEntriesFast(); | |
7079 | if (ntotal == 0) { | |
77566f2a | 7080 | AliInfo("nothing to write!"); |
8ec526a4 | 7081 | TTree *treeCT = new TTree(name,nametitle); |
7082 | return treeCT; | |
77566f2a | 7083 | } |
77566f2a | 7084 | |
8ec526a4 | 7085 | // Variable of the tree |
7086 | Int_t groupnumber = -1; // Group calibration | |
7087 | TH1F *histo = 0x0; | |
7088 | TObjArray vectorCT = *vVectorCT; | |
7089 | TObjArray plaCT = *pPlaCT; | |
77566f2a | 7090 | |
8ec526a4 | 7091 | // Init the tree |
7092 | TTree *treeCT = new TTree(name,nametitle); | |
7093 | treeCT->Branch("groupnumber",&groupnumber,"groupnumber/I"); | |
7094 | treeCT->Branch("histo","TH1F",&histo,32000,0); | |
7095 | ||
7096 | // Fill | |
77566f2a | 7097 | Int_t k = 0; |
8ec526a4 | 7098 | while (k < ntotal) { |
77566f2a | 7099 | TString nome(name); |
8ec526a4 | 7100 | groupnumber = ((AliTRDPlace *) plaCT.At(0))->GetPlace(); |
7101 | nome += groupnumber; | |
7102 | histo = ConvertVectorCTHisto(((AliTRDCTInfo *) vectorCT.At(0)),nome); | |
7103 | treeCT->Fill(); | |
7104 | vectorCT.RemoveAt(0); | |
7105 | vectorCT.Compress(); | |
7106 | plaCT.RemoveAt(0); | |
7107 | plaCT.Compress(); | |
77566f2a | 7108 | k++; |
77566f2a | 7109 | } |
7110 | ||
8ec526a4 | 7111 | return treeCT; |
77566f2a | 7112 | |
7113 | } | |
7114 | ||
7115 | //_____________________________________________________________________________ | |
8ec526a4 | 7116 | TTree *AliTRDCalibra::ConvertVectorPTreeHisto(TObjArray *vVectorP |
7117 | , TObjArray *pPlaP | |
7118 | , const Char_t *name | |
7119 | , const Char_t *nametitle) const | |
77566f2a | 7120 | { |
7121 | // | |
8ec526a4 | 7122 | // Convert the vector in a tree with two branchs: the group number |
7123 | // and the TGraphErrors histo reconstructed from the vector. | |
7124 | // The name must contain "PRF" for PRF calibration and not "PRF" | |
7125 | // for Vdrift calibration | |
77566f2a | 7126 | // |
7127 | ||
8ec526a4 | 7128 | // Size of the things |
7129 | Int_t ntotal = (Int_t) pPlaP->GetEntriesFast(); | |
7130 | if (ntotal == 0) { | |
77566f2a | 7131 | AliInfo("nothing to write!"); |
8ec526a4 | 7132 | TTree *treeP = new TTree(name,nametitle); |
7133 | return treeP; | |
77566f2a | 7134 | } |
7135 | ||
8ec526a4 | 7136 | // Variable of the tree |
7137 | Int_t groupnumber = -1; // Group calibration | |
7138 | TGraphErrors *histo = 0x0; | |
7139 | TObjArray vectorP = *vVectorP; | |
7140 | TObjArray plaP = *pPlaP; | |
77566f2a | 7141 | |
8ec526a4 | 7142 | // Init the tree |
7143 | TTree *treeP = new TTree(name,nametitle); | |
7144 | treeP->Branch("groupnumber",&groupnumber,"groupnumber/I"); | |
7145 | treeP->Branch("histo","TGraphErrors",&histo,32000,0); | |
77566f2a | 7146 | |
8ec526a4 | 7147 | // Fill |
77566f2a | 7148 | Int_t k = 0; |
8ec526a4 | 7149 | while (k < ntotal) { |
77566f2a | 7150 | TString nome(name); |
8ec526a4 | 7151 | groupnumber = ((AliTRDPlace *) plaP.At(0))->GetPlace(); |
7152 | nome += groupnumber; | |
7153 | histo = ConvertVectorPHisto((AliTRDPInfo *) vectorP.At(0),nome); | |
7154 | treeP->Fill(); | |
7155 | vectorP.RemoveAt(0); | |
7156 | vectorP.Compress(); | |
7157 | plaP.RemoveAt(0); | |
7158 | plaP.Compress(); | |
77566f2a | 7159 | k++; |
77566f2a | 7160 | } |
7161 | ||
8ec526a4 | 7162 | return treeP; |
77566f2a | 7163 | |
7164 | } | |
7165 | ||
7166 | //_____________________________________________________________________________ | |
8ec526a4 | 7167 | TObjArray *AliTRDCalibra::ConvertTreeVector(TTree *tree) const |
77566f2a | 7168 | { |
7169 | // | |
8ec526a4 | 7170 | // Convert the branch groupnumber of the tree taken from |
7171 | // TRD.calibration.root in case of vector method in a std::vector | |
7172 | // to be faster | |
77566f2a | 7173 | // |
7174 | ||
8ec526a4 | 7175 | // Initialise |
7176 | TObjArray *vectorplace = new TObjArray(); | |
77566f2a | 7177 | |
8ec526a4 | 7178 | // Variable of the tree |
7179 | Int_t groupnumber = -1; // Group calibration | |
77566f2a | 7180 | |
8ec526a4 | 7181 | // Set the branch |
77566f2a | 7182 | tree->SetBranchAddress("groupnumber",&groupnumber); |
8ec526a4 | 7183 | |
7184 | // Fill | |
7185 | Int_t ntotal = tree->GetEntries(); | |
7186 | for (Int_t k = 0; k < ntotal; k++) { | |
77566f2a | 7187 | tree->GetEntry(k); |
8ec526a4 | 7188 | AliTRDPlace *placegroupnumber = new AliTRDPlace(); |
7189 | placegroupnumber->SetPlace(groupnumber); | |
7190 | vectorplace->Add((TObject *) placegroupnumber); | |
7191 | } | |
7192 | ||
77566f2a | 7193 | return vectorplace; |
7194 | ||
7195 | } | |
7196 | ||
7197 | //_____________________________________________________________________________ | |
8ec526a4 | 7198 | Bool_t AliTRDCalibra::MergeVectorCT(TObjArray *vVectorCT2, TObjArray *pPlaCT2) |
77566f2a | 7199 | { |
7200 | // | |
7201 | // Add the two vectors and place the result in the first | |
7202 | // | |
7203 | ||
8ec526a4 | 7204 | if (((Int_t) pPlaCT2->GetEntriesFast()) != ((Int_t) vVectorCT2->GetEntriesFast())){ |
77566f2a | 7205 | AliInfo("VectorCT2 doesn't correspond to PlaCT2!"); |
7206 | return kFALSE; | |
7207 | } | |
77566f2a | 7208 | |
8ec526a4 | 7209 | // CH case |
7210 | for (Int_t k = 0; k < (Int_t) fPlaCH->GetEntriesFast(); k++) { | |
77566f2a | 7211 | |
8ec526a4 | 7212 | // Look if PlaCT1[k] it is also in the second vector |
77566f2a | 7213 | Int_t place = -1; |
8ec526a4 | 7214 | for (Int_t j = 0; j < (Int_t) pPlaCT2->GetEntriesFast(); j++) { |
7215 | if (((AliTRDPlace *) pPlaCT2->At(j))->GetPlace() == | |
7216 | ((AliTRDPlace *) fPlaCH->At(k))->GetPlace()) { | |
77566f2a | 7217 | place = j; |
7218 | break; | |
7219 | } | |
7220 | } | |
7221 | ||
8ec526a4 | 7222 | // If not in the second vector nothing to do |
7223 | ||
7224 | // If in the second vector | |
7225 | if (place != -1) { | |
77566f2a | 7226 | |
8ec526a4 | 7227 | AliTRDCTInfo *fCTInfo = new AliTRDCTInfo(); |
7228 | UShort_t *entries = new UShort_t[fNumberBinCharge]; | |
77566f2a | 7229 | |
8ec526a4 | 7230 | for (Int_t nu = 0; nu < fNumberBinCharge; nu++) { |
7231 | entries[nu] = ((AliTRDCTInfo *) fVectorCH->At(((AliTRDPlace *) fPlaCH->At(k))->GetPlace()))->GetEntries()[nu] | |
7232 | + ((AliTRDCTInfo *) vVectorCT2->At(((AliTRDPlace *) fPlaCH->At(k))->GetPlace()))->GetEntries()[nu]; | |
77566f2a | 7233 | } |
7234 | ||
8ec526a4 | 7235 | // Set |
7236 | fCTInfo->SetEntries(entries); | |
7237 | ||
7238 | // Nothing to do on PlaCT1 | |
77566f2a | 7239 | |
8ec526a4 | 7240 | // Update the vector |
7241 | fVectorCH->AddAt((TObject *) fCTInfo,((AliTRDPlace *) fPlaCH->At(k))->GetPlace()); | |
7242 | ||
77566f2a | 7243 | } |
7244 | ||
8ec526a4 | 7245 | } |
7246 | ||
7247 | // And at the end the vector in CT2 but not in CH1 | |
7248 | for (Int_t k = 0; k < (Int_t) pPlaCT2->GetEntriesFast(); k++) { | |
77566f2a | 7249 | |
8ec526a4 | 7250 | // Look if pPlaCT2[k] it is also in the second vector |
77566f2a | 7251 | Int_t place = -1; |
8ec526a4 | 7252 | for (Int_t j = 0; j < (Int_t) fPlaCH->GetEntriesFast(); j++) { |
7253 | if (((AliTRDPlace *) fPlaCH->At(j))->GetPlace() == ((AliTRDPlace *) pPlaCT2->At(k))->GetPlace()) { | |
77566f2a | 7254 | place = j; |
7255 | break; | |
7256 | } | |
7257 | } | |
8ec526a4 | 7258 | |
7259 | // If not in the first vector | |
7260 | if (place == -1) { | |
77566f2a | 7261 | |
8ec526a4 | 7262 | AliTRDCTInfo *fCTInfo = new AliTRDCTInfo(); |
7263 | fCTInfo = ((AliTRDCTInfo *) vVectorCT2->At(((AliTRDPlace *) pPlaCT2->At(k))->GetPlace())); | |
77566f2a | 7264 | |
8ec526a4 | 7265 | // Add at the end |
7266 | fPlaCH->Add((TObject *) (pPlaCT2->At(k))); | |
7267 | fVectorCH->Add((TObject *) fCTInfo); | |
7268 | ||
77566f2a | 7269 | } |
7270 | ||
7271 | } | |
77566f2a | 7272 | |
7273 | return kTRUE; | |
7274 | ||
77566f2a | 7275 | } |
7276 | ||
7277 | //_____________________________________________________________________________ | |
8ec526a4 | 7278 | Bool_t AliTRDCalibra::MergeVectorP(TObjArray *vVectorP2 |
7279 | , TObjArray *pPlaP2 | |
7280 | , Int_t i) | |
77566f2a | 7281 | { |
7282 | // | |
7283 | // Add the two vectors and place the result in the first | |
7284 | // | |
77566f2a | 7285 | |
8ec526a4 | 7286 | if (((Int_t) pPlaP2->GetEntriesFast()) != ((Int_t) vVectorP2->GetEntriesFast())) { |
7287 | AliInfo("VectorP2 doesn't correspond to PlaP2!"); | |
7288 | return kFALSE; | |
7289 | } | |
7290 | ||
7291 | // PH case | |
7292 | if (i == 1) { | |
77566f2a | 7293 | |
8ec526a4 | 7294 | for (Int_t k = 0; k < (Int_t) fPlaPH->GetEntriesFast(); k++) { |
77566f2a | 7295 | |
8ec526a4 | 7296 | // Look if fPlaPH[k] it is also in the second vector |
77566f2a | 7297 | Int_t place = -1; |
8ec526a4 | 7298 | for (Int_t j = 0; j < (Int_t) pPlaP2->GetEntriesFast(); j++) { |
7299 | if (((AliTRDPlace *) pPlaP2->At(j))->GetPlace() == ((AliTRDPlace *) fPlaPH->At(k))->GetPlace()) { | |
77566f2a | 7300 | place = j; |
7301 | break; | |
7302 | } | |
7303 | } | |
7304 | ||
8ec526a4 | 7305 | // If not in the second vector nothing to do |
7306 | ||
7307 | // If in the second vector | |
7308 | if (place != -1) { | |
7309 | ||
7310 | AliTRDPInfo *fPInfo = new AliTRDPInfo(); | |
7311 | UShort_t *entries = new UShort_t[fTimeMax]; | |
7312 | Float_t *sum = new Float_t[fTimeMax]; | |
7313 | Float_t *sumsquare = new Float_t[fTimeMax]; | |
7314 | ||
7315 | for (Int_t nu = 0; nu < fTimeMax; nu++) { | |
77566f2a | 7316 | |
8ec526a4 | 7317 | entries[nu] = ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu] |
7318 | + ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]; | |
77566f2a | 7319 | |
8ec526a4 | 7320 | Double_t calcul = ((((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSum()[nu]) |
7321 | * ((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu])) | |
7322 | + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSum()[nu]) | |
7323 | * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]))) | |
7324 | / ((Double_t) fPInfo->GetEntries()[nu]); | |
7325 | ||
7326 | sum[nu] = (Float_t) calcul; | |
77566f2a | 7327 | |
8ec526a4 | 7328 | Double_t calculsquare = ((((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSumSquare()[nu]) |
7329 | * ((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu])) | |
7330 | + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSumSquare()[nu]) | |
7331 | * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]))) | |
7332 | / ((Double_t) fPInfo->GetEntries()[nu]); | |
77566f2a | 7333 | |
7334 | ||
8ec526a4 | 7335 | sumsquare[nu] = calculsquare; |
7336 | ||
77566f2a | 7337 | } |
8ec526a4 | 7338 | |
7339 | // Set | |
7340 | fPInfo->SetSum(sum); | |
7341 | fPInfo->SetSumSquare(sumsquare); | |
7342 | fPInfo->SetEntries(entries); | |
77566f2a | 7343 | |
8ec526a4 | 7344 | // Nothing to do on PlaCT1 |
77566f2a | 7345 | |
8ec526a4 | 7346 | // Update the vector VectorCT1 |
7347 | fVectorPH->AddAt((TObject *) fPInfo,((AliTRDPlace *) fPlaPH->At(k))->GetPlace()); | |
77566f2a | 7348 | |
7349 | } | |
8ec526a4 | 7350 | |
77566f2a | 7351 | } |
8ec526a4 | 7352 | |
7353 | // And at the end the vector in P2 but not in CH1 | |
7354 | for (Int_t k = 0; k < (Int_t) pPlaP2->GetEntriesFast(); k++) { | |
77566f2a | 7355 | |
8ec526a4 | 7356 | // Look if PlaCT2[k] it is also in the second vector |
77566f2a | 7357 | Int_t place = -1; |
8ec526a4 | 7358 | for (Int_t j = 0; j < (Int_t) fPlaPH->GetEntriesFast(); j++) { |
7359 | if (((AliTRDPlace *) fPlaPH->At(j))->GetPlace() == ((AliTRDPlace *) pPlaP2->At(k))->GetPlace()) { | |
77566f2a | 7360 | place = j; |
7361 | break; | |
7362 | } | |
7363 | } | |
7364 | ||
8ec526a4 | 7365 | // If not in the first vector |
7366 | if (place == -1) { | |
77566f2a | 7367 | |
8ec526a4 | 7368 | AliTRDPInfo *fPInfo = new AliTRDPInfo(); |
7369 | fPInfo = (AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) pPlaP2->At(k))->GetPlace()); | |
77566f2a | 7370 | |
8ec526a4 | 7371 | // Add at the end of CH1 |
7372 | fPlaPH->Add(((TObject *) pPlaP2->At(k))); | |
7373 | fVectorPH->Add((TObject *) fPInfo); | |
7374 | ||
77566f2a | 7375 | } |
8ec526a4 | 7376 | |
77566f2a | 7377 | } |
8ec526a4 | 7378 | |
77566f2a | 7379 | } |
7380 | ||
7381 | ||
8ec526a4 | 7382 | // PRF case |
7383 | if (i == 1) { | |
7384 | ||
7385 | for (Int_t k = 0; k < (Int_t) fPlaPRF->GetEntriesFast(); k++) { | |
77566f2a | 7386 | |
8ec526a4 | 7387 | // Look if fPlaPRF[k] it is also in the second vector |
77566f2a | 7388 | Int_t place = -1; |
8ec526a4 | 7389 | for (Int_t j = 0; j < (Int_t) pPlaP2->GetEntriesFast(); j++) { |
7390 | if (((AliTRDPlace *) pPlaP2->At(j))->GetPlace() == ((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()) { | |
77566f2a | 7391 | place = j; |
7392 | break; | |
7393 | } | |
7394 | } | |
8ec526a4 | 7395 | |
7396 | // If not in the second vector nothing to do | |
7397 | ||
7398 | // If in the second vector | |
7399 | if (place != -1) { | |
77566f2a | 7400 | |
8ec526a4 | 7401 | AliTRDPInfo *fPInfo = new AliTRDPInfo(); |
7402 | UShort_t *entries = new UShort_t[fNumberBinPRF]; | |
7403 | Float_t *sum = new Float_t[fNumberBinPRF]; | |
7404 | Float_t *sumsquare = new Float_t[fNumberBinPRF]; | |
7405 | ||
7406 | for (Int_t nu = 0; nu < fNumberBinPRF; nu++) { | |
77566f2a | 7407 | |
8ec526a4 | 7408 | entries[nu] = ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu] |
7409 | + ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]; | |
77566f2a | 7410 | |
8ec526a4 | 7411 | Double_t calcul = ((((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSum()[nu]) |
7412 | * ((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu])) | |
7413 | + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSum()[nu]) | |
7414 | * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]))) | |
7415 | / ((Double_t) fPInfo->GetEntries()[nu]); | |
7416 | ||
7417 | sum[nu] = (Float_t) calcul; | |
77566f2a | 7418 | |
8ec526a4 | 7419 | Double_t calculsquare = ((((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSumSquare()[nu]) |
7420 | * ((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu])) | |
7421 | + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSumSquare()[nu]) | |
7422 | * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]))) | |
7423 | / ((Double_t) fPInfo->GetEntries()[nu]); | |
7424 | ||
7425 | sumsquare[nu] = calculsquare; | |
7426 | ||
77566f2a | 7427 | } |
8ec526a4 | 7428 | |
7429 | // Set | |
7430 | fPInfo->SetSum(sum); | |
7431 | fPInfo->SetSumSquare(sumsquare); | |
7432 | fPInfo->SetEntries(entries); | |
7433 | ||
7434 | // Nothing to do on PlaCT1 | |
77566f2a | 7435 | |
8ec526a4 | 7436 | // Update the vector VectorCT1 |
7437 | fVectorPRF->AddAt((TObject *) fPInfo,((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()); | |
77566f2a | 7438 | |
7439 | } | |
8ec526a4 | 7440 | |
77566f2a | 7441 | } |
8ec526a4 | 7442 | |
7443 | // And at the end the vector in P2 but not in CH1 | |
7444 | for (Int_t k = 0; k < (Int_t) pPlaP2->GetEntriesFast(); k++) { | |
77566f2a | 7445 | |
8ec526a4 | 7446 | // Look if PlaCT2[k] it is also in the second vector |
77566f2a | 7447 | Int_t place = -1; |
8ec526a4 | 7448 | for (Int_t j = 0; j < (Int_t) fPlaPRF->GetEntriesFast(); j++) { |
7449 | if (((AliTRDPlace *) fPlaPRF->At(j))->GetPlace() == ((AliTRDPlace *) pPlaP2->At(k))->GetPlace()) { | |
77566f2a | 7450 | place = j; |
7451 | break; | |
7452 | } | |
7453 | } | |
8ec526a4 | 7454 | |
7455 | // If not in the first vector | |
7456 | if (place == -1) { | |
7457 | ||
7458 | AliTRDPInfo *fPInfo = new AliTRDPInfo(); | |
7459 | fPInfo = (AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) pPlaP2->At(k))->GetPlace()); | |
7460 | ||
7461 | // Add at the end of CH1 | |
7462 | fPlaPRF->Add(((TObject *) pPlaP2->At(k))); | |
7463 | fVectorPRF->Add((TObject *) fPInfo); | |
7464 | ||
77566f2a | 7465 | } |
7466 | ||
7467 | } | |
8ec526a4 | 7468 | |
77566f2a | 7469 | } |
8ec526a4 | 7470 | |
77566f2a | 7471 | return kTRUE; |
8ec526a4 | 7472 | |
77566f2a | 7473 | } |
77566f2a | 7474 | |
8ec526a4 | 7475 | //____________Fit Methods______________________________________________________ |
7476 | ||
7477 | //_____________________________________________________________________________ | |
77566f2a | 7478 | void AliTRDCalibra::FitPente(TH1* projPH, Int_t idect) |
7479 | { | |
7480 | // | |
7481 | // Slope methode for the drift velocity | |
7482 | // | |
7483 | ||
8ec526a4 | 7484 | // Constants |
77566f2a | 7485 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); |
8ec526a4 | 7486 | Int_t binmax = 0; |
7487 | Int_t binmin = 0; | |
7488 | fPhd[0] = 0.0; | |
7489 | fPhd[1] = 0.0; | |
7490 | fPhd[2] = 0.0; | |
7491 | Int_t ju = 0; | |
9f4780aa | 7492 | Double_t vdriftCoefE = 0.0; |
7493 | Double_t t0CoefE = 0.0; | |
77566f2a | 7494 | fVdriftCoef[1] = 0.0; |
8ec526a4 | 7495 | fT0Coef[1] = 0.0; |
77566f2a | 7496 | TLine *line = new TLine(); |
77566f2a | 7497 | |
8ec526a4 | 7498 | // Some variables |
7499 | TAxis *xpph = projPH->GetXaxis(); | |
7500 | Int_t nbins = xpph->GetNbins(); | |
7501 | Double_t lowedge = xpph->GetBinLowEdge(1); | |
7502 | Double_t upedge = xpph->GetBinUpEdge(xpph->GetNbins()); | |
7503 | Double_t widbins = (upedge - lowedge) / nbins; | |
7504 | Double_t limit = upedge + 0.5 * widbins; | |
7505 | ||
7506 | // Beginning of the signal | |
7507 | TH1D *pentea = new TH1D("pentea","pentea",projPH->GetNbinsX(),0,(Float_t) limit); | |
7508 | for (Int_t k = 1; k < projPH->GetNbinsX(); k++) { | |
7509 | pentea->SetBinContent(k,(Double_t) (projPH->GetBinContent(k+1) - projPH->GetBinContent(k))); | |
77566f2a | 7510 | } |
8ec526a4 | 7511 | |
7512 | binmax = (Int_t) pentea->GetMaximumBin(); | |
7513 | if (binmax == 1) { | |
77566f2a | 7514 | binmax = 2; |
7515 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
7516 | } | |
7517 | pentea->Fit("pol2","0MR","",TMath::Max(pentea->GetBinCenter(binmax-1),0.0),pentea->GetBinCenter(binmax+1)); | |
7518 | Float_t l3P1am = pentea->GetFunction("pol2")->GetParameter(1); | |
7519 | Float_t l3P2am = pentea->GetFunction("pol2")->GetParameter(2); | |
9f4780aa | 7520 | Float_t l3P1amE = pentea->GetFunction("pol2")->GetParError(1); |
7521 | Float_t l3P2amE = pentea->GetFunction("pol2")->GetParError(2); | |
8ec526a4 | 7522 | if (l3P2am != 0) { |
7523 | fPhd[0] = -(l3P1am / (2 * l3P2am)); | |
7524 | } | |
9f4780aa | 7525 | if((l3P1am != 0.0) && (l3P2am != 0.0)){ |
7526 | t0CoefE = (l3P1amE/l3P1am + l3P2amE/l3P2am)*fPhd[0]; | |
7527 | } | |
77566f2a | 7528 | |
8ec526a4 | 7529 | // Amplification region |
77566f2a | 7530 | binmax = 0; |
8ec526a4 | 7531 | ju = 0; |
7532 | for (Int_t kbin = 1; kbin < projPH->GetNbinsX(); kbin ++) { | |
9f4780aa | 7533 | if (((projPH->GetBinContent(kbin+1) - projPH->GetBinContent(kbin)) <= 0.0) && (ju == 0) && (kbin > (fPhd[0]/widbins))) { |
77566f2a | 7534 | binmax = kbin; |
8ec526a4 | 7535 | ju = 1; |
77566f2a | 7536 | } |
7537 | } | |
8ec526a4 | 7538 | if (binmax == 1) { |
77566f2a | 7539 | binmax = 2; |
7540 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
7541 | } | |
7542 | projPH->Fit("pol2","0MR","",TMath::Max(projPH->GetBinCenter(binmax-1),0.0),projPH->GetBinCenter(binmax+1)); | |
7543 | Float_t l3P1amf = projPH->GetFunction("pol2")->GetParameter(1); | |
7544 | Float_t l3P2amf = projPH->GetFunction("pol2")->GetParameter(2); | |
9f4780aa | 7545 | Float_t l3P1amfE = projPH->GetFunction("pol2")->GetParError(1); |
7546 | Float_t l3P2amfE = projPH->GetFunction("pol2")->GetParError(2); | |
77566f2a | 7547 | |
8ec526a4 | 7548 | if (l3P2amf != 0) { |
7549 | fPhd[1] = -(l3P1amf / (2 * l3P2amf)); | |
7550 | } | |
9f4780aa | 7551 | if((l3P1amf != 0.0) && (l3P2amf != 0.0)){ |
7552 | vdriftCoefE = (l3P1amfE/l3P1amf + l3P2amfE/l3P2amf)*fPhd[1]; | |
7553 | } | |
77566f2a | 7554 | |
8ec526a4 | 7555 | // Drift region |
7556 | TH1D *pente = new TH1D("pente","pente",projPH->GetNbinsX(),0,(Float_t) limit); | |
7557 | for (Int_t k = binmax+4; k < projPH->GetNbinsX(); k++) { | |
7558 | pente->SetBinContent(k,(Double_t) (projPH->GetBinContent(k+1) - projPH->GetBinContent(k))); | |
77566f2a | 7559 | } |
8ec526a4 | 7560 | binmin = (Int_t) pente->GetMinimumBin(); |
7561 | if (binmin == 1) { | |
77566f2a | 7562 | binmin = 2; |
7563 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
7564 | } | |
9244c78b | 7565 | pente->Fit("pol2" |
7566 | ,"0MR" | |
7567 | ,"" | |
7568 | ,TMath::Max(pente->GetBinCenter(binmin-1), 0.0) | |
7569 | ,TMath::Min(pente->GetBinCenter(binmin+2),(Double_t) limit)); | |
77566f2a | 7570 | Float_t l3P1dr = pente->GetFunction("pol2")->GetParameter(1); |
7571 | Float_t l3P2dr = pente->GetFunction("pol2")->GetParameter(2); | |
9f4780aa | 7572 | Float_t l3P1drE = pente->GetFunction("pol2")->GetParError(1); |
7573 | Float_t l3P2drE = pente->GetFunction("pol2")->GetParError(2); | |
8ec526a4 | 7574 | if (l3P2dr != 0) { |
7575 | fPhd[2] = -(l3P1dr / (2 * l3P2dr)); | |
7576 | } | |
9f4780aa | 7577 | if((l3P1dr != 0.0) && (l3P2dr != 0.0)){ |
7578 | vdriftCoefE += (l3P1drE/l3P1dr + l3P2drE/l3P2dr)*fPhd[2]; | |
7579 | } | |
77566f2a | 7580 | |
8ec526a4 | 7581 | if ((fPhd[2] > fPhd[0]) && |
7582 | (fPhd[2] > fPhd[1]) && | |
7583 | (fPhd[1] > fPhd[0])) { | |
7584 | fVdriftCoef[1] = (kDrWidth) / (fPhd[2]-fPhd[1]); | |
7585 | if (fPhd[0] >= 0.0) { | |
9244c78b | 7586 | fT0Coef[1] = (fPhd[0] - fT0Shift) / widbins; |
9f4780aa | 7587 | if (fT0Coef[1] < -1.0) { |
7588 | fT0Coef[1] = fT0Coef[2]; | |
9244c78b | 7589 | } |
8ec526a4 | 7590 | } |
7591 | else { | |
9f4780aa | 7592 | fT0Coef[1] = fT0Coef[2]; |
8ec526a4 | 7593 | } |
77566f2a | 7594 | } |
8ec526a4 | 7595 | else { |
77566f2a | 7596 | fVdriftCoef[1] = -TMath::Abs(fVdriftCoef[2]); |
9f4780aa | 7597 | fT0Coef[1] = fT0Coef[2]; |
77566f2a | 7598 | } |
77566f2a | 7599 | |
8ec526a4 | 7600 | if ((fDebug == 1) || |
7601 | (fDebug == 4)) { | |
9f4780aa | 7602 | fCoefVdrift[1][idect] = fVdriftCoef[1]; |
7603 | fCoefVdriftE[1] [idect] = vdriftCoefE; | |
7604 | fCoefT0[1][idect] = fT0Coef[1]; | |
7605 | fCoefT0E[1][idect] = t0CoefE; | |
77566f2a | 7606 | } |
7607 | ||
8ec526a4 | 7608 | if (fDebug == 2) { |
77566f2a | 7609 | TCanvas *cpentei = new TCanvas("cpentei","cpentei",50,50,600,800); |
7610 | cpentei->cd(); | |
7611 | projPH->Draw(); | |
7612 | line->SetLineColor(2); | |
7613 | line->DrawLine(fPhd[0],0,fPhd[0],projPH->GetMaximum()); | |
7614 | line->DrawLine(fPhd[1],0,fPhd[1],projPH->GetMaximum()); | |
7615 | line->DrawLine(fPhd[2],0,fPhd[2],projPH->GetMaximum()); | |
8ec526a4 | 7616 | AliInfo(Form("fPhd[0] (beginning of the signal): %f" ,(Float_t) fPhd[0])); |
7617 | AliInfo(Form("fPhd[1] (end of the amplification region): %f" ,(Float_t) fPhd[1])); | |
7618 | AliInfo(Form("fPhd[2] (end of the drift region): %f" ,(Float_t) fPhd[2])); | |
7619 | AliInfo(Form("fVriftCoef[1] (with only the drift region(default)): %f",(Float_t) fVdriftCoef[1])); | |
77566f2a | 7620 | } |
8ec526a4 | 7621 | |
7622 | if (fDebug != 2) { | |
7623 | delete pentea; | |
7624 | } | |
7625 | if (fDebug != 2) { | |
7626 | delete pente; | |
7627 | } | |
7628 | ||
77566f2a | 7629 | } |
7630 | ||
8ec526a4 | 7631 | //_____________________________________________________________________________ |
77566f2a | 7632 | void AliTRDCalibra::FitPH(TH1* projPH, Int_t idect) |
7633 | { | |
7634 | // | |
7635 | // Fit methode for the drift velocity | |
7636 | // | |
7637 | ||
8ec526a4 | 7638 | // Constants |
7639 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); | |
7640 | ||
7641 | // Some variables | |
7642 | TAxis *xpph = projPH->GetXaxis(); | |
7643 | Double_t upedge = xpph->GetBinUpEdge(xpph->GetNbins()); | |
77566f2a | 7644 | |
8ec526a4 | 7645 | TF1 *fPH = new TF1("fPH",AliTRDCalibra::PH,-0.05,3.2,6); |
7646 | fPH->SetParameter(0,0.469); // Scaling | |
7647 | fPH->SetParameter(1,0.18); // Start | |
7648 | fPH->SetParameter(2,0.0857325); // AR | |
7649 | fPH->SetParameter(3,1.89); // DR | |
7650 | fPH->SetParameter(4,0.08); // QA/QD | |
7651 | fPH->SetParameter(5,0.0); // Baseline | |
77566f2a | 7652 | |
7653 | TLine *line = new TLine(); | |
7654 | ||
7655 | fVdriftCoef[0] = 0.0; | |
8ec526a4 | 7656 | fT0Coef[0] = 0.0; |
9f4780aa | 7657 | Double_t vdriftCoefE = 0.0; |
7658 | Double_t t0CoefE = 0.0; | |
77566f2a | 7659 | |
8ec526a4 | 7660 | if (idect%fFitPHPeriode == 0) { |
7661 | ||
7662 | AliInfo(Form("<AliTRDCalibra::FitPH> The detector %d will be fitted",idect)); | |
7663 | fPH->SetParameter(0,(projPH->Integral()-(projPH->GetBinContent(1)*projPH->GetNbinsX())) * 0.00028); // Scaling | |
7664 | fPH->SetParameter(1,fPhd[0] - 0.1); // Start | |
7665 | fPH->SetParameter(2,fPhd[1] - fPhd[0]); // AR | |
7666 | fPH->SetParameter(3,fPhd[2] - fPhd[1]); // DR | |
7667 | fPH->SetParameter(4,0.225); // QA/QD | |
77566f2a | 7668 | fPH->SetParameter(5,(Float_t) projPH->GetBinContent(1)); |
7669 | ||
8ec526a4 | 7670 | if (fDebug != 2) { |
7671 | projPH->Fit(fPH,"0M","",0.0,upedge); | |
77566f2a | 7672 | } |
7673 | ||
8ec526a4 | 7674 | if (fDebug == 2) { |
77566f2a | 7675 | TCanvas *cpente = new TCanvas("cpente","cpente",50,50,600,800); |
7676 | cpente->cd(); | |
8ec526a4 | 7677 | projPH->Fit(fPH,"M+","",0.0,upedge); |
77566f2a | 7678 | projPH->Draw("E0"); |
7679 | line->SetLineColor(4); | |
8ec526a4 | 7680 | line->DrawLine(fPH->GetParameter(1) |
7681 | ,0 | |
7682 | ,fPH->GetParameter(1) | |
7683 | ,projPH->GetMaximum()); | |
7684 | line->DrawLine(fPH->GetParameter(1)+fPH->GetParameter(2) | |
7685 | ,0 | |
7686 | ,fPH->GetParameter(1)+fPH->GetParameter(2) | |
7687 | ,projPH->GetMaximum()); | |
7688 | line->DrawLine(fPH->GetParameter(1)+fPH->GetParameter(2)+fPH->GetParameter(3) | |
7689 | ,0 | |
7690 | ,fPH->GetParameter(1)+fPH->GetParameter(2)+fPH->GetParameter(3) | |
7691 | ,projPH->GetMaximum()); | |
7692 | } | |
7693 | ||
7694 | if (fPH->GetParameter(3) != 0) { | |
7695 | fVdriftCoef[0] = kDrWidth / (fPH->GetParameter(3)); | |
9f4780aa | 7696 | vdriftCoefE = (fPH->GetParError(3)/fPH->GetParameter(3))*fVdriftCoef[0]; |
8ec526a4 | 7697 | fT0Coef[0] = fPH->GetParameter(1); |
9f4780aa | 7698 | t0CoefE = fPH->GetParError(1); |
77566f2a | 7699 | } |
7700 | else { | |
7701 | fVdriftCoef[0] = -TMath::Abs(fVdriftCoef[2]); | |
9f4780aa | 7702 | fT0Coef[0] = fT0Coef[2]; |
77566f2a | 7703 | } |
8ec526a4 | 7704 | |
7705 | if ((fDebug == 1) || | |
7706 | (fDebug == 4)) { | |
9f4780aa | 7707 | fCoefVdrift[0][idect] = fVdriftCoef[0]; |
7708 | fCoefVdriftE[0][idect] = vdriftCoefE; | |
7709 | fCoefT0[0][idect] = fT0Coef[0]; | |
7710 | fCoefT0E[0][idect] = t0CoefE; | |
77566f2a | 7711 | } |
8ec526a4 | 7712 | if (fDebug == 2) { |
7713 | AliInfo(Form("fVdriftCoef[0]: %f",(Float_t) fVdriftCoef[0])); | |
77566f2a | 7714 | } |
8ec526a4 | 7715 | |
77566f2a | 7716 | } |
7717 | ||
8ec526a4 | 7718 | else { |
7719 | ||
7720 | // Put the default value | |
7721 | if ((fDebug <= 1) || | |
e3cd8b1a | 7722 | (fDebug == 4)) { |
9f4780aa | 7723 | fCoefVdrift[0][idect] = -TMath::Abs(fVdriftCoef[2]); |
7724 | fCoefT0[0][idect] = -TMath::Abs(fT0Coef[2]); | |
77566f2a | 7725 | } |
7726 | ||
7727 | } | |
7728 | ||
8ec526a4 | 7729 | if (fDebug != 2) { |
7730 | delete fPH; | |
7731 | } | |
77566f2a | 7732 | |
7733 | } | |
8ec526a4 | 7734 | |
7735 | //_____________________________________________________________________________ | |
7736 | void AliTRDCalibra::FitPRF(TH1 *projPRF, Int_t idect) | |
77566f2a | 7737 | { |
7738 | // | |
7739 | // Fit methode for the sigma of the pad response function | |
7740 | // | |
7741 | ||
7742 | fPRFCoef[0] = 0.0; | |
9f4780aa | 7743 | Double_t prfCoefE = 0.0; |
77566f2a | 7744 | |
8ec526a4 | 7745 | if (fDebug != 2) { |
7746 | projPRF->Fit("gaus","0M","",-fRangeFitPRF,fRangeFitPRF); | |
77566f2a | 7747 | } |
7748 | ||
8ec526a4 | 7749 | if (fDebug == 2) { |
77566f2a | 7750 | TCanvas *cfit = new TCanvas("cfit","cfit",50,50,600,800); |
7751 | cfit->cd(); | |
8ec526a4 | 7752 | projPRF->Fit("gaus","M+","",-fRangeFitPRF,fRangeFitPRF); |
77566f2a | 7753 | projPRF->Draw(); |
77566f2a | 7754 | } |
8ec526a4 | 7755 | |
77566f2a | 7756 | fPRFCoef[0] = projPRF->GetFunction("gaus")->GetParameter(2); |
9f4780aa | 7757 | prfCoefE = projPRF->GetFunction("gaus")->GetParError(2); |
e5c60cc7 | 7758 | if(fPRFCoef[0] <= 0.0) fPRFCoef[0] = -fPRFCoef[1]; |
77566f2a | 7759 | |
8ec526a4 | 7760 | if ((fDebug == 1) || |
7761 | (fDebug == 4)) { | |
9f4780aa | 7762 | fCoefPRF[0][idect] = fPRFCoef[0]; |
7763 | fCoefPRFE[idect] = prfCoefE; | |
77566f2a | 7764 | } |
8ec526a4 | 7765 | if (fDebug == 2) { |
7766 | AliInfo(Form("fPRFCoef[0]: %f",(Float_t) fPRFCoef[0])); | |
77566f2a | 7767 | } |
7768 | ||
7769 | } | |
8ec526a4 | 7770 | |
7771 | //_____________________________________________________________________________ | |
7772 | void AliTRDCalibra::FitCH(TH1 *projch, Int_t idect) | |
77566f2a | 7773 | { |
7774 | // | |
7775 | // Fit methode for the gain factor | |
7776 | // | |
7777 | ||
7778 | fChargeCoef[0] = 0.0; | |
7779 | fChargeCoef[1] = 0.0; | |
9f4780aa | 7780 | Double_t chargeCoefE0 = 0.0; |
7781 | Double_t chargeCoefE1 = 0.0; | |
8ec526a4 | 7782 | TF1 *fLandauGaus = new TF1("fLandauGaus",FuncLandauGaus,0,300,5); |
77566f2a | 7783 | |
7784 | fChargeCoef[1] = projch->GetMean(); | |
9f4780aa | 7785 | chargeCoefE1 = projch->GetMeanError(); |
8ec526a4 | 7786 | projch->Fit("landau","0","" |
7787 | ,(Float_t) fChargeCoef[1]/fBeginFitCharge | |
7788 | ,projch->GetBinCenter(projch->GetNbinsX())); | |
7789 | fL3P0 = projch->GetFunction("landau")->GetParameter(0); | |
77566f2a | 7790 | Double_t l3P1 = projch->GetFunction("landau")->GetParameter(1); |
8ec526a4 | 7791 | fL3P2 = projch->GetFunction("landau")->GetParameter(2); |
77566f2a | 7792 | |
8ec526a4 | 7793 | projch->Fit("gaus","0","" |
7794 | ,(Float_t) fChargeCoef[1]/fBeginFitCharge | |
7795 | ,projch->GetBinCenter(projch->GetNbinsX())); | |
77566f2a | 7796 | Double_t g3P0 = projch->GetFunction("gaus")->GetParameter(0); |
8ec526a4 | 7797 | fG3P2 = projch->GetFunction("gaus")->GetParameter(2); |
77566f2a | 7798 | |
8ec526a4 | 7799 | fLandauGaus->SetParameters(fL3P0,l3P1,fL3P2,g3P0,fG3P2); |
7800 | if ((fDebug <= 1) || | |
7801 | (fDebug >= 3)) { | |
7802 | projch->Fit("fLandauGaus","0","" | |
7803 | ,(Float_t) fChargeCoef[1]/fBeginFitCharge | |
7804 | ,projch->GetBinCenter(projch->GetNbinsX())); | |
77566f2a | 7805 | } |
8ec526a4 | 7806 | |
7807 | if (fDebug == 2) { | |
77566f2a | 7808 | TCanvas *cp = new TCanvas("cp","cp",50,50,600,800); |
7809 | cp->cd(); | |
8ec526a4 | 7810 | projch->Fit("fLandauGaus","+","" |
7811 | ,(Float_t) fChargeCoef[1]/fBeginFitCharge | |
7812 | ,projch->GetBinCenter(projch->GetNbinsX())); | |
77566f2a | 7813 | projch->Draw(); |
7814 | fLandauGaus->Draw("same"); | |
7815 | } | |
7816 | ||
8ec526a4 | 7817 | if (projch->GetFunction("fLandauGaus")->GetParameter(1) > 0) { |
7818 | // Calcul of "real" coef | |
7819 | CalculChargeCoefMean(fCountDet[0],(Int_t) idect,kTRUE); | |
7820 | fChargeCoef[0] = projch->GetFunction("fLandauGaus")->GetParameter(1); | |
9f4780aa | 7821 | chargeCoefE0 = projch->GetFunction("fLandauGaus")->GetParError(1); |
8ec526a4 | 7822 | } |
77566f2a | 7823 | else { |
8ec526a4 | 7824 | // Calcul of "real" coef |
7825 | CalculChargeCoefMean(fCountDet[0],(Int_t) idect,kFALSE); | |
77566f2a | 7826 | fChargeCoef[0] = -TMath::Abs(fChargeCoef[3]); |
7827 | } | |
8ec526a4 | 7828 | |
7829 | if (fDebug == 2) { | |
7830 | AliInfo(Form("fChargeCoef[0]: %f",(Float_t) fChargeCoef[0])); | |
77566f2a | 7831 | AliInfo(Form("fChargeCoef[1]: %f",(Float_t) fChargeCoef[1])); |
7832 | } | |
7833 | ||
8ec526a4 | 7834 | if ((fDebug == 1) || |
7835 | (fDebug == 4)) { | |
7836 | if (fChargeCoef[0] > 0.0) { | |
9f4780aa | 7837 | fCoefCharge[0][idect]= fChargeCoef[0]; |
7838 | fCoefChargeE[0][idect]= chargeCoefE0; | |
7839 | fCoefCharge[1][idect]= fChargeCoef[1]; | |
7840 | fCoefChargeE[1][idect]= chargeCoefE1; | |
77566f2a | 7841 | } |
7842 | } | |
8ec526a4 | 7843 | fL3P0 = fLandauGaus->Integral(0.3*projch->GetMean(),3*projch->GetMean()); |
7844 | fG3P2 = fLandauGaus->GetParameter(2); | |
7845 | fL3P2 = fLandauGaus->GetParameter(4); | |
77566f2a | 7846 | |
8ec526a4 | 7847 | if (fDebug != 2) { |
7848 | delete fLandauGaus; | |
7849 | } | |
7850 | ||
77566f2a | 7851 | } |
8ec526a4 | 7852 | |
7853 | //_____________________________________________________________________________ | |
7854 | void AliTRDCalibra::FitBisCH(TH1* projch, Int_t idect) | |
77566f2a | 7855 | { |
7856 | // | |
7857 | // Fit methode for the gain factor more time consuming | |
7858 | // | |
77566f2a | 7859 | |
77566f2a | 7860 | // Setting fit range and start values |
7861 | Double_t fr[2]; | |
8ec526a4 | 7862 | //Double_t sv[4] = { l3P2, fChargeCoef[1], projch->Integral("width"), fG3P2 }; |
7863 | Double_t sv[4] = { fL3P2, fChargeCoef[1], fL3P0, fG3P2 }; | |
7864 | Double_t pllo[4] = { 0.001, 0.001, 0.001, 0.001 }; | |
7865 | Double_t plhi[4] = { 300.0, 300.0, 100000000.0, 300.0 }; | |
7866 | Double_t fp[4] = { 1.0, 1.0, 1.0, 1.0 }; | |
7867 | Double_t fpe[4] = { 1.0, 1.0, 1.0, 1.0 }; | |
7868 | fr[0] = 0.3 * projch->GetMean(); | |
7869 | fr[1] = 3.0 * projch->GetMean(); | |
7870 | fChargeCoef[2] = 0.0; | |
9f4780aa | 7871 | Double_t chargeCoefE2 = 0.0; |
8ec526a4 | 7872 | |
77566f2a | 7873 | Double_t chisqr; |
7874 | Int_t ndf; | |
8ec526a4 | 7875 | TF1 *fitsnr = LanGauFit(projch,&fr[0],&sv[0] |
7876 | ,&pllo[0],&plhi[0] | |
7877 | ,&fp[0],&fpe[0] | |
7878 | ,&chisqr,&ndf); | |
77566f2a | 7879 | |
8ec526a4 | 7880 | Double_t projchPeak; |
7881 | Double_t projchFWHM; | |
7882 | LanGauPro(fp,projchPeak,projchFWHM); | |
7883 | ||
7884 | if (fp[1] > 0) { | |
7885 | fChargeCoef[2] = fp[1]; | |
9f4780aa | 7886 | chargeCoefE2 = fpe[1]; |
7887 | //chargeCoefE2 = chisqr; | |
8ec526a4 | 7888 | } |
7889 | else { | |
7890 | fChargeCoef[2] = -TMath::Abs(fChargeCoef[3]); | |
7891 | } | |
77566f2a | 7892 | |
8ec526a4 | 7893 | if (fDebug == 2) { |
7894 | AliInfo(Form("fChargeCoef[2]: %f",(Float_t) fChargeCoef[2])); | |
77566f2a | 7895 | TCanvas *cpy = new TCanvas("cpy","cpy",50,50,600,800); |
7896 | cpy->cd(); | |
7897 | projch->Draw(); | |
7898 | fitsnr->Draw("same"); | |
7899 | } | |
8ec526a4 | 7900 | |
7901 | if ((fDebug == 1) || | |
7902 | (fDebug == 4)) { | |
7903 | if (fChargeCoef[2] > 0.0) { | |
9f4780aa | 7904 | fCoefCharge[2][idect]= fChargeCoef[2]; |
7905 | fCoefChargeE[2][idect]= chargeCoefE2; | |
77566f2a | 7906 | } |
7907 | } | |
8ec526a4 | 7908 | |
7909 | if (fDebug != 2) { | |
7910 | delete fitsnr; | |
7911 | } | |
7912 | ||
77566f2a | 7913 | } |
8ec526a4 | 7914 | |
7915 | //_____________________________________________________________________________ | |
77566f2a | 7916 | void AliTRDCalibra::NormierungCharge() |
7917 | { | |
7918 | // | |
8ec526a4 | 7919 | // Normalisation of the gain factor resulting for the fits |
77566f2a | 7920 | // |
7921 | ||
8ec526a4 | 7922 | // Calcul of the mean of the fit |
7923 | Double_t sum = 0.0; | |
8ec526a4 | 7924 | for (Int_t k = 0; k < (Int_t) fVectorFitCH->GetEntriesFast(); k++) { |
7925 | Int_t total = 0; | |
7926 | Int_t detector = ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetDetector(); | |
7927 | Float_t *coef = ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetCoef(); | |
7928 | if (GetChamber(detector) == 2) { | |
7929 | total = 1728; | |
7930 | } | |
7931 | if (GetChamber(detector) != 2) { | |
7932 | total = 2304; | |
7933 | } | |
7934 | for (Int_t j = 0; j < total; j++) { | |
7935 | if (coef[j] >= 0) { | |
7936 | sum += coef[j]; | |
77566f2a | 7937 | } |
7938 | } | |
7939 | } | |
8ec526a4 | 7940 | |
7941 | if (sum > 0) { | |
7942 | fScaleFitFactor = fScaleFitFactor / sum; | |
7943 | } | |
7944 | else { | |
7945 | fScaleFitFactor = 1.0; | |
7946 | } | |
7947 | ||
8ec526a4 | 7948 | if ((fDebug == 3) || |
7949 | (fDebug == 4)) { | |
9f4780aa | 7950 | if ((fCoefChargeDB[0]->GetEntries() > 0.0) && |
7951 | (fCoefChargeDB[0]->GetSumOfWeights() > 0.0)) { | |
7952 | fCoefChargeDB[0]->Scale(fCoefChargeDB[0]->GetEntries() / fCoefChargeDB[0]->GetSumOfWeights()); | |
7953 | } | |
8ec526a4 | 7954 | if ((fMeanChargeOn) && |
7955 | (fCoefChargeDB[1]->GetEntries() > 0.0) && | |
7956 | (fCoefChargeDB[1]->GetSumOfWeights() > 0.0)) { | |
7957 | fCoefChargeDB[1]->Scale(fCoefChargeDB[1]->GetEntries() / fCoefChargeDB[1]->GetSumOfWeights()); | |
7958 | } | |
7959 | if ((fFitChargeBisOn) && | |
7960 | (fCoefChargeDB[2]->GetEntries() > 0.0) && | |
7961 | (fCoefChargeDB[2]->GetSumOfWeights() > 0.0)) { | |
7962 | fCoefChargeDB[2]->Scale(fCoefChargeDB[2]->GetEntries() / fCoefChargeDB[2]->GetSumOfWeights()); | |
7963 | } | |
77566f2a | 7964 | } |
77566f2a | 7965 | |
7966 | } | |
7967 | ||
8ec526a4 | 7968 | //_____________________________________________________________________________ |
7969 | TH1I *AliTRDCalibra::ReBin(TH1I *hist) const | |
77566f2a | 7970 | { |
7971 | // | |
7972 | // Rebin of the 1D histo for the gain calibration if needed. | |
7973 | // you have to choose fRebin, divider of fNumberBinCharge | |
7974 | // | |
7975 | ||
8ec526a4 | 7976 | TAxis *xhist = hist->GetXaxis(); |
7977 | TH1I *rehist = new TH1I("projrebin","",(Int_t) xhist->GetNbins()/fRebin | |
7978 | ,xhist->GetBinLowEdge(1) | |
7979 | ,xhist->GetBinUpEdge(xhist->GetNbins())); | |
7980 | ||
7981 | AliInfo(Form("fRebin: %d",fRebin)); | |
77566f2a | 7982 | Int_t i = 1; |
8ec526a4 | 7983 | for (Int_t k = 1; k <= (Int_t) xhist->GetNbins()/fRebin; k++) { |
77566f2a | 7984 | Double_t sum = 0.0; |
8ec526a4 | 7985 | for (Int_t ji = i; ji < i+fRebin; ji++) { |
77566f2a | 7986 | sum += hist->GetBinContent(ji); |
7987 | } | |
8ec526a4 | 7988 | sum = sum / fRebin; |
77566f2a | 7989 | rehist->SetBinContent(k,sum); |
8ec526a4 | 7990 | i += fRebin; |
77566f2a | 7991 | } |
8ec526a4 | 7992 | |
7993 | if (fDebug == 2) { | |
77566f2a | 7994 | TCanvas *crebin = new TCanvas("crebin","",50,50,600,800); |
7995 | crebin->cd(); | |
7996 | rehist->Draw(); | |
7997 | } | |
8ec526a4 | 7998 | |
77566f2a | 7999 | return rehist; |
8000 | ||
8001 | } | |
8002 | ||
8ec526a4 | 8003 | //_____________________________________________________________________________ |
8004 | TH1F *AliTRDCalibra::ReBin(TH1F *hist) const | |
77566f2a | 8005 | { |
8006 | // | |
8007 | // Rebin of the 1D histo for the gain calibration if needed | |
8008 | // you have to choose fRebin divider of fNumberBinCharge | |
8009 | // | |
8010 | ||
8ec526a4 | 8011 | TAxis *xhist = hist->GetXaxis(); |
8012 | TH1F *rehist = new TH1F("projrebin","",(Int_t) xhist->GetNbins()/fRebin | |
8013 | ,xhist->GetBinLowEdge(1) | |
8014 | ,xhist->GetBinUpEdge(xhist->GetNbins())); | |
8015 | ||
8016 | AliInfo(Form("fRebin: %d",fRebin)); | |
77566f2a | 8017 | Int_t i = 1; |
8ec526a4 | 8018 | for (Int_t k = 1; k <= (Int_t) xhist->GetNbins()/fRebin; k++) { |
77566f2a | 8019 | Double_t sum = 0.0; |
8ec526a4 | 8020 | for (Int_t ji = i; ji < i+fRebin; ji++) { |
77566f2a | 8021 | sum += hist->GetBinContent(ji); |
8022 | } | |
8023 | sum = sum/fRebin; | |
8024 | rehist->SetBinContent(k,sum); | |
8ec526a4 | 8025 | i += fRebin; |
77566f2a | 8026 | } |
8ec526a4 | 8027 | |
8028 | if (fDebug == 2) { | |
77566f2a | 8029 | TCanvas *crebin = new TCanvas("crebin","",50,50,600,800); |
8030 | crebin->cd(); | |
8031 | rehist->Draw(); | |
8032 | } | |
8033 | ||
8034 | return rehist; | |
8035 | ||
8036 | } | |
8ec526a4 | 8037 | |
8038 | //_____________________________________________________________________________ | |
77566f2a | 8039 | TH1F *AliTRDCalibra::CorrectTheError(TGraphErrors *hist) |
8040 | { | |
8041 | // | |
8042 | // In the case of the vectors method the trees contains TGraphErrors for PH and PRF | |
8043 | // to be able to add them after | |
8044 | // We convert it to a TH1F to be able to applied the same fit function method | |
8045 | // After having called this function you can not add the statistics anymore | |
8046 | // | |
8047 | ||
8ec526a4 | 8048 | TH1F *rehist = 0x0; |
77566f2a | 8049 | |
8ec526a4 | 8050 | Int_t nbins = hist->GetN(); |
8051 | Double_t *x = hist->GetX(); | |
77566f2a | 8052 | Double_t *entries = hist->GetEX(); |
8ec526a4 | 8053 | Double_t *mean = hist->GetY(); |
8054 | Double_t *square = hist->GetEY(); | |
8055 | fEntriesCurrent = 0; | |
77566f2a | 8056 | |
8ec526a4 | 8057 | if (nbins < 2) { |
8058 | return rehist; | |
8059 | } | |
77566f2a | 8060 | |
8ec526a4 | 8061 | Double_t step = x[1] - x[0]; |
8062 | Double_t minvalue = x[0] - step/2; | |
8063 | Double_t maxvalue = x[(nbins-1)] + step/2; | |
77566f2a | 8064 | |
8065 | rehist = new TH1F("projcorrecterror","",nbins,minvalue,maxvalue); | |
8066 | ||
8ec526a4 | 8067 | for (Int_t k = 0; k < nbins; k++) { |
77566f2a | 8068 | rehist->SetBinContent(k+1,mean[k]); |
8ec526a4 | 8069 | if (entries[k] > 0.0) { |
77566f2a | 8070 | fEntriesCurrent += (Int_t) entries[k]; |
8ec526a4 | 8071 | Double_t d = TMath::Abs(square[k] - (mean[k]*mean[k])); |
77566f2a | 8072 | rehist->SetBinError(k+1,TMath::Sqrt(d/entries[k])); |
8073 | } | |
8ec526a4 | 8074 | else { |
8075 | rehist->SetBinError(k+1,0.0); | |
8076 | } | |
77566f2a | 8077 | } |
8ec526a4 | 8078 | |
8079 | return rehist; | |
77566f2a | 8080 | |
8081 | } | |
8ec526a4 | 8082 | |
8083 | //_____________________________________________________________________________ | |
8084 | TGraphErrors *AliTRDCalibra::AddProfiles(TGraphErrors *hist1 | |
8085 | , TGraphErrors *hist2) const | |
77566f2a | 8086 | { |
8087 | // | |
8088 | // In the case of the vectors method we use TGraphErrors for PH and PRF | |
8089 | // to be able to add the them after | |
8090 | // Here we add the TGraphErrors | |
8ec526a4 | 8091 | // |
77566f2a | 8092 | |
8ec526a4 | 8093 | // First TGraphErrors |
8094 | Int_t nbins1 = hist1->GetN(); | |
8095 | Double_t *x1 = hist1->GetX(); | |
8096 | Double_t *ex1 = hist1->GetEX(); | |
8097 | Double_t *y1 = hist1->GetY(); | |
8098 | Double_t *ey1 = hist1->GetEY(); | |
77566f2a | 8099 | |
8ec526a4 | 8100 | TGraphErrors *rehist = new TGraphErrors(nbins1); |
77566f2a | 8101 | |
8ec526a4 | 8102 | // Second TGraphErrors |
8103 | Double_t *ex2 = hist2->GetEX(); | |
8104 | Double_t *y2 = hist2->GetY(); | |
8105 | Double_t *ey2 = hist2->GetEY(); | |
77566f2a | 8106 | |
8ec526a4 | 8107 | // Define the Variables for the new TGraphErrors |
8108 | Double_t x; | |
8109 | Double_t ex; | |
8110 | Double_t y; | |
8111 | Double_t ey; | |
8112 | ||
8113 | for (Int_t k = 0; k < nbins1; k++) { | |
8114 | Double_t nentries = 0.0; | |
8115 | x = x1[k]; | |
8116 | y = 0.0; | |
8117 | ey = 0.0; | |
8118 | ex = 0.0; | |
8119 | if ((ex2[k] == 0.0) && | |
8120 | (ex1[k] == 0.0)) { | |
8121 | nentries = 0.0; | |
8122 | } | |
8123 | if ((ex2[k] == 0.0) && | |
8124 | (ex1[k] > 0.0)) { | |
8125 | nentries = ex1[k]; | |
8126 | y = y1[k]; | |
8127 | ey = ey1[k]; | |
8128 | ex = ex1[k]; | |
8129 | } | |
8130 | if ((ex2[k] > 0.0) && | |
8131 | (ex1[k] == 0.0)) { | |
8132 | nentries = ex2[k]; | |
8133 | y = y2[k]; | |
8134 | ey = ey2[k]; | |
8135 | ex = ex2[k]; | |
8136 | } | |
8137 | if ((ex2[k] > 0.0) && | |
8138 | (ex1[k] > 0.0)) { | |
8139 | nentries = ex1[k] + ex2[k]; | |
8140 | y = ( y1[k]*ex1[k]+ y2[k]*ex2[k]) / nentries; | |
8141 | ey = (ey1[k]*ex1[k]+ey2[k]*ex2[k]) / nentries; | |
77566f2a | 8142 | ex = nentries; |
8143 | } | |
8144 | rehist->SetPoint(k,x,y); | |
8145 | rehist->SetPointError(k,ex,ey); | |
77566f2a | 8146 | } |
8147 | ||
77566f2a | 8148 | return rehist; |
77566f2a | 8149 | |
8ec526a4 | 8150 | } |
77566f2a | 8151 | |
8ec526a4 | 8152 | // |
8153 | //____________Some basic geometry function_____________________________________ | |
8154 | // | |
77566f2a | 8155 | |
8156 | //_____________________________________________________________________________ | |
8157 | Int_t AliTRDCalibra::GetPlane(Int_t d) const | |
8158 | { | |
8159 | // | |
8ec526a4 | 8160 | // Reconstruct the plane number from the detector number |
77566f2a | 8161 | // |
8162 | ||
8163 | return ((Int_t) (d % 6)); | |
8164 | ||
8165 | } | |
8166 | ||
8167 | //_____________________________________________________________________________ | |
8168 | Int_t AliTRDCalibra::GetChamber(Int_t d) const | |
8169 | { | |
8170 | // | |
8ec526a4 | 8171 | // Reconstruct the chamber number from the detector number |
77566f2a | 8172 | // |
8173 | Int_t fgkNplan = 6; | |
8174 | ||
8175 | return ((Int_t) (d % 30) / fgkNplan); | |
8176 | ||
8177 | } | |
8178 | ||
8179 | //_____________________________________________________________________________ | |
8180 | Int_t AliTRDCalibra::GetSector(Int_t d) const | |
8181 | { | |
8182 | // | |
8ec526a4 | 8183 | // Reconstruct the sector number from the detector number |
77566f2a | 8184 | // |
8185 | Int_t fg = 30; | |
8186 | ||
8187 | return ((Int_t) (d / fg)); | |
8188 | ||
8189 | } | |
8190 | ||
8ec526a4 | 8191 | // |
8192 | //____________Fill and Init tree Gain, PRF, Vdrift and T0______________________ | |
8193 | // | |
77566f2a | 8194 | |
8195 | //_____________________________________________________________________________ | |
8ec526a4 | 8196 | void AliTRDCalibra::InitTreePRF() |
77566f2a | 8197 | { |
8198 | // | |
8199 | // Init the tree where the coefficients from the fit methods can be stored | |
8200 | // | |
8ec526a4 | 8201 | |
8202 | gDirectory = gROOT; | |
8203 | fPRFPad = new Float_t[2304]; | |
8204 | fPRF = new TTree("PRF","PRF"); | |
77566f2a | 8205 | fPRF->Branch("detector",&fPRFDetector,"detector/I"); |
8ec526a4 | 8206 | fPRF->Branch("width" ,fPRFPad ,"width[2304]/F"); |
8207 | ||
8208 | // Set to default value for the plane 0 supposed to be the first one | |
8209 | for (Int_t k = 0; k < 2304; k++) { | |
77566f2a | 8210 | fPRFPad[k] = 0.515; |
8211 | } | |
8212 | fPRFDetector = -1; | |
8213 | ||
77566f2a | 8214 | } |
8ec526a4 | 8215 | |
77566f2a | 8216 | //_____________________________________________________________________________ |
8ec526a4 | 8217 | void AliTRDCalibra::FillTreePRF(Int_t countdet) |
77566f2a | 8218 | { |
8219 | // | |
8220 | // Fill the tree with the sigma of the pad response function for the detector countdet | |
8221 | // | |
8222 | ||
8223 | Int_t numberofgroup = 0; | |
8224 | fPRFDetector = countdet; | |
8225 | fPRF->Fill(); | |
8ec526a4 | 8226 | |
8227 | if (GetChamber((Int_t)(countdet+1)) == 2) { | |
8228 | numberofgroup = 1728; | |
8229 | } | |
8230 | else { | |
8231 | numberofgroup = 2304; | |
8232 | } | |
8233 | ||
8234 | // Reset to default value for the next | |
8235 | for (Int_t k = 0; k < numberofgroup; k++) { | |
8236 | if (GetPlane((Int_t) (countdet+1)) == 0) { | |
8237 | fPRFPad[k] = 0.515; | |
8238 | } | |
8239 | if (GetPlane((Int_t) (countdet+1)) == 1) { | |
8240 | fPRFPad[k] = 0.502; | |
8241 | } | |
8242 | if (GetPlane((Int_t) (countdet+1)) == 2) { | |
8243 | fPRFPad[k] = 0.491; | |
8244 | } | |
8245 | if (GetPlane((Int_t) (countdet+1)) == 3) { | |
8246 | fPRFPad[k] = 0.481; | |
8247 | } | |
8248 | if (GetPlane((Int_t) (countdet+1)) == 4) { | |
8249 | fPRFPad[k] = 0.471; | |
8250 | } | |
8251 | if (GetPlane((Int_t) (countdet+1)) == 5) { | |
8252 | fPRFPad[k] = 0.463; | |
8253 | } | |
77566f2a | 8254 | } |
8ec526a4 | 8255 | |
77566f2a | 8256 | fPRFDetector = -1; |
8257 | ||
8258 | } | |
8259 | ||
8260 | //_____________________________________________________________________________ | |
8261 | void AliTRDCalibra::ConvertVectorFitCHTree() | |
8262 | { | |
8263 | // | |
8ec526a4 | 8264 | // Convert the vector stuff to a tree of 1D histos if the user |
8265 | // want to write it after the fill functions | |
77566f2a | 8266 | // |
8ec526a4 | 8267 | |
8268 | Int_t detector = -1; | |
8269 | Int_t numberofgroup = 1; | |
77566f2a | 8270 | Float_t gainPad[2304]; |
8ec526a4 | 8271 | |
77566f2a | 8272 | fGain = new TTree("Gain","Gain"); |
8273 | fGain->Branch("detector",&detector,"detector/I"); | |
8ec526a4 | 8274 | fGain->Branch("gainPad" ,gainPad ,"gainPad[2304]/F"); |
8275 | ||
8276 | Int_t loop = (Int_t) fVectorFitCH->GetEntriesFast(); | |
8277 | for (Int_t k = 0; k < loop; k++) { | |
8278 | detector = ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetDetector(); | |
8279 | if (GetChamber((Int_t) ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetDetector()) == 2) { | |
8280 | numberofgroup = 1728; | |
8281 | } | |
8282 | else { | |
8283 | numberofgroup = 2304; | |
8284 | } | |
8285 | for (Int_t i = 0; i < numberofgroup; i++) { | |
8286 | if (((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetCoef()[i] >= 0) { | |
8287 | gainPad[i] = ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetCoef()[i] * fScaleFitFactor; | |
8288 | } | |
77566f2a | 8289 | else { |
8ec526a4 | 8290 | gainPad[i] = (Float_t) ((AliTRDFitCHInfo *) fVectorFitCH->At(k))->GetCoef()[i]; |
77566f2a | 8291 | } |
8292 | } | |
8293 | fGain->Fill(); | |
8294 | } | |
77566f2a | 8295 | |
8296 | } | |
8ec526a4 | 8297 | |
77566f2a | 8298 | //_____________________________________________________________________________ |
8ec526a4 | 8299 | void AliTRDCalibra::FillTreeVdrift(Int_t countdet) |
77566f2a | 8300 | { |
8301 | // | |
8302 | // Fill the tree with the drift velocities for the detector countdet | |
8303 | // | |
8ec526a4 | 8304 | |
77566f2a | 8305 | Int_t numberofgroup = 0; |
8306 | fVdriftDetector = countdet; | |
9f4780aa | 8307 | |
77566f2a | 8308 | fVdrift->Fill(); |
8ec526a4 | 8309 | if (GetChamber((Int_t)(countdet+1)) == 2) { |
8310 | numberofgroup = 1728; | |
8311 | } | |
8312 | else { | |
8313 | numberofgroup = 2304; | |
8314 | } | |
8315 | // Reset to default value the gain coef | |
8316 | for (Int_t k = 0; k < numberofgroup; k++) { | |
77566f2a | 8317 | fVdriftPad[k] = -1.5; |
8318 | } | |
8319 | fVdriftDetector = -1; | |
8320 | ||
8321 | } | |
8322 | ||
8323 | //_____________________________________________________________________________ | |
8ec526a4 | 8324 | void AliTRDCalibra::InitTreePH() |
77566f2a | 8325 | { |
8326 | // | |
8327 | // Init the tree where the coefficients from the fit methods can be stored | |
8328 | // | |
8329 | ||
8ec526a4 | 8330 | gDirectory = gROOT; |
77566f2a | 8331 | fVdriftPad = new Float_t[2304]; |
8ec526a4 | 8332 | fVdrift = new TTree("Vdrift","Vdrift"); |
77566f2a | 8333 | fVdrift->Branch("detector",&fVdriftDetector,"detector/I"); |
8ec526a4 | 8334 | fVdrift->Branch("vdrift" ,fVdriftPad ,"vdrift[2304]/F"); |
8335 | // Set to default value for the plane 0 supposed to be the first one | |
8336 | for (Int_t k = 0; k < 2304; k++) { | |
77566f2a | 8337 | fVdriftPad[k] = -1.5; |
8338 | } | |
8339 | fVdriftDetector = -1; | |
8340 | ||
8341 | } | |
8ec526a4 | 8342 | |
77566f2a | 8343 | //_____________________________________________________________________________ |
8ec526a4 | 8344 | void AliTRDCalibra::FillTreeT0(Int_t countdet) |
77566f2a | 8345 | { |
8346 | // | |
8347 | // Fill the tree with the t0 value for the detector countdet | |
8348 | // | |
8ec526a4 | 8349 | |
77566f2a | 8350 | Int_t numberofgroup = 0; |
8ec526a4 | 8351 | |
77566f2a | 8352 | fT0Detector = countdet; |
9f4780aa | 8353 | |
77566f2a | 8354 | fT0->Fill(); |
8ec526a4 | 8355 | if (GetChamber((Int_t) (countdet+1)) == 2) { |
8356 | numberofgroup = 1728; | |
8357 | } | |
8358 | else { | |
8359 | numberofgroup = 2304; | |
8360 | } | |
9f4780aa | 8361 | // Reset to default value |
8ec526a4 | 8362 | for (Int_t k = 0; k < numberofgroup; k++) { |
77566f2a | 8363 | fT0Pad[k] = 0.0; |
8364 | } | |
8365 | fT0Detector = -1; | |
8366 | ||
8367 | } | |
8368 | ||
8369 | //_____________________________________________________________________________ | |
8ec526a4 | 8370 | void AliTRDCalibra::InitTreeT0() |
77566f2a | 8371 | { |
8372 | // | |
8373 | // Init the tree where the coefficients from the fit methods can be stored | |
8374 | // | |
8375 | ||
8ec526a4 | 8376 | gDirectory = gROOT; |
77566f2a | 8377 | fT0Pad = new Float_t[2304]; |
8378 | fT0 = new TTree("T0","T0"); | |
8379 | fT0->Branch("detector",&fT0Detector,"detector/I"); | |
8380 | fT0->Branch("t0",fT0Pad,"t0[2304]/F"); | |
8381 | //Set to default value for the plane 0 supposed to be the first one | |
8382 | for(Int_t k = 0; k < 2304; k++){ | |
8383 | fT0Pad[k] = 0.0; | |
8384 | } | |
8385 | fT0Detector = -1; | |
8386 | ||
8387 | } | |
8388 | ||
8ec526a4 | 8389 | // |
8390 | //____________Private Functions________________________________________________ | |
8391 | // | |
77566f2a | 8392 | |
8ec526a4 | 8393 | //_____________________________________________________________________________ |
8394 | Double_t AliTRDCalibra::PH(Double_t *x, Double_t *par) | |
77566f2a | 8395 | { |
8396 | // | |
8397 | // Function for the fit | |
8398 | // | |
8399 | ||
8ec526a4 | 8400 | //TF1 *fAsymmGauss = new TF1("fAsymmGauss",AsymmGauss,0,4,6); |
77566f2a | 8401 | |
8402 | //PARAMETERS FOR FIT PH | |
8403 | // PASAv.4 | |
8ec526a4 | 8404 | //fAsymmGauss->SetParameter(0,0.113755); |
8405 | //fAsymmGauss->SetParameter(1,0.350706); | |
8406 | //fAsymmGauss->SetParameter(2,0.0604244); | |
8407 | //fAsymmGauss->SetParameter(3,7.65596); | |
8408 | //fAsymmGauss->SetParameter(4,1.00124); | |
8409 | //fAsymmGauss->SetParameter(5,0.870597); // No tail cancelation | |
77566f2a | 8410 | |
8411 | Double_t xx = x[0]; | |
8412 | ||
8ec526a4 | 8413 | if (xx < par[1]) { |
8414 | return par[5]; | |
8415 | } | |
8416 | ||
8417 | Double_t dx = 0.005; | |
8418 | Double_t xs = par[1]; | |
8419 | Double_t ss = 0.0; | |
8420 | Double_t paras[2] = { 0.0, 0.0 }; | |
77566f2a | 8421 | |
77566f2a | 8422 | while (xs < xx) { |
8ec526a4 | 8423 | if ((xs >= par[1]) && |
8424 | (xs < (par[1]+par[2]))) { | |
77566f2a | 8425 | //fAsymmGauss->SetParameter(0,par[0]); |
8426 | //fAsymmGauss->SetParameter(1,xs); | |
8427 | //ss += fAsymmGauss->Eval(xx); | |
8428 | paras[0] = par[0]; | |
8429 | paras[1] = xs; | |
8430 | ss += AsymmGauss(&xx,paras); | |
8431 | } | |
8ec526a4 | 8432 | if ((xs >= (par[1]+par[2])) && |
8433 | (xs < (par[1]+par[2]+par[3]))) { | |
77566f2a | 8434 | //fAsymmGauss->SetParameter(0,par[0]*par[4]); |
8435 | //fAsymmGauss->SetParameter(1,xs); | |
8436 | //ss += fAsymmGauss->Eval(xx); | |
8437 | paras[0] = par[0]*par[4]; | |
8438 | paras[1] = xs; | |
8439 | ss += AsymmGauss(&xx,paras); | |
8440 | } | |
8441 | xs += dx; | |
8442 | } | |
8443 | ||
8ec526a4 | 8444 | return ss + par[5]; |
77566f2a | 8445 | |
8446 | } | |
8447 | ||
8ec526a4 | 8448 | //_____________________________________________________________________________ |
8449 | Double_t AliTRDCalibra::AsymmGauss(Double_t *x, Double_t *par) | |
77566f2a | 8450 | { |
8451 | // | |
8452 | // Function for the fit | |
8453 | // | |
8454 | ||
8455 | //par[0] = normalization | |
8456 | //par[1] = mean | |
8457 | //par[2] = sigma | |
8458 | //norm0 = 1 | |
8459 | //par[3] = lambda0 | |
8460 | //par[4] = norm1 | |
8461 | //par[5] = lambda1 | |
77566f2a | 8462 | |
8463 | Double_t par1save = par[1]; | |
8464 | //Double_t par2save = par[2]; | |
8465 | Double_t par2save = 0.0604244; | |
8466 | //Double_t par3save = par[3]; | |
8467 | Double_t par3save = 7.65596; | |
8468 | //Double_t par5save = par[5]; | |
8469 | Double_t par5save = 0.870597; | |
8ec526a4 | 8470 | Double_t dx = x[0] - par1save; |
77566f2a | 8471 | |
8ec526a4 | 8472 | Double_t sigma2 = par2save*par2save; |
8473 | Double_t sqrt2 = TMath::Sqrt(2.0); | |
8474 | Double_t exp1 = par3save * TMath::Exp(-par3save * (dx - 0.5 * par3save * sigma2)) | |
8475 | * (1.0 - TMath::Erf((par3save * sigma2 - dx) / (sqrt2 * par2save))); | |
8476 | Double_t exp2 = par5save * TMath::Exp(-par5save * (dx - 0.5 * par5save * sigma2)) | |
8477 | * (1.0 - TMath::Erf((par5save * sigma2 - dx) / (sqrt2 * par2save))); | |
77566f2a | 8478 | |
8479 | //return par[0]*(exp1+par[4]*exp2); | |
8ec526a4 | 8480 | return par[0] * (exp1 + 1.00124 * exp2); |
77566f2a | 8481 | |
8ec526a4 | 8482 | } |
77566f2a | 8483 | |
8ec526a4 | 8484 | //_____________________________________________________________________________ |
8485 | Double_t AliTRDCalibra::FuncLandauGaus(Double_t *x, Double_t *par) | |
77566f2a | 8486 | { |
8487 | // | |
8ec526a4 | 8488 | // Sum Landau + Gaus with identical mean |
77566f2a | 8489 | // |
8490 | ||
8ec526a4 | 8491 | Double_t valLandau = par[0] * TMath::Landau(x[0],par[1],par[2]); |
8492 | //Double_t valGaus = par[3] * TMath::Gaus(x[0],par[4],par[5]); | |
8493 | Double_t valGaus = par[3] * TMath::Gaus(x[0],par[1],par[4]); | |
8494 | Double_t val = valLandau + valGaus; | |
77566f2a | 8495 | |
77566f2a | 8496 | return val; |
8ec526a4 | 8497 | |
77566f2a | 8498 | } |
8ec526a4 | 8499 | |
8500 | //_____________________________________________________________________________ | |
8501 | Double_t AliTRDCalibra::LanGauFun(Double_t *x, Double_t *par) | |
77566f2a | 8502 | { |
8503 | // | |
8504 | // Function for the fit | |
8505 | // | |
8ec526a4 | 8506 | // Fit parameters: |
8507 | // par[0]=Width (scale) parameter of Landau density | |
8508 | // par[1]=Most Probable (MP, location) parameter of Landau density | |
8509 | // par[2]=Total area (integral -inf to inf, normalization constant) | |
8510 | // par[3]=Width (sigma) of convoluted Gaussian function | |
77566f2a | 8511 | // |
8ec526a4 | 8512 | // In the Landau distribution (represented by the CERNLIB approximation), |
8513 | // the maximum is located at x=-0.22278298 with the location parameter=0. | |
8514 | // This shift is corrected within this function, so that the actual | |
8515 | // maximum is identical to the MP parameter. | |
8516 | // | |
8517 | ||
77566f2a | 8518 | // Numeric constants |
8519 | Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2) | |
8520 | Double_t mpshift = -0.22278298; // Landau maximum location | |
8521 | ||
8522 | // Control constants | |
8ec526a4 | 8523 | Double_t np = 100.0; // Number of convolution steps |
8524 | Double_t sc = 5.0; // Convolution extends to +-sc Gaussian sigmas | |
77566f2a | 8525 | |
8526 | // Variables | |
8527 | Double_t xx; | |
8528 | Double_t mpc; | |
8529 | Double_t fland; | |
8530 | Double_t sum = 0.0; | |
8ec526a4 | 8531 | Double_t xlow; |
8532 | Double_t xupp; | |
77566f2a | 8533 | Double_t step; |
8534 | Double_t i; | |
8535 | ||
77566f2a | 8536 | // MP shift correction |
8537 | mpc = par[1] - mpshift * par[0]; | |
8ec526a4 | 8538 | |
77566f2a | 8539 | // Range of convolution integral |
8540 | xlow = x[0] - sc * par[3]; | |
8541 | xupp = x[0] + sc * par[3]; | |
8542 | ||
8ec526a4 | 8543 | step = (xupp - xlow) / np; |
8544 | ||
77566f2a | 8545 | // Convolution integral of Landau and Gaussian by sum |
8ec526a4 | 8546 | for (i = 1.0; i <= np/2; i++) { |
8547 | ||
8548 | xx = xlow + (i-.5) * step; | |
77566f2a | 8549 | fland = TMath::Landau(xx,mpc,par[0]) / par[0]; |
8ec526a4 | 8550 | sum += fland * TMath::Gaus(x[0],xx,par[3]); |
77566f2a | 8551 | |
8ec526a4 | 8552 | xx = xupp - (i-.5) * step; |
77566f2a | 8553 | fland = TMath::Landau(xx,mpc,par[0]) / par[0]; |
8ec526a4 | 8554 | sum += fland * TMath::Gaus(x[0],xx,par[3]); |
8555 | ||
77566f2a | 8556 | } |
8ec526a4 | 8557 | |
77566f2a | 8558 | return (par[2] * step * sum * invsq2pi / par[3]); |
8ec526a4 | 8559 | |
77566f2a | 8560 | } |
8ec526a4 | 8561 | |
8562 | //_____________________________________________________________________________ | |
8563 | TF1 *AliTRDCalibra::LanGauFit(TH1 *his, Double_t *fitrange, Double_t *startvalues | |
8564 | , Double_t *parlimitslo, Double_t *parlimitshi | |
8565 | , Double_t *fitparams, Double_t *fiterrors | |
8566 | , Double_t *chiSqr, Int_t *ndf) | |
77566f2a | 8567 | { |
8568 | // | |
8569 | // Function for the fit | |
8570 | // | |
8571 | ||
77566f2a | 8572 | Int_t i; |
8ec526a4 | 8573 | Char_t funname[100]; |
77566f2a | 8574 | |
8ec526a4 | 8575 | AliInfo(Form(funname,"Fitfcn_%s",his->GetName())); |
77566f2a | 8576 | |
8ec526a4 | 8577 | TF1 *ffitold = (TF1 *) gROOT->GetListOfFunctions()->FindObject(funname); |
8578 | if (ffitold) { | |
8579 | delete ffitold; | |
8580 | } | |
8581 | ||
8582 | TF1 *ffit = new TF1(funname,LanGauFun,fitrange[0],fitrange[1],4); | |
77566f2a | 8583 | ffit->SetParameters(startvalues); |
8584 | ffit->SetParNames("Width","MP","Area","GSigma"); | |
8585 | ||
8ec526a4 | 8586 | for (i = 0; i < 4; i++) { |
8587 | ffit->SetParLimits(i,parlimitslo[i],parlimitshi[i]); | |
77566f2a | 8588 | } |
8589 | ||
8ec526a4 | 8590 | his->Fit(funname,"RB0"); // Fit within specified range, use ParLimits, do not plot |
77566f2a | 8591 | |
8ec526a4 | 8592 | ffit->GetParameters(fitparams); // Obtain fit parameters |
8593 | for (i = 0; i < 4; i++) { | |
8594 | fiterrors[i] = ffit->GetParError(i); // Obtain fit parameter errors | |
8595 | } | |
8596 | chiSqr[0] = ffit->GetChisquare(); // Obtain chi^2 | |
8597 | ndf[0] = ffit->GetNDF(); // Obtain ndf | |
77566f2a | 8598 | |
8ec526a4 | 8599 | return (ffit); // Return fit function |
77566f2a | 8600 | |
8601 | } | |
8ec526a4 | 8602 | |
8603 | //_____________________________________________________________________________ | |
8604 | Int_t AliTRDCalibra::LanGauPro(Double_t *params, Double_t &maxx, Double_t &fwhm) | |
8605 | { | |
77566f2a | 8606 | // |
8607 | // Function for the fit | |
8608 | // | |
8ec526a4 | 8609 | |
8610 | Double_t p; | |
8611 | Double_t x; | |
8612 | Double_t fy; | |
8613 | Double_t fxr; | |
8614 | Double_t fxl; | |
77566f2a | 8615 | Double_t step; |
8ec526a4 | 8616 | Double_t l; |
8617 | Double_t lold; | |
8618 | ||
8619 | Int_t i = 0; | |
8620 | Int_t maxcalls = 10000; | |
77566f2a | 8621 | |
8622 | // Search for maximum | |
8ec526a4 | 8623 | p = params[1] - 0.1 * params[0]; |
77566f2a | 8624 | step = 0.05 * params[0]; |
8625 | lold = -2.0; | |
8626 | l = -1.0; | |
8627 | ||
8ec526a4 | 8628 | while ((l != lold) && (i < maxcalls)) { |
77566f2a | 8629 | i++; |
77566f2a | 8630 | lold = l; |
8ec526a4 | 8631 | x = p + step; |
8632 | l = LanGauFun(&x,params); | |
8633 | if (l < lold) { | |
8634 | step = -step / 10.0; | |
8635 | } | |
77566f2a | 8636 | p += step; |
8637 | } | |
8638 | ||
8ec526a4 | 8639 | if (i == maxcalls) { |
77566f2a | 8640 | return (-1); |
8ec526a4 | 8641 | } |
77566f2a | 8642 | maxx = x; |
8ec526a4 | 8643 | fy = l / 2.0; |
77566f2a | 8644 | |
8ec526a4 | 8645 | // Search for right x location of fy |
8646 | p = maxx + params[0]; | |
77566f2a | 8647 | step = params[0]; |
8648 | lold = -2.0; | |
8649 | l = -1e300; | |
8650 | i = 0; | |
8651 | ||
8ec526a4 | 8652 | while ( (l != lold) && (i < maxcalls) ) { |
77566f2a | 8653 | i++; |
8654 | ||
8655 | lold = l; | |
8656 | x = p + step; | |
8ec526a4 | 8657 | l = TMath::Abs(LanGauFun(&x,params) - fy); |
77566f2a | 8658 | |
8659 | if (l > lold) | |
8660 | step = -step/10; | |
8661 | ||
8662 | p += step; | |
8663 | } | |
8664 | ||
8ec526a4 | 8665 | if (i == maxcalls) |
77566f2a | 8666 | return (-2); |
8667 | ||
8668 | fxr = x; | |
8669 | ||
8670 | ||
8671 | // Search for left x location of fy | |
8672 | ||
8673 | p = maxx - 0.5 * params[0]; | |
8674 | step = -params[0]; | |
8675 | lold = -2.0; | |
8ec526a4 | 8676 | l = -1.0e300; |
77566f2a | 8677 | i = 0; |
8678 | ||
8ec526a4 | 8679 | while ((l != lold) && (i < maxcalls)) { |
77566f2a | 8680 | i++; |
77566f2a | 8681 | lold = l; |
8ec526a4 | 8682 | x = p + step; |
8683 | l = TMath::Abs(LanGauFun(&x,params) - fy); | |
8684 | if (l > lold) { | |
8685 | step = -step / 10.0; | |
8686 | } | |
77566f2a | 8687 | p += step; |
8688 | } | |
8689 | ||
8ec526a4 | 8690 | if (i == maxcalls) { |
8691 | return (-3); | |
8692 | } | |
77566f2a | 8693 | |
8ec526a4 | 8694 | fxl = x; |
8695 | fwhm = fxr - fxl; | |
77566f2a | 8696 | |
8ec526a4 | 8697 | return (0); |
77566f2a | 8698 | |
8ec526a4 | 8699 | } |