]>
Commit | Line | Data |
---|---|---|
6f791cc3 | 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 "AliCentralMultiplicityTask.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 <TROOT.h> | |
26 | #include <TFile.h> | |
3e478dba | 27 | #include <TError.h> |
6f791cc3 | 28 | #include <iostream> |
29 | #include <iomanip> | |
30 | ||
31 | //==================================================================== | |
32 | AliCentralMultiplicityTask::AliCentralMultiplicityTask(const char* name) | |
33 | : AliAnalysisTaskSE(name), | |
34 | fData(0), | |
35 | fList(0), | |
36 | fAODCentral(kFALSE), | |
3b2bfb07 | 37 | fManager(), |
38 | fUseSecondary(true) | |
6f791cc3 | 39 | { |
40 | ||
41 | DefineOutput(1, TList::Class()); | |
42 | } | |
43 | //____________________________________________________________________ | |
9c825779 | 44 | AliCentralMultiplicityTask::AliCentralMultiplicityTask() |
45 | : AliAnalysisTaskSE(), | |
46 | fData(0), | |
47 | fList(0), | |
48 | fAODCentral(), | |
3b2bfb07 | 49 | fManager(), |
50 | fUseSecondary(true) | |
9c825779 | 51 | { |
52 | } | |
53 | //____________________________________________________________________ | |
54 | AliCentralMultiplicityTask::AliCentralMultiplicityTask(const AliCentralMultiplicityTask& o) | |
55 | : AliAnalysisTaskSE(o), | |
56 | fData(o.fData), | |
57 | fList(o.fList), | |
58 | fAODCentral(o.fAODCentral), | |
3b2bfb07 | 59 | fManager(o.fManager), |
60 | fUseSecondary(o.fUseSecondary) | |
9c825779 | 61 | { |
62 | } | |
63 | //____________________________________________________________________ | |
64 | AliCentralMultiplicityTask& | |
65 | AliCentralMultiplicityTask::operator=(const AliCentralMultiplicityTask& o) | |
66 | { | |
3b2bfb07 | 67 | fData = o.fData; |
68 | fList = o.fList; | |
69 | fAODCentral = o.fAODCentral; | |
70 | fManager = o.fManager; | |
71 | fUseSecondary = o.fUseSecondary; | |
9c825779 | 72 | return *this; |
73 | } | |
74 | //____________________________________________________________________ | |
3e478dba | 75 | void AliCentralMultiplicityTask::UserCreateOutputObjects() |
76 | { | |
6f791cc3 | 77 | |
78 | AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager(); | |
79 | AliAODHandler* ah = | |
80 | dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler()); | |
81 | if (!ah) AliFatal("No AOD output handler set in analysis manager"); | |
82 | ||
83 | ||
84 | TObject* obj = &fAODCentral; | |
85 | ah->AddBranch("AliAODCentralMult", &obj); | |
86 | ||
87 | fList = new TList(); | |
88 | PostData(1,fList); | |
89 | ||
90 | } | |
91 | //____________________________________________________________________ | |
3e478dba | 92 | void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/) |
93 | { | |
6f791cc3 | 94 | |
95 | AliESDInputHandler* eventHandler = | |
96 | dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager() | |
97 | ->GetInputEventHandler()); | |
98 | if (!eventHandler) { | |
99 | AliWarning("No inputhandler found for this event!"); | |
100 | return;} | |
101 | ||
102 | AliESDEvent* esd = eventHandler->GetEvent(); | |
103 | ||
104 | //Selecting only events with |valid vertex| < 10 cm | |
105 | const AliESDVertex* vertex = esd->GetPrimaryVertexSPD(); | |
106 | if (!vertex) return; | |
107 | if(!(vertex->GetStatus())) return; | |
108 | if(vertex->GetNContributors() <= 0) return ; | |
109 | if(vertex->GetZRes() > 0.1 ) return; | |
110 | Double_t vertexXYZ[3]={0,0,0}; | |
111 | vertex->GetXYZ(vertexXYZ); | |
112 | if(TMath::Abs(vertexXYZ[2]) > 10) return; | |
113 | ||
3e478dba | 114 | Double_t delta = 2 ; |
6f791cc3 | 115 | Double_t vertexBinDouble = (vertexXYZ[2] + 10) / delta; |
3e478dba | 116 | //HHD: The vtxbins are 1-10, not 0-9 |
117 | Int_t vtxbin = Int_t(vertexBinDouble + 1) ; | |
6f791cc3 | 118 | |
119 | // Make sure AOD is filled | |
120 | AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager(); | |
121 | AliAODHandler* ah = | |
122 | dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler()); | |
123 | if (!ah) | |
124 | AliFatal("No AOD output handler set in analysis manager"); | |
125 | ||
126 | ah->SetFillAOD(kTRUE); | |
127 | ||
128 | //Doing analysis | |
129 | fAODCentral.Clear(""); | |
130 | TH2D *aodHist = &(fAODCentral.GetHistogram()); | |
131 | ||
132 | const AliMultiplicity* spdmult = esd->GetMultiplicity(); | |
133 | //Filling clusters in layer 1 used for tracklets... | |
3e478dba | 134 | for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++) |
6f791cc3 | 135 | aodHist->Fill(spdmult->GetEta(j),spdmult->GetPhi(j)); |
3e478dba | 136 | |
6f791cc3 | 137 | //...and then the unused ones in layer 1 |
3e478dba | 138 | for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++) |
6f791cc3 | 139 | aodHist->Fill(-TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.)), |
3e478dba | 140 | spdmult->GetPhiSingle(j)); |
6f791cc3 | 141 | |
6f791cc3 | 142 | |
3e478dba | 143 | // Corrections |
3b2bfb07 | 144 | TH2D* hSecMap = 0; |
6f791cc3 | 145 | TH1D* hAcceptance = fManager.GetAcceptanceCorrection(vtxbin); |
3b2bfb07 | 146 | if (fUseSecondary) hSecMap = fManager.GetSecMapCorrection(vtxbin); |
147 | if (fUseSecondary && !hSecMap) AliFatal("No secondary map!"); | |
148 | if (!hAcceptance) AliFatal("No acceptance!"); | |
dbe8d9ed | 149 | |
3b2bfb07 | 150 | if (hSecMap) aodHist->Divide(hSecMap); |
6f791cc3 | 151 | |
152 | for(Int_t nx = 1; nx <= aodHist->GetNbinsX(); nx++) { | |
3b2bfb07 | 153 | Float_t accCor = hAcceptance->GetBinContent(nx); |
6f791cc3 | 154 | |
155 | Bool_t etabinSeen = kFALSE; | |
156 | for(Int_t ny = 1; ny <= aodHist->GetNbinsY(); ny++) { | |
3b2bfb07 | 157 | Float_t aodValue = aodHist->GetBinContent(nx,ny); |
158 | Float_t secCor = hSecMap->GetBinContent(nx,ny); | |
159 | if (secCor > 0.5) etabinSeen = kTRUE; | |
160 | if (aodValue < 0.000001) { aodHist->SetBinContent(nx,ny, 0); continue; } | |
161 | if (accCor < 0.000001) accCor = 1; | |
162 | Float_t aodNew = aodValue / accCor ; | |
163 | aodHist->SetBinContent(nx,ny, aodNew); | |
3e478dba | 164 | Float_t aodErr = aodHist->GetBinError(nx,ny); |
165 | Float_t accErr = hAcceptance->GetBinError(nx); | |
3b2bfb07 | 166 | Float_t error = aodNew *TMath::Sqrt(TMath::Power(aodErr/aodValue,2) + |
167 | TMath::Power(accErr/accCor,2) ); | |
6f791cc3 | 168 | aodHist->SetBinError(nx,ny,error); |
169 | ||
170 | } | |
171 | //Filling underflow bin if we eta bin is in range | |
172 | if(etabinSeen) aodHist->SetBinContent(nx,0, 1.); | |
6f791cc3 | 173 | } |
174 | ||
175 | PostData(1,fList); | |
6f791cc3 | 176 | } |
177 | //____________________________________________________________________ | |
3e478dba | 178 | void AliCentralMultiplicityTask::Terminate(Option_t* /*option*/) |
179 | { | |
6f791cc3 | 180 | } |
181 | //____________________________________________________________________ | |
182 | void | |
183 | AliCentralMultiplicityTask::Print(Option_t* /*option*/) const | |
184 | { | |
6f791cc3 | 185 | } |
3e478dba | 186 | //==================================================================== |
6f791cc3 | 187 | AliCentralMultiplicityTask::Manager::Manager() : |
188 | fAcceptancePath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralAcceptance"), | |
189 | fSecMapPath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralSecMap"), | |
190 | fAcceptance(), | |
191 | fSecmap(), | |
192 | fAcceptanceName("centralacceptance"), | |
193 | fSecMapName("centralsecmap") | |
194 | { | |
195 | ||
196 | ||
197 | } | |
198 | //____________________________________________________________________ | |
3e478dba | 199 | AliCentralMultiplicityTask::Manager::Manager(const Manager& o) |
200 | :fAcceptancePath(o.fAcceptancePath), | |
201 | fSecMapPath(o.fSecMapPath), | |
202 | fAcceptance(o.fAcceptance), | |
203 | fSecmap(o.fSecmap), | |
204 | fAcceptanceName(o.fAcceptanceName), | |
205 | fSecMapName(o.fSecMapName) | |
206 | {} | |
207 | //____________________________________________________________________ | |
208 | AliCentralMultiplicityTask::Manager& | |
209 | AliCentralMultiplicityTask::Manager::operator=(const Manager& o) | |
210 | { | |
211 | fAcceptancePath = o.fAcceptancePath; | |
212 | fSecMapPath = o.fSecMapPath; | |
213 | fAcceptance = o.fAcceptance; | |
214 | fSecmap = o.fSecmap; | |
215 | fAcceptanceName = o.fAcceptanceName; | |
216 | fSecMapName = o.fSecMapName; | |
217 | return *this; | |
218 | } | |
219 | ||
220 | //____________________________________________________________________ | |
221 | const char* | |
222 | AliCentralMultiplicityTask::Manager::GetFullFileName(UShort_t what, | |
223 | UShort_t sys, | |
224 | UShort_t sNN, | |
225 | Short_t field) const | |
226 | { | |
227 | return Form("%s/%s", | |
228 | what == 0 ? GetSecMapPath() : GetAcceptancePath(), | |
229 | GetFileName(what, sys, sNN, field)); | |
230 | } | |
231 | ||
232 | //____________________________________________________________________ | |
233 | const char* | |
234 | AliCentralMultiplicityTask::Manager::GetFileName(UShort_t what , | |
235 | UShort_t sys, | |
236 | UShort_t sNN, | |
237 | Short_t field) const | |
238 | { | |
239 | // Must be static - otherwise the data may disappear on return from | |
240 | // this member function | |
241 | static TString fname = ""; | |
6f791cc3 | 242 | |
dbe8d9ed | 243 | fname = ""; |
6f791cc3 | 244 | switch(what) { |
3e478dba | 245 | case 0: fname.Append(fSecMapName.Data()); break; |
246 | case 1: fname.Append(fAcceptanceName.Data()); break; | |
6f791cc3 | 247 | default: |
3e478dba | 248 | ::Error("GetFileName", |
249 | "Invalid indentifier %d for central object, must be 0 or 1!", what); | |
6f791cc3 | 250 | break; |
251 | } | |
252 | fname.Append(Form("_%s_%04dGeV_%c%1dkG.root", | |
253 | AliForwardUtil::CollisionSystemString(sys), | |
254 | sNN, (field < 0 ? 'm' : 'p'), TMath::Abs(field))); | |
255 | ||
256 | return fname.Data(); | |
6f791cc3 | 257 | } |
3e478dba | 258 | |
6f791cc3 | 259 | //____________________________________________________________________ |
3e478dba | 260 | TH2D* |
261 | AliCentralMultiplicityTask::Manager::GetSecMapCorrection(UShort_t vtxbin) const | |
262 | { | |
263 | if (!fSecmap) { | |
264 | ::Warning("GetSecMapCorrection","No secondary map defined"); | |
265 | return 0; | |
266 | } | |
267 | return fSecmap->GetCorrection(vtxbin); | |
268 | } | |
269 | //____________________________________________________________________ | |
270 | TH1D* | |
271 | AliCentralMultiplicityTask::Manager::GetAcceptanceCorrection(UShort_t vtxbin) | |
272 | const | |
273 | { | |
274 | if (!fAcceptance) { | |
275 | ::Warning("GetAcceptanceCorrection","No acceptance map defined"); | |
276 | return 0; | |
277 | } | |
278 | return fAcceptance->GetCorrection(vtxbin); | |
279 | } | |
280 | ||
281 | //____________________________________________________________________ | |
282 | void | |
283 | AliCentralMultiplicityTask::Manager::Init(UShort_t sys, | |
284 | UShort_t sNN, | |
285 | Short_t field) | |
286 | { | |
6f791cc3 | 287 | TFile fsec(GetFullFileName(0,sys,sNN,field)); |
3e478dba | 288 | fSecmap = |
289 | dynamic_cast<AliCentralCorrSecondaryMap*>(fsec.Get(fSecMapName.Data())); | |
6f791cc3 | 290 | if(!fSecmap) { |
3e478dba | 291 | ::Error("Init", "no central Secondary Map found!") ; |
6f791cc3 | 292 | return; |
293 | } | |
294 | TFile facc(GetFullFileName(1,sys,sNN,field)); | |
3e478dba | 295 | fAcceptance = |
296 | dynamic_cast<AliCentralCorrAcceptance*>(facc.Get(fAcceptanceName.Data())); | |
297 | if(!fAcceptance) { | |
298 | ::Error("Init", "no central Acceptance found!") ; | |
299 | return; | |
300 | } | |
6f791cc3 | 301 | |
302 | } | |
303 | // | |
304 | // EOF | |
305 | // |