AliPhysics  vAN-20150427 (e6e7aad)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalTriggerRecJetAnalysisComponent.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 <iostream>
16 #include <string>
17 #include <vector>
18 
19 #include <TMath.h>
20 #include <TString.h>
21 
22 #include "AliAODMCParticle.h"
23 #include "AliCentrality.h"
24 #include "AliEmcalJet.h"
25 #include "AliJetContainer.h"
26 #include "AliMCParticle.h"
27 #include "AliMCEvent.h"
28 #include "AliParticleContainer.h"
29 #include "AliVEvent.h"
30 #include "AliVTrack.h"
31 #include "AliVVertex.h"
32 
33 #include "AliEMCalHistoContainer.h"
41 
45 
46 namespace EMCalTriggerPtAnalysis {
47 
51 AliEMCalTriggerRecJetAnalysisComponent::AliEMCalTriggerRecJetAnalysisComponent() :
53  fTrackSelection(NULL),
54  fMinimumJetPt(20.),
55  fRequestMCtrue(kFALSE),
56  fSwapEta(kFALSE),
57  fTriggerMethod(kTriggerString)
58 {
59 }
60 
67  fTrackSelection(NULL),
68  fMinimumJetPt(20.),
69  fRequestMCtrue(kFALSE),
70  fSwapEta(kFALSE),
71  fTriggerMethod(kTriggerString)
72 {
73 }
74 
80 }
81 
87 
88  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
89  // Create trigger definitions
90  std::map<std::string, std::string> triggerCombinations;
91  const char *triggernames[11] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
92  "EMCGLow", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
93  "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
94  // Define names and titles for different triggers in the histogram container
95  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
96  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
97  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
98  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
99  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
100  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "jet and gamma triggered events (high threshold)"));
101  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "exclusively gamma-triggered events (high threshold)"));
102  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively jet-triggered events (high threshold)"));
103  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "jet and gamma triggered events (low threshold)"));
104  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "exclusively gamma-triggered events (low threshold)"));
105  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively-triggered events (low threshold)"));
106 
107  // Create axis definitions
108  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
109  *jetptbinning = fBinning->GetBinning("jetpt"),
110  *etabinning = fBinning->GetBinning("eta"),
111  *phibinning = fBinning->GetBinning("phi"),
112  *vertexbinning = fBinning->GetBinning("zvertex"),
113  *centralitybinning = fBinning->GetBinning("centrality");
114 
115  const TAxis *trackaxes[6] = {
116  DefineAxis("trackpt", ptbinning),
117  DefineAxis("jettpt", jetptbinning ? jetptbinning : ptbinning),
118  DefineAxis("eta", etabinning),
119  DefineAxis("phi", phibinning),
120  DefineAxis("zvertex", vertexbinning),
121  DefineAxis("mbtrigger", 2, -0.5, 1.5)
122  };
123 
124  const TAxis *trackaxes1[5] = {
125  DefineAxis("trackpt", ptbinning),
126  DefineAxis("jetpt", jetptbinning),
127  DefineAxis("eta", etabinning),
128  DefineAxis("centrality", centralitybinning),
129  DefineAxis("dR", 20, 0., 0.5),
130  };
131 
132  const TAxis *jetaxes[4] = {
133  DefineAxis("jetpt", jetptbinning ? jetptbinning : ptbinning),
134  DefineAxis("jeteta", etabinning),
135  DefineAxis("jetphi", phibinning),
136  DefineAxis("zvertex", vertexbinning)
137  };
138 
139  // Build histograms
140  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
141  const std::string name = it->first, &title = it->second;
142  fHistos->CreateTHnSparse(Form("hTrackJetHist%s%s", jetptstring.Data(), name.c_str()), Form("Track-based data for tracks in jets in %s events", title.c_str()), 6, trackaxes, "s");
143  fHistos->CreateTHnSparse(Form("hTrackJetCentralityHist%s%s", jetptstring.Data(), name.c_str()), Form("Track-based histogram for tracks in jets in %s events and centrality", title.c_str()), 5, trackaxes1, "s");
144  fHistos->CreateTHnSparse(Form("hMCTrackJetHist%s%s", jetptstring.Data(), name.c_str()), Form("Track-based data for tracks in jets in %s events with MC kinematics", title.c_str()), 6, trackaxes, "s");
145  fHistos->CreateTHnSparse(Form("hRecJetHist%s%s", jetptstring.Data(), name.c_str()), Form("Reconstructed jets in %s-triggered events", name.c_str()), 4, jetaxes);
146  }
147 
148  for(int iaxis = 0; iaxis < 6; iaxis++) delete trackaxes[iaxis];
149 
150 }
151 
162  /*
163  * Analyse tracks from jets with a given minimum pt
164  */
165  std::vector<std::string> triggernames;
166  this->GetMachingTriggerNames(triggernames, fTriggerMethod);
167  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
168 
169  // Debugging:
170  if(fComponentDebugLevel > 1){
171  PrintTriggerNames(triggernames, "RecJets");
174  std::cout << "Decision from patches and from strings do not match" << std::endl;
175  }
176 
177  double weight = 1.;
178  if(fWeightHandler && data->GetMCEvent()){
179  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
180  }
181 
182  AliJetContainer *cont = data->GetJetContainerData();
183  AliEmcalJet *reconstructedJet = cont->GetNextAcceptJet(0);
184  AliVTrack *foundtrack(NULL);
185  const AliVParticle *assocMC(NULL);
186  AliCentrality *centralityHandler = data->GetRecEvent()->GetCentrality();
187  while(reconstructedJet){
188  if(TMath::Abs(reconstructedJet->Pt()) > fMinimumJetPt){
189  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name)
190  FillJetHistogram(Form("hRecJetHist%s%s", jetptstring.Data(), name->c_str()), reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
191  // Jet selected, loop over particles
192  for(int ipart = 0; ipart < reconstructedJet->GetNumberOfTracks(); ipart++){
193  foundtrack = dynamic_cast<AliVTrack *>(reconstructedJet->TrackAt(ipart, cont->GetParticleContainer()->GetArray()));
194  if(!fKineCuts->IsSelected(foundtrack)) continue;
195  if(fRequestMCtrue && data->GetMCEvent() && (assocMC = IsMCTrueTrack(foundtrack, data->GetMCEvent()))) continue;
196  if(fTrackSelection && !fTrackSelection->IsTrackAccepted(foundtrack)) continue;
197  // track selected, fill histogram
198  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name){
199  FillHistogram(Form("hTrackJetHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
200  FillTrackHistogramCentrality(Form("hTrackJetCentralityHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, centralityHandler->GetCentralityPercentile("V0A"), weight);
201  if(assocMC){
202  FillHistogram(Form("hMCTrackJetHist%s%s", jetptstring.Data(), name->c_str()), assocMC, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
203  }
204  }
205  }
206  }
207  reconstructedJet = cont->GetNextAcceptJet();
208  }
209 }
210 
219  const AliVTrack* const trk, const AliMCEvent* evnt) const {
220  int label = TMath::Abs(trk->GetLabel());
221  const AliVParticle *mcpart = evnt->GetTrack(label);
222  if(!mcpart) return NULL;
223  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(mcpart);
224  if(aodpart) {
225  if(!aodpart->IsPhysicalPrimary()) return NULL;
226  } else {
227  if(!evnt->IsPhysicalPrimary(label)) return NULL;
228  }
229  return mcpart;
230 }
231 
241  const TString& histname, const AliVParticle* track, const AliEmcalJet* jet,
242  double vz, double weight) {
243 
244  if(!fTriggerDecision) return;
245  double data[6] = {TMath::Abs(track->Pt()), TMath::Abs(jet->Pt()), (fSwapEta ? -1. : 1.) * track->Eta(), track->Phi(), vz, fTriggerDecision->IsMinBias() ? 1. : 0.};
246  fHistos->FillTHnSparse(histname.Data(), data, weight);
247 }
248 
257  const TString& histname, const AliEmcalJet* recjet, double vz, double weight) {
258  double data[4] = {TMath::Abs(recjet->Pt()), (fSwapEta ? -1. : 1.) * recjet->Eta(), recjet->Phi(), vz};
259  fHistos->FillTHnSparse(histname.Data(), data, weight);
260 }
261 
276  const TString& histname, const AliVTrack* const trk, const AliEmcalJet* jet, double centpercent, double weight) {
277  /*
278  */
279  double data[5] = { TMath::Abs(trk->Pt()), TMath::Abs(jet->Pt()), (fSwapEta ? -1. : 1.) * trk->Eta(), centpercent, jet->DeltaR(trk)};
280  fHistos->FillTHnSparse(histname.Data(), data, weight);
281 }
282 
283 } /* 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...
void PrintTriggerNames(const std::vector< std::string > &, const std::string &componentName) const
AliEMCalPtTaskVTrackSelection * fTrackSelection
Track selection cuts used in the analysis.
const AliEMCalTriggerWeightHandler * fWeightHandler
Event weight handler.
void FillTrackHistogramCentrality(const TString &histname, const AliVTrack *const trk, const AliEmcalJet *jet, double centpercent, double weight)
void GetMachingTriggerNames(std::vector< std::string > &triggernames, ETriggerMethod_t usePatches)
TAxis * DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning)
Declaration of the analysis component on reconstructed jets.
void FillTHnSparse(const char *name, const double *x, double weight=1.)
void FillHistogram(const TString &histname, const AliVParticle *track, const AliEmcalJet *jet, double vz, double weight)
void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Declarartion of class AliEMCalHistoContainer.
AliEMCalHistoContainer * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaTriggerDecision * fTriggerDecision
Trigger decision handler.
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.
void FillJetHistogram(const TString &histname, const AliEmcalJet *recjet, double vz, double weight)
double GetEventWeight(const AliMCEvent *const event) const
Declaration of the classes AliEMCalTriggerBinningComponent and AliEMCalTriggerBinningDimension.
virtual bool IsTrackAccepted(AliVTrack *const trk)=0
ETriggerMethod_t fTriggerMethod
Method used for the trigger decision.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Declartion of class AliEMCalPtTaskVTrackSelection.
const AliVParticle * IsMCTrueTrack(const AliVTrack *const trk, const AliMCEvent *evnt) const