AliPhysics  vAN-20150429 (ffa5c54)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
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 <TMath.h>
19 #include <TString.h>
20 
21 #include "AliAODMCParticle.h"
22 #include "AliEmcalJet.h"
23 #include "AliJetContainer.h"
24 #include "AliLog.h"
25 #include "AliMCParticle.h"
26 #include "AliMCEvent.h"
27 #include "AliParticleContainer.h"
28 #include "AliVEvent.h"
29 #include "AliVParticle.h"
30 #include "AliVVertex.h"
31 
32 #include "AliEMCalHistoContainer.h"
39 
43 
44 namespace EMCalTriggerPtAnalysis {
45 
49 AliEMCalTriggerMCJetAnalysisComponent::AliEMCalTriggerMCJetAnalysisComponent():
51  fMinimumJetPt(20.),
52  fTriggerMethod(kTriggerString)
53 {
54 }
55 
62  fMinimumJetPt(20.),
63  fTriggerMethod(kTriggerString)
64 {
65 }
66 
72 
73  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
74  // Create trigger definitions
75  std::map<std::string, std::string> triggerCombinations;
76  const char *triggernames[11] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
77  "EMCGLow", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
78  "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
79  // Define names and titles for different triggers in the histogram container
80  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
81  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
82  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
83  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
84  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
85  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "jet and gamma triggered events (high threshold)"));
86  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "exclusively gamma-triggered events (high threshold)"));
87  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively jet-triggered events (high threshold)"));
88  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "jet and gamma triggered events (low threshold)"));
89  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "exclusively gamma-triggered events (low threshold)"));
90  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively-triggered events (low threshold)"));
91 
92  // Create axis definitions
93  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
94  *jetptbinning = fBinning->GetBinning("jetpt"),
95  *etabinning = fBinning->GetBinning("eta"),
96  *phibinning = fBinning->GetBinning("phi"),
97  *vertexbinning = fBinning->GetBinning("zvertex");
98 
99  const TAxis *trackaxes[6] = {
100  DefineAxis("trackpt", ptbinning),
101  DefineAxis("jettpt", jetptbinning ? jetptbinning : ptbinning),
102  DefineAxis("eta", etabinning),
103  DefineAxis("phi", phibinning),
104  DefineAxis("zvertex", vertexbinning),
105  DefineAxis("mbtrigger", 2, -0.5, 1.5)
106  };
107 
108  const TAxis *jetaxes[4] = {
109  DefineAxis("jetpt", jetptbinning ? jetptbinning : ptbinning),
110  DefineAxis("jeteta", etabinning),
111  DefineAxis("jetphi", phibinning),
112  DefineAxis("zvertex", vertexbinning)
113  };
114 
115  // Build histograms
116  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
117  const std::string name = it->first, &title = it->second;
118  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");
119  fHistos->CreateTHnSparse(Form("hMCJetHist%s%s", jetptstring.Data(), name.c_str()), Form("Reconstructed jets in %s-triggered events", name.c_str()), 4, jetaxes);
120  }
121 
122  for(int iaxis = 0; iaxis < 6; iaxis++) delete trackaxes[iaxis];
123 }
124 
132  if(!data->GetJetContainerMC()){
133  AliError("No Jet container for MC found");
134  return;
135  }
136  std::vector<std::string> triggernames;
137  this->GetMachingTriggerNames(triggernames, fTriggerMethod);
138  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
139 
140  double weight = 1.;
141  if(fWeightHandler && data->GetMCEvent()){
142  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
143  }
144 
145  AliJetContainer *cont = data->GetJetContainerMC();
146  AliEmcalJet *reconstructedJet = cont->GetNextAcceptJet(0);
147  AliAODMCParticle *foundtrack(NULL);
148  while(reconstructedJet){
149  if(TMath::Abs(reconstructedJet->Pt()) > fMinimumJetPt){
150  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name)
151  FillJetHistogram(Form("hMCJetHist%s%s", jetptstring.Data(), name->c_str()), reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
152  // Jet selected, loop over particles
153  for(int ipart = 0; ipart < reconstructedJet->GetNumberOfTracks(); ipart++){
154  foundtrack = dynamic_cast<AliAODMCParticle *>(reconstructedJet->TrackAt(ipart, cont->GetParticleContainer()->GetArray()));
155  if(!fKineCuts->IsSelected(foundtrack)) continue;
156  if(!foundtrack->Charge()) continue;
157  if(!foundtrack->IsPhysicalPrimary()) continue;
158  // track selected, fill histogram
159  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name){
160  FillHistogram(Form("hParticleJetHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
161  }
162  }
163  }
164  reconstructedJet = cont->GetNextAcceptJet();
165  }
166 }
167 
177  const TString& histname, const AliVParticle* track, const AliEmcalJet* jet,
178  double vz, double weight) {
179  if(!fTriggerDecision) return;
180  double data[6] = {TMath::Abs(track->Pt()), TMath::Abs(jet->Pt()), track->Eta(), track->Phi(), vz, fTriggerDecision->IsMinBias() ? 1. : 0.};
181  fHistos->FillTHnSparse(histname.Data(), data, weight);
182 }
183 
192  const TString& histname, const AliEmcalJet* recjet, double vz, double weight) {
193  double data[4] = {TMath::Abs(recjet->Pt()), recjet->Eta(), recjet->Phi(), vz};
194  fHistos->FillTHnSparse(histname.Data(), data, weight);
195 }
196 } /* namespace EMCalTriggerPtAnalysis */
bool IsSelected(const AliVParticle *const track) const
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Weight handler for the analysis of high- tracks in EMCAL-triggered events.
Declaration of class AliEMCalTriggerAnaTriggerDecision, a container for trigger decision in EMCAL-tri...
const AliEMCalTriggerWeightHandler * fWeightHandler
Event weight handler.
void GetMachingTriggerNames(std::vector< std::string > &triggernames, ETriggerMethod_t usePatches)
TAxis * DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning)
void FillTHnSparse(const char *name, const double *x, double weight=1.)
void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
void FillJetHistogram(const TString &histname, const AliEmcalJet *recjet, double vz, double weight)
Declarartion of class AliEMCalHistoContainer.
Analysis component for particles in jets at generator level.
AliEMCalHistoContainer * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaTriggerDecision * fTriggerDecision
Trigger decision handler.
Definition of class AliEMCalTriggerMCJetAnalysisComponent.
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
const AliEMCalTriggerKineCuts * fKineCuts
Kinematical cuts for tracks and particle selection.
Base class for analysis components in the analysis of EMCAL-triggered events.
ETriggerMethod_t fTriggerMethod
Method used to select triggered events.
double GetEventWeight(const AliMCEvent *const event) const
Declaration of the classes AliEMCalTriggerBinningComponent and AliEMCalTriggerBinningDimension.
void FillHistogram(const TString &histname, const AliVParticle *track, const AliEmcalJet *jet, double vz, double weight)
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.