]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliForwardMultiplicityBase.cxx
Moved reading corrections into base class AliForwardMultiplicityBase.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliForwardMultiplicityBase.cxx
1 //====================================================================
2 // 
3 // Base class for classes that calculate the multiplicity in the
4 // forward regions event-by-event
5 // 
6 // Inputs: 
7 //   - AliESDEvent 
8 //
9 // Outputs: 
10 //   - AliAODForwardMult 
11 // 
12 // Histograms 
13 //   
14 // Corrections used 
15 #include "AliForwardMultiplicityBase.h"
16 #include "AliForwardCorrectionManager.h"
17 #include "AliLog.h"
18 #include "AliAODHandler.h"
19 #include "AliInputEventHandler.h"
20 #include "AliAnalysisManager.h"
21 #include "AliFMDEventInspector.h"
22 #include "AliFMDEnergyFitter.h"
23 #include "AliFMDSharingFilter.h"
24 #include "AliFMDDensityCalculator.h"
25 #include "AliFMDCorrector.h"
26 #include "AliFMDHistCollector.h"
27 #include "AliESDEvent.h"
28 #include <TROOT.h>
29
30
31 //====================================================================
32 Bool_t 
33 AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
34 {
35   // 
36   // Check if all needed corrections are there and accounted for.  If not,
37   // do a Fatal exit 
38   // 
39   // Parameters:
40   //    what Which corrections is needed
41   // 
42   // Return:
43   //    true if all present, false otherwise
44   //  
45
46   AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
47   // Check that we have the energy loss fits, needed by 
48   //   AliFMDSharingFilter 
49   //   AliFMDDensityCalculator 
50   if (what & AliForwardCorrectionManager::kELossFits && !fcm.GetELossFit()) { 
51     AliFatal(Form("No energy loss fits"));
52     return false;
53   }
54   // Check that we have the double hit correction - (optionally) used by 
55   //  AliFMDDensityCalculator 
56   if (what & AliForwardCorrectionManager::kDoubleHit && !fcm.GetDoubleHit()) {
57     AliFatal("No double hit corrections"); 
58     return false;
59   }
60   // Check that we have the secondary maps, needed by 
61   //   AliFMDCorrector 
62   //   AliFMDHistCollector
63   if (what & AliForwardCorrectionManager::kSecondaryMap && 
64       !fcm.GetSecondaryMap()) {
65     AliFatal("No secondary corrections");
66     return false;
67   }
68   // Check that we have the vertex bias correction, needed by 
69   //   AliFMDCorrector 
70   if (what & AliForwardCorrectionManager::kVertexBias && 
71       !fcm.GetVertexBias()) { 
72     AliFatal("No event vertex bias corrections");
73     return false;
74   }
75   // Check that we have the merging efficiencies, optionally used by 
76   //   AliFMDCorrector 
77   if (what & AliForwardCorrectionManager::kMergingEfficiency && 
78       !fcm.GetMergingEfficiency()) {
79     AliFatal("No merging efficiencies");
80     return false;
81   }
82   // Check that we have the acceptance correction, needed by 
83   //   AliFMDCorrector 
84   if (what & AliForwardCorrectionManager::kAcceptance && 
85       !fcm.GetAcceptance()) { 
86     AliFatal("No acceptance corrections");
87     return false;
88   }
89   return true;
90 }
91 //____________________________________________________________________
92 Bool_t
93 AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe, const TAxis*& pv)
94 {
95   UInt_t what = AliForwardCorrectionManager::kAll;
96   if (!fEnableLowFlux)
97     what ^= AliForwardCorrectionManager::kDoubleHit;
98   if (!GetCorrections().IsUseSecondaryMap()) {
99     what ^= AliForwardCorrectionManager::kSecondaryMap;
100     // Need to make eta and vertex axis here since we don't read
101     // that from the secondary correction objects
102     pe = new TAxis(200, -4, 6);
103     pv = new TAxis(10, -10, 10);
104   }
105   if (!GetCorrections().IsUseVertexBias())
106     what ^= AliForwardCorrectionManager::kVertexBias;
107   if (!GetCorrections().IsUseAcceptance())
108     what ^= AliForwardCorrectionManager::kAcceptance;
109   if (!GetCorrections().IsUseMergingEfficiency())
110     what ^= AliForwardCorrectionManager::kMergingEfficiency;
111
112   AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
113   if (!fcm.Init(GetEventInspector().GetCollisionSystem(),
114       GetEventInspector().GetEnergy(),
115       GetEventInspector().GetField(),
116       false,
117       what)) return false;
118   if (!CheckCorrections(what)) return false;
119
120   // Get the eta axis from the secondary maps - if read in
121   if (!pe) {
122     pe = fcm.GetEtaAxis();
123     if (!pe) AliFatal("No eta axis defined");
124   }
125   // Get the vertex axis from the secondary maps - if read in
126   if (!pv) {
127     pv = fcm.GetVertexAxis();
128     if (!pv) AliFatal("No vertex axis defined");
129   }
130
131   return true;
132 }
133 //____________________________________________________________________
134 AliESDEvent*
135 AliForwardMultiplicityBase::GetESDEvent()
136 {
137   AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
138   if (!esd) {
139     AliWarning("No ESD event found for input event");
140     return 0;
141   }
142
143   // On the first event, initialize the parameters
144   if (fFirstEvent && esd->GetESDRun()) {
145     GetEventInspector().ReadRunDetails(esd);
146
147     AliInfo(Form("Initializing with parameters from the ESD:\n"
148                  "         AliESDEvent::GetBeamEnergy()   ->%f\n"
149                  "         AliESDEvent::GetBeamType()     ->%s\n"
150                  "         AliESDEvent::GetCurrentL3()    ->%f\n"
151                  "         AliESDEvent::GetMagneticField()->%f\n"
152                  "         AliESDEvent::GetRunNumber()    ->%d\n",
153                  esd->GetBeamEnergy(),
154                  esd->GetBeamType(),
155                  esd->GetCurrentL3(),
156                  esd->GetMagneticField(),
157                  esd->GetRunNumber()));
158
159     fFirstEvent = false;
160
161     InitializeSubs();
162   }
163   return esd;
164 }
165 //____________________________________________________________________
166 void
167 AliForwardMultiplicityBase::MarkEventForStore() const
168 {
169   // Make sure the AOD tree is filled 
170   AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
171   AliAODHandler*      ah = 
172     dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
173   if (!ah)  
174     AliFatal("No AOD output handler set in analysis manager");
175
176   ah->SetFillAOD(kTRUE);
177 }
178
179 //____________________________________________________________________
180 void
181 AliForwardMultiplicityBase::Print(Option_t* option) const
182 {
183   // 
184   // Print information 
185   // 
186   // Parameters:
187   //    option Not used
188   //
189   std::cout << "AliForwardMultiplicityBase: " << GetName() << "\n" 
190             << "  Enable low flux code:   " << (fEnableLowFlux ? "yes" : "no")
191             << std::endl;
192   gROOT->IncreaseDirLevel();
193   GetEventInspector()   .Print(option);
194   GetEnergyFitter()     .Print(option);    
195   GetSharingFilter()    .Print(option);
196   GetDensityCalculator().Print(option);
197   GetCorrections()      .Print(option);
198   GetHistCollector()    .Print(option);
199   gROOT->DecreaseDirLevel();
200 }
201
202
203 //
204 // EOF
205 //