]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Savannah item #47411: implemented n-sigma getters in the AliTOFpidESD class (Y.Belikov)
authordecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 28 Apr 2009 11:26:01 +0000 (11:26 +0000)
committerdecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 28 Apr 2009 11:26:01 +0000 (11:26 +0000)
TOF/AliTOFpidESD.cxx
TOF/AliTOFpidESD.h

index 6bb14e0b81fe8331c808f92ab0dd35c169b36a10..98056517ae1676f8e1d5625cacc345c36fe3d41d 100644 (file)
@@ -34,14 +34,16 @@ ClassImp(AliTOFpidESD)
 AliTOFpidESD::AliTOFpidESD(): 
   fSigma(0),
   fRange(0),
-  fPmax(0)         // zero at 0.5 GeV/c for pp
+  fPmax(0),         // zero at 0.5 GeV/c for pp
+  fTime0(0)
 {
 }
 //_________________________________________________________________________
 AliTOFpidESD::AliTOFpidESD(Double_t *param):
   fSigma(param[0]),
   fRange(param[1]),
-  fPmax(0)          // zero at 0.5 GeV/c for pp
+  fPmax(0),          // zero at 0.5 GeV/c for pp
+  fTime0(0)
 {
   //
   //  The main constructor
@@ -51,6 +53,7 @@ AliTOFpidESD::AliTOFpidESD(Double_t *param):
   //fPmax=TMath::Exp(-0.5*3*3)/fSigma; // ~3 sigma at 0.5 GeV/c for PbPb 
 }
 
+//_________________________________________________________________________
 Double_t 
 AliTOFpidESD::GetMismatchProbability(Double_t p, Double_t mass) const {
   //
@@ -75,6 +78,17 @@ Int_t AliTOFpidESD::MakePID(AliESDEvent *event, Double_t timeZero)
   AliDebug(1,Form("TOF PID Parameters: Sigma (ps)= %f, Range= %f",fSigma,fRange));
   AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
 
+  fTime0=timeZero;
+  return MakePID(event);  
+}
+
+//_________________________________________________________________________
+Int_t AliTOFpidESD::MakePID(AliESDEvent *event)
+{
+  //
+  //  This function calculates the "detector response" PID probabilities
+  //                Just for a bare hint... 
+
   Int_t ntrk=event->GetNumberOfTracks();
   AliESDtrack **tracks=new AliESDtrack*[ntrk];
 
@@ -88,28 +102,54 @@ Int_t AliTOFpidESD::MakePID(AliESDEvent *event, Double_t timeZero)
     AliESDtrack *t=tracks[i];
     if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
     if ((t->GetStatus()&AliESDtrack::kTIME)==0) continue;
-    Double_t tof=t->GetTOFsignal()-timeZero;
-    Double_t time[10]; t->GetIntegratedTimes(time);
-    Double_t p[10];
-    Double_t mom=t->GetP();
-    Bool_t mismatch=kTRUE, heavy=kTRUE;
+
+    Double_t time[AliPID::kSPECIES];
+    if (!ExpectedSignals(t,time,AliPID::kSPECIES)) continue;
+    Double_t sigma[AliPID::kSPECIES];
+    if (!ExpectedSigmas(t,sigma,AliPID::kSPECIES)) continue;
+
+    AliDebug(2,Form("Expected TOF signals [ps]: %f %f %f %f %f",
+                   GetExpectedSignal(t,AliPID::kElectron),
+                   GetExpectedSignal(t,AliPID::kMuon),
+                   GetExpectedSignal(t,AliPID::kPion),
+                   GetExpectedSignal(t,AliPID::kKaon),
+                   GetExpectedSignal(t,AliPID::kProton)
+                   ));
+
+    AliDebug(2,Form("Expected TOF std deviations [ps]: %f %f %f %f %f",
+                   GetExpectedSigma(t,AliPID::kElectron),
+                   GetExpectedSigma(t,AliPID::kMuon),
+                   GetExpectedSigma(t,AliPID::kPion),
+                   GetExpectedSigma(t,AliPID::kKaon),
+                   GetExpectedSigma(t,AliPID::kProton)
+                   ));
+
+    AliDebug(2,Form("Expected TOF std deviations [number of expected sigmas]: %f %f %f %f %f",
+                   GetNumberOfSigmas(t,AliPID::kElectron),
+                   GetNumberOfSigmas(t,AliPID::kMuon),
+                   GetNumberOfSigmas(t,AliPID::kPion),
+                   GetNumberOfSigmas(t,AliPID::kKaon),
+                   GetNumberOfSigmas(t,AliPID::kProton)
+                   ));
+
+    Double_t tof = t->GetTOFsignal() - fTime0;
+
+    Double_t p[AliPID::kSPECIES];
+    Bool_t mismatch = kTRUE, heavy = kTRUE;
     for (Int_t j=0; j<AliPID::kSPECIES; j++) {
-      Double_t mass=AliPID::ParticleMass(j);
-      Double_t dpp=0.01;      //mean relative pt resolution;
-      if (mom>0.5) dpp=0.01*mom;
-      Double_t sigma=dpp*time[j]/(1.+ mom*mom/(mass*mass));
-      sigma=TMath::Sqrt(sigma*sigma + fSigma*fSigma);
-      if (TMath::Abs(tof-time[j]) > fRange*sigma) {
-       p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
-      } else 
-        p[j]=TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sigma*sigma))/sigma;
+      Double_t sig = sigma[j];
+      if (TMath::Abs(tof-time[j]) > fRange*sig) {
+       p[j] = TMath::Exp(-0.5*fRange*fRange)/sig;
+      } else
+        p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig;
 
       // Check the mismatching
