]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFcalibHisto.cxx
A fast HLT version of the SPD clusterfinder implemented.
[u/mrichter/AliRoot.git] / TOF / AliTOFcalibHisto.cxx
index 2c94e5576b3d7b9b2a1e2e0477053f1ff50371ee..4a0b3c59c473e75e0ad60c9191621d3725e45eb8 100644 (file)
@@ -18,6 +18,7 @@
  * AliTOFcalibHisto - class to handle TOF calibration histograms,
  *                    map histograms and more
  *
+ *
  * autors:   Roberto Preghenella (R+)
  * concacts: preghenella@bo.infn.it
  *
 
 #include "AliTOFcalibHisto.h"
 #include "AliLog.h"
-#include "TH1F.h"
+#include "TH1D.h"
 #include "TFile.h"
 #include "AliTOFRawStream.h"
 #include "AliTOFCableLengthMap.h"
 #include "AliESDtrack.h"
 
+#define SLEW_TOTMIN 10.
+#define SLEW_TOTMAX 16.
+
 ClassImp(AliTOFcalibHisto)
 
 //__________________________________________________________________________
@@ -87,31 +91,35 @@ const TString AliTOFcalibHisto::fgkCalibParName[kNcalibPars] = {
   "hLeftFEAchDelay",
   "hRightFEAchDelay",
   "hFEADelay",
+  "hICDelay",
   "hTRMDelay",
-  "hSlew"
+  "hStripDelay",
+  "hIndexDelay",
+  "hSlewing"
 };
 
 //__________________________________________________________________________
 
 /* LHC clock period [ns] */
-const Float_t AliTOFcalibHisto::fgkLHCperiod = 25.; /* SET THE CORRECT VALUE !!! */
+const Double_t AliTOFcalibHisto::fgkLHCperiod = (24.4e-3 * 1024); /* ns */
 
 //__________________________________________________________________________
 
 /* Amphenol cable delay [ns/cm] */
-const Float_t AliTOFcalibHisto::fgkAmphenolCableDelay = 5.13e-2; /* from measurement */
+const Double_t AliTOFcalibHisto::fgkAmphenolCableDelay = 5.13e-2; /* from measurement */
 
 //__________________________________________________________________________
 
 /* flat cable delay [ns/cm] */
-//const Float_t AliTOFcalibHisto::fgkFlatCableDelay = 5.3e-2; /* from Amphenol 132-2829 series data-sheet */
-const Float_t AliTOFcalibHisto::fgkFlatCableDelay = 5.124e-2; /* from LHC08d calibration */
+//const Double_t AliTOFcalibHisto::fgkFlatCableDelay = 5.3e-2; /* from Amphenol 132-2829 series data-sheet */
+const Double_t AliTOFcalibHisto::fgkFlatCableDelay = 5.124e-2; /* from LHC08d calibration */
 
 //__________________________________________________________________________
 
 /* interface card delay [ns/cm] */
-//const Float_t AliTOFcalibHisto::fgkInterfaceCardDelay = 6.9e-2; /* from HyperLinx simulation */
-const Float_t AliTOFcalibHisto::fgkInterfaceCardDelay = 5.7898e-2; /* from LHC08d calibration */
+//const Double_t AliTOFcalibHisto::fgkInterfaceCardDelay = 6.9e-2; /* from HyperLinx simulation */
+//const Double_t AliTOFcalibHisto::fgkInterfaceCardDelay = 5.7898e-2; /* from LHC08d calibration */
+const Double_t AliTOFcalibHisto::fgkInterfaceCardDelay = 6.31360207815420404e-02; /* from LHC09c calibration */
 
 //__________________________________________________________________________
 
@@ -140,13 +148,13 @@ const Int_t AliTOFcalibHisto::fgkDDLBCshift[72] = {
   2, 2, -2, -2,
   2, 2, -1, -1,
   2, 2, -1, -1,
-  2, 2, -1, -1,
+  2, 2, -1, -1
 };
 
 //__________________________________________________________________________
 
 /* strip flat-cable length (preliminary) [cm] */
