3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* Hege Erdal <hege.erdal@gmail.com> *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /// @file AliDxHFEParticleSelectionMCEl.cxx
20 /// @author Hege Erdal, Matthias Richter
22 /// @brief MC El selection for D0-HFE correlation
25 #include "AliDxHFEParticleSelectionMCEl.h"
26 #include "AliVParticle.h"
28 #include "THnSparse.h"
29 #include "AliAODMCParticle.h"
32 #include "AliAODTrack.h"
33 #include "AliReducedParticle.h"
42 /// ROOT macro for the implementation of ROOT specific class methods
43 ClassImp(AliDxHFEParticleSelectionMCEl)
45 AliDxHFEParticleSelectionMCEl::AliDxHFEParticleSelectionMCEl(const char* opt)
46 : AliDxHFEParticleSelectionEl(opt)
48 , fPDGnotMCElectron(NULL)
58 fMCTools.~AliDxHFEToolsMC();
60 // TODO: argument scan, build tool options accordingly
61 // e.g. set mc mode first/last, skip control histograms
62 TString toolopt("pdg=11 mc-last");
63 new (&fMCTools) AliDxHFEToolsMC(toolopt);
66 //at the moment not used, keep for now (to be used when plotting)
67 const char* AliDxHFEParticleSelectionMCEl::fgkPDGMotherBinLabels[]={
82 const char* AliDxHFEParticleSelectionMCEl::fgkPDGBinLabels[]={
96 AliDxHFEParticleSelectionMCEl::~AliDxHFEParticleSelectionMCEl()
100 if(fPDGnotMCElectron){
101 delete fPDGnotMCElectron;
102 fPDGnotMCElectron=NULL;
107 int AliDxHFEParticleSelectionMCEl::Init()
113 iResult=AliDxHFEParticleSelectionEl::Init();
114 if (iResult<0) return iResult;
116 // Histo containing PDG of track which was not MC truth electron
117 fPDGnotMCElectron= new TH1F("fPDGnotMCElectron","PDG of track not MC truth electron",AliDxHFEToolsMC::kNofPDGLabels,-0.5,AliDxHFEToolsMC::kNofPDGLabels-0.5);
118 for (int iLabel=0; iLabel<AliDxHFEToolsMC::kNofPDGLabels; iLabel++)
119 fPDGnotMCElectron->GetXaxis()->SetBinLabel(iLabel+1, fgkPDGBinLabels[iLabel]);
120 AddControlObject(fPDGnotMCElectron);
124 THnSparse* AliDxHFEParticleSelectionMCEl::DefineTHnSparse()
127 // Defines the THnSparse.
129 const int thnSize = 4;
130 InitTHnSparseArray(thnSize);
131 const double Pi=TMath::Pi();
133 name.Form("%s info", GetName());
137 int thnBins[thnSize] = { 1000, 200, 500, 14 };
138 double thnMin [thnSize] = { 0, 0, -1., -1.5 };
139 double thnMax [thnSize] = { 100, 2*Pi, 1., 12.5 };
140 const char* thnNames[thnSize]={
144 "Mother", //bin==-1: Not MC truth electron
147 return CreateControlTHnSparse(name,thnSize,thnBins,thnMin,thnMax,thnNames);
150 int AliDxHFEParticleSelectionMCEl::FillParticleProperties(AliVParticle* p, Double_t* data, int dimension) const
152 // fill the data array from the particle data
153 if (!data) return -EINVAL;
154 AliAODTrack *track=(AliAODTrack*)p;
155 if (!track) return -ENODATA;
157 if (dimension!=GetDimTHnSparse()) {
158 // TODO: think about filling only the available data and throwing a warning
161 data[i++]=track->Pt();
162 data[i++]=track->Phi();
163 data[i++]=track->Eta();
164 data[i++]=fOriginMother;
169 int AliDxHFEParticleSelectionMCEl::IsSelected(AliVParticle* p, const AliVEvent* pEvent)
171 /// overloaded from AliDxHFEParticleSelection: check particle
172 /// H: Have changed function. Now doing particle selection first, then run MC over
173 /// selected tracks. Could configure it to be configurable, but not sure if it
175 /// Result from normal track selection is returned, result from MC is stored in
183 // optional MC selection before the particle selection
184 if (fMCTools.MCFirst() && (iResult=CheckMC(p, pEvent))==0) {
189 // step 2 or 1, depending on sequence:
190 // normal particle selection
191 iResult=AliDxHFEParticleSelectionEl::IsSelected(p, pEvent);
192 if (fMCTools.MCFirst() || iResult==0) return iResult;
194 // step 2, only executed if MC check is last
195 // optional MC selection after the particle selection
196 // result stored to be filled into THnSparse
197 // TODO: strictly speaken the particles should be rejected
198 // if not mc selected, however skip this for the moment, because of
200 fResultMC=CheckMC(p, pEvent);
205 int AliDxHFEParticleSelectionMCEl::CheckMC(AliVParticle* p, const AliVEvent* pEvent)
207 /// check if MC criteria are fulfilled
214 if (!fMCTools.IsInitialized() && (iResult=fMCTools.InitMCParticles(pEvent))<0) {
215 // TODO: message? but has to be filtered in order to avoid message flood
216 return 0; // no meaningful filtering on mc possible
220 if (fMCTools.RejectByPDG(p,false, &pdgParticle)) {
222 // TODO: Move this to fMCTools???? Can this be part of the statistics in the MC class?
223 fPDGnotMCElectron->Fill(fMCTools.MapPDGLabel(pdgParticle));
228 pdgMother=fMCTools.FindMotherPDG(p,AliDxHFEToolsMC::kGetFirstMother);
230 // Particles considered HFE background. can be expanded
231 // Should be created only once
232 // TODO: that needs to be configured once to avoid performance penalty
233 vector<int> motherPDGs;
234 motherPDGs.push_back(AliDxHFEToolsMC::kPDGpi0);
235 motherPDGs.push_back(AliDxHFEToolsMC::kPDGeta);
236 motherPDGs.push_back(AliDxHFEToolsMC::kPDGgamma);
237 motherPDGs.push_back(AliDxHFEToolsMC::kPDGJpsi);
239 if(fMCTools.RejectByPDG(pdgMother,motherPDGs)){
240 pdgMother=fMCTools.FindMotherPDG(p,AliDxHFEToolsMC::kGetOriginMother);
241 fOriginMother=fMCTools.GetOriginMother();
244 //TODO: Could this be done in a more elegant way?
246 case(AliDxHFEToolsMC::kPDGpi0): fOriginMother=AliDxHFEToolsMC::kNrOrginMother; break;
247 case(AliDxHFEToolsMC::kPDGeta): fOriginMother=AliDxHFEToolsMC::kNrOrginMother+1; break;
248 case(AliDxHFEToolsMC::kPDGgamma): fOriginMother=AliDxHFEToolsMC::kNrOrginMother+2;break;
249 case(AliDxHFEToolsMC::kPDGJpsi): fOriginMother=AliDxHFEToolsMC::kNrOrginMother+3;break;
253 /*if (fMCTools.RejectByMotherPDG(p)) {
254 // rejected by pdg of original mother
255 // H: want pdg of origin process to be stored in THnSparse
256 // Not sure if this is needed... Need to check, using AliDxHFEToolsMC, who
257 // first mother are, and also what origin is. Use this info here.
264 void AliDxHFEParticleSelectionMCEl::Clear(const char* option)
266 /// clear internal memory
267 fMCTools.Clear(option);
270 AliVParticle *AliDxHFEParticleSelectionMCEl::CreateParticle(AliVParticle* track)
273 AliReducedParticle *part = new AliReducedParticle(track->Eta(), track->Phi(), track->Pt(),track->Charge(),fOriginMother);