-      Double_t pm=GetMismatchProbability(mom,mass);
-      if (p[j]>pm) mismatch=kFALSE;
+      Double_t mass = AliPID::ParticleMass(j);
+      Double_t pm = GetMismatchProbability(t->GetP(),mass);
+      if (p[j]>pm) mismatch = kFALSE;
 
       // Check for particles heavier than (AliPID::kSPECIES - 1)
-      if (tof < (time[j] + fRange*sigma)) heavy=kFALSE;
+      if (tof < (time[j] + fRange*sig)) heavy=kFALSE;
 
     }
 
@@ -128,61 +168,125 @@ Int_t AliTOFpidESD::MakePID(AliESDEvent *event, Double_t timeZero)
 }
 
 //_________________________________________________________________________
-Int_t AliTOFpidESD::MakePID(AliESDEvent *event)
+Bool_t AliTOFpidESD::ExpectedSignals(const AliESDtrack *t,
+                                     Double_t s[],Int_t n) const
 {
   //
-  //  This function calculates the "detector response" PID probabilities
-  //                Just for a bare hint... 
+  // Return the expected PID signals for the involved particle species
+  //
 
-  Int_t ntrk=event->GetNumberOfTracks();
-  AliESDtrack **tracks=new AliESDtrack*[ntrk];
+  if (n > AliPID::kSPECIESN)          return kFALSE;
+  if ( !t->IsOn(AliESDtrack::kTIME) ) return kFALSE;
 
-  Int_t i;
-  for (i=0; i<ntrk; i++) {
-    AliESDtrack *t=event->GetTrack(i);
-    tracks[i]=t;
+  Double_t time[AliPID::kSPECIESN];
+  t->GetIntegratedTimes(time);
+  for (Int_t i=0; i<n; i++) s[i]=time[i];
+  return kTRUE;
+}
+
+//_________________________________________________________________________
+Bool_t AliTOFpidESD::ExpectedSigmas(const AliESDtrack *t,
+                                     Double_t s[],Int_t n) const
+{
+  //
+  // Return the expected sigma of PID signals for the involved
+  // particle species.
+  // This approximate (but reasonable) formula takes into account the
+  // relative momentum resolution.
+  //
+
+  Double_t time[AliPID::kSPECIESN];
+  if ( !ExpectedSignals(t,time,n) ) return kFALSE;
+
+  Double_t mom = t->GetP();
+  Double_t dpp = 0.01;      //mean relative pt resolution;
+  if (mom>0.5) dpp = 0.01*mom;
+  for (Int_t i=0; i<n; i++) {
+    Double_t mass = AliPID::ParticleMass(i);
+    Double_t sigma = dpp*time[i]/(1.+ mom*mom/(mass*mass));
+    s[i] = TMath::Sqrt(sigma*sigma + fSigma*fSigma);
   }
+  return kTRUE;  
+}
 
-  for (i=0; i<ntrk; i++) {
-    AliESDtrack *t=tracks[i];
-    if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
-    if ((t->GetStatus()&AliESDtrack::kTIME)==0) continue;
-    Double_t tof=t->GetTOFsignal();
-    Double_t time[10]; t->GetIntegratedTimes(time);
-    Double_t p[10];
-    Double_t mom=t->GetP();
-    Bool_t mismatch=kTRUE, heavy=kTRUE;
-    for (Int_t j=0; j<AliPID::kSPECIES; j++) {
-      Double_t mass=AliPID::ParticleMass(j);
-      Double_t dpp=0.01;      //mean relative pt resolution;
-      if (mom>0.5) dpp=0.01*mom;
-      Double_t sigma=dpp*time[j]/(1.+ mom*mom/(mass*mass));
-      sigma=TMath::Sqrt(sigma*sigma + fSigma*fSigma);
-      if (TMath::Abs(tof-time[j]) > fRange*sigma) {
-       p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
-      } else
-        p[j]=TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sigma*sigma))/sigma;
+//_________________________________________________________________________
+Bool_t AliTOFpidESD::NumberOfSigmas(const AliESDtrack *t,
+                                    Double_t s[],Int_t n) const
+{
+  //
+  // Returns the deviation of the actual PID signal from the expected
+  // signal, in units of expected sigmas.
+  //
 
-      // Check the mismatching
-      Double_t pm=GetMismatchProbability(mom,mass);
-      if (p[j]>pm) mismatch=kFALSE;
+  Double_t time[AliPID::kSPECIESN];
+  if ( !ExpectedSignals(t,time,n) ) return kFALSE;
 
-      // Check for particles heavier than (AliPID::kSPECIES - 1)
-      if (tof < (time[j] + fRange*sigma)) heavy=kFALSE;
+  if ( !ExpectedSigmas(t,s,n) ) return kFALSE;
+  
+  Double_t tof = t->GetTOFsignal() - fTime0;
+  for (Int_t i=0; i<n; i++) s[i] = (time[i]-tof)/s[i];
+      
+  return kTRUE;
+}
 
-    }
+//_________________________________________________________________________
+ Double_t AliTOFpidESD::GetExpectedSignal(const AliESDtrack *t,
+                                          AliPID::EParticleType n) const
+{
+  //
+  // Return the expected PID signal for the specified particle type.
+  // If the operation is not possible, return a negative value.
+  //
 
-    if (mismatch)
-       for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
+  if (Int_t(n) >= AliPID::kSPECIESN)        return -1.;
+  if ( !t->IsOn(AliESDtrack::kTIME) ) return -1.;
 
-    t->SetTOFpid(p);
+  Double_t time[AliPID::kSPECIESN];
+  t->GetIntegratedTimes(time);
 
-    if (heavy) t->ResetStatus(AliESDtrack::kTOFpid);    
+  return time[n];
+}
 
