https://savannah.cern.ch/bugs/?102386
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 Sep 2013 15:09:53 +0000 (15:09 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 Sep 2013 15:09:53 +0000 (15:09 +0000)
STEER/AOD/AliAODpidUtil.cxx
STEER/ESD/AliESDpid.cxx
STEER/STEERBase/AliPIDResponse.cxx
STEER/STEERBase/AliPIDResponse.h
STEER/STEERBase/AliTOFPIDResponse.cxx
STEER/STEERBase/AliTOFPIDResponse.h

index 45cda46..4c61bb4 100644 (file)
@@ -33,6 +33,7 @@
 #include "AliESDtrack.h"
 #include "AliAODMCHeader.h"
 #include "AliAODMCParticle.h"
+#include "AliTOFPIDParams.h"
 
 #include <AliDetectorPID.h>
 
@@ -111,8 +112,17 @@ Float_t AliAODpidUtil::GetTOFsignalTunedOnData(const AliVTrack *t) const {
     Double_t tofSignal = track->GetTOFsignalTunedOnData();
 
     if(tofSignal <  99999) return (Float_t)tofSignal; // it has been already set
+
+    // read additional mismatch fraction
+    Float_t addmism = GetTOFPIDParams()->GetTOFadditionalMismForMC();
+    if(addmism > 1.){
+      Float_t centr = GetCurrentCentrality();
+      if(centr > 50) addmism *= 0.1667;
+      else if(centr > 20) addmism *= 0.33;
+    }
+
     AliAODPid *pidObj = track->GetDetPid();
-    tofSignal = pidObj->GetTOFsignal() + fTOFResponse.GetTailRandomValue();
+    tofSignal = pidObj->GetTOFsignal() + fTOFResponse.GetTailRandomValue(t->Pt(),t->Eta(),pidObj->GetTOFsignal(),addmism);
     track->SetTOFsignalTunedOnData(tofSignal);
     return (Float_t)tofSignal;
 }
index 7904395..9f9dd80 100644 (file)
@@ -34,6 +34,7 @@
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
 #include "AliMCEvent.h"
+#include "AliTOFPIDParams.h"
 
 #include <AliDetectorPID.h>
 
@@ -142,8 +143,15 @@ Float_t AliESDpid::GetTOFsignalTunedOnData(const AliVTrack *t) const {
     Double_t tofSignal = track->GetTOFsignalTunedOnData();
 
     if(tofSignal <  99999) return (Float_t)tofSignal; // it has been already set
+    // read additional mismatch fraction
+    Float_t addmism = GetTOFPIDParams()->GetTOFadditionalMismForMC();
+    if(addmism > 1.){
+      Float_t centr = GetCurrentCentrality();
+      if(centr > 50) addmism *= 0.1667;
+      else if(centr > 20) addmism *= 0.33;
+    }
 
-    tofSignal = t->GetTOFsignal() + fTOFResponse.GetTailRandomValue();
+    tofSignal = t->GetTOFsignal() + fTOFResponse.GetTailRandomValue(t->Pt(),t->Eta(),t->GetTOFsignal(),addmism);
     track->SetTOFsignalTunedOnData(tofSignal);
     return (Float_t)tofSignal;
 }
index ba0612a..8b559ce 100644 (file)
@@ -582,6 +582,17 @@ void AliPIDResponse::InitialiseEvent(AliVEvent *event, Int_t pass, Int_t run)
   // Set centrality percentile for EMCAL
   fEMCALResponse.SetCentrality(fCurrCentrality);
 
+  // switch off some TOF channel according to OADB to match data TOF matching eff 
+  if (fTuneMConData && ((fTuneMConDataMask & kDetTOF) == kDetTOF) && fTOFPIDParams->GetTOFmatchingLossMC() > 0.01){
+    Int_t ntrk = event->GetNumberOfTracks();
+    for(Int_t i=0;i < ntrk;i++){
+      AliVParticle *trk = event->GetTrack(i);
+      Int_t channel = GetTOFResponse().GetTOFchannel(trk);
+      Int_t swoffEachOfThem = Int_t(100./fTOFPIDParams->GetTOFmatchingLossMC() + 0.5);
+      if(!(channel%swoffEachOfThem)) ((AliVTrack *) trk)->ResetStatus(AliVTrack::kTOFout);
+    }
+  }
+
 }
 
 //______________________________________________________________________________
