+ Double_t time=0., tot=0., corr=0.;
+ Int_t deltaBC=0, l0l1=0, tdcBin=0;
+ Int_t index = -1;
+ Int_t detId[5] ={-1,-1,-1,-1,-1};
+ UInt_t timestamp=0;
+
+ Int_t ndigits = fDigits->GetEntriesFast();
+ // Loop on TOF Digits
+ for (Int_t i=0;i<ndigits;i++){
+ AliTOFdigit * dig = (AliTOFdigit*)fDigits->At(i);
+ detId[0] = dig->GetSector();
+ detId[1] = dig->GetPlate();
+ detId[2] = dig->GetStrip();
+ detId[3] = dig->GetPadz();
+ detId[4] = dig->GetPadx();
+ dig->SetTdcND(dig->GetTdc()); // save the non decalibrated time
+
+ index = AliTOFGeometry::GetIndex(detId); // The channel index
+
+ // Read Calibration parameters from the CDB
+ // get digit info
+ time = dig->GetTdc() * AliTOFGeometry::TdcBinWidth(); /* ps */
+ tot = dig->GetToT() * AliTOFGeometry::ToTBinWidth() * 1.e-3; /* ns */
+ deltaBC = 0;//dig->GetDeltaBC();
+ l0l1 = 0;//dig->GetL0L1Latency();
+
+ // get correction
+ corr = fCalib->GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp); /* ps */
+ AliDebug(2, Form("calibrate index %d: time=%f (ps) tot=%f (ns) deltaBC=%d l0l1=%d timestamp=%d corr=%f (ps)",
+ index, time, tot, deltaBC, l0l1, timestamp, corr));
+
+ // apply time correction
+ time += corr;
+
+ // convert in TDC bins and set digit
+ //tdcBin = (Int_t)(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
+ tdcBin = TMath::Nint(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
+ dig->SetTdc(tdcBin);
+
+ }
+
+ AliDebug(1,"Simulating miscalibrated digits");
+
+ return;