]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/hfe/AliHFEV0pidMC.cxx
Possibility to select on the basis of the presence of at least a fake track among...
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEV0pidMC.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 /* $Id$ */
17
18 //
19 // class to benchmark the V0 pid capabilties
20 // runs over reconstructed V0 candidates and uses MC information for 
21 // further analysis [purity, PID perfortmance]
22 //
23 // authors:
24 //    Matus Kalisky <matus.kalisky@cern.ch>
25 //
26
27 #include "TIterator.h"
28
29 #include "AliVParticle.h"
30 #include "AliESDtrack.h"
31 #include "AliMCParticle.h"
32 #include "AliMCEvent.h"
33
34 #include "AliHFEcollection.h"
35
36 #include "AliHFEV0pidMC.h"
37 ClassImp(AliHFEV0pidMC)
38
39 //____________________________________________________________
40   AliHFEV0pidMC::AliHFEV0pidMC():
41     fMC(0x0)
42     , fColl(NULL)
43     , fV0cuts(NULL)
44 {
45   //
46   // default constructor
47   //
48
49 }
50 //____________________________________________________________
51 AliHFEV0pidMC::~AliHFEV0pidMC(){
52   //
53   // destructor
54   //
55   if (fColl) delete fColl;
56   //if (fV0cuts) delete fV0cuts;
57 }
58 //____________________________________________________________
59 void AliHFEV0pidMC::Init(){
60   //
61   // initialize objects
62   //
63
64   fColl = new AliHFEcollection("V0pidMC", "MC based V0 benchmarking");
65   // QA
66   fColl->CreateTH1F("h_QA_nParticles", "QA on track processing", 10, -0.5, 9.5);
67
68   const Int_t nBins = 20;
69   const Float_t pMin = 0.1;
70   const Float_t pMax = 10.;
71
72   // before PID
73   fColl->CreateTH1F("h_Electron", "all electron candidates (no MC); p (GeV/c); counts", nBins, pMin, pMax, 0);
74   fColl->CreateTH1F("h_PionK0", "all K0 pion candidates (no MC); p (GeV/c); counts",  nBins, pMin, pMax, 0);
75   fColl->CreateTH1F("h_PionL", "all Lambda pion candidates (no MC); p (GeV/c); counts", nBins, pMin, pMax, 0);
76   fColl->CreateTH1F("h_Kaon", "all Kaon candidates (no MC); p (GeV/c); counts",  nBins, pMin, pMax, 0);
77   fColl->CreateTH1F("h_Proton", "all Lambda proton candidates (no MC); p (GeV/c); counts",  nBins, pMin, pMax, 0);
78   
79   fColl->CreateTH1F("h_mis_Electron", "all NON electron candidates MC tagged; p (GeV/c); counts",  nBins, pMin, pMax, 0);
80   fColl->CreateTH1F("h_mis_PionK0", "all NON K0 pion candidates MC tagged; p (GeV/c); counts",  nBins, pMin, pMax, 0);
81   fColl->CreateTH1F("h_mis_PionL", "all NON Lambda pion candidates MC tagged ; p (GeV/c); counts", nBins, pMin, pMax, 0);
82   fColl->CreateTH1F("h_mis_Kaon", "all NON Kaon candidates MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
83   fColl->CreateTH1F("h_mis_Proton", "all NON Lambda proton candidates MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);  
84
85   fColl->CreateTH1Fvector1(5, "h_tag_Electron", "electron candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
86   fColl->CreateTH1Fvector1(5, "h_tag_PionK0", "K0 pion candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
87   fColl->CreateTH1Fvector1(5, "h_tag_PionL", "Lambda pion candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
88   fColl->CreateTH1Fvector1(5, "h_tag_Kaon", "kaon candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
89   fColl->CreateTH1Fvector1(5, "h_tag_Proton", "Lambda proton candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
90
91 }
92 //____________________________________________________________
93 Bool_t  AliHFEV0pidMC::Process(TObjArray * const particles, Int_t type){
94   //
95   // process the selected V0 daughter tracks
96   //
97   
98   TString hname;
99   const TString typeName[5] = {"Electron", "PionK0", "PionL", "Kaon", "Proton"};
100   const Int_t  typePID[5] = {0, 2, 2, 3, 4};
101
102   if(!fMC) return kFALSE;
103   if(!particles) return kFALSE;
104   
105   AliVParticle *recTrack = NULL;
106   TIterator *trackIter = particles->MakeIterator(); 
107   while((recTrack = dynamic_cast<AliVParticle *>(trackIter->Next()))){
108     fColl->Fill("h_QA_nParticles", 0);
109     // only ESD for now
110     AliESDtrack *track = dynamic_cast<AliESDtrack *>(recTrack);
111     if(!track) continue;
112     const AliExternalTrackParam *ext = track->GetOuterParam();
113     if(!ext) continue;
114     // MC label
115     Int_t label = track->GetLabel();
116     if(label <0){
117        fColl->Fill("h_QA_nParticles", 1);
118       continue;
119     }
120     AliMCParticle *mcpD = dynamic_cast<AliMCParticle*>(fMC->GetTrack(label));
121     if(!mcpD){
122       fColl->Fill("h_QA_nParticles", 2);
123       continue;
124     }
125
126     Float_t p = ext->P();
127     //Short_t charge = ext->Charge();
128     Int_t pdgD = mcpD->PdgCode();
129     AliMCParticle *mcpM = dynamic_cast<AliMCParticle*>(fMC->GetTrack(mcpD->GetMother()));
130     if(!mcpM){
131       fColl->Fill("h_QA_nParticles", 3);
132       continue;
133     }
134     //Int_t pdgM = mcpM->PdgCode();
135
136     // all candidates
137     hname = "h_" + typeName[type];
138     fColl->Fill(hname, p);
139     Int_t pidD = PDGtoPIDdaughter(pdgD);
140     
141     // all misidentified candidates
142     hname = "h_mis_" + typeName[type];
143     if(typePID[type] != pidD){
144       fColl->Fill(hname, p);
145     }
146
147     // for every particle fill detailed information about the missidentified particles
148     hname = "h_tag_" + typeName[type];
149     Int_t aliPID = PDGtoAliPID(pdgD);
150     fColl->Fill(hname, aliPID, p);
151     
152   }// .. loop over array
153   
154   
155   return kTRUE;
156 }  
157 //____________________________________________________________
158 Int_t AliHFEV0pidMC::PDGtoPIDdaughter(Int_t pdg) const {
159   //
160   // convert PDG to local pid 
161   //
162   switch (TMath::Abs(pdg)){
163   case 11:
164     return 0;  // electron gamma
165   case 211:
166     return 2; // pion K0 or pion Lambda
167   case 321:
168     return 3; //kaon Phi
169   case 2212:
170     return 4; // proton Lambda
171   default:
172     return -1;
173   };
174   
175   return -1;
176 }
177 //____________________________________________________________
178 Int_t AliHFEV0pidMC::PDGtoPIDmother(Int_t pdg) const {
179   //
180   // convert PDG to local pid
181   //
182   switch (TMath::Abs(pdg)){
183   case 22:
184       return 0; // gamma
185     case 310: 
186     return 1; // K0s
187   case 333:
188     return 2; // Phi
189   case 3122:
190     return 3; // Lambda
191   default:
192     return -1;
193   };
194   
195   return -1;
196 }
197 //____________________________________________________________
198 Int_t AliHFEV0pidMC::PDGtoAliPID(Int_t pdg) const {
199   //
200   // convert PDG to AliPID
201   //
202   
203   switch (TMath::Abs(pdg)){
204   case 11:
205     return 0; // electron 
206   case 13:
207     return 1; // muon
208   case 211:
209     return 2; // pion 
210   case 321:
211     return 3; // kaon 
212   case 2212:
213     return 4; // proton 
214   default:
215     return -1;
216   };
217   return -1;
218 }
219