]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliCentralMCMultiplicityTask.cxx
Renamed some member functions for more logical names
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliCentralMCMultiplicityTask.cxx
1 //====================================================================
2 // 
3 // Base class for classes that calculate the multiplicity in the
4 // central region event-by-event
5 // 
6 // Inputs: 
7 //   - AliESDEvent 
8 //
9 // Outputs: 
10 //   - AliAODCentralMult 
11 // 
12 // Histograms 
13 //   
14 // Corrections used 
15 #include "AliCentralMCMultiplicityTask.h"
16 #include "AliForwardCorrectionManager.h"
17 #include "AliForwardUtil.h"
18 #include "AliLog.h"
19 #include "AliAODHandler.h"
20 #include "AliInputEventHandler.h"
21 #include "AliESDInputHandler.h"
22 #include "AliAnalysisManager.h"
23 #include "AliESDEvent.h"
24 #include "AliMultiplicity.h"
25 #include "AliFMDEventInspector.h"
26 #include <AliMCEvent.h>
27 #include <AliTrackReference.h>
28 #include <AliStack.h>
29 #include <TROOT.h>
30 #include <TH1D.h>
31 #include <TH2D.h>
32 #include <TH3D.h>
33 #include <TFile.h>
34 #include <TError.h>
35 #include <iostream>
36 #include <iomanip>
37
38 //====================================================================
39 AliCentralMCMultiplicityTask::AliCentralMCMultiplicityTask(const char* name) 
40   : AliCentralMultiplicityTask(name),
41     fTrackDensity(name),
42     fAODMCCentral(kTRUE)
43 {
44   // 
45   // Constructor 
46   //   
47   DGUARD(fDebug,3,"Named CTOR of AliCentralMCMultiplicityTask: %s", 
48          name);
49   fBranchNames = 
50     "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
51     "SPDVertex.,PrimaryVertex.";
52 }
53 //____________________________________________________________________
54 AliCentralMCMultiplicityTask::AliCentralMCMultiplicityTask() 
55   : AliCentralMultiplicityTask(),
56     fTrackDensity(),
57     fAODMCCentral(kTRUE)
58 {
59   // 
60   // Constructor 
61   // 
62   DGUARD(fDebug, 3,"Default CTOR of AliCentralMCMultiplicityTask");
63 }
64 //____________________________________________________________________
65 AliCentralMCMultiplicityTask::AliCentralMCMultiplicityTask(const AliCentralMCMultiplicityTask& o)
66   : AliCentralMultiplicityTask(o),
67     fTrackDensity(o.fTrackDensity),
68     fAODMCCentral(o.fAODMCCentral)
69 {
70   //
71   // Copy constructor 
72   // 
73   DGUARD(fDebug, 3,"COPY CTOR of AliCentralMCMultiplicityTask");
74 }
75 //____________________________________________________________________
76 AliCentralMCMultiplicityTask&
77 AliCentralMCMultiplicityTask::operator=(const AliCentralMCMultiplicityTask& o)
78 {
79   // 
80   // Assignment operator 
81   //
82   DGUARD(fDebug,3,"Assignment of AliCentralMCMultiplicityTask");
83   if (&o == this) return *this; 
84   AliCentralMultiplicityTask::operator=(o);
85   fAODMCCentral     = o.fAODMCCentral;
86   fTrackDensity     = o.fTrackDensity;
87   return *this;
88 }
89 //____________________________________________________________________
90 void AliCentralMCMultiplicityTask::UserCreateOutputObjects() 
91 {
92   // 
93   // Create output objects 
94   // 
95   //
96   DGUARD(fDebug,1,"Create user output in AliCentralMCMultiplicityTask");
97   AliCentralMultiplicityTask::UserCreateOutputObjects();
98
99   AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
100   AliAODHandler*      ah = 
101     dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
102   if (!ah) AliFatal("No AOD output handler set in analysis manager");
103   
104   
105   TObject* obj = &fAODMCCentral;
106   ah->AddBranch("AliAODCentralMult", &obj);
107
108   
109   fTrackDensity.CreateOutputObjects(fList);
110
111 }
112 //____________________________________________________________________
113 void AliCentralMCMultiplicityTask::UserExec(Option_t* option) 
114 {
115   // 
116   // Process each event 
117   // 
118   // Parameters:
119   //    option Not used
120   //  
121   DGUARD(fDebug,1,"Process event in AliCentralMCMultiplicityTask");
122   fAODMCCentral.Clear("");
123   // Call base class 
124   AliCentralMultiplicityTask::UserExec(option);
125 fAODMCCentral.Init(*(fAODCentral.GetHistogram().GetXaxis()));
126   // check if we need this event 
127   AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
128   AliAODHandler*      ah = 
129     dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
130   if (!ah)  
131     AliFatal("No AOD output handler set in analysis manager");
132
133   // if base class did not want this event, then neither to we 
134   if (!ah->GetFillAOD() || fIvz <= 0) return;
135   
136   const AliMCEvent*  mcEvent = MCEvent();
137   if (!mcEvent) return;
138   TH2D&              hist    = fAODMCCentral.GetHistogram();
139
140   Double_t vz = GetManager().GetSecMap()->GetVertexAxis().GetBinCenter(fIvz);
141
142   fTrackDensity.Calculate(*mcEvent, vz, hist, NULL);
143
144   CorrectData(hist, fIvz);
145
146 }
147
148 //____________________________________________________________________
149 void AliCentralMCMultiplicityTask::Terminate(Option_t* option) 
150 {
151   // 
152   // End of job
153   // 
154   // Parameters:
155   //    option Not used 
156   //
157   DGUARD(fDebug,1,"Final analysis of merge in AliCentralMCMultiplicityTask");
158   AliCentralMultiplicityTask::Terminate(option);
159 }
160 //____________________________________________________________________
161 void
162 AliCentralMCMultiplicityTask::Print(Option_t* option) const
163 {
164   // 
165   // Print information 
166   // 
167   // Parameters:
168   //    option Not used
169   //
170   AliCentralMultiplicityTask::Print(option);
171   gROOT->IncreaseDirLevel();
172   fTrackDensity.Print(option);
173   gROOT->DecreaseDirLevel();
174 }
175 //
176 // EOF
177 //