-  }
+//_________________________________________________________________________
+ Double_t AliTOFpidESD::GetExpectedSigma(const AliESDtrack *t,
+                                         AliPID::EParticleType n) const
+{
+  //
+  // Return the expected sigma of the PID signal for the specified
+  // particle type.
+  // If the operation is not possible, return a negative value.
+  //
 
-  delete[] tracks;
-  
-  return 0;
+  Double_t time[AliPID::kSPECIESN];
+  if ( !ExpectedSignals(t,time,AliPID::kSPECIESN) ) return -1.;
+
+  Double_t mom = t->GetP();
+  Double_t dpp = 0.01;      //mean relative pt resolution;
+  if (mom>0.5) dpp = 0.01*mom;
+
+  Double_t mass = AliPID::ParticleMass(n);
+  Double_t sigma = dpp*time[n]/(1.+ mom*mom/(mass*mass));
+
+  return TMath::Sqrt(sigma*sigma + fSigma*fSigma);
 }
 
+//_________________________________________________________________________
+ Double_t AliTOFpidESD::GetNumberOfSigmas(const AliESDtrack *t,
+                                          AliPID::EParticleType n) const
+{
+  //
+  // Returns the deviation of the actual PID signal from the expected
+  // signal for the specified particle type, in units of expected
+  // sigmas.
+  // If the operation is not possible, return a negative value.
+  //
+
+  Double_t time=GetExpectedSignal(t,n);;
+  if (time < 0.) return -1.;
+
+  Double_t sigma=GetExpectedSigma(t,n);
+  if (sigma < 0.) return -1;
+  
+  Double_t tof=t->GetTOFsignal() - fTime0;
+  return (time-tof)/sigma;
+}
index aa39bb49c277ea3580a0b42360da2b27511bf315..9116a5bfe883bf091a7ee4f72b57dea86d42e946 100644 (file)
 //-------------------------------------------------------
 
 #include "TObject.h"
