AliPhysics  v5-06-40-01 (42bb456)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
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 <TMath.h>
23 
24 #include "AliAODMCParticle.h"
25 #include "AliMCEvent.h"
26 #include "AliVParticle.h"
27 #include "AliVEvent.h"
28 #include "AliVVertex.h"
29 
36 
37 
39 
40 namespace EMCalTriggerPtAnalysis {
41 
42 //______________________________________________________________________________
43 AliEMCalTriggerMCParticleAnalysisComponent::AliEMCalTriggerMCParticleAnalysisComponent() :
44  AliEMCalTriggerTracksAnalysisComponent()
45 {
46  /*
47  * Dummy Constructor for I/O
48  */
49 }
50 
51 //______________________________________________________________________________
52 AliEMCalTriggerMCParticleAnalysisComponent::AliEMCalTriggerMCParticleAnalysisComponent(const char* name) :
53  AliEMCalTriggerTracksAnalysisComponent(name)
54 {
55  /*
56  * Main Constructor, to be called by the users
57  */
58 }
59 
60  //______________________________________________________________________________
61 void AliEMCalTriggerMCParticleAnalysisComponent::CreateHistos() {
62  /*
63  * Create histograms for the MC truth analysis component
64  */
65 
66  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
67  *etabinning = fBinning->GetBinning("eta"),
68  *phibinning = fBinning->GetBinning("phi"),
69  *vertexbinning = fBinning->GetBinning("zvertex");
70  AliEMCalTriggerTracksAnalysisComponent::CreateHistos();
71  const TAxis *trackaxes[4] = {
72  DefineAxis("pt", ptbinning),
73  DefineAxis("eta", etabinning),
74  DefineAxis("phi", phibinning),
75  DefineAxis("zvertex", vertexbinning)
76  };
77  fHistos->CreateTHnSparse("hMCtrueParticles", "Particle-based histogram for MC-true particles", 4, trackaxes, "s");
78 }
79 
80 //______________________________________________________________________________
81 void AliEMCalTriggerMCParticleAnalysisComponent::Process(const AliEMCalTriggerEventData* const data) {
82  /*
83  * Run event loop
84  */
85  AliMCEvent *mc = data->GetMCEvent();
86  if(!mc) return;
87  AliVEvent *rec = data->GetRecEvent();
88  Double_t values[4];
89  double weight = 1.;
90  if(fWeightHandler && data->GetMCEvent()){
91  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
92  }
93  for(int itrk = 0; itrk < mc->GetNumberOfTracks(); itrk++){
94  AliVParticle *track = mc->GetTrack(itrk);
95  if(!track->Charge()) continue;
96  if(!IsPhysicalPrimary(track, mc)) continue;
97  if(!fKineCuts->IsSelected(track)) continue;
98 
99  values[0] = TMath::Abs(track->Pt());
100  values[1] = track->Eta();
101  values[2] = track->Phi();
102  values[3] = rec->GetPrimaryVertex()->GetZ();
103  fHistos->FillTHnSparse("hMCtrueParticles", values, weight);
104  }
105 }
106 
107 //______________________________________________________________________________
108 bool AliEMCalTriggerMCParticleAnalysisComponent::IsPhysicalPrimary(const AliVParticle* const part, const AliMCEvent* const mcev) const {
109  /*
110  * Transparent access to Physical primary information
111  */
112  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(part);
113  if(aodpart){
114  return aodpart->IsPhysicalPrimary();
115  }
116  return mcev->IsPhysicalPrimary(part->GetLabel()); // No abs value since default value is -1
117 }
118 
119 } /* namespace EMCalTriggerPtAnalysis */
Weight handler for the analysis of high- tracks in EMCAL-triggered events.
void Process(Int_t *pflag[11520][7], TH1 *inhisto, Double_t Nsigma=4., Int_t dnbins=200, Double_t dmaxval=-1.)
ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerMCParticleAnalysisComponent) namespace EMCalTriggerPtAnalysis
Declaration of the classes AliEMCalTriggerBinningComponent and AliEMCalTriggerBinningDimension.
Event Data used in exchange to the different analysis components.