+
+//----------------------------------------------------------------------------
+
+Bool_t
+AliTOFcalib::IsChannelEfficient(Int_t index)
+{
+ /*
+ * is channel efficient
+ */
+
+ if (!fInitFlag) {
+ AliError("class not yet initialized. Initialize it before.");
+ return kTRUE;
+ }
+
+ /* check efficiency */
+ if (fReadoutEfficiency->GetBinContent(index + 1) < 0.95) return kFALSE;
+ return kTRUE;
+
+}
+
+//----------------------------------------------------------------------------
+
+Bool_t
+AliTOFcalib::IsChannelProblematic(Int_t index)
+{
+ /*
+ * is channel problematic
+ */
+
+ if (!fInitFlag) {
+ AliError("class not yet initialized. Initialize it before.");
+ return kTRUE;
+ }
+
+ /* check problematic */
+ if (fProblematic->GetBinContent(index + 1) != 0) return kTRUE;
+ return kFALSE;
+
+}
+
+//----------------------------------------------------------------------------
+
+void
+AliTOFcalib::CalibrateTExp(AliESDEvent *event) const
+{
+ /*
+ * calibrate TExp
+ */
+
+ if (!fInitFlag) {
+ AliError("class not yet initialized. Initialize it before.");
+ return;
+ }
+
+ /* loop over tracks */
+ AliESDtrack *track = NULL;
+ Double_t texp[AliPID::kSPECIES];
+ for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
+
+ /* get track */
+ track = event->GetTrack(itrk);
+ if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) continue;
+
+ /* get integrated times */
+ track->GetIntegratedTimes(texp);
+ /* 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);
+
+ }
+
+}
+
+//----------------------------------------------------------------------------
+
+Double_t
+AliTOFcalib::TuneForMC(AliESDEvent *event, Double_t resolution)
+{
+ /*
+ * tune for MC
+ */
+
+ /* get vertex spread and define T0-spread */
+ Double_t diamond2 = TMath::Abs(event->GetSigma2DiamondZ());
+ Double_t t0spread = TMath::Sqrt(diamond2) / 2.99792457999999984e-02;
+ /* generate random startTime */
+ Double_t startTime = gRandom->Gaus(0., t0spread);
+ /* define extra smearing for resolution */
+ Double_t defaultResolution = 80.;
+ Double_t extraSmearing = 0.;
+ if (resolution > defaultResolution)
+ extraSmearing = TMath::Sqrt(resolution * resolution - defaultResolution * defaultResolution);
+
+ /* loop over tracks */
+ AliESDtrack *track = NULL;
+ Double_t time;
+ for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
+ /* get track */
+ track = event->GetTrack(itrk);
+ if (!track) continue;
+ /* check TOF match */
+ if (!track->IsOn(AliESDtrack::kTOFout)) continue;
+ /* check if channel is enabled */
+ if (!IsChannelEnabled(track->GetTOFCalChannel())) {
+ /* reset TOF status */
+ track->ResetStatus(AliESDtrack::kTOFin);
+ track->ResetStatus(AliESDtrack::kTOFout);
+ track->ResetStatus(AliESDtrack::kTOFmismatch);
+ track->ResetStatus(AliESDtrack::kTOFpid);
+ }
+ /* get original time and manipulate it */
+ time = track->GetTOFsignal();
+ time += startTime; /* add start time */
+ time += gRandom->Gaus(0., extraSmearing); /* extra smearing */
+ time -= 25.; /* remove 25 ps to center the signal */
+ track->SetTOFsignal(time);
+ }
+
+ return startTime;
+}