]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliCentralMultiplicityTask.cxx
remove buggy histos
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliCentralMultiplicityTask.cxx
CommitLineData
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"
52047b6f 16#include "AliAODForwardMult.h"
6f791cc3 17#include "AliForwardUtil.h"
18#include "AliLog.h"
19#include "AliAODHandler.h"
6f791cc3 20#include "AliAnalysisManager.h"
21#include "AliESDEvent.h"
22#include "AliMultiplicity.h"
23#include <TROOT.h>
2a276c75 24#include <TSystem.h>
6f791cc3 25#include <TFile.h>
3e478dba 26#include <TError.h>
28b4012a 27#include <TSystem.h>
6f791cc3 28#include <iostream>
29#include <iomanip>
30
31//====================================================================
32AliCentralMultiplicityTask::AliCentralMultiplicityTask(const char* name)
33 : AliAnalysisTaskSE(name),
52047b6f 34 fInspector("centralEventInspector"),
6f791cc3 35 fData(0),
36 fList(0),
37 fAODCentral(kFALSE),
3b2bfb07 38 fManager(),
e58000b7 39 fUseSecondary(true),
9453b19e 40 fUseAcceptance(true),
52047b6f 41 fFirstEventSeen(false),
28b4012a 42 fIvz(0),
43 fNClusterTracklet(0),
44 fClusterPerTracklet(0),
45 fNCluster(0),
9ecab72f 46 fNTracklet(0),
47 fEtaMin(0),
48 fEtaMax(0)
6f791cc3 49{
fb3430ac 50 //
51 // Constructor
52 //
6ab100ec 53 DGUARD(fDebug,0,"Named CTOR of AliCentralMultiplicityTask: %s", name);
6f791cc3 54 DefineOutput(1, TList::Class());
a59cbd24 55 fBranchNames =
56 "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
57 "SPDVertex.,PrimaryVertex.";
6f791cc3 58}
59//____________________________________________________________________
9c825779 60AliCentralMultiplicityTask::AliCentralMultiplicityTask()
61 : AliAnalysisTaskSE(),
52047b6f 62 fInspector(),
9c825779 63 fData(0),
64 fList(0),
65 fAODCentral(),
3b2bfb07 66 fManager(),
e58000b7 67 fUseSecondary(true),
9453b19e 68 fUseAcceptance(true),
52047b6f 69 fFirstEventSeen(false),
28b4012a 70 fIvz(0),
71 fNClusterTracklet(0),
72 fClusterPerTracklet(0),
73 fNCluster(0),
9ecab72f 74 fNTracklet(0),
75 fEtaMin(0),
76 fEtaMax(0)
9c825779 77{
fb3430ac 78 //
79 // Constructor
80 //
6ab100ec 81 DGUARD(fDebug,0,"Default CTOR of AliCentralMultiplicityTask");
9c825779 82}
83//____________________________________________________________________
84AliCentralMultiplicityTask::AliCentralMultiplicityTask(const AliCentralMultiplicityTask& o)
85 : AliAnalysisTaskSE(o),
52047b6f 86 fInspector(o.fInspector),
9c825779 87 fData(o.fData),
88 fList(o.fList),
89 fAODCentral(o.fAODCentral),
3b2bfb07 90 fManager(o.fManager),
e58000b7 91 fUseSecondary(o.fUseSecondary),
9453b19e 92 fUseAcceptance(o.fUseAcceptance),
52047b6f 93 fFirstEventSeen(o.fFirstEventSeen),
28b4012a 94 fIvz(0),
95 fNClusterTracklet(o.fNClusterTracklet),
96 fClusterPerTracklet(o.fClusterPerTracklet),
97 fNCluster(o.fNCluster),
9ecab72f 98 fNTracklet(o.fNTracklet),
99 fEtaMin(o.fEtaMin),
100 fEtaMax(o.fEtaMax)
9c825779 101{
fb3430ac 102 //
103 // Copy constructor
104 //
6ab100ec 105 DGUARD(fDebug,0,"COPY CTOR of AliCentralMultiplicityTask");
106
9c825779 107}
108//____________________________________________________________________
109AliCentralMultiplicityTask&
110AliCentralMultiplicityTask::operator=(const AliCentralMultiplicityTask& o)
111{
fb3430ac 112 //
113 // Assignment operator
114 //
6ab100ec 115 DGUARD(fDebug,3,"Assignment of AliCentralMultiplicityTask");
d015ecfe 116 if (&o == this) return *this;
28b4012a 117 fInspector = o.fInspector;
118 fData = o.fData;
119 fList = o.fList;
120 fAODCentral = o.fAODCentral;
121 fManager = o.fManager;
122 fUseSecondary = o.fUseSecondary;
123 fUseAcceptance = o.fUseAcceptance;
124 fFirstEventSeen = o.fFirstEventSeen;
125 fIvz = 0;
126 fNClusterTracklet = o.fNClusterTracklet;
127 fClusterPerTracklet= o.fClusterPerTracklet;
128 fNCluster = o.fNCluster;
129 fNTracklet = o.fNTracklet;
9ecab72f 130 fEtaMin = o.fEtaMin;
131 fEtaMax = o.fEtaMax;
9c825779 132 return *this;
133}
2a276c75 134//____________________________________________________________________
135Bool_t
136AliCentralMultiplicityTask::Configure(const char* macro)
137{
138 // --- Configure the task ------------------------------------------
139 TString macroPath(gROOT->GetMacroPath());
140 if (!macroPath.Contains("$(ALICE_ROOT)/PWGLF/FORWARD/analysis2")) {
141 macroPath.Append(":$(ALICE_ROOT)/PWGLF/FORWARD/analysis2");
142 gROOT->SetMacroPath(macroPath);
143 }
144 const char* config = gSystem->Which(gROOT->GetMacroPath(),macro);
145 if (!config) {
146 AliWarningF("%s not found in %s", macro, gROOT->GetMacroPath());
147 return false;
148 }
149
150 AliInfoF("Loading configuration of '%s' from %s", ClassName(), config);
151 gROOT->Macro(Form("%s((AliCentralMultiplicityTask*)%p)", config, this));
152 delete config;
153
154 return true;
155}
156
9c825779 157//____________________________________________________________________
3e478dba 158void AliCentralMultiplicityTask::UserCreateOutputObjects()
159{
fb3430ac 160 //
161 // Create output objects
162 //
163 //
6ab100ec 164 DGUARD(fDebug,1,"Create user output in AliCentralMultiplicityTask");
6f791cc3 165
166 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
167 AliAODHandler* ah =
168 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
169 if (!ah) AliFatal("No AOD output handler set in analysis manager");
170
171
172 TObject* obj = &fAODCentral;
173 ah->AddBranch("AliAODCentralMult", &obj);
614f9452 174
175
52047b6f 176
6f791cc3 177 fList = new TList();
9d05ffeb 178 fList->SetOwner();
52047b6f 179
180 fInspector.DefineOutput(fList);
181
182 PostData(1,fList);
183}
184
185//____________________________________________________________________
186AliESDEvent*
187AliCentralMultiplicityTask::GetESDEvent()
188{
189 //
190 // Get the ESD event. IF this is the first event, initialise
191 //
6ab100ec 192 DGUARD(fDebug,1,"Get ESD event in AliCentralMultiplicityTask");
6ff251d8 193 if (IsZombie()) return 0;
52047b6f 194 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
195 if (!esd) {
196 AliWarning("No ESD event found for input event");
197 return 0;
198 }
28b4012a 199
200 // IF we've read the first event already, just return the event
52047b6f 201 if (fFirstEventSeen) return esd;
6f791cc3 202
28b4012a 203 // Read the details of the rung
52047b6f 204 fInspector.ReadRunDetails(esd);
28b4012a 205
206 // If we weren't initialised before (i.e., in the setup), do so now.
207 if (!GetManager().IsInit()) {
208 GetManager().Init(fInspector.GetCollisionSystem(),
209 fInspector.GetEnergy(),
210 fInspector.GetField());
6ff251d8 211 //AliInfo("Manager of corrections in AliCentralMultiplicityTask init");
212 }
213 Bool_t ok = true;
214 if (!GetManager().HasSecondaryCorrection()) {
215 ok = false;
216 AliError("No secondary correction defined!");
217 }
218 if (!GetManager().HasAcceptanceCorrection()) {
219 ok = false;
220 AliError("No acceptance correction defined!");
221 }
222 // If the corrections are not seen, make this a zombie, and prevent
223 // further execution of this task.
224 if (!ok) {
225 AliError("Missing corrections, make this a zombie");
226 SetZombie(true);
227 esd = 0;
228 fFirstEventSeen = true;
229 return esd;
28b4012a 230 }
231
232 // Check for existence and get secondary map
52047b6f 233 AliCentralCorrSecondaryMap* secMap = GetManager().GetSecMap();
52047b6f 234 const TAxis& vaxis = secMap->GetVertexAxis();
235
9ecab72f 236 FindEtaLimits();
237
28b4012a 238 fNClusterTracklet = new TH2D("nClusterVsnTracklet",
9ecab72f 239 "Total number of cluster vs number of tracklets",
2b556440 240 100, 0, 10000, 100, 0, 10000);
28b4012a 241 fNClusterTracklet->SetDirectory(0);
242 fNClusterTracklet->SetXTitle("# of free clusters");
243 fNClusterTracklet->SetYTitle("# of tracklets");
244 fNClusterTracklet->SetStats(0);
245 fList->Add(fNClusterTracklet);
246
247 Int_t nEta = 80;
248 Double_t lEta = 2;
249 fClusterPerTracklet = new TH2D("clusterPerTracklet",
250 "N_{free cluster}/N_{tracklet} vs. #eta",
251 nEta,-lEta,lEta, 101, -.05, 10.05);
252 fClusterPerTracklet->SetDirectory(0);
253 fClusterPerTracklet->SetXTitle("#eta");
254 fClusterPerTracklet->SetYTitle("N_{free cluster}/N_{tracklet}");
255 fClusterPerTracklet->SetStats(0);
256 fList->Add(fClusterPerTracklet);
257
258 // Cache histograms
259 fNCluster = new TH1D("cacheCluster", "", nEta,-lEta,lEta);
260 fNCluster->SetDirectory(0);
261 fNCluster->Sumw2();
262
263 fNTracklet = new TH1D("cacheTracklet", "", nEta,-lEta,lEta);
264 fNTracklet->SetDirectory(0);
265 fNTracklet->Sumw2();
266
267 // Initialize the inspecto
52047b6f 268 fInspector.Init(vaxis);
52047b6f 269 fFirstEventSeen = kTRUE;
28b4012a 270
271 // Print some information
52047b6f 272 Print();
273
274 return esd;
6f791cc3 275}
52047b6f 276//____________________________________________________________________
277void
278AliCentralMultiplicityTask::MarkEventForStore() const
279{
280 // Make sure the AOD tree is filled
6ab100ec 281 DGUARD(fDebug,1,"Mark AOD event for store in AliCentralMultiplicityTask");
52047b6f 282 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
283 AliAODHandler* ah =
284 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
285 if (!ah)
286 AliFatal("No AOD output handler set in analysis manager");
287
288 ah->SetFillAOD(kTRUE);
289}
290
9ecab72f 291//____________________________________________________________________
292void AliCentralMultiplicityTask::FindEtaLimits()
293{
6ab100ec 294 // Find our pseudo-rapidity limits
295 //
296 // Uses the secondary map to do so.
297 DGUARD(fDebug,1,"Find eta limits in AliCentralMultiplicityTask");
9ecab72f 298 AliCentralCorrSecondaryMap* secMap = GetManager().GetSecMap();
4bcdcbc1 299
9ecab72f 300 const TAxis& vaxis = secMap->GetVertexAxis();
614f9452 301
9ecab72f 302 fEtaMin.Set(vaxis.GetNbins());
303 fEtaMax.Set(vaxis.GetNbins());
614f9452 304
305 TList* hits = new TList;
306 hits->SetOwner();
307 hits->SetName("hitMaps");
308 fList->Add(hits);
309
9ecab72f 310 TList* secs = new TList;
311 secs->SetOwner();
312 secs->SetName("secondaryMaps");
313 fList->Add(secs);
6ab100ec 314 unsigned short s = 1;
614f9452 315 TH2D* hCoverage = new TH2D("coverage", "#eta coverage per v_{z}",
6ab100ec 316 secMap->GetCorrection(s)->GetXaxis()->GetNbins(),
317 secMap->GetCorrection(s)->GetXaxis()->GetXmin(),
318 secMap->GetCorrection(s)->GetXaxis()->GetXmax(),
614f9452 319 vaxis.GetNbins(),vaxis.GetXmin(),vaxis.GetXmax());
320 hCoverage->SetDirectory(0);
321 hCoverage->SetXTitle("#eta");
322 hCoverage->SetYTitle("v_{z} [cm]");
323 hCoverage->SetZTitle("n_{bins}");
324 fList->Add(hCoverage);
9ecab72f 325
4077f3e8 326 fAODCentral.Init(*(secMap->GetCorrection(s)->GetXaxis()));
327
9ecab72f 328 for (Int_t v = 1; v <= vaxis.GetNbins(); v++) {
329 TH2D* corr = secMap->GetCorrection(UShort_t(v));
330 TH1D* proj = corr->ProjectionX(Form("secCor%02d", v));
331 proj->Scale(1. / corr->GetNbinsY());
332 proj->SetTitle(Form("Projection of secondary correction "
333 "for %+5.1f<v_{z}<%+5.1f",
334 vaxis.GetBinLowEdge(v), vaxis.GetBinUpEdge(v)));
335 proj->SetYTitle("#LT 2^{nd} correction#GT");
336 proj->SetDirectory(0);
337 proj->SetMarkerStyle(20);
338 proj->SetMarkerColor(kBlue+1);
339 secs->Add(proj);
614f9452 340
341 TH2D* obg = static_cast<TH2D*>(corr->Clone(Form("secCor2DFiducial%02d",v)));
342 obg->SetDirectory(0);
343 secs->Add(obg);
344
9ecab72f 345 TH1D* after = static_cast<TH1D*>(proj->Clone(Form("secCorFiducial%02d",v)));
346 after->SetDirectory(0);
347 after->SetMarkerColor(kRed+1);
348 secs->Add(after);
614f9452 349
350 TH2D* data = static_cast<TH2D*>(corr->Clone(Form("hitMap%02d",v)));
351 //d->SetTitle(Form("hitMap%02d",v));
352 data->SetTitle(Form("d^{2}N/d#eta d#phi "
353 "for %+5.1f<v_{z}<%+5.1f",
354 vaxis.GetBinLowEdge(v), vaxis.GetBinUpEdge(v)));
355 data->GetZaxis()->SetTitle("");
356 data->SetMarkerColor(kBlack);
357 data->SetMarkerStyle(1);
358 hits->Add(data);
359
360 TH1D* hAcceptance = fManager.GetAcceptanceCorrection(v);
361 TH1D* accClone = static_cast<TH1D*>(hAcceptance->Clone(Form("acceptance%02d",v)));
362 secs->Add(accClone);
363
b4db5d3b 364 // Double_t prev = 0;
9ecab72f 365 for (Int_t e = 1; e <= proj->GetNbinsX(); e++) {
366 Double_t c = proj->GetBinContent(e);
614f9452 367 if (c > .5 /*&& TMath::Abs(c - prev) < .1*c*/) {
9ecab72f 368 fEtaMin[v-1] = e;
369 break;
370 }
b4db5d3b 371 // prev = c;
9ecab72f 372 after->SetBinContent(e, 0);
373 after->SetBinError(e, 0);
c6523308 374 for(Int_t nn =1; nn <=obg->GetNbinsY();nn++)
375 obg->SetBinContent(e,nn,0);
376
9ecab72f 377 }
378 for (Int_t e = proj->GetNbinsX(); e >= 1; e--) {
379 Double_t c = proj->GetBinContent(e);
614f9452 380 if (c > .5 /*&& TMath::Abs(c - prev) < .1*c*/) {
9ecab72f 381 fEtaMax[v-1] = e;
382 break;
383 }
b4db5d3b 384 // prev = c;
9ecab72f 385 after->SetBinContent(e, 0);
386 after->SetBinError(e, 0);
c6523308 387 for(Int_t nn =1; nn <=obg->GetNbinsY();nn++)
388 obg->SetBinContent(e,nn,0);
389
9ecab72f 390 }
614f9452 391
392 for (Int_t nn = fEtaMin[v-1]; nn<=fEtaMax[v-1]; nn++) {
393 hCoverage->SetBinContent(nn,v,1);
394 }
395
9ecab72f 396 }
397}
398
6f791cc3 399//____________________________________________________________________
3e478dba 400void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/)
401{
fb3430ac 402 //
403 // Process each event
404 //
405 // Parameters:
406 // option Not used
407 //
6ab100ec 408 DGUARD(fDebug,1,"Process event in AliCentralMultiplicityTask");
c4a7e081 409 fAODCentral.Clear("");
52047b6f 410 fIvz = 0;
411
412 AliESDEvent* esd = GetESDEvent();
6ff251d8 413 if (!esd) return;
414
52047b6f 415 Bool_t lowFlux = kFALSE;
416 UInt_t triggers = 0;
417 UShort_t ivz = 0;
418 Double_t vz = 0;
419 Double_t cent = -1;
420 UShort_t nClusters = 0;
421 UInt_t found = fInspector.Process(esd, triggers, lowFlux,
422 ivz, vz, cent, nClusters);
423
424 // No event or no trigger
425 if (found & AliFMDEventInspector::kNoEvent) return;
426 if (found & AliFMDEventInspector::kNoTriggers) return;
6f791cc3 427
428 // Make sure AOD is filled
52047b6f 429 MarkEventForStore();
430
431 if (found == AliFMDEventInspector::kNoSPD) return;
432 if (found == AliFMDEventInspector::kNoVertex) return;
433 if (triggers & AliAODForwardMult::kPileUp) return;
434 if (found == AliFMDEventInspector::kBadVertex) return; // Out of range
6f791cc3 435
436 //Doing analysis
52047b6f 437 fIvz = ivz;
6f791cc3 438 const AliMultiplicity* spdmult = esd->GetMultiplicity();
52047b6f 439
440 TH2D& aodHist = fAODCentral.GetHistogram();
441
442 ProcessESD(aodHist, spdmult);
443 CorrectData(aodHist, ivz);
614f9452 444 //Producing hit maps
445 TList* hitList = static_cast<TList*>(fList->FindObject("hitMaps"));
446 TH2D* data = 0;
447 if(hitList)
448 data = static_cast<TH2D*>(hitList->At(ivz-1));
449 if(data)
450 data->Add(&aodHist);
451
52047b6f 452 PostData(1,fList);
453}
454//____________________________________________________________________
455void
456AliCentralMultiplicityTask::ProcessESD(TH2D& aodHist,
457 const AliMultiplicity* spdmult) const
458{
6ab100ec 459 DGUARD(fDebug,1,"Process the ESD in AliCentralMultiplicityTask");
28b4012a 460 fNTracklet->Reset();
461 fNCluster->Reset();
462
6f791cc3 463 //Filling clusters in layer 1 used for tracklets...
28b4012a 464 for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++) {
465 Double_t eta = spdmult->GetEta(j);
466 fNTracklet->Fill(eta);
467 aodHist.Fill(eta,spdmult->GetPhi(j));
468 }
3e478dba 469
6f791cc3 470 //...and then the unused ones in layer 1
28b4012a 471 for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++) {
472 Double_t eta = -TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.));
473 fNCluster->Fill(eta);
474 aodHist.Fill(eta, spdmult->GetPhiSingle(j));
475 }
476 fNClusterTracklet->Fill(fNCluster->GetEntries(),
477 fNTracklet->GetEntries());
478
479 fNCluster->Divide(fNTracklet);
480 for (Int_t j = 1; j <= fNCluster->GetNbinsX(); j++)
481 fClusterPerTracklet->Fill(fNCluster->GetXaxis()->GetBinCenter(j),
482 fNCluster->GetBinContent(j));
483
52047b6f 484}
485
486//____________________________________________________________________
487void
488AliCentralMultiplicityTask::CorrectData(TH2D& aodHist, UShort_t vtxbin) const
489{
3e478dba 490 // Corrections
6ab100ec 491 DGUARD(fDebug,1,"Correct data in AliCentralMultiplicityTask");
6f791cc3 492 TH1D* hAcceptance = fManager.GetAcceptanceCorrection(vtxbin);
9453b19e 493 TH2D* hSecMap = fManager.GetSecMapCorrection(vtxbin);
12fffad7 494
9453b19e 495 if (!hSecMap) AliFatal("No secondary map!");
496 if (!hAcceptance) AliFatal("No acceptance!");
dbe8d9ed 497
52047b6f 498 if (fUseSecondary && hSecMap) aodHist.Divide(hSecMap);
6f791cc3 499
52047b6f 500 for(Int_t nx = 1; nx <= aodHist.GetNbinsX(); nx++) {
3b2bfb07 501 Float_t accCor = hAcceptance->GetBinContent(nx);
9453b19e 502 Float_t accErr = hAcceptance->GetBinError(nx);
9ecab72f 503
504 Bool_t fiducial = true;
505 if (nx < fEtaMin[vtxbin-1] || nx > fEtaMax[vtxbin-1])
506 fiducial = false;
d7d87bc9 507 // Bool_t etabinSeen = kFALSE;
52047b6f 508 for(Int_t ny = 1; ny <= aodHist.GetNbinsY(); ny++) {
9ecab72f 509#if 1
510 if (!fiducial) {
511 aodHist.SetBinContent(nx, ny, 0);
512 aodHist.SetBinError(nx, ny, 0);
513 continue;
514 }
515#endif
9453b19e 516 // Get currrent value
52047b6f 517 Float_t aodValue = aodHist.GetBinContent(nx,ny);
518 Float_t aodErr = aodHist.GetBinError(nx,ny);
9453b19e 519
9ecab72f 520#if 0 // This is done once in the FindEtaBins function
9453b19e 521 // Set underflow bin
12fffad7 522 Float_t secCor = 0;
52047b6f 523 if(hSecMap) secCor = hSecMap->GetBinContent(nx,ny);
3b2bfb07 524 if (secCor > 0.5) etabinSeen = kTRUE;
9ecab72f 525#endif
52047b6f 526 if (aodValue < 0.000001) {
527 aodHist.SetBinContent(nx,ny, 0);
9ecab72f 528 aodHist.SetBinError(nx,ny, 0);
52047b6f 529 continue;
530 }
9453b19e 531 if (!fUseAcceptance) continue;
532
533 // Acceptance correction
3b2bfb07 534 if (accCor < 0.000001) accCor = 1;
535 Float_t aodNew = aodValue / accCor ;
12fffad7 536 Float_t error = aodNew*TMath::Sqrt(TMath::Power(aodErr/aodValue,2) +
537 TMath::Power(accErr/accCor,2) );
52047b6f 538 aodHist.SetBinContent(nx,ny, aodNew);
12fffad7 539 //test
52047b6f 540 aodHist.SetBinError(nx,ny,error);
541 aodHist.SetBinError(nx,ny,aodErr);
6f791cc3 542 }
543 //Filling underflow bin if we eta bin is in range
9ecab72f 544 if (fiducial) aodHist.SetBinContent(nx,0, 1.);
545 // if (etabinSeen) aodHist.SetBinContent(nx,0, 1.);
6f791cc3 546 }
6f791cc3 547}
52047b6f 548
6f791cc3 549//____________________________________________________________________
3e478dba 550void AliCentralMultiplicityTask::Terminate(Option_t* /*option*/)
551{
fb3430ac 552 //
553 // End of job
554 //
555 // Parameters:
556 // option Not used
557 //
6ab100ec 558 DGUARD(fDebug,1,"Process merged output in AliCentralMultiplicityTask");
6f791cc3 559}
560//____________________________________________________________________
561void
52047b6f 562AliCentralMultiplicityTask::Print(Option_t* option) const
6f791cc3 563{
fb3430ac 564 //
565 // Print information
566 //
567 // Parameters:
568 // option Not used
569 //
52047b6f 570 std::cout << ClassName() << ": " << GetName() << "\n"
571 << std::boolalpha
572 << " Use secondary correction: " << fUseSecondary << '\n'
573 << " Use acceptance correction: " << fUseAcceptance << '\n'
574 << " Off-line trigger mask: 0x"
575 << std::hex << std::setfill('0')
576 << std::setw (8) << fOfflineTriggerMask
577 << std::dec << std::setfill (' ')
578 << std::noboolalpha << std::endl;
9ecab72f 579 AliCentralCorrSecondaryMap* secMap = GetManager().GetSecMap();
580 if (secMap) {
581 const TAxis& vaxis = secMap->GetVertexAxis();
582 std::cout << " Eta ranges:\n"
583 << " Vertex | Eta bins\n"
584 << " bin range | \n"
585 << " ----------------+-----------" << std::endl;
586 for (Int_t v = 1; v <= vaxis.GetNbins(); v++) {
587 std::cout << " " << std::setw(2) << v << " "
588 << std::setw(5) << vaxis.GetBinLowEdge(v) << "-"
589 << std::setw(5) << vaxis.GetBinUpEdge(v) << " | "
590 << std::setw(3) << fEtaMin[v-1] << "-"
591 << std::setw(3) << fEtaMax[v-1] << std::endl;
592 }
593 }
594
52047b6f 595 gROOT->IncreaseDirLevel();
596 fManager.Print(option);
597 fInspector.Print(option);
598 gROOT->DecreaseDirLevel();
599
6f791cc3 600}
3e478dba 601//====================================================================
6f791cc3 602AliCentralMultiplicityTask::Manager::Manager() :
bd6f5206 603 fAcceptancePath("$ALICE_ROOT/PWGLF/FORWARD/corrections/CentralAcceptance"),
604 fSecMapPath("$ALICE_ROOT/PWGLF/FORWARD/corrections/CentralSecMap"),
6f791cc3 605 fAcceptance(),
606 fSecmap(),
607 fAcceptanceName("centralacceptance"),
e58000b7 608 fSecMapName("centralsecmap"),
609 fIsInit(kFALSE)
6f791cc3 610{
fb3430ac 611 //
612 // Constructor
613 //
6f791cc3 614}
615//____________________________________________________________________
3e478dba 616AliCentralMultiplicityTask::Manager::Manager(const Manager& o)
617 :fAcceptancePath(o.fAcceptancePath),
618 fSecMapPath(o.fSecMapPath),
619 fAcceptance(o.fAcceptance),
620 fSecmap(o.fSecmap),
621 fAcceptanceName(o.fAcceptanceName),
e58000b7 622 fSecMapName(o.fSecMapName),
623 fIsInit(o.fIsInit)
fb3430ac 624{
625 //
626 // Copy Constructor
627 //
628}
3e478dba 629//____________________________________________________________________
630AliCentralMultiplicityTask::Manager&
631AliCentralMultiplicityTask::Manager::operator=(const Manager& o)
632{
fb3430ac 633 //
634 // Assignment operator
635 //
d015ecfe 636 if (&o == this) return *this;
3e478dba 637 fAcceptancePath = o.fAcceptancePath;
638 fSecMapPath = o.fSecMapPath;
639 fAcceptance = o.fAcceptance;
640 fSecmap = o.fSecmap;
641 fAcceptanceName = o.fAcceptanceName;
642 fSecMapName = o.fSecMapName;
e58000b7 643 fIsInit = o.fIsInit;
3e478dba 644 return *this;
645}
646
647//____________________________________________________________________
648const char*
649AliCentralMultiplicityTask::Manager::GetFullFileName(UShort_t what,
650 UShort_t sys,
651 UShort_t sNN,
652 Short_t field) const
653{
fb3430ac 654 //
655 // Get full path name to object file
656 //
657 // Parameters:
658 // what What to get
659 // sys Collision system
660 // sNN Center of mass energy
661 // field Magnetic field
662 //
663 // Return:
664 //
665 //
3e478dba 666 return Form("%s/%s",
667 what == 0 ? GetSecMapPath() : GetAcceptancePath(),
668 GetFileName(what, sys, sNN, field));
669}
670
671//____________________________________________________________________
672const char*
673AliCentralMultiplicityTask::Manager::GetFileName(UShort_t what ,
674 UShort_t sys,
675 UShort_t sNN,
676 Short_t field) const
677{
fb3430ac 678 //
679 // Get the full path name
680 //
681 // Parameters:
682 // what What to get
683 // sys Collision system
684 // sNN Center of mass energy
685 // field Magnetic field
686 //
687 // Return:
688 //
689 //
3e478dba 690 // Must be static - otherwise the data may disappear on return from
691 // this member function
692 static TString fname = "";
6f791cc3 693
694 switch(what) {
28b4012a 695 case 0: fname = fSecMapName; break;
696 case 1: fname = fAcceptanceName; break;
6f791cc3 697 default:
3e478dba 698 ::Error("GetFileName",
699 "Invalid indentifier %d for central object, must be 0 or 1!", what);
6f791cc3 700 break;
701 }
28b4012a 702 fname.Append(Form("_%s_%04dGeV_%c%1dkG.root",
6f791cc3 703 AliForwardUtil::CollisionSystemString(sys),
704 sNN, (field < 0 ? 'm' : 'p'), TMath::Abs(field)));
705
706 return fname.Data();
6f791cc3 707}
3e478dba 708
6f791cc3 709//____________________________________________________________________
3e478dba 710TH2D*
711AliCentralMultiplicityTask::Manager::GetSecMapCorrection(UShort_t vtxbin) const
712{
fb3430ac 713 //
714 // Get the secondary map
715 //
716 // Parameters:
717 // vtxbin
718 //
719 // Return:
720 //
721 //
3e478dba 722 if (!fSecmap) {
723 ::Warning("GetSecMapCorrection","No secondary map defined");
724 return 0;
725 }
726 return fSecmap->GetCorrection(vtxbin);
727}
728//____________________________________________________________________
729TH1D*
730AliCentralMultiplicityTask::Manager::GetAcceptanceCorrection(UShort_t vtxbin)
731 const
732{
fb3430ac 733 //
734 // Get the acceptance correction
735 //
736 // Parameters:
737 // vtxbin
738 //
739 // Return:
740 //
741 //
3e478dba 742 if (!fAcceptance) {
743 ::Warning("GetAcceptanceCorrection","No acceptance map defined");
744 return 0;
745 }
746 return fAcceptance->GetCorrection(vtxbin);
747}
748
749//____________________________________________________________________
750void
751AliCentralMultiplicityTask::Manager::Init(UShort_t sys,
752 UShort_t sNN,
753 Short_t field)
754{
fb3430ac 755 //
756 // Initialize
757 //
758 // Parameters:
0151a6c6 759 // sys Collision system (1: pp, 2: PbPb, 3: pPb)
fb3430ac 760 // sNN Center of mass energy per nucleon pair [GeV]
761 // field Magnetic field [kG]
762 //
e58000b7 763 if(fIsInit) ::Warning("Init","Already initialised - overriding...");
764
6f791cc3 765 TFile fsec(GetFullFileName(0,sys,sNN,field));
3e478dba 766 fSecmap =
767 dynamic_cast<AliCentralCorrSecondaryMap*>(fsec.Get(fSecMapName.Data()));
6f791cc3 768 if(!fSecmap) {
3e478dba 769 ::Error("Init", "no central Secondary Map found!") ;
6f791cc3 770 return;
771 }
772 TFile facc(GetFullFileName(1,sys,sNN,field));
3e478dba 773 fAcceptance =
774 dynamic_cast<AliCentralCorrAcceptance*>(facc.Get(fAcceptanceName.Data()));
775 if(!fAcceptance) {
776 ::Error("Init", "no central Acceptance found!") ;
777 return;
778 }
e58000b7 779
780 if(fSecmap && fAcceptance) {
781 fIsInit = kTRUE;
782 ::Info("Init",
52047b6f 783 "Central Manager initialised for %s, energy %dGeV, field %dkG",
0151a6c6 784 sys == 1 ? "pp" : sys == 2 ? "PbPb" : sys == 3 ? "pPb" : "unknown", sNN,field);
52047b6f 785 }
786}
28b4012a 787//____________________________________________________________________
788Bool_t
789AliCentralMultiplicityTask::Manager::WriteFile(UShort_t what,
790 UShort_t sys,
791 UShort_t sNN,
792 Short_t fld,
793 TObject* obj,
794 Bool_t full) const
795{
796 //
797 // Write correction output to (a temporary) file
798 //
799 // Parameters:
800 // What What to write
0151a6c6 801 // sys Collision system (1: pp, 2: PbPb, 3: pPb)
28b4012a 802 // sNN Center of mass energy per nucleon (GeV)
803 // fld Field (kG)
804 // obj Object to write
805 // full if true, write to full path, otherwise locally
806 //
807 // Return:
808 // true on success.
809 TString ofName;
810 if (!full)
811 ofName = GetFileName(what, sys, sNN, fld);
812 else
813 ofName = GetFullFileName(what, sys, sNN, fld);
814 if (ofName.IsNull()) {
815 AliErrorGeneral("Manager",Form("Unknown object type %d", what));
816 return false;
817 }
818 TFile* output = TFile::Open(ofName, "RECREATE");
819 if (!output) {
820 AliErrorGeneral("Manager",Form("Failed to open file %s", ofName.Data()));
821 return false;
822 }
823
824 TString oName(GetObjectName(what));
825 Int_t ret = obj->Write(oName);
826 if (ret <= 0) {
827 AliErrorGeneral("Manager",Form("Failed to write %p to %s/%s (%d)",
828 obj, ofName.Data(), oName.Data(), ret));
829 return false;
830 }
831
832 ret = output->Write();
833 if (ret < 0) {
834 AliErrorGeneral("Manager",
835 Form("Failed to write %s to disk (%d)", ofName.Data(),ret));
836 return false;
837 }
838 output->ls();
839 output->Close();
840
841 TString cName(obj->IsA()->GetName());
842 AliInfoGeneral("Manager",
843 Form("Wrote %s object %s to %s\n",
844 cName.Data(),oName.Data(), ofName.Data()));
845 if (!full) {
846 TString dName(GetFileDir(what));
847 AliInfoGeneral("Manager",
848 Form("%s should be copied to %s\n"
849 "Do for example\n\t"
bd6f5206 850 "aliroot $ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/"
28b4012a 851 "MoveCorrections.C\\(%d\\)\nor\n\t"
852 "cp %s %s/",
853 ofName.Data(),dName.Data(),
854 what, ofName.Data(),
855 gSystem->ExpandPathName(dName.Data())));
856
857
858 }
859 return true;
860}
6f791cc3 861
52047b6f 862//____________________________________________________________________
863void
864AliCentralMultiplicityTask::Manager::Print(Option_t* option) const
865{
28b4012a 866 //
867 // Print information to standard output
868 //
52047b6f 869 std::cout << " AliCentralMultiplicityTask::Manager\n"
870 << std::boolalpha
871 << " Initialized: " << fIsInit << '\n'
872 << " Acceptance path: " << fAcceptancePath << '\n'
873 << " Acceptance name: " << fAcceptanceName << '\n'
874 << " Acceptance: " << fAcceptance << '\n'
875 << " Secondary path: " << fSecMapPath << '\n'
876 << " Secondary name: " << fSecMapName << '\n'
877 << " Secondary map: " << fSecmap
878 << std::noboolalpha << std::endl;
879 if (fAcceptance) fAcceptance->Print(option);
880 if (fSecmap) fSecmap->Print(option);
6f791cc3 881}
52047b6f 882
6f791cc3 883//
884// EOF
885//