307 JParser<> zap(
"General purpose plot program for 1D ROOT objects.");
309 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
314 zap[
'L'] =
make_field(
legend,
"position legend e.g. TR [factor]") = JLegend(), JLegend(
"TL"), JLegend(
"TR"), JLegend(
"BR"), JLegend(
"BL");
315 zap[
'x'] =
make_field(X,
"abscissa range") = JRange_t::DEFAULT_RANGE();
316 zap[
'y'] =
make_field(Y,
"ordinate range") = JRange_t::DEFAULT_RANGE();
317 zap[
'z'] =
make_field(Z,
"ordinate range of projection)") = JRange_t::DEFAULT_RANGE();
318 zap[
'X'] =
make_field(logx,
"logarithmic x-axis (-XX log10 axis)");
321 zap[
'P'] =
make_field(project,
"projection") =
'\0',
'x',
'X',
'y',
'Y';
332 <<
"\"" <<
JName_t <<
"\" -> ROOT name; "
333 <<
"\"" <<
JTitle_t <<
"\" -> ROOT title)") =
"KM3NeT preliminary";
335 zap[
'g'] =
make_field(group,
"group colour codes of objects") = 1;
341 catch(
const exception &error) {
352 ((
TRootCanvas *) cv->GetCanvasImp())->
Connect(
"CloseWindow()",
"TApplication", tp,
"Terminate()");
358 gStyle->SetTitleOffset(
gStyle->GetTitleOffset() * 1.3,
"Y");
361 gROOT->SetStyle(
"gplot");
364 cv->SetFillStyle(4000);
370 JMarkerAttributes::getInstance().setMarkerSize(
markerSize);
371 JLineAttributes ::getInstance().setLineWidth (
lineWidth);
383 const bool px = (project ==
'x' || project ==
'X');
384 const bool py = (project ==
'y' || project ==
'Y');
385 const bool pz = (project ==
'z' || project ==
'Z');
409 ERROR(
"File: " << input->getFullFilename() <<
" not opened." <<
endl);
419 const TString tag(key->GetName());
425 if (tag.Contains(
regexp) && isTObject(key)) {
428 title = key->GetName();
430 title = key->GetTitle();
435 TAttMarker marker = JMarkerAttributes::getInstance().get(0);
436 TAttLine line = JLineAttributes ::getInstance().get(0);
441 marker = JMarkerAttributes::getInstance().get(getSize(
listOfObjects));
444 line = JLineAttributes::getInstance().get(getSize(
listOfObjects));
446 line.SetLineColor(marker.GetMarkerColor());
454 object = h1.ProjectionX();
460 TH2& h2 =
dynamic_cast<TH2&
>(*object);
466 h2.GetYaxis()->FindBin(Z.getLowerLimit()),
467 h2.GetYaxis()->FindBin(Z.getUpperLimit()) - 1);
471 h2.GetYaxis()->GetNbins());
477 h2.GetXaxis()->FindBin(Z.getLowerLimit()),
478 h2.GetXaxis()->FindBin(Z.getUpperLimit()) - 1);
482 h2.GetXaxis()->GetNbins());
486 ERROR(
"For 2D histograms, use option option -P for projections or use JPlot2D" <<
endl);
495 TH3&
h3 =
dynamic_cast<TH3&
>(*object);
511 ERROR(
"For 3D histograms, use option option -P for projections or use JPlot2D -P <projection>" <<
endl);
521 if (
dynamic_cast<TMarker*
>(
object.get()) ==
NULL) {
528 if (
dynamic_cast<TLine*
>(
object.get()) ==
NULL) {
529 dynamic_cast<TAttLine&
> (*object) = line;
540 if (!isTAttLine(
object) ||
fillArea < 0) {
541 fill.SetFillColor(marker.GetMarkerColor());
554 TH1& h1 =
dynamic_cast<TH1&
>(*object);
556 for (
int i = 1; i <= h1.GetNbinsX(); ++i) {
557 h1.SetBinError(i, 0.0);
564 TGraphErrors&
g1 =
dynamic_cast<TGraphErrors&
>(*object);
566 for (
Int_t i = 0; i !=
g1.GetN(); ++i) {
578 TH1& h1 =
dynamic_cast<TH1&
>(*object);
580 h1.SetStats(
stats != -1);
582 xmin = min(xmin, h1.GetXaxis()->GetXmin());
583 xmax = max(xmax, h1.GetXaxis()->GetXmax());
584 ymin = min(
ymin,
logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
587 if (!
logy && h1.GetListOfFunctions() !=
NULL) {
589 ymin = min(
ymin, f1->GetMinimum(h1.GetXaxis()->GetXmin(), h1.GetXaxis()->GetXmax()));
590 ymax = max(
ymax, f1->GetMaximum(h1.GetXaxis()->GetXmin(), h1.GetXaxis()->GetXmax()));
598 TGraph&
g1 =
dynamic_cast<TGraph&
>(*object);
600 for (
Int_t i = 0; i !=
g1.GetN(); ++i) {
602 xmin = min(xmin,
g1.GetX()[i]);
603 xmax = max(xmax,
g1.GetX()[i]);
605 if (!
logy ||
g1.GetY()[i] > 0.0) {
615 TGraphErrors&
g1 =
dynamic_cast<TGraphErrors&
>(*object);
617 for (
Int_t i = 0; i !=
g1.GetN(); ++i) {
618 if (!
logy ||
g1.GetY()[i] -
g1.GetEY()[i] > 0.0) {
ymin = min(
ymin,
g1.GetY()[i] -
g1.GetEY()[i]); }
619 if (!
logy ||
g1.GetY()[i] +
g1.GetEY()[i] > 0.0) {
ymax = max(
ymax,
g1.GetY()[i] +
g1.GetEY()[i]); }
628 for (
TIter i1(
m1.GetListOfGraphs()); TGraph*
g1 =
dynamic_cast<TGraph*
>(
i1()); ) {
630 for (
Int_t i = 0; i !=
g1->GetN(); ++i) {
632 xmin = min(xmin,
g1->GetX()[i]);
633 xmax = max(xmax,
g1->GetX()[i]);
635 if (!
logy ||
g1->GetY()[i] > 0.0) {
646 TF2& f2 =
dynamic_cast<TF2&
>(*object);
649 TString formula = f2.GetExpFormula();
650 TString
_z_ = TString::Format(
"%f", 0.5 * (Z.getLowerLimit() + Z.getUpperLimit()));
661 formula.ReplaceAll(
"y",
_z_);
669 formula.ReplaceAll(
"x",
_z_);
670 formula.ReplaceAll(
"y",
"x");
678 ERROR(
"For 2D functions, use option option -P for projections or use JPlot2D" <<
endl);
683 DEBUG(
"TF1: " << f1->GetExpFormula() <<
endl);
685 f1->SetParameters(f2.GetParameters());
693 TF1& f1 =
dynamic_cast<TF1&
>(*object);
717 TH1& h1 =
dynamic_cast<TH1&
>(*i);
719 NOTICE(
"TH1[" << index <<
"] " << h1.GetName() <<
endl);
721 xmin = min(xmin, h1.GetXaxis()->GetXmin());
722 xmax = max(xmax, h1.GetXaxis()->GetXmax());
724 ymin = min(
ymin,
logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
730 h1.SetFillColor(JMarkerAttributes::getInstance().get(index).
GetMarkerColor());
739 xmin = min(xmin, h1.GetX1());
740 xmax = max(xmax, h1.GetX2());
748 for (TString buffer[] = {
object.getLabel(), input->getFilename().c_str(),
"" }, *i = buffer; *i !=
""; ++i) {
750 *i = (*i)(
TRegexp(
"\\[.*\\]"));
752 if (i->Length() > 2) {
753 object.setLabel((*i)(1, i->Length() - 2));
757 DEBUG(
"Add object: " << tag <<
" with label <" <<
object.getLabel() <<
">" <<
endl);
760 master =
dynamic_cast<TH1*
>(
object.get());
778 TH1* h1 =
dynamic_cast<TH1*
> (i->get());
779 TGraph*
g1 =
dynamic_cast<TGraph*
> (i->get());
789 iterator.reset(h1->GetListOfFunctions()->MakeIterator());
793 iterator.reset(
g1->GetListOfFunctions()->MakeIterator());
797 for (
TIter i1(
m1->GetListOfGraphs()); TGraph*
gi =
dynamic_cast<TGraph*
>(
i1()); ) {
798 for (
TIter i2(
gi->GetListOfFunctions()); TF1*
fi =
dynamic_cast<TF1*
>(
i2()); ) {
811 for (
int nf = 0, ns = 0, nc = 1; TF1* f1 = (TF1*)
iterator->Next(); ++
nf) {
813 f1->GetRange(x1[1], x2[1]);
816 dynamic_cast<TAttLine&
>(*f1) = JLineAttributes::getInstance().get(0);
820 if (x1[0] == x1[1] &&
826 f1->SetLineStyle(JLineAttributes ::getInstance().get(ns).
GetLineStyle());
827 f1->SetLineColor(JMarkerAttributes::getInstance().get(nc).
GetMarkerColor());
833 f1->SetLineColor(
ls->GetLineColor());
834 f1->SetLineStyle(JLineAttributes::getInstance().get(ns++).
GetLineStyle());
857 xmin = X.getLowerLimit();
858 xmax = X.getUpperLimit();
862 ymin = Y.getLowerLimit();
863 ymax = Y.getUpperLimit();
873 DEBUG(
"plot frame " << xmin <<
' ' << xmax <<
' ' <<
ymin <<
' ' <<
ymax <<
endl);
903 if (logx) {
gPad->SetLogx(); }
906 master->SetTitle(title.c_str());
908 master->GetXaxis()->SetRangeUser(max(xmin,
master->GetXaxis()->GetXmin()),
909 min(xmax,
master->GetXaxis()->GetXmax()));
911 if (logx > 1) { setLogarithmicX(
master); }
912 if (logx > 2) {
master->GetXaxis()->SetNoExponent(); }
915 if (
logy > 2) {
master->GetYaxis()->SetNoExponent(); }
923 master->GetXaxis()->SetMoreLogLabels((logx == 1 &&
log10(xmax/xmin) < 2) ||
924 (logx > 1 && (xmax-xmin) < 2));
929 master->SetNdivisions(i->second, i->first.c_str());
934 master->GetXaxis()->SetTimeDisplay(1);
937 master->GetXaxis()->SetTimeFormat(
"#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
938 master->GetXaxis()->SetTimeOffset(0.0,
"gmt");
940 master->GetXaxis()->SetTimeFormat(
"%d-%m-%y");
941 master->GetXaxis()->SetTimeOffset(0.0,
"gmt");
947 master->Draw(option.c_str());
954 if (
dynamic_cast<TH1*
>(i->get()) !=
master) {
955 if (logx > 1) { setLog<typelist> X(i->get(),
'X'); }
956 if (
logy > 1) { setLog<typelist> Y(i->get(),
'Y'); }
961 if (
grid.count(
'x') ||
grid.count(
'X')) {
gPad->SetGridx(); }
962 if (
grid.count(
'y') ||
grid.count(
'Y')) {
gPad->SetGridy(); }
972 DEBUG(
"Draw " << (*i)->GetName() <<
' ' << (*i)->GetTitle() <<
endl);
974 string buffer(option);
982 TF1* f1 =
dynamic_cast<TF1*
> (i->get());
983 TGraph*
g1 =
dynamic_cast<TGraph*
> (i->get());
994 (
dynamic_cast<TGraphErrors*
> (
g1) ==
NULL &&
1001 for (
TIter i1(
q1->GetListOfGraphs()); TGraph*
gi =
dynamic_cast<TGraph*
>(
i1()); ) {
1003 string zbuf = buffer;
1010 gi->Draw(zbuf.c_str());
1015 (*i).Draw(buffer.c_str());
1036 width = max(width,
getWidth(
object.getLabel()));
1047 lg->AddEntry(
object,
" " +
object.getLabel(), isTAttLine(
object) || option.find(
"HIST") != string::npos || option.find(
"hist") != string::npos ?
"L" : isTAttFill(
object) &&
fillArea != 0 ?
"F" :
"P");