AliPhysics  d565ceb (d565ceb)
AliAnalysisTaskEmcalTriggerEmulation.cxx
Go to the documentation of this file.
1  /**************************************************************************
2  * Copyright(c) 1998-2016, 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 <sstream>
16 
17 #include <TArrayD.h>
18 #include <THashList.h>
19 #include <THistManager.h>
20 #include <TMath.h>
21 
22 #include "AliAODMCParticle.h"
23 #include "AliClusterContainer.h"
24 #include "AliMCParticleContainer.h"
25 #include "AliTrackContainer.h"
26 #include "AliVCluster.h"
27 #include "AliVEvent.h"
28 #include "AliVParticle.h"
29 #include "AliVTrack.h"
30 #include "AliVVertex.h"
31 
37 
41 
42 namespace EMCalTriggerPtAnalysis {
43 
44 AliAnalysisTaskEmcalTriggerEmulation::AliAnalysisTaskEmcalTriggerEmulation() :
46  fkWeightHandler(nullptr),
47  fkTriggerEmulation(nullptr),
48  fHistManager(nullptr),
49  fNameMCParticles(),
50  fNameClusters(),
51  fNameTracks(),
52  fIsMC(false),
53  fEtaRange(-0.8, 0.8),
54  fPhiRange(0, 2*TMath::Pi())
55 {
56  /*
57  * See header file for details
58  */
59 }
60 
62  AliAnalysisTaskEmcal(name, true),
67  fNameClusters(),
68  fNameTracks(),
69  fIsMC(false),
70  fEtaRange(-0.8, 0.8),
71  fPhiRange(0, 2*TMath::Pi())
72 {
73  /*
74  * See header file for details
75  */
76 }
77 
79  /*
80  * See header file for details
81  */
84  if(fHistManager) delete fHistManager;
85 }
86 
88  /*
89  * See header file for details
90  */
92 
95  binfact.Create(&binhandler);
96 
97  std::stringstream kinestring;
98  kinestring << "eta " << fEtaRange << ", phi " << fPhiRange;
99 
100  fHistManager = new THistManager("histos");
101  fHistManager->CreateTH1("hEvents", "Event counter", 1, 0.5, 1.5);
102  fHistManager->CreateTH1("hVertexZ", "z-component of the primary vertex", 100, -40, 40);
103  fHistManager->CreateTH1("hParticles", Form("Particles (%s)", kinestring.str().c_str()), *binhandler.GetBinning("pt"));
104  fHistManager->CreateTH1("hClusters", "Clusters", *binhandler.GetBinning("pt"));
105  fHistManager->CreateTH1("hTracks", Form("Tracks (%s)", kinestring.str().c_str()), *binhandler.GetBinning("pt"));
106 
107  for(auto histo : *fHistManager) fOutput->Add(histo);
108 }
109 
111  /*
112  * See header file for details
113  */
114  double weight = 1;
115  if(fIsMC){
117  const AliAODMCParticle *mcpart(nullptr);
118  // Loop MC particles
119  for(auto mcen : GetMCParticleContainer(fNameMCParticles.Data())->accepted()){
120  mcpart =static_cast<const AliAODMCParticle *>(mcen);
121  if(!mcpart->IsPhysicalPrimary()) continue;
122  if(mcpart->Charge() == 0) continue;
123  if(!fEtaRange.IsInRange(mcpart->Eta())) continue;
124  if(!fPhiRange.IsInRange(mcpart->Phi())) continue;
125  fHistManager->FillTH1("hParticles", TMath::Abs(mcpart->Pt()), weight);
126  }
127  if(fkTriggerEmulation){
129  }
130  }
131 
132  fHistManager->FillTH1("hEvents", 1, weight);
133  fHistManager->FillTH1("hVertexZ", InputEvent()->GetPrimaryVertex()->GetZ(), weight);
134 
135  // Loop clusters
136  const AliVCluster *clust(nullptr);
137  for(auto clusten : GetClusterContainer(fNameClusters.Data())->accepted()){
138  clust = static_cast<const AliVCluster *>(clusten);
139  fHistManager->FillTH1("hClusters", TMath::Abs(clust->E()), weight);
140  }
141 
142  // Loop tracks
143  // Assume: Track quality cuts done by the track container
144  const AliVTrack *track(nullptr);
145  const AliAODMCParticle *assocMC(nullptr), *tmp(nullptr);
146  for(auto tracken : GetTrackContainer(fNameTracks.Data())->accepted()){
147  track = static_cast<const AliVTrack *>(tracken);
148  double pt = TMath::Abs(track->Pt());
149  if(fIsMC){
150  for(auto mcen : GetMCParticleContainer(fNameMCParticles.Data())->accepted()){
151  tmp = static_cast<const AliAODMCParticle *>(mcen);
152  if(TMath::Abs(tmp->GetLabel()) == TMath::Abs(track->GetLabel())){
153  assocMC = tmp;
154  break;
155  }
156  }
157  if(!assocMC) continue;
158  if(!assocMC->IsPhysicalPrimary()) continue;
159  pt = TMath::Abs(assocMC->Pt());
160  }
161  if(!fEtaRange.IsInRange(track->Eta())) continue;
162  if(!fPhiRange.IsInRange(track->Phi())) continue;
163  fHistManager->FillTH1("hTracks", pt, weight);
164  }
165 
166  return true;
167 }
168 
169 } /* namespace EMCalTriggerPtAnalysis */
virtual bool Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
Base task in the EMCAL framework.
Emulate EMCAL trigger offline in simulation, and monitor reference distribution.
const AliEMCalTriggerWeightHandler * fkWeightHandler
Handler containing bin weights for -hard productions.
Global binning handler used by several analysis components.
AliCutValueRange< double > fEtaRange
Acceptance range for particles and tracks in -direction.
AliGenPythiaEventHeader * fPythiaHeader
!event Pythia header
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Global binning definition for the high- charged particle analysis.
bool SelectEvent(const AliEmcalContainer *const cont) const
double GetEventWeight(const AliMCEvent *const event) const
AliEmcalList * fOutput
!output list
AliMCParticleContainer * GetMCParticleContainer(Int_t i=0) const
const AliEmcalTriggerEmulation * fkTriggerEmulation
Offline emulation of the EMCAL trigger.
Analysis of high- tracks in triggered events.
AliTrackContainer * GetTrackContainer(Int_t i=0) const
Container class for histograms.
Definition: THistManager.h:99
void UserCreateOutputObjects()
Main initialization function on the worker.
AliCutValueRange< double > fPhiRange
Acceptance range for particles and tracks in -direction.