AliPhysics  cdeda5a (cdeda5a)
 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 <TLinearBinning.h>
21 #include <TMath.h>
22 #include <TString.h>
23 
24 #include "AliAODMCParticle.h"
25 #include "AliCentrality.h"
26 #include "AliEmcalJet.h"
27 #include "AliEmcalTrackSelection.h"
28 #include "AliJetContainer.h"
29 #include "AliMCParticle.h"
30 #include "AliMCEvent.h"
31 #include "AliParticleContainer.h"
32 #include "AliVEvent.h"
33 #include "AliVTrack.h"
34 #include "AliVVertex.h"
35 
42 
46 
47 namespace EMCalTriggerPtAnalysis {
48 
52 AliEMCalTriggerRecJetAnalysisComponent::AliEMCalTriggerRecJetAnalysisComponent() :
54  fTrackSelection(NULL),
55  fMinimumJetPt(20.),
56  fRequestMCtrue(kFALSE),
57  fSwapEta(kFALSE)
58 {
59 }
60 
67  fTrackSelection(NULL),
68  fMinimumJetPt(20.),
69  fRequestMCtrue(kFALSE),
70  fSwapEta(kFALSE)
71 {
72 }
73 
79 }
80 
86 
87  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
88  // Create trigger definitions
89  std::map<std::string, std::string> triggerCombinations;
90  GetAllTriggerNamesAndTitles(triggerCombinations);
91  // Create axis definitions
92  const TBinning *ptbinning = fBinning->GetBinning("pt"),
93  *jetptbinning = fBinning->GetBinning("jetpt"),
94  *etabinning = fBinning->GetBinning("eta"),
95  *phibinning = fBinning->GetBinning("phi"),
96  *vertexbinning = fBinning->GetBinning("zvertex"),
97  *centralitybinning = fBinning->GetBinning("centrality");
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", TLinearBinning(2, -0.5, 1.5))
106  };
107 
108  const TAxis *trackaxes1[5] = {
109  DefineAxis("trackpt", *ptbinning),
110  DefineAxis("jetpt", jetptbinning ? *jetptbinning : *ptbinning),
111  DefineAxis("eta", *etabinning),
112  DefineAxis("centrality", *centralitybinning),
113  DefineAxis("dR", TLinearBinning(20, 0., 0.5)),
114  };
115 
116  const TAxis *jetaxes[4] = {
117  DefineAxis("jetpt", jetptbinning ? *jetptbinning : *ptbinning),
118  DefineAxis("jeteta", *etabinning),
119  DefineAxis("jetphi", *phibinning),
120  DefineAxis("zvertex", *vertexbinning)
121  };
122 
123  // Build histograms
124  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
125  const std::string name = it->first, &title = it->second;
126  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");
127  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");
128  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");
129  fHistos->CreateTHnSparse(Form("hRecJetHist%s%s", jetptstring.Data(), name.c_str()), Form("Reconstructed jets in %s-triggered events", name.c_str()), 4, jetaxes);
130  }
131 
132  for(int iaxis = 0; iaxis < 6; iaxis++) delete trackaxes[iaxis];
133 
134 }
135 
146  /*
147  * Analyse tracks from jets with a given minimum pt
148  */
149  std::vector<std::string> triggernames;
150  this->GetMachingTriggerNames(triggernames);
151  TString jetptstring = Form("jetPt%03d", int(fMinimumJetPt));
152 
153  // Debugging:
154  if(fComponentDebugLevel > 1){
155  PrintTriggerNames(triggernames, "RecJets");
156  }
157 
158  double weight = 1.;
159  if(fWeightHandler && data->GetMCEvent()){
160  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
161  }
162 
163  AliJetContainer *cont = data->GetJetContainerData();
164  cont->ResetCurrentID();
165  AliEmcalJet *reconstructedJet = cont->GetNextAcceptJet();
166  AliVTrack *foundtrack(NULL);
167  const AliVParticle *assocMC(NULL);
168  AliCentrality *centralityHandler = data->GetRecEvent()->GetCentrality();
169  while(reconstructedJet){
170  if(TMath::Abs(reconstructedJet->Pt()) > fMinimumJetPt){
171  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name)
172  FillJetHistogram(Form("hRecJetHist%s%s", jetptstring.Data(), name->c_str()), reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
173  // Jet selected, loop over particles
174  for(int ipart = 0; ipart < reconstructedJet->GetNumberOfTracks(); ipart++){
175  foundtrack = dynamic_cast<AliVTrack *>(reconstructedJet->TrackAt(ipart, cont->GetParticleContainer()->GetArray()));
176  if(!fKineCuts->IsSelected(foundtrack)) continue;
177  if(fRequestMCtrue && data->GetMCEvent() && (assocMC = IsMCTrueTrack(foundtrack, data->GetMCEvent()))) continue;
178  if(fTrackSelection && !fTrackSelection->IsTrackAccepted(foundtrack)) continue;
179  // track selected, fill histogram
180  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); ++name){
181  FillHistogram(Form("hTrackJetHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
182  FillTrackHistogramCentrality(Form("hTrackJetCentralityHist%s%s", jetptstring.Data(), name->c_str()), foundtrack, reconstructedJet, centralityHandler->GetCentralityPercentile("V0A"), weight);
183  if(assocMC){
184  FillHistogram(Form("hMCTrackJetHist%s%s", jetptstring.Data(), name->c_str()), assocMC, reconstructedJet, data->GetRecEvent()->GetPrimaryVertex()->GetZ(), weight);
185  }
186  }
187  }
188  }
189  reconstructedJet = cont->GetNextAcceptJet();
190  }
191 }
192 
201  const AliVTrack* const trk, const AliMCEvent* evnt) const {
202  int label = TMath::Abs(trk->GetLabel());
203  const AliVParticle *mcpart = evnt->GetTrack(label);
204  if(!mcpart) return NULL;
205  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(mcpart);
206  if(aodpart) {
207  if(!aodpart->IsPhysicalPrimary()) return NULL;
208  } else {
209  if(!evnt->IsPhysicalPrimary(label)) return NULL;
210  }
211  return mcpart;
212 }
213 
223  const TString& histname, const AliVParticle* track, const AliEmcalJet* jet,
224  double vz, double weight) {
225 
226  if(!fTriggerClassManager) return;
227  double data[6] = {TMath::Abs(track->Pt()), TMath::Abs(jet->Pt()), (fSwapEta ? -1. : 1.) * track->Eta(), track->Phi(), vz, fTriggerClassManager->HasMinBiasTrigger() ? 1. : 0.};
228  fHistos->FillTHnSparse(histname.Data(), data, weight);
229 }
230 
239  const TString& histname, const AliEmcalJet* recjet, double vz, double weight) {
240  double data[4] = {TMath::Abs(recjet->Pt()), (fSwapEta ? -1. : 1.) * recjet->Eta(), recjet->Phi(), vz};
241  fHistos->FillTHnSparse(histname.Data(), data, weight);
242 }
243 
258  const TString& histname, const AliVTrack* const trk, const AliEmcalJet* jet, double centpercent, double weight) {
259  /*
260  */
261  double data[5] = { TMath::Abs(trk->Pt()), TMath::Abs(jet->Pt()), (fSwapEta ? -1. : 1.) * trk->Eta(), centpercent, jet->DeltaR(trk)};
262  fHistos->FillTHnSparse(histname.Data(), data, weight);
263 }
264 
265 } /* namespace EMCalTriggerPtAnalysis */
const char * title
Definition: MakeQAPdf.C:26
void PrintTriggerNames(const std::vector< std::string > &, const std::string &componentName) const
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:108
const AliEMCalTriggerWeightHandler * fWeightHandler
Event weight handler.
Double_t Phi() const
Definition: AliEmcalJet.h:104
void FillTrackHistogramCentrality(const TString &histname, const AliVTrack *const trk, const AliEmcalJet *jet, double centpercent, double weight)
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
Int_t TrackAt(Int_t idx) const
Definition: AliEmcalJet.h:147
UShort_t GetNumberOfTracks() const
Definition: AliEmcalJet.h:126
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.
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:96
void FillJetHistogram(const TString &histname, const AliEmcalJet *recjet, double vz, double weight)
double GetEventWeight(const AliMCEvent *const event) const
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