10 # include <TFitResult.h>
13 # include <THashList.h>
35 const Color_t
cc[] = { kMagenta+2,
61 TObject*
GetO(TSeqCollection* l,
const char* name, TClass* cls)
64 Warning(
"GetO",
"No list passed");
67 TObject* o = l->FindObject(name);
69 Warning(
"GetO",
"No object named %s found in list %s",
75 if (!o->IsA()->InheritsFrom(cls)) {
76 Warning(
"GetO",
"Object %s read from %s is not a %s but a %s",
77 name, l->GetName(), cls->GetName(), o->ClassName());
83 TObject*
CopyO(TSeqCollection* l,
const char* name,
const char* newName,
88 TObject* copy = orig->Clone(newName ? newName : name);
102 return static_cast<TH1*
>(
GetO(l,name,TH1::Class()));
115 return static_cast<TH2*
>(
GetO(l,name,TH2::Class()));
127 TH1*
CopyH1(TSeqCollection* l,
const char* name,
const char* newName=0)
129 TH1* copy =
static_cast<TH1*
>(
CopyO(l,name,newName,TH1::Class()));
130 if (copy) copy->SetDirectory(0);
143 TH2*
CopyH2(TSeqCollection* l,
const char* name,
const char* newName=0)
145 TH2* copy =
static_cast<TH2*
>(
CopyO(l,name,newName,TH2::Class()));
146 if (copy) copy->SetDirectory(0);
169 if (a1->GetNbins() != a2->GetNbins()) {
170 ::Warning(
"CheckAxisNBins",
"Incompatible number %s bins: %d vs %d",
171 which, a1->GetNbins(), a2->GetNbins());
190 if (!TMath::AreEqualRel(a1->GetXmin(), a2->GetXmin(),1.E-12) ||
191 !TMath::AreEqualRel(a1->GetXmax(), a2->GetXmax(),1.E-12)) {
192 Warning(
"CheckAxisLimits",
193 "Limits of %s axis incompatible [%f,%f] vs [%f,%f]", which,
194 a1->GetXmin(), a1->GetXmax(), a2->GetXmin(), a2->GetXmax());
213 const TArrayD * h1Array = a1->GetXbins();
214 const TArrayD * h2Array = a2->GetXbins();
215 Int_t fN = h1Array->fN;
216 if ( fN == 0 )
return true;
217 if (h2Array->fN != fN) {
219 Warning(
"CheckAxisBins",
"Not equal number of %s bin limits: %d vs %d",
220 which, fN, h2Array->fN);
224 for (
int i = 0; i < fN; ++i) {
225 if (!TMath::AreEqualRel(h1Array->GetAt(i),h2Array->GetAt(i),1E-10)) {
226 Warning(
"CheckAxisBins",
227 "%s limit # %3d incompatible: %f vs %f",
228 which, i, h1Array->GetAt(i),h2Array->GetAt(i));
252 THashList *l1 = (
const_cast<TAxis*
>(a1))->GetLabels();
253 THashList *l2 = (
const_cast<TAxis*
>(a2))->GetLabels();
255 if (!l1 && !l2)
return true;
257 Warning(
"CheckAxisLabels",
"Difference in %s labels: %p vs %p",
262 if (l1->GetSize() != l2->GetSize()) {
263 Warning(
"CheckAxisLabels",
"Different number of %s labels: %d vs %d",
264 which, l1->GetSize(), l2->GetSize());
267 for (
int i = 1; i <= a1->GetNbins(); ++i) {
268 TString label1 = a1->GetBinLabel(i);
269 TString label2 = a2->GetBinLabel(i);
270 if (label1 != label2) {
271 Warning(
"CheckAxisLabels",
"%s label # %d not the same: '%s' vs '%s'",
272 which, i, label1.Data(), label2.Data());
314 if (h1 == h2)
return true;
316 if (h1->GetDimension() != h2->GetDimension()) {
317 Warning(
"CheckConsistency",
318 "%s and %s have different dimensions %d vs %d",
319 h1->GetName(), h2->GetName(),
320 h1->GetDimension(), h2->GetDimension());
323 Int_t dim = h1->GetDimension();
326 Bool_t alsoLbls = (h1->GetEntries() != 0 && h2->GetEntries() != 0);
327 if (!
CheckAxis(
"X", h1->GetXaxis(), h2->GetXaxis(), alsoLbls)) ret =
false;
329 !
CheckAxis(
"Y", h1->GetYaxis(), h2->GetYaxis(), alsoLbls)) ret =
false;
331 !
CheckAxis(
"Z", h1->GetZaxis(), h2->GetZaxis(), alsoLbls)) ret =
false;
348 TH1* ret =
static_cast<TH1*
>(templ->Clone(src->GetName()));
349 ret->SetDirectory(0);
351 for (
Int_t i = 1; i <= ret->GetNbinsX(); i++) {
352 Double_t x = ret->GetXaxis()->GetBinCenter(i);
353 Int_t b = src->GetXaxis()->FindBin(x);
354 if (b <= 0 || b >= src->GetNbinsX())
continue;
357 ret->SetBinContent(i, c);
358 ret->SetBinError (i, e);
375 TH2* ret =
static_cast<TH2*
>(templ->Clone(src->GetName()));
376 ret->SetDirectory(0);
378 for (
Int_t i = 1; i <= ret->GetNbinsX(); i++) {
379 Double_t x = ret->GetXaxis()->GetBinCenter(i);
380 Int_t bx = src->GetXaxis()->FindBin(x);
381 if (bx <= 0 || bx >= src->GetNbinsX())
continue;
382 for (
Int_t j = 1; j <= ret->GetNbinsY(); j++) {
383 Double_t y = ret->GetYaxis()->GetBinCenter(j);
384 Int_t by = src->GetYaxis()->FindBin(y);
386 Double_t e = src->GetBinError(bx,by);
387 ret->SetBinContent(i, j, c);
388 ret->SetBinError (i, j, e);
422 h->SetMarkerColor(color);
423 h->SetMarkerStyle(marker);
424 h->SetMarkerSize(size);
425 h->SetFillColor(color);
426 h->SetFillStyle(fill);
427 h->SetLineColor(color);
428 h->SetLineStyle(line);
429 h->SetLineWidth(width);
430 h->GetXaxis()->SetNdivisions(210);
431 h->GetYaxis()->SetNdivisions(210);
443 Printf(
"Content of %s - %s", h->GetName(), h->GetTitle());
444 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
446 for (
Int_t j = 1; j <= h->GetNbinsY(); j++) {
449 if (TMath::IsNaN(c) || TMath::IsNaN(e))
450 printf(
"*** NAN ***");
452 printf(
"%.*f+/-%.*f ", prec, c, prec, e);
466 Printf(
"Content of %s - %s", h->GetName(), h->GetTitle());
467 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
468 if (h->GetBinContent(i) <= 1e-6)
continue;
469 printf(
"%3d (%+6.3f): %.*f+/-%.*f\n", i,
470 h->GetXaxis()->GetBinCenter(i),
471 prec, h->GetBinContent(i),
472 prec, h->GetBinError(i));
501 Int_t bMin = h->FindBin(min+epsilon);
502 Int_t bMax = h->FindBin(max-epsilon);
503 if (bMin < 1) bMin = 0;
504 Double_t val = h->IntegralAndError(bMin, bMax, err);
506 if (TMath::Abs(h->GetXaxis()->GetXmin()+h->GetXaxis()->GetXmax())>=epsilon)
511 bMin = h->FindBin(-min+epsilon);
512 bMax = h->FindBin(-max-epsilon);
513 val += h->IntegralAndError(bMin, bMax, err2);
514 err = TMath::Sqrt(err*err+err2*err2);
539 if (TMath::Abs(n) < 1e-16 || TMath::Abs(d) < 1e-16)
return 0;
541 er = TMath::Sqrt(en*en/n/n + ed*ed/d/d);
569 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
572 Double_t dr = (dc > 1e-6 ? 1/dc : 0);
574 for (
Int_t j = 1; j <= h->GetNbinsY(); j++) {
575 Double_t nc = h->GetBinContent(i,j);
579 Double_t se = sc*TMath::Sqrt(ns*ns+dq*dq);
581 h->SetBinContent(i,j,sc);
582 h->SetBinError (i,j,se);
607 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
612 Double_t se = sc*TMath::Sqrt(es*es+rr*rr);
614 h->SetBinContent(i,sc);
615 h->SetBinError (i,se);
640 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
641 for (
Int_t j = 1; j <= h->GetNbinsY(); j++) {
646 Double_t se = sc*TMath::Sqrt(es*es+rr*rr);
648 h->SetBinContent(i,j,sc);
649 h->SetBinError (i,j,se);
667 for (
Int_t iy = 1; iy <= in->GetNbinsY(); iy++) {
668 Double_t z = in->GetYaxis()->GetBinCenter(iy);
669 Int_t bin = ipz->GetXaxis()->FindBin(z);
670 Double_t nEv = ipz->GetBinContent(bin);
671 Double_t eEv = ipz->GetBinError (bin);
672 Double_t esc = (nEv > 0 ? 1./nEv : 0);
675 for (
Int_t ix = 1; ix <= in->GetNbinsX(); ix++) {
677 Double_t e = in->GetBinError (ix,iy);
682 if (full)se = sc * TMath::Sqrt(r*r+rE2);
684 Double_t scl = 1 / in->GetXaxis()->GetBinWidth(ix);
687 in->SetBinContent(ix, iy, scl*sc);
688 in->SetBinError (ix, iy, scl*se);
715 TH2* mask = other ? other : h;
718 Int_t nIPz = h->GetNbinsY();
719 Int_t nEta = h->GetNbinsX();
720 TH1* p = h->ProjectionX(name,1,nIPz,
"e");
724 p->SetYTitle(Form(
"#LT(%s)#GT", h->GetYaxis()->GetTitle()));
726 for (
Int_t etaBin = 1; etaBin <= nEta; etaBin++) {
732 for (
Int_t ipzBin = 1; ipzBin <= nIPz; ipzBin++) {
733 Double_t bc = mask->GetBinContent(etaBin, ipzBin);
734 if (bc < 1e-9)
continue;
735 Double_t be = mask->GetBinError (etaBin, ipzBin);
736 if (TMath::IsNaN(be))
continue;
746 TMath::Sort(j, hr.fArray, idx.fArray,
false);
755 for (k = 0; k < j; k++) {
757 Int_t ipzBin = hb[l];
761 Double_t x = TMath::Sqrt(nsume+hee*hee)/(nsum+hvv);
765 Double_t by = h->GetYaxis()->GetBinCenter(ipzBin);
766 Int_t ib = ipz ? ipz->FindBin(by) : 0;
768 nsum += h->GetBinContent(etaBin, ipzBin);
769 nsume += TMath::Power(h->GetBinError(etaBin, ipzBin), 2);
772 dsum += !ipz ? 1 : ipz->GetBinContent(ib);
773 dsume += !ipz ? 0 : TMath::Power(ipz->GetBinError(ib),2);
776 if (k == 0 || n == 0) {
781 Double_t norm = (mode > 0 ? n : dsum);
786 if (mode==2) ave = TMath::Sqrt(nsume)/n;
787 else ave = av*TMath::Sqrt(rne+rde);
789 Printf(
"%10s - bin %3d (%+6.3f) count=%2d n=%9.3f+/-%9.3f d=%9.3f+/-%9.3f "
790 "norm=%9.3f -> %9.3f +/- %9.3f",
791 h->GetName(), etaBin, h->GetXaxis()->GetBinCenter(etaBin), n,
792 nsum, TMath::Sqrt(nsume)/(mode == 2 ? n : nsum),
793 dsum, TMath::Sqrt(dsume)/(mode == 2 ? n : dsum),
797 p->SetBinContent(etaBin, av);
798 p->SetBinError (etaBin, ave);
800 if (mode == 0) p->Scale(1,
"width");
820 TH2* tmp =
static_cast<TH2*
>(h->Clone(
"tmp"));
821 tmp->SetDirectory(0);
824 TH1* ret =
Avg(tmp, 0, 2, name);
865 if (!deltaRec || !deltaBg) {
866 Error(
"GetDeltaScale",
"Missing input histogram(s): %p %p",
870 deltaRec->Scale(1./nEvRec);
871 deltaBg ->Scale(1./nEvBg);
872 Double_t top = TMath::Min(lim,deltaRec->GetXaxis()->GetXmax());
880 Printf(
"%20s: data=%9g+/-%9g inj=%9g+/-%9g -> %9g+/-%9g",
881 list->GetName(), iRec, eRec, iBg, eBg, r, eR);
905 TH1* deltaRec =
CopyH1(list,Form(
"b%d_TrData_WDist", b));
906 TH1* deltaBg =
CopyH1(list,Form(
"b%d_TrInj_WDist", b));
929 TSeqCollection* simList,
936 TH1* deltaReal =
CopyH1(realList,Form(
"b%d_TrData_WDist", b));
937 TH1* deltaSim =
CopyH1(simList, Form(
"b%d_TrData_WDist", b));
964 Double_t top = deltaReal->GetYaxis()->GetXmax();
965 TH1* ret = deltaReal->ProjectionX(
"scalar");
967 ret->SetTitle(
"Background scale (#it{k})");
968 ret->SetYTitle(
"#delta scale");
969 ret->SetXTitle(
"#it{#eta}");
970 ret->SetDirectory(0);
971 for (
Int_t i = 1; i <= ret->GetNbinsX(); i++) {
972 TH1* tmpReal = deltaReal->ProjectionY(
"tmpReal",i,i);
973 TH1* tmpSim = deltaSim ->ProjectionY(
"tmpSim", i,i);
975 ret->SetBinContent(i, r);
976 ret->SetBinError (i, eR);
999 TH2* deltaRec =
GetH2(list,Form(
"b%d_TrData_WDvsEta", b));
1000 TH2* deltaBg =
GetH2(list,Form(
"b%d_TrInj_WDvsEta", b));
1020 TSeqCollection* simList,
1026 TH2* deltaReal =
CopyH2(realList,Form(
"b%d_TrData_WDvsEta", b));
1027 TH2* deltaSim =
CopyH2(simList, Form(
"b%d_TrData_WDvsEta", b));
1028 return GetDeltaDist(deltaReal, deltaSim, nEvReal, nEvSim, lim);
1053 TSeqCollection*
list,
1059 TH2* in =
GetH2(list,Form(
"b%d_Tr%s_ZvEtaCutT",b,comb ?
"Comb" :
"Inj"));
1060 TH2* ret =
static_cast<TH2*
>(in->Clone(
"bg"));
1061 in ->SetDirectory(0);
1062 ret->SetDirectory(0);
1064 if (comb)
return ret;
1071 return Scale(ret, r, eR);
1109 TH2* beta =
static_cast<TH2*
>(bg->Clone(
"beta"));
1110 beta->Divide(simMeas);
1111 beta->SetDirectory(0);
1112 TH2* one =
static_cast<TH2*
>(bg->Clone(
"one"));
1114 one->SetDirectory(0);
1115 for (
Int_t i = 1; i <= one->GetNbinsX(); i++)
1116 for (
Int_t j = 1; j <= one->GetNbinsY(); j++)
1117 one->SetBinContent(i,j,1);
1119 meas->Multiply(one);
1133 TH1* h =
CopyH1(l, Form(
"b%d_Tr%s_WDist", b, which));
1135 h->SetYTitle(
"tracklets/event");
1136 h->SetXTitle(
"#Delta");
1138 Bool_t isData = (scale < 1e-6);
1139 Color_t
color = (isData ? kGreen+2 : kBlue+2);
1141 if (w.EqualTo(
"Data"))
SetAttr(h, color, isData ? 21 : 25);
1142 if (w.EqualTo(
"Inj"))
SetAttr(h, color, isData ? 23 : 32);
1143 if (w.EqualTo(
"Comb"))
SetAttr(h, color, 26);
1144 if (w.EqualTo(
"Prim"))
SetAttr(h, kMagenta+2, 28);
1145 if (w.EqualTo(
"Sec"))
SetAttr(h, kMagenta+2, 27);
1147 if (w.EqualTo(
"Data")) h->SetTitle(
"Measured");
1148 if (w.EqualTo(
"Inj")) h->SetTitle(
"Injection");
1149 if (w.EqualTo(
"Comb")) h->SetTitle(
"Combinatorial");
1150 if (w.EqualTo(
"Prim")) h->SetTitle(
"Primaries");
1151 if (w.EqualTo(
"Sec")) h->SetTitle(
"Secondaries");
1153 if (w.EqualTo(
"Inj")) {
1156 h->SetTitle(Form(
"%5.3f#pm%5.3f #times %s",
1157 r, eR, h->GetTitle()));
1161 Scale(h, scale, scaleE);
1162 h->SetTitle(Form(
"%5.3f#pm%5.3f #times %s",
1163 scale, scaleE, h->GetTitle()));
1255 TSeqCollection* realList,
1256 TSeqCollection* simList,
1265 const Double_t k = (realList == simList ? 1 : 1.3);
1266 realList->SetName(
"realList");
1267 simList ->SetName(
"simList");
1268 TH2* realMeas =
GetH2(realList, Form(
"b%d_TrData_ZvEtaCutT", b));
1269 TH2* realIPzC =
GetH2(realList,
"zv");
1270 TH1* realIPz = realIPzC->ProjectionX(
"realIPz", b+1,b+1,
"e");
1272 GetH2(simList, Form(
"b%d_TrData_ZvEtaCutT", b)));
1274 TH1* simIPz = simIPzC->ProjectionX(
"simIPz", b+1,b+1,
"e");
1276 GetH2(simList, Form(
"b%d_zvEtaPrimMC", b)));
1278 TH1* trueIPz = simIPzC->ProjectionX(
"trueIPz", b+1,b+1,
"e");
1279 TH2* simBg =
Coerce(realMeas,
GetBg(simComb, simList, b, 1, lim));
1281 (realComb ?simList : realList),
1289 if (scaleMode == 0) {
1292 Scale(realBg, scale, 0);
1294 else if (scaleMode == 1) {
1299 realIPz->GetEntries(), lim);
1301 simIPz->GetEntries(), lim);
1302 scale =
RatioE(realR, realRe, simR, simRe, scaleE);
1305 realIPz->GetEntries(),
1306 simIPz->GetEntries(),
1309 Scale(realBg, scale, scaleE);
1311 else if (scaleMode == 2) {
1316 tmpReal->Divide(tmpSim);
1317 tmpReal->SetName(
"k");
1318 tmpReal->SetTitle(
"Background scale");
1319 tmpReal->SetMarkerColor(tmpReal->GetMarkerColor());
1320 tmpReal->SetMarkerStyle(tmpReal->GetMarkerStyle()+4);
1321 tmpReal->SetLineColor(tmpReal->GetLineColor());
1323 Scale(realBg, tmpReal);
1326 realIPz->GetEntries(),
1327 simIPz ->GetEntries(), lim);
1328 TF1* kfit =
new TF1(
"kfit",
"pol0");
1329 histK->Fit(kfit,
"Q0+");
1330 scale = kfit->GetParameter(0);
1331 scaleE = kfit->GetParError(0);
1332 Scale(realBg, histK);
1341 Warning(
"CorrectOneBin",
"Real data (%s) and simulated data (%s) done "
1342 "with different binning", realList->GetName(), simList->GetName());
1345 realMeas->SetName(
"realMeas");
1346 simMeas ->SetName(
"simMeas");
1347 realBg ->SetName(
"realBg");
1348 simBg ->SetName(
"simBg");
1349 trueGen ->SetName(
"trueGen");
1350 realMeas->SetTitle(
"Measured (real)");
1351 realBg ->SetTitle(
"Background (real)");
1352 simMeas ->SetTitle(
"Measured (simulated)");
1353 simBg ->SetTitle(
"Background (simulated)");
1354 trueGen ->SetTitle(
"Generated");
1355 realMeas->SetDirectory(0);
1356 simMeas ->SetDirectory(0);
1357 trueGen ->SetDirectory(0);
1358 realIPz ->SetDirectory(0);
1359 simIPz ->SetDirectory(0);
1360 trueIPz ->SetDirectory(0);
1364 Double_t ipzMin = realMeas->GetYaxis()->GetXmin();
1365 Double_t ipzMax = realMeas->GetYaxis()->GetXmax();
1369 realIPz->SetMarkerColor(kRed+2); realIPz->SetMarkerStyle(20);
1370 simIPz ->SetMarkerColor(kBlue+2); simIPz ->SetMarkerStyle(21);
1371 trueIPz->SetMarkerColor(kBlack); trueIPz->SetMarkerStyle(24);
1374 for (
Int_t i = 1; i <= realIPz->GetNbinsX(); i++) {
1375 if (simIPz->GetBinContent(i) < 1e-6) {
1376 realIPz->SetBinContent(i,0);
1377 realIPz->SetBinError (i,0);
1393 realMeas->Scale(1/realNev);
1394 realBg ->Scale(1/(realComb ? simNev : realNev));
1395 realIPz ->Scale(1/realNev);
1396 simMeas ->Scale(1/simNev);
1397 simBg ->Scale(1/simNev);
1398 simIPz ->Scale(1/simNev);
1399 trueGen ->Scale(1/trueNev);
1400 trueIPz ->Scale(1/trueNev);
1404 TH2* realSig =
static_cast<TH2*
>(realMeas->Clone(
"realSig"));
1405 realSig->SetTitle(
"Signal (real)");
1406 realSig->SetDirectory(0);
1410 TH2* simSig =
static_cast<TH2*
>(simMeas->Clone(
"simSig"));
1411 simSig->SetTitle(
"Signal (simulated)");
1412 simSig->SetDirectory(0);
1414 simSig->Add(simBg, -1);
1417 TH2* alpha =
static_cast<TH2*
>(trueGen->Clone(
"alpha"));
1418 alpha->SetTitle(
"#alpha");
1419 alpha->SetDirectory(0);
1420 alpha->Divide(simSig);
1422 TH2* fiducial =
static_cast<TH2*
>(alpha->Clone(
"fiducial"));
1423 fiducial->SetTitle(
"Fiducial cut");
1424 fiducial->SetDirectory(0);
1425 for (
Int_t i = 1; i <= fiducial->GetNbinsX(); i++) {
1426 for (
Int_t j = 1; j <= fiducial->GetNbinsY(); j++) {
1427 Double_t a = fiducial->GetBinContent(i,j);
1428 fiducial->SetBinError(i,j,0);
1429 fiducial->SetBinContent(i,j, (a > 0 && a <= 2.5));
1432 alpha ->Multiply(fiducial);
1435 TH2* result =
static_cast<TH2*
>(realSig->Clone(
"result"));
1436 result->SetTitle(
"Result");
1437 result->SetDirectory(0);
1438 result->Multiply(alpha);
1443 TH1* truth =
Avg(trueGen, trueIPz, mode,
"truth");
1445 SetAttr(truth,
cc[b%11], 24, 1.5, 0, 3, 2);
1448 TH1* dndeta =
Avg(result, realIPz, mode,
"dndeta");
1450 SetAttr(dndeta,
cc[b%11], 20, 1.2, 0, 1, 1);
1452 for (
Int_t i = 1; i <= dndeta->GetNbinsX(); i++) {
1453 dndeta->SetBinError(i,1./3*dndeta->GetBinError(i));
1457 TF1* f =
new TF1(
"ff",
"pol0", -lim, lim);
1458 TFitResultPtr r = dndeta->Fit(f,
"QN0RS",
"", -lim, lim);
1459 Printf(
"dNch/deta %20s: %6.1f +/- %6.1f (%5.2f - %5.3f+/-%5.3f)",
1461 r->Parameter(0), r->ParError(0), r->Chi2()/r->Ndf(),
1466 realMeas->Multiply(fiducial);
1467 simMeas ->Multiply(fiducial);
1468 realSig ->Multiply(fiducial);
1469 simSig ->Multiply(fiducial);
1470 realBg ->Multiply(fiducial);
1471 simBg ->Multiply(fiducial);
1472 realSig ->Multiply(fiducial);
1473 simSig ->Multiply(fiducial);
1474 TH1* realAvgMeas =
Avg(realMeas,realIPz, mode,
"realAvgMeas",result);
1475 TH1* simAvgMeas =
Avg(simMeas, simIPz, mode,
"simAvgMeas", result);
1476 TH1* realAvgBg =
Avg(realBg, realIPz, mode,
"realAvgBg", result);
1477 TH1* simAvgBg =
Avg(simBg, simIPz, mode,
"simAvgBg", result);
1478 TH1* realAvgSig =
Avg(realSig, realIPz, mode,
"realAvgSig", result);
1479 TH1* simAvgSig =
Avg(simSig, simIPz, mode,
"simAvgSig", result);
1480 SetAttr(realAvgMeas, kGreen+2, 21);
1481 SetAttr(realAvgBg, kGreen+2, 22);
1482 SetAttr(realAvgSig, kGreen+2, 23);
1483 SetAttr(simAvgMeas, kRed+2, 22);
1484 SetAttr(simAvgBg, kBlue+2, 21);
1485 SetAttr(simAvgSig, kBlue+2, 22);
1488 THStack* summary =
new THStack(
"summary", dndeta->GetYaxis()->GetTitle());
1489 summary->Add(dndeta,
"e2");
1490 summary->Add(truth,
"E");
1491 summary->Add(realAvgMeas);
1492 summary->Add(simAvgMeas);
1493 summary->Add(realAvgBg);
1494 summary->Add(simAvgBg);
1495 summary->Add(realAvgSig);
1496 summary->Add(simAvgSig);
1500 summary->Add(histK);
1505 realIPz->Scale(1/realNev);
1506 simIPz ->Scale(1/simNev);
1507 trueIPz->Scale(1/trueNev);
1510 TCanvas*
c =
new TCanvas(Form(
"c%02d",b),
1511 Form(
"Centrality bin %d",b),
1514 c->cd(1); realMeas->DrawCopy(
"lego2 e");
1515 c->cd(2); realBg ->DrawCopy(
"lego2 e");
1516 c->cd(3); realSig ->DrawCopy(
"lego2 e");
1517 c->cd(4); realIPz ->DrawCopy();
1518 c->cd(4); simIPz ->DrawCopy(
"same");
1519 c->cd(4); trueIPz ->DrawCopy(
"same");
1520 c->cd(5); simMeas ->DrawCopy(
"lego2 e");
1521 c->cd(6); simBg ->DrawCopy(
"lego2 e");
1522 c->cd(7); simSig ->DrawCopy(
"lego2 e");
1523 c->cd(8); alpha ->DrawCopy(
"lego2 e");
1524 c->cd(9); fiducial->DrawCopy(
"lego2 e");
1525 c->cd(10); trueGen ->DrawCopy(
"lego2 e");
1526 c->cd(11); result ->DrawCopy(
"lego2 e");
1527 c->cd(12); summary ->DrawClone(
"nostack");
1528 c->GetPad(4)->Modified();
1529 c->GetPad(12)->Modified();
1530 c->GetPad(4)->BuildLegend();
1531 c->GetPad(12)->BuildLegend();
1532 TLatex* ltx =
new TLatex(.52, .3,
1533 Form(
"d#it{N}_{ch}/d#eta|_{|#eta|<%3.1f}"
1534 "=%6.1f#pm%6.1f (#chi^{2}/#nu=%5.2f)",
1535 lim, r->Parameter(0),
1536 r->ParError(0), r->Chi2()/r->Ndf()));
1537 ltx->SetTextAlign(23);
1539 ltx->SetTextFont(42);
1540 ltx->SetTextSize(0.035);
1541 c->cd(12); ltx->Draw();
1542 ltx->DrawLatex(.52,.25,
1543 Form(
"%sk%s=%5.3f#pm%5.3f",
1550 stack->Add(dndeta,
"e2");
1558 if (histK) histK ->Write();
1562 TDirectory* det = dir->mkdir(
"details");
1580 if (histK) histK->Write();
1581 THStack* deltas =
new THStack(
"deltas",
"#Delta distributions");
1582 deltas->Add(
GetDelta(realList,
"Data",b,realNev,0, 0, lim));
1583 deltas->Add(
GetDelta(simList,
"Data",b,simNev, scale,scaleE,lim));
1584 deltas->Add(
GetDelta(realList,
"Inj", b,realNev,0, 0, lim));
1585 deltas->Add(
GetDelta(simList,
"Inj", b,simNev, scale,scaleE,lim));
1586 deltas->Add(
GetDelta(simList,
"Comb",b,simNev, scale,scaleE,lim));
1587 deltas->Add(
GetDelta(simList,
"Prim",b,trueNev,scale,scaleE,lim));
1588 deltas->Add(
GetDelta(simList,
"Sec", b,trueNev,scale,scaleE,lim));
1589 TH1* sum =
GetDelta(simList,
"Prim", b,trueNev,0, 0, lim);
1590 sum->Add(
GetDelta(simList,
"Sec", b,trueNev,0, 0, lim));
1591 sum->Add(
GetDelta(simList,
"Comb", b,simNev, 0, 0, lim));
1592 sum->SetTitle(Form(
"%5.3f#pm%5.3f #times (Prim+Sec+Comb)",scale,scaleE));
1593 Scale(sum,scale,scaleE);
1598 TDirectory* avs = dir->mkdir(
"averages");
1600 realAvgMeas->Write();
1601 realAvgSig ->Write();
1602 realAvgBg ->Write();
1603 simAvgMeas ->Write();
1604 simAvgSig ->Write();
1628 Printf(
"=== %-15s - %s ===", title, path);
1631 Warning(
"",
"No stats");
1634 TH1* stats =
static_cast<TH1*
>(tmp->Clone());
1635 stats->SetDirectory(0);
1636 TAxis* axis = stats->GetXaxis();
1637 for (
Int_t i = 1; i <= 4; i++) {
1638 Printf(
"%31s: %f", axis->GetBinLabel(i), stats->GetBinContent(i));
1640 Double_t scale = stats->GetBinContent(4);
1641 stats->Scale(1/scale);
1642 for (
Int_t i = 6; i <= 23; i++) {
1643 Printf(
"%31s: %f", axis->GetBinLabel(i), stats->GetBinContent(i));
1672 const char* realFileName,
1673 const char* simFileName,
1675 const char* otherFileName=
"")
1677 TFile* realFile = TFile::Open(realFileName,
"READ");
1678 TFile* simFile = TFile::Open(simFileName,
"READ");
1679 TFile* otherFile = 0;
1680 if (otherFileName && otherFileName[0] !=
'\0')
1681 otherFile = TFile::Open(otherFileName,
"READ");
1682 TList* realList =
static_cast<TList*
>(realFile->Get(
"clist"));
1683 TList* simList =
static_cast<TList*
>(simFile ->Get(
"clist"));
1686 otherList =
static_cast<TObjArray*
>(otherFile->Get(
"TObjArray"));
1688 ShowStats(realList,
"Real data", realFile->GetName());
1689 ShowStats(simList,
"Simulated data",simFile ->GetName());
1691 TH1* realCent =
GetH1(realList,
"EvCentr");
1692 TH1* simCent =
GetH1(simList,
"EvCentr");
1694 Warning(
"SimpleCorrection",
"Inconsistent centralities");
1697 TH2* realIpz =
GetH2(realList,
"b0_TrData_ZvEtaCutT");
1698 TH2* simIpz =
GetH2(simList,
"b0_TrData_ZvEtaCutT");
1700 Warning(
"SimpleCorrection",
"Inconsistent IPz or eta axis");
1706 Bool_t realComb = flags & 0x1;
1707 Bool_t simComb = flags & 0x2;
1708 Bool_t preScale = flags & 0x4;
1709 Bool_t full = flags & 0x8;
1710 Bool_t showOne = flags & 0x20;
1712 Printf(
"Real background: %s\n"
1713 "Simulated background: %s\n"
1715 "Full pre-scale: %s\n"
1716 "Show each bin: %s\n"
1717 "Delta upper limit: %g\n"
1719 (realComb ?
"comb" :
"inj"),
1720 (simComb ?
"comb" :
"inj"),
1721 (preScale ?
"yes" :
"no"),
1722 (full ?
"yes" :
"no"),
1723 (showOne ?
"yes" :
"no"),
1725 (scaleMode==0 ?
"fixed" :
1726 scaleMode==1 ?
"c" :
1727 scaleMode==2 ?
"eta-c" :
1731 if (flags & 0x10) realList = simList;
1733 tit.Form(
"Real BG: %s Simulated BG: %s%s",
1734 realComb ?
"MC-labels" :
"Injection",
1735 simComb ?
"MC-labels" :
"Injection",
1736 preScale ?
" (pre-scaled)" :
"");
1738 TFile* output = TFile::Open(Form(
"result_0x%x.root", flags&0x3),
1740 realCent->Write(
"cent");
1741 THStack* res =
new THStack(
"result", tit);
1742 TH1* cent =
GetH1(realList,
"EvCentr");
1743 for (
Int_t b = 0; b < nBins; b++) {
1744 Double_t c1 = cent->GetXaxis()->GetBinLowEdge(b+1);
1745 Double_t c2 = cent->GetXaxis()->GetBinUpEdge (b+1);
1747 name.Form(
"cent%03dd%02d_%03dd%02d",
1750 TDirectory*
dir = output->mkdir(name);
1751 CorrectOneBin(res,dir,b,realList,simList,realComb,simComb,preScale,full,
1752 showOne, scaleMode, deltaLim);
1755 TH1* od =
GetH1(otherList, Form(
"bin%d_DataCorrSignal_Bla",b));
1756 TH1* ot =
GetH1(otherList, Form(
"bin%d_MCTruth",b));
1757 TH1* td =
static_cast<TH1*
>(od->Clone(
"otherdNdeta"));
1758 TH1* tt =
static_cast<TH1*
>(ot->Clone(
"otherTruth"));
1759 td->SetDirectory(0);
1760 tt->SetDirectory(0);
1761 SetAttr(td,
cc[b%11], 21, 1.2, 3004, 1, 1);
1762 SetAttr(tt,
cc[b%11], 25, 1.4, 0, 7, 3);
1763 if (td->GetMinimum() < 1e-6) { td->SetMinimum(); td->SetMaximum(); }
1764 if (tt->GetMinimum() < 1e-6) { tt->SetMinimum(); tt->SetMaximum(); }
1774 res->SetMaximum(1.2*res->GetMaximum(
"nostack"));
Bool_t CheckAxisNBins(const char *which, const TAxis *a1, const TAxis *a2)
Int_t color[]
option to what and if export to output file
Bool_t CheckAxisLabels(const char *which, const TAxis *a1, const TAxis *a2)
const Bool_t kSimpleCorrectLoaded
Bool_t CheckAxisBins(const char *which, const TAxis *a1, const TAxis *a2)
TH1 * Avg2(TH2 *h, TH1 *ipz, UShort_t mode, const char *name)
TList * list
TDirectory file where lists per trigger are stored in train ouput.
TH1 * GetH1(TSeqCollection *l, const char *name)
TH1 * SetAttr(TH1 *h, Color_t color, Style_t marker=20, Double_t size=1., Style_t fill=0, Style_t line=1, Width_t width=1)
void ShowStats(TList *list, const char *title, const char *path)
Double_t Integrate(TH1 *h, Double_t min, Double_t max, Double_t &err)
TH2 * GetH2(TSeqCollection *l, const char *name)
TH2 * CorrectSignal(Bool_t comb, TH2 *meas, TH2 *bg, TH2 *simMeas)
Bool_t CheckConsistency(const TH1 *h1, const TH1 *h2)
TH1 * GetDeltaDist(TH2 *deltaReal, TH2 *deltaSim, Double_t nEvReal, Double_t nEvSim, Double_t lim=1e9)
TH1 * Avg(TH2 *h, TH1 *ipz, UShort_t mode, const char *name, TH2 *other=0)
TH2 * CopyH2(TSeqCollection *l, const char *name, const char *newName=0)
Double_t RatioE(Double_t n, Double_t en, Double_t d, Double_t ed, Double_t &er)
TH2 * GetBg(Bool_t comb, TSeqCollection *list, Int_t b, Double_t nEv=1, Double_t lim=1e9)
TObject * CopyO(TSeqCollection *l, const char *name, const char *newName, TClass *cls)
Bool_t CheckAxisLimits(const char *which, const TAxis *a1, const TAxis *a2)
void PrintH(TH2 *h, Int_t prec=2)
void SimpleCorrect(UShort_t flags, UShort_t scaleMode, const char *realFileName, const char *simFileName, Int_t nBins=9, const char *otherFileName="")
TH2 * Scale(TH2 *h, TH1 *g)
TObject * GetO(TSeqCollection *l, const char *name, TClass *cls)
TH1 * CopyH1(TSeqCollection *l, const char *name, const char *newName=0)
Bool_t CheckAxis(const char *which, const TAxis *a1, const TAxis *a2, Bool_t alsoLbls)
Double_t GetDeltaScale(TH1 *deltaRec, TH1 *deltaBg, Double_t &eR, Double_t nEvRec=1, Double_t nEvBg=1, Double_t lim=1e9)
TH1 * Coerce(const TH1 *templ, TH1 *src)
TH2 * CorrectForIPz(TH2 *in, TH1 *ipz, Bool_t full=true)
void CorrectOneBin(THStack *stack, TDirectory *dir, Int_t b, TSeqCollection *realList, TSeqCollection *simList, Bool_t realComb, Bool_t simComb, Bool_t preScale=false, Bool_t full=false, Bool_t showOne=false, UShort_t scaleMode=2, Double_t lim=1e9)
TH1 * GetDelta(TSeqCollection *l, const char *which, Int_t b, Int_t nEv, Double_t scale=0, Double_t scaleE=0, Double_t lim=1e9)