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