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"
41 /// ROOT macro for the implementation of ROOT specific class methods
42 ClassImp(AliDxHFEParticleSelectionMCEl)
44 AliDxHFEParticleSelectionMCEl::AliDxHFEParticleSelectionMCEl(const char* opt)
45 : AliDxHFEParticleSelectionEl(opt)
47 , fElectronProperties(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[]={
81 const char* AliDxHFEParticleSelectionMCEl::fgkTrackControlBinNames[]={
85 "MC statistics electron"
87 "PDG of selected electron",
90 AliDxHFEParticleSelectionMCEl::~AliDxHFEParticleSelectionMCEl()
95 THnSparse* AliDxHFEParticleSelectionMCEl::DefineTHnSparse() const
98 // Defines the THnSparse.
100 const int thnSize = 6;
101 const double Pi=TMath::Pi();
103 name.Form("%s info", GetName());
106 // Pt Phi Eta 'stat e' mother "pdg e"
107 int thnBins[thnSize] = { 1000, 200, 500, 2, 14, 10 };
108 double thnMin [thnSize] = { 0, 0, -1., -0.5, -1.5, -0.5 };
109 double thnMax [thnSize] = { 100, 2*Pi, 1., 1.5, 12.5, 9.5 };
111 return CreateControlTHnSparse(name,thnSize,thnBins,thnMin,thnMax,fgkTrackControlBinNames);
115 int AliDxHFEParticleSelectionMCEl::DefineParticleProperties(AliVParticle* p, Double_t* data, int dimension) const
117 // fill the data array from the particle data
118 if (!data) return -EINVAL;
119 AliAODTrack *track=(AliAODTrack*)p;
120 if (!track) return -ENODATA;
122 // TODO: this corresponds to the THnSparse dimensions which is available in the same class
123 // use this consistently
124 const int requiredDimension=6;
125 if (dimension!=requiredDimension) {
126 // TODO: think about filling only the available data and throwing a warning
129 data[i++]=track->Pt();
130 data[i++]=track->Phi();
131 data[i++]=track->Eta();
132 data[i++]=fResultMC; // stat electron (MC electron or not)
133 data[i++]=fOriginMother; // at the moment not included background. Should expand
134 data[i++]=1; // PDG e - not sure if needed, maybe only needed as separate histo?
139 int AliDxHFEParticleSelectionMCEl::IsSelected(AliVParticle* p, const AliVEvent* pEvent)
141 /// overloaded from AliDxHFEParticleSelection: check particle
142 /// H: Have changed function. Now doing particle selection first, then run MC over
143 /// selected tracks. Could configure it to be configurable, but not sure if it
145 /// Result from normal track selection is returned, result from MC is stored in
153 // optional MC selection before the particle selection
154 if (fMCTools.MCFirst() && (iResult=CheckMC(p, pEvent))==0) {
159 // step 2 or 1, depending on sequence:
160 // normal particle selection
161 iResult=AliDxHFEParticleSelectionEl::IsSelected(p, pEvent);
162 if (fMCTools.MCFirst() || iResult==0) return iResult;
164 // step 2, only executed if MC check is last
165 // optional MC selection after the particle selection
166 iResult=CheckMC(p, pEvent);
167 // TODO: why do we need to store the result in a member?
173 int AliDxHFEParticleSelectionMCEl::CheckMC(AliVParticle* p, const AliVEvent* pEvent)
175 /// check if MC criteria are fulfilled
182 if (!fMCTools.IsInitialized() && (iResult=fMCTools.InitMCParticles(pEvent))<0) {
183 // TODO: message? but has to be filtered in order to avoid message flood
184 return 0; // no meaningful filtering on mc possible
187 if (fMCTools.RejectByPDG(p,false)) {
189 // would also like to use this info? or not meaningful?
190 // NEED TO CHANGE THIS!
195 pdgMother=fMCTools.FindMotherPDG(p,AliDxHFEToolsMC::kGetFirstMother);
197 // Particles considered HFE background. can be expanded
198 // Should be created only once
199 // TODO: that needs to be configured once to avoid performance penalty
200 vector<int> motherPDGs;
201 motherPDGs.push_back(AliDxHFEToolsMC::kPDGpi0);
202 motherPDGs.push_back(AliDxHFEToolsMC::kPDGeta);
203 motherPDGs.push_back(AliDxHFEToolsMC::kPDGgamma);
204 motherPDGs.push_back(AliDxHFEToolsMC::kPDGJpsi);
206 if(fMCTools.RejectByPDG(pdgMother,motherPDGs)){
207 pdgMother=fMCTools.FindMotherPDG(p,AliDxHFEToolsMC::kGetOriginMother);
208 fOriginMother=fMCTools.GetOriginMother();
211 //Could this be done in a more elegant way?
213 case(AliDxHFEToolsMC::kPDGpi0): fOriginMother=AliDxHFEToolsMC::kNrOrginMother; break;
214 case(AliDxHFEToolsMC::kPDGeta): fOriginMother=AliDxHFEToolsMC::kNrOrginMother+1; break;
215 case(AliDxHFEToolsMC::kPDGgamma): fOriginMother=AliDxHFEToolsMC::kNrOrginMother+2;break;
216 case(AliDxHFEToolsMC::kPDGJpsi): fOriginMother=AliDxHFEToolsMC::kNrOrginMother+3;break;
220 /*if (fMCTools.RejectByMotherPDG(p)) {
221 // rejected by pdg of original mother
222 // H: want pdg of origin process to be stored in THnSparse
223 // Not sure if this is needed... Need to check, using AliDxHFEToolsMC, who
224 // first mother are, and also what origin is. Use this info here.
231 void AliDxHFEParticleSelectionMCEl::Clear(const char* option)
233 /// clear internal memory
234 fMCTools.Clear(option);