]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSpidESD2.cxx
Using 2 recpoins per layer, if needed
[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 "AliITSRecPoint.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   printf("==== Landau Fit PID ITS ====== \n");
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 cluind[12];
121     for(Int_t ii=0;ii<12;ii++){
122       cluind[ii]=track->GetClusterIndex(ii);
123     }
124     AliITSRecPoint* cluarr[12];
125     Float_t qclu[8],qclucorr[8],nlay[8];
126     for(Int_t i=0;i<8;i++){
127       qclu[i]=0;
128       qclucorr[i]=0;
129       nlay[i]=0;
130     }
131     Int_t jj=0;
132     for(Int_t i=0;i<12;i++){
133       cluind[i]=track->GetClusterIndex(i);
134       if(cluind[i]>0){
135         cluarr[i]=(AliITSRecPoint*)fTracker->GetCluster(cluind[i]);
136         Int_t lay=cluarr[i]->GetLayer();
137         if(lay>1){//sdd+ssd only
138           qclu[jj]=cluarr[i]->GetQ(); 
139           qclucorr[jj]=qclu[jj]*TMath::Sqrt((1-snp*snp)/(1+tgl*tgl));
140           nlay[jj]=lay;
141           jj++;
142         }
143         else qclucorr[jj]=-1;
144       }
145     }
146
147     Float_t prip=0.33;
148     Float_t prik=0.33;
149     Float_t pripi=0.33;
150     Float_t prie=0.;
151     AliITSPident mypid(momits,dEdxsignal,fSp,qclucorr,nlay,prip,prik,pripi,prie); 
152     condprobfun[0]=mypid.GetProdCondFunPi();//el --PID in the ITS does not distinguish among Pi,el,mu
153     condprobfun[1]=mypid.GetProdCondFunPi();//mu
154     condprobfun[2]=mypid.GetProdCondFunPi();//pi
155     condprobfun[3]=mypid.GetProdCondFunK();//kaon
156     condprobfun[4]=mypid.GetProdCondFunPro();//pro
157
158     esdtr->SetITSpid(condprobfun);
159
160     delete track;
161    }
162   fTracker->UnloadClusters();
163   fLoader->UnloadRecPoints();
164   return 0;
165 }