]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSpidESD2.cxx
Update of PID 2 to the present recpoint normalisation
[u/mrichter/AliRoot.git] / ITS / AliITSpidESD2.cxx
1 /**************************************************************************
2  * Copyright(c) 2005-2007, 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 /* $Id$ */
17
18 //-----------------------------------------------------------------------//
19 // ITS PID class --- method # 2                                          //
20 //                                                                       //
21 //                                                                       //
22 //The PID is based on the likelihood of all the four ITS' layers,        //
23 //without using the truncated mean for the dE/dx. The response           //
24 //functions for each layer are convoluted Landau-Gaussian functions.     // 
25 // Origin: Elena Bruna bruna@to.infn.it, Massimo Masera masera@to.infn.it//
26 //-----------------------------------------------------------------------//
27
28 #include "AliITSpidESD2.h"
29 #include "AliESDEvent.h"
30 #include "AliESDtrack.h"
31 #include "AliITStrackV2.h"
32 #include "AliITSRecPoint.h"
33 #include "AliITStrackerMI.h"
34 #include "AliITSLoader.h"
35 #include "AliITSPident.h"
36 #include "AliITSSteerPid.h"
37 #include "AliLog.h"
38
39 ClassImp(AliITSpidESD2)
40 //_________________________________________________________________________
41   AliITSpidESD2::AliITSpidESD2():AliITSpidESD(),
42 fTracker(0),
43 fLoader(0),
44 fSp(0)
45 { //
46   //  The main constructor
47 }
48 //_________________________________________________________________________
49 AliITSpidESD2::AliITSpidESD2(AliITStrackerMI* tracker,AliITSLoader* loader):AliITSpidESD(),
50 fTracker(0),
51 fLoader(0),
52 fSp(0)
53 { //
54   //  The main constructor
55   fTracker=tracker;
56   fLoader=loader;
57   fSp=new AliITSSteerPid();
58   fSp->InitLayer();
59 }
60 //_________________________________________________________________________
61 AliITSpidESD2::~AliITSpidESD2(){
62   //destructor
63
64   if(fSp)delete fSp;
65
66 }
67 //______________________________________________________________________
68 AliITSpidESD2::AliITSpidESD2(const AliITSpidESD2 &ob) :AliITSpidESD(ob),
69 fTracker(ob.fTracker),
70 fLoader(ob.fLoader),
71 fSp(ob.fSp) 
72 {
73   // Copy constructor
74  
75 }
76
77 //______________________________________________________________________
78 AliITSpidESD2& AliITSpidESD2::operator=(const AliITSpidESD2& ob ){
79   // Assignment operator
80   this->~AliITSpidESD2();
81   new(this) AliITSpidESD2(ob);
82   return *this;
83 }
84
85 //_________________________________________________________________________
86 Int_t AliITSpidESD2::MakePID(AliESDEvent *event)
87 {
88
89   //
90   //  This function calculates the "detector response" PID probabilities 
91   //
92   Double_t xr,par[5];
93   AliITStrackV2* track=0;
94   fLoader->LoadRecPoints();
95   TTree *cTree=fLoader->TreeR();
96   fTracker->LoadClusters(cTree);
97   printf("==== Landau Fit PID ITS ====== \n");
98   Int_t ntrk=event->GetNumberOfTracks();
99   Double_t momits;
100   // for (Int_t i=0; i<ntrk; i++) {
101   for (Int_t i=0; i<ntrk; i++) {
102     AliESDtrack *esdtr=event->GetTrack(i);
103     if ((esdtr->GetStatus()&AliESDtrack::kITSin )==0)
104       if ((esdtr->GetStatus()&AliESDtrack::kITSout)==0) continue;
105
106     track = new AliITStrackV2(*esdtr);
107     Double_t dEdxsignal=track->GetdEdx();
108     track->GetExternalParameters(xr,par);
109     if (par[4]!=0) {
110       Float_t lamb=TMath::ATan(par[3]);
111       momits=1/(TMath::Abs(par[4])*TMath::Cos(lamb));
112     }
113     else {
114       AliWarning("Null particle momentum in ITS");
115       momits = 0.;
116     } 
117     Double_t snp=track->GetSnp();
118     Double_t tgl=track->GetTgl();
119     const Int_t kns=AliPID::kSPECIES;
120     Double_t condprobfun[kns];
121     for(Int_t ii=0;ii<kns;ii++)condprobfun[ii]=0;
122     Int_t cluind[12];
123     for(Int_t ii=0;ii<12;ii++){
124       cluind[ii]=track->GetClusterIndex(ii);
125     }
126     AliITSRecPoint* cluarr[12];
127     Float_t qclu[8],qclucorr[8],nlay[8];
128     for(Int_t ii=0;ii<8;ii++){
129       qclu[ii]=0;
130       qclucorr[ii]=0;
131       nlay[ii]=0;
132     }
133     Int_t jj=0;
134     cout<<"track = "<<i<<endl;
135     for(Int_t ij=0;ij<12;ij++){
136       cluind[ij]=track->GetClusterIndex(ij);
137       cout<<cluind[ij]<<endl;
138       if(cluind[ij]>0){
139         cluarr[ij]=(AliITSRecPoint*)fTracker->GetCluster(cluind[ij]);
140         Int_t lay=cluarr[ij]->GetLayer();
141         cout<<"lay = "<<lay<<endl;
142         if(lay>1){//sdd+ssd only
143           qclu[jj]=cluarr[ij]->GetQ(); 
144           qclucorr[jj]=qclu[jj]*TMath::Sqrt((1-snp*snp)/(1+tgl*tgl));
145           nlay[jj]=lay;
146           jj++;
147         }
148         else qclucorr[jj]=-1;
149       }
150     }
151
152     Float_t prip=0.33;
153     Float_t prik=0.33;
154     Float_t pripi=0.33;
155     Float_t prie=0.;
156     AliITSPident mypid(momits,dEdxsignal,fSp,qclucorr,nlay,prip,prik,pripi,prie); 
157     condprobfun[0]=mypid.GetProdCondFunPi();//el --PID in the ITS does not distinguish among Pi,el,mu
158     condprobfun[1]=mypid.GetProdCondFunPi();//mu
159     condprobfun[2]=mypid.GetProdCondFunPi();//pi
160     condprobfun[3]=mypid.GetProdCondFunK();//kaon
161     condprobfun[4]=mypid.GetProdCondFunPro();//pro
162
163     esdtr->SetITSpid(condprobfun);
164
165     delete track;
166   }
167   fTracker->UnloadClusters();
168   fLoader->UnloadRecPoints();
169   return 0;
170 }