]>
Commit | Line | Data |
---|---|---|
ce85db45 | 1 | //==================================================================== |
2 | #include "AliBasedNdetaTask.h" | |
3 | #include <TMath.h> | |
4 | #include <TH2D.h> | |
5 | #include <TH1D.h> | |
6 | #include <THStack.h> | |
7 | #include <TList.h> | |
e58000b7 | 8 | #include <TParameter.h> |
ce85db45 | 9 | #include <AliAnalysisManager.h> |
10 | #include <AliAODEvent.h> | |
11 | #include <AliAODHandler.h> | |
12 | #include <AliAODInputHandler.h> | |
13 | #include "AliForwardUtil.h" | |
14 | #include "AliAODForwardMult.h" | |
3846ec25 | 15 | #include <TFile.h> |
ce85db45 | 16 | |
17 | //____________________________________________________________________ | |
18 | AliBasedNdetaTask::AliBasedNdetaTask() | |
19 | : AliAnalysisTaskSE(), | |
ce85db45 | 20 | fSums(0), // Container of sums |
e1f47419 | 21 | fOutput(0), // Container of output |
ce85db45 | 22 | fVtxMin(0), // Minimum v_z |
23 | fVtxMax(0), // Maximum v_z | |
24 | fTriggerMask(0), // Trigger mask | |
25 | fRebin(0), // Rebinning factor | |
26 | fCutEdges(false), | |
27 | fSymmetrice(true), | |
e58000b7 | 28 | fCorrEmpty(true), |
29 | fTriggerEff(1), | |
3846ec25 | 30 | fShapeCorr(0), |
e1f47419 | 31 | fListOfCentralities(0), |
e1f47419 | 32 | fSNNString(0), |
33 | fSysString(0), | |
e308a636 | 34 | fCent(0), |
ffca499d | 35 | fCentAxis(0), |
0be6c8cd | 36 | fNormalizationScheme(kFull), |
37 | fSchemeString(0), | |
38 | fTriggerString(0) | |
fb3430ac | 39 | { |
40 | // | |
41 | // Constructor | |
42 | // | |
43 | } | |
ce85db45 | 44 | |
45 | //____________________________________________________________________ | |
46 | AliBasedNdetaTask::AliBasedNdetaTask(const char* name) | |
47 | : AliAnalysisTaskSE(name), | |
ce85db45 | 48 | fSums(0), // Container of sums |
e1f47419 | 49 | fOutput(0), // Container of output |
ce85db45 | 50 | fVtxMin(-10), // Minimum v_z |
51 | fVtxMax(10), // Maximum v_z | |
52 | fTriggerMask(AliAODForwardMult::kInel), | |
53 | fRebin(5), // Rebinning factor | |
54 | fCutEdges(false), | |
55 | fSymmetrice(true), | |
e58000b7 | 56 | fCorrEmpty(true), |
57 | fTriggerEff(1), | |
3846ec25 | 58 | fShapeCorr(0), |
e1f47419 | 59 | fListOfCentralities(0), |
e1f47419 | 60 | fSNNString(0), |
61 | fSysString(0), | |
e308a636 | 62 | fCent(0), |
ffca499d | 63 | fCentAxis(0), |
0be6c8cd | 64 | fNormalizationScheme(kFull), |
65 | fSchemeString(0), | |
66 | fTriggerString(0) | |
ce85db45 | 67 | { |
fb3430ac | 68 | // |
69 | // Constructor | |
70 | // | |
e308a636 | 71 | fListOfCentralities = new TObjArray(1); |
0be6c8cd | 72 | |
73 | // Set the normalisation scheme | |
74 | SetNormalizationScheme(kFull); | |
75 | ||
76 | // Set the trigger mask | |
77 | SetTriggerMask(AliAODForwardMult::kInel); | |
fb3430ac | 78 | |
ce85db45 | 79 | // Output slot #1 writes into a TH1 container |
80 | DefineOutput(1, TList::Class()); | |
81 | DefineOutput(2, TList::Class()); | |
82 | } | |
83 | ||
84 | //____________________________________________________________________ | |
85 | AliBasedNdetaTask::AliBasedNdetaTask(const AliBasedNdetaTask& o) | |
86 | : AliAnalysisTaskSE(o), | |
ce85db45 | 87 | fSums(o.fSums), // TList* - Container of sums |
e1f47419 | 88 | fOutput(o.fOutput), // Container of output |
ce85db45 | 89 | fVtxMin(o.fVtxMin), // Double_t - Minimum v_z |
90 | fVtxMax(o.fVtxMax), // Double_t - Maximum v_z | |
91 | fTriggerMask(o.fTriggerMask),// Int_t - Trigger mask | |
92 | fRebin(o.fRebin), // Int_t - Rebinning factor | |
93 | fCutEdges(o.fCutEdges), // Bool_t - Whether to cut edges when rebinning | |
94 | fSymmetrice(true), | |
e58000b7 | 95 | fCorrEmpty(true), |
96 | fTriggerEff(o.fTriggerEff), | |
3846ec25 | 97 | fShapeCorr(o.fShapeCorr), |
e1f47419 | 98 | fListOfCentralities(o.fListOfCentralities), |
e1f47419 | 99 | fSNNString(o.fSNNString), |
100 | fSysString(o.fSysString), | |
e308a636 | 101 | fCent(o.fCent), |
ffca499d | 102 | fCentAxis(o.fCentAxis), |
0be6c8cd | 103 | fNormalizationScheme(o.fNormalizationScheme), |
104 | fSchemeString(o.fSchemeString), | |
105 | fTriggerString(o.fTriggerString) | |
ce85db45 | 106 | {} |
107 | ||
108 | //____________________________________________________________________ | |
109 | AliBasedNdetaTask::~AliBasedNdetaTask() | |
110 | { | |
fb3430ac | 111 | // |
112 | // Destructor | |
113 | // | |
ce85db45 | 114 | if (fSums) { |
115 | fSums->Delete(); | |
116 | delete fSums; | |
117 | fSums = 0; | |
118 | } | |
e1f47419 | 119 | if (fOutput) { |
120 | fOutput->Delete(); | |
121 | delete fOutput; | |
122 | fOutput = 0; | |
ce85db45 | 123 | } |
124 | } | |
125 | ||
e1f47419 | 126 | //________________________________________________________________________ |
127 | void | |
e308a636 | 128 | AliBasedNdetaTask::SetCentralityAxis(UShort_t n, Short_t* bins) |
129 | { | |
130 | if (!fCentAxis) { | |
131 | fCentAxis = new TAxis(); | |
132 | fCentAxis->SetName("centAxis"); | |
133 | fCentAxis->SetTitle("Centrality [%]"); | |
134 | } | |
135 | TArrayD dbins(n+1); | |
136 | for (UShort_t i = 0; i <= n; i++) | |
137 | dbins[i] = (bins[i] == 100 ? 100.1 : bins[i]); | |
138 | fCentAxis->Set(n, dbins.GetArray()); | |
139 | } | |
140 | ||
141 | //________________________________________________________________________ | |
142 | void | |
143 | AliBasedNdetaTask::AddCentralityBin(UShort_t at, Short_t low, Short_t high) | |
e1f47419 | 144 | { |
145 | // | |
146 | // Add a centrality bin | |
147 | // | |
148 | // Parameters: | |
149 | // low Low cut | |
150 | // high High cut | |
151 | // | |
e308a636 | 152 | CentralityBin* bin = MakeCentralityBin(GetName(), low, high); |
153 | AliInfo(Form("Adding centrality bin %p [%3d,%3d] @ %d", bin, low, high, at)); | |
154 | fListOfCentralities->AddAtAndExpand(bin, at); | |
e1f47419 | 155 | } |
156 | ||
157 | //________________________________________________________________________ | |
158 | AliBasedNdetaTask::CentralityBin* | |
159 | AliBasedNdetaTask::MakeCentralityBin(const char* name, | |
160 | Short_t low, Short_t high) const | |
161 | { | |
162 | // | |
163 | // Make a centrality bin | |
164 | // | |
165 | // Parameters: | |
166 | // name Name used for histograms | |
167 | // low Low cut in percent | |
168 | // high High cut in percent | |
169 | // | |
170 | // Return: | |
171 | // A newly created centrality bin | |
172 | // | |
173 | return new CentralityBin(name, low, high); | |
174 | } | |
ffca499d | 175 | //________________________________________________________________________ |
176 | void | |
177 | AliBasedNdetaTask::SetNormalizationScheme(const char* what) | |
178 | { | |
179 | // | |
180 | // Set normalisation scheme | |
181 | // | |
182 | UShort_t scheme = 0; | |
183 | TString twhat(what); | |
184 | twhat.ToUpper(); | |
185 | TObjString* opt; | |
186 | TIter next(twhat.Tokenize(" ,|")); | |
187 | while ((opt = static_cast<TObjString*>(next()))) { | |
188 | TString s(opt->GetString()); | |
189 | if (s.IsNull()) continue; | |
0be6c8cd | 190 | Bool_t add = true; |
191 | switch (s[0]) { | |
192 | case '-': add = false; // Fall through | |
193 | case '+': s.Remove(0,1); // Remove character | |
194 | } | |
195 | UShort_t bit = 0; | |
196 | if (s.CompareTo("EVENT") == 0) bit = kEventLevel; | |
197 | else if (s.CompareTo("SHAPE") == 0) bit = kShape; | |
198 | else if (s.CompareTo("BACKGROUND")== 0) bit = kBackground; | |
199 | else if (s.CompareTo("TRIGGER") == 0) bit = kTriggerEfficiency; | |
200 | else if (s.CompareTo("FULL") == 0) bit = kFull; | |
201 | else if (s.CompareTo("NONE") == 0) bit = kNone; | |
ffca499d | 202 | else |
203 | Warning("SetNormalizationScheme", "Unknown option %s", s.Data()); | |
0be6c8cd | 204 | if (add) scheme |= bit; |
205 | else scheme ^= bit; | |
ffca499d | 206 | } |
207 | SetNormalizationScheme(scheme); | |
208 | } | |
0be6c8cd | 209 | //________________________________________________________________________ |
210 | void | |
211 | AliBasedNdetaTask::SetNormalizationScheme(UShort_t scheme) | |
212 | { | |
213 | fNormalizationScheme = scheme; | |
214 | TString tit = ""; | |
215 | if (scheme == kFull) tit = "FULL"; | |
216 | else { | |
217 | if (scheme & kEventLevel) tit.Append("EVENT "); | |
218 | if (scheme & kShape) tit.Append("SHAPE "); | |
219 | if (scheme & kBackground) tit.Append("BACKGROUND "); | |
220 | if (scheme & kTriggerEfficiency) tit.Append("TRIGGER"); | |
221 | } | |
222 | tit = tit.Strip(TString::kBoth); | |
223 | if (!fSchemeString) fSchemeString = new TNamed("scheme", ""); | |
224 | fSchemeString->SetTitle(tit); | |
225 | fSchemeString->SetUniqueID(fNormalizationScheme); | |
226 | } | |
ce85db45 | 227 | //________________________________________________________________________ |
228 | void | |
229 | AliBasedNdetaTask::SetTriggerMask(const char* mask) | |
230 | { | |
fb3430ac | 231 | // |
232 | // Set the trigger maskl | |
233 | // | |
234 | // Parameters: | |
235 | // mask Trigger mask | |
236 | // | |
ce85db45 | 237 | UShort_t trgMask = 0; |
238 | TString trgs(mask); | |
239 | trgs.ToUpper(); | |
240 | TObjString* trg; | |
241 | TIter next(trgs.Tokenize(" ,|")); | |
242 | while ((trg = static_cast<TObjString*>(next()))) { | |
243 | TString s(trg->GetString()); | |
244 | if (s.IsNull()) continue; | |
245 | if (s.CompareTo("INEL") == 0) trgMask = AliAODForwardMult::kInel; | |
246 | else if (s.CompareTo("INEL>0")== 0) trgMask = AliAODForwardMult::kInelGt0; | |
247 | else if (s.CompareTo("NSD") == 0) trgMask = AliAODForwardMult::kNSD; | |
248 | else | |
249 | Warning("SetTriggerMask", "Unknown trigger %s", s.Data()); | |
250 | } | |
251 | if (trgMask == 0) trgMask = 1; | |
252 | SetTriggerMask(trgMask); | |
253 | } | |
0be6c8cd | 254 | //________________________________________________________________________ |
255 | void | |
256 | AliBasedNdetaTask::SetTriggerMask(UShort_t mask) | |
257 | { | |
258 | fTriggerMask = mask; | |
259 | TString tit(AliAODForwardMult::GetTriggerString(mask)); | |
260 | tit = tit.Strip(TString::kBoth); | |
261 | if (!fTriggerString) fTriggerString = new TNamed("trigger", ""); | |
262 | fTriggerString->SetTitle(tit); | |
263 | fTriggerString->SetUniqueID(fTriggerMask); | |
264 | } | |
ce85db45 | 265 | |
e58000b7 | 266 | //________________________________________________________________________ |
267 | void | |
268 | AliBasedNdetaTask::SetShapeCorrection(const TH1* c) | |
269 | { | |
fb3430ac | 270 | // |
271 | // Set the shape correction (a.k.a., track correction) for selected | |
272 | // trigger(s) | |
273 | // | |
274 | // Parameters: | |
275 | // h Correction | |
276 | // | |
e58000b7 | 277 | if (!c) return; |
278 | fShapeCorr = static_cast<TH1*>(c->Clone()); | |
279 | fShapeCorr->SetDirectory(0); | |
280 | } | |
281 | ||
ce85db45 | 282 | //________________________________________________________________________ |
283 | void | |
284 | AliBasedNdetaTask::UserCreateOutputObjects() | |
285 | { | |
fb3430ac | 286 | // |
287 | // Create output objects. | |
288 | // | |
289 | // This is called once per slave process | |
290 | // | |
ce85db45 | 291 | fSums = new TList; |
292 | fSums->SetName(Form("%s_sums", GetName())); | |
293 | fSums->SetOwner(); | |
294 | ||
e1f47419 | 295 | // Automatically add 'all' centrality bin if nothing has been defined. |
e308a636 | 296 | AddCentralityBin(0, 0, 0); |
297 | if (fCentAxis && fCentAxis->GetNbins() > 0 && fCentAxis->GetXbins()) { | |
298 | const TArrayD* bins = fCentAxis->GetXbins(); | |
299 | Int_t nbin = fCentAxis->GetNbins(); | |
300 | for (Int_t i = 0; i < nbin; i++) | |
301 | AddCentralityBin(i+1, Short_t((*bins)[i]), Short_t((*bins)[i+1])); | |
302 | } | |
303 | fSums->Add(fCentAxis); | |
304 | ||
ce85db45 | 305 | |
e1f47419 | 306 | // Centrality histogram |
307 | fCent = new TH1D("cent", "Centrality", 100, 0, 100); | |
308 | fCent->SetDirectory(0); | |
309 | fCent->SetXTitle(0); | |
310 | fSums->Add(fCent); | |
311 | ||
312 | // Loop over centrality bins | |
313 | TIter next(fListOfCentralities); | |
314 | CentralityBin* bin = 0; | |
315 | while ((bin = static_cast<CentralityBin*>(next()))) | |
316 | bin->CreateOutputObjects(fSums); | |
ce85db45 | 317 | |
318 | // Check that we have an AOD input handler | |
319 | AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager(); | |
320 | AliAODInputHandler* ah = | |
321 | dynamic_cast<AliAODInputHandler*>(am->GetInputEventHandler()); | |
322 | if (!ah) AliFatal("No AOD input handler set in analysis manager"); | |
323 | ||
324 | // Post data for ALL output slots >0 here, to get at least an empty histogram | |
325 | PostData(1, fSums); | |
326 | } | |
ce85db45 | 327 | //____________________________________________________________________ |
328 | void | |
329 | AliBasedNdetaTask::UserExec(Option_t *) | |
330 | { | |
fb3430ac | 331 | // |
332 | // Process a single event | |
333 | // | |
334 | // Parameters: | |
335 | // option Not used | |
336 | // | |
ce85db45 | 337 | // Main loop |
338 | AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent()); | |
339 | if (!aod) { | |
340 | AliError("Cannot get the AOD event"); | |
341 | return; | |
342 | } | |
e58000b7 | 343 | |
e1f47419 | 344 | TObject* obj = aod->FindListObject("Forward"); |
345 | if (!obj) { | |
346 | AliWarning("No forward object found"); | |
347 | return; | |
678a4979 | 348 | } |
e1f47419 | 349 | AliAODForwardMult* forward = static_cast<AliAODForwardMult*>(obj); |
e308a636 | 350 | |
e1f47419 | 351 | // Fill centrality histogram |
e308a636 | 352 | Float_t cent = forward->GetCentrality(); |
353 | fCent->Fill(cent); | |
e1f47419 | 354 | |
ce85db45 | 355 | // Get the histogram(s) |
e58000b7 | 356 | TH2D* data = GetHistogram(aod, false); |
ce85db45 | 357 | TH2D* dataMC = GetHistogram(aod, true); |
358 | ||
e1f47419 | 359 | // Loop over centrality bins |
ffca499d | 360 | CentralityBin* allBin = |
361 | static_cast<CentralityBin*>(fListOfCentralities->At(0)); | |
e308a636 | 362 | allBin->ProcessEvent(forward, fTriggerMask, fVtxMin, fVtxMax, data, dataMC); |
363 | ||
364 | // Find this centrality bin | |
365 | if (fCentAxis && fCentAxis->GetNbins() > 0) { | |
366 | Int_t icent = fCentAxis->FindBin(cent); | |
367 | CentralityBin* thisBin = 0; | |
368 | if (icent >= 1 && icent <= fCentAxis->GetNbins()) | |
369 | thisBin = static_cast<CentralityBin*>(fListOfCentralities->At(icent)); | |
370 | if (thisBin) | |
ffca499d | 371 | thisBin->ProcessEvent(forward, fTriggerMask, fVtxMin, fVtxMax, |
372 | data, dataMC); | |
e308a636 | 373 | } |
ce85db45 | 374 | |
e1f47419 | 375 | // Here, we get the update |
376 | if (!fSNNString) { | |
377 | UShort_t sNN = forward->GetSNN(); | |
378 | fSNNString = new TNamed("sNN", ""); | |
379 | fSNNString->SetTitle(AliForwardUtil::CenterOfMassEnergyString(sNN)); | |
380 | fSNNString->SetUniqueID(sNN); | |
381 | fSums->Add(fSNNString); | |
e58000b7 | 382 | |
e1f47419 | 383 | UShort_t sys = forward->GetSystem(); |
384 | fSysString = new TNamed("sys", ""); | |
385 | fSysString->SetTitle(AliForwardUtil::CollisionSystemString(sys)); | |
386 | fSysString->SetUniqueID(sys); | |
387 | fSums->Add(fSysString); | |
0be6c8cd | 388 | |
389 | fSums->Add(fSchemeString); | |
390 | fSums->Add(fTriggerString); | |
391 | ||
392 | // Print(); | |
3846ec25 | 393 | } |
e58000b7 | 394 | |
ce85db45 | 395 | PostData(1, fSums); |
396 | } | |
397 | ||
398 | //________________________________________________________________________ | |
399 | void | |
400 | AliBasedNdetaTask::SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker, | |
401 | const char* title, const char* ytitle) | |
402 | { | |
fb3430ac | 403 | // |
404 | // Set histogram graphical options, etc. | |
405 | // | |
406 | // Parameters: | |
407 | // h Histogram to modify | |
408 | // colour Marker color | |
409 | // marker Marker style | |
410 | // title Title of histogram | |
411 | // ytitle Title on y-axis. | |
412 | // | |
ce85db45 | 413 | h->SetTitle(title); |
414 | h->SetMarkerColor(colour); | |
415 | h->SetMarkerStyle(marker); | |
416 | h->SetMarkerSize(1); | |
417 | h->SetFillStyle(0); | |
418 | h->SetYTitle(ytitle); | |
419 | h->GetXaxis()->SetTitleFont(132); | |
420 | h->GetXaxis()->SetLabelFont(132); | |
421 | h->GetXaxis()->SetNdivisions(10); | |
422 | h->GetYaxis()->SetTitleFont(132); | |
423 | h->GetYaxis()->SetLabelFont(132); | |
424 | h->GetYaxis()->SetNdivisions(10); | |
425 | h->GetYaxis()->SetDecimals(); | |
426 | h->SetStats(0); | |
427 | } | |
428 | ||
429 | //________________________________________________________________________ | |
430 | TH1D* | |
431 | AliBasedNdetaTask::ProjectX(const TH2D* h, | |
432 | const char* name, | |
433 | Int_t firstbin, | |
434 | Int_t lastbin, | |
435 | bool corr, | |
e1f47419 | 436 | bool error) |
ce85db45 | 437 | { |
fb3430ac | 438 | // |
439 | // Project onto the X axis | |
440 | // | |
441 | // Parameters: | |
442 | // h 2D histogram | |
443 | // name New name | |
444 | // firstbin First bin to use | |
445 | // lastbin Last bin to use | |
446 | // error Whether to calculate errors | |
447 | // | |
448 | // Return: | |
449 | // Newly created histogram or null | |
450 | // | |
ce85db45 | 451 | if (!h) return 0; |
e1f47419 | 452 | #if USE_ROOT_PROJECT |
453 | return h->ProjectionX(name, firstbin, lastbin, (error ? "e" : "")); | |
454 | #endif | |
ce85db45 | 455 | |
456 | TAxis* xaxis = h->GetXaxis(); | |
457 | TAxis* yaxis = h->GetYaxis(); | |
458 | TH1D* ret = new TH1D(name, h->GetTitle(), xaxis->GetNbins(), | |
459 | xaxis->GetXmin(), xaxis->GetXmax()); | |
460 | static_cast<const TAttLine*>(h)->Copy(*ret); | |
461 | static_cast<const TAttFill*>(h)->Copy(*ret); | |
462 | static_cast<const TAttMarker*>(h)->Copy(*ret); | |
463 | ret->GetXaxis()->ImportAttributes(xaxis); | |
464 | ||
465 | Int_t first = firstbin; | |
466 | Int_t last = lastbin; | |
467 | if (first < 0) first = 0; | |
468 | else if (first >= yaxis->GetNbins()+1) first = yaxis->GetNbins(); | |
469 | if (last < 0) last = yaxis->GetNbins(); | |
470 | else if (last > yaxis->GetNbins()+1) last = yaxis->GetNbins(); | |
471 | if (last-first < 0) { | |
e1f47419 | 472 | AliWarningGeneral("AliBasedNdetaTask", |
473 | Form("Nothing to project [%d,%d]", first, last)); | |
ce85db45 | 474 | return 0; |
475 | ||
476 | } | |
477 | ||
478 | // Loop over X bins | |
479 | // AliInfo(Form("Projecting bins [%d,%d] of %s", first, last, h->GetName())); | |
480 | Int_t ybins = (last-first+1); | |
481 | for (Int_t xbin = 0; xbin <= xaxis->GetNbins()+1; xbin++) { | |
482 | Double_t content = 0; | |
483 | Double_t error2 = 0; | |
484 | Int_t nbins = 0; | |
485 | ||
486 | ||
487 | for (Int_t ybin = first; ybin <= last; ybin++) { | |
488 | Double_t c1 = h->GetCellContent(xbin, ybin); | |
489 | Double_t e1 = h->GetCellError(xbin, ybin); | |
490 | ||
491 | // Ignore empty bins | |
492 | if (c1 < 1e-12) continue; | |
493 | if (e1 < 1e-12) { | |
494 | if (error) continue; | |
495 | e1 = 1; | |
496 | } | |
497 | ||
498 | content += c1; | |
499 | error2 += e1*e1; | |
500 | nbins++; | |
501 | } // for (ybin) | |
502 | if(content > 0 && nbins > 0) { | |
503 | Double_t factor = (corr ? Double_t(ybins) / nbins : 1); | |
504 | if (error) { | |
505 | // Calculate weighted average | |
506 | ret->SetBinContent(xbin, content * factor); | |
507 | ret->SetBinError(xbin, factor * TMath::Sqrt(error2)); | |
508 | } | |
509 | else | |
510 | ret->SetBinContent(xbin, factor * content); | |
511 | } | |
512 | } // for (xbin) | |
513 | ||
514 | return ret; | |
515 | } | |
516 | ||
517 | //________________________________________________________________________ | |
518 | void | |
519 | AliBasedNdetaTask::Terminate(Option_t *) | |
520 | { | |
fb3430ac | 521 | // |
522 | // Called at end of event processing.. | |
523 | // | |
524 | // This is called once in the master | |
525 | // | |
526 | // Parameters: | |
527 | // option Not used | |
528 | // | |
ce85db45 | 529 | // Draw result to screen, or perform fitting, normalizations Called |
530 | // once at the end of the query | |
0be6c8cd | 531 | |
ce85db45 | 532 | fSums = dynamic_cast<TList*> (GetOutputData(1)); |
533 | if(!fSums) { | |
534 | AliError("Could not retrieve TList fSums"); | |
535 | return; | |
536 | } | |
537 | ||
e1f47419 | 538 | fOutput = new TList; |
539 | fOutput->SetName(Form("%s_result", GetName())); | |
540 | fOutput->SetOwner(); | |
e58000b7 | 541 | |
0be6c8cd | 542 | fSNNString = static_cast<TNamed*>(fSums->FindObject("sNN")); |
543 | fSysString = static_cast<TNamed*>(fSums->FindObject("sys")); | |
544 | fCentAxis = static_cast<TAxis*>(fSums->FindObject("centAxis")); | |
545 | fSchemeString = static_cast<TNamed*>(fSums->FindObject("scheme")); | |
546 | fTriggerString = static_cast<TNamed*>(fSums->FindObject("trigger")); | |
ce85db45 | 547 | |
e1f47419 | 548 | if(fSysString && fSNNString && |
549 | fSysString->GetUniqueID() == AliForwardUtil::kPP) | |
550 | LoadNormalizationData(fSysString->GetUniqueID(), | |
551 | fSNNString->GetUniqueID()); | |
0be6c8cd | 552 | // Print before we loop |
553 | Print(); | |
ce85db45 | 554 | |
e1f47419 | 555 | // Loop over centrality bins |
556 | TIter next(fListOfCentralities); | |
557 | CentralityBin* bin = 0; | |
558 | while ((bin = static_cast<CentralityBin*>(next()))) | |
ffca499d | 559 | bin->End(fSums, fOutput, fNormalizationScheme, fShapeCorr, fTriggerEff, |
e1f47419 | 560 | fSymmetrice, fRebin, fCorrEmpty, fCutEdges, |
ffca499d | 561 | fVtxMin, fVtxMax, fTriggerMask, GetColor(), GetMarker()); |
ce85db45 | 562 | |
e1f47419 | 563 | // Output collision energy string |
564 | if (fSNNString) fOutput->Add(fSNNString->Clone()); | |
ce85db45 | 565 | |
e1f47419 | 566 | // Output collision system string |
567 | if (fSysString) fOutput->Add(fSysString->Clone()); | |
ce85db45 | 568 | |
e308a636 | 569 | // Output centrality axis |
570 | if (fCentAxis) fOutput->Add(fCentAxis); | |
571 | ||
e1f47419 | 572 | // Output trigger string |
0be6c8cd | 573 | if (fTriggerString) fOutput->Add(fTriggerString->Clone()); |
574 | ||
575 | // Normalization string | |
576 | if (fSchemeString) fOutput->Add(fSchemeString->Clone()); | |
ce85db45 | 577 | |
e1f47419 | 578 | // Output vertex axis |
ce85db45 | 579 | TAxis* vtxAxis = new TAxis(1,fVtxMin,fVtxMax); |
580 | vtxAxis->SetName("vtxAxis"); | |
581 | vtxAxis->SetTitle(Form("v_{z}#in[%+5.1f,%+5.1f]cm", fVtxMin,fVtxMax)); | |
582 | fOutput->Add(vtxAxis); | |
e1f47419 | 583 | |
584 | // Output trigger efficiency and shape correction | |
e58000b7 | 585 | fOutput->Add(new TParameter<Double_t>("triggerEff", fTriggerEff)); |
586 | if (fShapeCorr) fOutput->Add(fShapeCorr); | |
ffca499d | 587 | |
ce85db45 | 588 | PostData(2, fOutput); |
589 | } | |
3846ec25 | 590 | //________________________________________________________________________ |
591 | void | |
592 | AliBasedNdetaTask::LoadNormalizationData(UShort_t sys, UShort_t energy) | |
593 | { | |
e1f47419 | 594 | // Load the normalisation data for dN/deta for pp INEL, INEL>0, and NSD |
3846ec25 | 595 | TString type("pp"); |
3846ec25 | 596 | TString snn("900"); |
597 | if(energy == 7000) snn.Form("7000"); | |
598 | if(energy == 2750) snn.Form("2750"); | |
599 | ||
e1f47419 | 600 | if(fShapeCorr && (fTriggerEff != 1)) { |
601 | AliInfo("Objects already set for normalization - no action taken"); | |
602 | return; | |
603 | } | |
3846ec25 | 604 | |
e1f47419 | 605 | TFile* fin = TFile::Open(Form("$ALICE_ROOT/PWG2/FORWARD/corrections/" |
606 | "Normalization/normalizationHists_%s_%s.root", | |
607 | type.Data(),snn.Data())); | |
608 | if(!fin) { | |
609 | AliWarning(Form("no file for normalization of %d/%d", sys, energy)); | |
610 | return; | |
611 | } | |
3846ec25 | 612 | |
e1f47419 | 613 | // Shape correction |
614 | TString shapeCorName(Form("h%sNormalization", | |
615 | fTriggerMask == AliAODForwardMult::kInel ? "Inel" : | |
616 | fTriggerMask == AliAODForwardMult::kNSD ? "NSD" : | |
617 | fTriggerMask == AliAODForwardMult::kInelGt0 ? | |
618 | "InelGt0" : "All")); | |
619 | TH2F* shapeCor = dynamic_cast<TH2F*>(fin->Get(shapeCorName)); | |
620 | if (shapeCor) SetShapeCorrection(shapeCor); | |
ce85db45 | 621 | |
e1f47419 | 622 | // Trigger efficiency |
623 | TString effName(Form("%sTriggerEff", | |
624 | fTriggerMask == AliAODForwardMult::kInel ? "inel" : | |
625 | fTriggerMask == AliAODForwardMult::kNSD ? "nsd" : | |
626 | fTriggerMask == AliAODForwardMult::kInelGt0 ? | |
627 | "inelgt0" : "all")); | |
628 | TParameter<float>* eff = static_cast<TParameter<float>*>(fin->Get(effName)); | |
629 | if (eff) SetTriggerEff(eff->GetVal()); | |
3846ec25 | 630 | |
e1f47419 | 631 | // Print - out |
632 | if (shapeCor && eff) AliInfo("Loaded objects for normalization."); | |
3846ec25 | 633 | } |
0be6c8cd | 634 | |
635 | ||
636 | //________________________________________________________________________ | |
637 | void | |
638 | AliBasedNdetaTask::Print(Option_t*) const | |
639 | { | |
640 | // | |
641 | // Print information | |
642 | // | |
643 | std::cout << this->ClassName() << ": " << this->GetName() << "\n" | |
644 | << std::boolalpha | |
645 | << " Trigger: " << (fTriggerString ? | |
646 | fTriggerString->GetTitle() : | |
647 | "none") << "\n" | |
648 | << " Vertex range: [" << fVtxMin << ":" << fVtxMax << "]\n" | |
649 | << " Rebin factor: " << fRebin << "\n" | |
650 | << " Cut edges: " << fCutEdges << "\n" | |
651 | << " Symmertrice: " << fSymmetrice << "\n" | |
652 | << " Correct for empty: " << fCorrEmpty << "\n" | |
653 | << " Normalization scheme: " << (fSchemeString ? | |
654 | fSchemeString->GetTitle() : | |
655 | "none") <<"\n" | |
656 | << " Trigger efficiency: " << fTriggerEff << "\n" | |
657 | << " Shape correction: " << (fShapeCorr ? | |
658 | fShapeCorr->GetName() : | |
659 | "none") << "\n" | |
660 | << " sqrt(s_NN): " << (fSNNString ? | |
661 | fSNNString->GetTitle() : | |
662 | "unknown") << "\n" | |
663 | << " Collision system: " << (fSysString ? | |
664 | fSysString->GetTitle() : | |
665 | "unknown") << "\n" | |
666 | << " Centrality bins: " << (fCentAxis ? "" : "none"); | |
667 | if (fCentAxis) { | |
668 | Int_t nBins = fCentAxis->GetNbins(); | |
669 | const Double_t* bins = fCentAxis->GetXbins()->GetArray(); | |
670 | for (Int_t i = 0; i <= nBins; i++) | |
671 | std::cout << (i==0 ? "" : "-") << bins[i]; | |
672 | } | |
673 | std::cout << std::noboolalpha << std::endl; | |
674 | ||
675 | } | |
676 | ||
ce85db45 | 677 | //________________________________________________________________________ |
678 | TH1D* | |
e1f47419 | 679 | AliBasedNdetaTask::Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges) |
ce85db45 | 680 | { |
fb3430ac | 681 | // |
682 | // Make a copy of the input histogram and rebin that histogram | |
683 | // | |
684 | // Parameters: | |
685 | // h Histogram to rebin | |
686 | // | |
687 | // Return: | |
688 | // New (rebinned) histogram | |
689 | // | |
e1f47419 | 690 | if (rebin <= 1) return 0; |
ce85db45 | 691 | |
692 | Int_t nBins = h->GetNbinsX(); | |
e1f47419 | 693 | if(nBins % rebin != 0) { |
694 | AliWarningGeneral("AliBasedNdetaTask", | |
695 | Form("Rebin factor %d is not a devisor of current number " | |
696 | "of bins %d in the histogram %s", | |
697 | rebin, nBins, h->GetName())); | |
ce85db45 | 698 | return 0; |
699 | } | |
700 | ||
701 | // Make a copy | |
702 | TH1D* tmp = static_cast<TH1D*>(h->Clone(Form("%s_rebin%02d", | |
e1f47419 | 703 | h->GetName(), rebin))); |
704 | tmp->Rebin(rebin); | |
ce85db45 | 705 | tmp->SetDirectory(0); |
706 | ||
707 | // The new number of bins | |
e1f47419 | 708 | Int_t nBinsNew = nBins / rebin; |
ce85db45 | 709 | for(Int_t i = 1;i<= nBinsNew; i++) { |
710 | Double_t content = 0; | |
711 | Double_t sumw = 0; | |
712 | Double_t wsum = 0; | |
713 | Int_t nbins = 0; | |
e1f47419 | 714 | for(Int_t j = 1; j<=rebin;j++) { |
715 | Int_t bin = (i-1)*rebin + j; | |
ce85db45 | 716 | Double_t c = h->GetBinContent(bin); |
ce85db45 | 717 | if (c <= 0) continue; |
678a4979 | 718 | |
e1f47419 | 719 | if (cutEdges) { |
ce85db45 | 720 | if (h->GetBinContent(bin+1)<=0 || |
3846ec25 | 721 | h->GetBinContent(bin-1)<=0) { |
e1f47419 | 722 | #if 0 |
723 | AliWarningGeneral("AliBasedNdetaTask", | |
724 | Form("removing bin %d=%f of %s (%d=%f,%d=%f)", | |
725 | bin, c, h->GetName(), | |
726 | bin+1, h->GetBinContent(bin+1), | |
727 | bin-1, h->GetBinContent(bin-1))); | |
728 | #endif | |
ce85db45 | 729 | continue; |
730 | } | |
731 | } | |
732 | Double_t e = h->GetBinError(bin); | |
733 | Double_t w = 1 / (e*e); // 1/c/c | |
734 | content += c; | |
735 | sumw += w; | |
736 | wsum += w * c; | |
737 | nbins++; | |
738 | } | |
739 | ||
740 | if(content > 0 && nbins > 0) { | |
741 | tmp->SetBinContent(i, wsum / sumw); | |
742 | tmp->SetBinError(i,1./TMath::Sqrt(sumw)); | |
743 | } | |
744 | } | |
745 | ||
746 | return tmp; | |
747 | } | |
748 | ||
749 | //__________________________________________________________________ | |
ce85db45 | 750 | TH1* |
e1f47419 | 751 | AliBasedNdetaTask::Symmetrice(const TH1* h) |
ce85db45 | 752 | { |
fb3430ac | 753 | // |
754 | // Make an extension of @a h to make it symmetric about 0 | |
755 | // | |
756 | // Parameters: | |
757 | // h Histogram to symmertrice | |
758 | // | |
759 | // Return: | |
760 | // Symmetric extension of @a h | |
761 | // | |
ce85db45 | 762 | Int_t nBins = h->GetNbinsX(); |
763 | TH1* s = static_cast<TH1*>(h->Clone(Form("%s_mirror", h->GetName()))); | |
764 | s->SetTitle(Form("%s (mirrored)", h->GetTitle())); | |
765 | s->Reset(); | |
766 | s->SetBins(nBins, -h->GetXaxis()->GetXmax(), -h->GetXaxis()->GetXmin()); | |
767 | s->SetMarkerColor(h->GetMarkerColor()); | |
768 | s->SetMarkerSize(h->GetMarkerSize()); | |
769 | s->SetMarkerStyle(h->GetMarkerStyle()+4); | |
770 | s->SetFillColor(h->GetFillColor()); | |
771 | s->SetFillStyle(h->GetFillStyle()); | |
772 | s->SetDirectory(0); | |
773 | ||
774 | // Find the first and last bin with data | |
775 | Int_t first = nBins+1; | |
776 | Int_t last = 0; | |
777 | for (Int_t i = 1; i <= nBins; i++) { | |
778 | if (h->GetBinContent(i) <= 0) continue; | |
779 | first = TMath::Min(first, i); | |
780 | last = TMath::Max(last, i); | |
781 | } | |
782 | ||
783 | Double_t xfirst = h->GetBinCenter(first-1); | |
784 | Int_t f1 = h->GetXaxis()->FindBin(-xfirst); | |
785 | Int_t l2 = s->GetXaxis()->FindBin(xfirst); | |
786 | for (Int_t i = f1, j=l2; i <= last; i++,j--) { | |
787 | s->SetBinContent(j, h->GetBinContent(i)); | |
788 | s->SetBinError(j, h->GetBinError(i)); | |
789 | } | |
790 | // Fill in overlap bin | |
791 | s->SetBinContent(l2+1, h->GetBinContent(first)); | |
792 | s->SetBinError(l2+1, h->GetBinError(first)); | |
793 | return s; | |
794 | } | |
e1f47419 | 795 | |
796 | //==================================================================== | |
797 | AliBasedNdetaTask::CentralityBin::CentralityBin() | |
798 | : TNamed("", ""), | |
799 | fSums(0), | |
800 | fOutput(0), | |
801 | fSum(0), | |
802 | fSumMC(0), | |
803 | fTriggers(0), | |
804 | fLow(0), | |
805 | fHigh(0) | |
806 | { | |
807 | // | |
808 | // Constructor | |
809 | // | |
810 | } | |
811 | //____________________________________________________________________ | |
812 | AliBasedNdetaTask::CentralityBin::CentralityBin(const char* name, | |
813 | Short_t low, Short_t high) | |
814 | : TNamed(name, ""), | |
815 | fSums(0), | |
816 | fOutput(0), | |
817 | fSum(0), | |
818 | fSumMC(0), | |
819 | fTriggers(0), | |
820 | fLow(low), | |
821 | fHigh(high) | |
822 | { | |
823 | // | |
824 | // Constructor | |
825 | // | |
826 | // Parameters: | |
827 | // name Name used for histograms (e.g., Forward) | |
828 | // low Lower centrality cut in percent | |
829 | // high Upper centrality cut in percent | |
830 | // | |
831 | if (low <= 0 && high <= 0) { | |
832 | fLow = 0; | |
833 | fHigh = 0; | |
834 | SetTitle("All centralities"); | |
835 | } | |
836 | else { | |
837 | fLow = low; | |
838 | fHigh = high; | |
839 | SetTitle(Form("Centrality bin from %3d%% to %3d%%", low, high)); | |
840 | } | |
841 | } | |
842 | //____________________________________________________________________ | |
843 | AliBasedNdetaTask::CentralityBin::CentralityBin(const CentralityBin& o) | |
844 | : TNamed(o), | |
845 | fSums(o.fSums), | |
846 | fOutput(o.fOutput), | |
847 | fSum(o.fSum), | |
848 | fSumMC(o.fSumMC), | |
849 | fTriggers(o.fTriggers), | |
850 | fLow(o.fLow), | |
851 | fHigh(o.fHigh) | |
852 | { | |
853 | // | |
854 | // Copy constructor | |
855 | // | |
856 | // Parameters: | |
857 | // other Object to copy from | |
858 | // | |
859 | } | |
860 | //____________________________________________________________________ | |
861 | AliBasedNdetaTask::CentralityBin::~CentralityBin() | |
862 | { | |
863 | // | |
864 | // Destructor | |
865 | // | |
866 | if (fSums) fSums->Delete(); | |
867 | if (fOutput) fOutput->Delete(); | |
868 | } | |
869 | ||
870 | //____________________________________________________________________ | |
871 | AliBasedNdetaTask::CentralityBin& | |
872 | AliBasedNdetaTask::CentralityBin::operator=(const CentralityBin& o) | |
873 | { | |
874 | // | |
875 | // Assignment operator | |
876 | // | |
877 | // Parameters: | |
878 | // other Object to assign from | |
879 | // | |
880 | // Return: | |
881 | // Reference to this | |
882 | // | |
883 | SetName(o.GetName()); | |
884 | SetTitle(o.GetTitle()); | |
885 | fSums = o.fSums; | |
886 | fOutput = o.fOutput; | |
887 | fSum = o.fSum; | |
888 | fSumMC = o.fSumMC; | |
889 | fTriggers = o.fTriggers; | |
890 | fLow = o.fLow; | |
891 | fHigh = o.fHigh; | |
892 | ||
893 | return *this; | |
894 | } | |
895 | //____________________________________________________________________ | |
896 | const char* | |
897 | AliBasedNdetaTask::CentralityBin::GetListName() const | |
898 | { | |
899 | // | |
900 | // Get the list name | |
901 | // | |
902 | // Return: | |
903 | // List Name | |
904 | // | |
905 | if (IsAllBin()) return "all"; | |
906 | return Form("cent%03d_%03d", fLow, fHigh); | |
907 | } | |
908 | //____________________________________________________________________ | |
909 | void | |
910 | AliBasedNdetaTask::CentralityBin::CreateOutputObjects(TList* dir) | |
911 | { | |
912 | // | |
913 | // Create output objects | |
914 | // | |
915 | // Parameters: | |
916 | // dir Parent list | |
917 | // | |
918 | fSums = new TList; | |
919 | fSums->SetName(GetListName()); | |
920 | fSums->SetOwner(); | |
921 | dir->Add(fSums); | |
922 | ||
ffca499d | 923 | fTriggers = AliAODForwardMult::MakeTriggerHistogram("triggers"); |
924 | fTriggers->SetDirectory(0); | |
e1f47419 | 925 | fSums->Add(fTriggers); |
926 | } | |
927 | //____________________________________________________________________ | |
928 | void | |
929 | AliBasedNdetaTask::CentralityBin::CreateSums(const TH2D* data, const TH2D* mc) | |
930 | { | |
931 | // | |
932 | // Create sum histogram | |
933 | // | |
934 | // Parameters: | |
935 | // data Data histogram to clone | |
936 | // mc (optional) MC histogram to clone | |
937 | // | |
938 | fSum = static_cast<TH2D*>(data->Clone(GetName())); | |
939 | fSum->SetDirectory(0); | |
940 | fSum->Reset(); | |
941 | fSums->Add(fSum); | |
942 | ||
943 | // If no MC data is given, then do not create MC sum histogram | |
944 | if (!mc) return; | |
945 | ||
946 | fSumMC = static_cast<TH2D*>(mc->Clone(Form("%sMC", GetName()))); | |
947 | fSumMC->SetDirectory(0); | |
948 | fSumMC->Reset(); | |
949 | fSums->Add(fSumMC); | |
950 | } | |
951 | ||
952 | //____________________________________________________________________ | |
953 | Bool_t | |
954 | AliBasedNdetaTask::CentralityBin::CheckEvent(const AliAODForwardMult* forward, | |
955 | Int_t triggerMask, | |
956 | Double_t vzMin, Double_t vzMax) | |
957 | { | |
958 | // | |
959 | // Check the trigger, vertex, and centrality | |
960 | // | |
961 | // Parameters: | |
962 | // aod Event input | |
963 | // | |
964 | // Return: | |
965 | // true if the event is to be used | |
966 | // | |
967 | if (!forward) return false; | |
e1f47419 | 968 | |
ffca499d | 969 | // We do not check for centrality here - it's already done |
970 | return forward->CheckEvent(triggerMask, vzMin, vzMax, 0, 0, fTriggers); | |
e1f47419 | 971 | } |
972 | ||
973 | ||
974 | //____________________________________________________________________ | |
975 | void | |
976 | AliBasedNdetaTask::CentralityBin::ProcessEvent(const AliAODForwardMult* forward, | |
977 | Int_t triggerMask, | |
978 | Double_t vzMin, Double_t vzMax, | |
979 | const TH2D* data, const TH2D* mc) | |
980 | { | |
981 | // | |
982 | // Process an event | |
983 | // | |
984 | // Parameters: | |
985 | // forward Forward data (for trigger, vertex, & centrality) | |
986 | // triggerMask Trigger mask | |
987 | // vzMin Minimum IP z coordinate | |
988 | // vzMax Maximum IP z coordinate | |
989 | // data Data histogram | |
990 | // mc MC histogram | |
991 | // | |
992 | if (!CheckEvent(forward, triggerMask, vzMin, vzMax)) return; | |
993 | if (!data) return; | |
994 | if (!fSum) CreateSums(data, mc); | |
995 | ||
996 | fSum->Add(data); | |
997 | if (mc) fSumMC->Add(mc); | |
998 | } | |
999 | ||
1000 | //________________________________________________________________________ | |
1001 | void | |
1002 | AliBasedNdetaTask::CentralityBin::End(TList* sums, | |
1003 | TList* results, | |
ffca499d | 1004 | UShort_t scheme, |
e1f47419 | 1005 | const TH1* shapeCorr, |
1006 | Double_t trigEff, | |
1007 | Bool_t symmetrice, | |
1008 | Int_t rebin, | |
1009 | Bool_t corrEmpty, | |
1010 | Bool_t cutEdges, | |
1011 | Double_t vzMin, | |
1012 | Double_t vzMax, | |
ffca499d | 1013 | Int_t triggerMask, |
1014 | Int_t color, | |
1015 | Int_t marker) | |
e1f47419 | 1016 | { |
1017 | // | |
1018 | // End of processing | |
1019 | // | |
1020 | // Parameters: | |
1021 | // sums List of sums | |
1022 | // results Output list of results | |
1023 | // shapeCorr Shape correction or nil | |
1024 | // trigEff Trigger efficiency | |
1025 | // symmetrice Whether to symmetrice the results | |
1026 | // rebin Whether to rebin the results | |
1027 | // corrEmpty Whether to correct for empty bins | |
1028 | // cutEdges Whether to cut edges when rebinning | |
1029 | // vzMin Minimum IP z coordinate | |
1030 | // vzMax Maximum IP z coordinate | |
1031 | // triggerMask Trigger mask | |
1032 | // | |
1033 | ||
1034 | fSums = dynamic_cast<TList*>(sums->FindObject(GetListName())); | |
1035 | if(!fSums) { | |
1036 | AliError("Could not retrieve TList fSums"); | |
1037 | return; | |
1038 | } | |
1039 | ||
1040 | fOutput = new TList; | |
1041 | fOutput->SetName(GetListName()); | |
1042 | fOutput->SetOwner(); | |
1043 | results->Add(fOutput); | |
1044 | ||
1045 | fSum = static_cast<TH2D*>(fSums->FindObject(GetName())); | |
1046 | fSumMC = static_cast<TH2D*>(fSums->FindObject(Form("%sMC", GetName()))); | |
ffca499d | 1047 | fTriggers = static_cast<TH1I*>(fSums->FindObject("triggers")); |
e1f47419 | 1048 | |
1049 | if (!fTriggers) { | |
1050 | AliError("Couldn't find histogram 'triggers' in list"); | |
1051 | return; | |
1052 | } | |
1053 | if (!fSum) { | |
e308a636 | 1054 | AliError(Form("Couldn't find histogram '%s' in list", GetName())); |
e1f47419 | 1055 | return; |
1056 | } | |
ffca499d | 1057 | |
1058 | TH1I& t = *fTriggers; | |
0be6c8cd | 1059 | Double_t nAll = t.GetBinContent(AliAODForwardMult::kBinAll); |
1060 | Double_t nB = t.GetBinContent(AliAODForwardMult::kBinB); | |
1061 | Double_t nA = t.GetBinContent(AliAODForwardMult::kBinA); | |
1062 | Double_t nC = t.GetBinContent(AliAODForwardMult::kBinC); | |
1063 | Double_t nE = t.GetBinContent(AliAODForwardMult::kBinE); | |
1064 | Double_t nOffline = t.GetBinContent(AliAODForwardMult::kBinOffline); | |
1065 | Double_t nTriggered = t.GetBinContent(AliAODForwardMult::kWithTrigger); | |
1066 | Double_t nWithVertex = t.GetBinContent(AliAODForwardMult::kWithVertex); | |
1067 | Double_t nAccepted = t.GetBinContent(AliAODForwardMult::kAccepted); | |
1068 | Double_t nGood = nB - nA - nC + 2 * nE; | |
e308a636 | 1069 | |
e1f47419 | 1070 | |
e308a636 | 1071 | if (nTriggered <= 0.1) { |
e1f47419 | 1072 | AliError("Number of triggered events <= 0"); |
1073 | return; | |
1074 | } | |
e308a636 | 1075 | if (nWithVertex <= 0.1) { |
1076 | AliError("Number of events with vertex <= 0"); | |
1077 | return; | |
1078 | } | |
1079 | if (nGood <= 0.1) { | |
e1f47419 | 1080 | AliWarning(Form("Number of good events=%d=%d-%d-%d+2*%d<=0", |
0be6c8cd | 1081 | Int_t(nGood), Int_t(nB), Int_t(nA), Int_t(nC), Int_t(nE))); |
1082 | nGood = nTriggered; | |
e1f47419 | 1083 | } |
e308a636 | 1084 | |
1085 | ||
1086 | // Scaling | |
0be6c8cd | 1087 | // |
e308a636 | 1088 | // N_A + N_A/N_V (N_T - N_V) = N_A + N_A/N_V*N_T - N_A |
1089 | // = N_A/N_V * N_T | |
0be6c8cd | 1090 | // or with beta |
1091 | // | |
1092 | // N_A + N_A/N_V (N_T - N_V - beta) = | |
1093 | // N_A (1 + N_T/N_V - 1 - beta/N_V) | |
1094 | // N_A (N_T / N_V - beta/N_V) | |
1095 | // | |
e308a636 | 1096 | // where |
0be6c8cd | 1097 | // |
e308a636 | 1098 | // N_A = nAccepted |
1099 | // N_V = nWithVertex | |
1100 | // N_T = nTriggered | |
0be6c8cd | 1101 | // |
e308a636 | 1102 | // so that the normalisation is simply |
0be6c8cd | 1103 | // |
e308a636 | 1104 | // N_A / E_V |
0be6c8cd | 1105 | // |
1106 | // or | |
1107 | // | |
1108 | // N_A (1 / E_V - beta / N_V) | |
1109 | // | |
1110 | // with | |
1111 | // | |
1112 | // E_V = N_V / N_T | |
1113 | // | |
1114 | Double_t ntotal = nAccepted; | |
1115 | Double_t scaler = 1; | |
1116 | Double_t vtxEff = nWithVertex /nTriggered; | |
1117 | Double_t beta = nA + nC - 2*nE; | |
ffca499d | 1118 | Bool_t shape = (scheme & kShape); |
0be6c8cd | 1119 | if (scheme & kEventLevel) { |
1120 | ntotal = nAccepted / vtxEff; | |
1121 | scaler = vtxEff; | |
1122 | AliInfo(Form("Calculating event normalisation as\n" | |
1123 | " N = N_A * N_T / N_V = %d * %d / %d = %f", | |
1124 | Int_t(nAccepted), Int_t(nTriggered), Int_t(nWithVertex), | |
1125 | ntotal)); | |
1126 | ||
1127 | if (scheme & kBackground) { | |
1128 | AliInfo(Form("Correcting for background\n" | |
1129 | " beta = N_a + N_c + 2N_e = %d + %d - 2 * %d = %d", | |
1130 | Int_t(nA), Int_t(nC), Int_t(nE), Int_t(beta))); | |
1131 | ntotal -= nAccepted * beta / nWithVertex; | |
1132 | scaler -= (beta > 0 ? nWithVertex / beta : 0); | |
1133 | AliInfo(Form("Calculating event normalisation as\n" | |
1134 | " N = N - N_A * beta / N_V = %f - %d * %d / %d = %f", | |
1135 | nAccepted / vtxEff, Int_t(nAccepted), Int_t(beta), | |
1136 | Int_t(nWithVertex), ntotal)); | |
1137 | } | |
ffca499d | 1138 | } |
0be6c8cd | 1139 | if (scheme & kTriggerEfficiency) { |
1140 | AliInfo(Form("Correcting normalisation for trigger efficiency:\n" | |
1141 | " N = 1 / E_X * N = 1 / %f * %d = %f", | |
1142 | trigEff, Int_t(ntotal), ntotal / trigEff)); | |
1143 | ntotal /= trigEff * (shape ? trigEff : 1); | |
1144 | scaler *= trigEff * (shape ? trigEff : 1); | |
ffca499d | 1145 | } |
e308a636 | 1146 | |
0be6c8cd | 1147 | AliInfo(Form("\n" |
1148 | " Total of %9d events for %s\n" | |
1149 | " of these %9d have an offline trigger\n" | |
1150 | " of these N_T = %9d has a %s trigger\n" | |
1151 | " of these N_V = %9d has a vertex\n" | |
1152 | " of these N_A = %9d were in [%+4.1f,%+4.1f]cm\n" | |
1153 | " Triggers by hardware type:\n" | |
1154 | " N_b = %9d\n" | |
1155 | " N_ac = %9d (%d+%d)\n" | |
1156 | " N_e = %9d\n" | |
1157 | " Implies %9d good triggers\n" | |
1158 | " Vertex efficiency: %f\n" | |
1159 | " Trigger efficiency: %f\n" | |
1160 | " Total number of events: N = %f\n" | |
1161 | " Scaler (N_A/N): %f", | |
1162 | Int_t(nAll), GetTitle(), Int_t(nOffline), | |
1163 | Int_t(nTriggered), | |
e1f47419 | 1164 | AliAODForwardMult::GetTriggerString(triggerMask), |
0be6c8cd | 1165 | Int_t(nWithVertex), Int_t(nAccepted), |
e1f47419 | 1166 | vzMin, vzMax, |
0be6c8cd | 1167 | Int_t(nB), Int_t(nA+nC), Int_t(nA), Int_t(nC), Int_t(nE), |
1168 | Int_t(nGood), vtxEff, trigEff, ntotal, scaler)); | |
e1f47419 | 1169 | |
1170 | const char* name = GetName(); | |
1171 | ||
1172 | // Get acceptance normalisation from underflow bins | |
1173 | TH1D* norm = ProjectX(fSum, Form("norm%s",name), 0, 0, corrEmpty, false); | |
1174 | norm->SetDirectory(0); | |
1175 | ||
1176 | // Scale by shape correction | |
0be6c8cd | 1177 | if (shape && shapeCorr) fSum->Divide(shapeCorr); |
e1f47419 | 1178 | else AliInfo("No shape correction specified, or disabled"); |
1179 | ||
1180 | // Project on X axis | |
1181 | TH1D* dndeta = ProjectX(fSum, Form("dndeta%s",name), 1, fSum->GetNbinsY(), | |
1182 | corrEmpty); | |
1183 | dndeta->SetDirectory(0); | |
1184 | ||
1185 | // Normalize to the acceptance - | |
1186 | dndeta->Divide(norm); | |
1187 | ||
1188 | // Scale by the vertex efficiency | |
0be6c8cd | 1189 | dndeta->Scale(scaler, "width"); |
e1f47419 | 1190 | |
ffca499d | 1191 | SetHistogramAttributes(dndeta, color, marker, Form("ALICE %s", name)); |
1192 | SetHistogramAttributes(norm, color, marker, Form("ALICE %s normalisation", | |
1193 | name)); | |
e1f47419 | 1194 | |
1195 | fOutput->Add(fTriggers->Clone()); | |
1196 | if (symmetrice) fOutput->Add(Symmetrice(dndeta)); | |
1197 | fOutput->Add(dndeta); | |
1198 | fOutput->Add(norm); | |
1199 | fOutput->Add(Rebin(dndeta, rebin, cutEdges)); | |
1200 | if (symmetrice) fOutput->Add(Symmetrice(Rebin(dndeta, rebin, cutEdges))); | |
1201 | ||
1202 | if (fSumMC) { | |
1203 | // Get acceptance normalisation from underflow bins | |
1204 | TH1D* normMC = ProjectX(fSumMC,Form("norm%sMC", name), 0, 1, | |
1205 | corrEmpty, false); | |
1206 | // Project onto eta axis - _ignoring_underflow_bins_! | |
1207 | TH1D* dndetaMC = ProjectX(fSumMC,Form("dndeta%sMC", name),1, | |
1208 | fSum->GetNbinsY(), corrEmpty); | |
1209 | // Normalize to the acceptance | |
1210 | dndetaMC->Divide(normMC); | |
1211 | // Scale by the vertex efficiency | |
ffca499d | 1212 | dndetaMC->Scale(ntotal, "width"); |
e1f47419 | 1213 | normMC->Scale(1. / nAccepted); |
1214 | ||
ffca499d | 1215 | SetHistogramAttributes(dndetaMC, color+2, marker, |
1216 | Form("ALICE %s (MC)",name)); | |
1217 | SetHistogramAttributes(normMC, color+2, marker, | |
1218 | Form("ALICE %s (MC) normalisation",name)); | |
e1f47419 | 1219 | |
1220 | fOutput->Add(dndetaMC); | |
1221 | if (symmetrice) fOutput->Add(Symmetrice(dndetaMC)); | |
1222 | ||
1223 | fOutput->Add(normMC); | |
1224 | fOutput->Add(Rebin(dndetaMC, rebin, cutEdges)); | |
1225 | ||
1226 | if (symmetrice) | |
1227 | fOutput->Add(Symmetrice(Rebin(dndetaMC, rebin, cutEdges))); | |
1228 | } | |
e308a636 | 1229 | |
1230 | // Temporary stuff | |
ffca499d | 1231 | if (!IsAllBin()) return; |
1232 | ||
e308a636 | 1233 | TFile* forward = TFile::Open("forward.root", "READ"); |
1234 | if (!forward) { | |
1235 | AliWarning(Form("No forward.root file found")); | |
1236 | return; | |
1237 | } | |
1238 | ||
1239 | TH1D* shapeCorrProj = 0; | |
1240 | if (shapeCorr) { | |
1241 | shapeCorrProj = static_cast<const TH2D*>(shapeCorr)->ProjectionX(); | |
1242 | shapeCorrProj->Scale(1. / shapeCorr->GetNbinsY()); | |
1243 | shapeCorrProj->SetDirectory(0); | |
1244 | fOutput->Add(shapeCorrProj); | |
1245 | } | |
1246 | ||
1247 | TList* official = static_cast<TList*>(forward->Get("official")); | |
1248 | if (official) { | |
1249 | TH1F* histEta = static_cast<TH1F*>(official->FindObject("fHistEta")); | |
1250 | if (histEta) { | |
1251 | TH1D* oEta = new TH1D("tracks", "", histEta->GetNbinsX(), | |
1252 | histEta->GetXaxis()->GetXmin(), | |
1253 | histEta->GetXaxis()->GetXmax()); | |
1254 | for (Int_t i = 1; i < histEta->GetNbinsX(); i++) { | |
1255 | oEta->SetBinContent(i, histEta->GetBinContent(i)); | |
1256 | oEta->SetBinError(i, histEta->GetBinError(i)); | |
1257 | } | |
1258 | if (shapeCorrProj) oEta->Divide(shapeCorrProj); | |
1259 | oEta->Scale(ntotal/nAccepted, "width"); | |
1260 | oEta->SetDirectory(0); | |
ffca499d | 1261 | oEta->SetMarkerStyle(marker+4); |
1262 | oEta->SetMarkerColor(color+5); | |
e308a636 | 1263 | fOutput->Add(oEta); |
1264 | fOutput->Add(Rebin(oEta, rebin, false)); | |
1265 | } | |
1266 | else | |
1267 | AliWarning(Form("Couldn't find histogram fHistEta in list %s", | |
1268 | official->GetName())); | |
1269 | } | |
1270 | else | |
1271 | AliWarning(Form("Couldn't find list 'official' in %s",forward->GetName())); | |
1272 | ||
1273 | TList* tracks = static_cast<TList*>(forward->Get("tracks")); | |
1274 | if (tracks) { | |
1275 | TH1F* histEta = static_cast<TH1F*>(tracks->FindObject("fHistEta")); | |
1276 | if (histEta) { | |
1277 | TH1D* oEta = new TH1D("tracks", "", histEta->GetNbinsX(), | |
1278 | histEta->GetXaxis()->GetXmin(), | |
1279 | histEta->GetXaxis()->GetXmax()); | |
1280 | for (Int_t i = 1; i < histEta->GetNbinsX(); i++) { | |
1281 | oEta->SetBinContent(i, histEta->GetBinContent(i)); | |
1282 | oEta->SetBinError(i, histEta->GetBinError(i)); | |
1283 | } | |
1284 | if (shapeCorrProj) oEta->Divide(shapeCorrProj); | |
1285 | oEta->Scale(ntotal/nAccepted, "width"); | |
1286 | oEta->SetDirectory(0); | |
ffca499d | 1287 | oEta->SetMarkerStyle(marker); |
1288 | oEta->SetMarkerColor(color+5); | |
e308a636 | 1289 | fOutput->Add(oEta); |
1290 | fOutput->Add(Rebin(oEta, rebin, false)); | |
1291 | } | |
1292 | else | |
1293 | AliWarning(Form("Couldn't find histogram fHistEta in list %s", | |
1294 | tracks->GetName())); | |
1295 | } | |
1296 | else | |
1297 | AliWarning(Form("Couldn't find list 'tracks' in %s",forward->GetName())); | |
1298 | ||
1299 | forward->Close(); | |
e1f47419 | 1300 | } |
1301 | ||
fb3430ac | 1302 | // |
1303 | // EOF | |
1304 | // |