AliPhysics  879ce3b (879ce3b)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AliAnalysisTaskParticleInJet.cxx
Go to the documentation of this file.
1 /*
2  * AliAnalysisTaskParticleInJet.cxx
3  *
4  * Created on: Feb 17, 2016
5  * Author: markus
6  */
7 #include <map>
8 #include <string>
9 
10 #include <TArrayD.h>
11 #include <THashList.h>
12 #include <THistManager.h>
13 #include <TMath.h>
14 #include <TString.h>
15 
16 #include "AliAODMCParticle.h"
17 #include "AliEmcalJet.h"
18 #include "AliEmcalTrackSelection.h"
19 #include "AliInputEventHandler.h"
20 #include "AliJetContainer.h"
21 #include "AliMCEvent.h"
22 #include "AliMCParticle.h"
23 #include "AliParticleContainer.h"
24 #include "AliVEvent.h"
25 #include "AliVParticle.h"
26 #include "AliVTrack.h"
27 
29 
31 
33 AliAnalysisTaskEmcalJet(),
34 fHistMgr(NULL),
35 fTrackSelection(NULL),
36 fParticleContainerNameRec(""),
37 fParticleContainerNameMC(""),
38 fJetContainerNameRec(""),
39 fJetContainerNameMC("")
40 {
41 }
42 
44 AliAnalysisTaskEmcalJet(),
45 fHistMgr(NULL),
46 fTrackSelection(NULL),
47 fParticleContainerNameRec(""),
48 fParticleContainerNameMC(""),
49 fJetContainerNameRec(""),
50 fJetContainerNameMC("")
51 {
52 }
53 
56 }
57 
59  fHistMgr = new THistManager("histos");
60 
61  TArrayD ptbinning, jetptbinning;
62  CreatePtBinning(ptbinning);
63  CreateLinearBinning(jetptbinning, 200, 0., 200);
64 
65  std::map<std::string, std::string> histmap1D, histmap2D;
66  histmap1D.insert(std::pair<std::string, std::string>("hMCall","MC true particles in full acceptance"));
67  histmap1D.insert(std::pair<std::string, std::string>("hMCcont","Accepted true particles in particle containers"));
68  histmap1D.insert(std::pair<std::string, std::string>("hTracksMB","All accepted tracks in the EMCAL acceptance in MB events"));
69  histmap1D.insert(std::pair<std::string, std::string>("hTracksEG1","All accepted tracks in the EMCAL acceptance in EG1 events"));
70  histmap1D.insert(std::pair<std::string, std::string>("hTracksEG2","All accepted tracks in the EMCAL acceptance in EG2 events"));
71  histmap1D.insert(std::pair<std::string, std::string>("hTracksEJ1","All accepted tracks in the EMCAL acceptance in EJ1 events"));
72  histmap1D.insert(std::pair<std::string, std::string>("hTracksEJ2","All accepted tracks in the EMCAL acceptance in EJ2 events"));
73  histmap2D.insert(std::pair<std::string, std::string>("hMCjetTrack","Particles in jets with jet pt"));
74  histmap2D.insert(std::pair<std::string, std::string>("hRecjetTrackMB","Particles in jets with jet pt in MB events"));
75  histmap2D.insert(std::pair<std::string, std::string>("hRecjetTrackEG1","Particles in jets with jet pt in EG1 events"));
76  histmap2D.insert(std::pair<std::string, std::string>("hRecjetTrackEG2","Particles in jets with jet pt in EG2 events"));
77  histmap2D.insert(std::pair<std::string, std::string>("hRecjetTrackEJ1","Particles in jets with jet pt in EJ1 events"));
78  histmap2D.insert(std::pair<std::string, std::string>("hRecjetTrackEJ2","Particles in jets with jet pt in EJ2 events"));
79 
80  for(std::map<std::string, std::string>::iterator it = histmap1D.begin(); it != histmap1D.end(); ++it){
81  fHistMgr->CreateTH1(it->first.c_str(), it->second.c_str(), ptbinning);
82  }
83  for(std::map<std::string, std::string>::iterator it = histmap2D.begin(); it != histmap2D.end(); ++it){
84  fHistMgr->CreateTH2(it->first.c_str(), it->second.c_str(), jetptbinning, ptbinning);
85  }
86 
87  fHistMgr->GetListOfHistograms()->SetOwner(kFALSE);
88  for(TIter histiter = TIter(fHistMgr->GetListOfHistograms()).Begin(); histiter != TIter::End(); ++histiter)
89  fHistosQA->Add(*histiter);
90 }
91 
93  TString triggerstring = fInputEvent->GetFiredTriggerClasses();
94  Bool_t isMinBias = fInputHandler->IsEventSelected() & AliVEvent::kINT7,
95  isEG1 = triggerstring.Contains("EG1"),
96  isEG2 = triggerstring.Contains("EG2"),
97  isEJ1 = triggerstring.Contains("EJ1"),
98  isEJ2 = triggerstring.Contains("EJ2");
99  if(!(isMinBias || isEG1 || isEG2 || isEJ1 || isEJ2)) return kFALSE;
100 
101  if(MCEvent()){
102  AliVParticle *mctrack = 0;
103  for(Int_t ipart = 0; ipart < MCEvent()->GetNumberOfTracks(); ipart++){
104  mctrack = MCEvent()->GetTrack(ipart);
105  if(!IsPhysicalPrimary(mctrack)) continue;
106  if(!AcceptParticle(mctrack)) continue;
107  fHistMgr->FillTH1("hMCall", mctrack->Pt());
108  }
109  std::vector<const AliVParticle *> particles = GetSelectedParticles(GetParticleContainer(fParticleContainerNameMC.Data()));
110  for(std::vector<const AliVParticle *>::iterator it = particles.begin(); it != particles.end(); ++it) {
111  const Double_t &pt = (*it)->Pt();
112  fHistMgr->FillTH1("hMCcont", pt);
113  }
114 
115  // Look at the MC Jet container
116  AliEmcalJet *mcjet = GetJetContainer(fJetContainerNameMC.Data())->GetNextAcceptJet(0);
117  do{
118  for(int itrk = 0; itrk < mcjet->GetNumberOfTracks(); itrk++){
119  mctrack = mcjet->TrackAt(itrk, GetParticleContainer(0)->GetArray());
120  if(!AcceptParticle(mctrack)) continue;
121  fHistMgr->FillTH2("hMCjetTrack", mcjet->Pt(), mctrack->Pt());
122  }
123  } while ((mcjet = GetJetContainer(fJetContainerNameMC.Data())->GetNextAcceptJet()));
124  }
125 
126  // Loop over particles, select tracks, fill histograms of tracks in EMCAL
127  std::vector<const AliVParticle *> tracks = GetSelectedParticles(GetParticleContainer(fParticleContainerNameRec.Data()));
128  for(std::vector<const AliVParticle *>::iterator it = tracks.begin(); it != tracks.end(); ++it) {
129  const Double_t &pt = (*it)->Pt();
130  if(isMinBias) fHistMgr->FillTH1("hTracksMB", pt);
131  if(isEJ1) fHistMgr->FillTH1("hTracksEJ1", pt);
132  if(isEJ2) fHistMgr->FillTH1("hTracksEJ2", pt);
133  if(isEG1) fHistMgr->FillTH1("hTracksEG1", pt);
134  if(isEG2) fHistMgr->FillTH1("hTracksEG2", pt);
135  }
136 
137  // Look at the MC Jet container
138  AliVParticle *jettrack = NULL;
139  AliEmcalJet *recjet = GetJetContainer(fJetContainerNameRec.Data())->GetNextAcceptJet(0);
140  do{
141  for(int itrk = 0; itrk < recjet->GetNumberOfTracks(); itrk++){
142  jettrack = recjet->TrackAt(itrk, GetParticleContainer(1)->GetArray());
143  if(!AcceptParticle(jettrack)) continue;
144  if(!AcceptTrack(dynamic_cast<AliVTrack *>(jettrack))) continue;
145  if(isMinBias) fHistMgr->FillTH2("hRecjetTrackMB", recjet->Pt(), jettrack->Pt());
146  if(isEJ1) fHistMgr->FillTH2("hRecjetTrackEJ1", recjet->Pt(), jettrack->Pt());
147  if(isEJ2) fHistMgr->FillTH2("hRecjetTrackEJ2", recjet->Pt(), jettrack->Pt());
148  if(isEG1) fHistMgr->FillTH2("hRecjetTrackEG1", recjet->Pt(), jettrack->Pt());
149  if(isEG2) fHistMgr->FillTH2("hRecjetTrackEG2", recjet->Pt(), jettrack->Pt());
150  }
151  } while ((recjet = GetJetContainer(fJetContainerNameRec.Data())->GetNextAcceptJet()));
152 
153  return true;
154 }
155 
156 std::vector<const AliVParticle *> AliAnalysisTaskParticleInJet::GetSelectedParticles(AliParticleContainer *const cont) const {
157  std::vector<const AliVParticle *> result;
158  AliVParticle * test = cont->GetNextAcceptParticle(0);
159  AliVTrack *track = NULL;
160  do{
161  if(!AcceptParticle(test)) continue;
162  if((track = dynamic_cast<AliVTrack *>(test))){
163  // apply extra track cuts
164  if(!AcceptTrack(track)) continue;
165  }
166  result.push_back(test);
167  } while ((test = cont->GetNextAcceptParticle()));
168 
169  return result;
170 }
171 
172 Bool_t AliAnalysisTaskParticleInJet::AcceptParticle(const AliVParticle * const part) const{
173  if(part->Phi() < 1.4 || part->Phi() > 3.1) return false;
174  if(TMath::Abs(part->Eta()) > 0.5) return false;
175  if(!part->Charge()) return false;
176  return true;
177 }
178 
179 Bool_t AliAnalysisTaskParticleInJet::AcceptTrack(AliVTrack * const track) const{
180  if(!fTrackSelection->IsTrackAccepted(track)) return false;
181  return true;
182 }
183 
184 Bool_t AliAnalysisTaskParticleInJet::IsPhysicalPrimary(const AliVParticle *const part) const {
185  const AliMCParticle *mcpart = dynamic_cast<const AliMCParticle *>(part);
186  if(mcpart){
187  return MCEvent()->IsPhysicalPrimary(part->GetLabel());
188  } else {
189  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(part);
190  if(aodpart) return aodpart->IsPhysicalPrimary();
191  }
192  return false;
193 }
194 
195 void AliAnalysisTaskParticleInJet::CreatePtBinning(TArrayD& binning) const {
196  std::vector<double> mybinning;
197  std::map<double,double> definitions;
198  definitions.insert(std::pair<double, double>(1, 0.05));
199  definitions.insert(std::pair<double, double>(2, 0.1));
200  definitions.insert(std::pair<double, double>(4, 0.2));
201  definitions.insert(std::pair<double, double>(7, 0.5));
202  definitions.insert(std::pair<double, double>(16, 1));
203  definitions.insert(std::pair<double, double>(36, 2));
204  definitions.insert(std::pair<double, double>(40, 4));
205  definitions.insert(std::pair<double, double>(50, 5));
206  definitions.insert(std::pair<double, double>(100, 10));
207  definitions.insert(std::pair<double, double>(200, 20));
208  double currentval = 0.;
209  mybinning.push_back(currentval);
210  for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
211  double limit = id->first, binwidth = id->second;
212  while(currentval < limit){
213  currentval += binwidth;
214  mybinning.push_back(currentval);
215  }
216  }
217  binning.Set(mybinning.size());
218  int ib = 0;
219  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
220  binning[ib++] = *it;
221 }
222 
223 void AliAnalysisTaskParticleInJet::CreateLinearBinning(TArrayD& binning, int nbins, double min, double max) const {
224  double binwidth = (max-min)/static_cast<double>(nbins);
225  binning.Set(nbins+1);
226  binning[0] = min;
227  double currentlimit = min + binwidth;
228  for(int ibin = 0; ibin < nbins; ibin++){
229  binning[ibin+1] = currentlimit;
230  currentlimit += binwidth;
231  }
232 }
Bool_t IsPhysicalPrimary(const AliVParticle *const part) const
std::vector< const AliVParticle * > GetSelectedParticles(AliParticleContainer *const cont) const
Bool_t AcceptTrack(AliVTrack *const track) const
Bool_t AcceptParticle(const AliVParticle *const part) const
virtual AliVParticle * GetNextAcceptParticle(Int_t i=-1)
void CreatePtBinning(TArrayD &binning) const
AliEmcalTrackSelection * fTrackSelection
void CreateLinearBinning(TArrayD &binning, int nbins, double min, double max) const
const Int_t nbins
Declartion of class AliEmcalTrackSelection.
ClassImp(AliAnalysisTaskParticleInJet) AliAnalysisTaskParticleInJet
virtual bool IsTrackAccepted(AliVTrack *const trk)=0