1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /*************************************************************************
18 * AliTOFcalibHisto - class to handle TOF calibration histograms,
19 * map histograms and more
22 * autors: Roberto Preghenella (R+)
23 * concacts: preghenella@bo.infn.it
25 *************************************************************************/
27 #include "AliTOFcalibHisto.h"
31 #include "AliTOFRawStream.h"
32 #include "AliTOFCableLengthMap.h"
33 #include "AliESDtrack.h"
35 #define SLEW_TOTMIN 10.
36 #define SLEW_TOTMAX 16.
38 ClassImp(AliTOFcalibHisto)
40 //__________________________________________________________________________
42 TFile *AliTOFcalibHisto::fgCalibHistoFile = NULL;
43 TFile *AliTOFcalibHisto::fgCalibParFile = NULL;
44 TFile *AliTOFcalibHisto::fgCalibStatFile = NULL;
46 //__________________________________________________________________________
48 TString AliTOFcalibHisto::fgCalibHistoFileName = "$ALICE_ROOT/TOF/data/AliTOFcalibHisto.root";
49 TString AliTOFcalibHisto::fgCalibParFileName = "$ALICE_ROOT/TOF/data/AliTOFcalibPar.root";
50 TString AliTOFcalibHisto::fgCalibStatFileName = "$ALICE_ROOT/TOF/data/AliTOFcalibStat.root";
52 //__________________________________________________________________________
54 const TString AliTOFcalibHisto::fgkCalibConstName[kNcalibConsts] = {
61 //__________________________________________________________________________
63 const TString AliTOFcalibHisto::fgkCalibMapName[kNcalibMaps] = {
84 "InterfaceCardLength",
88 //__________________________________________________________________________
90 const TString AliTOFcalibHisto::fgkCalibParName[kNcalibPars] = {
103 //__________________________________________________________________________
105 const TString AliTOFcalibHisto::fgkCalibStatName[kNcalibStats] = {
109 //__________________________________________________________________________
111 /* LHC clock period [ns] */
112 const Double_t AliTOFcalibHisto::fgkLHCperiod = (24.4e-3 * 1024); /* ns */
114 //__________________________________________________________________________
116 /* Amphenol cable delay [ns/cm] */
117 const Double_t AliTOFcalibHisto::fgkAmphenolCableDelay = 5.13e-2; /* from measurement */
119 //__________________________________________________________________________
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 */
125 //__________________________________________________________________________
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 */
132 //__________________________________________________________________________
134 /* number of readout channels (DO/EO) */
135 const Int_t AliTOFcalibHisto::fgkNchannels = 157248;
136 const Int_t AliTOFcalibHisto::fgkNchannelsEO = 172800;
138 //__________________________________________________________________________
140 /* DDL BC shifts due to TTC fibers [LHCperiod] */
141 const Int_t AliTOFcalibHisto::fgkDDLBCshift[72] = {
162 //__________________________________________________________________________
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.
173 //__________________________________________________________________________
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
185 //__________________________________________________________________________
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
203 //__________________________________________________________________________
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
221 //__________________________________________________________________________
223 const Int_t AliTOFcalibHisto::fg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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 */
335 //__________________________________________________________________________
337 AliTOFcalibHisto::AliTOFcalibHisto() :
344 /* default constructor */
347 //__________________________________________________________________________
349 AliTOFcalibHisto::~AliTOFcalibHisto()
351 /* default destructor */
354 //__________________________________________________________________________
357 AliTOFcalibHisto::LoadHisto(TFile* file, TH1D **histo, const Char_t *name)
360 *histo = (TH1D *)file->Get(name);
362 AliWarning(Form("error while getting %s histo", name));
365 //__________________________________________________________________________
368 AliTOFcalibHisto::CreateHisto(TH1D **histo, const Char_t *name, Int_t size)
371 *histo = new TH1D(name, Form(";index;%s", name), size, 0, size);
373 AliWarning(Form("error while creating %s histo", name));
376 //__________________________________________________________________________
379 AliTOFcalibHisto::WriteHisto(TFile *file, TH1D *histo)
382 if (!file || !file->IsOpen() || !histo)
388 //__________________________________________________________________________
391 AliTOFcalibHisto::SetHisto(TH1D *histo, Int_t index, Double_t value)
396 histo->SetBinContent(index + 1, value);
399 //__________________________________________________________________________
402 AliTOFcalibHisto::GetHisto(TH1D *histo, Int_t index)
406 AliWarning("cannot get histo");
409 return histo->GetBinContent(index + 1);
412 //__________________________________________________________________________
415 AliTOFcalibHisto::LoadCalibHisto()
417 /* load calib histo */
419 if (fgCalibHistoFile && fgCalibHistoFile->IsOpen())
420 AliWarning("calib histo file already open: reloading");
422 /* open input file */
423 TFile *fileIn = TFile::Open(GetCalibHistoFileName());
424 if (!fileIn || !fileIn->IsOpen())
425 AliFatal(Form("cannot open input file %s", GetCalibHistoFileName()));
427 /* set calib histo file */
428 fgCalibHistoFile = fileIn;
431 for (Int_t iConst = 0; iConst < kNcalibConsts; iConst++)
432 LoadHisto(fileIn, &fCalibConst[iConst], fgkCalibConstName[iConst].Data());
434 for (Int_t iMap = 0; iMap < kNcalibMaps; iMap++)
435 LoadHisto(fileIn, &fCalibMap[iMap], fgkCalibMapName[iMap].Data());
438 //__________________________________________________________________________
441 AliTOFcalibHisto::LoadCalibPar()
445 if (fgCalibParFile && fgCalibParFile->IsOpen())
446 AliWarning("calib par file already open: reloading");
448 /* load calib histo */
451 /* open input file */
452 TFile *fileIn = TFile::Open(GetCalibParFileName());
453 if (!fileIn || !fileIn->IsOpen())
454 AliError(Form("cannot open input file %s", GetCalibParFileName()));
456 /* set calib par file */
457 fgCalibParFile = fileIn;
460 for (Int_t i = 0; i < kNcalibPars; i++)
461 LoadHisto(fileIn, &fCalibPar[i], fgkCalibParName[i].Data());
465 //__________________________________________________________________________
468 AliTOFcalibHisto::LoadCalibStat()
470 /* load calib stat */
472 if (fgCalibStatFile && fgCalibStatFile->IsOpen())
473 AliWarning("calib par file already open: reloading");
475 /* load calib histo */
478 /* open input file */
479 TFile *fileIn = TFile::Open(GetCalibStatFileName());
480 if (!fileIn || !fileIn->IsOpen())
481 AliError(Form("cannot open input file %s", GetCalibStatFileName()));
483 /* set calib par file */
484 fgCalibStatFile = fileIn;
487 for (Int_t i = 0; i < kNcalibStats; i++)
488 LoadHisto(fileIn, &fCalibStat[i], fgkCalibStatName[i].Data());
492 //__________________________________________________________________________
495 AliTOFcalibHisto::WriteCalibHisto()
497 /* write calib histo */
499 /* open output file */
500 TFile *fileOut = TFile::Open(GetCalibHistoFileName(), "RECREATE");
501 if (!fileOut || !fileOut->IsOpen())
502 AliFatal(Form("cannot open output file %s", GetCalibHistoFileName()));
505 for (Int_t iConst = 0; iConst < kNcalibConsts; iConst++)
506 CreateHisto(&fCalibConst[iConst], fgkCalibConstName[iConst].Data(), 1);
508 for (Int_t iMap = 0; iMap < kNcalibMaps; iMap++)
510 CreateHisto(&fCalibMap[iMap], fgkCalibMapName[iMap].Data(), fgkNchannelsEO);
512 CreateHisto(&fCalibMap[iMap], fgkCalibMapName[iMap].Data(), fgkNchannels);
514 /*** SETUP CONSTS ***/
516 SetHisto(fCalibConst[kLHCperiod], 0, fgkLHCperiod);
517 SetHisto(fCalibConst[kAmphenolCableDelay], 0, fgkAmphenolCableDelay);
518 SetHisto(fCalibConst[kFlatCableDelay], 0, fgkFlatCableDelay);
519 SetHisto(fCalibConst[kInterfaceCardDelay], 0, fgkInterfaceCardDelay);
523 AliTOFRawStream rawStream;
524 Int_t indexEO, det[5], dummy, index, sector, plate, strip, sectorStrip, padz, padx, pad, icIndex;
526 /* temporarly disable warnings */
527 AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel();
528 AliLog::SetGlobalLogLevel(AliLog::kError);
530 /* loop over electronics oriented (EO) indices */
531 for (Int_t ddl = 0; ddl < 72; ddl++)
532 for (Int_t trm = 0; trm < 10; trm++)
533 for (Int_t chain = 0; chain < 2; chain++)
534 for (Int_t tdc = 0; tdc < 15; tdc++)
535 for (Int_t channel = 0; channel < 8; channel++) {
537 /* compute index EO */
538 indexEO = GetIndexEO(ddl, trm, chain, tdc, channel);
540 /* convert EO indices into detector oriented (DO) indices
541 (this call causes some warnings because the loop includes
542 EO indices which are not connected to physical channels) */
543 rawStream.EquipmentId2VolumeId(ddl, trm + 3, chain, tdc, channel, det);
545 /* swap det[3] and det[4] */
546 dummy = det[3]; det[3] = det[4]; det[4] = dummy;
548 /* check detector indices */
549 if (det[0] < 0 || det[0] > 17 ||
550 det[1] < 0 || det[1] > 4 ||
551 det[2] < 0 || det[2] > 18 ||
552 det[3] < 0 || det[3] > 1 ||
553 det[4] < 0 || det[4] > 47) {
554 SetHisto(fCalibMap[kIndex], indexEO, -1);
558 /* setup information */
559 index = AliTOFGeometry::GetIndex(det);
563 sectorStrip = plate < 3 ? plate * 19 + strip : plate * 19 - 4 + strip;
566 pad = padz + 2 * padx;
567 icIndex = pad < 48 ? pad : 95 - pad;
572 SetHisto(fCalibMap[kIndex], indexEO, index);
574 SetHisto(fCalibMap[kDDL], index, ddl);
575 SetHisto(fCalibMap[kTRM], index, trm);
576 SetHisto(fCalibMap[kChain], index, chain);
577 SetHisto(fCalibMap[kTDC], index, tdc);
578 SetHisto(fCalibMap[kChannel], index, channel);
580 SetHisto(fCalibMap[kSector], index, sector);
581 SetHisto(fCalibMap[kPlate], index, plate);
582 SetHisto(fCalibMap[kStrip], index, strip);
583 SetHisto(fCalibMap[kSectorStrip], index, sectorStrip);
584 SetHisto(fCalibMap[kPadZ], index, padz);
585 SetHisto(fCalibMap[kPadX], index, padx);
586 SetHisto(fCalibMap[kPad], index, pad);
587 SetHisto(fCalibMap[kInterfaceCardIndex], index, icIndex);
588 /* calib constants */
589 SetHisto(fCalibMap[kDDLBCshift], index, fgkDDLBCshift[ddl]);
590 SetHisto(fCalibMap[kFlatCableLength], index, fgkFlatCableLength[sectorStrip]);
591 SetHisto(fCalibMap[kInterfaceCardLength], index, fgkInterfaceCardLength[icIndex]);
592 SetHisto(fCalibMap[kAmphenolCableLength], index, AliTOFCableLengthMap::GetCableLength(ddl, trm + 3, chain, tdc));
594 } /* loop over electronics oriented (EO) indices */
596 /* re-enable warnings */
597 AliLog::SetGlobalLogLevel(logLevel);
600 for (Int_t iConst = 0; iConst < kNcalibConsts; iConst++)
601 WriteHisto(fileOut, fCalibConst[iConst]);
603 for (Int_t iMap = 0; iMap < kNcalibMaps; iMap++)
604 WriteHisto(fileOut, fCalibMap[iMap]);
606 /* close output file */
610 //__________________________________________________________________________
613 AliTOFcalibHisto::WriteCalibStat()
615 /* write calib stat */
617 /* open output file */
618 TFile *fileOut = TFile::Open(GetCalibStatFileName(), "RECREATE");
619 if (!fileOut || !fileOut->IsOpen())
620 AliFatal(Form("cannot open output file %s", GetCalibStatFileName()));
623 for (Int_t iStat = 0; iStat < kNcalibStats; iStat++)
624 CreateHisto(&fCalibStat[iStat], fgkCalibStatName[iStat].Data(), fgkNchannels);
626 /*** SETUP STATS ***/
628 Int_t sector, sectorStrip;
630 /* load calib histo */
633 /* loop over channels */
634 for (Int_t index = 0; index < fgkNchannels; index++) {
635 sector = (Int_t)GetCalibMap(kSector, index);
636 sectorStrip = (Int_t)GetCalibMap(kSectorStrip, index);
638 SetHisto(fCalibStat[kStripStat], index, (Double_t)fgkStripStat[sector][sectorStrip]);
639 } /* loop over channels */
642 for (Int_t iStat = 0; iStat < kNcalibStats; iStat++)
643 WriteHisto(fileOut, fCalibStat[iStat]);
645 /* close output file */
649 //__________________________________________________________________________
652 AliTOFcalibHisto::GetCorrection(Int_t corr, Int_t index, Double_t tot)
654 /* apply correction */
656 Int_t ddl, chain, tdc, channel, hptdc, pbCh, feaIndex, sector, plate, padx, trm, icIndex, sectorStrip;
661 return -GetCalibConst(kLHCperiod) * GetCalibMap(kDDLBCshift, index);
662 case kAmphenolCableCorr:
663 return GetCalibConst(kAmphenolCableDelay) * GetCalibMap(kAmphenolCableLength, index);
665 return GetCalibConst(kFlatCableDelay) * GetCalibMap(kFlatCableLength, index);
666 case kInterfaceCardCorr:
667 return GetCalibConst(kInterfaceCardDelay) * GetCalibMap(kInterfaceCardLength, index);
669 ddl = (Int_t)GetCalibMap(kDDL, index);
670 return GetCalibPar(kDDLdelayPar, ddl);
671 case kHPTDCdelayCorr:
672 chain = (Int_t)GetCalibMap(kChain, index);
673 tdc = (Int_t)GetCalibMap(kTDC, index);
674 hptdc = tdc + 15 * chain;
675 return GetCalibPar(kHPTDCdelayPar, hptdc);
676 case kFEAchDelayCorr:
677 ddl = (Int_t)GetCalibMap(kDDL, index);
678 tdc = (Int_t)GetCalibMap(kTDC, index);
679 channel = (Int_t)GetCalibMap(kChannel, index);
680 pbCh = channel + 8 * (tdc % 3);
682 return GetCalibPar(kRightFEAchDelayPar, pbCh);
684 return GetCalibPar(kLeftFEAchDelayPar, pbCh);
686 sector = (Int_t)GetCalibMap(kSector, index);
687 plate = (Int_t)GetCalibMap(kPlate, index);
688 sectorStrip = (Int_t)GetCalibMap(kSectorStrip, index);
689 padx = (Int_t)GetCalibMap(kPadX, index);
690 feaIndex = padx / 12 + 4 * sectorStrip + 364 * sector;
691 return GetCalibPar(kFEAdelayPar, feaIndex);
693 ddl = (Int_t)GetCalibMap(kDDL, index);
694 trm = (Int_t)GetCalibMap(kTRM, index);
695 return GetCalibPar(kTRMdelayPar, trm + 10 * ddl);
697 icIndex = (Int_t)GetCalibMap(kInterfaceCardIndex, index);
698 return GetCalibPar(kICdelayPar, icIndex);
699 case kStripDelayCorr:
700 sector = (Int_t)GetCalibMap(kSector, index);
701 sectorStrip = (Int_t)GetCalibMap(kSectorStrip, index);
702 return GetCalibPar(kStripDelayPar, sectorStrip + 91 * sector);
703 case kIndexDelayCorr:
704 return GetCalibPar(kIndexDelayPar, index);
705 case kTimeSlewingCorr:
706 tot = tot < SLEW_TOTMIN ? SLEW_TOTMIN : tot;
707 tot = tot > SLEW_TOTMAX ? SLEW_TOTMAX : tot;
709 for (Int_t i = 0; i < fCalibPar[kTimeSlewingPar]->GetNbinsX(); i++)
710 slewing += GetCalibPar(kTimeSlewingPar, i) * TMath::Power(tot, i);
713 AliWarning(Form("unknown correction flag (%d)", corr));
718 //__________________________________________________________________________
721 AliTOFcalibHisto::GetNominalCorrection(Int_t index)
723 /* get nominal correction */
725 for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
726 corr += GetCorrection(iCorr, index);
730 //__________________________________________________________________________
733 AliTOFcalibHisto::ApplyNominalCorrection(AliESDtrack *track)
735 /* apply nominal correction */
737 Double_t rawTime = track->GetTOFsignalRaw();
738 Int_t index = track->GetTOFCalChannel();
739 Double_t time = rawTime - 1.e3 * GetNominalCorrection(index);
740 track->SetTOFsignal(time);
743 //__________________________________________________________________________
746 AliTOFcalibHisto::GetCableCorrection(Int_t index)
748 /* get cable correction */
750 for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
751 if (fgCableCorrectionFlag[iCorr])
752 corr += GetCorrection(iCorr, index);
756 //__________________________________________________________________________
759 AliTOFcalibHisto::GetFullCorrection(Int_t index, Double_t tot)
761 /* get full correction */
763 for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
764 if (fgFullCorrectionFlag[iCorr]) {
765 corr += GetCorrection(iCorr, index, tot);
770 //__________________________________________________________________________
773 AliTOFcalibHisto::GetStatus(Int_t index)
777 Bool_t status = kTRUE;
779 for (Int_t iStat = 0; iStat < kNcalibStats; iStat++)
780 status &= GetCalibStat(iStat, index);