246     JParser<> zap(
"General purpose plot program for 1D ROOT objects.");
 
  248     zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
  250     zap[
'w'] = 
make_field(canvas,     
"size of canvas <nx>x<ny> [pixels]")  = 
JCanvas(500, 500);
 
  253     zap[
'L'] = 
make_field(legend,     
"position legend e.g. TR [factor]")   = JLegend(), JLegend(
"TL"), JLegend(
"TR"), JLegend(
"BR"), JLegend(
"BL");
 
  254     zap[
'x'] = 
make_field(X,          
"abscissa range")                     = JRange_t::DEFAULT_RANGE();
 
  255     zap[
'y'] = 
make_field(Y,          
"ordinate range")                     = JRange_t::DEFAULT_RANGE();
 
  256     zap[
'z'] = 
make_field(Z,          
"ordinate range of projection)")      = JRange_t::DEFAULT_RANGE();
 
  257     zap[
'X'] = 
make_field(logx,       
"logarithmic x-axis (-XX log10 axis)");
 
  258     zap[
'Y'] = 
make_field(logy,       
"logarithmic y-axis");
 
  259     zap[
'Z'] = 
make_field(logz,       
"logarithmic y-axis; after projection");
 
  261     zap[
'>'] = 
make_field(xLabel,     
"x-axis label")                       = 
"";
 
  262     zap[
'^'] = 
make_field(yLabel,     
"y-axis label")                       = 
"";
 
  263     zap[
'C'] = 
make_field(drawLine,   
"draw line (-C black-and-white -CC colour)");
 
  264     zap[
'F'] = 
make_field(fillArea,   
"fill area")                          = 0;
 
  265     zap[
'l'] = 
make_field(lineWidth,  
"line width")                         = 2;
 
  266     zap[
'S'] = 
make_field(markerSize, 
"marker size")                        = 1.0;
 
  267     zap[
'O'] = 
make_field(option,     
"plotting option")                    = 
"";
 
  269     zap[
'B'] = 
make_field(batch,      
"batch processing");
 
  270     zap[
'T'] = 
make_field(title,      
"graphics title ("  
  271                           << 
"\"" << JName_t  << 
"\" -> ROOT name; " 
  272                           << 
"\"" << JTitle_t << 
"\" -> ROOT title)")      = 
"KM3NeT preliminary";
 
  274     zap[
'g'] = 
make_field(group,      
"group colour codes of objects")      = 1;
 
  275     zap[
't'] = 
make_field(xTimeFormat, 
"set time format for x-axis, e.g. \%d\\/\%m\\/\\%y%F1970-01-01 00:00:00") = 
"";
 
  280   catch(
const exception &error) {
 
  281     FATAL(error.what() << endl);
 
  285   gROOT->SetBatch(batch);
 
  287   TApplication* tp = 
new TApplication(
"user", NULL, NULL);
 
  288   TCanvas*      cv = 
new TCanvas(
"c1", 
"c1", canvas.
x, canvas.
y);
 
  290   unique_ptr<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh(), parameters));
 
  293     gStyle->SetTitleOffset(gStyle->GetTitleOffset() * 1.3, 
"Y");
 
  296   gROOT->SetStyle(
"gplot");
 
  299   cv->SetFillStyle(4000);
 
  300   cv->SetFillColor(kWhite);
 
  309   Double_t 
xmin = numeric_limits<double>::max();
 
  310   Double_t 
xmax = numeric_limits<double>::lowest();
 
  312   Double_t ymin = numeric_limits<double>::max();
 
  313   Double_t ymax = numeric_limits<double>::lowest();
 
  322   logy = (logy || logz);
 
  337     DEBUG(
"Input: " << *input << endl);
 
  342       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  346     const TRegexp regexp(input->getObjectName());
 
  348     TIter iter(dir->GetListOfKeys());
 
  350     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  352       const TString tag(key->GetName());
 
  354       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  358       if (tag.Contains(regexp) && 
isTObject(key)) {
 
  360         if        (title == JName_t) {
 
  361           title = key->GetName();
 
  362         } 
else if (title == JTitle_t) {
 
  363           title = key->GetTitle();
 
  378           line.SetLineColor(marker.GetMarkerColor());
 
  384           TProfile& h1 = 
dynamic_cast<TProfile&
>(*object);
 
  386           object = h1.ProjectionX();
 
  392           TH2& h2 = 
dynamic_cast<TH2&
>(*object);
 
  403                                       h2.GetYaxis()->GetNbins());
 
  414                                       h2.GetXaxis()->GetNbins());
 
  418             ERROR(
"For 2D histograms, use option option -P for projections or use JPlot2D" << endl);
 
  427           TH3& h3 = 
