10 #include <AliAnalysisManager.h> 11 #include <AliAODEvent.h> 12 #include <AliAODHandler.h> 13 #include <AliAODInputHandler.h> 20 #include <TParameter.h> 38 else if (c < 10)
return 1;
39 else if (c < 20)
return 2;
40 else if (c < 30)
return 3;
41 else if (c < 40)
return 4;
42 else if (c < 50)
return 5;
43 else if (c < 60)
return 6;
44 else if (c < 70)
return 7;
45 else if (c < 80)
return 8;
46 else if (c < 90)
return 9;
60 const Color_t
cc[] = { kMagenta+2,
87 else if (c < 10)
return 1;
88 else if (c < 20)
return 2;
89 else if (c < 40)
return 3;
90 else if (c < 60)
return 4;
91 else if (c < 80)
return 5;
92 else if (c < 100)
return 6;
106 const Color_t
cc[] = { kMagenta+2,
114 Int_t bin = pPbBin(c1,c2);
126 fListOfCentralities(0),
127 fNormalizationScheme(kFull),
128 fFinalMCCorrFile(
""),
129 fSatelliteVertices(0),
130 fEmpiricalCorrection(0),
134 fCentMethod(
"default"),
136 fUseUtilPileup(false),
144 DGUARD(fDebug,3,
"Default CTOR of AliBasedNdetaTask");
172 DGUARD(fDebug, 3,
"Named CTOR of AliBasedNdetaTask: %s", name);
191 DGUARD(fDebug,3,
"Destruction of AliBasedNdetaTask");
198 AliAnalysisTaskSE::SetDebugLevel(lvl);
217 DGUARD(fDebug,3,
"Add a centrality bin [%6.2f,%6.2f] @ %d", low, high, at);
220 Error(
"AddCentralityBin",
221 "Failed to create centrality bin for %s [%6.2f,%6.2f] @ %d",
222 GetName(), low, high, at);
230 else color = pPbColor (low,high);
232 DMSG(fDebug, 3,
"Color of bin %d", color);
253 DGUARD(fDebug,3,
"Make a centrality bin %s [%6.2f,%6.2f]", name, low, high);
257 #define TESTAPPEND(SCHEME,BIT,STRING) \ 258 do { if (!(SCHEME & BIT)) break; \ 259 if (!s.IsNull()) s.Append(","); s.Append(STRING); } while(false) 271 if (scheme ==
kFull) {
289 if (twhat.EqualTo(
"DEFAULT"))
292 TObjArray* token = twhat.Tokenize(
" ,|");
294 while ((opt = static_cast<TObjString*>(next()))) {
296 if (s.IsNull())
continue;
299 case '-': add =
false;
300 case '+': s.Remove(0,1);
303 if (s.EqualTo(
"SHAPE")) {
304 AliWarningGeneral(
"AliBasedNdetaTask",
305 Form(
"SHAPE correction no longer supported (%s)",
310 else if (s.CompareTo(
"BACKGROUND")== 0) bit =
kBackground;
312 else if (s.CompareTo(
"FULL") == 0) bit =
kFull;
313 else if (s.CompareTo(
"NONE") == 0) bit =
kNone;
314 else if (s.CompareTo(
"ZEROBIN") == 0) bit =
kZeroBin;
316 ::Warning(
"SetNormalizationScheme",
"Unknown option %s", s.Data());
317 if (add) scheme |= bit;
330 DGUARD(fDebug,3,
"Set the normalization scheme: %s", what);
337 DGUARD(fDebug,3,
"Set the normalization scheme: 0x%x", scheme);
346 AliErrorF(
"Unknown centrality estimator: %s", method.Data());
352 AliInfoF(
"No centrality estimator: \"%s\"", method.Data());
358 if (fName.Contains(
"Forward", TString::kIgnoreCase) && meth.Contains(
"FMD"))
359 AliWarningF(
"Centrality estimator %s used by %s - beware of auto-corr",
360 meth.Data(), fName.Data());
361 else if (fName.Contains(
"Central", TString::kIgnoreCase) &&
362 (meth.Contains(
"CL0") || meth.Contains(
"TKL")))
363 AliWarningF(
"Centrality estimator %s used by %s - beware of auto-corr",
364 meth.Data(), fName.Data());
367 AliInfoF(
"Centrality estimator set to %s", fCentMethod.Data());
378 if (m.EqualTo(
"NONE") || m.EqualTo(
"NO") || m.EqualTo(
"FALSE"))
385 else if (m.BeginsWith(
"NPA")) ret =
kCentNPA;
386 else if (m.BeginsWith(
"ZPC")) ret =
kCentZPC;
387 else if (m.BeginsWith(
"ZPA")) ret =
kCentZPA;
388 else if (m.BeginsWith(
"ZNC")) ret =
kCentZNC;
389 else if (m.BeginsWith(
"ZNA")) ret =
kCentZNA;
390 else if (m.BeginsWith(
"CND")) ret =
kCentCND;
391 else if (m.BeginsWith(
"CL1")) ret =
kCentCL1;
392 else if (m.BeginsWith(
"CL0")) ret =
kCentCL0;
393 else if (m.BeginsWith(
"TKL")) ret =
kCentTkl;
394 else if (m.BeginsWith(
"TRK")) ret =
kCentTrk;
395 else if (m.BeginsWith(
"FMD")) ret =
kCentFMD;
396 else if (m.BeginsWith(
"V0C")) ret =
kCentV0C;
397 else if (m.BeginsWith(
"V0A123")) ret =
kCentV0A123;
398 else if (m.BeginsWith(
"V0A")) ret =
kCentV0A;
399 else if (m.BeginsWith(
"V0M")) ret =
kCentV0M;
400 else if (m.BeginsWith(
"MULTV0A")) ret =
kMultV0A;
401 else if (m.BeginsWith(
"MULTV0M")) ret =
kMultV0M;
402 else if (m.BeginsWith(
"MULTV0C")) ret =
kMultV0C;
403 else if (m.BeginsWith(
"MULT")) ret =
kMult;
404 if (m.Contains(
"TRUE")) ret |=
kCentTrue;
405 if (m.Contains(
"EQ")) ret |=
kCentEq;
436 case kMult: ret =
"MULT";
break;
437 case kMultV0A: ret =
"MULTV0A";
break;
438 case kMultV0M: ret =
"MULTV0M";
break;
439 case kMultV0C: ret =
"MULTV0C";
break;
440 default: ret =
"";
break;
445 if (!tru) ret.Append(
"eq");
446 else ret.Append(
"Eq");
448 if (tru) ret.Append(
"true");
465 if (
fCentMethod.EqualTo(
"none", TString::kIgnoreCase)) {
469 Info(
"InitializeCentBins",
470 "No centrality, forcing centrality axis to null");
471 h->GetXaxis()->Set(0,0,0);
478 for (
Int_t i = 0; i < nbin; i++)
493 DGUARD(fDebug,1,
"Create user ouput object");
513 while ((bin = static_cast<CentralityBin*>(next())))
525 a.GetSize()-1, a.GetArray());
527 "Integral vs centrality",
528 a.GetSize()-2, a.GetArray());
536 "Integral vs centrality",
544 fMeanVsC =
new TProfile(
"sumVsC",
"Null",1,0,100);
553 fMeanVsC->SetYTitle(
"#LT#int signal#GT");
560 fTakenCent->SetTitle(
"Centralities taken by bins");
601 DGUARD(fDebug,2,
"Getting centrality from event of object: %s",
615 DMSG(fDebug,1,
"Centrality stored in AOD forward: %5.1f%%", cent);
619 if (cent < 0) cent = -.5;
620 else if (TMath::Abs(cent-100) < 1.1) cent = 100;
621 DMSG(fDebug,1,
"Centrality from mult: %5.1f%% (%d)", cent, qual);
648 DGUARD(fDebug,1,
"Analyse the AOD event");
652 if (!forward)
return false;
659 if (!data)
return false;
669 DMSG(fDebug,5,
"IPz=%f -> Weight %f", vtx, ipzW);
689 fMeanVsC->Fill(cent, data->Integral());
692 DMSG(fDebug,1,
"Got event centrality %f (%s)", cent,
695 "out-of-calib" :
"in-calib");
698 DMSG(fDebug,1,
"Centrality %5.2f%% maps to bin %d", cent, icent);
700 TMath::Abs(cent-
fCentAxis.GetXmax()) < 1e-6)
704 if (icent >= 1 && icent <=
fCentAxis.GetNbins())
738 const char*
title,
const char* ytitle)
751 h->SetMarkerColor(colour);
752 h->SetMarkerStyle(marker);
753 h->SetMarkerSize(marker == 29 || marker == 30 ? 1.2 : 1);
756 if (ytitle && ytitle[0] !=
'\0') ytit = ytitle;
757 ytit =
"#frac{1}{#it{N}}#frac{d#it{N}_{ch}}{d#it{#eta}}";
759 h->GetXaxis()->SetTitleFont(132);
760 h->GetXaxis()->SetLabelFont(132);
761 h->GetXaxis()->SetNdivisions(10);
762 h->GetYaxis()->SetTitleFont(132);
763 h->GetYaxis()->SetLabelFont(132);
764 h->GetYaxis()->SetNdivisions(10);
765 h->GetYaxis()->SetDecimals();
775 for (
Int_t i = 1; i <= copy->GetNbinsX(); i++) {
776 Double_t a = norm->GetBinContent(i);
777 for (
Int_t j = 1; j <= copy->GetNbinsY(); j++) {
779 copy->SetBinContent(i,j,0);
780 copy->SetBinError(i,j,0);
783 Double_t c = copy->GetBinContent(i, j);
784 Double_t e = copy->GetBinError(i, j);
785 copy->SetBinContent(i, j, c / a);
786 copy->SetBinError(i, j, e / a);
796 for (
Int_t i = 1; i <= copy->GetNbinsX(); i++) {
797 Double_t a = norm->GetBinContent(i);
799 copy->SetBinContent(i,0);
800 copy->SetBinError(i,0);
803 Double_t c = copy->GetBinContent(i);
805 copy->SetBinContent(i, c / a);
806 copy->SetBinError(i, e / a);
835 return h->ProjectionX(name, firstbin, lastbin, (error ?
"e" :
""));
837 const TAxis* xaxis = h->GetXaxis();
838 const TAxis* yaxis = h->GetYaxis();
839 TH1D* ret =
new TH1D(name, h->GetTitle(), xaxis->GetNbins(),
840 xaxis->GetXmin(), xaxis->GetXmax());
841 static_cast<const TAttLine*
>(h)->Copy(*ret);
842 static_cast<const TAttFill*
>(h)->Copy(*ret);
843 static_cast<const TAttMarker*
>(h)->Copy(*ret);
844 ret->GetXaxis()->ImportAttributes(xaxis);
846 Int_t first = firstbin;
847 Int_t last = lastbin;
848 if (first < 0) first = 1;
849 else if (first >= yaxis->GetNbins()+2) first = yaxis->GetNbins()+1;
850 if (last < 0) last = yaxis->GetNbins();
851 else if (last >= yaxis->GetNbins()+2) last = yaxis->GetNbins()+1;
852 if (last-first < 0) {
853 AliWarningGeneral(
"AliBasedNdetaTask",
854 Form(
"Nothing to project [%d,%d]", first, last));
861 Int_t ybins = (last-first+1);
862 for (
Int_t xbin = 0; xbin <= xaxis->GetNbins()+1; xbin++) {
868 for (
Int_t ybin = first; ybin <= last; ybin++) {
869 Double_t c1 = h->GetBinContent(h->GetBin(xbin, ybin));
870 Double_t e1 = h->GetBinError(h->GetBin(xbin, ybin));
873 if (c1 < 1e-12)
continue;
883 if(content > 0 && nbins > 0) {
886 AliWarningGeneral(ret->GetName(),
887 Form(
"factor @ %d is %d/%d -> %f",
888 xbin, ybins, nbins, factor));
892 ret->SetBinContent(xbin, content * factor);
893 ret->SetBinError(xbin, factor * TMath::Sqrt(error2));
896 ret->SetBinContent(xbin, factor * content);
917 DGUARD(fDebug,1,
"Process final merged results");
933 Info(
"",
"centAxis: %p (%s)", cH, (cH ? cH->ClassName() :
"null"));
935 TAxis* cA = (cH ? cH->GetXaxis() : 0);
949 gStyle->SetPalette(1);
950 THStack* dndetaStack =
new THStack(
"dndeta",
"dN/d#eta");
951 THStack* dndetaMCStack =
new THStack(
"dndetaMC",
"dN_{ch}/d#eta");
952 THStack* dndetaEmpStack =
new THStack(
"dndetaEmp",
"dN_{ch}/d#eta");
953 THStack* leftRightStack =
new THStack(
"leftRight",
"#eta>0/#eta<0");
956 TList* truthlist = 0;
962 mclist =
dynamic_cast<TList*
>(ftest->Get(Form(
"%sResults",GetName())));
963 truthlist =
dynamic_cast<TList*
>(ftest->Get(
"MCTruthResults"));
966 AliWarning(
"MC analysis file invalid - no final MC correction possible");
971 DMSG(fDebug,3,
"Marker style=%d, color=%d", style, color);
972 while ((bin = static_cast<CentralityBin*>(next()))) {
976 style, color, mclist, truthlist))
981 AliWarning(
"Skipping MB bin since we have centrality");
986 AliWarning(
"Skipping 0-100 bin, as we have centrality");
993 TH1* leftRight =
Asymmetry(dndetaEmp ? dndetaEmp : dndeta);
995 DMSG(fDebug,2,
"Results: bare=%p mcbare=%p", dndeta, dndetaMC);
996 if (dndeta) dndetaStack->Add(dndeta);
997 if (dndetaMC) dndetaMCStack->Add(dndetaMC);
998 if (dndetaEmp) dndetaEmpStack->Add(dndetaEmp);
999 if (leftRight) leftRightStack->Add(leftRight);
1005 if (!dndetaMCStack->GetHists() ||
1006 dndetaMCStack->GetHists()->GetEntries() <= 0) {
1008 delete dndetaMCStack;
1011 if (dndetaMCStack)
fResults->Add(dndetaMCStack);
1014 DMSG(0,fDebug,
"Emp stack: %p (%d)", dndetaEmpStack,
1015 dndetaEmpStack->GetHists() && dndetaEmpStack->GetHists()->GetEntries()
1016 ? dndetaEmpStack->GetHists()->GetEntries() : -1);
1017 if (!dndetaEmpStack->GetHists() ||
1018 dndetaEmpStack->GetHists()->GetEntries() <= 0) {
1020 delete dndetaEmpStack;
1023 if (dndetaEmpStack)
fResults->Add(dndetaEmpStack);
1027 if (!leftRightStack->GetHists() ||
1028 leftRightStack->GetHists()->GetEntries() <= 0) {
1030 delete leftRightStack;
1033 if (leftRightStack)
fResults->Add(leftRightStack);
1039 sNNObj->SetUniqueID(sNN);
1047 sysObj->SetUniqueID(sys);
1053 centEstimator->SetUniqueID(centID);
1062 if (tstr.EqualTo(
"MBOR")) tstr =
"INEL";
1063 else if (tstr.EqualTo(
"V0AND")) tstr =
"NSD";
1065 else if (tstr.EqualTo(
"V0AND")) tstr =
"VISX";
1067 maskObj->SetUniqueID(trig);
1075 maskObj->SetUniqueID(filter);
1083 schemeObj->SetUniqueID(scheme);
1089 fIPzAxis.SetTitle(Form(
"v_{z}#in[%+5.1f,%+5.1f]cm",
1101 str.Append(Form(
"Empty bins %scorrected for, ",
fCorrEmpty ?
"" :
"not "));
1102 str.Append(Form(
"TH2::ProjectionX %sused",
fUseROOTProj ?
"" :
"not "));
1103 options->SetTitle(str);
1108 fMeanVsC =
static_cast<TProfile*
>(sumVsC->Clone());
1116 #define PF(N,V,...) \ 1117 AliForwardUtil::PrintField(N,V, ## __VA_ARGS__) 1118 #define PFB(N,FLAG) \ 1120 AliForwardUtil::PrintName(N); \ 1121 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \ 1123 #define PFV(N,VALUE) \ 1125 AliForwardUtil::PrintName(N); \ 1126 std::cout << (VALUE) << std::endl; } while(false) 1129 void appendBit(
TString& str,
const char* bit)
1131 if (!str.IsNull()) str.Append(
"|");
1147 gROOT->IncreaseDirLevel();
1151 PFV(
"Normalization scheme", schemeString );
1162 if (opt.Contains(
"R") &&
1167 while ((bin = next())) bin->Print(option);
1169 gROOT->DecreaseDirLevel();
1176 Int_t base = bits & (0xFE);
1179 case kCircle:
return (hollow ? 24 : 20);
1180 case kSquare:
return (hollow ? 25 : 21);
1183 case kDiamond:
return (hollow ? 27 : 33);
1184 case kCross:
return (hollow ? 28 : 34);
1185 case kStar:
return (hollow ? 30 : 29);
1195 case 24:
case 25:
case 26:
case 27:
case 28:
case 30:
case 32:
1199 case 20:
case 24: bits |=
kCircle;
break;
1200 case 21:
case 25: bits |=
kSquare;
break;
1203 case 27:
case 33: bits |=
kDiamond;
break;
1204 case 28:
case 34: bits |=
kCross;
break;
1205 case 29:
case 30: bits |=
kStar;
break;
1222 DGUARD(fDebug,1,
"Initializing sums with %s", data->GetName());
1225 const char* postfix = GetTitle();
1227 fSum =
static_cast<TH2D*
>(data->Clone(n));
1228 if (postfix) fSum->SetTitle(Form(
"%s (%s)", data->GetTitle(), postfix));
1229 fSum->SetDirectory(0);
1230 fSum->SetMarkerColor(col);
1235 fSum0 =
static_cast<TH2D*
>(data->Clone(n0));
1237 fSum0->SetTitle(Form(
"%s 0-bin (%s)", data->GetTitle(), postfix));
1239 fSum0->SetTitle(Form(
"%s 0-bin", data->GetTitle()));
1240 fSum0->SetDirectory(0);
1241 fSum0->SetMarkerColor(col);
1246 fEvents =
new TH1I(GetHistName(2),
"Event types", 2, -.5, 1.5);
1247 fEvents->SetDirectory(0);
1248 fEvents->SetFillColor(kRed+1);
1249 fEvents->SetFillStyle(3002);
1250 fEvents->GetXaxis()->SetBinLabel(1,
"Non-zero");
1251 fEvents->GetXaxis()->SetBinLabel(2,
"Zero");
1258 Int_t what,
const char* post)
1262 case 0: n =
"sum";
break;
1263 case 1: n =
"sum0";
break;
1264 case 2: n =
"events";
break;
1266 if (post && post[0] !=
'\0') n.Append(post);
1274 return GetHistName(GetName(), what, GetTitle());
1281 DGUARD(fDebug,2,
"Adding %s to sums w/weight %f (%f)",
1282 data->GetName(),weight,data->Integral());
1283 if (isZero) fSum0->Add(data, weight);
1284 else fSum->Add(data, weight);
1285 fEvents->Fill(isZero ? 1 : 0);
1298 DGUARD(fDebug,2,
"Calculating final summed histogram %s", fSum->GetName());
1301 TH2D* ret =
static_cast<TH2D*
>(fSum->Clone(fSum->GetName()));
1302 ret->SetDirectory(0);
1309 "Adding histograms %s(%d) and %s(%d) w/weights %f and %f resp.",
1310 fSum0->GetName(), n, fSum->GetName(), n0, 1./epsilon,1./epsilon0);
1311 ret->Add(fSum0, fSum, 1. / epsilon0, 1. / epsilon);
1312 ntotal = n / epsilon + n0 / epsilon0;
1317 const char* postfix = GetTitle();
1318 if (!postfix) postfix =
"";
1319 out->SetName(Form(
"partial%s", postfix));
1325 TH2D* sumCopy =
static_cast<TH2D*
>(fSum->Clone(
"sum"));
1326 TH2D* sum0Copy =
static_cast<TH2D*
>(fSum0->Clone(
"sum0"));
1327 TH2D* retCopy =
static_cast<TH2D*
>(ret->Clone(
"sumAll"));
1329 sumCopy->SetDirectory(0);
1331 sum0Copy->SetDirectory(0);
1332 retCopy->SetMarkerStyle(marker);
1333 retCopy->SetDirectory(0);
1335 Int_t nY = fSum->GetNbinsY();
1337 TH1D* norm =
ProjectX(fSum,
"norm", o, o, rootProj, corrEmpty,
false);
1338 TH1D* norm0 =
ProjectX(fSum0,
"norm0", o, o, rootProj, corrEmpty,
false);
1339 TH1D* normAll =
ProjectX(ret,
"normAll", o, o, rootProj, corrEmpty,
false);
1340 norm->SetTitle(
"#eta coverage - >0-bin");
1341 norm0->SetTitle(
"#eta coverage - 0-bin");
1342 normAll->SetTitle(
"#eta coverage");
1343 norm->SetDirectory(0);
1344 norm0->SetDirectory(0);
1345 normAll->SetDirectory(0);
1347 TH1D* sumCopyPx =
ProjectX(sumCopy,
"average", 1,nY,rootProj,corrEmpty);
1348 TH1D* sum0CopyPx =
ProjectX(sum0Copy,
"average0", 1,nY,rootProj,corrEmpty);
1349 TH1D* retCopyPx =
ProjectX(retCopy,
"averageAll", 1,nY,rootProj,corrEmpty);
1350 sumCopyPx-> SetTitle(Form(
"#sum_{i}^{N_{#phi}}%s", sumCopy->GetTitle()));
1351 sum0CopyPx->SetTitle(Form(
"#sum_{i}^{N_{#phi}}%s", sum0Copy->GetTitle()));
1352 retCopyPx-> SetTitle(Form(
"#sum_{i}^{N_{#phi}}%s", retCopy->GetTitle()));
1353 sumCopyPx-> SetDirectory(0);
1354 sum0CopyPx->SetDirectory(0);
1355 retCopyPx-> SetDirectory(0);
1357 TH1D* phi =
ProjectX(fSum,
"phi", nY+1,nY+1,rootProj,corrEmpty,
false);
1358 TH1D* phi0 =
ProjectX(fSum0,
"phi0", nY+1,nY+1,rootProj,corrEmpty,
false);
1359 TH1D* phiAll =
ProjectX(ret,
"phiAll", nY+1,nY+1,rootProj,corrEmpty,
false);
1360 phi ->SetTitle(
"#phi acceptance from dead strips - >0-bin");
1361 phi0 ->SetTitle(
"#phi acceptance from dead strips - 0-bin");
1362 phiAll->SetTitle(
"#phi acceptance from dead strips");
1363 phi ->SetDirectory(0);
1364 phi0 ->SetDirectory(0);
1365 phiAll->SetDirectory(0);
1367 const TH1D* cov = (corrEmpty ? norm : phi);
1368 const TH1D* cov0 = (corrEmpty ? norm0 : phi0);
1369 const TH1D* covAll = (corrEmpty ? normAll : phiAll);
1377 sumCopyPx ->Scale(1.,
"width");
1378 sum0CopyPx->Scale(1.,
"width");
1379 retCopyPx ->Scale(1.,
"width");
1381 DMSG(fDebug,2,
"Maximum %f,%f changed to %f", sumCopyPx->GetMaximum(),
1382 sum0CopyPx->GetMaximum(), retCopyPx->GetMaximum());
1385 norm ->Scale(n > 0 ? 1. / n : 1);
1386 norm0 ->Scale(n0 > 0 ? 1. / n0 : 1);
1387 normAll->Scale(ntotal > 0 ? 1. / ntotal : 1);
1390 phi ->Scale(n > 0 ? 1. / n : 1);
1391 phi0 ->Scale(n0 > 0 ? 1. / n0 : 1);
1392 phiAll->Scale(ntotal > 0 ? 1. / ntotal : 1);
1397 out->Add(sumCopyPx);
1398 out->Add(sum0CopyPx);
1399 out->Add(retCopyPx);
1409 DMSG(fDebug,1,
"Returning (1/%f * %s + 1/%f * %s), " 1410 "1/%f * %d + 1/%f * %d = %d",
1411 epsilon0, fSum0->GetName(), epsilon, fSum->GetName(),
1412 epsilon0, n0, epsilon, n, int(ntotal));
1414 DMSG(fDebug,1,
"Returning %s, %d", fSum->GetName(), int(ntotal));
1418 for (
Int_t i = 1; i <= ret->GetNbinsX(); i++) {
1419 Double_t nc = sum->GetBinContent(i, 0);
1420 Double_t nc0 = sum0->GetBinContent(i, 0);
1421 ret->SetBinContent(i, 0, nc + nc0);
1431 PFV(
"dN/deta sum bin", GetName());
1432 gROOT->IncreaseDirLevel();
1433 PF(
"Normal sum",
"%s (%p)", GetHistName(0).
Data(), fSum);
1434 PF(
"0-bin sum",
"%s (%p)", GetHistName(1).
Data(), fSum0);
1435 PF(
"Event count",
"%s (%p)", GetHistName(2).
Data(), fEvents);
1436 gROOT->DecreaseDirLevel();
1450 fDoFinalMCCorrection(false),
1457 DGUARD(
fDebug,3,
"Default CTOR of AliBasedNdeta::CentralityBin");
1459 #define TRUNC(X) (Int_t(X) + Float_t(Int_t(X*100)%100)/100) 1485 DGUARD(
fDebug,3,
"Named CTOR of AliBasedNdeta::CentralityBin: " 1487 if (low <= 0 && high <= 0) {
1490 SetTitle(
"All centralities");
1495 SetTitle(Form(
"Centrality bin from %6.2f%% to %6.2f%%", low, high));
1519 DGUARD(
fDebug,3,
"Copy CTOR of AliBasedNdeta::CentralityBin");
1527 DGUARD(
fDebug,3,
"DTOR of AliBasedNdeta::CentralityBin");
1547 if (&o ==
this)
return *
this;
1548 SetName(o.GetName());
1549 SetTitle(o.GetTitle());
1565 Color_t Brighten(Color_t origNum,
Int_t nTimes=2)
1567 TColor* col = gROOT->GetColor(origNum);
1568 if (!col)
return origNum;
1572 Int_t off = nTimes*0x33;
1573 Int_t newR = TMath::Min((origR+off),0xff);
1574 Int_t newG = TMath::Min((origG+off),0xff);
1575 Int_t newB = TMath::Min((origB+off),0xff);
1576 Int_t newNum = TColor::GetColor(newR, newG, newB);
1589 Int_t nCol = gStyle->GetNumberOfColors();
1590 Int_t icol = TMath::Min(nCol-1,
int(fc * nCol + .5));
1591 Int_t col = gStyle->GetColorPalette(icol);
1594 col = Brighten(orig);
1611 return Form(
"cent%03dd%02d_%03dd%02d",
1626 DGUARD(
fDebug,1,
"Create centrality bin output objects");
1657 const char* post = (mc ?
"MC" :
"");
1661 TH2D* sum =
static_cast<TH2D*
>(list->FindObject(sn));
1662 TH2D* sum0 =
static_cast<TH2D*
>(list->FindObject(sn0));
1663 TH1I* events =
static_cast<TH1I*
>(list->FindObject(ev));
1664 if (!sum || !sum0 || !events) {
1666 AliWarningF(
"Failed to find one or more histograms: " 1667 "%s (%p) %s (%p) %s (%p)",
1673 Sum* ret =
new Sum(GetName(), post);
1696 data ? data->GetName() :
"(null)");
1728 if (!forward)
return false;
1731 "IPz: %f < %f < %f Trigger: 0x%08x (masked 0x%08x vetoed 0x%08x)",
1732 vzMin, forward->
GetIpZ(), vzMax,
1739 DMSG(
fDebug, 2,
"%s", (ret ?
"Accepted" :
"Rejected"));
1768 DGUARD(
fDebug,1,
"Process one event for %s a given centrality bin " 1769 "[%5.1f%%,%5.1f%%) w/weight %f",
1770 data ? data->GetName() :
"(null)",
fLow,
fHigh, weight);
1771 if (!
CheckEvent(forward, triggerMask, vzMin, vzMax, filter))
1773 if (!data)
return false;
1776 fSum->
Add(data, isZero, weight);
1777 if (mc)
fSumMC->
Add(mc, isZero, weight);
1799 DGUARD(
fDebug,1,
"Normalize centrality bin %s [%6.2f-%6.2f%%] with %s",
1812 if (nTriggered <= 0.1) {
1813 AliError(
"Number of triggered events <= 0");
1816 if (nWithVertex <= 0.1) {
1817 AliError(
"Number of events with vertex <= 0");
1821 Double_t vtxEff = nWithVertex / nTriggered;
1829 ntotal = nAccepted / vtxEff;
1831 DMSG(
fDebug,0,
"Calculating event normalisation as\n" 1832 " N = N_A * N_T / N_V = %d * %d / %d = %f (%f)",
1848 ntotal -= nAccepted * beta / nWithVertex;
1852 scaler /= (1 - beta / nTriggered);
1853 DMSG(
fDebug,0,
"Calculating event normalisation as\n" 1854 " beta = N_a + N_c + 2 N_e = %d + %d - 2 * %d = %d\n" 1855 " N = N - N_A * beta / N_V = %f - %d * %d / %d = %f (%f)",
1857 nAccepted / vtxEff,
Int_t(nAccepted),
Int_t(beta),
1858 Int_t(nWithVertex), ntotal, scaler);
1859 rhs.Append(
"(1/eps_V - beta/N_vtx)");
1862 rhs.Append(
"/eps_V");
1868 DMSG(
fDebug,0,
"Correcting for trigger efficiency:\n" 1869 " N = 1 / E_X * N = 1 / %f * %d = %f (%f)",
1870 trigEff, old, ntotal, scaler);
1871 rhs.Append(
"/eps_T");
1885 ntotal = nAccepted * (1 + 1/trigEff * (nTriggered / nWithVertex - 1
1886 - beta / nWithVertex));
1887 scaler = nWithVertex / (nWithVertex +
1888 1/trigEff * (nTriggered-nWithVertex-beta));
1889 DMSG(
fDebug,0,
"Calculating event normalisation as\n" 1890 " beta = N_a + N_c + 2 N_e = %d + %d - 2 * %d = %d\n" 1891 " N = N_A (1 + 1/E_X (N_T/N_V - 1 - beta / N_V)) = " 1892 "%d (1 + 1 / %f (%d / %d - 1 - %d / %d)) = %f (%f)",
1894 Int_t(nAccepted), trigEff,
Int_t(nTriggered),
1897 rhs.Append(
"(1+1/eps_T(1/eps_V-1-beta/N_vtx))");
1901 text->Append(Form(
"%-40s = %d\n",
"N_all",
UInt_t(nAll)));
1902 text->Append(Form(
"%-40s = %d\n",
"N_acc",
UInt_t(nAccepted)));
1903 text->Append(Form(
"%-40s = %d\n",
"N_trg",
UInt_t(nTriggered)));
1904 text->Append(Form(
"%-40s = %d\n",
"N_vtx",
UInt_t(nWithVertex)));
1905 text->Append(Form(
"%-40s = %d\n",
"N_B",
UInt_t(nB)));
1906 text->Append(Form(
"%-40s = %d\n",
"N_A",
UInt_t(nA)));
1907 text->Append(Form(
"%-40s = %d\n",
"N_C",
UInt_t(nC)));
1908 text->Append(Form(
"%-40s = %d\n",
"N_E",
UInt_t(nE)));
1909 text->Append(Form(
"%-40s = %d\n",
"beta = N_A + N_C - 2N_E",
UInt_t(beta)));
1910 text->Append(Form(
"%-40s = %f\n",
"eps_V = N_vtx/N_trg",vtxEff));
1911 text->Append(Form(
"%-40s = %f\n",
"eps_T", trigEff));
1912 text->Append(Form(
"%-40s = %f\n", rhs.Data(), ntotal));
1915 tN.ReplaceAll(
"w/Selected trigger (",
"");
1916 tN.ReplaceAll(
")",
"");
1918 " Total of %9d events for %s\n" 1919 " of these %9d have an offline trigger\n" 1920 " of these N_T = %9d has the selected trigger (%s)\n" 1921 " of these N_V = %9d has a vertex\n" 1922 " of these N_A = %9d were in the selected range",
1923 Int_t(nAll), GetTitle(),
1925 Int_t(nTriggered), tN.Data(),
1929 " Triggers by hardware type:\n" 1931 " N_ac = %9d (%d+%d)\n" 1933 " Vertex efficiency: %f\n" 1934 " Trigger efficiency: %f\n" 1935 " Total number of events: N = %f\n" 1936 " Scaler (N_A/N): %f\n" 1945 rhs.Data(), ntotal);
1955 n.ReplaceAll(
"dNdeta",
"");
1956 n.Prepend(
"dndeta");
1966 AliWarningF(
"No output list defined in %s [%6.2f,%6.2f]", GetName(),
1974 AliWarningF(
"Object %s not found in output list of %s",
1975 n.Data(), GetName());
1978 return static_cast<TH1*
>(o);
1984 const char* postfix,
2003 DGUARD(
fDebug,1,
"Make centrality bin result from %s", sum->GetName());
2005 base.ReplaceAll(
"dNdeta",
"");
2006 base.Append(postfix);
2007 TH2D* copy =
static_cast<TH2D*
>(sum->Clone(Form(
"d2Ndetadphi%s",
2011 Int_t nY = sum->GetNbinsY();
2022 Int_t o = (corrEmpty ? 0 : nY+1);
2023 accNorm =
ProjectX(sum, Form(
"norm%s",base.Data()), o, o,
2024 rootProj, corrEmpty,
false);
2025 accNorm->SetDirectory(0);
2031 copy->Scale(scaler);
2035 TH1D* dndeta =
ProjectX(copy, Form(
"dndeta%s",base.Data()),
2036 1, nY, rootProj, corrEmpty);
2037 dndeta->SetDirectory(0);
2041 dndeta->Scale(scaler);
2043 dndeta->Scale(1.,
"width");
2044 copy->Scale(1.,
"width");
2046 TH1D* dndetaMCCorrection = 0;
2047 TH1D* dndetaMCtruth = 0;
2048 TList* centlist = 0;
2049 TList* truthcentlist = 0;
2057 dndetaMCCorrection =
2058 static_cast<TH1D*
>(centlist->FindObject(Form(
"dndeta%s%s",
2067 static_cast<TH1D*
>(truthcentlist->FindObject(Form(
"dndetaMCTruth%s",
2071 if (dndetaMCCorrection && dndetaMCtruth) {
2072 AliInfo(
"Correcting with final MC correction");
2073 TString testString(dndetaMCCorrection->GetName());
2076 dndetaMCCorrection->Divide(dndetaMCtruth);
2077 dndetaMCCorrection->SetTitle(
"Final MC correction");
2078 dndetaMCCorrection->SetName(
"finalMCCorr");
2079 for(
Int_t m = 1; m <= dndetaMCCorrection->GetNbinsX(); m++) {
2080 if(dndetaMCCorrection->GetBinContent(m) < 0.5 ||
2081 dndetaMCCorrection->GetBinContent(m) > 1.75) {
2082 dndetaMCCorrection->SetBinContent(m,1.);
2083 dndetaMCCorrection->SetBinError(m,0.1);
2090 dndeta->Divide(dndetaMCCorrection);
2094 for(
Int_t m = 1; m <= dndeta->GetNbinsX(); m++) {
2095 if(dndeta->GetBinContent(m) <= 0.01 )
continue;
2097 Double_t eta = dndeta->GetXaxis()->GetBinCenter(m);
2098 Int_t bin = dndetaMCCorrection->GetXaxis()->FindBin(eta);
2099 Double_t mccorr = dndetaMCCorrection->GetBinContent(bin);
2100 Double_t mcerror = dndetaMCCorrection->GetBinError(bin);
2101 if (mccorr < 1e-6) {
2102 dndeta->SetBinContent(m, 0);
2103 dndeta->SetBinError(m, 0);
2105 Double_t value = dndeta->GetBinContent(m);
2106 Double_t error = dndeta->GetBinError(m);
2107 Double_t sumw2 = (error * error * mccorr * mccorr +
2108 mcerror * mcerror * value * value);
2109 dndeta->SetBinContent(m,value/mccorr) ;
2110 dndeta->SetBinError(m,TMath::Sqrt(sumw2)/mccorr/mccorr);
2115 DMSG(
fDebug,1,
"No final MC correction applied");
2120 if (postfix && postfix[0] !=
'\0') post = Form(
" (%s)", postfix);
2122 Form(
"ALICE %s%s", GetName(), post.Data()));
2124 Form(
"ALICE %s normalisation%s",
2125 GetName(), post.Data()));
2131 if (dndetaMCCorrection)
fOutput->Add(dndetaMCCorrection);
2137 for (
Int_t nn=1; nn <= sum->GetNbinsY(); nn++) {
2138 TH1D* dndeta_phi =
ProjectX(copy, Form(
"dndeta%s_phibin%d",
2140 nn, nn, rootProj, corrEmpty);
2141 dndeta_phi->SetDirectory(0);
2143 dndeta_phi->Scale(TMath::Pi()/10.,
"width");
2146 dndetaMCCorrection =
2147 static_cast<TH1D*
>(centlist->FindObject(Form(
"dndeta%s_phibin%d",
2151 =
static_cast<TH1D*
>(truthcentlist->FindObject(
"dndetaMCTruth"));
2153 if (dndetaMCCorrection && dndetaMCtruth) {
2154 AliInfo(
"Correcting with final MC correction");
2155 TString testString(dndetaMCCorrection->GetName());
2156 dndetaMCCorrection->Divide(dndetaMCtruth);
2157 dndetaMCCorrection->SetTitle(Form(
"Final_MC_correction_phibin%d",nn));
2158 dndetaMCCorrection->SetName(Form(
"Final_MC_correction_phibin%d",nn));
2159 for(
Int_t m = 1; m <= dndetaMCCorrection->GetNbinsX(); m++) {
2160 if(dndetaMCCorrection->GetBinContent(m) < 0.25 ||
2161 dndetaMCCorrection->GetBinContent(m) > 1.75) {
2162 dndetaMCCorrection->SetBinContent(m,1.);
2163 dndetaMCCorrection->SetBinError(m,0.1);
2167 dndeta_phi->Divide(dndetaMCCorrection);
2170 if(dndetaMCCorrection)
fOutput->Add(dndetaMCCorrection);
2204 AliErrorF(
"Could not retrieve TList fSums: %s",
GetListName());
2216 AliInfo(
"This task did not produce any output");
2225 AliError(
"Couldn't find histogram 'triggers' in list");
2232 DMSG(
fDebug,2,
"Using epsilonT=%f, epsilonT0=%f for 0x%x",
2233 epsilonT, epsilonT0, triggerMask);
2238 marker, rootProj, corrEmpty);
2242 epsilonT0, epsilonT, marker,
2243 rootProj, corrEmpty);
2245 AliError(
"Failed to get sum from summer - bailing out");
2253 AliError(
"Failed to calculate normalization - bailing out");
2262 MakeResult(sum,
"", rootProj, corrEmpty, scaler, marker, color,
2267 MakeResult(sumMC,
"MC", rootProj, corrEmpty, scaler,
2280 PFV(
"Centrality bin", GetTitle());
2281 gROOT->IncreaseDirLevel();
2289 if (opt.Contains(
"R")) {
2294 gROOT->DecreaseDirLevel();
2308 for (
int i=1;i<=data->GetNbinsX();i++) {
2310 ->FindBin(data->GetXaxis()->GetBinCenter(i));
2314 ->GetBinContent(binzvertex,bincorrection);
2315 if(correction<0.001) {
2316 data->SetBinContent(i,0,0);
2317 data->SetBinContent(i,data->GetNbinsY()+1,0);
2319 for(
int j=1;j<=data->GetNbinsY();j++) {
2320 if (data->GetBinContent(i,j)>0.0) {
2321 data->SetBinContent(i,j,data->GetBinContent(i,j)*correction);
2322 data->SetBinError(i,j,data->GetBinError(i,j)*correction);
2335 TH1* ret =
static_cast<TH1*
>(h->Clone(Form(
"%s_leftright", h->GetName())));
2342 ret->SetDirectory(0);
2344 ret->SetTitle(Form(
"%s (+/-)", h->GetTitle()));
2345 ret->SetYTitle(
"Right/Left");
2346 Int_t nBins = h->GetNbinsX();
2347 for (
Int_t i = 1; i <= nBins; i++) {
2353 if (c1 <= 0)
continue;
2355 Int_t j = h->FindBin(-x);
2356 if (j <= 0 || j > nBins)
continue;
2361 Double_t e = TMath::Sqrt((e2*e2*c1*c1+e1*e1*c2*c2)/(c12*c12));
2362 Int_t k = ret->FindBin(x);
2363 ret->SetBinContent(k, c2/c1);
2364 ret->SetBinError(k, e);
2366 TF1* fit =
new TF1(
"fit",
"pol0");
2367 ret->Fit(fit,
"QN+");
2370 TLatex* ltx =
new TLatex(-1, fit->GetParameter(0),
2371 Form(
"%6.4f#pm%6.4f #chi^{2}/#nu=%5.2f",
2372 fit->GetParameter(0),
2373 fit->GetParError(0),
2374 fit->GetChisquare()/fit->GetNDF()));
2375 ltx->SetTextColor(ret->GetMarkerColor());
2376 ltx->SetTextAlign(12);
2377 if (!ret->GetListOfFunctions()->FindObject(fit))
2378 ret->GetListOfFunctions()->Add(fit);
2379 ret->GetListOfFunctions()->Add(ltx);
Int_t color[]
print message on plot with ok/not ok
virtual Bool_t CheckEvent(const AliAODForwardMult &forward)
const char * GetResultName(const char *postfix="") const
void Print(Option_t *option="R") const
static void ScaleToCoverage(TH2D *copy, const TH1D *norm)
void SetTriggerBits(UInt_t bits)
static const char * CenterOfMassEnergyString(UShort_t cms)
static UShort_t ParseNormalizationScheme(const Char_t *what)
TH2D * fEmpiricalCorrection
UShort_t fNormalizationScheme
Double_t GetCentrality(AliAODEvent &event, AliAODForwardMult *forward, Int_t &qual)
virtual Bool_t Event(AliAODEvent &aod)
static TH1I * MakeTriggerHistogram(const char *name="triggers", UInt_t mask=0)
virtual void InitializeCentBins()
#define DMSG(L, N, F,...)
static TH1 * Asymmetry(TH1 *h)
TH2D * CalcSum(TList *o, Double_t &ntotal, Double_t zeroEff, Double_t otherEff=1, Int_t marker=20, Bool_t rootXproj=false, Bool_t corrEmpty=true) const
virtual void MakeResult(const TH2D *sum, const char *postfix, bool rootProj, bool corrEmpty, Double_t scaler, Int_t marker, Int_t color, TList *mclist, TList *truthlist)
virtual void CheckEventData(Double_t vtx, TH2 *data, TH2 *mcData)
virtual void SetDebugLevel(Int_t level)
virtual bool End(TList *sums, TList *results, UShort_t scheme, Double_t trigEff, Double_t trigEff0, Bool_t rootProj, Bool_t corrEmpty, Int_t triggerMask, Int_t marker, Int_t color, TList *mclist, TList *truthlist)
virtual void Print(Option_t *option="") const
void SetIPzAxis(Int_t n, Double_t min, Double_t max)
virtual ~AliBasedNdetaTask()
TLatex * text[5]
option to what and if export to output file
static Int_t GetMarkerStyle(UShort_t bits)
static Int_t FlipHollowStyle(Int_t style)
virtual Bool_t Finalize()
AliAnalysisUtils fAnaUtil
void SetNormalizationScheme(UShort_t scheme)
void Init(TList *list, const TH2D *data, Int_t col)
static Bool_t IsTriggerBits(UInt_t bits, UInt_t trg)
virtual Bool_t CheckEvent(const AliAODForwardMult *forward, Int_t triggerMask, Double_t vzMin, Double_t vzMax, Int_t filter)
Various utilities used in PWGLF/FORWARD.
Bool_t fSatelliteVertices
Bool_t IsInclusiveBin() const
static void GetParameter(TObject *o, UShort_t &value)
void Print(Option_t *option="") const
void SetDebugLevel(Int_t lvl)
virtual Int_t GetColor() const
virtual void CreateSums(const TH2D *data, const TH2D *mc)
virtual Bool_t ProcessEvent(const AliAODForwardMult *forward, UInt_t triggerMask, Bool_t isZero, Double_t vzMin, Double_t vzMax, const TH2D *data, const TH2D *mc, UInt_t filter, Double_t weight)
void SetColor(Color_t colour)
Bool_t fDoFinalMCCorrection
TObjArray * fListOfCentralities
static const Char_t * GetTriggerString(UInt_t mask, const char *sep="&")
#define DGUARD(L, N, F,...)
const char * GetListName() const
CentralityBin & operator=(const CentralityBin &other)
static Int_t GetCentMethodID(const TString &meth)
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
static const char * GetCentMethod(UShort_t id)
virtual CentralityBin * MakeCentralityBin(const char *name, Float_t low, Float_t high) const
static TObject * MakeParameter(const char *name, UShort_t value)
void SetSatelliteVertices(Bool_t satVtx)
virtual TH2D * GetHistogram(const AliAODEvent &aod, Bool_t mc=false)=0
static TH1I * MakeStatusHistogram(const char *name="status")
virtual Bool_t ReadSum(TList *list, bool mc=false)
void AddCentralityBin(UShort_t at, Float_t low, Float_t high)
Bool_t ApplyEmpiricalCorrection(const AliAODForwardMult *aod, TH2D *data)
TH1 * GetResult(const char *postfix="", Bool_t verbose=true) const
static Float_t GetCentrality(const AliVEvent &event, const TString &method, Int_t &qual, Bool_t verbose=false)
static TH1D * ProjectX(const TH2D *h, const char *name, Int_t firstbin, Int_t lastbin, bool useROOT=false, bool corr=true, bool error=true)
void Add(const TH2D *data, Bool_t isZero, Double_t weight)
AliAODForwardMult * GetForward(const AliAODEvent &aod, Bool_t mc=false, Bool_t verb=true)
UInt_t GetTriggerBits() const
Bool_t fSatelliteVertices
virtual Bool_t CheckEvent(const AliAODForwardMult &forward)
static TString GetHistName(const char *name, Int_t what=0, const char *post=0)
#define TESTAPPEND(SCHEME, BIT, STRING)
static const char * CollisionSystemString(UShort_t sys)
virtual void CreateOutputObjects(TList *dir, Int_t mask)
virtual Int_t GetMarker() const
virtual Double_t GetCentrality(AliAODEvent &event, AliAODForwardMult *forward, Int_t &qual)
virtual void Print(Option_t *option="") const
Bool_t CheckEvent(UInt_t triggerMask=kInel, Double_t vzMin=-10, Double_t vzMax=10, Double_t cMin=0, Double_t cMax=100, TH1 *hist=0, TH1 *status=0, UInt_t filterMask=kDefaultFilter) const
Int_t GetColor(Int_t fallback=kRed+2) const
static UShort_t GetMarkerBits(Int_t style)
Bool_t HasCentrality() const
Bool_t SetCentralityMethod(const TString &method)
static const Char_t * NormalizationSchemeString(UShort_t scheme)
virtual Double_t Normalization(const TH1I &t, UShort_t scheme, Double_t trgEff, Double_t &ntotal, TString *text) const
static void SetHistogramAttributes(TH1D *h, Int_t colour, Int_t marker, const char *title, const char *ytitle=0)