@@ -1528,7 +1539,11 @@ void AliPIDResponse::InitializeTOFResponse(){
   AliInfo(Form("  StartTime method %d",fTOFPIDParams->GetStartTimeMethod()));
   AliInfo(Form("  TOF res. mom. params: %5.2f %5.2f %5.2f %5.2f",
                fTOFPIDParams->GetSigParams(0),fTOFPIDParams->GetSigParams(1),fTOFPIDParams->GetSigParams(2),fTOFPIDParams->GetSigParams(3)));
-  
+  AliInfo(Form("  Fraction of tracks within gaussian behaviour: %6.4f",fTOFPIDParams->GetTOFtail()));
+  AliInfo(Form("  MC: Fraction of tracks (percentage) to cut to fit matching in data: %6.2f%%",fTOFPIDParams->GetTOFmatchingLossMC()));
+  AliInfo(Form("  MC: Fraction of random hits (percentage) to add to fit mismatch in data: %6.2f%%",fTOFPIDParams->GetTOFadditionalMismForMC()));
+  AliInfo(Form("  Start Time Offset %6.2f ps",fTOFPIDParams->GetTOFtimeOffset()));
+
   for (Int_t i=0;i<4;i++) {
     fTOFResponse.SetTrackParameter(i,fTOFPIDParams->GetSigParams(i));
   }
@@ -1717,12 +1732,16 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
   // Set TOF response function
   // Input option for event_time used
   //
-  
+
     Float_t t0spread = 0.; //vevent->GetEventTimeSpread();
     if(t0spread < 10) t0spread = 80;
 
-    // T0 from TOF algorithm
+    // T0-FILL and T0-TO offset (because of TOF misallignment
+    Float_t starttimeoffset = 0;
+    if(fTOFPIDParams && !(fIsMC)) starttimeoffset=fTOFPIDParams->GetTOFtimeOffset();
+
 
+    // T0 from TOF algorithm
     Bool_t flagT0TOF=kFALSE;
     Bool_t flagT0T0=kFALSE;
     Float_t *startTime = new Float_t[fTOFResponse.GetNmomBins()];
@@ -1758,6 +1777,8 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
        startTime[i]=tofHeader->GetDefaultEventTimeVal();
        startTimeRes[i]=tofHeader->GetDefaultEventTimeRes();
        if(startTimeRes[i] < 1.e-5) startTimeRes[i] = t0spread;
+
+       if(startTimeRes[i] > t0spread - 10 && TMath::Abs(startTime[i]) < 0.001) startTime[i] = -starttimeoffset; // apply offset for T0-fill
       }
 
       TArrayI *ibin=(TArrayI*)tofHeader->GetNvalues();
@@ -1768,6 +1789,7 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
        startTime[icurrent]=t0Bin->GetAt(j);
        startTimeRes[icurrent]=t0ResBin->GetAt(j);
        if(startTimeRes[icurrent] < 1.e-5) startTimeRes[icurrent] = t0spread;
+       if(startTimeRes[icurrent] > t0spread - 10 && TMath::Abs(startTime[icurrent]) < 0.001) startTime[icurrent] = -starttimeoffset; // apply offset for T0-fill
       }
     }
 
@@ -1777,7 +1799,7 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
 
     if(option == kFILL_T0){ // T0-FILL is used
        for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-         estimatedT0event[i]=0.0;
+         estimatedT0event[i]=0.0-starttimeoffset;
          estimatedT0resolution[i]=t0spread;
        }
        fTOFResponse.SetT0event(estimatedT0event);
@@ -1795,7 +1817,7 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
        }
        else{
            for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             estimatedT0event[i]=0.0;
+             estimatedT0event[i]=0.0-starttimeoffset;
              estimatedT0resolution[i]=t0spread;
              fTOFResponse.SetT0binMask(i,startTimeMask[i]);
            }
@@ -1808,12 +1830,12 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
        Float_t t0A=-10000;
        Float_t t0C=-10000;
        if(flagT0T0){
-           t0A= vevent->GetT0TOF()[1];
-           t0C= vevent->GetT0TOF()[2];
+           t0A= vevent->GetT0TOF()[1] - starttimeoffset;
+           t0C= vevent->GetT0TOF()[2] - starttimeoffset;
         //      t0AC= vevent->GetT0TOF()[0];
-        t0AC= t0A/resT0A/resT0A + t0C/resT0C/resT0C;
-        resT0AC= TMath::Sqrt(1./resT0A/resT0A + 1./resT0C/resT0C);
-        t0AC /= resT0AC*resT0AC;
+           t0AC= t0A/resT0A/resT0A + t0C/resT0C/resT0C;
+           resT0AC= TMath::Sqrt(1./resT0A/resT0A + 1./resT0C/resT0C);
+           t0AC /= resT0AC*resT0AC;
        }
 
        Float_t t0t0Best = 0;
@@ -1869,7 +1891,7 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
                estimatedT0resolution[i]=t0t0BestRes;
              }
              else{
-               estimatedT0event[i]=0.0;
+               estimatedT0event[i]=0.0-starttimeoffset;
                estimatedT0resolution[i]=t0spread;
              }
            }
