]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCpidESD.cxx
Adding Extraction of OCDB entries - spline fits by default
[u/mrichter/AliRoot.git] / TPC / AliTPCpidESD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 //-----------------------------------------------------------------
17 //           Implementation of the TPC PID class
18 // Very naive one... Should be made better by the detector experts...
19 //      Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
20 //-----------------------------------------------------------------
21
22 #include "AliTPCpidESD.h"
23 #include "AliESDEvent.h"
24 #include "AliESDtrack.h"
25 #include "AliMathBase.h"
26
27 ClassImp(AliTPCpidESD)
28
29 //_________________________________________________________________________
30   AliTPCpidESD::AliTPCpidESD(Double_t *param):
31     fMIP(0.),
32     fRes(0.),
33     fRange(0.)
34 {
35   //
36   //  The main constructor
37   //
38   fMIP=param[0];
39   fRes=param[1];
40   fRange=param[2];
41 }
42
43 Double_t AliTPCpidESD::Bethe(Double_t betaGamma) {
44   //
45   // This is the Bethe-Bloch function normalised to 1 at the minimum
46   // WARNING
47   // Simulated and reconstructed Bethe-Bloch differs 
48   //           Simulated  curve is the dNprim/dx
49   //           Reconstructed is proportianal dNtot/dx
50   // Temporary fix for production -  Simple linear correction function
51   // Future    2 Bethe Bloch formulas needed
52   //           1. for simulation
53   //           2. for reconstructed PID
54   //
55   const Float_t kmeanCorrection =0.1;
56   Double_t bb = AliMathBase::BetheBlochAleph(betaGamma);
57   Double_t meanCorrection =(1+(bb-1)*kmeanCorrection);
58   bb *= meanCorrection;
59   return bb;
60 }
61
62 //_________________________________________________________________________
63 Int_t AliTPCpidESD::MakePID(AliESDEvent *event)
64 {
65   //
66   //  This function calculates the "detector response" PID probabilities 
67   //
68   Int_t ntrk=event->GetNumberOfTracks();
69   for (Int_t i=0; i<ntrk; i++) {
70     AliESDtrack *t=event->GetTrack(i);
71     if ((t->GetStatus()&AliESDtrack::kTPCin )==0)
72       if ((t->GetStatus()&AliESDtrack::kTPCout)==0) continue;
73     Double_t p[10];
74     Double_t mom=t->GetP();
75     const AliExternalTrackParam *in=t->GetInnerParam();
76     if (in) mom=in->GetP();
77     Double_t dedx=t->GetTPCsignal()/fMIP;
78     Bool_t mismatch=kTRUE, heavy=kTRUE;
79     for (Int_t j=0; j<AliPID::kSPECIES; j++) {
80       Double_t mass=AliPID::ParticleMass(j);
81       Double_t bethe=Bethe(mom/mass); 
82       Double_t sigma=fRes*bethe;
83       if (TMath::Abs(dedx-bethe) > fRange*sigma) {
84         p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
85       } else {
86         p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
87         mismatch=kFALSE;
88       }
89
90       // Check for particles heavier than (AliPID::kSPECIES - 1)
91       if (dedx < (bethe + fRange*sigma)) heavy=kFALSE;
92
93     }
94
95     if (mismatch)
96        for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
97
98     t->SetTPCpid(p);
99
100     if (heavy) t->ResetStatus(AliESDtrack::kTPCpid);
101
102   }
103   return 0;
104 }