AliPhysics  a0db429 (a0db429)
 All Classes Namespaces Files Functions Variables Typedefs 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 {
58 }
59 
66  fTrackSelection(NULL),
67  fMinimumJetPt(20.),
68  fRequestMCtrue(kFALSE),
69  fSwapEta(kFALSE)
70 {
71 }
72 
78 }
79 
85 
86  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
87  // Create trigger definitions
88  std::map<std::string, std::string> triggerCombinations;
89  GetAllTriggerNamesAndTitles(triggerCombinations);
90  // Create axis definitions
91  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
92  *jetptbinning = fBinning->GetBinning("jetpt"),
93  *etabinning = fBinning->GetBinning("eta"),
94  *phibinning = fBinning->GetBinning("phi"),
95  *vertexbinning = fBinning->GetBinning("zvertex"),
96  *centralitybinning = fBinning->GetBinning("centrality");
97 
98  const TAxis *trackaxes[6] = {
99  DefineAxis("trackpt", ptbinning),
100  DefineAxis("jettpt", jetptbinning ? jetptbinning : ptbinning),
101  DefineAxis("eta", etabinning),
102  DefineAxis("phi", phibinning),
103  DefineAxis("zvertex", vertexbinning),
104  DefineAxis("mbtrigger", 2, -0.5, 1.5)
105  };
106 
107  const TAxis *trackaxes1[5] = {
108  DefineAxis("trackpt", ptbinning),
109  DefineAxis("jetpt", jetptbinning),
110  DefineAxis("eta", etabinning),
111  DefineAxis("centrality", centralitybinning),
112  DefineAxis("dR", 20, 0., 0.5),
113  };
114 
115  const TAxis *jetaxes[4] = {
116  DefineAxis("jetpt", jetptbinning ? jetptbinning : ptbinning),
117  DefineAxis("jeteta", etabinning),
118  DefineAxis("jetphi", phibinning),
119  DefineAxis("zvertex", vertexbinning)
120  };
121 
122  // Build histograms
123  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
124  const std::string name = it->first, &title = it->second;
125  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");
126  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");
127  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");
128  fHistos->CreateTHnSparse(Form("hRecJetHist%s%s", jetptstring.Data(), name.c_str()), Form("Reconstructed jets in %s-triggered events", name.c_str()), 4, jetaxes);
129  }
130 
131  for(int iaxis = 0; iaxis < 6; iaxis++) delete trackaxes[iaxis];
132 
133 }
134 
145  /*
146  * Analyse tracks from jets with a given minimum pt
147  */
148  std::vector<std::string> triggernames;
149  this->GetMachingTriggerNames(triggernames);
150  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
151 
152  // Debugging:
153  if(fComponentDebugLevel > 1){
154  PrintTriggerNames(triggernames, "RecJets");
155  }
156 
157  double weight = 1.;
158  if(fWeightHandler && data->GetMCEvent()){
159  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
160  }
161 
162  AliJetContainer *cont = data->GetJetContainerData();
163  AliEmcalJet *reconstructedJet = cont->GetNextAcceptJet(0);
164  AliVTrack *foundtrack(NULL);
165  const AliVParticle *assocMC(NULL);
166  AliCentrality *centralityHandler = data->GetRecEvent()->GetCentrality();
167  while(reconstructedJet){
168  if(TMath::Abs(reconstructedJet->Pt()) > fMinimumJetPt){
169  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name)
170  FillJetHistogram(Form("hRecJetHist%s%s", jetptstring.Data(), name->c_str()), reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
171  // Jet selected, loop over particles
172  for(int ipart = 0; ipart < reconstructedJet->GetNumberOfTracks(); ipart++){
173  foundtrack = dynamic_cast<AliVTrack *>(reconstructedJet->TrackAt(ipart, cont->GetParticleContainer()->GetArray()));
174  if(!fKineCuts->IsSelected(foundtrack)) continue;
175  if(fRequestMCtrue && data->GetMCEvent() && (assocMC = IsMCTrueTrack(foundtrack, data->GetMCEvent()))) continue;
176  if(fTrackSelection && !fTrackSelection->IsTrackAccepted(foundtrack)) continue;
177  // track selected, fill histogram
178  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name){
179  FillHistogram(Form("hTrackJetHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
180  FillTrackHistogramCentrality(Form("hTrackJetCentralityHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, centralityHandler->GetCentralityPercentile("V0A"), weight);
181  if(assocMC){
182  FillHistogram(Form("hMCTrackJetHist%s%s", jetptstring.Data(), name->c_str()), assocMC, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
183  }
184  }
185  }
186  }
187  reconstructedJet = cont->GetNextAcceptJet();
188  }
189 }
190 
199  const AliVTrack* const trk, const AliMCEvent* evnt) const {
200  int label = TMath::Abs(trk->GetLabel());
201  const AliVParticle *mcpart = evnt->GetTrack(label);
202  if(!mcpart) return NULL;
203  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(mcpart);
204  if(aodpart) {
205  if(!aodpart->IsPhysicalPrimary()) return NULL;
206  } else {
207  if(!evnt->IsPhysicalPrimary(label)) return NULL;
208  }
209  return mcpart;
210 }
211 
221  const TString& histname, const AliVParticle* track, const AliEmcalJet* jet,
222  double vz, double weight) {
223 
224  if(!fTriggerClassManager) return;
225  double data[6] = {TMath::Abs(track->Pt()), TMath::Abs(jet->Pt()), (fSwapEta ? -1. : 1.) * track->Eta(), track->Phi(), vz, fTriggerClassManager->HasMinBiasTrigger() ? 1. : 0.};
226  fHistos->FillTHnSparse(histname.Data(), data, weight);
227 }
228 
237  const TString& histname, const AliEmcalJet* recjet, double vz, double weight) {
238  double data[4] = {TMath::Abs(recjet->Pt()), (fSwapEta ? -1. : 1.) * recjet->Eta(), recjet->Phi(), vz};
239  fHistos->FillTHnSparse(histname.Data(), data, weight);
240 }
241 
256  const TString& histname, const AliVTrack* const trk, const AliEmcalJet* jet, double centpercent, double weight) {
257  /*
258  */
259  double data[5] = { TMath::Abs(trk->Pt()), TMath::Abs(jet->Pt()), (fSwapEta ? -1. : 1.) * trk->Eta(), centpercent, jet->DeltaR(trk)};
260  fHistos->FillTHnSparse(histname.Data(), data, weight);
261 }
262 
263 } /* namespace EMCalTriggerPtAnalysis */
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Weight handler for the analysis of high- tracks in EMCAL-triggered events.
const char * title
Definition: MakeQAPdf.C:26
void PrintTriggerNames(const std::vector< std::string > &, const std::string &componentName) const
void GetMachingTriggerNames(std::vector< std::string > &triggernames) 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)
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.)
Declaration of a management class for trigger classes.
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="")
void GetAllTriggerNamesAndTitles(std::map< std::string, std::string > &triggers) const
Declarartion of class AliEMCalHistoContainer.
AliEMCalHistoContainer * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaClassManager * fTriggerClassManager
Global trigger class manager.
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
Simple event container within the high- track analysis.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.
Declartion of class AliEMCalPtTaskVTrackSelection.
const AliVParticle * IsMCTrueTrack(const AliVTrack *const trk, const AliMCEvent *evnt) const