+#include "AliPID.h"
 
 class AliESDEvent;
-
-class AliTOFGeometry;
+class AliESDtrack;
 
 class AliTOFpidESD : public TObject {
 public:
@@ -21,20 +21,41 @@ public:
   AliTOFpidESD(Double_t *param);
  ~AliTOFpidESD(){}
  
+  void     SetTimeZero(Double_t t0) { fTime0=t0; }
+  Double_t GetTimeZero() const { return fTime0; }
+
   void     SetMaxMismatchProbability(Double_t p) {fPmax=p;}
   Double_t GetMaxMismatchProbability() const {return fPmax;}
 
   Int_t MakePID(AliESDEvent *event);
   Int_t MakePID(AliESDEvent *event, Double_t timeZero);
 
+  Bool_t ExpectedSignals(const AliESDtrack *t, 
+                          Double_t s[], 
+                          Int_t n=AliPID::kSPECIES) const;
+  Bool_t ExpectedSigmas(const AliESDtrack *t, 
+                         Double_t s[],
+                         Int_t n=AliPID::kSPECIES) const;
+  Bool_t NumberOfSigmas(const AliESDtrack *t, 
+                         Double_t s[],
+                         Int_t n=AliPID::kSPECIES) const;
+
+  Double_t GetExpectedSignal(const AliESDtrack *t,
+                     AliPID::EParticleType n=AliPID::kKaon) const;
+  Double_t GetExpectedSigma(const AliESDtrack *t,
+                     AliPID::EParticleType n=AliPID::kKaon) const;
+  Double_t GetNumberOfSigmas(const AliESDtrack *t,
+                     AliPID::EParticleType n=AliPID::kKaon) const;
+
 private:
   Double_t GetMismatchProbability(Double_t p,Double_t mass) const;
 
   Double_t fSigma;        // intrinsic TOF resolution
   Double_t fRange;        // one particle type PID range (in sigmas)
   Double_t fPmax;         // "maximal" probability of mismathing (at ~0.5 GeV/c)
+  Double_t fTime0;        // time zero
 
-  ClassDef(AliTOFpidESD,2)   // TOF PID class
+  ClassDef(AliTOFpidESD,3)   // TOF PID class
 };
 
 #endif