AliPhysics  ea71c62 (ea71c62)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <THistManager.h>
20 #include <TMath.h>
21 #include <TString.h>
22 
23 #include "AliAODMCParticle.h"
24 #include "AliCentrality.h"
25 #include "AliEmcalJet.h"
26 #include "AliEmcalTrackSelection.h"
27 #include "AliJetContainer.h"
28 #include "AliMCParticle.h"
29 #include "AliMCEvent.h"
30 #include "AliParticleContainer.h"
31 #include "AliVEvent.h"
32 #include "AliVTrack.h"
33 #include "AliVVertex.h"
34 
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  cont->ResetCurrentID();
164  AliEmcalJet *reconstructedJet = cont->GetNextAcceptJet();
165  AliVTrack *foundtrack(NULL);
166  const AliVParticle *assocMC(NULL);
167  AliCentrality *centralityHandler = data->GetRecEvent()->GetCentrality();
168  while(reconstructedJet){
169  if(TMath::Abs(reconstructedJet->Pt()) > fMinimumJetPt){
170  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name)
171  FillJetHistogram(Form("hRecJetHist%s%s", jetptstring.Data(), name->c_str()), reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
172  // Jet selected, loop over particles
173  for(int ipart = 0; ipart < reconstructedJet->GetNumberOfTracks(); ipart++){
174  foundtrack = dynamic_cast<AliVTrack *>(reconstructedJet->TrackAt(ipart, cont->GetParticleContainer()->GetArray()));
175  if(!fKineCuts->IsSelected(foundtrack)) continue;
176  if(fRequestMCtrue && data->GetMCEvent() && (assocMC = IsMCTrueTrack(foundtrack, data->GetMCEvent()))) continue;
177  if(fTrackSelection && !fTrackSelection->IsTrackAccepted(foundtrack)) continue;
178  // track selected, fill histogram
179  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name){
180  FillHistogram(Form("hTrackJetHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
181  FillTrackHistogramCentrality(Form("hTrackJetCentralityHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, centralityHandler->GetCentralityPercentile("V0A"), weight);
182  if(assocMC){
183  FillHistogram(Form("hMCTrackJetHist%s%s", jetptstring.Data(), name->c_str()), assocMC, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
184  }
185  }
186  }
187  }
188  reconstructedJet = cont->GetNextAcceptJet();
189  }
190 }
191 
200  const AliVTrack* const trk, const AliMCEvent* evnt) const {
201  int label = TMath::Abs(trk->GetLabel());
202  const AliVParticle *mcpart = evnt->GetTrack(label);
203  if(!mcpart) return NULL;
204  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(mcpart);
205  if(aodpart) {
206  if(!aodpart->IsPhysicalPrimary()) return NULL;
207  } else {
208  if(!evnt->IsPhysicalPrimary(label)) return NULL;
209  }
210  return mcpart;
211 }
212 
222  const TString& histname, const AliVParticle* track, const AliEmcalJet* jet,
223  double vz, double weight) {
224 
225  if(!fTriggerClassManager) return;
226  double data[6] = {TMath::Abs(track->Pt()), TMath::Abs(jet->Pt()), (fSwapEta ? -1. : 1.) * track->Eta(), track->Phi(), vz, fTriggerClassManager->HasMinBiasTrigger() ? 1. : 0.};
227  fHistos->FillTHnSparse(histname.Data(), data, weight);
228 }
229 
238  const TString& histname, const AliEmcalJet* recjet, double vz, double weight) {
239  double data[4] = {TMath::Abs(recjet->Pt()), (fSwapEta ? -1. : 1.) * recjet->Eta(), recjet->Phi(), vz};
240  fHistos->FillTHnSparse(histname.Data(), data, weight);
241 }
242 
257  const TString& histname, const AliVTrack* const trk, const AliEmcalJet* jet, double centpercent, double weight) {
258  /*
259  */
260  double data[5] = { TMath::Abs(trk->Pt()), TMath::Abs(jet->Pt()), (fSwapEta ? -1. : 1.) * trk->Eta(), centpercent, jet->DeltaR(trk)};
261  fHistos->FillTHnSparse(histname.Data(), data, weight);
262 }
263 
264 } /* namespace EMCalTriggerPtAnalysis */
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
Double_t Eta() const
Definition: AliEmcalJet.h:88
const AliEMCalTriggerWeightHandler * fWeightHandler
Event weight handler.
Double_t Phi() const
Definition: AliEmcalJet.h:84
void FillTrackHistogramCentrality(const TString &histname, const AliVTrack *const trk, const AliEmcalJet *jet, double centpercent, double weight)
TAxis * DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning)
UShort_t GetNumberOfTracks() const
Definition: AliEmcalJet.h:106
Declaration of the analysis component on reconstructed jets.
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 FillHistogram(const TString &histname, const AliVParticle *track, const AliEmcalJet *jet, double vz, double weight)
void GetAllTriggerNamesAndTitles(std::map< std::string, std::string > &triggers) const
THistManager * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaClassManager * fTriggerClassManager
Global trigger class manager.
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
AliEmcalJet * GetNextAcceptJet()
Double_t DeltaR(const AliVParticle *part) const
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:76
void FillJetHistogram(const TString &histname, const AliEmcalJet *recjet, double vz, double weight)
double GetEventWeight(const AliMCEvent *const event) const
Short_t TrackAt(Int_t idx) const
Definition: AliEmcalJet.h:127
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
Simple event container within the high- track analysis.
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.
const AliVParticle * IsMCTrueTrack(const AliVTrack *const trk, const AliMCEvent *evnt) const
AliEmcalTrackSelection * fTrackSelection
Track selection cuts used in the analysis.
virtual bool IsTrackAccepted(AliVTrack *const trk)=0