]>
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" | |
e58000b7 | 25 | #include "AliFMDEventInspector.h" |
6f791cc3 | 26 | #include <TROOT.h> |
27 | #include <TFile.h> | |
3e478dba | 28 | #include <TError.h> |
6f791cc3 | 29 | #include <iostream> |
30 | #include <iomanip> | |
31 | ||
32 | //==================================================================== | |
33 | AliCentralMultiplicityTask::AliCentralMultiplicityTask(const char* name) | |
34 | : AliAnalysisTaskSE(name), | |
35 | fData(0), | |
36 | fList(0), | |
37 | fAODCentral(kFALSE), | |
3b2bfb07 | 38 | fManager(), |
e58000b7 | 39 | fUseSecondary(true), |
fb3430ac | 40 | fFirstEventSeen(false) |
6f791cc3 | 41 | { |
fb3430ac | 42 | // |
43 | // Constructor | |
44 | // | |
6f791cc3 | 45 | DefineOutput(1, TList::Class()); |
46 | } | |
47 | //____________________________________________________________________ | |
9c825779 | 48 | AliCentralMultiplicityTask::AliCentralMultiplicityTask() |
49 | : AliAnalysisTaskSE(), | |
50 | fData(0), | |
51 | fList(0), | |
52 | fAODCentral(), | |
3b2bfb07 | 53 | fManager(), |
e58000b7 | 54 | fUseSecondary(true), |
fb3430ac | 55 | fFirstEventSeen(false) |
9c825779 | 56 | { |
fb3430ac | 57 | // |
58 | // Constructor | |
59 | // | |
9c825779 | 60 | } |
61 | //____________________________________________________________________ | |
62 | AliCentralMultiplicityTask::AliCentralMultiplicityTask(const AliCentralMultiplicityTask& o) | |
63 | : AliAnalysisTaskSE(o), | |
64 | fData(o.fData), | |
65 | fList(o.fList), | |
66 | fAODCentral(o.fAODCentral), | |
3b2bfb07 | 67 | fManager(o.fManager), |
e58000b7 | 68 | fUseSecondary(o.fUseSecondary), |
fb3430ac | 69 | fFirstEventSeen(o.fFirstEventSeen) |
9c825779 | 70 | { |
fb3430ac | 71 | // |
72 | // Copy constructor | |
73 | // | |
9c825779 | 74 | } |
75 | //____________________________________________________________________ | |
76 | AliCentralMultiplicityTask& | |
77 | AliCentralMultiplicityTask::operator=(const AliCentralMultiplicityTask& o) | |
78 | { | |
fb3430ac | 79 | // |
80 | // Assignment operator | |
81 | // | |
e58000b7 | 82 | fData = o.fData; |
83 | fList = o.fList; | |
84 | fAODCentral = o.fAODCentral; | |
85 | fManager = o.fManager; | |
86 | fUseSecondary = o.fUseSecondary; | |
fb3430ac | 87 | fFirstEventSeen = o.fFirstEventSeen; |
9c825779 | 88 | return *this; |
89 | } | |
90 | //____________________________________________________________________ | |
3e478dba | 91 | void AliCentralMultiplicityTask::UserCreateOutputObjects() |
92 | { | |
fb3430ac | 93 | // |
94 | // Create output objects | |
95 | // | |
96 | // | |
6f791cc3 | 97 | |
98 | AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager(); | |
99 | AliAODHandler* ah = | |
100 | dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler()); | |
101 | if (!ah) AliFatal("No AOD output handler set in analysis manager"); | |
102 | ||
103 | ||
104 | TObject* obj = &fAODCentral; | |
105 | ah->AddBranch("AliAODCentralMult", &obj); | |
106 | ||
107 | fList = new TList(); | |
9d05ffeb | 108 | fList->SetOwner(); |
6f791cc3 | 109 | PostData(1,fList); |
110 | ||
111 | } | |
112 | //____________________________________________________________________ | |
3e478dba | 113 | void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/) |
114 | { | |
fb3430ac | 115 | // |
116 | // Process each event | |
117 | // | |
118 | // Parameters: | |
119 | // option Not used | |
120 | // | |
6f791cc3 | 121 | |
122 | AliESDInputHandler* eventHandler = | |
123 | dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager() | |
124 | ->GetInputEventHandler()); | |
125 | if (!eventHandler) { | |
126 | AliWarning("No inputhandler found for this event!"); | |
127 | return;} | |
128 | ||
129 | AliESDEvent* esd = eventHandler->GetEvent(); | |
130 | ||
fb3430ac | 131 | if(!GetManager().IsInit() && !fFirstEventSeen) { |
e58000b7 | 132 | AliFMDEventInspector inspector; |
133 | inspector.ReadRunDetails(esd); | |
134 | GetManager().Init(inspector.GetCollisionSystem(), | |
135 | inspector.GetEnergy(), | |
136 | inspector.GetField()); | |
137 | ||
138 | //std::cout<<inspector.GetCollisionSystem()<<" "<<inspector.GetEnergy()<<" "<<inspector.GetField()<<std::endl; | |
139 | AliInfo("Manager of corrections in AliCentralMultiplicityTask init"); | |
fb3430ac | 140 | fFirstEventSeen = kTRUE; |
e58000b7 | 141 | } |
142 | ||
6f791cc3 | 143 | //Selecting only events with |valid vertex| < 10 cm |
144 | const AliESDVertex* vertex = esd->GetPrimaryVertexSPD(); | |
145 | if (!vertex) return; | |
146 | if(!(vertex->GetStatus())) return; | |
147 | if(vertex->GetNContributors() <= 0) return ; | |
148 | if(vertex->GetZRes() > 0.1 ) return; | |
149 | Double_t vertexXYZ[3]={0,0,0}; | |
150 | vertex->GetXYZ(vertexXYZ); | |
151 | if(TMath::Abs(vertexXYZ[2]) > 10) return; | |
152 | ||
3e478dba | 153 | Double_t delta = 2 ; |
6f791cc3 | 154 | Double_t vertexBinDouble = (vertexXYZ[2] + 10) / delta; |
3e478dba | 155 | //HHD: The vtxbins are 1-10, not 0-9 |
156 | Int_t vtxbin = Int_t(vertexBinDouble + 1) ; | |
6f791cc3 | 157 | |
158 | // Make sure AOD is filled | |
159 | AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager(); | |
160 | AliAODHandler* ah = | |
161 | dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler()); | |
162 | if (!ah) | |
163 | AliFatal("No AOD output handler set in analysis manager"); | |
164 | ||
165 | ah->SetFillAOD(kTRUE); | |
166 | ||
167 | //Doing analysis | |
168 | fAODCentral.Clear(""); | |
169 | TH2D *aodHist = &(fAODCentral.GetHistogram()); | |
170 | ||
171 | const AliMultiplicity* spdmult = esd->GetMultiplicity(); | |
172 | //Filling clusters in layer 1 used for tracklets... | |
3e478dba | 173 | for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++) |
6f791cc3 | 174 | aodHist->Fill(spdmult->GetEta(j),spdmult->GetPhi(j)); |
3e478dba | 175 | |
6f791cc3 | 176 | //...and then the unused ones in layer 1 |
3e478dba | 177 | for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++) |
6f791cc3 | 178 | aodHist->Fill(-TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.)), |
3e478dba | 179 | spdmult->GetPhiSingle(j)); |
6f791cc3 | 180 | |
6f791cc3 | 181 | |
3e478dba | 182 | // Corrections |
3b2bfb07 | 183 | TH2D* hSecMap = 0; |
6f791cc3 | 184 | TH1D* hAcceptance = fManager.GetAcceptanceCorrection(vtxbin); |
3b2bfb07 | 185 | if (fUseSecondary) hSecMap = fManager.GetSecMapCorrection(vtxbin); |
186 | if (fUseSecondary && !hSecMap) AliFatal("No secondary map!"); | |
187 | if (!hAcceptance) AliFatal("No acceptance!"); | |
dbe8d9ed | 188 | |
3b2bfb07 | 189 | if (hSecMap) aodHist->Divide(hSecMap); |
6f791cc3 | 190 | |
191 | for(Int_t nx = 1; nx <= aodHist->GetNbinsX(); nx++) { | |
3b2bfb07 | 192 | Float_t accCor = hAcceptance->GetBinContent(nx); |
6f791cc3 | 193 | |
194 | Bool_t etabinSeen = kFALSE; | |
195 | for(Int_t ny = 1; ny <= aodHist->GetNbinsY(); ny++) { | |
3b2bfb07 | 196 | Float_t aodValue = aodHist->GetBinContent(nx,ny); |
197 | Float_t secCor = hSecMap->GetBinContent(nx,ny); | |
198 | if (secCor > 0.5) etabinSeen = kTRUE; | |
199 | if (aodValue < 0.000001) { aodHist->SetBinContent(nx,ny, 0); continue; } | |
200 | if (accCor < 0.000001) accCor = 1; | |
201 | Float_t aodNew = aodValue / accCor ; | |
202 | aodHist->SetBinContent(nx,ny, aodNew); | |
3e478dba | 203 | Float_t aodErr = aodHist->GetBinError(nx,ny); |
204 | Float_t accErr = hAcceptance->GetBinError(nx); | |
3b2bfb07 | 205 | Float_t error = aodNew *TMath::Sqrt(TMath::Power(aodErr/aodValue,2) + |
206 | TMath::Power(accErr/accCor,2) ); | |
6f791cc3 | 207 | aodHist->SetBinError(nx,ny,error); |
208 | ||
209 | } | |
210 | //Filling underflow bin if we eta bin is in range | |
211 | if(etabinSeen) aodHist->SetBinContent(nx,0, 1.); | |
6f791cc3 | 212 | } |
213 | ||
214 | PostData(1,fList); | |
6f791cc3 | 215 | } |
216 | //____________________________________________________________________ | |
3e478dba | 217 | void AliCentralMultiplicityTask::Terminate(Option_t* /*option*/) |
218 | { | |
fb3430ac | 219 | // |
220 | // End of job | |
221 | // | |
222 | // Parameters: | |
223 | // option Not used | |
224 | // | |
6f791cc3 | 225 | } |
226 | //____________________________________________________________________ | |
227 | void | |
228 | AliCentralMultiplicityTask::Print(Option_t* /*option*/) const | |
229 | { | |
fb3430ac | 230 | // |
231 | // Print information | |
232 | // | |
233 | // Parameters: | |
234 | // option Not used | |
235 | // | |
6f791cc3 | 236 | } |
3e478dba | 237 | //==================================================================== |
6f791cc3 | 238 | AliCentralMultiplicityTask::Manager::Manager() : |
239 | fAcceptancePath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralAcceptance"), | |
240 | fSecMapPath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralSecMap"), | |
241 | fAcceptance(), | |
242 | fSecmap(), | |
243 | fAcceptanceName("centralacceptance"), | |
e58000b7 | 244 | fSecMapName("centralsecmap"), |
245 | fIsInit(kFALSE) | |
6f791cc3 | 246 | { |
fb3430ac | 247 | // |
248 | // Constructor | |
249 | // | |
6f791cc3 | 250 | } |
251 | //____________________________________________________________________ | |
3e478dba | 252 | AliCentralMultiplicityTask::Manager::Manager(const Manager& o) |
253 | :fAcceptancePath(o.fAcceptancePath), | |
254 | fSecMapPath(o.fSecMapPath), | |
255 | fAcceptance(o.fAcceptance), | |
256 | fSecmap(o.fSecmap), | |
257 | fAcceptanceName(o.fAcceptanceName), | |
e58000b7 | 258 | fSecMapName(o.fSecMapName), |
259 | fIsInit(o.fIsInit) | |
fb3430ac | 260 | { |
261 | // | |
262 | // Copy Constructor | |
263 | // | |
264 | } | |
3e478dba | 265 | //____________________________________________________________________ |
266 | AliCentralMultiplicityTask::Manager& | |
267 | AliCentralMultiplicityTask::Manager::operator=(const Manager& o) | |
268 | { | |
fb3430ac | 269 | // |
270 | // Assignment operator | |
271 | // | |
3e478dba | 272 | fAcceptancePath = o.fAcceptancePath; |
273 | fSecMapPath = o.fSecMapPath; | |
274 | fAcceptance = o.fAcceptance; | |
275 | fSecmap = o.fSecmap; | |
276 | fAcceptanceName = o.fAcceptanceName; | |
277 | fSecMapName = o.fSecMapName; | |
e58000b7 | 278 | fIsInit = o.fIsInit; |
3e478dba | 279 | return *this; |
280 | } | |
281 | ||
282 | //____________________________________________________________________ | |
283 | const char* | |
284 | AliCentralMultiplicityTask::Manager::GetFullFileName(UShort_t what, | |
285 | UShort_t sys, | |
286 | UShort_t sNN, | |
287 | Short_t field) const | |
288 | { | |
fb3430ac | 289 | // |
290 | // Get full path name to object file | |
291 | // | |
292 | // Parameters: | |
293 | // what What to get | |
294 | // sys Collision system | |
295 | // sNN Center of mass energy | |
296 | // field Magnetic field | |
297 | // | |
298 | // Return: | |
299 | // | |
300 | // | |
3e478dba | 301 | return Form("%s/%s", |
302 | what == 0 ? GetSecMapPath() : GetAcceptancePath(), | |
303 | GetFileName(what, sys, sNN, field)); | |
304 | } | |
305 | ||
306 | //____________________________________________________________________ | |
307 | const char* | |
308 | AliCentralMultiplicityTask::Manager::GetFileName(UShort_t what , | |
309 | UShort_t sys, | |
310 | UShort_t sNN, | |
311 | Short_t field) const | |
312 | { | |
fb3430ac | 313 | // |
314 | // Get the full path name | |
315 | // | |
316 | // Parameters: | |
317 | // what What to get | |
318 | // sys Collision system | |
319 | // sNN Center of mass energy | |
320 | // field Magnetic field | |
321 | // | |
322 | // Return: | |
323 | // | |
324 | // | |
3e478dba | 325 | // Must be static - otherwise the data may disappear on return from |
326 | // this member function | |
327 | static TString fname = ""; | |
6f791cc3 | 328 | |
dbe8d9ed | 329 | fname = ""; |
6f791cc3 | 330 | switch(what) { |
3e478dba | 331 | case 0: fname.Append(fSecMapName.Data()); break; |
332 | case 1: fname.Append(fAcceptanceName.Data()); break; | |
6f791cc3 | 333 | default: |
3e478dba | 334 | ::Error("GetFileName", |
335 | "Invalid indentifier %d for central object, must be 0 or 1!", what); | |
6f791cc3 | 336 | break; |
337 | } | |
338 | fname.Append(Form("_%s_%04dGeV_%c%1dkG.root", | |
339 | AliForwardUtil::CollisionSystemString(sys), | |
340 | sNN, (field < 0 ? 'm' : 'p'), TMath::Abs(field))); | |
341 | ||
342 | return fname.Data(); | |
6f791cc3 | 343 | } |
3e478dba | 344 | |
6f791cc3 | 345 | //____________________________________________________________________ |
3e478dba | 346 | TH2D* |
347 | AliCentralMultiplicityTask::Manager::GetSecMapCorrection(UShort_t vtxbin) const | |
348 | { | |
fb3430ac | 349 | // |
350 | // Get the secondary map | |
351 | // | |
352 | // Parameters: | |
353 | // vtxbin | |
354 | // | |
355 | // Return: | |
356 | // | |
357 | // | |
3e478dba | 358 | if (!fSecmap) { |
359 | ::Warning("GetSecMapCorrection","No secondary map defined"); | |
360 | return 0; | |
361 | } | |
362 | return fSecmap->GetCorrection(vtxbin); | |
363 | } | |
364 | //____________________________________________________________________ | |
365 | TH1D* | |
366 | AliCentralMultiplicityTask::Manager::GetAcceptanceCorrection(UShort_t vtxbin) | |
367 | const | |
368 | { | |
fb3430ac | 369 | // |
370 | // Get the acceptance correction | |
371 | // | |
372 | // Parameters: | |
373 | // vtxbin | |
374 | // | |
375 | // Return: | |
376 | // | |
377 | // | |
3e478dba | 378 | if (!fAcceptance) { |
379 | ::Warning("GetAcceptanceCorrection","No acceptance map defined"); | |
380 | return 0; | |
381 | } | |
382 | return fAcceptance->GetCorrection(vtxbin); | |
383 | } | |
384 | ||
385 | //____________________________________________________________________ | |
386 | void | |
387 | AliCentralMultiplicityTask::Manager::Init(UShort_t sys, | |
388 | UShort_t sNN, | |
389 | Short_t field) | |
390 | { | |
fb3430ac | 391 | // |
392 | // Initialize | |
393 | // | |
394 | // Parameters: | |
395 | // sys Collision system (1: pp, 2: PbPb) | |
396 | // sNN Center of mass energy per nucleon pair [GeV] | |
397 | // field Magnetic field [kG] | |
398 | // | |
e58000b7 | 399 | if(fIsInit) ::Warning("Init","Already initialised - overriding..."); |
400 | ||
6f791cc3 | 401 | TFile fsec(GetFullFileName(0,sys,sNN,field)); |
3e478dba | 402 | fSecmap = |
403 | dynamic_cast<AliCentralCorrSecondaryMap*>(fsec.Get(fSecMapName.Data())); | |
6f791cc3 | 404 | if(!fSecmap) { |
3e478dba | 405 | ::Error("Init", "no central Secondary Map found!") ; |
6f791cc3 | 406 | return; |
407 | } | |
408 | TFile facc(GetFullFileName(1,sys,sNN,field)); | |
3e478dba | 409 | fAcceptance = |
410 | dynamic_cast<AliCentralCorrAcceptance*>(facc.Get(fAcceptanceName.Data())); | |
411 | if(!fAcceptance) { | |
412 | ::Error("Init", "no central Acceptance found!") ; | |
413 | return; | |
414 | } | |
e58000b7 | 415 | |
416 | if(fSecmap && fAcceptance) { | |
417 | fIsInit = kTRUE; | |
418 | ::Info("Init", | |
419 | "Central Manager initialised for sys %d, energy %d, field %d",sys,sNN,field); | |
6f791cc3 | 420 | |
e58000b7 | 421 | } |
422 | ||
6f791cc3 | 423 | } |
424 | // | |
425 | // EOF | |
426 | // |