@@ -1883,12 +1905,12 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
        Float_t t0A=-10000;
        Float_t t0C=-10000;
        if(flagT0T0){
-           t0A= vevent->GetT0TOF()[1];
-           t0C= vevent->GetT0TOF()[2];
+           t0A= vevent->GetT0TOF()[1] - starttimeoffset;
+           t0C= vevent->GetT0TOF()[2] - starttimeoffset;
         //      t0AC= vevent->GetT0TOF()[0];
-        t0AC= t0A/resT0A/resT0A + t0C/resT0C/resT0C;
-        resT0AC= TMath::Sqrt(1./resT0A/resT0A + 1./resT0C/resT0C);
-        t0AC /= resT0AC*resT0AC;
+           t0AC= t0A/resT0A/resT0A + t0C/resT0C/resT0C;
+           resT0AC= TMath::Sqrt(1./resT0A/resT0A + 1./resT0C/resT0C);
+           t0AC /= resT0AC*resT0AC;
        }
 
        if(TMath::Abs(t0A) < t0cut && TMath::Abs(t0C) < t0cut && TMath::Abs(t0C-t0A) < 500){
@@ -1914,7 +1936,7 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
        }
        else{
            for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             estimatedT0event[i]=0.0;
+             estimatedT0event[i]= 0.0 - starttimeoffset;
              estimatedT0resolution[i]=t0spread;
              fTOFResponse.SetT0binMask(i,0);
            }
@@ -1922,6 +1944,7 @@ void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
        fTOFResponse.SetT0event(estimatedT0event);
        fTOFResponse.SetT0resolution(estimatedT0resolution);
     }
+
     delete [] startTime;
     delete [] startTimeRes;
     delete [] startTimeMask;
index 91d1c6a..cbdea74 100644 (file)
@@ -118,6 +118,7 @@ public:
   // pid status
   EDetPidStatus CheckPIDStatus(EDetector detCode, const AliVTrack *track)  const;
 
+  AliTOFPIDParams *GetTOFPIDParams() const {return fTOFPIDParams;}
   Float_t GetTOFMismatchProbability(const AliVTrack *track) const;
   
   void SetITSPIDmethod(ITSPIDmethod pmeth) { fITSPIDmethod = pmeth; }
@@ -173,7 +174,7 @@ public:
   AliPIDResponse(const AliPIDResponse &other);
   AliPIDResponse& operator=(const AliPIDResponse &other);
 
-  
+
 protected:
   AliITSPIDResponse   fITSResponse;    //PID response function of the ITS
   AliTPCPIDResponse   fTPCResponse;    //PID response function of the TPC
index 5d22244..26db33d 100644 (file)
@@ -26,6 +26,7 @@
 #include "TH1F.h"
 #include "TH1D.h"
 #include "TFile.h"
+#include "TRandom.h"
 
 #include "AliTOFPIDResponse.h"
 
@@ -222,8 +223,19 @@ Int_t AliTOFPIDResponse::GetStartTimeMask(Float_t mom) const {
 
 }
 //_________________________________________________________________________
-Double_t AliTOFPIDResponse::GetTailRandomValue() // generate a random value to add a tail to TOF time (for MC analyses)
+Double_t AliTOFPIDResponse::GetTailRandomValue(Float_t pt,Float_t eta,Float_t time,Float_t addmism) // generate a random value to add a tail to TOF time (for MC analyses)
 {
+
+  // To add mismatch
+  Float_t mismAdd = addmism*0.01;
+  if(pt>1.0) mismAdd /= pt;
+
+  if(mismAdd > 0.01){ // apply additional mismatch
+    if(gRandom->Rndm() < mismAdd){
+      return GetMismatchRandomValue(eta)-time;
+    }
+  }
+
   if(fTOFtailResponse)
     return fTOFtailResponse->GetRandom();
   else
@@ -255,3 +267,11 @@ Double_t AliTOFPIDResponse::GetMismatchRandomValue(Float_t eta) // generate a ra
           
   return fHmismTOF->GetRandom() + distIP*3.35655419905265973e+01;
 }
+//_________________________________________________________________________
+Int_t AliTOFPIDResponse::GetTOFchannel(AliVParticle *trk) const{
+  Float_t etaAbs = TMath::Abs(trk->Eta());
+  Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs);
+  if(channel < 1 || etaAbs > 1) channel = 1; 
+  
+  return channel;
+}
index c1d5132..24934b0 100644 (file)
@@ -39,7 +39,7 @@ public:
 
   Double_t GetMismatchProbability(Double_t p,Double_t mass) const;
 
-  static Double_t GetTailRandomValue(); // generate a random value to add a tail to TOF time (for MC analyses)
+  static Double_t GetTailRandomValue(Float_t pt=1.0,Float_t eta=0.0,Float_t time=0.0,Float_t addmism=0.0); // generate a random value to add a tail to TOF time (for MC analyses), addmism = additional mismatch in percentile
   static Double_t GetMismatchRandomValue(Float_t eta); // generate a random value for mismatched tracks (for MC analyses)
 
   void     SetT0event(Float_t *t0event){for(Int_t i=0;i < fNmomBins;i++) fT0event[i] = t0event[i];};
@@ -65,6 +65,7 @@ public:
   // Tracking resolution for expected times
   void SetTrackParameter(Int_t ip,Float_t value){if(ip>=0 && ip < 4) fPar[ip] = value;};
   Float_t GetTrackParameter(Int_t ip){if(ip>=0 && ip < 4) return fPar[ip]; else return -1.0;};
+  Int_t GetTOFchannel(AliVParticle *trk) const;
 
  private:
   Double_t fSigma;        // intrinsic TOF resolution