dynamic_cast<TH3&
>(*object);
 
  443             ERROR(
"For 3D histograms, use option option -P for projections or use JPlot2D -P <projection>" << endl);
 
  453           if (
dynamic_cast<TMarker*
>(
object.get()) == NULL) {
 
  454             dynamic_cast<TAttMarker&
>(*object) = marker; 
 
  460           if (
dynamic_cast<TLine*
>(
object.get())   == NULL) {
 
  461             dynamic_cast<TAttLine&
>  (*object) = line;
 
  470             TAttFill& fill = 
dynamic_cast<TAttFill&
>(*object);
 
  473               fill.SetFillColor(marker.GetMarkerColor());
 
  474               fill.SetFillStyle(abs(fillArea));
 
  486             TH1& h1 = 
dynamic_cast<TH1&
>(*object);
 
  488             for (
int i = 1; i <= h1.GetNbinsX(); ++i) {
 
  489               h1.SetBinError(i, 0.0);
 
  496             TGraphErrors& 
g1 = 
dynamic_cast<TGraphErrors&
>(*object);
 
  498             for (Int_t i = 0; i != 
g1.GetN(); ++i) {
 
  510           TH1& h1 = 
dynamic_cast<TH1&
>(*object);
 
  512           h1.SetStats(stats != -1);
 
  514           xmin = min(
xmin, h1.GetXaxis()->GetXmin());
 
  515           xmax = max(
xmax, h1.GetXaxis()->GetXmax());       
 
  516           ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
 
  517           ymax = max(ymax, h1.GetMaximum());
 
  519           if (!logy && h1.GetListOfFunctions() != NULL) {
 
  520             for (unique_ptr<TIterator> 
iterator(h1.GetListOfFunctions()->MakeIterator()); TF1* 
f1 = (TF1*) 
iterator->Next(); ) {
 
  521               ymin = min(ymin, 
f1->GetMinimum(h1.GetXaxis()->GetXmin(), h1.GetXaxis()->GetXmax()));
 
  522               ymax = max(ymax, 
f1->GetMaximum(h1.GetXaxis()->GetXmin(), h1.GetXaxis()->GetXmax()));
 
  530           TGraph& 
g1 = 
dynamic_cast<TGraph&
>(*object);
 
  532           for (Int_t i = 0; i != 
g1.GetN(); ++i) {
 
  537             if (!logy || 
g1.GetY()[i] > 0.0) {
 
  538               ymin = min(ymin, 
g1.GetY()[i]);
 
  539               ymax = max(ymax, 
g1.GetY()[i]);
 
  547           TGraphErrors& 
g1 = 
dynamic_cast<TGraphErrors&
>(*object);
 
  549           for (Int_t i = 0; i != 
g1.GetN(); ++i) {
 
  550             if (!logy || 
g1.GetY()[i] - 
g1.GetEY()[i] > 0.0) { ymin = min(ymin, 
g1.GetY()[i] - 
g1.GetEY()[i]); }
 
  551             if (!logy || 
g1.GetY()[i] + 
g1.GetEY()[i] > 0.0) { ymax = max(ymax, 
g1.GetY()[i] + 
g1.GetEY()[i]); }
 
  558           TMultiGraph& m1 = 
dynamic_cast<TMultiGraph&
>(*object);
 
  560           for (TIter i1(m1.GetListOfGraphs()); TGraph* 
g1 = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  562             for (Int_t i = 0; i != 
g1->GetN(); ++i) {
 
  567               if (!logy || 
g1->GetY()[i] > 0.0) {
 
  568                 ymin = min(ymin, 
g1->GetY()[i]);
 
  569                 ymax = max(ymax, 
g1->GetY()[i]);
 
  578           TF2& f2 = 
dynamic_cast<TF2&
>(*object);
 
  581           TString formula = f2.GetExpFormula();
 
  589           f2.GetRange(__xmin, __ymin, __xmax, __ymax);
 
  593             formula.ReplaceAll(
"y", _z_);
 
  597             f1->SetRange(__xmin, __xmax);
 
  601             formula.ReplaceAll(
"x", _z_);
 
  602             formula.ReplaceAll(
"y", 
"x");
 
  606             f1->SetRange(__ymin, __ymax);
 
  610             ERROR(
"For 2D functions, use option option -P for projections or use JPlot2D" << endl);
 
  615           DEBUG(
"TF1: " << 
f1->GetExpFormula() << endl);
 
  617           f1->SetParameters(f2.GetParameters());
 
  625           TF1& 
f1 = 
dynamic_cast<TF1&
>(*object);
 
  630           f1.GetRange(__xmin, __xmax);
 
  634           ymin = min(ymin, 
f1.GetMinimum());
 
  635           ymax = max(ymax, 
f1.GetMaximum());
 
  641           THStack& hs = 
dynamic_cast<THStack&
>(*object);
 
  643           NOTICE(
"THStack" << endl);
 
  645           unique_ptr<TIterator> 
iterator(hs.GetHists()->MakeIterator());
 
  649             TH1& h1 = 
dynamic_cast<TH1&
>(*i);
 
  651             NOTICE(
"TH1[" << index << 
"] " << h1.GetName() << endl);
 
  653             xmin = min(
xmin, h1.GetXaxis()->GetXmin());
 
  654             xmax = max(
xmax, h1.GetXaxis()->GetXmax());
 
  656             ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
 
  657             ymax = max(ymax, h1.GetMaximum());
 
  660             h1.SetLineColor(kBlack);
 
  669           TLine& h1 = 
dynamic_cast<TLine&
>(*object);
 
  673           ymin = min(ymin, h1.GetY1());
 
  674           ymax = max(ymax, h1.GetY2());
 
  680         for (TString buffer[] = { 
object.getLabel(), input->getFilename().c_str(), 
"" }, *i = buffer; *i != 
""; ++i) {
 
  682           *i = (*i)(TRegexp(
"\\[.*\\]"));
 
  684           if (i->Length() > 2) {
 
  685             object.setLabel((*i)(1, i->Length() - 2));
 
  689         DEBUG(
"Add object: " << tag << 
" with label <" << 
object.
getLabel() << 
">" << endl);
 
  691         if (master == NULL) {
 
  692           master = 
dynamic_cast<TH1*
>(
object.get());
 
  695         listOfObjects.push_back(
object);
 
  700   if (listOfObjects.empty()) {
 
  701     ERROR(
"Nothing to draw." << endl);
 
  710     TH1*         h1 = 
dynamic_cast<TH1*
>        (i->get());
 
  711     TGraph*      
g1 = 
dynamic_cast<TGraph*
>     (i->get());
 
  712     TMultiGraph* m1 = 
dynamic_cast<TMultiGraph*
>(i->get());
 
  713     TAttLine*    
ls = 
dynamic_cast<TAttLine*
>   (i->get());
 
  721       iterator.reset(h1->GetListOfFunctions()->MakeIterator());
 
  723     } 
else if (
g1 != NULL) {
 
  725       iterator.reset(
g1->GetListOfFunctions()->MakeIterator());
 
  727     } 
else if (m1 != NULL) {
 
  729       for (TIter i1(m1->GetListOfGraphs()); TGraph* gi = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  730         for (TIter i2(gi->GetListOfFunctions()); TF1* fi = 
dynamic_cast<TF1*
>(i2()); ) {
 
  740       Double_t x1[] = { numeric_limits<Double_t>::max(),    numeric_limits<Double_t>::max() };
 
  741       Double_t x2[] = { numeric_limits<Double_t>::lowest(), numeric_limits<Double_t>::lowest() };
 
  743       for (
int nf = 0, 
ns = 0, nc = 1; TF1* 
f1 = (TF1*) 
iterator->Next(); ++nf) {
 
  745         f1->GetRange(x1[1], x2[1]);
 
  750         if (listOfObjects.size() == 1) {
 
  752           if      (x1[0] == x1[1] && 
 
  765           f1->SetLineColor(
ls->GetLineColor());
 
  796   } 
else if (ymax > ymin) {
 
  802   if (!listOfObjects.empty()) {
 
  804     if (master == NULL) {
 
  806       master = 
new TH1D(MASTER.c_str(), NULL, 1000, 
xmin, 
xmax);
 
  808       master->SetStats(kFALSE);
 
  810       for (Int_t i = 1; i <= master->GetXaxis()->GetNbins(); ++i) {
 
  811         master->SetBinContent(i, ymin);
 
  816   if (master == NULL) {
 
  818     TText* p = 
new TText(0.5, 0.5, 
MAKE_CSTRING(
"No data"));
 
  826     if (logx) { gPad->SetLogx(); }
 
  827     if (logy) { gPad->SetLogy(); }
 
  829     master->SetTitle(title.c_str());
 
  831     master->GetXaxis()->SetRangeUser(
xmin, 
xmax);
 
  835     if (logx > 2) { master->GetXaxis()->SetNoExponent(); }
 
  837     master->SetMinimum(ymin);
 
  838     master->SetMaximum(ymax);
 
  840     if (xLabel != 
"") { master->GetXaxis()->SetTitle(xLabel.c_str()); master->GetXaxis()->CenterTitle(
true); }
 
  841     if (yLabel != 
"") { master->GetYaxis()->SetTitle(yLabel.c_str()); master->GetYaxis()->CenterTitle(
true); }
 
  843     master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(
xmax/
xmin) < 2) ||
 
  846     master->GetYaxis()->SetMoreLogLabels( logy      && log10(ymax/ymin) < 2);
 
  847     master->GetYaxis()->SetNoExponent   ( logy      && log10(ymax/ymin) < 2);
 
  850       master->SetNdivisions(i->second, i->first.c_str());
 
  853     if (xTimeFormat != 
"") {
 
  855       master->GetXaxis()->SetTimeDisplay(1);
 
  857       if        (xTimeFormat == 
"utc") {
 
  858         master->GetXaxis()->SetTimeFormat(
"#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
 
  859         master->GetXaxis()->SetTimeOffset(0.0, 
"gmt");
 
  860       } 
else if (xTimeFormat == 
"UTC") {
 
  861         master->GetXaxis()->SetTimeFormat(
"%d-%m-%y");
 
  862         master->GetXaxis()->SetTimeOffset(0.0, 
"gmt");
 
  864         master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
 
  868     master->Draw(option.c_str());
 
  873       if (
dynamic_cast<TH1*
>(i->get()) != master) {
 
  874         if      (setLogX<TH1>         (i->get())) {}
 
  875         else if (setLogX<TF1>         (i->get())) {}
 
  876         else if (setLogX<TGraphErrors>(i->get())) {}
 
  877         else if (setLogX<TGraph>      (i->get())) {}
 
  878         else if (setLogX<TMultiGraph> (i->get())) {}
 
  879         else if (setLogX<TLine>       (i->get())) {}
 
  880         else if (setLogX<TEllipse>    (i->get())) {}
 
  885   if (grid.count(
'x') || grid.count(
'X')) { gPad->SetGridx(); }
 
  886   if (grid.count(
'y') || grid.count(
'Y')) { gPad->SetGridy(); }
 
  889     gStyle->SetOptStat(stats);
 
  891     gStyle->SetOptFit(kFALSE);
 
  896     DEBUG(
"Draw " << (*i)->GetName() << 
' ' << (*i)->GetTitle() << endl);
 
  898     string buffer(option);
 
  906     TF1*         
f1 = 
dynamic_cast<TF1*
>        (i->get());
 
  907     TGraph*      
g1 = 
dynamic_cast<TGraph*
>     (i->get());
 
  908     TMultiGraph* q1 = 
dynamic_cast<TMultiGraph*
>(i->get());
 
  915       if (
g1->GetN() > 1 && drawLine)
 
  917       else if (fillArea == 0 ||
 
  918                (
dynamic_cast<TGraphErrors*
>     (
g1) == NULL &&
 
  919                 dynamic_cast<TGraphAsymmErrors*
>(
g1) == NULL))
 
  925       for (TIter i1(q1->GetListOfGraphs()); TGraph* gi = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  927         string zbuf = buffer;
 
  929         if (gi->GetN() > 1 && drawLine)
 
  934         gi->Draw(zbuf.c_str());
 
  939       (*i).Draw(buffer.c_str());
 
  945   if (legend.is_valid()) {
 
  948       group = listOfObjects.size();
 
  951     Ssiz_t height = listOfObjects.size()/group;
 
  955       width = max(width, getWidth(i->getLabel()));
 
  958     TLegend* lg = 
getLegend(width, height, legend.location, legend.factor);
 
  960     for (
size_t i = 0; i < listOfObjects.size(); i += group) {
 
  964       if (
dynamic_cast<TMarker*
>(
object.get()) == NULL  &&
 
  965           dynamic_cast<TLine*
>  (
object.get()) == NULL  &&
 
  966           dynamic_cast<TText*
>  (
object.get()) == NULL) {
 
  984   return (master != NULL ? 0 : 1);
 
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
#define MAKE_CSTRING(A)
Make C-string.
 
Double_t g1(const Double_t x)
Function.
 
Utility class to parse parameter values.
 
Auxiliary data structure for TObject with a user defined label.
 
Utility class to parse command line options.
 
Data structure for size of TCanvas.
 
int y
number of pixels in Y
 
int x
number of pixels in X
 
Wrapper class around ROOT TStyle.
 
const JPolynome f1(1.0, 2.0, 3.0)
Function.
 
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
 
void setLogarithmicX(TList *list)
Make x-axis of objects in list logarithmic (e.g. after using log10()).
 
void setRange(double &xmin, double &xmax, const bool logx)
Set axis range.
 
bool isTAttFill(const TObject *object)
Get drawing option of object.
 
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
 
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
 
bool isTAttLine(const TObject *object)
Get drawing option of object.
 
static const char LABEL_TERMINATOR
label terminator
 
T & getInstance(const T &object)
Get static instance from temporary object.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
TLegend * getLegend(const Int_t width, const Int_t height, const std::string option, const Double_t factor=1.0)
Get legend.
 
Type definition of range.
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
 
JProperties getProperties()
Get properties of this class.
 
Auxiliary data structure to list files in directory.