AliPhysics  58f3d52 (58f3d52)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEMCalTriggerMCParticleAnalysisComponent.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 /*
16  * Analysis component for simple Monte-Carlo particles. Loops over all particles, selects
17  * those which are physical primary, and fills a THnSparse with them.
18  *
19  * Author: Markus Fasel
20  */
21 #include <TAxis.h>
22 #include <TBinning.h>
23 #include <TMath.h>
24 #include <THistManager.h>
25 
26 #include "AliAODMCParticle.h"
27 #include "AliMCEvent.h"
28 #include "AliVParticle.h"
29 #include "AliVEvent.h"
30 #include "AliVVertex.h"
31 
38 
39 
41 
42 namespace EMCalTriggerPtAnalysis {
43 
44 //______________________________________________________________________________
45 AliEMCalTriggerMCParticleAnalysisComponent::AliEMCalTriggerMCParticleAnalysisComponent() :
47 {
48  /*
49  * Dummy Constructor for I/O
50  */
51 }
52 
53 //______________________________________________________________________________
56 {
57  /*
58  * Main Constructor, to be called by the users
59  */
60 }
61 
62  //______________________________________________________________________________
64  /*
65  * Create histograms for the MC truth analysis component
66  */
67 
68  const TBinning *ptbinning = fBinning->GetBinning("pt"),
69  *etabinning = fBinning->GetBinning("eta"),
70  *phibinning = fBinning->GetBinning("phi"),
71  *vertexbinning = fBinning->GetBinning("zvertex");
73  const TAxis *trackaxes[4] = {
74  DefineAxis("pt", *ptbinning),
75  DefineAxis("eta", *etabinning),
76  DefineAxis("phi", *phibinning),
77  DefineAxis("zvertex", *vertexbinning)
78  };
79  fHistos->CreateTHnSparse("hMCtrueParticles", "Particle-based histogram for MC-true particles", 4, trackaxes, "s");
80 }
81 
82 //______________________________________________________________________________
84  /*
85  * Run event loop
86  */
87  AliMCEvent *mc = data->GetMCEvent();
88  if(!mc) return;
89  AliVEvent *rec = data->GetRecEvent();
90  Double_t values[4];
91  double weight = 1.;
92  if(fWeightHandler && data->GetMCEvent()){
93  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
94  }
95  for(int itrk = 0; itrk < mc->GetNumberOfTracks(); itrk++){
96  AliVParticle *track = mc->GetTrack(itrk);
97  if(!track->Charge()) continue;
98  if(!IsPhysicalPrimary(track, mc)) continue;
99  if(!fKineCuts->IsSelected(track)) continue;
100 
101  values[0] = TMath::Abs(track->Pt());
102  values[1] = track->Eta();
103  values[2] = track->Phi();
104  values[3] = rec->GetPrimaryVertex()->GetZ();
105  fHistos->FillTHnSparse("hMCtrueParticles", values, weight);
106  }
107 }
108 
109 //______________________________________________________________________________
110 bool AliEMCalTriggerMCParticleAnalysisComponent::IsPhysicalPrimary(const AliVParticle* const part, const AliMCEvent* const mcev) const {
111  /*
112  * Transparent access to Physical primary information
113  */
114  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(part);
115  if(aodpart){
116  return aodpart->IsPhysicalPrimary();
117  }
118  return mcev->IsPhysicalPrimary(part->GetLabel()); // No abs value since default value is -1
119 }
120 
121 } /* namespace EMCalTriggerPtAnalysis */
double Double_t
Definition: External.C:58
const AliEMCalTriggerWeightHandler * fWeightHandler
Event weight handler.
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
THistManager * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerKineCuts * fKineCuts
Kinematical cuts for tracks and particle selection.
Base class for analysis components in the analysis of EMCAL-triggered events.
double GetEventWeight(const AliMCEvent *const event) const
Simple event container within the high- track analysis.
bool IsPhysicalPrimary(const AliVParticle *const part, const AliMCEvent *const ev) const
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.