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