Line data Source code
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 : // *
17 : // *
18 : // * AliTOFcalibHisto - class to handle TOF calibration histograms,
19 : // * map histograms and more
20 : // *
21 : // *
22 : // * autors: Roberto Preghenella (R+)
23 : // * concacts: preghenella@bo.infn.it
24 : // *
25 : // *
26 :
27 : #include "AliTOFcalibHisto.h"
28 : #include "AliLog.h"
29 : #include "TH1D.h"
30 : #include "TFile.h"
31 : #include "AliTOFRawStream.h"
32 : #include "AliTOFCableLengthMap.h"
33 : #include "AliESDtrack.h"
34 :
35 : #define SLEW_TOTMIN 10.
36 : #define SLEW_TOTMAX 16.
37 :
38 26 : ClassImp(AliTOFcalibHisto)
39 :
40 : //__________________________________________________________________________
41 :
42 : TFile *AliTOFcalibHisto::fgCalibHistoFile = NULL;
43 : TFile *AliTOFcalibHisto::fgCalibParFile = NULL;
44 : TFile *AliTOFcalibHisto::fgCalibStatFile = NULL;
45 :
46 : //__________________________________________________________________________
47 :
48 26 : TString AliTOFcalibHisto::fgCalibHistoFileName = "$ALICE_ROOT/TOF/data/AliTOFcalibHisto.root";
49 26 : TString AliTOFcalibHisto::fgCalibParFileName = "$ALICE_ROOT/TOF/data/AliTOFcalibPar.root";
50 26 : TString AliTOFcalibHisto::fgCalibStatFileName = "$ALICE_ROOT/TOF/data/AliTOFcalibStat.root";
51 :
52 : //__________________________________________________________________________
53 :
54 13 : const TString AliTOFcalibHisto::fgkCalibConstName[kNcalibConsts] = {
55 26 : "LHCperiod",
56 13 : "AmphenolCableDelay",
57 13 : "FlatCableDelay",
58 117 : "InterfaceCardDelay"
59 : };
60 :
61 : //__________________________________________________________________________
62 :
63 13 : const TString AliTOFcalibHisto::fgkCalibMapName[kNcalibMaps] = {
64 : /* main index */
65 26 : "Index",
66 : /* EO indices */
67 13 : "DDL",
68 13 : "TRM",
69 13 : "Chain",
70 13 : "TDC",
71 13 : "Channel",
72 : /* DO indices */
73 13 : "Sector",
74 13 : "Plate",
75 13 : "Strip",
76 13 : "SectorStrip",
77 13 : "PadZ",
78 13 : "PadX",
79 13 : "Pad",
80 13 : "InterfaceCardIndex",
81 : /* calib constants */
82 13 : "DDLBCshift",
83 13 : "FlatCableLength",
84 13 : "InterfaceCardLength",
85 299 : "AmphenolCableLength"
86 : };
87 :
88 : //__________________________________________________________________________
89 :
90 13 : const TString AliTOFcalibHisto::fgkCalibParName[kNcalibPars] = {
91 26 : "hDDLDelay",
92 13 : "hHPTDCDelay",
93 13 : "hLeftFEAchDelay",
94 13 : "hRightFEAchDelay",
95 13 : "hFEADelay",
96 13 : "hICDelay",
97 13 : "hTRMDelay",
98 13 : "hStripDelay",
99 13 : "hIndexDelay",
100 195 : "hSlewing"
101 : };
102 :
103 : //__________________________________________________________________________
104 :
105 65 : const TString AliTOFcalibHisto::fgkCalibStatName[kNcalibStats] = {
106 26 : "hStripStat"
107 : };
108 :
109 : //__________________________________________________________________________
110 :
111 : /* LHC clock period [ns] */
112 : const Double_t AliTOFcalibHisto::fgkLHCperiod = (24.4e-3 * 1024); /* ns */
113 :
114 : //__________________________________________________________________________
115 :
116 : /* Amphenol cable delay [ns/cm] */
117 : const Double_t AliTOFcalibHisto::fgkAmphenolCableDelay = 5.13e-2; /* from measurement */
118 :
119 : //__________________________________________________________________________
120 :
121 : /* flat cable delay [ns/cm] */
122 : //const Double_t AliTOFcalibHisto::fgkFlatCableDelay = 5.3e-2; /* from Amphenol 132-2829 series data-sheet */
123 : const Double_t AliTOFcalibHisto::fgkFlatCableDelay = 5.124e-2; /* from LHC08d calibration */
124 :
125 : //__________________________________________________________________________
126 :
127 : /* interface card delay [ns/cm] */
128 : //const Double_t AliTOFcalibHisto::fgkInterfaceCardDelay = 6.9e-2; /* from HyperLinx simulation */
129 : //const Double_t AliTOFcalibHisto::fgkInterfaceCardDelay = 5.7898e-2; /* from LHC08d calibration */
130 : const Double_t AliTOFcalibHisto::fgkInterfaceCardDelay = 6.31360207815420404e-02; /* from LHC09c calibration */
131 :
132 : //__________________________________________________________________________
133 :
134 : /* number of readout channels (DO/EO) */
135 : const Int_t AliTOFcalibHisto::fgkNchannels = 157248;
136 : const Int_t AliTOFcalibHisto::fgkNchannelsEO = 172800;
137 :
138 : //__________________________________________________________________________
139 :
140 : /* DDL BC shifts due to TTC fibers [LHCperiod] */
141 : const Int_t AliTOFcalibHisto::fgkDDLBCshift[72] = {
142 : 2, 2, -1, -1,
143 : 2, 2, 0, 0,
144 : 2, 2, 0, 0,
145 : 2, 2, 0, 0,
146 : 2, 2, 0, 0,
147 : 2, 2, 0, 0,
148 : 2, 2, 0, 0,
149 : 2, 2, 0, 0,
150 : 2, 2, 0, 0,
151 : 2, 2, 0, 0,
152 : 2, 2, -1, -1,
153 : 2, 2, -1, -1,
154 : 2, 2, -2, -2,
155 : 2, 2, -2, -2,
156 : 2, 2, -2, -2,
157 : 2, 2, -1, -1,
158 : 2, 2, -1, -1,
159 : 2, 2, -1, -1
160 : };
161 :
162 : //__________________________________________________________________________
163 :
164 : /* strip flat-cable length (preliminary) [cm] */
165 : const Double_t AliTOFcalibHisto::fgkFlatCableLength[91] = {
166 : 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 17.,
167 : 21., 21., 21., 21., 21., 17., 17., 21., 21., 17., 21., 21., 21., 17., 21., 21., 17., 21., 23.,
168 : 17., 19., 17., 19., 17., 19., 17., 19., 17., 19., 17., 19., 17., 19., 17.,
169 : 23., 21., 17., 21., 21., 17., 21., 21., 21., 17., 21., 21., 17., 17., 21., 21., 21., 21., 21.,
170 : 17., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18.
171 : };
172 :
173 : //__________________________________________________________________________
174 :
175 : /* interface card lenght (preliminary) [cm] */
176 : const Double_t AliTOFcalibHisto::fgkInterfaceCardLength[48] = {
177 : 13.97, 12.57, 14.52, 13.10, 15.44, 13.60, 10.58, 9.14,
178 : 11.21, 9.76, 12.11, 10.76, 8.67, 7.58, 9.32, 8.09,
179 : 10.24, 8.4, 5.51, 4.31, 6.54, 5.23, 7.48, 6.28,
180 : 10.43, 8.76, 11.05, 9.43, 11.72, 10.14, 7.2, 5.69,
181 : 7.71, 6.26, 8.36, 7.19, 4.85, 4.09, 5.57, 4.35,
182 : 6.59, 5.12, 2.49, 2.96, 2.70, 2.76, 2.91, 2.55
183 : };
184 :
185 : //__________________________________________________________________________
186 :
187 : Bool_t AliTOFcalibHisto::fgCableCorrectionFlag[kNcorrections] = {
188 : kFALSE, // kDDLBCcorr
189 : kTRUE, // kAmphenolCableCorr
190 : kTRUE, // kFlatCableCorr
191 : kTRUE, // kInterfaceCardCorr
192 : kFALSE, // kDDLdelayCorr
193 : kFALSE, // kHPTDCdelayCorr
194 : kFALSE, // kFEAchDelayCorr
195 : kFALSE, // kFEAdelayCorr
196 : kFALSE, // kTRMdelayCorr
197 : kFALSE, // kICdelayCorr
198 : kFALSE, // kStripDelayCorr
199 : kFALSE, // kIndexDelayCorr
200 : kFALSE, // kTimeSlewingCorr
201 : };
202 :
203 : //__________________________________________________________________________
204 :
205 : Bool_t AliTOFcalibHisto::fgFullCorrectionFlag[kNcorrections] = {
206 : kFALSE, // kDDLBCcorr
207 : kTRUE, // kAmphenolCableCorr
208 : kTRUE, // kFlatCableCorr
209 : kTRUE, // kInterfaceCardCorr
210 : kTRUE, // kDDLdelayCorr
211 : kTRUE, // kHPTDCdelayCorr
212 : kTRUE, // kFEAchDelayCorr
213 : kTRUE, // kFEAdelayCorr
214 : kTRUE, // kTRMdelayCorr
215 : kFALSE, // kICdelayCorr
216 : kTRUE, // kStripDelayCorr
217 : kTRUE, // kIndexDelayCorr
218 : kTRUE, // kTimeSlewingCorr
219 : };
220 :
221 : //__________________________________________________________________________
222 :
223 : const Int_t AliTOFcalibHisto::fgkStripStat[18][91] = {
224 :
225 : {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
226 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
227 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
228 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
229 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* S00 */
230 :
231 : {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
232 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
233 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
234 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
235 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* S01 */
236 :
237 : {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
238 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
239 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
240 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
241 : 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
323 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
324 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
325 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* S16 */
326 :
327 : {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
328 : 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
329 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
330 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
331 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* S17 */
332 :
333 : };
334 :
335 : //__________________________________________________________________________
336 :
337 : AliTOFcalibHisto::AliTOFcalibHisto() :
338 0 : TObject(),
339 0 : fCalibConst(),
340 0 : fCalibMap(),
341 0 : fCalibPar(),
342 0 : fCalibStat()
343 0 : {
344 : /* default constructor */
345 0 : }
346 :
347 : //__________________________________________________________________________
348 :
349 : AliTOFcalibHisto::~AliTOFcalibHisto()
350 0 : {
351 : /* default destructor */
352 :
353 0 : if (fgCalibHistoFile && fgCalibHistoFile->IsOpen()) {
354 0 : fgCalibHistoFile->Close();
355 : }
356 0 : }
357 :
358 : //__________________________________________________________________________
359 :
360 : void
361 : AliTOFcalibHisto::LoadHisto(TFile * const file, TH1D **histo, const Char_t *name)
362 : {
363 : /* load histo */
364 0 : *histo = (TH1D *)file->Get(name);
365 0 : if (!*histo)
366 0 : AliWarning(Form("error while getting %s histo", name));
367 0 : }
368 :
369 : //__________________________________________________________________________
370 :
371 : void
372 : AliTOFcalibHisto::CreateHisto(TH1D **histo, const Char_t *name, Int_t size)
373 : {
374 : /* create histo */
375 0 : *histo = new TH1D(name, Form(";index;%s", name), size, 0, size);
376 0 : if (!*histo)
377 0 : AliWarning(Form("error while creating %s histo", name));
378 0 : }
379 :
380 : //__________________________________________________________________________
381 :
382 : void
383 : AliTOFcalibHisto::WriteHisto(TFile *file, TH1D *histo)
384 : {
385 : /* write histo */
386 0 : if (!file || !file->IsOpen() || !histo)
387 : return;
388 0 : file->cd();
389 0 : histo->Write();
390 0 : }
391 :
392 : //__________________________________________________________________________
393 :
394 : void
395 : AliTOFcalibHisto::SetHisto(TH1D *histo, Int_t index, Double_t value)
396 : {
397 : /* set histo */
398 0 : if (!histo)
399 : return;
400 0 : histo->SetBinContent(index + 1, value);
401 0 : }
402 :
403 : //__________________________________________________________________________
404 :
405 : Double_t
406 : AliTOFcalibHisto::GetHisto(TH1D *histo, Int_t index)
407 : {
408 : /* get histo */
409 0 : if (!histo) {
410 0 : AliWarning("cannot get histo");
411 0 : return 0.;
412 : }
413 0 : return histo->GetBinContent(index + 1);
414 0 : }
415 :
416 : //__________________________________________________________________________
417 :
418 : void
419 : AliTOFcalibHisto::LoadCalibHisto()
420 : {
421 : /* load calib histo */
422 :
423 0 : if (fgCalibHistoFile && fgCalibHistoFile->IsOpen()) {
424 0 : AliWarning("calib histo file already open: reloading");
425 0 : fgCalibHistoFile->Close();
426 0 : }
427 :
428 : /* open input file */
429 0 : TFile *fileIn = TFile::Open(GetCalibHistoFileName());
430 0 : if (!fileIn || !fileIn->IsOpen()) {
431 0 : AliFatal(Form("cannot open input file %s", GetCalibHistoFileName()));
432 0 : return;
433 : }
434 :
435 : /* set calib histo file */
436 0 : fgCalibHistoFile = fileIn;
437 :
438 : /* load consts */
439 0 : for (Int_t iConst = 0; iConst < kNcalibConsts; iConst++)
440 0 : LoadHisto(fileIn, &fCalibConst[iConst], fgkCalibConstName[iConst].Data());
441 : /* load maps */
442 0 : for (Int_t iMap = 0; iMap < kNcalibMaps; iMap++)
443 0 : LoadHisto(fileIn, &fCalibMap[iMap], fgkCalibMapName[iMap].Data());
444 0 : }
445 :
446 : //__________________________________________________________________________
447 :
448 : void
449 : AliTOFcalibHisto::LoadCalibPar()
450 : {
451 : /* load calib par */
452 :
453 0 : if (fgCalibParFile && fgCalibParFile->IsOpen())
454 0 : AliWarning("calib par file already open: reloading");
455 :
456 : /* load calib histo */
457 0 : LoadCalibHisto();
458 :
459 : /* open input file */
460 0 : TFile *fileIn = TFile::Open(GetCalibParFileName());
461 0 : if (!fileIn || !fileIn->IsOpen()) {
462 0 : AliError(Form("cannot open input file %s", GetCalibParFileName()));
463 0 : return;
464 : }
465 :
466 : /* set calib par file */
467 0 : fgCalibParFile = fileIn;
468 :
469 : /* load pars */
470 0 : for (Int_t i = 0; i < kNcalibPars; i++)
471 0 : LoadHisto(fileIn, &fCalibPar[i], fgkCalibParName[i].Data());
472 :
473 0 : }
474 :
475 : //__________________________________________________________________________
476 :
477 : void
478 : AliTOFcalibHisto::LoadCalibStat()
479 : {
480 : /* load calib stat */
481 :
482 0 : if (fgCalibStatFile && fgCalibStatFile->IsOpen())
483 0 : AliWarning("calib par file already open: reloading");
484 :
485 : /* load calib histo */
486 0 : LoadCalibHisto();
487 :
488 : /* open input file */
489 0 : TFile *fileIn = TFile::Open(GetCalibStatFileName());
490 0 : if (!fileIn || !fileIn->IsOpen()) {
491 0 : AliError(Form("cannot open input file %s", GetCalibStatFileName()));
492 0 : return;
493 : }
494 :
495 : /* set calib par file */
496 0 : fgCalibStatFile = fileIn;
497 :
498 : /* load pars */
499 0 : for (Int_t i = 0; i < kNcalibStats; i++)
500 0 : LoadHisto(fileIn, &fCalibStat[i], fgkCalibStatName[i].Data());
501 :
502 0 : }
503 :
504 : //__________________________________________________________________________
505 :
506 : void
507 : AliTOFcalibHisto::WriteCalibHisto()
508 : {
509 : /* write calib histo */
510 :
511 : /* open output file */
512 0 : TFile *fileOut = TFile::Open(GetCalibHistoFileName(), "RECREATE");
513 0 : if (!fileOut || !fileOut->IsOpen()) {
514 0 : AliFatal(Form("cannot open output file %s", GetCalibHistoFileName()));
515 0 : return;
516 : }
517 :
518 : /* create consts */
519 0 : for (Int_t iConst = 0; iConst < kNcalibConsts; iConst++)
520 0 : CreateHisto(&fCalibConst[iConst], fgkCalibConstName[iConst].Data(), 1);
521 : /* create maps */
522 0 : for (Int_t iMap = 0; iMap < kNcalibMaps; iMap++)
523 0 : if (iMap == kIndex)
524 0 : CreateHisto(&fCalibMap[iMap], fgkCalibMapName[iMap].Data(), fgkNchannelsEO);
525 : else
526 0 : CreateHisto(&fCalibMap[iMap], fgkCalibMapName[iMap].Data(), fgkNchannels);
527 :
528 : /*** SETUP CONSTS ***/
529 :
530 0 : SetHisto(fCalibConst[kLHCperiod], 0, fgkLHCperiod);
531 0 : SetHisto(fCalibConst[kAmphenolCableDelay], 0, fgkAmphenolCableDelay);
532 0 : SetHisto(fCalibConst[kFlatCableDelay], 0, fgkFlatCableDelay);
533 0 : SetHisto(fCalibConst[kInterfaceCardDelay], 0, fgkInterfaceCardDelay);
534 :
535 : /*** SETUP MAPS ***/
536 :
537 0 : AliTOFRawStream rawStream;
538 0 : Int_t indexEO, det[5], dummy, index, sector, plate, strip, sectorStrip, padz, padx, pad, icIndex;
539 :
540 : /* temporarly disable warnings */
541 0 : AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel();
542 0 : AliLog::SetGlobalLogLevel(AliLog::kError);
543 :
544 : /* loop over electronics oriented (EO) indices */
545 0 : for (Int_t ddl = 0; ddl < 72; ddl++)
546 0 : for (Int_t trm = 0; trm < 10; trm++)
547 0 : for (Int_t chain = 0; chain < 2; chain++)
548 0 : for (Int_t tdc = 0; tdc < 15; tdc++)
549 0 : for (Int_t channel = 0; channel < 8; channel++) {
550 :
551 : /* compute index EO */
552 0 : indexEO = GetIndexEO(ddl, trm, chain, tdc, channel);
553 :
554 : /* convert EO indices into detector oriented (DO) indices
555 : (this call causes some warnings because the loop includes
556 : EO indices which are not connected to physical channels) */
557 0 : rawStream.EquipmentId2VolumeId(ddl, trm + 3, chain, tdc, channel, det);
558 :
559 : /* swap det[3] and det[4] */
560 0 : dummy = det[3]; det[3] = det[4]; det[4] = dummy;
561 :
562 : /* check detector indices */
563 0 : if (det[0] < 0 || det[0] > 17 ||
564 0 : det[1] < 0 || det[1] > 4 ||
565 0 : det[2] < 0 || det[2] > 18 ||
566 0 : det[3] < 0 || det[3] > 1 ||
567 0 : det[4] < 0 || det[4] > 47) {
568 0 : SetHisto(fCalibMap[kIndex], indexEO, -1);
569 : continue;
570 : }
571 :
572 : /* setup information */
573 0 : index = AliTOFGeometry::GetIndex(det);
574 0 : sector = det[0];
575 0 : plate = det[1];
576 0 : strip = det[2];
577 0 : sectorStrip = plate < 3 ? plate * 19 + strip : plate * 19 - 4 + strip;
578 0 : padz = det[3];
579 0 : padx = det[4];
580 0 : pad = padz + 2 * padx;
581 0 : icIndex = pad < 48 ? pad : 95 - pad;
582 :
583 : /* set maps */
584 :
585 : /* main index */
586 0 : SetHisto(fCalibMap[kIndex], indexEO, index);
587 : /* EO indices */
588 0 : SetHisto(fCalibMap[kDDL], index, ddl);
589 0 : SetHisto(fCalibMap[kTRM], index, trm);
590 0 : SetHisto(fCalibMap[kChain], index, chain);
591 0 : SetHisto(fCalibMap[kTDC], index, tdc);
592 0 : SetHisto(fCalibMap[kChannel], index, channel);
593 : /* DO indices */
594 0 : SetHisto(fCalibMap[kSector], index, sector);
595 0 : SetHisto(fCalibMap[kPlate], index, plate);
596 0 : SetHisto(fCalibMap[kStrip], index, strip);
597 0 : SetHisto(fCalibMap[kSectorStrip], index, sectorStrip);
598 0 : SetHisto(fCalibMap[kPadZ], index, padz);
599 0 : SetHisto(fCalibMap[kPadX], index, padx);
600 0 : SetHisto(fCalibMap[kPad], index, pad);
601 0 : SetHisto(fCalibMap[kInterfaceCardIndex], index, icIndex);
602 : /* calib constants */
603 0 : SetHisto(fCalibMap[kDDLBCshift], index, fgkDDLBCshift[ddl]);
604 0 : SetHisto(fCalibMap[kFlatCableLength], index, fgkFlatCableLength[sectorStrip]);
605 0 : SetHisto(fCalibMap[kInterfaceCardLength], index, fgkInterfaceCardLength[icIndex]);
606 0 : SetHisto(fCalibMap[kAmphenolCableLength], index, AliTOFCableLengthMap::GetCableLength(ddl, trm + 3, chain, tdc));
607 :
608 : } /* loop over electronics oriented (EO) indices */
609 :
610 : /* re-enable warnings */
611 0 : AliLog::SetGlobalLogLevel(logLevel);
612 :
613 : /* write consts */
614 0 : for (Int_t iConst = 0; iConst < kNcalibConsts; iConst++)
615 0 : WriteHisto(fileOut, fCalibConst[iConst]);
616 : /* write maps */
617 0 : for (Int_t iMap = 0; iMap < kNcalibMaps; iMap++)
618 0 : WriteHisto(fileOut, fCalibMap[iMap]);
619 :
620 : /* close output file */
621 0 : fileOut->Close();
622 0 : }
623 :
624 : //__________________________________________________________________________
625 :
626 : void
627 : AliTOFcalibHisto::WriteCalibStat()
628 : {
629 : /* write calib stat */
630 :
631 : /* open output file */
632 0 : TFile *fileOut = TFile::Open(GetCalibStatFileName(), "RECREATE");
633 0 : if (!fileOut || !fileOut->IsOpen()) {
634 0 : AliFatal(Form("cannot open output file %s", GetCalibStatFileName()));
635 0 : return;
636 : }
637 :
638 : /* create stats */
639 0 : for (Int_t iStat = 0; iStat < kNcalibStats; iStat++)
640 0 : CreateHisto(&fCalibStat[iStat], fgkCalibStatName[iStat].Data(), fgkNchannels);
641 :
642 : /*** SETUP STATS ***/
643 :
644 : Int_t sector, sectorStrip;
645 :
646 : /* load calib histo */
647 0 : LoadCalibHisto();
648 :
649 : /* loop over channels */
650 0 : for (Int_t index = 0; index < fgkNchannels; index++) {
651 0 : sector = (Int_t)GetCalibMap(kSector, index);
652 0 : sectorStrip = (Int_t)GetCalibMap(kSectorStrip, index);
653 : /* strip stat */
654 0 : SetHisto(fCalibStat[kStripStat], index, (Double_t)fgkStripStat[sector][sectorStrip]);
655 : } /* loop over channels */
656 :
657 : /* write stats */
658 0 : for (Int_t iStat = 0; iStat < kNcalibStats; iStat++)
659 0 : WriteHisto(fileOut, fCalibStat[iStat]);
660 :
661 : /* close output file */
662 0 : fileOut->Close();
663 0 : }
664 :
665 : //__________________________________________________________________________
666 :
667 : Double_t
668 : AliTOFcalibHisto::GetCorrection(Int_t corr, Int_t index, Double_t tot)
669 : {
670 : /* apply correction */
671 :
672 : Int_t ddl, chain, tdc, channel, hptdc, pbCh, feaIndex, sector, plate, padx, trm, icIndex, sectorStrip;
673 : Double_t slewing;
674 :
675 0 : switch (corr) {
676 : case kDDLBCcorr:
677 0 : return -GetCalibConst(kLHCperiod) * GetCalibMap(kDDLBCshift, index);
678 : case kAmphenolCableCorr:
679 0 : return GetCalibConst(kAmphenolCableDelay) * GetCalibMap(kAmphenolCableLength, index);
680 : case kFlatCableCorr:
681 0 : return GetCalibConst(kFlatCableDelay) * GetCalibMap(kFlatCableLength, index);
682 : case kInterfaceCardCorr:
683 0 : return GetCalibConst(kInterfaceCardDelay) * GetCalibMap(kInterfaceCardLength, index);
684 : case kDDLdelayCorr:
685 0 : ddl = (Int_t)GetCalibMap(kDDL, index);
686 0 : return GetCalibPar(kDDLdelayPar, ddl);
687 : case kHPTDCdelayCorr:
688 0 : chain = (Int_t)GetCalibMap(kChain, index);
689 0 : tdc = (Int_t)GetCalibMap(kTDC, index);
690 0 : hptdc = tdc + 15 * chain;
691 0 : return GetCalibPar(kHPTDCdelayPar, hptdc);
692 : case kFEAchDelayCorr:
693 0 : ddl = (Int_t)GetCalibMap(kDDL, index);
694 0 : tdc = (Int_t)GetCalibMap(kTDC, index);
695 0 : channel = (Int_t)GetCalibMap(kChannel, index);
696 0 : pbCh = channel + 8 * (tdc % 3);
697 0 : if (ddl % 2 == 0)
698 0 : return GetCalibPar(kRightFEAchDelayPar, pbCh);
699 : else
700 0 : return GetCalibPar(kLeftFEAchDelayPar, pbCh);
701 : case kFEAdelayCorr:
702 0 : sector = (Int_t)GetCalibMap(kSector, index);
703 0 : plate = (Int_t)GetCalibMap(kPlate, index);
704 0 : sectorStrip = (Int_t)GetCalibMap(kSectorStrip, index);
705 0 : padx = (Int_t)GetCalibMap(kPadX, index);
706 0 : feaIndex = padx / 12 + 4 * sectorStrip + 364 * sector;
707 0 : return GetCalibPar(kFEAdelayPar, feaIndex);
708 : case kTRMdelayCorr:
709 0 : ddl = (Int_t)GetCalibMap(kDDL, index);
710 0 : trm = (Int_t)GetCalibMap(kTRM, index);
711 0 : return GetCalibPar(kTRMdelayPar, trm + 10 * ddl);
712 : case kICdelayCorr:
713 0 : icIndex = (Int_t)GetCalibMap(kInterfaceCardIndex, index);
714 0 : return GetCalibPar(kICdelayPar, icIndex);
715 : case kStripDelayCorr:
716 0 : sector = (Int_t)GetCalibMap(kSector, index);
717 0 : sectorStrip = (Int_t)GetCalibMap(kSectorStrip, index);
718 0 : return GetCalibPar(kStripDelayPar, sectorStrip + 91 * sector);
719 : case kIndexDelayCorr:
720 0 : return GetCalibPar(kIndexDelayPar, index);
721 : case kTimeSlewingCorr:
722 0 : tot = tot < SLEW_TOTMIN ? SLEW_TOTMIN : tot;
723 0 : tot = tot > SLEW_TOTMAX ? SLEW_TOTMAX : tot;
724 : slewing = 0.;
725 0 : for (Int_t i = 0; i < fCalibPar[kTimeSlewingPar]->GetNbinsX(); i++)
726 0 : slewing += GetCalibPar(kTimeSlewingPar, i) * TMath::Power(tot, i);
727 0 : return slewing;
728 : default:
729 0 : AliWarning(Form("unknown correction flag (%d)", corr));
730 0 : return 0.;
731 : }
732 0 : }
733 :
734 : //__________________________________________________________________________
735 :
736 : Double_t
737 : AliTOFcalibHisto::GetNominalCorrection(Int_t index)
738 : {
739 : /* get nominal correction */
740 : Double_t corr = 0;
741 0 : for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
742 0 : corr += GetCorrection(iCorr, index);
743 0 : return corr;
744 : }
745 :
746 : //__________________________________________________________________________
747 :
748 : void
749 : AliTOFcalibHisto::ApplyNominalCorrection(AliESDtrack *track)
750 : {
751 : /* apply nominal correction */
752 :
753 0 : Double_t rawTime = track->GetTOFsignalRaw();
754 0 : Int_t index = track->GetTOFCalChannel();
755 0 : Double_t time = rawTime - 1.e3 * GetNominalCorrection(index);
756 0 : track->SetTOFsignal(time);
757 0 : }
758 :
759 : //__________________________________________________________________________
760 :
761 : Double_t
762 : AliTOFcalibHisto::GetCableCorrection(Int_t index)
763 : {
764 : /* get cable correction */
765 : Double_t corr = 0;
766 0 : for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
767 0 : if (fgCableCorrectionFlag[iCorr])
768 0 : corr += GetCorrection(iCorr, index);
769 0 : return corr;
770 : }
771 :
772 : //__________________________________________________________________________
773 :
774 : Double_t
775 : AliTOFcalibHisto::GetFullCorrection(Int_t index, Double_t tot)
776 : {
777 : /* get full correction */
778 : Double_t corr = 0;
779 0 : for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
780 0 : if (fgFullCorrectionFlag[iCorr]) {
781 0 : corr += GetCorrection(iCorr, index, tot);
782 0 : }
783 0 : return corr;
784 : }
785 :
786 : //__________________________________________________________________________
787 :
788 : Bool_t
789 : AliTOFcalibHisto::GetStatus(Int_t index)
790 : {
791 : /* get status */
792 :
793 : Bool_t status = kTRUE;
794 :
795 0 : for (Int_t iStat = 0; iStat < kNcalibStats; iStat++)
796 0 : status &= GetCalibStat(iStat, index);
797 :
798 0 : return status;
799 : }
|