AliPhysics  720d1f3 (720d1f3)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEMCalTriggerMCJetAnalysisComponent.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2014, 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 #include <string>
16 #include <vector>
17 
18 #include <THistManager.h>
19 #include <TLinearBinning.h>
20 #include <TMath.h>
21 #include <TString.h>
22 
23 #include "AliAODMCParticle.h"
24 #include "AliEmcalJet.h"
25 #include "AliJetContainer.h"
26 #include "AliLog.h"
27 #include "AliMCParticle.h"
28 #include "AliMCEvent.h"
29 #include "AliParticleContainer.h"
30 #include "AliVEvent.h"
31 #include "AliVParticle.h"
32 #include "AliVVertex.h"
33 
40 
44 
45 namespace EMCalTriggerPtAnalysis {
46 
50 AliEMCalTriggerMCJetAnalysisComponent::AliEMCalTriggerMCJetAnalysisComponent():
52  fMinimumJetPt(20.)
53 {
54 }
55 
62  fMinimumJetPt(20.)
63 {
64 }
65 
71 
72  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
73  // Create trigger definitions
74  std::map<std::string, std::string> triggerCombinations;
75  GetAllTriggerNamesAndTitles(triggerCombinations);
76 
77  // Create axis definitions
78  const TBinning *ptbinning = fBinning->GetBinning("pt"),
79  *jetptbinning = fBinning->GetBinning("jetpt"),
80  *etabinning = fBinning->GetBinning("eta"),
81  *phibinning = fBinning->GetBinning("phi"),
82  *vertexbinning = fBinning->GetBinning("zvertex");
83 
84  const TAxis *trackaxes[6] = {
85  DefineAxis("trackpt", *ptbinning),
86  DefineAxis("jettpt", jetptbinning ? *jetptbinning : *ptbinning),
87  DefineAxis("eta", *etabinning),
88  DefineAxis("phi", *phibinning),
89  DefineAxis("zvertex", *vertexbinning),
90  DefineAxis("mbtrigger", TLinearBinning(2, -0.5, 1.5))
91  };
92 
93  const TAxis *jetaxes[4] = {
94  DefineAxis("jetpt", jetptbinning ? *jetptbinning : *ptbinning),
95  DefineAxis("jeteta", *etabinning),
96  DefineAxis("jetphi", *phibinning),
97  DefineAxis("zvertex", *vertexbinning)
98  };
99 
100  // Build histograms
101  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
102  const std::string name = it->first, &title = it->second;
103  fHistos->CreateTHnSparse(Form("hParticleJetHist%s%s", jetptstring.Data(), name.c_str()), Form("Track-based data for tracks in jets in %s events", title.c_str()), 6, trackaxes, "s");
104  fHistos->CreateTHnSparse(Form("hMCJetHist%s%s", jetptstring.Data(), name.c_str()), Form("Reconstructed jets in %s-triggered events", name.c_str()), 4, jetaxes);
105  }
106 
107  for(int iaxis = 0; iaxis < 6; iaxis++) delete trackaxes[iaxis];
108 }
109 
117  if(!data->GetJetContainerMC()){
118  AliError("No Jet container for MC found");
119  return;
120  }
121  std::vector<std::string> triggernames;
122  this->GetMachingTriggerNames(triggernames);
123  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
124 
125  double weight = 1.;
126  if(fWeightHandler && data->GetMCEvent()){
127  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
128  }
129 
130  AliJetContainer *cont = data->GetJetContainerMC();
131  cont->ResetCurrentID();
132  AliEmcalJet *reconstructedJet = cont->GetNextAcceptJet();
133  AliAODMCParticle *foundtrack(NULL);
134  while(reconstructedJet){
135  if(TMath::Abs(reconstructedJet->Pt()) > fMinimumJetPt){
136  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name)
137  FillJetHistogram(Form("hMCJetHist%s%s", jetptstring.Data(), name->c_str()), reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
138  // Jet selected, loop over particles
139  for(int ipart = 0; ipart < reconstructedJet->GetNumberOfTracks(); ipart++){
140  foundtrack = dynamic_cast<AliAODMCParticle *>(reconstructedJet->TrackAt(ipart, cont->GetParticleContainer()->GetArray()));
141  if(!fKineCuts->IsSelected(foundtrack)) continue;
142  if(!foundtrack->Charge()) continue;
143  if(!foundtrack->IsPhysicalPrimary()) continue;
144  // track selected, fill histogram
145  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name){
146  FillHistogram(Form("hParticleJetHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
147  }
148  }
149  }
150  reconstructedJet = cont->GetNextAcceptJet();
151  }
152 }
153 
163  const TString& histname, const AliVParticle* track, const AliEmcalJet* jet,
164  double vz, double weight) {
165  if(!fTriggerClassManager) return;
166  double data[6] = {TMath::Abs(track->Pt()), TMath::Abs(jet->Pt()), track->Eta(), track->Phi(), vz, fTriggerClassManager->HasMinBiasTrigger() ? 1. : 0.};
167  fHistos->FillTHnSparse(histname.Data(), data, weight);
168 }
169 
178  const TString& histname, const AliEmcalJet* recjet, double vz, double weight) {
179  double data[4] = {TMath::Abs(recjet->Pt()), recjet->Eta(), recjet->Phi(), vz};
180  fHistos->FillTHnSparse(histname.Data(), data, weight);
181 }
182 } /* namespace EMCalTriggerPtAnalysis */
const char * title
Definition: MakeQAPdf.C:26
Class creating a linear binning, used in the histogram manager.
void GetMachingTriggerNames(std::vector< std::string > &triggernames) const
Double_t Eta() const
Definition: AliEmcalJet.h:114
const AliEMCalTriggerWeightHandler * fWeightHandler
Event weight handler.
Double_t Phi() const
Definition: AliEmcalJet.h:110
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
UShort_t GetNumberOfTracks() const
Definition: AliEmcalJet.h:132
AliParticleContainer * GetParticleContainer() const
Declaration of a management class for trigger classes.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
void GetAllTriggerNamesAndTitles(std::map< std::string, std::string > &triggers) const
void FillJetHistogram(const TString &histname, const AliEmcalJet *recjet, double vz, double weight)
Analysis component for particles in jets at generator level.
THistManager * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaClassManager * fTriggerClassManager
Global trigger class manager.
Definition of class AliEMCalTriggerMCJetAnalysisComponent.
AliEmcalJet * GetNextAcceptJet()
const AliEMCalTriggerKineCuts * fKineCuts
Kinematical cuts for tracks and particle selection.
Base class for analysis components in the analysis of EMCAL-triggered events.
Double_t Pt() const
Definition: AliEmcalJet.h:102
double GetEventWeight(const AliMCEvent *const event) const
Short_t TrackAt(Int_t idx) const
Definition: AliEmcalJet.h:153
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
Simple event container within the high- track analysis.
void FillHistogram(const TString &histname, const AliVParticle *track, const AliEmcalJet *jet, double vz, double weight)
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.
Container for jet within the EMCAL jet framework.