]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFcalib.cxx
Fix for TOF new calib task for CPass
[u/mrichter/AliRoot.git] / TOF / AliTOFcalib.cxx
index b52764e57eabe03f2c0e2a9edf71ec8a5151e08a..e24882ed110b0c9a10b41f7028112f654ca68434 100644 (file)
@@ -2383,46 +2383,70 @@ AliTOFcalib::CalibrateESD(AliESDEvent *event)
     return;
   }
 
-  /* loop over tracks */
-  AliESDtrack *track = NULL;
   Int_t index, l0l1, deltaBC;
-  Double_t time, tot, corr, texp[AliPID::kSPECIESC];
+  Double_t time, tot, corr;
   UInt_t timestamp = event->GetTimeStamp();
-  for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
-
-    /* get track */
-    track = event->GetTrack(itrk);
-    if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) continue;
 
-    /* calibrate TOF signal */
-    if (fCalibrateTOFsignal) {
-      /* get info */
-      index = track->GetTOFCalChannel();
-      time = track->GetTOFsignalRaw();
-      tot = track->GetTOFsignalToT();
-      l0l1 = track->GetTOFL0L1();
-      deltaBC = track->GetTOFDeltaBC();
-      /* get correction */
-      corr = GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp);
-      /* apply correction */
-      time -= corr;
-      /* set new TOF signal */
-      track->SetTOFsignal(time);
+  // calibrating TOF hits
+
+  AliESDTOFHit* hit = NULL;
+  AliESDtrack* track = NULL;
+  TClonesArray* esdTOFhits = event->GetESDTOFHits();
+  if (esdTOFhits) { // new TOF data structure
+    for (Int_t ihit = 0; ihit < esdTOFhits->GetEntriesFast(); ihit++) {
+      
+      /* get track */
+      hit = (AliESDTOFHit*)esdTOFhits->At(ihit);
+      //if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) continue;
+      if (!hit) continue;
+      
+      /* calibrate TOF signal */
+      if (fCalibrateTOFsignal) {
+       /* get info */
+       index = hit->GetTOFchannel();
+       time = hit->GetTimeRaw();
+       tot = hit->GetTOT();
+       l0l1 = hit->GetL0L1Latency();
+       deltaBC = hit->GetDeltaBC();
+       /* get correction */
+       corr = GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp);
+       /* apply correction */
+       time -= corr;
+       /* set new TOF signal */
+       hit->SetTime(time);
+      }
+      
     }
+  }
+  else { // old TOF data structure
 
-    /* correct expected time */
-    if (fCorrectTExp) {
-      /* get integrated times */
-      track->GetIntegratedTimes(texp,AliPID::kSPECIESC);
-      /* loop over particle types and correct expected time */
-      for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
-       texp[ipart] += fResponseParams->EvalTExpCorr(ipart, track->P());
-      /* set integrated times */
-      track->SetIntegratedTimes(texp);
+    for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
+   
+      /* get track */
+      track = event->GetTrack(itrk);
+      if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) continue;
+      
+      /* calibrate TOF signal */
+      if (fCalibrateTOFsignal) {
+       /* get info */
+       index = track->GetTOFCalChannel();
+       time = track->GetTOFsignalRaw();
+       tot = track->GetTOFsignalToT();
+       l0l1 = track->GetTOFL0L1();
+       deltaBC = track->GetTOFDeltaBC();
+       /* get correction */
+       corr = GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp);
+       /* apply correction */
+       time -= corr;
+       /* set new TOF signal */
+       track->SetTOFsignal(time);
+      }
     }
-
+    
+    if (fCorrectTExp) 
+      CalibrateTExp(event);
   }
-
+  
 }
 
 //----------------------------------------------------------------------------
@@ -2500,6 +2524,13 @@ AliTOFcalib::CalibrateTExp(AliESDEvent *event) const
    * calibrate TExp
    */
 
+  /* check if new TOF data structure, crash in case */
+  TClonesArray* esdTOFhits = event->GetESDTOFHits();
+  if (esdTOFhits) { 
+    AliFatal("This method is DEPRECATED, doing NOTHING");
+    return ;
+  }
+
   if (!fInitFlag) {
     AliError("class not yet initialized. Initialize it before.");
     return;
@@ -2535,6 +2566,13 @@ AliTOFcalib::TuneForMC(AliESDEvent *event, Double_t resolution)
    * tune for MC
    */
 
+  /* check if new TOF data structure, crash in case */
+  TClonesArray* esdTOFhits = event->GetESDTOFHits();
+  if (esdTOFhits) { 
+    AliFatal("This method is DEPRECATED, doing NOTHING");
+    return 0.;
+  }
+
   /* get vertex spread and define T0-spread */
   Double_t diamond2 = TMath::Abs(event->GetSigma2DiamondZ());
   Double_t t0spread = TMath::Sqrt(diamond2) / 2.99792457999999984e-02;