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