Draw distribution into the active canvas.
234 bool flag_legend =
false;
235 bool flag_logy =
false;
236 bool flag_mode =
false;
237 bool flag_median =
false;
238 bool flag_mean =
false;
239 bool flag_quartiles =
false;
240 bool flag_deciles =
false;
241 bool flag_percentiles =
false;
242 bool flag_smooth1 =
false;
243 bool flag_smooth3 =
false;
244 bool flag_smooth5 =
false;
245 bool flag_smooth10 =
false;
254 std::string draw_options =
"";
257 if (options.find(
"smooth1") < options.size()) {
261 if (options.find(
"smooth3") < options.size()) {
265 if (options.find(
"smooth5") < options.size()) {
269 if (options.find(
"smooth10") < options.size()) {
270 flag_smooth10 =
true;
273 if (options.find(
"same") < options.size()) {
274 draw_options.append(
"SAME");
277 if (options.find(
"logy") < options.size()) {
281 if (options.find(
"L") < options.size()) {
285 if (options.find(
"D1") < options.size()) {
286 draw_options.append(
"C");
289 if (options.find(
"BTsi") < options.size()) {
292 else if (options.find(
"BTul") < options.size()) {
295 else if (options.find(
"BTll") < options.size()) {
302 if (options.find(
"B1") < options.size()) {
304 if (bandtype == 0 && intervals.size() != 2) {
306 intervals.push_back(0.1587);
307 intervals.push_back(0.8413);
309 else if (bandtype == 1 && intervals.size() != 1) {
311 intervals.push_back(0.6827);
313 else if (bandtype == 2 && intervals.size() != 1) {
315 intervals.push_back(0.90);
317 else if (bandtype == 3 && intervals.size() != 1) {
319 intervals.push_back(0.10);
323 if (options.find(
"B2") < options.size()) {
325 if (bandtype == 0 && intervals.size() != 4) {
327 intervals.push_back(0.1587);
328 intervals.push_back(0.8413);
329 intervals.push_back(0.0228);
330 intervals.push_back(0.9772);
332 else if (bandtype == 1 && intervals.size() != 2) {
334 intervals.push_back(0.6827);
335 intervals.push_back(0.9545);
337 else if (bandtype == 2 && intervals.size() != 2) {
339 intervals.push_back(0.90);
340 intervals.push_back(0.95);
342 else if (bandtype == 3 && intervals.size() != 2) {
344 intervals.push_back(0.10);
345 intervals.push_back(0.05);
349 if (options.find(
"B3") < options.size()) {
351 if (bandtype == 0 && intervals.size() != 6) {
353 intervals.push_back(0.1587);
354 intervals.push_back(0.8413);
355 intervals.push_back(0.0228);
356 intervals.push_back(0.9772);
357 intervals.push_back(0.0013);
358 intervals.push_back(0.9987);
360 else if (bandtype == 1 && intervals.size() != 3) {
362 intervals.push_back(0.6827);
363 intervals.push_back(0.9545);
364 intervals.push_back(0.9973);
366 else if (bandtype == 2 && intervals.size() != 3) {
368 intervals.push_back(0.90);
369 intervals.push_back(0.95);
370 intervals.push_back(0.99);
372 else if (bandtype == 3 && intervals.size() != 3) {
374 intervals.push_back(0.10);
375 intervals.push_back(0.05);
376 intervals.push_back(0.01);
380 if (options.find(
"CS0") < options.size()) {
383 else if (options.find(
"CS1") < options.size()) {
386 else if (options.find(
"CS2") < options.size()) {
389 else if (options.find(
"CS3") < options.size()) {
396 if (options.find(
"mode") < options.size()) {
400 if (options.find(
"median") < options.size()) {
403 if (options.find(
"mean") < options.size()) {
406 if (options.find(
"quartiles") < options.size()) {
407 flag_quartiles =
true;
409 if (options.find(
"deciles") < options.size()) {
412 if (options.find(
"percentiles") < options.size()) {
413 flag_percentiles =
true;
420 TLegend* legend =
new TLegend();
421 legend->SetBorderSize(0);
422 legend->SetFillColor(kWhite);
423 legend->SetTextAlign(12);
424 legend->SetTextFont(62);
425 legend->SetTextSize(0.03);
453 for (
int i = 0; i < nbands; ++i) {
457 double prob_high = 0;
458 double prob_interval = 0;
462 TH1D * hist_band = 0;
465 prob_low = intervals[2*(nbands-i)-2];
466 prob_high = intervals[2*(nbands-i)-1];
469 prob_interval = prob_high - prob_low;
473 else if (bandtype == 1) {
476 for (
int ibin = 1; ibin < hist_band->GetNbinsX(); ++ibin)
477 hist_band->SetBinContent(ibin, hist_band->GetBinContent(ibin)*
fHistogram->GetBinContent(ibin));
479 else if(bandtype == 2) {
483 prob_interval = intervals[nbands-1-i];
485 else if(bandtype == 3) {
489 prob_interval = 1.-intervals[nbands-1-i];
493 hist_band->SetFillStyle(1001);
494 hist_band->SetFillColor(col);
495 hist_band->SetLineColor(col);
498 hist_band->Draw(std::string(draw_options+std::string(
"same")).c_str());
501 fHistogram->Draw(std::string(std::string(
"SAME")+draw_options).c_str());
504 std::string legend_label;
506 legend_label.append(Form(
"central %.1f%% interval ", prob_interval*100));
507 else if (bandtype == 1)
508 legend_label.append(Form(
"smallest %.1f%% interval(s)", prob_interval*100));
509 else if (bandtype == 2)
510 legend_label.append(Form(
"%.0f%% upper limit", prob_interval*100));
511 else if (bandtype == 3)
512 legend_label.append(Form(
"%.0f%% lower limit", prob_interval*100));
514 legend->AddEntry(hist_band, legend_label.c_str(),
"F");
525 double ymax = ymaxhist;
529 ymin = 1e-4*ymaxhist;
532 TLine* line_quantiles =
new TLine();
533 line_quantiles->SetLineStyle(2);
534 line_quantiles->SetLineColor(
GetColor(3));
536 if (flag_quartiles) {
537 for (
int i = 1; i < 4; ++i) {
539 int quantile_xbin =
fHistogram->FindBin(quantile_x);
540 double quantile_y =
fHistogram->GetBinContent(quantile_xbin);
541 double quantile_ymin = 0;
543 quantile_ymin = 1e-4*ymaxhist;
544 line_quantiles->DrawLine(quantile_x, quantile_ymin, quantile_x, quantile_y);
546 TLegendEntry* le = legend->AddEntry(line_quantiles,
"quartiles",
"L");
550 le->SetFillColor(kWhite);
551 le->SetFillStyle(1001);
555 for (
int i = 1; i < 10; ++i) {
557 int quantile_xbin =
fHistogram->FindBin(quantile_x);
558 double quantile_y =
fHistogram->GetBinContent(quantile_xbin);
559 double quantile_ymin = 0;
561 quantile_ymin = 1e-4*ymaxhist;
562 line_quantiles->DrawLine(quantile_x, quantile_ymin, quantile_x, quantile_y);
564 TLegendEntry* le = legend->AddEntry(line_quantiles,
"deciles",
"FL");
566 le->SetFillStyle(1001);
569 if (flag_percentiles) {
570 for (
int i = 1; i < 100; ++i) {
572 int quantile_xbin =
fHistogram->FindBin(quantile_x);
573 double quantile_y =
fHistogram->GetBinContent(quantile_xbin);
574 double quantile_ymin = 0;
576 quantile_ymin = 1e-4*ymaxhist;
577 line_quantiles->DrawLine(quantile_x, quantile_ymin, quantile_x, quantile_y);
579 TLegendEntry* le = legend->AddEntry(line_quantiles,
"percentiles",
"L");
581 le->SetFillStyle(1001);
588 TMarker* marker_mode =
new TMarker(
fMode, 0.50*ymaxhist, 24);
589 marker_mode->SetMarkerColor(
GetColor(4));
590 marker_mode->SetMarkerSize(1.5);
592 TMarker* marker_mean =
new TMarker(
GetMean(), 0.55*ymaxhist, 20);
593 marker_mean->SetMarkerColor(
GetColor(4));
594 marker_mean->SetMarkerSize(1.5);
596 TMarker* marker_median =
new TMarker(
GetMedian(), 0.45*ymaxhist, 21);
597 marker_median->SetMarkerColor(
GetColor(4));
598 marker_median->SetMarkerSize(1.5);
601 TArrow* arrow_mode =
new TArrow(
fMode, 0.485*ymaxhist,
604 arrow_mode->SetLineColor(
GetColor(4));
605 arrow_mode->SetFillColor(
GetColor(4));
608 TArrow* arrow_std =
new TArrow(
GetMean()-
GetRMS(), 0.55*ymaxhist,
611 arrow_std->SetLineColor(
GetColor(4));
612 arrow_std->SetFillColor(
GetColor(4));
615 TArrow* arrow_ci =
new TArrow(
GetQuantile(0.1587), 0.45*ymaxhist,
618 arrow_ci->SetLineColor(
GetColor(4));
619 arrow_ci->SetFillColor(
GetColor(4));
631 TLegendEntry* le = legend->AddEntry(marker_mode,
"global mode",
"P");
632 le->SetMarkerStyle(24);
633 le->SetMarkerSize(1.5);
640 TLegendEntry* le = legend->AddEntry(arrow_std,
"mean and standard deviation",
"PL");
642 le->SetMarkerStyle(20);
643 le->SetMarkerSize(1.5);
649 marker_median->Draw();
650 TLegendEntry* le = legend->AddEntry(arrow_ci,
"median and central 68.3% interval",
"PL");
652 le->SetMarkerStyle(21);
653 le->SetMarkerSize(1.5);
658 double height = 0.03*legend->GetNRows();
666 fHistogram->GetYaxis()->SetRangeUser(ymin, 1.05*ymaxhist);
671 gPad->SetTopMargin(0.02);
673 double xlegend1 = gPad->GetLeftMargin() + 0.10 * (1.0 - gPad->GetRightMargin() - gPad->GetLeftMargin());
674 double xlegend2 = 1.0-gPad->GetRightMargin();
675 double ylegend1 = 1.-gPad->GetTopMargin()-height;
676 double ylegend2 = 1.-gPad->GetTopMargin();
679 legend->SetX1NDC(xlegend1);
680 legend->SetX2NDC(xlegend2);
681 legend->SetY1NDC(ylegend1);
682 legend->SetY2NDC(ylegend2);
690 gPad->SetTopMargin(1.-ylegend1+0.01);