-const Float_t AliTOFcalibHisto::fgkFlatCableLength[91] = {
+const Double_t AliTOFcalibHisto::fgkFlatCableLength[91] = {
   18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 18., 17.,
   21., 21., 21., 21., 21., 17., 17., 21., 21., 17., 21., 21., 21., 17., 21., 21., 17., 21., 23.,
   17., 19., 17., 19., 17., 19., 17., 19., 17., 19., 17., 19., 17., 19., 17.,
@@ -157,7 +165,7 @@ const Float_t AliTOFcalibHisto::fgkFlatCableLength[91] = {
 //__________________________________________________________________________
 
 /* interface card lenght (preliminary) [cm] */
-const Float_t AliTOFcalibHisto::fgkInterfaceCardLength[48] = {
+const Double_t AliTOFcalibHisto::fgkInterfaceCardLength[48] = {
   13.97, 12.57, 14.52, 13.10, 15.44, 13.60, 10.58, 9.14, 
   11.21, 9.76, 12.11, 10.76, 8.67, 7.58, 9.32, 8.09,
   10.24, 8.4, 5.51, 4.31, 6.54, 5.23, 7.48, 6.28,
@@ -168,6 +176,42 @@ const Float_t AliTOFcalibHisto::fgkInterfaceCardLength[48] = {
 
 //__________________________________________________________________________
 
+Bool_t AliTOFcalibHisto::fgCableCorrectionFlag[kNcorrections] = {
+  kFALSE, // kDDLBCcorr
+  kTRUE, // kAmphenolCableCorr
+  kTRUE, // kFlatCableCorr
+  kTRUE, // kInterfaceCardCorr
+  kFALSE, // kDDLdelayCorr
+  kFALSE, // kHPTDCdelayCorr
+  kFALSE, // kFEAchDelayCorr
+  kFALSE, // kFEAdelayCorr
+  kFALSE, // kTRMdelayCorr
+  kFALSE, // kICdelayCorr
+  kFALSE, // kStripDelayCorr
+  kFALSE, // kIndexDelayCorr
+  kFALSE, // kTimeSlewingCorr
+};
+
+//__________________________________________________________________________
+
+Bool_t AliTOFcalibHisto::fgFullCorrectionFlag[kNcorrections] = {
+  kFALSE, // kDDLBCcorr
+  kTRUE, // kAmphenolCableCorr
+  kTRUE, // kFlatCableCorr
+  kTRUE, // kInterfaceCardCorr
+  kTRUE, // kDDLdelayCorr
+  kTRUE, // kHPTDCdelayCorr
+  kTRUE, // kFEAchDelayCorr
+  kTRUE, // kFEAdelayCorr
+  kTRUE, // kTRMdelayCorr
+  kFALSE, // kICdelayCorr
+  kTRUE, // kStripDelayCorr
+  kTRUE, // kIndexDelayCorr
+  kTRUE, // kTimeSlewingCorr
+};
+
+//__________________________________________________________________________
+
 AliTOFcalibHisto::AliTOFcalibHisto() :
   TObject(),
   fCalibConst(),
@@ -187,10 +231,10 @@ AliTOFcalibHisto::~AliTOFcalibHisto()
 //__________________________________________________________________________
 
 void 
-AliTOFcalibHisto::LoadHisto(TFile* file, TH1F **histo, const Char_t *name) 
+AliTOFcalibHisto::LoadHisto(TFile* file, TH1D **histo, const Char_t *name) 
 {
   /* load histo */
-  *histo = (TH1F *)file->Get(name);
+  *histo = (TH1D *)file->Get(name);
   if (!*histo)
     AliWarning(Form("error while getting %s histo", name));
 }
@@ -198,10 +242,10 @@ AliTOFcalibHisto::LoadHisto(TFile* file, TH1F **histo, const Char_t *name)
 //__________________________________________________________________________
 
 void 
-AliTOFcalibHisto::CreateHisto(TH1F **histo, const Char_t *name, Int_t size) 
+AliTOFcalibHisto::CreateHisto(TH1D **histo, const Char_t *name, Int_t size) 
 {
   /* create histo */
-  *histo = new TH1F(name, Form(";index;%s", name), size, 0, size);
+  *histo = new TH1D(name, Form(";index;%s", name), size, 0, size);
   if (!*histo)
     AliWarning(Form("error while creating %s histo", name));
 }
@@ -209,7 +253,7 @@ AliTOFcalibHisto::CreateHisto(TH1F **histo, const Char_t *name, Int_t size)
 //__________________________________________________________________________
 
 void 
-AliTOFcalibHisto::WriteHisto(TFile *file, TH1F *histo) 
+AliTOFcalibHisto::WriteHisto(TFile *file, TH1D *histo) 
 {
   /* write histo */
   if (!file || !file->IsOpen() || !histo)
@@ -221,7 +265,7 @@ AliTOFcalibHisto::WriteHisto(TFile *file, TH1F *histo)
 //__________________________________________________________________________
 
 void
-AliTOFcalibHisto::SetHisto(TH1F *histo, Int_t index, Float_t value)
+AliTOFcalibHisto::SetHisto(TH1D *histo, Int_t index, Double_t value)
 {
   /* set histo */
   if (!histo)
@@ -231,8 +275,8 @@ AliTOFcalibHisto::SetHisto(TH1F *histo, Int_t index, Float_t value)
 
 //__________________________________________________________________________
 
-Float_t
-AliTOFcalibHisto::GetHisto(TH1F *histo, Int_t index)
+Double_t
+AliTOFcalibHisto::GetHisto(TH1D *histo, Int_t index)
 {
   /* get histo */
   if (!histo) {
@@ -340,6 +384,9 @@ AliTOFcalibHisto::WriteCalibHisto()
        for (Int_t tdc = 0; tdc < 15; tdc++)
          for (Int_t channel = 0; channel < 8; channel++) {
            
+           /* compute index EO */
+           indexEO = GetIndexEO(ddl, trm, chain, tdc, channel);
+
            /* convert EO indices into detector oriented (DO) indices
               (this call causes some warnings because the loop includes
               EO indices which are not connected to physical channels) */
@@ -353,11 +400,12 @@ AliTOFcalibHisto::WriteCalibHisto()
                det[1] < 0 || det[1] > 4 ||
                det[2] < 0 || det[2] > 18 ||
                det[3] < 0 || det[3] > 1 ||
-               det[4] < 0 || det[4] > 47)
+               det[4] < 0 || det[4] > 47) {
+             SetHisto(fCalibMap[kIndex], indexEO, -1);
              continue;
+           }
            
            /* setup information */
-           indexEO = GetIndexEO(ddl, trm, chain, tdc, channel);
            index = AliTOFGeometry::GetIndex(det);
            sector = det[0];
            plate = det[1];
@@ -411,13 +459,13 @@ AliTOFcalibHisto::WriteCalibHisto()
 
 //__________________________________________________________________________
 
-Float_t
-AliTOFcalibHisto::GetCorrection(Int_t corr, Int_t index, Float_t tot)
+Double_t
+AliTOFcalibHisto::GetCorrection(Int_t corr, Int_t index, Double_t tot)
 {
   /* apply correction */
 
-  Int_t ddl, chain, tdc, channel, hptdc, pbCh, feaIndex, sector, plate, strip, padx, trm;
-  Float_t slewing;
+  Int_t ddl, chain, tdc, channel, hptdc, pbCh, feaIndex, sector, plate, padx, trm, icIndex, sectorStrip;
+  Double_t slewing;
   
   switch (corr) {
   case kDDLBCcorr:
@@ -448,14 +496,26 @@ AliTOFcalibHisto::GetCorrection(Int_t corr, Int_t index, Float_t tot)
   case kFEAdelayCorr:
     sector = (Int_t)GetCalibMap(kSector, index);
     plate = (Int_t)GetCalibMap(kPlate, index);
-    strip = (Int_t)GetCalibMap(kStrip, index);
+    sectorStrip = (Int_t)GetCalibMap(kSectorStrip, index);
     padx = (Int_t)GetCalibMap(kPadX, index);
-    feaIndex = padx / 12 + 4 * strip + 4 * 19 * plate + 4 * 19 * 5 * sector;      
+    feaIndex = padx / 12 + 4 * sectorStrip + 364 * sector;      
     return GetCalibPar(kFEAdelayPar, feaIndex);
   case kTRMdelayCorr:
+    ddl = (Int_t)GetCalibMap(kDDL, index);
     trm = (Int_t)GetCalibMap(kTRM, index);
-    return GetCalibPar(kTRMdelayPar, trm);
+    return GetCalibPar(kTRMdelayPar, trm + 10 * ddl);
+  case kICdelayCorr:
+    icIndex = (Int_t)GetCalibMap(kInterfaceCardIndex, index);
+    return GetCalibPar(kICdelayPar, icIndex);
+  case kStripDelayCorr:
+    sector = (Int_t)GetCalibMap(kSector, index);
+    sectorStrip = (Int_t)GetCalibMap(kSectorStrip, index);
+    return GetCalibPar(kStripDelayPar, sectorStrip + 91 * sector);
+  case kIndexDelayCorr:
+    return GetCalibPar(kIndexDelayPar, index);
   case kTimeSlewingCorr:
+    tot = tot < SLEW_TOTMIN ? SLEW_TOTMIN : tot;
+    tot = tot > SLEW_TOTMAX ? SLEW_TOTMAX : tot;
     slewing = 0.;
     for (Int_t i = 0; i < fCalibPar[kTimeSlewingPar]->GetNbinsX(); i++)
       slewing += GetCalibPar(kTimeSlewingPar, i) * TMath::Power(tot, i);
@@ -468,11 +528,11 @@ AliTOFcalibHisto::GetCorrection(Int_t corr, Int_t index, Float_t tot)
 
 //__________________________________________________________________________
 
-Float_t
+Double_t
 AliTOFcalibHisto::GetNominalCorrection(Int_t index)
 {
   /* get nominal correction */
-  Float_t corr = 0;
+  Double_t corr = 0;
   for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
     corr += GetCorrection(iCorr, index);
   return corr;
@@ -491,3 +551,30 @@ AliTOFcalibHisto::ApplyNominalCorrection(AliESDtrack *track)
   track->SetTOFsignal(time);
 }
 
+//__________________________________________________________________________
+
+Double_t
+AliTOFcalibHisto::GetCableCorrection(Int_t index)
+{
+  /* get cable correction */
+  Double_t corr = 0;
+  for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
+    if (fgCableCorrectionFlag[iCorr])
+      corr += GetCorrection(iCorr, index);
+  return corr;
+}
+
+//__________________________________________________________________________
+
+Double_t
+AliTOFcalibHisto::GetFullCorrection(Int_t index, Double_t tot)
+{
+  /* get full correction */
+  Double_t corr = 0;
+  for (Int_t iCorr = 0; iCorr < kNcorrections; iCorr++)
+    if (fgFullCorrectionFlag[iCorr]) {
+      corr += GetCorrection(iCorr, index, tot);
+    }
+  return corr;
+}
+