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