86 , fArrHists(c.fArrHists)
87 , fArrCocktail(c.fArrCocktail)
88 , fHistSignal(c.GetSignalHistogram())
89 , fHistSB(c.GetSoverBHistogram())
90 , fHistSgn(c.GetSignificanceHistogram())
91 , fHistBackground(c.GetBackgroundHistogram())
92 , fHistCocktail(c.GetCocktailHistogram())
93 , fHistDataPM(c.GetUnlikeSignHistogram())
94 , fHistRfactor(c.GetRfactorHistogram())
95 , fHistSignalMC(c.GetMCSignalShape())
96 , fValues(c.GetValues())
97 , fErrors(c.GetErrors())
98 , fIntMin(c.GetIntegralMin())
99 , fIntMax(c.GetIntegralMax())
100 , fRebin(c.GetRebin())
104 fMethod(c.GetMethod())
105 , fScaleMin(c.GetScaleMin())
106 , fScaleMax(c.GetScaleMax())
107 , fScaleMin2(c.GetScaleMin2())
108 , fScaleMax2(c.GetScaleMax2())
109 , fScaleFactor(c.GetScaleFactor())
110 , fPeakMethod(c.GetExtractionMethod())
222 if (intMin < histRaw->GetXaxis()->GetXmin()) intMin = histRaw->GetXaxis()->GetXmin();
223 if (intMin < histBackground->GetXaxis()->GetXmin()) intMin = histBackground->GetXaxis()->GetXmin();
225 if (intMax > histRaw->GetXaxis()->GetXmax())
226 intMax = histRaw->GetXaxis()->GetXmax() - histRaw->GetBinWidth(histRaw->GetNbinsX()) / 2.;
227 if (intMax > histBackground->GetXaxis()->GetXmax())
228 intMax = histBackground->GetXaxis()->GetXmax() - histBackground->GetBinWidth(histBackground->GetNbinsX()) / 2.;
230 Double_t intRaw = histRaw->Integral(histRaw->FindBin(intMin), histRaw->FindBin(intMax));
231 Double_t intBack = histBackground->Integral(histBackground->FindBin(intMin), histBackground->FindBin(intMax));
234 if (histBackground->GetDefaultSumw2()) histBackground->Sumw2();
242 Double_t intMin2, Double_t intMax2)
248 if (TMath::Abs(intMin2 - intMax2) < 0.00001)
return (
ScaleHistograms(histRaw, histBackground, intMin, intMax));
251 if (intMin < histRaw->GetXaxis()->GetXmin()) intMin = histRaw->GetXaxis()->GetXmin();
252 if (intMin < histBackground->GetXaxis()->GetXmin()) intMin = histBackground->GetXaxis()->GetXmin();
254 if (intMax2 > histRaw->GetXaxis()->GetXmax())
255 intMax2 = histRaw->GetXaxis()->GetXmax() - histRaw->GetBinWidth(histRaw->GetNbinsX()) / 2.;
256 if (intMax2 > histBackground->GetXaxis()->GetXmax())
257 intMax2 = histBackground->GetXaxis()->GetXmax() - histBackground->GetBinWidth(histBackground->GetNbinsX()) / 2.;
259 Double_t intRaw = histRaw->Integral(histRaw->FindBin(intMin), histRaw->FindBin(intMax));
260 Double_t intBack = histBackground->Integral(histBackground->FindBin(intMin), histBackground->FindBin(intMax));
261 intRaw += histRaw->Integral(histRaw->FindBin(intMin2), histRaw->FindBin(intMax2));
262 intBack += histBackground->Integral(histBackground->FindBin(intMin2), histBackground->FindBin(intMax2));
266 if (histBackground->GetDefaultSumw2()) histBackground->Sumw2();
280 if (!obj1)
return obj2;
281 if (!obj2)
return obj1;
283 TString key = Form(
"%s_%s", obj1->GetName(),
"Signal");
284 if (obj1->IsA() == TProfile2D::Class() && obj2->IsA() == TProfile2D::Class()) {
287 ((TProfile2D*) obj1)->Add(((TProfile2D*) obj2), val);
288 return (TH1*) obj1->Clone(key.Data());
293 else if (obj1->IsA() == TProfile::Class() && obj2->IsA() == TProfile::Class()) {
296 ((TProfile*) obj1)->Add(((TProfile*) obj2), val);
297 return (TH1*) obj1->Clone(key.Data());
301 TH1D* histSign =
new TH1D(key.Data(),
"", obj1->GetXaxis()->GetNbins(), obj1->GetXaxis()->GetXmin(),
302 obj1->GetXaxis()->GetXmax());
303 if (histSign->GetDefaultSumw2()) histSign->Sumw2();
304 histSign->SetDirectory(0);
306 for (Int_t i = 0; i <= obj1->GetNbinsX(); i++) {
307 histSign->SetBinContent(i, obj1->GetBinContent(i) - obj2->GetBinContent(i));
308 histSign->SetBinError(
309 i, TMath::Sqrt(obj1->GetBinError(i) * obj1->GetBinError(i) - obj2->GetBinError(i) * obj2->GetBinError(i)));
325 TH1* histSign = (TH1*) obj1->Clone(key.Data());
326 histSign->Add(obj2, val);
330 obj1->Add(obj2, val);
346 Double_t massPOI = TDatabasePDG::Instance()->GetParticle(
fPOIpdg)->Mass();
347 Double_t sigPOI = massPOI * 0.02;
358 Info(
"DescribePeakShape",
"Signal extraction method: %d", (Int_t)
fPeakMethod);
366 Error(
"DescribePeakShape",
"No MC histogram passed. Returning.");
370 mc = mcShape->GetBinContent(
fHistSignal->FindBin(massPOI));
371 mcShape->Scale(data / mc);
376 Error(
"DescribePeakShape",
"No MC histogram passed. Returning.");
379 if (mcShape->GetBinWidth(1) !=
fHistSignal->GetBinWidth(1))
380 printf(
" WARNING: MC and signal histogram have different bin widths. \n");
382 mc = mcShape->Integral(mcShape->FindBin(
fIntMin), mcShape->FindBin(
fIntMax));
383 mcShape->Scale(data / mc);
388 printf(
" ERROR: No MC histogram passed or set. Returning. \n");
395 fit->SetParNames(
"N");
401 fit->SetParNames(
"alpha",
"n",
"meanx",
"sigma",
"N");
404 fit->SetParameters(0.4, 4.0, massPOI, sigPOI, 1.3 * nPOI);
405 fit->SetParLimits(0, 0.0, 1.);
406 fit->SetParLimits(1, 0.01, 10.);
407 fit->SetParLimits(2, massPOI - sigPOI, massPOI + sigPOI);
408 fit->SetParLimits(3, sigPOI / 5, 5 * sigPOI);
409 fit->SetParLimits(4, 0.2 * nPOI, 2.0 * nPOI);
418 fit->SetParNames(
"N",
"meanx",
"sigma");
419 fit->SetParameters(1.3 * nPOI, massPOI, sigPOI);
420 fit->SetParLimits(0, 0.2 * nPOI, 2.0 * nPOI);
421 fit->SetParLimits(1, massPOI - sigPOI, massPOI + sigPOI);
422 fit->SetParLimits(2, sigPOI / 5, 5 * sigPOI);
431 Fatal(
"DescribePeakShape",
"Function class not added!");
440 if (fitResult != 0) Warning(
"DescripePeakShape",
"fit has error/issue (%d)", fitResult);
443 if (fit)
fValues(6) = (fit->GetNDF() ? fit->GetChisquare() / fit->GetNDF() : -1.);
471 fValues(4) = fit->GetParameter(parMass);
472 fErrors(4) = fit->GetParError(parMass);
475 fValues(5) = fit->GetParameter(parSigma);
476 fErrors(5) = fit->GetParError(parSigma);
489 return (TH1F*)
fHistSignal->Clone(
"BinCountReturn");
506 fit->SetName(Form(
"UserFunc"));
1085 TString optString(option);
1086 optString.ToLower();
1089 Bool_t optTask = optString.Contains(
"same");
1090 optString.ReplaceAll(
"same",
"");
1091 Bool_t optLegFull = optString.Contains(
"legf");
1092 optString.ReplaceAll(
"legf",
"");
1093 Bool_t optLeg = optString.Contains(
"leg");
1094 optString.ReplaceAll(
"leg",
"");
1095 Bool_t optCan = optString.Contains(
"can");
1096 optString.ReplaceAll(
"can",
"");
1097 Bool_t optLine = optString.Contains(
"line");
1098 optString.ReplaceAll(
"line",
"");
1099 Bool_t optStat = optString.Contains(
"stat");
1100 optString.ReplaceAll(
"stat",
"");
1101 Bool_t optSSB = optString.Contains(
"ssb");
1102 optString.ReplaceAll(
"ssb",
"");
1103 Bool_t optSB = optString.Contains(
"sb");
1104 optString.ReplaceAll(
"sb",
"");
1105 Bool_t optSgn = optString.Contains(
"sgn");
1106 optString.ReplaceAll(
"sgn",
"");
1107 Bool_t optOnlyRaw = optString.Contains(
"onlyraw");
1108 optString.ReplaceAll(
"onlyraw",
"");
1109 Bool_t optOnlySig = optString.Contains(
"onlysig");
1110 optString.ReplaceAll(
"onlysig",
"");
1111 Bool_t optNoSig = optString.Contains(
"nosig");
1112 optString.ReplaceAll(
"nosig",
"");
1113 Bool_t optNoBgrd = optString.Contains(
"nobgrd");
1114 optString.ReplaceAll(
"nobgrd",
"");
1115 Bool_t optOnlyMC = optString.Contains(
"onlymc");
1116 optString.ReplaceAll(
"onlymc",
"");
1117 Bool_t optNoMC = optString.Contains(
"nomc");
1118 optString.ReplaceAll(
"nomc",
"");
1119 Bool_t optCocktail = optString.Contains(
"cocktail");
1120 optString.ReplaceAll(
"cocktail",
"");
1121 optString.ReplaceAll(
" ",
"");
1127 if (optLegFull) optLeg = kTRUE;
1132 TString key = Form(
"cSignalExtraction%s", (optSB ?
"SB" : (optSgn ?
"SGN" : (optSSB ?
"SSB" :
""))));
1133 c = (TCanvas*) gROOT->FindObject(key.Data());
1134 if (!c) c =
new TCanvas(key.Data(), key.Data());
1142 TList* prim = gPad->GetListOfPrimitives();
1143 for (Int_t io = 0; io < prim->GetSize(); io++) {
1145 if (obj->InheritsFrom(TH1::Class()) && obj != prim->At(io + 1)) nobj++;
1150 if ((optLeg && optTask && !nobj) || (optLeg && !optTask)) {
1151 leg =
new TLegend(.75, .3, 1. - gPad->GetTopMargin() - gStyle->GetTickLength(
"X"),
1152 1. - gPad->GetRightMargin() - gStyle->GetTickLength(
"Y"),
fArrHists->GetName(),
"nbNDC");
1153 if (optTask) leg->SetHeader(
"");
1155 else if (optLeg && nobj) {
1156 leg = (TLegend*) prim->FindObject(
"TPave");
1160 gPad->SetLogx(optString.Contains(
"logx"));
1161 gPad->SetLogy(optString.Contains(
"logy"));
1162 gPad->SetLogz(optString.Contains(
"logz"));
1163 optString.ReplaceAll(
"logx",
"");
1164 optString.ReplaceAll(
"logy",
"");
1165 optString.ReplaceAll(
"logz",
"");
1168 if (optString.Contains(
"e2") || optString.Contains(
"e3") || optString.Contains(
"e4")) {
1170 gStyle->SetErrorX(0.5);
1175 Info(
"Draw",
"this is object number: %d", nobj);
1178 TString ytitle =
fHistDataPM->GetYaxis()->GetTitle();
1180 if (!(
fHistDataPM->GetXaxis()->IsVariableBinSize())) {
1181 ytitle += Form(
"/%.0f MeV/#it{c}^{2}",
fHistDataPM->GetBinWidth(1) * 1e3);
1187 fHistDataPM->SetNameTitle(Form(
"unlike-sign%s", GetName()),
"unlike-sign");
1196 fHistSignal->SetNameTitle(Form(
"signal%s", GetName()),
"signal");
1202 fHistCocktail->SetNameTitle(Form(
"cocktail%s", GetName()),
"cocktail");
1209 fHistSB->SetNameTitle(Form(
"s2b%s", GetName()),
"signal");
1215 fHistSgn->SetNameTitle(Form(
"sgn%s", GetName()),
"signal");
1231 Info(
"Draw",
"Start plotting stuff with option -%s-", optString.Data());
1232 TString drawOpt = (optString.IsNull() ?
"EP" : optString);
1236 if (optSB && !optOnlyRaw && !optNoSig) {
1237 fHistSB->Draw(i > 0 ? (drawOpt +
"same").Data() : drawOpt.Data());
1240 else if (optSgn && !optOnlyRaw && !optNoSig) {
1241 fHistSgn->Draw(i > 0 ? (drawOpt +
"same").Data() : drawOpt.Data());
1244 else if (optOnlySig) {
1245 drawOpt = (optString.IsNull() ?
"EP0" : optString);
1246 fHistSignal->DrawCopy(i > 0 ? (drawOpt +
"same").Data() : drawOpt.Data());
1248 drawOpt = (optString.IsNull() ?
"L same" : optString +
"same");
1250 static_cast<TF1*
>(
fgPeakShape)->DrawCopy(drawOpt.Data());
1254 else if (!optSB && !optSgn) {
1255 fHistDataPM->DrawCopy(i > 0 ? (drawOpt +
"same").Data() : drawOpt.Data());
1258 drawOpt = (optString.IsNull() ?
"HIST" : optString);
1260 fHistBackground->DrawCopy(i > 0 ? (drawOpt +
"same").Data() : drawOpt.Data());
1263 if (!optOnlyRaw && !optNoSig) {
1264 drawOpt = (optString.IsNull() ?
"EP0" : optString);
1265 fHistSignal->DrawCopy(i > 0 ? (drawOpt +
"same").Data() : drawOpt.Data());
1267 drawOpt = (optString.IsNull() ?
"L same" : optString +
"same");
1269 static_cast<TF1*
>(
fgPeakShape)->DrawCopy(drawOpt.Data());
1276 drawOpt = (optString.IsNull() ?
"HIST" : optString);
1286 fHistCocktail->DrawCopy(i > 0 ? (drawOpt +
"same").Data() : drawOpt.Data());
1298 while ((hmc =
dynamic_cast<TH1*
>(nextObj()))) {
1299 TString key = hmc->GetTitle();
1300 TString tit = hmc->GetTitle();
1301 if (key.CountChar(
'_') != 1)
continue;
1310 if (1 &&
fHistSignal->GetNbinsX() != hmc->GetNbinsX()) {
1313 hmc->SetTitle(tit.Data());
1314 hmc->Scale(1.,
"width");
1320 hmc->SetYTitle(Form(
"S/(S+B)"));
1327 hmc->Draw(i > 0 ?
"HISTsame" :
"HIST");
1334 Double_t max = -1e10;
1335 Double_t min = +1e10;
1337 TListIter nextObj(gPad->GetListOfPrimitives(), kIterBackward);
1339 while ((obj = nextObj())) {
1340 if (obj->InheritsFrom(TH1::Class())) {
1341 TH1* hobj =
static_cast<TH1*
>(obj);
1342 max = TMath::Max(max,
1344 Double_t tmpmax = max * (gPad->GetLogy() ? 5. : 1.1);
1345 hobj->SetMaximum(tmpmax);
1348 if (gPad->GetLogy() && objmin < 0.) objmin = 0.5;
1349 min = TMath::Min(min, objmin);
1350 Double_t tmpmin = min * (min < 0. ? 1.1 : 0.9);
1351 hobj->SetMinimum(tmpmin);
1357 && (tmpmax / (tmpmin > 0. ? tmpmin : 1.) > TMath::Power(10., TGaxis::GetMaxDigits())
1358 || tmpmin < TMath::Power(10., -TGaxis::GetMaxDigits()))) {
1359 hobj->GetYaxis()->SetMoreLogLabels(kFALSE);
1360 hobj->GetYaxis()->SetNoExponent(kFALSE);
1367 TListIter nextObjFwd(gPad->GetListOfPrimitives(), kIterForward);
1368 if (optLeg && leg) {
1371 while ((obj = nextObjFwd())) {
1372 if (obj->InheritsFrom(TH1::Class()) || obj->InheritsFrom(TF1::Class())) {
1374 if (nobj && ileg < nobj) {
1379 TString histClass = obj->GetTitle();
1380 if (histClass.IsNull()) histClass = obj->GetName();
1381 histClass.ReplaceAll(
"Pair.",
"");
1382 histClass.ReplaceAll(
"Pair_",
"");
1388 histClass.Remove(TString::kBoth,
' ');
1393 TString legOpt = obj->GetDrawOption();
1396 legOpt.ReplaceAll(
"hist",
"");
1397 legOpt.ReplaceAll(
"same",
"");
1398 legOpt.ReplaceAll(
"scat",
"");
1399 legOpt.ReplaceAll(
"col",
"");
1400 legOpt.ReplaceAll(
"z",
"");
1401 legOpt.ReplaceAll(
"text",
"");
1402 legOpt.ReplaceAll(
"e",
"");
1404 if (ileg == nobj && optTask) leg->AddEntry((TObject*) 0x0,
fArrHists->GetName(),
"");
1405 leg->AddEntry(obj, histClass.Data(), legOpt.Data());
1415 if (!nobj) leg->Draw();
1419 TLine* line =
new TLine();
1420 line->SetLineColor(kBlack);
1421 line->SetLineStyle(kDashed);
1426 DrawStats(0.7, gPad->GetBottomMargin() + gStyle->GetTickLength(
"Y"),
1427 1. - gPad->GetRightMargin() - gStyle->GetTickLength(
"X"),
1428 gPad->GetBottomMargin() + gStyle->GetTickLength(
"Y") + 5 * 0.025);