]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliForwardMultiplicityTask.cxx
Mega commit of many changes to PWGLFforward
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardMultiplicityTask.cxx
1 // 
2 // Calculate the multiplicity in the forward regions event-by-event 
3 // 
4 // Inputs: 
5 //   - AliESDEvent 
6 //
7 // Outputs: 
8 //   - AliAODForwardMult 
9 // 
10 // Histograms 
11 //   
12 // Corrections used 
13 //
14 #include "AliForwardMultiplicityTask.h"
15 #include "AliTriggerAnalysis.h"
16 #include "AliPhysicsSelection.h"
17 #include "AliLog.h"
18 #include "AliESDEvent.h"
19 #include "AliAODHandler.h"
20 #include "AliMultiplicity.h"
21 #include "AliInputEventHandler.h"
22 #include "AliForwardCorrectionManager.h"
23 #include "AliAnalysisManager.h"
24 #include <TH1.h>
25 #include <TH3D.h>
26 #include <TDirectory.h>
27 #include <TTree.h>
28 #include <TROOT.h>
29
30
31 //====================================================================
32 AliForwardMultiplicityTask::AliForwardMultiplicityTask()
33   : AliForwardMultiplicityBase(),
34     fESDFMD(),
35     fEventInspector(),
36     fSharingFilter(),
37     fDensityCalculator(),
38     fCorrections(),
39     fHistCollector(),
40     fEventPlaneFinder()
41 {
42   // 
43   // Constructor
44   //
45   DGUARD(fDebug, 3,"Default CTOR of AliForwardMultiplicityTask");
46 }
47
48 //____________________________________________________________________
49 AliForwardMultiplicityTask::AliForwardMultiplicityTask(const char* name)
50   : AliForwardMultiplicityBase(name),
51     fESDFMD(),
52     fEventInspector("event"),
53     fSharingFilter("sharing"), 
54     fDensityCalculator("density"),
55     fCorrections("corrections"),
56     fHistCollector("collector"),
57     fEventPlaneFinder("eventplane")
58 {
59   // 
60   // Constructor 
61   // 
62   // Parameters:
63   //    name Name of task 
64   //
65   DGUARD(fDebug, 3,"named CTOR of AliForwardMultiplicityTask: %s", name);
66 }
67
68 //____________________________________________________________________
69 AliForwardMultiplicityTask::AliForwardMultiplicityTask(const AliForwardMultiplicityTask& o)
70   : AliForwardMultiplicityBase(o),
71     fESDFMD(o.fESDFMD),
72     fEventInspector(o.fEventInspector),
73     fSharingFilter(o.fSharingFilter),
74     fDensityCalculator(o.fDensityCalculator),
75     fCorrections(o.fCorrections),
76     fHistCollector(o.fHistCollector),
77     fEventPlaneFinder(o.fEventPlaneFinder)
78
79 {
80   // 
81   // Copy constructor 
82   // 
83   // Parameters:
84   //    o Object to copy from 
85   //
86   DGUARD(fDebug, 3,"Copy CTOR of AliForwardMultiplicityTask");
87 }
88
89 //____________________________________________________________________
90 AliForwardMultiplicityTask&
91 AliForwardMultiplicityTask::operator=(const AliForwardMultiplicityTask& o)
92 {
93   // 
94   // Assignment operator 
95   // 
96   // Parameters:
97   //    o Object to assign from 
98   // 
99   // Return:
100   //    Reference to this object 
101   //
102   DGUARD(fDebug,3,"Assignment to AliForwardMultiplicityTask");
103   if (&o == this) return *this;
104   AliForwardMultiplicityBase::operator=(o);
105
106   fEventInspector    = o.fEventInspector;
107   fSharingFilter     = o.fSharingFilter;
108   fDensityCalculator = o.fDensityCalculator;
109   fCorrections       = o.fCorrections;
110   fHistCollector     = o.fHistCollector;
111   fEventPlaneFinder  = o.fEventPlaneFinder;
112
113   return *this;
114 }
115
116 //____________________________________________________________________
117 void
118 AliForwardMultiplicityTask::UserExec(Option_t*)
119 {
120   // 
121   // Process each event 
122   // 
123   // Parameters:
124   //    option Not used
125   //  
126
127   DGUARD(fDebug,1,"Process the input event");
128   // static Int_t cnt = 0;
129   // cnt++;
130   // Get the input data 
131   AliESDEvent* esd = GetESDEvent();
132   if (!esd) return;
133
134   // Clear stuff 
135   fHistos.Clear();
136   fESDFMD.Clear();
137   fAODFMD.Clear();
138   fAODEP.Clear();
139   
140   Bool_t   lowFlux   = kFALSE;
141   UInt_t   triggers  = 0;
142   UShort_t ivz       = 0;
143   TVector3 ip;
144   Double_t cent      = -1;
145   UShort_t nClusters = 0;
146   UInt_t   found     = fEventInspector.Process(esd, triggers, lowFlux, 
147                                                ivz, ip, cent, nClusters);
148   
149   if (found & AliFMDEventInspector::kNoEvent)    return;
150   if (found & AliFMDEventInspector::kNoTriggers) return;
151
152   // Set trigger bits, and mark this event for storage 
153   fAODFMD.SetTriggerBits(triggers);
154   fAODFMD.SetSNN(fEventInspector.GetEnergy());
155   fAODFMD.SetSystem(fEventInspector.GetCollisionSystem());
156   fAODFMD.SetCentrality(cent);
157   fAODFMD.SetNClusters(nClusters);
158   MarkEventForStore();
159  
160   if (found & AliFMDEventInspector::kNoSPD)      return;
161   if (found & AliFMDEventInspector::kNoFMD)      return;
162   if (found & AliFMDEventInspector::kNoVertex)   return;
163   
164   if (triggers & AliAODForwardMult::kPileUp) return;
165   
166   fAODFMD.SetIpZ(ip.Z());
167
168   if (found & AliFMDEventInspector::kBadVertex) return;
169
170   // We we do not want to use low flux specific code, we disable it here. 
171   if (!fEnableLowFlux) lowFlux = false;
172
173   // Get FMD data 
174   AliESDFMD* esdFMD = esd->GetFMDData();
175   //  // Apply the sharing filter (or hit merging or clustering if you like)
176   if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) { 
177     AliWarning("Sharing filter failed!");
178     return;
179   }
180   
181   // Calculate the inclusive charged particle density 
182   if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) { 
183     // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) { 
184     AliWarning("Density calculator failed!");
185     return;
186   }
187
188   if (fEventInspector.GetCollisionSystem() == AliFMDEventInspector::kPbPb) {
189     if (!fEventPlaneFinder.FindEventplane(esd, fAODEP, 
190                                           &(fAODFMD.GetHistogram()), &fHistos))
191       AliWarning("Eventplane finder failed!");
192   }
193   
194   // Do the secondary and other corrections. 
195   if (!fCorrections.Correct(fHistos, ivz)) { 
196     AliWarning("Corrections failed");
197     return;
198   }
199
200   if (!fHistCollector.Collect(fHistos, fRingSums, 
201                               ivz, fAODFMD.GetHistogram(),
202                               fAODFMD.GetCentrality())) {
203     AliWarning("Histogram collector failed");
204     return;
205   }
206
207   if (fAODFMD.IsTriggerBits(AliAODForwardMult::kInel))
208     fHData->Add(&(fAODFMD.GetHistogram()));
209
210   PostData(1, fList);
211 }
212
213 //____________________________________________________________________
214 void
215 AliForwardMultiplicityTask::FinishTaskOutput()
216 {
217   if (!fList) 
218     Warning("FinishTaskOutput", "No list defined");
219   else {
220     if (fDebug) 
221       fList->ls();
222   }
223   AliAnalysisTaskSE::FinishTaskOutput();
224 }
225
226
227 //
228 // EOF
229 //