]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliCentralMCMultiplicityTask.cxx
Cleaned up error handling when missing corrections. Previously
[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,0,"Named CTOR of AliCentralMCMultiplicityTask: %s", name);
48 }
49 //____________________________________________________________________
50 AliCentralMCMultiplicityTask::AliCentralMCMultiplicityTask() 
51   : AliCentralMultiplicityTask(),
52     fTrackDensity(),
53     fAODMCCentral(kTRUE)
54 {
55   // 
56   // Constructor 
57   // 
58   DGUARD(fDebug,0,"Default CTOR of AliCentralMCMultiplicityTask");
59 }
60 //____________________________________________________________________
61 AliCentralMCMultiplicityTask::AliCentralMCMultiplicityTask(const AliCentralMCMultiplicityTask& o)
62   : AliCentralMultiplicityTask(o),
63     fTrackDensity(o.fTrackDensity),
64     fAODMCCentral(o.fAODMCCentral)
65 {
66   //
67   // Copy constructor 
68   // 
69   DGUARD(fDebug,0,"COPY CTOR of AliCentralMCMultiplicityTask");
70 }
71 //____________________________________________________________________
72 AliCentralMCMultiplicityTask&
73 AliCentralMCMultiplicityTask::operator=(const AliCentralMCMultiplicityTask& o)
74 {
75   // 
76   // Assignment operator 
77   //
78   DGUARD(fDebug,3,"Assignment of AliCentralMCMultiplicityTask");
79   if (&o == this) return *this; 
80   AliCentralMultiplicityTask::operator=(o);
81   fAODMCCentral     = o.fAODMCCentral;
82   fTrackDensity     = o.fTrackDensity;
83   return *this;
84 }
85 //____________________________________________________________________
86 void AliCentralMCMultiplicityTask::UserCreateOutputObjects() 
87 {
88   // 
89   // Create output objects 
90   // 
91   //
92   DGUARD(fDebug,1,"Create user output in AliCentralMCMultiplicityTask");
93   AliCentralMultiplicityTask::UserCreateOutputObjects();
94
95   AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
96   AliAODHandler*      ah = 
97     dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
98   if (!ah) AliFatal("No AOD output handler set in analysis manager");
99   
100   
101   TObject* obj = &fAODMCCentral;
102   ah->AddBranch("AliAODCentralMult", &obj);
103
104   
105   fTrackDensity.DefineOutput(fList);
106
107 }
108 //____________________________________________________________________
109 void AliCentralMCMultiplicityTask::UserExec(Option_t* option) 
110 {
111   // 
112   // Process each event 
113   // 
114   // Parameters:
115   //    option Not used
116   //  
117   DGUARD(fDebug,1,"Process event in AliCentralMCMultiplicityTask");
118   fAODMCCentral.Clear("");
119   
120   // Call base class 
121   AliCentralMultiplicityTask::UserExec(option);
122
123   // check if we need this event 
124   AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
125   AliAODHandler*      ah = 
126     dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
127   if (!ah)  
128     AliFatal("No AOD output handler set in analysis manager");
129
130   // if base class did not want this event, then neither to we 
131   if (!ah->GetFillAOD() || fIvz <= 0) return;
132   
133   const AliMCEvent*  mcEvent = MCEvent();
134   if (!mcEvent) return;
135   TH2D&              hist    = fAODMCCentral.GetHistogram();
136
137   Double_t vz = GetManager().GetSecMap()->GetVertexAxis().GetBinCenter(fIvz);
138
139   fTrackDensity.Calculate(*mcEvent, vz, hist, NULL);
140
141   CorrectData(hist, fIvz);
142
143 }
144
145 //____________________________________________________________________
146 void AliCentralMCMultiplicityTask::Terminate(Option_t* option) 
147 {
148   // 
149   // End of job
150   // 
151   // Parameters:
152   //    option Not used 
153   //
154   DGUARD(fDebug,1,"Final analysis of merge in AliCentralMCMultiplicityTask");
155   AliCentralMultiplicityTask::Terminate(option);
156 }
157 //____________________________________________________________________
158 void
159 AliCentralMCMultiplicityTask::Print(Option_t* option) const
160 {
161   // 
162   // Print information 
163   // 
164   // Parameters:
165   //    option Not used
166   //
167   AliCentralMultiplicityTask::Print(option);
168   gROOT->IncreaseDirLevel();
169   fTrackDensity.Print(option);
170   gROOT->DecreaseDirLevel();
171 }
172 //
173 // EOF
174 //