]>
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> | |
8 | #include <AliAnalysisManager.h> | |
9 | #include <AliAODEvent.h> | |
10 | #include <AliAODHandler.h> | |
11 | #include <AliAODInputHandler.h> | |
12 | #include "AliForwardUtil.h" | |
13 | #include "AliAODForwardMult.h" | |
3846ec25 | 14 | #include <TFile.h> |
5bb5d1f6 | 15 | #include <TStyle.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), |
c25b5e1b | 29 | fUseROOTProj(false), |
e58000b7 | 30 | fTriggerEff(1), |
66cf95f2 | 31 | fTriggerEff0(1), |
3846ec25 | 32 | fShapeCorr(0), |
e1f47419 | 33 | fListOfCentralities(0), |
e1f47419 | 34 | fSNNString(0), |
35 | fSysString(0), | |
e308a636 | 36 | fCent(0), |
ffca499d | 37 | fCentAxis(0), |
0be6c8cd | 38 | fNormalizationScheme(kFull), |
39 | fSchemeString(0), | |
c89b9ac1 | 40 | fTriggerString(0), |
3d9b0442 | 41 | fFinalMCCorrFile(""), |
cd49c50b | 42 | fglobalempiricalcorrection(0), |
43 | fmeabsignalvscentr(0) | |
fb3430ac | 44 | { |
45 | // | |
46 | // Constructor | |
47 | // | |
5ca83fee | 48 | DGUARD(fDebug,3,"Default CTOR of AliBasedNdetaTask"); |
fb3430ac | 49 | } |
ce85db45 | 50 | |
51 | //____________________________________________________________________ | |
52 | AliBasedNdetaTask::AliBasedNdetaTask(const char* name) | |
53 | : AliAnalysisTaskSE(name), | |
ce85db45 | 54 | fSums(0), // Container of sums |
e1f47419 | 55 | fOutput(0), // Container of output |
ce85db45 | 56 | fVtxMin(-10), // Minimum v_z |
57 | fVtxMax(10), // Maximum v_z | |
58 | fTriggerMask(AliAODForwardMult::kInel), | |
59 | fRebin(5), // Rebinning factor | |
60 | fCutEdges(false), | |
61 | fSymmetrice(true), | |
e58000b7 | 62 | fCorrEmpty(true), |
c25b5e1b | 63 | fUseROOTProj(false), |
e58000b7 | 64 | fTriggerEff(1), |
66cf95f2 | 65 | fTriggerEff0(1), |
3846ec25 | 66 | fShapeCorr(0), |
e1f47419 | 67 | fListOfCentralities(0), |
e1f47419 | 68 | fSNNString(0), |
69 | fSysString(0), | |
e308a636 | 70 | fCent(0), |
ffca499d | 71 | fCentAxis(0), |
0be6c8cd | 72 | fNormalizationScheme(kFull), |
73 | fSchemeString(0), | |
c89b9ac1 | 74 | fTriggerString(0), |
3d9b0442 | 75 | fFinalMCCorrFile(""), |
cd49c50b | 76 | fglobalempiricalcorrection(0), |
77 | fmeabsignalvscentr(0) | |
ce85db45 | 78 | { |
fb3430ac | 79 | // |
80 | // Constructor | |
81 | // | |
5ca83fee | 82 | DGUARD(fDebug, 3,"Named CTOR of AliBasedNdetaTask: %s", name); |
e308a636 | 83 | fListOfCentralities = new TObjArray(1); |
0be6c8cd | 84 | |
85 | // Set the normalisation scheme | |
86 | SetNormalizationScheme(kFull); | |
87 | ||
88 | // Set the trigger mask | |
89 | SetTriggerMask(AliAODForwardMult::kInel); | |
fb3430ac | 90 | |
ce85db45 | 91 | // Output slot #1 writes into a TH1 container |
92 | DefineOutput(1, TList::Class()); | |
93 | DefineOutput(2, TList::Class()); | |
94 | } | |
95 | ||
96 | //____________________________________________________________________ | |
97 | AliBasedNdetaTask::AliBasedNdetaTask(const AliBasedNdetaTask& o) | |
98 | : AliAnalysisTaskSE(o), | |
ce85db45 | 99 | fSums(o.fSums), // TList* - Container of sums |
e1f47419 | 100 | fOutput(o.fOutput), // Container of output |
ce85db45 | 101 | fVtxMin(o.fVtxMin), // Double_t - Minimum v_z |
102 | fVtxMax(o.fVtxMax), // Double_t - Maximum v_z | |
103 | fTriggerMask(o.fTriggerMask),// Int_t - Trigger mask | |
104 | fRebin(o.fRebin), // Int_t - Rebinning factor | |
105 | fCutEdges(o.fCutEdges), // Bool_t - Whether to cut edges when rebinning | |
c25b5e1b | 106 | fSymmetrice(o.fSymmetrice), |
107 | fCorrEmpty(o.fCorrEmpty), | |
108 | fUseROOTProj(o.fUseROOTProj), | |
e58000b7 | 109 | fTriggerEff(o.fTriggerEff), |
66cf95f2 | 110 | fTriggerEff0(o.fTriggerEff0), |
3846ec25 | 111 | fShapeCorr(o.fShapeCorr), |
e1f47419 | 112 | fListOfCentralities(o.fListOfCentralities), |
e1f47419 | 113 | fSNNString(o.fSNNString), |
114 | fSysString(o.fSysString), | |
e308a636 | 115 | fCent(o.fCent), |
ffca499d | 116 | fCentAxis(o.fCentAxis), |
0be6c8cd | 117 | fNormalizationScheme(o.fNormalizationScheme), |
118 | fSchemeString(o.fSchemeString), | |
c89b9ac1 | 119 | fTriggerString(o.fTriggerString), |
3d9b0442 | 120 | fFinalMCCorrFile(o.fFinalMCCorrFile), |
cd49c50b | 121 | fglobalempiricalcorrection(o.fglobalempiricalcorrection), |
122 | fmeabsignalvscentr(o.fmeabsignalvscentr) | |
f53fb4f6 | 123 | { |
5ca83fee | 124 | DGUARD(fDebug, 3,"Copy CTOR of AliBasedNdetaTask"); |
f53fb4f6 | 125 | } |
ce85db45 | 126 | |
127 | //____________________________________________________________________ | |
128 | AliBasedNdetaTask::~AliBasedNdetaTask() | |
129 | { | |
fb3430ac | 130 | // |
131 | // Destructor | |
132 | // | |
f53fb4f6 | 133 | DGUARD(fDebug,3,"Destruction of AliBasedNdetaTask"); |
ce85db45 | 134 | if (fSums) { |
135 | fSums->Delete(); | |
136 | delete fSums; | |
137 | fSums = 0; | |
138 | } | |
e1f47419 | 139 | if (fOutput) { |
140 | fOutput->Delete(); | |
141 | delete fOutput; | |
142 | fOutput = 0; | |
ce85db45 | 143 | } |
144 | } | |
145 | ||
f53fb4f6 | 146 | //________________________________________________________________________ |
147 | void | |
148 | AliBasedNdetaTask::SetDebugLevel(Int_t lvl) | |
149 | { | |
150 | AliAnalysisTaskSE::SetDebugLevel(lvl); | |
151 | for (Int_t i = 0; i < fListOfCentralities->GetEntries(); i++) { | |
152 | CentralityBin* bin = | |
153 | static_cast<CentralityBin*>(fListOfCentralities->At(i)); | |
154 | bin->SetDebugLevel(lvl); | |
155 | } | |
156 | } | |
157 | ||
e1f47419 | 158 | //________________________________________________________________________ |
159 | void | |
e308a636 | 160 | AliBasedNdetaTask::SetCentralityAxis(UShort_t n, Short_t* bins) |
161 | { | |
f53fb4f6 | 162 | DGUARD(fDebug,3,"Set centrality axis, %d bins", n); |
e308a636 | 163 | if (!fCentAxis) { |
164 | fCentAxis = new TAxis(); | |
165 | fCentAxis->SetName("centAxis"); | |
166 | fCentAxis->SetTitle("Centrality [%]"); | |
167 | } | |
168 | TArrayD dbins(n+1); | |
169 | for (UShort_t i = 0; i <= n; i++) | |
170 | dbins[i] = (bins[i] == 100 ? 100.1 : bins[i]); | |
171 | fCentAxis->Set(n, dbins.GetArray()); | |
172 | } | |
173 | ||
174 | //________________________________________________________________________ | |
175 | void | |
176 | AliBasedNdetaTask::AddCentralityBin(UShort_t at, Short_t low, Short_t high) | |
e1f47419 | 177 | { |
178 | // | |
179 | // Add a centrality bin | |
180 | // | |
181 | // Parameters: | |
182 | // low Low cut | |
183 | // high High cut | |
184 | // | |
1a7e2e15 | 185 | DGUARD(fDebug,3,"Add a centrality bin [%d,%d] @ %d", low, high, at); |
e308a636 | 186 | CentralityBin* bin = MakeCentralityBin(GetName(), low, high); |
1a7e2e15 | 187 | if (!bin) { |
188 | Error("AddCentralityBin", | |
189 | "Failed to create centrality bin for %s [%d,%d] @ %d", | |
190 | GetName(), low, high, at); | |
191 | return; | |
192 | } | |
f53fb4f6 | 193 | bin->SetDebugLevel(fDebug); |
e308a636 | 194 | fListOfCentralities->AddAtAndExpand(bin, at); |
e1f47419 | 195 | } |
196 | ||
197 | //________________________________________________________________________ | |
198 | AliBasedNdetaTask::CentralityBin* | |
199 | AliBasedNdetaTask::MakeCentralityBin(const char* name, | |
200 | Short_t low, Short_t high) const | |
201 | { | |
202 | // | |
203 | // Make a centrality bin | |
204 | // | |
205 | // Parameters: | |
206 | // name Name used for histograms | |
207 | // low Low cut in percent | |
208 | // high High cut in percent | |
209 | // | |
210 | // Return: | |
211 | // A newly created centrality bin | |
212 | // | |
1a7e2e15 | 213 | DGUARD(fDebug,3,"Make a centrality bin %s [%d,%d]", name, low, high); |
e1f47419 | 214 | return new CentralityBin(name, low, high); |
215 | } | |
a76fb27d | 216 | |
217 | #define TESTAPPEND(SCHEME,BIT,STRING) \ | |
218 | do { if (!(SCHEME & BIT)) break; \ | |
219 | if (!s.IsNull()) s.Append(","); s.Append(STRING); } while(false) | |
220 | ||
ffca499d | 221 | //________________________________________________________________________ |
a76fb27d | 222 | const Char_t* |
223 | AliBasedNdetaTask::NormalizationSchemeString(UShort_t scheme) | |
224 | { | |
225 | // Create a string from normalization scheme bits | |
226 | static TString s; | |
227 | s = ""; | |
228 | ||
229 | if (scheme == kNone) | |
230 | return s.Data(); | |
231 | if (scheme == kFull) { | |
232 | s = "FULL"; | |
233 | return s.Data(); | |
234 | } | |
235 | TESTAPPEND(scheme, kEventLevel, "EVENT"); | |
236 | TESTAPPEND(scheme, kShape, "SHAPE"); | |
237 | TESTAPPEND(scheme, kBackground, "BACKGROUND"); | |
238 | TESTAPPEND(scheme, kTriggerEfficiency, "TRIGGER"); | |
239 | TESTAPPEND(scheme, kZeroBin, "ZEROBIN"); | |
240 | ||
241 | return s.Data(); | |
242 | } | |
243 | //________________________________________________________________________ | |
244 | UShort_t | |
245 | AliBasedNdetaTask::ParseNormalizationScheme(const char* what) | |
ffca499d | 246 | { |
ffca499d | 247 | UShort_t scheme = 0; |
248 | TString twhat(what); | |
249 | twhat.ToUpper(); | |
250 | TObjString* opt; | |
09d5920f | 251 | TObjArray* token = twhat.Tokenize(" ,|"); |
252 | TIter next(token); | |
ffca499d | 253 | while ((opt = static_cast<TObjString*>(next()))) { |
254 | TString s(opt->GetString()); | |
255 | if (s.IsNull()) continue; | |
0be6c8cd | 256 | Bool_t add = true; |
257 | switch (s[0]) { | |
258 | case '-': add = false; // Fall through | |
259 | case '+': s.Remove(0,1); // Remove character | |
260 | } | |
261 | UShort_t bit = 0; | |
262 | if (s.CompareTo("EVENT") == 0) bit = kEventLevel; | |
263 | else if (s.CompareTo("SHAPE") == 0) bit = kShape; | |
264 | else if (s.CompareTo("BACKGROUND")== 0) bit = kBackground; | |
265 | else if (s.CompareTo("TRIGGER") == 0) bit = kTriggerEfficiency; | |
266 | else if (s.CompareTo("FULL") == 0) bit = kFull; | |
267 | else if (s.CompareTo("NONE") == 0) bit = kNone; | |
4fa8d795 | 268 | else if (s.CompareTo("ZEROBIN") == 0) bit = kZeroBin; |
ffca499d | 269 | else |
a76fb27d | 270 | ::Warning("SetNormalizationScheme", "Unknown option %s", s.Data()); |
0be6c8cd | 271 | if (add) scheme |= bit; |
272 | else scheme ^= bit; | |
ffca499d | 273 | } |
09d5920f | 274 | delete token; |
a76fb27d | 275 | return scheme; |
276 | } | |
277 | //________________________________________________________________________ | |
278 | void | |
279 | AliBasedNdetaTask::SetNormalizationScheme(const char* what) | |
280 | { | |
281 | // | |
282 | // Set normalisation scheme | |
283 | // | |
284 | DGUARD(fDebug,3,"Set the normalization scheme: %s", what); | |
285 | SetNormalizationScheme(ParseNormalizationScheme(what)); | |
ffca499d | 286 | } |
0be6c8cd | 287 | //________________________________________________________________________ |
288 | void | |
289 | AliBasedNdetaTask::SetNormalizationScheme(UShort_t scheme) | |
290 | { | |
f53fb4f6 | 291 | DGUARD(fDebug,3,"Set the normalization scheme: 0x%x", scheme); |
0be6c8cd | 292 | fNormalizationScheme = scheme; |
241cca4d | 293 | if (fSchemeString) delete fSchemeString; |
294 | fSchemeString = AliForwardUtil::MakeParameter("scheme", scheme); | |
0be6c8cd | 295 | } |
ce85db45 | 296 | //________________________________________________________________________ |
297 | void | |
298 | AliBasedNdetaTask::SetTriggerMask(const char* mask) | |
299 | { | |
fb3430ac | 300 | // |
301 | // Set the trigger maskl | |
302 | // | |
303 | // Parameters: | |
304 | // mask Trigger mask | |
305 | // | |
f53fb4f6 | 306 | DGUARD(fDebug,3,"Set the trigger mask: %s", mask); |
9453b19e | 307 | SetTriggerMask(AliAODForwardMult::MakeTriggerMask(mask)); |
ce85db45 | 308 | } |
0be6c8cd | 309 | //________________________________________________________________________ |
310 | void | |
311 | AliBasedNdetaTask::SetTriggerMask(UShort_t mask) | |
312 | { | |
f53fb4f6 | 313 | DGUARD(fDebug,3,"Set the trigger mask: 0x%0x", mask); |
0be6c8cd | 314 | fTriggerMask = mask; |
241cca4d | 315 | if (fTriggerString) delete fTriggerString; |
316 | fTriggerString = AliForwardUtil::MakeParameter("trigger", fTriggerMask); | |
0be6c8cd | 317 | } |
ce85db45 | 318 | |
e58000b7 | 319 | //________________________________________________________________________ |
320 | void | |
f67d699c | 321 | AliBasedNdetaTask::SetShapeCorrection(const TH2F* c) |
e58000b7 | 322 | { |
fb3430ac | 323 | // |
324 | // Set the shape correction (a.k.a., track correction) for selected | |
325 | // trigger(s) | |
326 | // | |
327 | // Parameters: | |
328 | // h Correction | |
329 | // | |
f53fb4f6 | 330 | DGUARD(fDebug,3,"Set the shape correction: %p", c); |
e58000b7 | 331 | if (!c) return; |
f67d699c | 332 | fShapeCorr = static_cast<TH2F*>(c->Clone()); |
e58000b7 | 333 | fShapeCorr->SetDirectory(0); |
334 | } | |
335 | ||
f67d699c | 336 | //________________________________________________________________________ |
337 | void | |
338 | AliBasedNdetaTask::InitializeCentBins() | |
339 | { | |
340 | if (fListOfCentralities->GetEntries() > 0) return; | |
341 | ||
342 | // Automatically add 'all' centrality bin if nothing has been defined. | |
343 | AddCentralityBin(0, 0, 0); | |
344 | if (fCentAxis && fCentAxis->GetNbins() > 0 && fCentAxis->GetXbins()) { | |
345 | const TArrayD* bins = fCentAxis->GetXbins(); | |
346 | Int_t nbin = fCentAxis->GetNbins(); | |
347 | for (Int_t i = 0; i < nbin; i++) | |
348 | AddCentralityBin(i+1, Short_t((*bins)[i]), Short_t((*bins)[i+1])); | |
349 | } | |
350 | } | |
351 | ||
ce85db45 | 352 | //________________________________________________________________________ |
353 | void | |
354 | AliBasedNdetaTask::UserCreateOutputObjects() | |
355 | { | |
fb3430ac | 356 | // |
357 | // Create output objects. | |
358 | // | |
359 | // This is called once per slave process | |
360 | // | |
f53fb4f6 | 361 | DGUARD(fDebug,1,"Create user ouput object"); |
ce85db45 | 362 | fSums = new TList; |
363 | fSums->SetName(Form("%s_sums", GetName())); | |
364 | fSums->SetOwner(); | |
365 | ||
f67d699c | 366 | InitializeCentBins(); |
9ecab72f | 367 | if (fCentAxis) fSums->Add(fCentAxis); |
e308a636 | 368 | |
1ff25622 | 369 | fSums->Add(AliForwardUtil::MakeParameter("alirootRev", |
370 | AliForwardUtil::AliROOTRevision())); | |
371 | fSums->Add(AliForwardUtil::MakeParameter("alirootBranch", | |
372 | AliForwardUtil::AliROOTBranch())); | |
ce85db45 | 373 | |
e1f47419 | 374 | // Centrality histogram |
375 | fCent = new TH1D("cent", "Centrality", 100, 0, 100); | |
376 | fCent->SetDirectory(0); | |
377 | fCent->SetXTitle(0); | |
378 | fSums->Add(fCent); | |
379 | ||
380 | // Loop over centrality bins | |
381 | TIter next(fListOfCentralities); | |
382 | CentralityBin* bin = 0; | |
383 | while ((bin = static_cast<CentralityBin*>(next()))) | |
1a7e2e15 | 384 | bin->CreateOutputObjects(fSums, fTriggerMask); |
f67d699c | 385 | |
cd49c50b | 386 | fmeabsignalvscentr=new TH2D("meabsignalvscentr","meabsignalvscentr",400,0,20,100,0,100); |
387 | fSums->Add(fmeabsignalvscentr); | |
290052e7 | 388 | // Post data for ALL output slots >0 here, to get at least an empty |
389 | // histogram | |
ce85db45 | 390 | PostData(1, fSums); |
391 | } | |
4bcdcbc1 | 392 | |
ce85db45 | 393 | //____________________________________________________________________ |
394 | void | |
395 | AliBasedNdetaTask::UserExec(Option_t *) | |
396 | { | |
fb3430ac | 397 | // |
398 | // Process a single event | |
399 | // | |
400 | // Parameters: | |
401 | // option Not used | |
402 | // | |
ce85db45 | 403 | // Main loop |
f53fb4f6 | 404 | DGUARD(fDebug,1,"Analyse the AOD event"); |
290052e7 | 405 | AliAODEvent* aod = AliForwardUtil::GetAODEvent(this); |
4bcdcbc1 | 406 | if (!aod) return; |
407 | ||
e58000b7 | 408 | |
e1f47419 | 409 | TObject* obj = aod->FindListObject("Forward"); |
410 | if (!obj) { | |
411 | AliWarning("No forward object found"); | |
412 | return; | |
678a4979 | 413 | } |
e1f47419 | 414 | AliAODForwardMult* forward = static_cast<AliAODForwardMult*>(obj); |
e308a636 | 415 | |
e1f47419 | 416 | // Fill centrality histogram |
e308a636 | 417 | Float_t cent = forward->GetCentrality(); |
418 | fCent->Fill(cent); | |
e1f47419 | 419 | |
ce85db45 | 420 | // Get the histogram(s) |
e58000b7 | 421 | TH2D* data = GetHistogram(aod, false); |
ce85db45 | 422 | TH2D* dataMC = GetHistogram(aod, true); |
3d9b0442 | 423 | if(!ApplyEmpiricalCorrection(forward,data)) |
424 | return; | |
cd49c50b | 425 | |
8449e3e0 | 426 | #if 0 |
427 | // Code disabled - breaks execution | |
cd49c50b | 428 | Int_t notemptybins=0; |
429 | Double_t sum=0.0; | |
430 | for (Int_t ix=1;ix<=data->GetXaxis()->GetNbins();ix++) | |
8449e3e0 | 431 | { |
432 | Double_t sumy=0.0; | |
433 | for(Int_t iy=1;iy<=data->GetYaxis()->GetNbins();iy++) | |
cd49c50b | 434 | { |
8449e3e0 | 435 | if(data->GetBinContent(ix,iy)>0.0) |
436 | { | |
437 | sumy+=data->GetBinContent(ix,iy); | |
438 | notemptybins++; | |
439 | } | |
cd49c50b | 440 | |
441 | } | |
8449e3e0 | 442 | sum+=sumy; |
443 | } | |
cd49c50b | 444 | |
8449e3e0 | 445 | if(notemptybins>0) |
446 | { | |
447 | sum=sum/((Double_t)notemptybins); | |
448 | } | |
449 | else | |
450 | sum=-1.0; | |
451 | fmeabsignalvscentr->Fill(sum,cent); | |
452 | #endif | |
cd49c50b | 453 | |
4fa8d795 | 454 | Bool_t isZero = ((fNormalizationScheme & kZeroBin) && |
455 | !forward->IsTriggerBits(AliAODForwardMult::kNClusterGt0)); | |
456 | ||
457 | ||
e1f47419 | 458 | // Loop over centrality bins |
ffca499d | 459 | CentralityBin* allBin = |
460 | static_cast<CentralityBin*>(fListOfCentralities->At(0)); | |
4fa8d795 | 461 | allBin->ProcessEvent(forward, fTriggerMask, isZero, |
462 | fVtxMin, fVtxMax, data, dataMC); | |
e308a636 | 463 | |
464 | // Find this centrality bin | |
465 | if (fCentAxis && fCentAxis->GetNbins() > 0) { | |
466 | Int_t icent = fCentAxis->FindBin(cent); | |
467 | CentralityBin* thisBin = 0; | |
468 | if (icent >= 1 && icent <= fCentAxis->GetNbins()) | |
469 | thisBin = static_cast<CentralityBin*>(fListOfCentralities->At(icent)); | |
470 | if (thisBin) | |
4fa8d795 | 471 | thisBin->ProcessEvent(forward, fTriggerMask, isZero, fVtxMin, fVtxMax, |
ffca499d | 472 | data, dataMC); |
e308a636 | 473 | } |
ce85db45 | 474 | |
e1f47419 | 475 | // Here, we get the update |
a76fb27d | 476 | if (!fSNNString) { |
241cca4d | 477 | fSNNString = AliForwardUtil::MakeParameter("sNN", forward->GetSNN()); |
478 | fSysString = AliForwardUtil::MakeParameter("sys", forward->GetSystem()); | |
479 | ||
a76fb27d | 480 | fSums->Add(fSNNString); |
a76fb27d | 481 | fSums->Add(fSysString); |
a76fb27d | 482 | fSums->Add(fSchemeString); |
483 | fSums->Add(fTriggerString); | |
484 | ||
485 | // Print(); | |
486 | } | |
ce85db45 | 487 | PostData(1, fSums); |
488 | } | |
489 | ||
490 | //________________________________________________________________________ | |
491 | void | |
492 | AliBasedNdetaTask::SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker, | |
493 | const char* title, const char* ytitle) | |
494 | { | |
fb3430ac | 495 | // |
496 | // Set histogram graphical options, etc. | |
497 | // | |
498 | // Parameters: | |
499 | // h Histogram to modify | |
500 | // colour Marker color | |
501 | // marker Marker style | |
502 | // title Title of histogram | |
503 | // ytitle Title on y-axis. | |
504 | // | |
ce85db45 | 505 | h->SetTitle(title); |
506 | h->SetMarkerColor(colour); | |
507 | h->SetMarkerStyle(marker); | |
9ecab72f | 508 | h->SetMarkerSize(marker == 29 || marker == 30 ? 1.2 : 1); |
ce85db45 | 509 | h->SetFillStyle(0); |
510 | h->SetYTitle(ytitle); | |
511 | h->GetXaxis()->SetTitleFont(132); | |
512 | h->GetXaxis()->SetLabelFont(132); | |
513 | h->GetXaxis()->SetNdivisions(10); | |
514 | h->GetYaxis()->SetTitleFont(132); | |
515 | h->GetYaxis()->SetLabelFont(132); | |
516 | h->GetYaxis()->SetNdivisions(10); | |
517 | h->GetYaxis()->SetDecimals(); | |
518 | h->SetStats(0); | |
519 | } | |
520 | ||
4fa8d795 | 521 | //________________________________________________________________________ |
522 | void | |
523 | AliBasedNdetaTask::ScaleToCoverage(TH2D* copy, const TH1D* norm) | |
524 | { | |
525 | // Normalize to the acceptance - | |
526 | // dndeta->Divide(accNorm); | |
527 | for (Int_t i = 1; i <= copy->GetNbinsX(); i++) { | |
528 | Double_t a = norm->GetBinContent(i); | |
529 | for (Int_t j = 1; j <= copy->GetNbinsY(); j++) { | |
530 | if (a <= 0) { | |
531 | copy->SetBinContent(i,j,0); | |
532 | copy->SetBinError(i,j,0); | |
533 | continue; | |
534 | } | |
535 | Double_t c = copy->GetBinContent(i, j); | |
536 | Double_t e = copy->GetBinError(i, j); | |
537 | copy->SetBinContent(i, j, c / a); | |
538 | copy->SetBinError(i, j, e / a); | |
539 | } | |
540 | } | |
541 | } | |
5ca83fee | 542 | //________________________________________________________________________ |
543 | void | |
544 | AliBasedNdetaTask::ScaleToCoverage(TH1D* copy, const TH1D* norm) | |
545 | { | |
546 | // Normalize to the acceptance - | |
547 | // dndeta->Divide(accNorm); | |
548 | for (Int_t i = 1; i <= copy->GetNbinsX(); i++) { | |
549 | Double_t a = norm->GetBinContent(i); | |
550 | if (a <= 0) { | |
551 | copy->SetBinContent(i,0); | |
552 | copy->SetBinError(i,0); | |
553 | continue; | |
554 | } | |
555 | Double_t c = copy->GetBinContent(i); | |
556 | Double_t e = copy->GetBinError(i); | |
557 | copy->SetBinContent(i, c / a); | |
558 | copy->SetBinError(i, e / a); | |
559 | } | |
560 | } | |
4fa8d795 | 561 | |
ce85db45 | 562 | //________________________________________________________________________ |
563 | TH1D* | |
564 | AliBasedNdetaTask::ProjectX(const TH2D* h, | |
565 | const char* name, | |
566 | Int_t firstbin, | |
567 | Int_t lastbin, | |
c25b5e1b | 568 | bool useRoot, |
ce85db45 | 569 | bool corr, |
e1f47419 | 570 | bool error) |
ce85db45 | 571 | { |
fb3430ac | 572 | // |
573 | // Project onto the X axis | |
574 | // | |
575 | // Parameters: | |
576 | // h 2D histogram | |
577 | // name New name | |
578 | // firstbin First bin to use | |
579 | // lastbin Last bin to use | |
580 | // error Whether to calculate errors | |
581 | // | |
582 | // Return: | |
583 | // Newly created histogram or null | |
584 | // | |
ce85db45 | 585 | if (!h) return 0; |
c25b5e1b | 586 | if (useRoot) |
587 | return h->ProjectionX(name, firstbin, lastbin, (error ? "e" : "")); | |
ce85db45 | 588 | |
589 | TAxis* xaxis = h->GetXaxis(); | |
590 | TAxis* yaxis = h->GetYaxis(); | |
591 | TH1D* ret = new TH1D(name, h->GetTitle(), xaxis->GetNbins(), | |
592 | xaxis->GetXmin(), xaxis->GetXmax()); | |
593 | static_cast<const TAttLine*>(h)->Copy(*ret); | |
594 | static_cast<const TAttFill*>(h)->Copy(*ret); | |
595 | static_cast<const TAttMarker*>(h)->Copy(*ret); | |
596 | ret->GetXaxis()->ImportAttributes(xaxis); | |
597 | ||
598 | Int_t first = firstbin; | |
599 | Int_t last = lastbin; | |
5ca83fee | 600 | if (first < 0) first = 1; |
601 | else if (first >= yaxis->GetNbins()+2) first = yaxis->GetNbins()+1; | |
ce85db45 | 602 | if (last < 0) last = yaxis->GetNbins(); |
5ca83fee | 603 | else if (last >= yaxis->GetNbins()+2) last = yaxis->GetNbins()+1; |
ce85db45 | 604 | if (last-first < 0) { |
e1f47419 | 605 | AliWarningGeneral("AliBasedNdetaTask", |
606 | Form("Nothing to project [%d,%d]", first, last)); | |
ce85db45 | 607 | return 0; |
608 | ||
609 | } | |
610 | ||
611 | // Loop over X bins | |
612 | // AliInfo(Form("Projecting bins [%d,%d] of %s", first, last, h->GetName())); | |
613 | Int_t ybins = (last-first+1); | |
614 | for (Int_t xbin = 0; xbin <= xaxis->GetNbins()+1; xbin++) { | |
615 | Double_t content = 0; | |
616 | Double_t error2 = 0; | |
617 | Int_t nbins = 0; | |
618 | ||
619 | ||
620 | for (Int_t ybin = first; ybin <= last; ybin++) { | |
621 | Double_t c1 = h->GetCellContent(xbin, ybin); | |
622 | Double_t e1 = h->GetCellError(xbin, ybin); | |
623 | ||
624 | // Ignore empty bins | |
625 | if (c1 < 1e-12) continue; | |
626 | if (e1 < 1e-12) { | |
627 | if (error) continue; | |
628 | e1 = 1; | |
629 | } | |
630 | ||
631 | content += c1; | |
632 | error2 += e1*e1; | |
633 | nbins++; | |
634 | } // for (ybin) | |
635 | if(content > 0 && nbins > 0) { | |
636 | Double_t factor = (corr ? Double_t(ybins) / nbins : 1); | |
c25b5e1b | 637 | #if 0 |
638 | AliWarningGeneral(ret->GetName(), | |
639 | Form("factor @ %d is %d/%d -> %f", | |
640 | xbin, ybins, nbins, factor)); | |
641 | #endif | |
ce85db45 | 642 | if (error) { |
643 | // Calculate weighted average | |
644 | ret->SetBinContent(xbin, content * factor); | |
645 | ret->SetBinError(xbin, factor * TMath::Sqrt(error2)); | |
646 | } | |
647 | else | |
648 | ret->SetBinContent(xbin, factor * content); | |
649 | } | |
650 | } // for (xbin) | |
651 | ||
652 | return ret; | |
653 | } | |
654 | ||
655 | //________________________________________________________________________ | |
656 | void | |
657 | AliBasedNdetaTask::Terminate(Option_t *) | |
658 | { | |
fb3430ac | 659 | // |
660 | // Called at end of event processing.. | |
661 | // | |
662 | // This is called once in the master | |
663 | // | |
664 | // Parameters: | |
665 | // option Not used | |
666 | // | |
ce85db45 | 667 | // Draw result to screen, or perform fitting, normalizations Called |
668 | // once at the end of the query | |
f53fb4f6 | 669 | DGUARD(fDebug,1,"Process final merged results"); |
0be6c8cd | 670 | |
ce85db45 | 671 | fSums = dynamic_cast<TList*> (GetOutputData(1)); |
672 | if(!fSums) { | |
673 | AliError("Could not retrieve TList fSums"); | |
674 | return; | |
675 | } | |
676 | ||
e1f47419 | 677 | fOutput = new TList; |
678 | fOutput->SetName(Form("%s_result", GetName())); | |
679 | fOutput->SetOwner(); | |
c89b9ac1 | 680 | |
241cca4d | 681 | fSNNString = fSums->FindObject("sNN"); |
682 | fSysString = fSums->FindObject("sys"); | |
0be6c8cd | 683 | fCentAxis = static_cast<TAxis*>(fSums->FindObject("centAxis")); |
241cca4d | 684 | fSchemeString = fSums->FindObject("scheme"); |
685 | fTriggerString = fSums->FindObject("trigger"); | |
ce85db45 | 686 | |
e1f47419 | 687 | if(fSysString && fSNNString && |
688 | fSysString->GetUniqueID() == AliForwardUtil::kPP) | |
689 | LoadNormalizationData(fSysString->GetUniqueID(), | |
690 | fSNNString->GetUniqueID()); | |
f67d699c | 691 | |
692 | InitializeCentBins(); | |
693 | ||
0be6c8cd | 694 | // Print before we loop |
695 | Print(); | |
ce85db45 | 696 | |
e1f47419 | 697 | // Loop over centrality bins |
698 | TIter next(fListOfCentralities); | |
699 | CentralityBin* bin = 0; | |
5bb5d1f6 | 700 | gStyle->SetPalette(1); |
701 | THStack* dndetaStack = new THStack("dndeta", "dN/d#eta"); | |
702 | THStack* dndetaStackRebin = new THStack(Form("dndeta_rebin%02d", fRebin), | |
703 | "dN_{ch}/d#eta"); | |
704 | THStack* dndetaMCStack = new THStack("dndetaMC", "dN_{ch}/d#eta"); | |
705 | THStack* dndetaMCStackRebin = new THStack(Form("dndetaMC_rebin%02d", fRebin), | |
706 | "dN_{ch}/d#eta"); | |
707 | ||
c89b9ac1 | 708 | TList* mclist = 0; |
709 | TList* truthlist = 0; | |
710 | ||
797161e8 | 711 | if (fFinalMCCorrFile.Contains(".root")) { |
c89b9ac1 | 712 | TFile* ftest = TFile::Open(fFinalMCCorrFile.Data()); |
713 | if(ftest) { | |
797161e8 | 714 | mclist = dynamic_cast<TList*>(ftest->Get(Form("%sResults",GetName()))); |
715 | truthlist = dynamic_cast<TList*>(ftest->Get("MCTruthResults")); | |
c89b9ac1 | 716 | } |
797161e8 | 717 | else |
718 | AliWarning("MC analysis file invalid - no final MC correction possible"); | |
c89b9ac1 | 719 | } |
9ecab72f | 720 | Int_t style = GetMarker(); |
721 | Int_t color = GetColor(); | |
c89b9ac1 | 722 | |
9ecab72f | 723 | AliInfo(Form("Marker style=%d, color=%d", style, color)); |
5bb5d1f6 | 724 | while ((bin = static_cast<CentralityBin*>(next()))) { |
c89b9ac1 | 725 | |
66cf95f2 | 726 | bin->End(fSums, fOutput, fNormalizationScheme, fShapeCorr, |
727 | fTriggerEff, fTriggerEff0, | |
c25b5e1b | 728 | fSymmetrice, fRebin, fUseROOTProj, fCorrEmpty, fCutEdges, |
c89b9ac1 | 729 | fTriggerMask, style, color, mclist, truthlist); |
5bb5d1f6 | 730 | if (fCentAxis && bin->IsAllBin()) continue; |
731 | TH1* dndeta = bin->GetResult(0, false, ""); | |
732 | TH1* dndetaSym = bin->GetResult(0, true, ""); | |
733 | TH1* dndetaMC = bin->GetResult(0, false, "MC"); | |
734 | TH1* dndetaMCSym = bin->GetResult(0, true, "MC"); | |
735 | if (dndeta) dndetaStack->Add(dndeta); | |
736 | if (dndetaSym) dndetaStack->Add(dndetaSym); | |
737 | if (dndetaMC) dndetaMCStack->Add(dndetaMC); | |
738 | if (dndetaMCSym) dndetaMCStack->Add(dndetaMCSym); | |
739 | if (fRebin > 1) { | |
740 | dndeta = bin->GetResult(fRebin, false, ""); | |
741 | dndetaSym = bin->GetResult(fRebin, true, ""); | |
742 | dndetaMC = bin->GetResult(fRebin, false, "MC"); | |
743 | dndetaMCSym = bin->GetResult(fRebin, true, "MC"); | |
744 | if (dndeta) dndetaStackRebin->Add(dndeta); | |
745 | if (dndetaSym) dndetaStackRebin->Add(dndetaSym); | |
746 | if (dndetaMC) dndetaMCStackRebin->Add(dndetaMC); | |
747 | if (dndetaMCSym) dndetaMCStackRebin->Add(dndetaMCSym); | |
748 | } | |
749 | } | |
750 | // Output the stack | |
751 | fOutput->Add(dndetaStack); | |
752 | ||
753 | // If available output rebinned stack | |
754 | if (!dndetaStackRebin->GetHists() || | |
755 | dndetaStackRebin->GetHists()->GetEntries() <= 0) { | |
756 | AliWarning("No rebinned histograms found"); | |
757 | delete dndetaStackRebin; | |
758 | dndetaStackRebin = 0; | |
759 | } | |
760 | if (dndetaStackRebin) fOutput->Add(dndetaStackRebin); | |
761 | ||
762 | // If available, output track-ref stack | |
763 | if (!dndetaMCStack->GetHists() || | |
764 | dndetaMCStack->GetHists()->GetEntries() <= 0) { | |
765 | AliWarning("No MC histograms found"); | |
766 | delete dndetaMCStack; | |
767 | dndetaMCStack = 0; | |
768 | } | |
769 | if (dndetaMCStack) fOutput->Add(dndetaMCStack); | |
770 | ||
771 | // If available, output rebinned track-ref stack | |
772 | if (!dndetaMCStackRebin->GetHists() || | |
773 | dndetaMCStackRebin->GetHists()->GetEntries() <= 0) { | |
774 | AliWarning("No rebinned MC histograms found"); | |
775 | delete dndetaMCStackRebin; | |
776 | dndetaMCStackRebin = 0; | |
777 | } | |
778 | if (dndetaMCStackRebin) fOutput->Add(dndetaMCStackRebin); | |
ce85db45 | 779 | |
e1f47419 | 780 | // Output collision energy string |
a76fb27d | 781 | if (fSNNString) { |
782 | UShort_t sNN = fSNNString->GetUniqueID(); | |
783 | TNamed* sNNObj = new TNamed(fSNNString->GetName(), | |
784 | AliForwardUtil::CenterOfMassEnergyString(sNN)); | |
785 | sNNObj->SetUniqueID(sNN); | |
786 | fOutput->Add(sNNObj); // fSNNString->Clone()); | |
787 | } | |
ce85db45 | 788 | |
e1f47419 | 789 | // Output collision system string |
a76fb27d | 790 | if (fSysString) { |
791 | UShort_t sys = fSysString->GetUniqueID(); | |
792 | TNamed* sysObj = new TNamed(fSysString->GetName(), | |
793 | AliForwardUtil::CollisionSystemString(sys)); | |
794 | sysObj->SetUniqueID(sys); | |
795 | fOutput->Add(sysObj); // fSysString->Clone()); | |
796 | } | |
ce85db45 | 797 | |
e308a636 | 798 | // Output centrality axis |
799 | if (fCentAxis) fOutput->Add(fCentAxis); | |
800 | ||
e1f47419 | 801 | // Output trigger string |
a76fb27d | 802 | if (fTriggerString) { |
803 | UShort_t mask = fTriggerString->GetUniqueID(); | |
804 | TNamed* maskObj = new TNamed(fTriggerString->GetName(), | |
805 | AliAODForwardMult::GetTriggerString(mask)); | |
806 | maskObj->SetUniqueID(mask); | |
807 | fOutput->Add(maskObj); // fTriggerString->Clone()); | |
808 | } | |
0be6c8cd | 809 | |
810 | // Normalization string | |
a76fb27d | 811 | if (fSchemeString) { |
812 | UShort_t scheme = fSchemeString->GetUniqueID(); | |
813 | TNamed* schemeObj = new TNamed(fSchemeString->GetName(), | |
814 | NormalizationSchemeString(scheme)); | |
815 | schemeObj->SetUniqueID(scheme); | |
816 | fOutput->Add(schemeObj); // fSchemeString->Clone()); | |
817 | } | |
ce85db45 | 818 | |
e1f47419 | 819 | // Output vertex axis |
ce85db45 | 820 | TAxis* vtxAxis = new TAxis(1,fVtxMin,fVtxMax); |
821 | vtxAxis->SetName("vtxAxis"); | |
822 | vtxAxis->SetTitle(Form("v_{z}#in[%+5.1f,%+5.1f]cm", fVtxMin,fVtxMax)); | |
823 | fOutput->Add(vtxAxis); | |
e1f47419 | 824 | |
825 | // Output trigger efficiency and shape correction | |
241cca4d | 826 | fOutput->Add(AliForwardUtil::MakeParameter("triggerEff", fTriggerEff)); |
66cf95f2 | 827 | fOutput->Add(AliForwardUtil::MakeParameter("triggerEff0", fTriggerEff0)); |
e58000b7 | 828 | if (fShapeCorr) fOutput->Add(fShapeCorr); |
ffca499d | 829 | |
c25b5e1b | 830 | TNamed* options = new TNamed("options",""); |
831 | TString str; | |
832 | str.Append(Form("Edges %scut, ", fCutEdges ? "" : "not ")); | |
833 | str.Append(Form("Empty bins %scorrected for, ", fCorrEmpty ? "" : "not ")); | |
834 | str.Append(Form("TH2::ProjectionX %sused", fUseROOTProj ? "" : "not ")); | |
835 | options->SetTitle(str); | |
836 | fOutput->Add(options); | |
837 | ||
ce85db45 | 838 | PostData(2, fOutput); |
839 | } | |
3846ec25 | 840 | //________________________________________________________________________ |
841 | void | |
842 | AliBasedNdetaTask::LoadNormalizationData(UShort_t sys, UShort_t energy) | |
843 | { | |
e1f47419 | 844 | // Load the normalisation data for dN/deta for pp INEL, INEL>0, and NSD |
f53fb4f6 | 845 | DGUARD(fDebug,1,"Load the normalization data for sys=%d, energy=%d", |
846 | sys, energy); | |
3846ec25 | 847 | TString type("pp"); |
3846ec25 | 848 | TString snn("900"); |
849 | if(energy == 7000) snn.Form("7000"); | |
850 | if(energy == 2750) snn.Form("2750"); | |
851 | ||
4fa8d795 | 852 | if(fShapeCorr && (fTriggerEff != 1)) { |
e1f47419 | 853 | AliInfo("Objects already set for normalization - no action taken"); |
854 | return; | |
855 | } | |
3846ec25 | 856 | |
bd6f5206 | 857 | TFile* fin = TFile::Open(Form("$ALICE_ROOT/PWGLF/FORWARD/corrections/" |
e1f47419 | 858 | "Normalization/normalizationHists_%s_%s.root", |
859 | type.Data(),snn.Data())); | |
860 | if(!fin) { | |
861 | AliWarning(Form("no file for normalization of %d/%d", sys, energy)); | |
862 | return; | |
863 | } | |
3846ec25 | 864 | |
4fa8d795 | 865 | // Shape correction |
866 | if ((fNormalizationScheme & kShape) && !fShapeCorr) { | |
867 | TString trigName("All"); | |
868 | if (fTriggerMask == AliAODForwardMult::kInel || | |
869 | fTriggerMask == AliAODForwardMult::kNClusterGt0) | |
870 | trigName = "Inel"; | |
871 | else if (fTriggerMask == AliAODForwardMult::kNSD) | |
872 | trigName = "NSD"; | |
873 | else if (fTriggerMask == AliAODForwardMult::kInelGt0) | |
874 | trigName = "InelGt0"; | |
875 | else { | |
876 | AliWarning(Form("Normalization for trigger %s not known, using all", | |
877 | AliAODForwardMult::GetTriggerString(fTriggerMask))); | |
878 | } | |
879 | ||
880 | TString shapeCorName(Form("h%sNormalization", trigName.Data())); | |
881 | TH2F* shapeCor = dynamic_cast<TH2F*>(fin->Get(shapeCorName)); | |
882 | if (shapeCor) SetShapeCorrection(shapeCor); | |
883 | else { | |
884 | AliWarning(Form("No shape correction found for %s", trigName.Data())); | |
885 | } | |
886 | } | |
ce85db45 | 887 | |
e1f47419 | 888 | // Trigger efficiency |
889 | TString effName(Form("%sTriggerEff", | |
890 | fTriggerMask == AliAODForwardMult::kInel ? "inel" : | |
891 | fTriggerMask == AliAODForwardMult::kNSD ? "nsd" : | |
892 | fTriggerMask == AliAODForwardMult::kInelGt0 ? | |
893 | "inelgt0" : "all")); | |
241cca4d | 894 | |
895 | Double_t trigEff = 1; | |
896 | if (fNormalizationScheme & kTriggerEfficiency) { | |
897 | TObject* eff = fin->Get(effName); | |
898 | if (eff) AliForwardUtil::GetParameter(eff, trigEff); | |
899 | } | |
4fa8d795 | 900 | if (fTriggerEff != 1) SetTriggerEff(trigEff); |
901 | if (fTriggerEff < 0) fTriggerEff = 1; | |
3846ec25 | 902 | |
66cf95f2 | 903 | // Trigger efficiency |
904 | TString eff0Name(Form("%sTriggerEff0", | |
905 | fTriggerMask == AliAODForwardMult::kInel ? "inel" : | |
906 | fTriggerMask == AliAODForwardMult::kNSD ? "nsd" : | |
907 | fTriggerMask == AliAODForwardMult::kInelGt0 ? | |
908 | "inelgt0" : "all")); | |
909 | ||
910 | Double_t trigEff0 = 1; | |
911 | if (fNormalizationScheme & kTriggerEfficiency) { | |
912 | TObject* eff = fin->Get(eff0Name); | |
913 | if (eff) AliForwardUtil::GetParameter(eff, trigEff0); | |
914 | } | |
915 | if (fTriggerEff0 != 1) SetTriggerEff0(trigEff0); | |
916 | if (fTriggerEff0 < 0) fTriggerEff0 = 1; | |
917 | ||
b30dee70 | 918 | // TEMPORARY FIX |
919 | // Rescale the shape correction by the trigger efficiency | |
4fa8d795 | 920 | if (fShapeCorr) { |
921 | AliWarning(Form("Rescaling shape correction by trigger efficiency: " | |
922 | "1/E_X=1/%f", trigEff)); | |
923 | fShapeCorr->Scale(1. / trigEff); | |
924 | } | |
b30dee70 | 925 | |
e1f47419 | 926 | // Print - out |
4fa8d795 | 927 | if (fShapeCorr && fTriggerEff) AliInfo("Loaded objects for normalization."); |
3846ec25 | 928 | } |
0be6c8cd | 929 | |
930 | ||
931 | //________________________________________________________________________ | |
932 | void | |
933 | AliBasedNdetaTask::Print(Option_t*) const | |
934 | { | |
935 | // | |
936 | // Print information | |
937 | // | |
938 | std::cout << this->ClassName() << ": " << this->GetName() << "\n" | |
939 | << std::boolalpha | |
66cf95f2 | 940 | << " Trigger: " << (fTriggerString ? |
941 | fTriggerString->GetTitle() : | |
942 | "none") << "\n" | |
943 | << " Vertex range: [" << fVtxMin << ":" | |
944 | << fVtxMax << "]\n" | |
945 | << " Rebin factor: " << fRebin << "\n" | |
946 | << " Cut edges: " << fCutEdges << "\n" | |
947 | << " Symmertrice: " << fSymmetrice << "\n" | |
948 | << " Use TH2::ProjectionX: " << fUseROOTProj << "\n" | |
949 | << " Correct for empty: " << fCorrEmpty << "\n" | |
950 | << " Normalization scheme: " << (fSchemeString ? | |
951 | fSchemeString->GetTitle() : | |
0be6c8cd | 952 | "none") <<"\n" |
66cf95f2 | 953 | << " Trigger efficiency: " << fTriggerEff << "\n" |
954 | << " Bin-0 Trigger efficiency: " << fTriggerEff0 << "\n" | |
955 | << " Shape correction: " << (fShapeCorr ? | |
956 | fShapeCorr->GetName() : | |
957 | "none") << "\n" | |
958 | << " sqrt(s_NN): " << (fSNNString ? | |
959 | fSNNString->GetTitle() : | |
960 | "unknown") << "\n" | |
961 | << " Collision system: " << (fSysString ? | |
962 | fSysString->GetTitle() : | |
963 | "unknown") << "\n" | |
964 | << " Centrality bins: " << (fCentAxis ? "" : "none"); | |
0be6c8cd | 965 | if (fCentAxis) { |
966 | Int_t nBins = fCentAxis->GetNbins(); | |
967 | const Double_t* bins = fCentAxis->GetXbins()->GetArray(); | |
968 | for (Int_t i = 0; i <= nBins; i++) | |
969 | std::cout << (i==0 ? "" : "-") << bins[i]; | |
970 | } | |
971 | std::cout << std::noboolalpha << std::endl; | |
972 | ||
973 | } | |
974 | ||
ce85db45 | 975 | //________________________________________________________________________ |
976 | TH1D* | |
e1f47419 | 977 | AliBasedNdetaTask::Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges) |
ce85db45 | 978 | { |
fb3430ac | 979 | // |
980 | // Make a copy of the input histogram and rebin that histogram | |
981 | // | |
982 | // Parameters: | |
983 | // h Histogram to rebin | |
984 | // | |
985 | // Return: | |
986 | // New (rebinned) histogram | |
987 | // | |
e1f47419 | 988 | if (rebin <= 1) return 0; |
ce85db45 | 989 | |
990 | Int_t nBins = h->GetNbinsX(); | |
e1f47419 | 991 | if(nBins % rebin != 0) { |
992 | AliWarningGeneral("AliBasedNdetaTask", | |
993 | Form("Rebin factor %d is not a devisor of current number " | |
994 | "of bins %d in the histogram %s", | |
995 | rebin, nBins, h->GetName())); | |
ce85db45 | 996 | return 0; |
997 | } | |
998 | ||
999 | // Make a copy | |
1000 | TH1D* tmp = static_cast<TH1D*>(h->Clone(Form("%s_rebin%02d", | |
e1f47419 | 1001 | h->GetName(), rebin))); |
1002 | tmp->Rebin(rebin); | |
3d9b0442 | 1003 | tmp->Reset(); |
ce85db45 | 1004 | tmp->SetDirectory(0); |
1005 | ||
1006 | // The new number of bins | |
e1f47419 | 1007 | Int_t nBinsNew = nBins / rebin; |
ce85db45 | 1008 | for(Int_t i = 1;i<= nBinsNew; i++) { |
1009 | Double_t content = 0; | |
1010 | Double_t sumw = 0; | |
1011 | Double_t wsum = 0; | |
1012 | Int_t nbins = 0; | |
e1f47419 | 1013 | for(Int_t j = 1; j<=rebin;j++) { |
1014 | Int_t bin = (i-1)*rebin + j; | |
ce85db45 | 1015 | Double_t c = h->GetBinContent(bin); |
3d9b0442 | 1016 | if (c <= 0) |
1017 | { | |
1018 | content = -1; | |
1019 | break; | |
1020 | } | |
e1f47419 | 1021 | if (cutEdges) { |
ce85db45 | 1022 | if (h->GetBinContent(bin+1)<=0 || |
3846ec25 | 1023 | h->GetBinContent(bin-1)<=0) { |
e1f47419 | 1024 | #if 0 |
1025 | AliWarningGeneral("AliBasedNdetaTask", | |
1026 | Form("removing bin %d=%f of %s (%d=%f,%d=%f)", | |
1027 | bin, c, h->GetName(), | |
1028 | bin+1, h->GetBinContent(bin+1), | |
1029 | bin-1, h->GetBinContent(bin-1))); | |
1030 | #endif | |
ce85db45 | 1031 | continue; |
1032 | } | |
1033 | } | |
1034 | Double_t e = h->GetBinError(bin); | |
1035 | Double_t w = 1 / (e*e); // 1/c/c | |
1036 | content += c; | |
1037 | sumw += w; | |
1038 | wsum += w * c; | |
1039 | nbins++; | |
1040 | } | |
1041 | ||
1042 | if(content > 0 && nbins > 0) { | |
1043 | tmp->SetBinContent(i, wsum / sumw); | |
1044 | tmp->SetBinError(i,1./TMath::Sqrt(sumw)); | |
1045 | } | |
1046 | } | |
1047 | ||
1048 | return tmp; | |
1049 | } | |
1050 | ||
1051 | //__________________________________________________________________ | |
ce85db45 | 1052 | TH1* |
e1f47419 | 1053 | AliBasedNdetaTask::Symmetrice(const TH1* h) |
ce85db45 | 1054 | { |
fb3430ac | 1055 | // |
1056 | // Make an extension of @a h to make it symmetric about 0 | |
1057 | // | |
1058 | // Parameters: | |
1059 | // h Histogram to symmertrice | |
1060 | // | |
1061 | // Return: | |
1062 | // Symmetric extension of @a h | |
1063 | // | |
ce85db45 | 1064 | Int_t nBins = h->GetNbinsX(); |
1065 | TH1* s = static_cast<TH1*>(h->Clone(Form("%s_mirror", h->GetName()))); | |
1066 | s->SetTitle(Form("%s (mirrored)", h->GetTitle())); | |
1067 | s->Reset(); | |
1068 | s->SetBins(nBins, -h->GetXaxis()->GetXmax(), -h->GetXaxis()->GetXmin()); | |
1069 | s->SetMarkerColor(h->GetMarkerColor()); | |
1070 | s->SetMarkerSize(h->GetMarkerSize()); | |
9ecab72f | 1071 | s->SetMarkerStyle(FlipHollowStyle(h->GetMarkerStyle())); |
ce85db45 | 1072 | s->SetFillColor(h->GetFillColor()); |
1073 | s->SetFillStyle(h->GetFillStyle()); | |
1074 | s->SetDirectory(0); | |
1075 | ||
1076 | // Find the first and last bin with data | |
1077 | Int_t first = nBins+1; | |
1078 | Int_t last = 0; | |
1079 | for (Int_t i = 1; i <= nBins; i++) { | |
1080 | if (h->GetBinContent(i) <= 0) continue; | |
1081 | first = TMath::Min(first, i); | |
1082 | last = TMath::Max(last, i); | |
1083 | } | |
1084 | ||
1085 | Double_t xfirst = h->GetBinCenter(first-1); | |
1086 | Int_t f1 = h->GetXaxis()->FindBin(-xfirst); | |
1087 | Int_t l2 = s->GetXaxis()->FindBin(xfirst); | |
1088 | for (Int_t i = f1, j=l2; i <= last; i++,j--) { | |
1089 | s->SetBinContent(j, h->GetBinContent(i)); | |
1090 | s->SetBinError(j, h->GetBinError(i)); | |
1091 | } | |
1092 | // Fill in overlap bin | |
1093 | s->SetBinContent(l2+1, h->GetBinContent(first)); | |
1094 | s->SetBinError(l2+1, h->GetBinError(first)); | |
1095 | return s; | |
1096 | } | |
e1f47419 | 1097 | |
9ecab72f | 1098 | //__________________________________________________________________ |
1099 | Int_t | |
1100 | AliBasedNdetaTask::GetMarkerStyle(UShort_t bits) | |
1101 | { | |
1102 | Int_t base = bits & (0xFE); | |
1103 | Bool_t hollow = bits & kHollow; | |
1104 | switch (base) { | |
1105 | case kCircle: return (hollow ? 24 : 20); | |
1106 | case kSquare: return (hollow ? 25 : 21); | |
1107 | case kUpTriangle: return (hollow ? 26 : 22); | |
1108 | case kDownTriangle: return (hollow ? 32 : 23); | |
1109 | case kDiamond: return (hollow ? 27 : 33); | |
1110 | case kCross: return (hollow ? 28 : 34); | |
1111 | case kStar: return (hollow ? 30 : 29); | |
1112 | } | |
1113 | return 1; | |
1114 | } | |
1115 | //__________________________________________________________________ | |
1116 | UShort_t | |
1117 | AliBasedNdetaTask::GetMarkerBits(Int_t style) | |
1118 | { | |
1119 | UShort_t bits = 0; | |
1120 | switch (style) { | |
1121 | case 24: case 25: case 26: case 27: case 28: case 30: case 32: | |
1122 | bits |= kHollow; break; | |
1123 | } | |
1124 | switch (style) { | |
1125 | case 20: case 24: bits |= kCircle; break; | |
1126 | case 21: case 25: bits |= kSquare; break; | |
1127 | case 22: case 26: bits |= kUpTriangle; break; | |
1128 | case 23: case 32: bits |= kDownTriangle; break; | |
1129 | case 27: case 33: bits |= kDiamond; break; | |
1130 | case 28: case 34: bits |= kCross; break; | |
1131 | case 29: case 30: bits |= kStar; break; | |
1132 | } | |
1133 | return bits; | |
1134 | } | |
1135 | //__________________________________________________________________ | |
1136 | Int_t | |
1137 | AliBasedNdetaTask::FlipHollowStyle(Int_t style) | |
1138 | { | |
1139 | UShort_t bits = GetMarkerBits(style); | |
1140 | Int_t ret = GetMarkerStyle(bits ^ kHollow); | |
1141 | return ret; | |
1142 | } | |
1143 | ||
4fa8d795 | 1144 | //==================================================================== |
1145 | void | |
1146 | AliBasedNdetaTask::Sum::Init(TList* list, const TH2D* data, Int_t col) | |
1147 | { | |
f53fb4f6 | 1148 | DGUARD(fDebug,1,"Initializing sums with %s", data->GetName()); |
4fa8d795 | 1149 | TString n(GetHistName(0)); |
1150 | TString n0(GetHistName(1)); | |
1151 | const char* postfix = GetTitle(); | |
1152 | ||
1153 | fSum = static_cast<TH2D*>(data->Clone(n)); | |
1154 | if (postfix) fSum->SetTitle(Form("%s (%s)", data->GetTitle(), postfix)); | |
1155 | fSum->SetDirectory(0); | |
1156 | fSum->SetMarkerColor(col); | |
9ecab72f | 1157 | fSum->SetMarkerStyle(GetMarkerStyle(kCircle|kSolid)); |
4fa8d795 | 1158 | fSum->Reset(); |
1159 | list->Add(fSum); | |
1160 | ||
1161 | fSum0 = static_cast<TH2D*>(data->Clone(n0)); | |
1162 | if (postfix) | |
1163 | fSum0->SetTitle(Form("%s 0-bin (%s)", data->GetTitle(), postfix)); | |
1164 | else | |
1165 | fSum0->SetTitle(Form("%s 0-bin", data->GetTitle())); | |
1166 | fSum0->SetDirectory(0); | |
1167 | fSum0->SetMarkerColor(col); | |
9ecab72f | 1168 | fSum0->SetMarkerStyle(GetMarkerStyle(kCross|kHollow)); |
4fa8d795 | 1169 | fSum0->Reset(); |
1170 | list->Add(fSum0); | |
1171 | ||
1172 | fEvents = new TH1I(GetHistName(2), "Event types", 2, -.5, 1.5); | |
1173 | fEvents->SetDirectory(0); | |
1174 | fEvents->GetXaxis()->SetBinLabel(1, "Non-zero"); | |
1175 | fEvents->GetXaxis()->SetBinLabel(2, "Zero"); | |
1176 | list->Add(fEvents); | |
1177 | } | |
1178 | ||
1179 | //____________________________________________________________________ | |
1180 | TString | |
f67d699c | 1181 | AliBasedNdetaTask::Sum::GetHistName(const char* name, Int_t what, const char* post) |
4fa8d795 | 1182 | { |
f67d699c | 1183 | TString n(name); |
4fa8d795 | 1184 | if (what == 1) n.Append("0"); |
1185 | else if (what == 2) n.Append("Events"); | |
f67d699c | 1186 | if (post && post[0] != '\0') n.Append(post); |
4fa8d795 | 1187 | return n; |
1188 | } | |
1189 | ||
f67d699c | 1190 | //____________________________________________________________________ |
1191 | TString | |
1192 | AliBasedNdetaTask::Sum::GetHistName(Int_t what) const | |
1193 | { | |
1194 | return GetHistName(GetName(), what, GetTitle()); | |
1195 | } | |
1196 | ||
4fa8d795 | 1197 | //____________________________________________________________________ |
1198 | void | |
1199 | AliBasedNdetaTask::Sum::Add(const TH2D* data, Bool_t isZero) | |
1200 | { | |
f53fb4f6 | 1201 | DGUARD(fDebug,2,"Adding %s to sums", data->GetName()); |
4fa8d795 | 1202 | if (isZero) fSum0->Add(data); |
1203 | else fSum->Add(data); | |
1204 | fEvents->Fill(isZero ? 1 : 0); | |
1205 | } | |
1206 | ||
1207 | //____________________________________________________________________ | |
1208 | TH2D* | |
f67d699c | 1209 | AliBasedNdetaTask::Sum::CalcSum(TList* output, |
1210 | Double_t& ntotal, | |
1211 | Double_t epsilon0, | |
1212 | Double_t epsilon, | |
1213 | Int_t marker, | |
1214 | Bool_t rootProj, | |
1215 | Bool_t corrEmpty) const | |
4fa8d795 | 1216 | { |
f67d699c | 1217 | DGUARD(fDebug,2,"Calculating final summed histogram %s", fSum->GetName()); |
9ecab72f | 1218 | |
f67d699c | 1219 | TH2D* ret = static_cast<TH2D*>(fSum->Clone(fSum->GetName())); |
4fa8d795 | 1220 | ret->SetDirectory(0); |
1221 | ret->Reset(); | |
f67d699c | 1222 | Int_t n = Int_t(fEvents->GetBinContent(1)); |
1223 | Int_t n0 = Int_t(fEvents->GetBinContent(2)); | |
4fa8d795 | 1224 | |
1a7e2e15 | 1225 | AliInfoF("Adding histograms %s(%d) and %s(%d) with weights %f and %f resp.", |
1226 | fSum0->GetName(), n, fSum->GetName(), n0, 1./epsilon, 1./epsilon0); | |
f67d699c | 1227 | DMSG(fDebug,2, "Adding histograms %s and %s with weights %f and %f resp.", |
1228 | fSum0->GetName(), fSum->GetName(), 1./epsilon, 1./epsilon0); | |
4fa8d795 | 1229 | // Generate merged histogram |
f67d699c | 1230 | ret->Add(fSum0, fSum, 1. / epsilon0, 1. / epsilon); |
4fa8d795 | 1231 | ntotal = n / epsilon + n0 / epsilon0; |
1232 | ||
1233 | TList* out = new TList; | |
1234 | out->SetOwner(); | |
1235 | const char* postfix = GetTitle(); | |
1236 | if (!postfix) postfix = ""; | |
1237 | out->SetName(Form("partial%s", postfix)); | |
1238 | output->Add(out); | |
1239 | ||
1240 | // Now make copies, normalize them, and store in output list | |
f67d699c | 1241 | TH2D* sumCopy = static_cast<TH2D*>(fSum->Clone("sum")); |
1242 | TH2D* sum0Copy = static_cast<TH2D*>(fSum0->Clone("sum0")); | |
4fa8d795 | 1243 | TH2D* retCopy = static_cast<TH2D*>(ret->Clone("sumAll")); |
9ecab72f | 1244 | sumCopy->SetMarkerStyle(FlipHollowStyle(marker)); |
4fa8d795 | 1245 | sumCopy->SetDirectory(0); |
9ecab72f | 1246 | sum0Copy->SetMarkerStyle(GetMarkerStyle(GetMarkerBits(marker)+4)); |
4fa8d795 | 1247 | sum0Copy->SetDirectory(0); |
1248 | retCopy->SetMarkerStyle(marker); | |
1249 | retCopy->SetDirectory(0); | |
1250 | ||
5ca83fee | 1251 | Int_t nY = fSum->GetNbinsY(); |
1252 | Int_t o = 0; // nY+1; | |
1253 | TH1D* norm = ProjectX(fSum, "norm", o, o, rootProj, corrEmpty, false); | |
1254 | TH1D* norm0 = ProjectX(fSum0, "norm0", o, o, rootProj, corrEmpty, false); | |
1255 | TH1D* normAll = ProjectX(ret, "normAll", o, o, rootProj, corrEmpty, false); | |
4fa8d795 | 1256 | norm->SetDirectory(0); |
1257 | norm0->SetDirectory(0); | |
1258 | normAll->SetDirectory(0); | |
1259 | ||
1260 | ScaleToCoverage(sumCopy, norm); | |
1261 | ScaleToCoverage(sum0Copy, norm0); | |
1262 | ScaleToCoverage(retCopy, normAll); | |
1263 | ||
4fa8d795 | 1264 | TH1D* sumCopyPx = ProjectX(sumCopy, "average", 1, nY,rootProj,corrEmpty); |
1265 | TH1D* sum0CopyPx = ProjectX(sum0Copy, "average0", 1, nY,rootProj,corrEmpty); | |
1266 | TH1D* retCopyPx = ProjectX(retCopy, "averageAll", 1, nY,rootProj,corrEmpty); | |
1267 | sumCopyPx->SetDirectory(0); | |
1268 | sum0CopyPx->SetDirectory(0); | |
1269 | retCopyPx->SetDirectory(0); | |
1270 | ||
5ca83fee | 1271 | TH1D* phi = ProjectX(fSum, "phi", nY+1, nY+1,rootProj,corrEmpty); |
1272 | TH1D* phi0 = ProjectX(fSum0, "phi0", nY+1, nY+1,rootProj,corrEmpty); | |
1273 | TH1D* phiAll = ProjectX(ret, "phiAll", nY+1, nY+1,rootProj,corrEmpty); | |
1274 | phi->SetDirectory(0); | |
1275 | phi0->SetDirectory(0); | |
1276 | phiAll->SetDirectory(0); | |
1277 | ||
4fa8d795 | 1278 | // Scale our 1D histograms |
1279 | sumCopyPx->Scale(1., "width"); | |
1280 | sum0CopyPx->Scale(1., "width"); | |
1281 | retCopyPx->Scale(1., "width"); | |
1282 | ||
1283 | AliInfo(Form("Maximum %f,%f changed to %f", sumCopyPx->GetMaximum(), | |
1284 | sum0CopyPx->GetMaximum(), retCopyPx->GetMaximum())); | |
1285 | ||
1286 | // Scale the normalization - they should be 1 at the maximum | |
1287 | norm->Scale(n > 0 ? 1. / n : 1); | |
1288 | norm0->Scale(n0 > 0 ? 1. / n0 : 1); | |
1289 | normAll->Scale(ntotal > 0 ? 1. / ntotal : 1); | |
1290 | ||
1291 | out->Add(sumCopy); | |
1292 | out->Add(sum0Copy); | |
1293 | out->Add(retCopy); | |
1294 | out->Add(sumCopyPx); | |
1295 | out->Add(sum0CopyPx); | |
1296 | out->Add(retCopyPx); | |
1297 | out->Add(norm); | |
1298 | out->Add(norm0); | |
1299 | out->Add(normAll); | |
5ca83fee | 1300 | out->Add(phi); |
1301 | out->Add(phi0); | |
1302 | out->Add(phiAll); | |
4fa8d795 | 1303 | |
f67d699c | 1304 | AliInfoF("Returning (1/%f * %s + 1/%f * %s), " |
1305 | "1/%f * %d + 1/%f * %d = %d", | |
1306 | epsilon0, fSum0->GetName(), epsilon, fSum->GetName(), | |
1307 | epsilon0, n0, epsilon, n, int(ntotal)); | |
4fa8d795 | 1308 | #if 0 |
1309 | for (Int_t i = 1; i <= ret->GetNbinsX(); i++) { | |
1310 | Double_t nc = sum->GetBinContent(i, 0); | |
1311 | Double_t nc0 = sum0->GetBinContent(i, 0); | |
1312 | ret->SetBinContent(i, 0, nc + nc0); // Just count events | |
1313 | } | |
1314 | #endif | |
1315 | ||
1316 | return ret; | |
1317 | } | |
1318 | ||
e1f47419 | 1319 | //==================================================================== |
1320 | AliBasedNdetaTask::CentralityBin::CentralityBin() | |
1321 | : TNamed("", ""), | |
1322 | fSums(0), | |
1323 | fOutput(0), | |
1324 | fSum(0), | |
1325 | fSumMC(0), | |
1326 | fTriggers(0), | |
1327 | fLow(0), | |
c89b9ac1 | 1328 | fHigh(0), |
f53fb4f6 | 1329 | fDoFinalMCCorrection(false), |
1330 | fDebug(0) | |
e1f47419 | 1331 | { |
1332 | // | |
1333 | // Constructor | |
1334 | // | |
5ca83fee | 1335 | DGUARD(fDebug,3,"Default CTOR of AliBasedNdeta::CentralityBin"); |
e1f47419 | 1336 | } |
1337 | //____________________________________________________________________ | |
1338 | AliBasedNdetaTask::CentralityBin::CentralityBin(const char* name, | |
1339 | Short_t low, Short_t high) | |
1340 | : TNamed(name, ""), | |
1341 | fSums(0), | |
1342 | fOutput(0), | |
1343 | fSum(0), | |
1344 | fSumMC(0), | |
1345 | fTriggers(0), | |
1346 | fLow(low), | |
c89b9ac1 | 1347 | fHigh(high), |
f53fb4f6 | 1348 | fDoFinalMCCorrection(false), |
1349 | fDebug(0) | |
e1f47419 | 1350 | { |
1351 | // | |
1352 | // Constructor | |
1353 | // | |
1354 | // Parameters: | |
1355 | // name Name used for histograms (e.g., Forward) | |
1356 | // low Lower centrality cut in percent | |
1357 | // high Upper centrality cut in percent | |
1358 | // | |
5ca83fee | 1359 | DGUARD(fDebug,3,"Named CTOR of AliBasedNdeta::CentralityBin: %s [%3d,%3d]", |
1360 | name,low,high); | |
e1f47419 | 1361 | if (low <= 0 && high <= 0) { |
1362 | fLow = 0; | |
1363 | fHigh = 0; | |
1364 | SetTitle("All centralities"); | |
1365 | } | |
1366 | else { | |
1367 | fLow = low; | |
1368 | fHigh = high; | |
1369 | SetTitle(Form("Centrality bin from %3d%% to %3d%%", low, high)); | |
1370 | } | |
1371 | } | |
1372 | //____________________________________________________________________ | |
1373 | AliBasedNdetaTask::CentralityBin::CentralityBin(const CentralityBin& o) | |
1374 | : TNamed(o), | |
1375 | fSums(o.fSums), | |
1376 | fOutput(o.fOutput), | |
1377 | fSum(o.fSum), | |
1378 | fSumMC(o.fSumMC), | |
1379 | fTriggers(o.fTriggers), | |
1380 | fLow(o.fLow), | |
c89b9ac1 | 1381 | fHigh(o.fHigh), |
f53fb4f6 | 1382 | fDoFinalMCCorrection(o.fDoFinalMCCorrection), |
1383 | fDebug(o.fDebug) | |
e1f47419 | 1384 | { |
1385 | // | |
1386 | // Copy constructor | |
1387 | // | |
1388 | // Parameters: | |
1389 | // other Object to copy from | |
1390 | // | |
5ca83fee | 1391 | DGUARD(fDebug,3,"Copy CTOR of AliBasedNdeta::CentralityBin"); |
e1f47419 | 1392 | } |
1393 | //____________________________________________________________________ | |
1394 | AliBasedNdetaTask::CentralityBin::~CentralityBin() | |
1395 | { | |
1396 | // | |
1397 | // Destructor | |
1398 | // | |
5ca83fee | 1399 | DGUARD(fDebug,3,"DTOR of AliBasedNdeta::CentralityBin"); |
1400 | ||
1401 | // if (fSums) fSums->Delete(); | |
1402 | // if (fOutput) fOutput->Delete(); | |
e1f47419 | 1403 | } |
1404 | ||
1405 | //____________________________________________________________________ | |
1406 | AliBasedNdetaTask::CentralityBin& | |
1407 | AliBasedNdetaTask::CentralityBin::operator=(const CentralityBin& o) | |
1408 | { | |
1409 | // | |
1410 | // Assignment operator | |
1411 | // | |
1412 | // Parameters: | |
1413 | // other Object to assign from | |
1414 | // | |
1415 | // Return: | |
1416 | // Reference to this | |
1417 | // | |
f53fb4f6 | 1418 | DGUARD(fDebug,3,"Centrality bin assignment"); |
d015ecfe | 1419 | if (&o == this) return *this; |
e1f47419 | 1420 | SetName(o.GetName()); |
1421 | SetTitle(o.GetTitle()); | |
1422 | fSums = o.fSums; | |
1423 | fOutput = o.fOutput; | |
1424 | fSum = o.fSum; | |
1425 | fSumMC = o.fSumMC; | |
1426 | fTriggers = o.fTriggers; | |
1427 | fLow = o.fLow; | |
1428 | fHigh = o.fHigh; | |
c89b9ac1 | 1429 | fDoFinalMCCorrection = o.fDoFinalMCCorrection; |
e1f47419 | 1430 | |
1431 | return *this; | |
1432 | } | |
1433 | //____________________________________________________________________ | |
5bb5d1f6 | 1434 | Int_t |
9ecab72f | 1435 | AliBasedNdetaTask::CentralityBin::GetColor(Int_t fallback) const |
5bb5d1f6 | 1436 | { |
9ecab72f | 1437 | if (IsAllBin()) return fallback; |
5bb5d1f6 | 1438 | Float_t fc = (fLow+double(fHigh-fLow)/2) / 100; |
1439 | Int_t nCol = gStyle->GetNumberOfColors(); | |
1440 | Int_t icol = TMath::Min(nCol-1,int(fc * nCol + .5)); | |
1441 | Int_t col = gStyle->GetColorPalette(icol); | |
1442 | return col; | |
1443 | } | |
1444 | //____________________________________________________________________ | |
e1f47419 | 1445 | const char* |
1446 | AliBasedNdetaTask::CentralityBin::GetListName() const | |
1447 | { | |
1448 | // | |
1449 | // Get the list name | |
1450 | // | |
1451 | // Return: | |
1452 | // List Name | |
1453 | // | |
1454 | if (IsAllBin()) return "all"; | |
1455 | return Form("cent%03d_%03d", fLow, fHigh); | |
1456 | } | |
1457 | //____________________________________________________________________ | |
1458 | void | |
1a7e2e15 | 1459 | AliBasedNdetaTask::CentralityBin::CreateOutputObjects(TList* dir, Int_t mask) |
e1f47419 | 1460 | { |
1461 | // | |
1462 | // Create output objects | |
1463 | // | |
1464 | // Parameters: | |
1465 | // dir Parent list | |
1466 | // | |
f53fb4f6 | 1467 | DGUARD(fDebug,1,"Create centrality bin output objects"); |
e1f47419 | 1468 | fSums = new TList; |
1469 | fSums->SetName(GetListName()); | |
1470 | fSums->SetOwner(); | |
1471 | dir->Add(fSums); | |
1472 | ||
1a7e2e15 | 1473 | fTriggers = AliAODForwardMult::MakeTriggerHistogram("triggers", mask); |
ffca499d | 1474 | fTriggers->SetDirectory(0); |
e1f47419 | 1475 | fSums->Add(fTriggers); |
1476 | } | |
f53fb4f6 | 1477 | //____________________________________________________________________ |
1478 | void | |
1479 | AliBasedNdetaTask::CentralityBin::SetDebugLevel(Int_t lvl) | |
1480 | { | |
1481 | fDebug = lvl; | |
1482 | if (fSum) fSum->fDebug = lvl; | |
1483 | if (fSumMC) fSumMC->fDebug = lvl; | |
1484 | } | |
1485 | ||
f67d699c | 1486 | //____________________________________________________________________ |
1487 | Bool_t | |
1488 | AliBasedNdetaTask::CentralityBin::ReadSum(TList* list, bool mc) | |
1489 | { | |
1490 | const char* post = (mc ? "MC" : ""); | |
1491 | TString sn = Sum::GetHistName(GetName(),0,post); | |
1492 | TString sn0 = Sum::GetHistName(GetName(),1,post); | |
1493 | TString ev = Sum::GetHistName(GetName(),2,post); | |
1494 | TH2D* sum = static_cast<TH2D*>(list->FindObject(sn)); | |
1495 | TH2D* sum0 = static_cast<TH2D*>(list->FindObject(sn0)); | |
1496 | TH1I* events = static_cast<TH1I*>(list->FindObject(ev)); | |
1497 | if (!sum || !sum0 || !events) { | |
1498 | AliWarningF("Failed to find one or more histograms: " | |
1499 | "%s (%p) %s (%p) %s (%p)", | |
1500 | sn.Data(), sum, | |
1501 | sn0.Data(), sum0, | |
1502 | ev.Data(), events); | |
1503 | return false; | |
1504 | } | |
1505 | Sum* ret = new Sum(GetName(), post); | |
1506 | ret->fSum = sum; | |
1507 | ret->fSum0 = sum0; | |
1508 | ret->fEvents = events; | |
1509 | ret->fDebug = fDebug; | |
1510 | if (mc) fSumMC = ret; | |
1511 | else fSum = ret; | |
1512 | ||
1513 | return true; | |
1514 | } | |
1515 | ||
e1f47419 | 1516 | //____________________________________________________________________ |
1517 | void | |
1518 | AliBasedNdetaTask::CentralityBin::CreateSums(const TH2D* data, const TH2D* mc) | |
1519 | { | |
1520 | // | |
1521 | // Create sum histogram | |
1522 | // | |
1523 | // Parameters: | |
1524 | // data Data histogram to clone | |
1525 | // mc (optional) MC histogram to clone | |
1526 | // | |
f67d699c | 1527 | DGUARD(fDebug,1,"Create centrality bin sums from %s", |
1528 | data ? data->GetName() : "(null)"); | |
9ecab72f | 1529 | if (data) { |
1530 | fSum = new Sum(GetName(),""); | |
1531 | fSum->Init(fSums, data, GetColor()); | |
f53fb4f6 | 1532 | fSum->fDebug = fDebug; |
9ecab72f | 1533 | } |
1534 | ||
e1f47419 | 1535 | // If no MC data is given, then do not create MC sum histogram |
1536 | if (!mc) return; | |
1537 | ||
4fa8d795 | 1538 | fSumMC = new Sum(GetName(), "MC"); |
1539 | fSumMC->Init(fSums, mc, GetColor()); | |
f53fb4f6 | 1540 | fSumMC->fDebug = fDebug; |
e1f47419 | 1541 | } |
1542 | ||
1543 | //____________________________________________________________________ | |
1544 | Bool_t | |
1545 | AliBasedNdetaTask::CentralityBin::CheckEvent(const AliAODForwardMult* forward, | |
1546 | Int_t triggerMask, | |
1547 | Double_t vzMin, Double_t vzMax) | |
1548 | { | |
1549 | // | |
1550 | // Check the trigger, vertex, and centrality | |
1551 | // | |
1552 | // Parameters: | |
1553 | // aod Event input | |
1554 | // | |
1555 | // Return: | |
1556 | // true if the event is to be used | |
1557 | // | |
1558 | if (!forward) return false; | |
e1f47419 | 1559 | |
f53fb4f6 | 1560 | DGUARD(fDebug,2,"Check the event"); |
ffca499d | 1561 | // We do not check for centrality here - it's already done |
1562 | return forward->CheckEvent(triggerMask, vzMin, vzMax, 0, 0, fTriggers); | |
e1f47419 | 1563 | } |
1564 | ||
1565 | ||
1566 | //____________________________________________________________________ | |
1567 | void | |
1568 | AliBasedNdetaTask::CentralityBin::ProcessEvent(const AliAODForwardMult* forward, | |
4fa8d795 | 1569 | Int_t triggerMask, Bool_t isZero, |
e1f47419 | 1570 | Double_t vzMin, Double_t vzMax, |
1571 | const TH2D* data, const TH2D* mc) | |
1572 | { | |
1573 | // | |
1574 | // Process an event | |
1575 | // | |
1576 | // Parameters: | |
1577 | // forward Forward data (for trigger, vertex, & centrality) | |
1578 | // triggerMask Trigger mask | |
1579 | // vzMin Minimum IP z coordinate | |
1580 | // vzMax Maximum IP z coordinate | |
1581 | // data Data histogram | |
1582 | // mc MC histogram | |
1583 | // | |
f53fb4f6 | 1584 | DGUARD(fDebug,1,"Process one event for %s a given centrality bin", |
f67d699c | 1585 | data ? data->GetName() : "(null)"); |
e1f47419 | 1586 | if (!CheckEvent(forward, triggerMask, vzMin, vzMax)) return; |
1587 | if (!data) return; | |
1588 | if (!fSum) CreateSums(data, mc); | |
4fa8d795 | 1589 | |
1590 | fSum->Add(data, isZero); | |
1591 | if (mc) fSumMC->Add(mc, isZero); | |
e1f47419 | 1592 | } |
1593 | ||
1594 | //________________________________________________________________________ | |
b30dee70 | 1595 | Double_t |
1596 | AliBasedNdetaTask::CentralityBin::Normalization(const TH1I& t, | |
1597 | UShort_t scheme, | |
1598 | Double_t trigEff, | |
1a7e2e15 | 1599 | Double_t& ntotal, |
1600 | TString* text) const | |
e1f47419 | 1601 | { |
1602 | // | |
b30dee70 | 1603 | // Calculate normalization |
e1f47419 | 1604 | // |
b30dee70 | 1605 | // Parameters: |
1606 | // t Trigger histogram | |
1607 | // scheme Normaliztion scheme | |
1608 | // trigEff From MC | |
1609 | // ntotal On return, contains the number of events. | |
e1f47419 | 1610 | // |
1a7e2e15 | 1611 | DGUARD(fDebug,1,"Normalize centrality bin %s with %s", |
1612 | GetName(), t.GetName()); | |
0be6c8cd | 1613 | Double_t nAll = t.GetBinContent(AliAODForwardMult::kBinAll); |
1614 | Double_t nB = t.GetBinContent(AliAODForwardMult::kBinB); | |
1615 | Double_t nA = t.GetBinContent(AliAODForwardMult::kBinA); | |
1616 | Double_t nC = t.GetBinContent(AliAODForwardMult::kBinC); | |
1617 | Double_t nE = t.GetBinContent(AliAODForwardMult::kBinE); | |
1618 | Double_t nOffline = t.GetBinContent(AliAODForwardMult::kBinOffline); | |
1619 | Double_t nTriggered = t.GetBinContent(AliAODForwardMult::kWithTrigger); | |
1620 | Double_t nWithVertex = t.GetBinContent(AliAODForwardMult::kWithVertex); | |
66cf95f2 | 1621 | Double_t nAccepted = ntotal; |
4fa8d795 | 1622 | ntotal = 0; |
e1f47419 | 1623 | |
e308a636 | 1624 | if (nTriggered <= 0.1) { |
e1f47419 | 1625 | AliError("Number of triggered events <= 0"); |
b30dee70 | 1626 | return -1; |
e1f47419 | 1627 | } |
e308a636 | 1628 | if (nWithVertex <= 0.1) { |
1629 | AliError("Number of events with vertex <= 0"); | |
b30dee70 | 1630 | return -1; |
e1f47419 | 1631 | } |
b30dee70 | 1632 | ntotal = nAccepted; |
1633 | Double_t vtxEff = nWithVertex / nTriggered; | |
0be6c8cd | 1634 | Double_t scaler = 1; |
0be6c8cd | 1635 | Double_t beta = nA + nC - 2*nE; |
b30dee70 | 1636 | |
1a7e2e15 | 1637 | |
1638 | TString rhs("N = N_acc"); | |
1639 | if (!(scheme & kZeroBin)) { | |
1640 | if (scheme & kEventLevel) { | |
1641 | ntotal = nAccepted / vtxEff; | |
1642 | scaler = vtxEff; | |
1643 | AliInfoF("Calculating event normalisation as\n" | |
1644 | " N = N_A * N_T / N_V = %d * %d / %d = %f (%f)", | |
1645 | Int_t(nAccepted), Int_t(nTriggered), Int_t(nWithVertex), | |
1646 | ntotal, scaler); | |
1647 | if (scheme & kBackground) { | |
1648 | // 1 E_V E_V | |
1649 | // s = --------- = ------------- = ------------ | |
1650 | // 1 - beta 1 - beta E_V 1 - beta N_V | |
1651 | // --- ---- -------- ---- --- | |
1652 | // E_V N_V N_V N_V N_T | |
1653 | // | |
1654 | // E_V | |
1655 | // = ------------ | |
1656 | // 1 - beta | |
1657 | // ---- | |
1658 | // N_T | |
1659 | // | |
1660 | ntotal -= nAccepted * beta / nWithVertex; | |
1661 | // This one is direct and correct. | |
1662 | // scaler = 1. / (1. / vtxEff - beta / nWithVertex); | |
1663 | // A simpler expresion | |
1664 | scaler /= (1 - beta / nTriggered); // 0.831631 -> 0.780689 | |
1665 | AliInfo(Form("Calculating event normalisation as\n" | |
1666 | " beta = N_a + N_c + 2 N_e = %d + %d - 2 * %d = %d\n" | |
1667 | " N = N - N_A * beta / N_V = %f - %d * %d / %d = %f (%f)", | |
1668 | Int_t(nA), Int_t(nC), Int_t(nE), Int_t(beta), | |
1669 | nAccepted / vtxEff, Int_t(nAccepted), Int_t(beta), | |
1670 | Int_t(nWithVertex), ntotal, scaler)); | |
1671 | rhs.Append("(1/eps_V - beta/N_vtx)"); | |
1672 | } // Background | |
1673 | else | |
1674 | rhs.Append("/eps_V"); | |
1675 | } // Event-level | |
1676 | if (scheme & kTriggerEfficiency) { | |
1677 | ntotal /= trigEff; | |
1678 | scaler *= trigEff; | |
1679 | AliInfo(Form("Correcting for trigger efficiency:\n" | |
1680 | " N = 1 / E_X * N = 1 / %f * %d = %f (%f)", | |
1681 | trigEff, Int_t(ntotal), ntotal / trigEff, scaler)); | |
1682 | rhs.Append("/eps_T"); | |
1683 | } // Trigger efficiency | |
1684 | } | |
1685 | else { | |
4fa8d795 | 1686 | // Calculate as |
1687 | // | |
1688 | // N = N_A + 1/E_X * N_A / N_V (N_T - N_V - beta) | |
1689 | // = N_A (1 + 1/E_X (N_T/N_V - 1 - beta / N_V)) | |
1a7e2e15 | 1690 | // = N_A (1 + 1/E_X (1/E_V - 1 - beta / N_V)) |
4fa8d795 | 1691 | // |
1692 | // s = N_A/N = 1 / (1 + 1/E_X (N_T/N_V - 1 - beta / N_V)) | |
1693 | // = N_V / (N_V + 1/E_X (N_T - N_V - beta)) | |
1694 | // | |
1695 | if (!(scheme & kBackground)) beta = 0; | |
1696 | ntotal = nAccepted * (1 + 1/trigEff * (nTriggered / nWithVertex - 1 | |
1697 | - beta / nWithVertex)); | |
1698 | scaler = nWithVertex / (nWithVertex + | |
1699 | 1/trigEff * (nTriggered-nWithVertex-beta)); | |
1700 | AliInfo(Form("Calculating event normalisation as\n" | |
1701 | " beta = N_a + N_c + 2 N_e = %d + %d - 2 * %d = %d\n" | |
1702 | " N = N_A (1 + 1/E_X (N_T/N_V - 1 - beta / N_V)) = " | |
1703 | "%d (1 + 1 / %f (%d / %d - 1 - %d / %d)) = %f (%f)", | |
1704 | Int_t(nA), Int_t(nC), Int_t(nE), Int_t(beta), | |
1705 | Int_t(nAccepted), trigEff, Int_t(nTriggered), | |
1706 | Int_t(nWithVertex), Int_t(beta), Int_t(nWithVertex), | |
1707 | ntotal, scaler)); | |
1a7e2e15 | 1708 | rhs.Append("(1+1/eps_T(1/eps_V-1-beta/N_vtx))"); |
4fa8d795 | 1709 | } |
1a7e2e15 | 1710 | |
1711 | if (text) { | |
1712 | text->Append(Form("%-40s = %d\n", "N_all", UInt_t(nAll))); | |
1713 | text->Append(Form("%-40s = %d\n", "N_acc", UInt_t(nAccepted))); | |
1714 | text->Append(Form("%-40s = %d\n", "N_trg", UInt_t(nTriggered))); | |
1715 | text->Append(Form("%-40s = %d\n", "N_vtx", UInt_t(nWithVertex))); | |
1716 | text->Append(Form("%-40s = %d\n", "N_B", UInt_t(nB))); | |
1717 | text->Append(Form("%-40s = %d\n", "N_A", UInt_t(nA))); | |
1718 | text->Append(Form("%-40s = %d\n", "N_C", UInt_t(nC))); | |
1719 | text->Append(Form("%-40s = %d\n", "N_E", UInt_t(nE))); | |
1720 | text->Append(Form("%-40s = %d\n", "beta = N_A + N_C - 2N_E",UInt_t(beta))); | |
1721 | text->Append(Form("%-40s = %f\n", "eps_V = N_vtx/N_trg",vtxEff)); | |
1722 | text->Append(Form("%-40s = %f\n", "eps_T", trigEff)); | |
1723 | text->Append(Form("%-40s = %f\n", rhs.Data(), ntotal)); | |
ffca499d | 1724 | } |
e308a636 | 1725 | |
0be6c8cd | 1726 | AliInfo(Form("\n" |
1727 | " Total of %9d events for %s\n" | |
1728 | " of these %9d have an offline trigger\n" | |
b30dee70 | 1729 | " of these N_T = %9d has the selected trigger\n" |
0be6c8cd | 1730 | " of these N_V = %9d has a vertex\n" |
b30dee70 | 1731 | " of these N_A = %9d were in the selected range\n" |
0be6c8cd | 1732 | " Triggers by hardware type:\n" |
1733 | " N_b = %9d\n" | |
1734 | " N_ac = %9d (%d+%d)\n" | |
1735 | " N_e = %9d\n" | |
0be6c8cd | 1736 | " Vertex efficiency: %f\n" |
1737 | " Trigger efficiency: %f\n" | |
1738 | " Total number of events: N = %f\n" | |
1a7e2e15 | 1739 | " Scaler (N_A/N): %f\n" |
1740 | " %25s = %f", | |
0be6c8cd | 1741 | Int_t(nAll), GetTitle(), Int_t(nOffline), |
b30dee70 | 1742 | Int_t(nTriggered), Int_t(nWithVertex), Int_t(nAccepted), |
0be6c8cd | 1743 | Int_t(nB), Int_t(nA+nC), Int_t(nA), Int_t(nC), Int_t(nE), |
1a7e2e15 | 1744 | vtxEff, trigEff, ntotal, scaler, rhs.Data(), ntotal)); |
b30dee70 | 1745 | return scaler; |
1746 | } | |
1747 | ||
5bb5d1f6 | 1748 | //________________________________________________________________________ |
1749 | const char* | |
1750 | AliBasedNdetaTask::CentralityBin::GetResultName(Int_t rebin, | |
1751 | Bool_t sym, | |
1752 | const char* postfix) const | |
1753 | { | |
1754 | static TString n; | |
1755 | n = Form("dndeta%s%s",GetName(), postfix); | |
1756 | if (rebin > 1) n.Append(Form("_rebin%02d", rebin)); | |
1757 | if (sym) n.Append("_mirror"); | |
1758 | return n.Data(); | |
1759 | } | |
1760 | //________________________________________________________________________ | |
1761 | TH1* | |
1762 | AliBasedNdetaTask::CentralityBin::GetResult(Int_t rebin, | |
1763 | Bool_t sym, | |
1764 | const char* postfix) const | |
1765 | { | |
1766 | if (!fOutput) { | |
1767 | AliWarning(Form("No output list defined in %s [%3d,%3d]", GetName(), | |
1768 | fLow, fHigh)); | |
1769 | return 0; | |
1770 | } | |
1771 | TString n = GetResultName(rebin, sym, postfix); | |
1772 | TObject* o = fOutput->FindObject(n.Data()); | |
1773 | if (!o) { | |
1774 | // AliWarning(Form("Object %s not found in output list", n.Data())); | |
1775 | return 0; | |
1776 | } | |
1777 | return static_cast<TH1*>(o); | |
1778 | } | |
1779 | ||
c25b5e1b | 1780 | //________________________________________________________________________ |
1781 | void | |
1782 | AliBasedNdetaTask::CentralityBin::MakeResult(const TH2D* sum, | |
1783 | const char* postfix, | |
1784 | bool rootProj, | |
1785 | bool corrEmpty, | |
f67d699c | 1786 | const TH2F* shapeCorr, |
c25b5e1b | 1787 | Double_t scaler, |
1788 | bool symmetrice, | |
1789 | Int_t rebin, | |
1790 | bool cutEdges, | |
9ecab72f | 1791 | Int_t marker, |
c89b9ac1 | 1792 | Int_t color, |
1793 | TList* mclist, | |
1794 | TList* truthlist) | |
c25b5e1b | 1795 | { |
1796 | // | |
1797 | // Generate the dN/deta result from input | |
1798 | // | |
1799 | // Parameters: | |
1800 | // sum Sum of 2D hists | |
1801 | // postfix Post fix on names | |
1802 | // rootProj Whether to use ROOT TH2::ProjectionX | |
1803 | // corrEmpty Correct for empty bins | |
1804 | // shapeCorr Shape correction to use | |
1805 | // scaler Event-level normalization scaler | |
1806 | // symmetrice Whether to make symmetric extensions | |
1807 | // rebin Whether to rebin | |
1808 | // cutEdges Whether to cut edges when rebinning | |
1809 | // | |
f53fb4f6 | 1810 | DGUARD(fDebug,1,"Make centrality bin result from %s", sum->GetName()); |
c25b5e1b | 1811 | TH2D* copy = static_cast<TH2D*>(sum->Clone(Form("d2Ndetadphi%s%s", |
1812 | GetName(), postfix))); | |
5ca83fee | 1813 | Int_t nY = sum->GetNbinsY(); |
1814 | Int_t o = (corrEmpty ? 0 : nY+1); | |
1815 | TH1D* accNorm = ProjectX(sum, Form("norm%s%s",GetName(), postfix), o, o, | |
c25b5e1b | 1816 | rootProj, corrEmpty, false); |
1817 | accNorm->SetDirectory(0); | |
1818 | ||
1819 | // ---- Scale by shape correction ---------------------------------- | |
1820 | if (shapeCorr) copy->Divide(shapeCorr); | |
1821 | else AliInfo("No shape correction specified, or disabled"); | |
1822 | ||
4fa8d795 | 1823 | // --- Normalize to the coverage ----------------------------------- |
5ca83fee | 1824 | if (corrEmpty) { |
1825 | ScaleToCoverage(copy, accNorm); | |
1826 | // --- Event-level normalization --------------------------------- | |
1827 | copy->Scale(scaler); | |
1828 | } | |
c25b5e1b | 1829 | |
1830 | // --- Project on X axis ------------------------------------------- | |
1831 | TH1D* dndeta = ProjectX(copy, Form("dndeta%s%s",GetName(), postfix), | |
5ca83fee | 1832 | 1, nY, rootProj, corrEmpty); |
c25b5e1b | 1833 | dndeta->SetDirectory(0); |
1834 | // Event-level normalization | |
5ca83fee | 1835 | if (!corrEmpty) { |
1836 | ScaleToCoverage(dndeta, accNorm); | |
1837 | dndeta->Scale(scaler); | |
1838 | } | |
c25b5e1b | 1839 | dndeta->Scale(1., "width"); |
1840 | copy->Scale(1., "width"); | |
c89b9ac1 | 1841 | |
1842 | TH1D* dndetaMCCorrection = 0; | |
1843 | TList* centlist = 0; | |
1844 | TH1D* dndetaMCtruth = 0; | |
1845 | TList* truthcentlist = 0; | |
1846 | ||
1847 | // Possible final correction to <MC analysis> / <MC truth> | |
1848 | if(mclist) | |
1849 | centlist = static_cast<TList*> (mclist->FindObject(GetListName())); | |
1850 | if(centlist) | |
66cf95f2 | 1851 | dndetaMCCorrection = |
1852 | static_cast<TH1D*>(centlist->FindObject(Form("dndeta%s%s", | |
1853 | GetName(), postfix))); | |
c89b9ac1 | 1854 | if(truthlist) |
66cf95f2 | 1855 | truthcentlist =static_cast<TList*>(truthlist->FindObject(GetListName())); |
c89b9ac1 | 1856 | if(truthcentlist) |
66cf95f2 | 1857 | dndetaMCtruth =static_cast<TH1D*>(truthcentlist->FindObject("dndetaTruth")); |
1858 | ||
c89b9ac1 | 1859 | if(dndetaMCCorrection && dndetaMCtruth) { |
1860 | AliInfo("Correcting with final MC correction"); | |
1861 | dndetaMCCorrection->Divide(dndetaMCtruth); | |
dd3fe5b6 | 1862 | dndetaMCCorrection->SetTitle("Final MC correction"); |
1863 | dndetaMCCorrection->SetName("finalMCCorr"); | |
66cf95f2 | 1864 | dndeta->Divide(dndetaMCCorrection); |
c89b9ac1 | 1865 | } |
66cf95f2 | 1866 | else |
1867 | AliInfo("No final MC correction applied"); | |
c89b9ac1 | 1868 | |
c25b5e1b | 1869 | // --- Set some histogram attributes ------------------------------- |
5bb5d1f6 | 1870 | TString post; |
9ecab72f | 1871 | Int_t rColor = GetColor(color); |
5bb5d1f6 | 1872 | if (postfix && postfix[0] != '\0') post = Form(" (%s)", postfix); |
9ecab72f | 1873 | SetHistogramAttributes(dndeta, rColor, marker, |
5bb5d1f6 | 1874 | Form("ALICE %s%s", GetName(), post.Data())); |
9ecab72f | 1875 | SetHistogramAttributes(accNorm, rColor, marker, |
5bb5d1f6 | 1876 | Form("ALICE %s normalisation%s", |
1877 | GetName(), post.Data())); | |
c25b5e1b | 1878 | |
1879 | // --- Make symmetric extensions and rebinnings -------------------- | |
1880 | if (symmetrice) fOutput->Add(Symmetrice(dndeta)); | |
1881 | fOutput->Add(dndeta); | |
1882 | fOutput->Add(accNorm); | |
1883 | fOutput->Add(copy); | |
1884 | fOutput->Add(Rebin(dndeta, rebin, cutEdges)); | |
1885 | if (symmetrice) fOutput->Add(Symmetrice(Rebin(dndeta, rebin, cutEdges))); | |
dd3fe5b6 | 1886 | if (dndetaMCCorrection) fOutput->Add(dndetaMCCorrection); |
c25b5e1b | 1887 | } |
1888 | ||
b30dee70 | 1889 | //________________________________________________________________________ |
1890 | void | |
1891 | AliBasedNdetaTask::CentralityBin::End(TList* sums, | |
1892 | TList* results, | |
1893 | UShort_t scheme, | |
f67d699c | 1894 | const TH2F* shapeCorr, |
b30dee70 | 1895 | Double_t trigEff, |
66cf95f2 | 1896 | Double_t trigEff0, |
b30dee70 | 1897 | Bool_t symmetrice, |
1898 | Int_t rebin, | |
c25b5e1b | 1899 | Bool_t rootProj, |
b30dee70 | 1900 | Bool_t corrEmpty, |
1901 | Bool_t cutEdges, | |
1902 | Int_t triggerMask, | |
9ecab72f | 1903 | Int_t marker, |
c89b9ac1 | 1904 | Int_t color, |
1905 | TList* mclist, | |
1906 | TList* truthlist) | |
b30dee70 | 1907 | { |
1908 | // | |
1909 | // End of processing | |
1910 | // | |
1911 | // Parameters: | |
1912 | // sums List of sums | |
1913 | // results Output list of results | |
1914 | // shapeCorr Shape correction or nil | |
1915 | // trigEff Trigger efficiency | |
1916 | // symmetrice Whether to symmetrice the results | |
1917 | // rebin Whether to rebin the results | |
1918 | // corrEmpty Whether to correct for empty bins | |
1919 | // cutEdges Whether to cut edges when rebinning | |
1920 | // triggerMask Trigger mask | |
1921 | // | |
f53fb4f6 | 1922 | DGUARD(fDebug,1,"End centrality bin procesing"); |
b30dee70 | 1923 | |
1924 | fSums = dynamic_cast<TList*>(sums->FindObject(GetListName())); | |
1925 | if(!fSums) { | |
1926 | AliError("Could not retrieve TList fSums"); | |
1927 | return; | |
1928 | } | |
e1f47419 | 1929 | |
b30dee70 | 1930 | fOutput = new TList; |
1931 | fOutput->SetName(GetListName()); | |
1932 | fOutput->SetOwner(); | |
1933 | results->Add(fOutput); | |
1934 | ||
9ecab72f | 1935 | if (!fSum) { |
f67d699c | 1936 | if (!ReadSum(fSums, false)) { |
1937 | AliInfo("This task did not produce any output"); | |
1938 | return; | |
1939 | } | |
9ecab72f | 1940 | } |
f67d699c | 1941 | if (!fSumMC) ReadSum(fSums, true); |
9ecab72f | 1942 | |
b30dee70 | 1943 | fTriggers = static_cast<TH1I*>(fSums->FindObject("triggers")); |
1944 | ||
1945 | if (!fTriggers) { | |
1946 | AliError("Couldn't find histogram 'triggers' in list"); | |
1947 | return; | |
1948 | } | |
b30dee70 | 1949 | |
b30dee70 | 1950 | // --- Get normalization scaler ------------------------------------ |
4fa8d795 | 1951 | Double_t epsilonT = trigEff; |
66cf95f2 | 1952 | Double_t epsilonT0 = trigEff0; |
1953 | AliInfoF("Using epsilonT=%f, epsilonT0=%f for %d", | |
1954 | epsilonT, epsilonT0, triggerMask); | |
1955 | #if 0 | |
b30dee70 | 1956 | // TEMPORARY FIX |
1957 | if (triggerMask == AliAODForwardMult::kNSD) { | |
1958 | // This is a local change | |
c89b9ac1 | 1959 | epsilonT = 0.96; |
b30dee70 | 1960 | AliWarning(Form("Using hard-coded NSD trigger efficiency of %f",epsilonT)); |
1961 | } | |
4fa8d795 | 1962 | else if (triggerMask == AliAODForwardMult::kInel) { |
1963 | // This is a local change | |
c89b9ac1 | 1964 | epsilonT = 0.934; |
4fa8d795 | 1965 | AliWarning(Form("Using hard-coded Inel trigger efficiency of %f",epsilonT)); |
1966 | } | |
1967 | if (scheme & kZeroBin) { | |
1968 | if (triggerMask==AliAODForwardMult::kInel) | |
1969 | epsilonT0 = 0.785021; // 0.100240; | |
1970 | else if (triggerMask==AliAODForwardMult::kInelGt0) | |
1971 | epsilonT0 = 0; | |
1972 | else if (triggerMask==AliAODForwardMult::kNSD) | |
1973 | epsilonT0 = .706587; | |
1974 | epsilonT = 1; | |
1975 | AliWarning(Form("Using hard-coded NCluster>0 trigger efficiency of %f", | |
1976 | epsilonT0)); | |
1977 | } | |
66cf95f2 | 1978 | #endif |
4fa8d795 | 1979 | |
1980 | // Get our histograms | |
1981 | Double_t nSum = 0; | |
66cf95f2 | 1982 | TH2D* sum = fSum->CalcSum(fOutput, nSum, epsilonT0, epsilonT, |
4fa8d795 | 1983 | marker, rootProj, corrEmpty); |
1984 | Double_t nSumMC = 0; | |
1985 | TH2D* sumMC = 0; | |
f67d699c | 1986 | if (fSumMC) sumMC = fSumMC->CalcSum(fOutput, nSumMC, |
66cf95f2 | 1987 | epsilonT0, epsilonT, marker, |
f67d699c | 1988 | rootProj, corrEmpty); |
4fa8d795 | 1989 | if (!sum) { |
1990 | AliError("Failed to get sum from summer - bailing out"); | |
1991 | return; | |
1992 | } | |
1993 | ||
1a7e2e15 | 1994 | TString text; |
4fa8d795 | 1995 | Double_t ntotal = nSum; |
1a7e2e15 | 1996 | Double_t scaler = Normalization(*fTriggers, scheme, epsilonT, ntotal, &text); |
b30dee70 | 1997 | if (scaler < 0) { |
1998 | AliError("Failed to calculate normalization - bailing out"); | |
1999 | return; | |
2000 | } | |
e1f47419 | 2001 | fOutput->Add(fTriggers->Clone()); |
1a7e2e15 | 2002 | fOutput->Add(new TNamed("normCalc", text.Data())); |
c25b5e1b | 2003 | |
2004 | // --- Make result and store --------------------------------------- | |
4fa8d795 | 2005 | MakeResult(sum, "", rootProj, corrEmpty, (scheme & kShape) ? shapeCorr : 0, |
797161e8 | 2006 | scaler, symmetrice, rebin, cutEdges, marker, color, |
2007 | mclist, truthlist); | |
e1f47419 | 2008 | |
b30dee70 | 2009 | // --- Process result from TrackRefs ------------------------------- |
4fa8d795 | 2010 | if (sumMC) |
2011 | MakeResult(sumMC, "MC", rootProj, corrEmpty, | |
c25b5e1b | 2012 | (scheme & kShape) ? shapeCorr : 0, |
4fa8d795 | 2013 | scaler, symmetrice, rebin, cutEdges, |
797161e8 | 2014 | GetMarkerStyle(GetMarkerBits(marker)+4), color, |
2015 | mclist, truthlist); | |
4fa8d795 | 2016 | |
e308a636 | 2017 | // Temporary stuff |
5bb5d1f6 | 2018 | // if (!IsAllBin()) return; |
e308a636 | 2019 | |
e1f47419 | 2020 | } |
8449e3e0 | 2021 | //____________________________________________________________________ |
2022 | Bool_t | |
2023 | AliBasedNdetaTask::ApplyEmpiricalCorrection(const AliAODForwardMult* aod, | |
2024 | TH2D* data) | |
3d9b0442 | 2025 | { |
8449e3e0 | 2026 | if (!fglobalempiricalcorrection || !data) |
2027 | return true; | |
2028 | Float_t zvertex=aod->GetIpZ(); | |
2029 | Int_t binzvertex=fglobalempiricalcorrection->GetXaxis()->FindBin(zvertex); | |
2030 | if(binzvertex<1||binzvertex>fglobalempiricalcorrection->GetNbinsX()) | |
2031 | return false; | |
2032 | for (int i=1;i<=data->GetNbinsX();i++) { | |
2033 | Int_t bincorrection=fglobalempiricalcorrection->GetYaxis() | |
2034 | ->FindBin(data->GetXaxis()->GetBinCenter(i)); | |
2035 | if(bincorrection<1||bincorrection>fglobalempiricalcorrection->GetNbinsY()) | |
2036 | return false; | |
2037 | Float_t correction=fglobalempiricalcorrection | |
2038 | ->GetBinContent(binzvertex,bincorrection); | |
2039 | if(correction<0.001) { | |
2040 | data->SetBinContent(i,0,0); | |
2041 | data->SetBinContent(i,data->GetNbinsY()+1,0); | |
2042 | } | |
2043 | for(int j=1;j<=data->GetNbinsY();j++) { | |
2044 | if (data->GetBinContent(i,j)>0.0) { | |
2045 | data->SetBinContent(i,j,data->GetBinContent(i,j)*correction); | |
2046 | data->SetBinError(i,j,data->GetBinError(i,j)*correction); | |
2047 | } | |
2048 | } | |
2049 | } | |
2050 | return true; | |
3d9b0442 | 2051 | } |
e1f47419 | 2052 | |
fb3430ac | 2053 | // |
2054 | // EOF | |
2055 | // |