65   typedef JRange<double>  JRange_t;
 
   96     JParser<> zap(
"General purpose plot program for 1D ROOT objects.");
 
   98     zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
  100     zap[
'w'] = 
make_field(canvas,     
"size of canvas <nx>x<ny> [pixels]")  = JCanvas(500, 500);
 
  102     zap[
'L'] = 
make_field(legend,     
"position legend e.g. TR")            = 
"", 
"TL", 
"TR", 
"BR", 
"BL";
 
  103     zap[
'x'] = 
make_field(
X,          
"abscissa range")                     = JRange_t();
 
  104     zap[
'y'] = 
make_field(
Y,          
"ordinate range")                     = JRange_t();
 
  105     zap[
'z'] = 
make_field(Z,          
"ordinate range of projection)")      = JRange_t();
 
  106     zap[
'X'] = 
make_field(logx,       
"logarithmic x-axis (-XX log10 axis)");
 
  107     zap[
'Y'] = 
make_field(logy,       
"logarithmic y-axis");
 
  108     zap[
'Z'] = 
make_field(logz,       
"logarithmic y-axis; after projection");
 
  109     zap[
'P'] = 
make_field(project,    
"projection")                         = 
'\0', 
'x', 
'X', 
'y', 
'Y';
 
  110     zap[
'>'] = 
make_field(xLabel,     
"x-axis label")                       = 
"";
 
  111     zap[
'^'] = 
make_field(yLabel,     
"y-axis label")                       = 
"";
 
  114     zap[
'l'] = 
make_field(lineWidth,  
"line width")                         = 2;
 
  115     zap[
'S'] = 
make_field(markerSize, 
"marker size")                        = 1.0;
 
  116     zap[
'O'] = 
make_field(option,     
"plotting option")                    = 
"";
 
  118     zap[
'B'] = 
make_field(batch,      
"batch processing");
 
  119     zap[
'T'] = 
make_field(title,      
"title")                              = 
"KM3NeT preliminary";
 
  121     zap[
'g'] = 
make_field(group,      
"group colour codes of objects")      = 1;
 
  122     zap[
't'] = 
make_field(xTimeFormat, 
"set time format for x-axis, e.g. \%d\\/\%m\\/\\%y%F1970-01-01 00:00:00") = 
"";
 
  127   catch(
const exception &error) {
 
  128     FATAL(error.what() << endl);
 
  132   gROOT->SetBatch(batch);
 
  134   TApplication* tp = 
new TApplication(
"user", NULL, NULL);
 
  135   TCanvas*      cv = 
new TCanvas(
"c1", 
"c1", canvas.x, canvas.y);
 
  137   JSinglePointer<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh()));
 
  139   gROOT->SetStyle(
"gplot");
 
  143   cv->SetFillStyle(4000);
 
  144   cv->SetFillColor(kWhite);
 
  153   Double_t xmin = numeric_limits<double>::max();
 
  154   Double_t xmax = numeric_limits<double>::lowest();
 
  156   Double_t ymin = numeric_limits<double>::max();
 
  157   Double_t ymax = numeric_limits<double>::lowest();
 
  162   const bool px = (project == 
'x' || project == 
'X');  
 
  163   const bool py = (project == 
'y' || project == 
'Y');  
 
  164   const bool pz = (project == 
'z' || project == 
'Z');  
 
  166   logy = (logy || logz);
 
  181     DEBUG(
"Input: " << *input << endl);
 
  186       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  190     const TRegexp regexp(input->getObjectName());
 
  192     TIter iter(dir->GetListOfKeys());
 
  194     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  196       const TString tag(key->GetName());
 
  198       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  202       if (tag.Contains(regexp)) {
 
  204         if        (title == JName_t) {
 
  205           title = key->GetName();
 
  206         } 
else if (title == JTitle_t) {
 
  207           title = key->GetTitle();
 
  210         JRootObject object(key->ReadObj());
 
  223           line.SetLineColor(marker.GetMarkerColor());
 
  227           TProfile& 
h1 = 
dynamic_cast<TProfile&
>(*object);
 
  229           object = h1.ProjectionX();
 
  235           TH2& h2 = 
dynamic_cast<TH2&
>(*object);
 
  241                                       h2.GetYaxis()->FindBin(Z.getLowerLimit()),
 
  242                                       h2.GetYaxis()->FindBin(Z.getUpperLimit()) - 1);
 
  246                                       h2.GetYaxis()->GetNbins());
 
  252                                       h2.GetXaxis()->FindBin(Z.getLowerLimit()),
 
  253                                       h2.GetXaxis()->FindBin(Z.getUpperLimit()) - 1);
 
  257                                       h2.GetXaxis()->GetNbins());
 
  261             ERROR(
"For 2D histograms, use option option -P for projections or use JPlot2D" << endl);
 
  270           TH3& h3 = 
dynamic_cast<TH3&
>(*object);
 
  286             ERROR(
"For 3D histograms, use option option -P for projections or use JPlot2D -P <projection>" << endl);
 
  295           dynamic_cast<TAttMarker&
>(*object) = marker; 
 
  301           dynamic_cast<TAttLine&
>  (*object) = line; 
 
  307           TH1& h1 = 
dynamic_cast<TH1&
>(*object);
 
  309           h1.SetStats(stats != -1);
 
  311           xmin = min(xmin, h1.GetXaxis()->GetXmin());
 
  312           xmax = max(xmax, h1.GetXaxis()->GetXmax());       
 
  313           ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
 
  314           ymax = max(ymax, h1.GetMaximum());
 
  317             for (
int i = 1; i <= h1.GetNbinsX(); ++i) {
 
  318               h1.SetBinError(i, 0.0);
 
  328             TAttFill& fill = 
dynamic_cast<TAttFill&
>(*object);
 
  330             fill.SetFillColor(marker.GetMarkerColor()); 
 
  337           TGraph& 
g1 = 
dynamic_cast<TGraph&
>(*object);
 
  339           for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  341             xmin = min(xmin, g1.GetX()[i]);
 
  342             xmax = max(xmax, g1.GetX()[i]);
 
  344             if (!logy || g1.GetY()[i] > 0.0) {
 
  345               ymin = min(ymin, g1.GetY()[i]);
 
  346               ymax = max(ymax, g1.GetY()[i]);
 
  354           TGraphErrors& g1 = 
dynamic_cast<TGraphErrors&
>(*object);
 
  357             for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  362             for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  363               if (!logy || g1.GetY()[i] - g1.GetEY()[i] > 0.0) { ymin = min(ymin, g1.GetY()[i] - g1.GetEY()[i]); }
 
  364               if (!logy || g1.GetY()[i] + g1.GetEY()[i] > 0.0) { ymax = max(ymax, g1.GetY()[i] + g1.GetEY()[i]); }
 
  372           TMultiGraph& m1 = 
dynamic_cast<TMultiGraph&
>(*object);
 
  374           for (TIter i1(m1.GetListOfGraphs()); TGraph* g1 = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  376             for (Int_t i = 0; i != g1->GetN(); ++i) {
 
  378               xmin = min(xmin, g1->GetX()[i]);
 
  379               xmax = max(xmax, g1->GetX()[i]);
 
  381               if (!logy || g1->GetY()[i] > 0.0) {
 
  382                 ymin = min(ymin, g1->GetY()[i]);
 
  383                 ymax = max(ymax, g1->GetY()[i]);
 
  392           TF2& f2 = 
dynamic_cast<TF2&
>(*object);
 
  395           TString formula = f2.GetExpFormula();
 
  396           TString _z_     = TString::Format(
"%f", 0.5 * (Z.getLowerLimit() + Z.getUpperLimit()));
 
  403           f2.GetRange(__xmin, __ymin, __xmax, __ymax);
 
  407             formula.ReplaceAll(
"y", _z_);
 
  411             f1->SetRange(__xmin, __xmax);
 
  415             formula.ReplaceAll(
"x", _z_);
 
  416             formula.ReplaceAll(
"y", 
"x");
 
  420             f1->SetRange(__ymin, __ymax);
 
  424             ERROR(
"For 2D functions, use option option -P for projections or use JPlot2D" << endl);
 
  429           DEBUG(
"TF1: " << f1->GetExpFormula() << endl);
 
  431           f1->SetParameters(f2.GetParameters());
 
  439           TF1& f1 = 
dynamic_cast<TF1&
>(*object);
 
  444           f1.GetRange(__xmin, __xmax);
 
  446           xmin = min(xmin, __xmin);
 
  447           xmax = max(xmax, __xmax);
 
  448           ymin = min(ymin, f1.GetMinimum());
 
  449           ymax = max(ymax, f1.GetMaximum());
 
  455           THStack& hs = 
dynamic_cast<THStack&
>(*object);
 
  457           NOTICE(
"THStack" << endl);
 
  459           TIterator* 
iterator = hs.GetHists()->MakeIterator();
 
  461           for (
size_t index = 1; 
TObject* i = iterator->Next(); ++index) {
 
  463             TH1& h1 = 
dynamic_cast<TH1&
>(*i);
 
  465             NOTICE(
"TH1[" << index << 
"] " << h1.GetName() << endl);
 
  467             xmin = min(xmin, h1.GetXaxis()->GetXmin());
 
  468             xmax = max(xmax, h1.GetXaxis()->GetXmax());
 
  470             ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
 
  471             ymax = max(ymax, h1.GetMaximum());
 
  474             h1.SetLineColor(kBlack);
 
  481         for (TString buffer[] = { 
object.getLabel(), input->getFilename().c_str(), 
"" }, *i = buffer; *i != 
""; ++i) {
 
  483           *i = (*i)(TRegexp(
"\\[.*\\]"));
 
  485           DEBUG(
"Label: <" << *i << 
">" << endl); 
 
  487           if (i->Length() > 2) {
 
  488             object.setLabel((*i)(1, i->Length() - 2));
 
  492         DEBUG(
"Add object: " << tag << 
" with label " << 
object.
getLabel() << endl);
 
  495           master = 
dynamic_cast<TH1*
>(
object.get());
 
  498         listOfObjects.push_back(
object);
 
  503   if (listOfObjects.empty()) {
 
  504     ERROR(
"Nothing to draw." << endl);
 
  509     TH1*         h1 = 
dynamic_cast<TH1*
>        (i->get());
 
  510     TGraph*      g1 = 
dynamic_cast<TGraph*
>     (i->get());
 
  511     TMultiGraph* m1 = 
dynamic_cast<TMultiGraph*
>(i->get());
 
  512     TAttLine*    ls = 
dynamic_cast<TAttLine*
>   (i->get());
 
  515     TIterator*   iterator = NULL;
 
  519       iterator = h1->GetListOfFunctions()->MakeIterator();
 
  521     } 
else if (g1 != NULL) {
 
  523       iterator = g1->GetListOfFunctions()->MakeIterator();
 
  525     } 
else if (m1 != NULL) {
 
  527       for (TIter i1(m1->GetListOfGraphs()); TGraph* gi = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  528         for (TIter i2(gi->GetListOfFunctions()); TF1* fi = 
dynamic_cast<TF1*
>(i2()); ) {
 
  533       iterator = list.MakeIterator();
 
  536     if (iterator != NULL) {
 
  538       Double_t x1 = numeric_limits<Double_t>::max();
 
  539       Double_t x2 = numeric_limits<Double_t>::lowest();
 
  541       for (
int ns = 0, nc = 1; TF1* f1 = (TF1*) iterator->Next(); ) {
 
  546         f1->GetRange(__x1, __x2);
 
  551         if (listOfObjects.size() == 1) {
 
  555           if (x1 != numeric_limits<Double_t>::max() &&
 
  556               x2 != numeric_limits<Double_t>::lowest()) {
 
  571           f1->SetLineColor(ls->GetLineColor());
 
  578         f1->GetRange(__xmin, __xmax);
 
  580         ymin = min(ymin, f1->GetMinimum(__xmin, __xmax));
 
  581         ymax = max(ymax, f1->GetMaximum(__xmin, __xmax));
 
  591   if (
X != JRange_t()) { 
 
  592     xmin = 
X.getLowerLimit();
 
  593     xmax = 
X.getUpperLimit();
 
  596   if (
Y != JRange_t()) {
 
  597     ymin = 
Y.getLowerLimit();
 
  598     ymax = 
Y.getUpperLimit();
 
  605   if (!listOfObjects.empty()) {
 
  607     if (
master == NULL || 
master->GetXaxis()->GetXmin() > xmin  || 
master->GetXaxis()->GetXmax() < xmax) {
 
  609       if        (
X != JRange_t()) {
 
  611         master = 
new TH1D(
"__H__", NULL, 100, 
X.getLowerLimit(), 
X.getUpperLimit());
 
  615       } 
else if (xmin < xmax) {
 
  617         master = 
new TH1D(
"__H__", NULL, 100, xmin, xmax);
 
  626     TText* p = 
new TText(0.5, 0.5, 
MAKE_CSTRING(
"No data"));
 
  634     if (logx) { gPad->SetLogx(); }
 
  635     if (logy) { gPad->SetLogy(); }
 
  637     master->GetXaxis()->SetRangeUser(xmin, xmax);
 
  643     master->SetTitle(title.c_str());
 
  648     if (xLabel != 
"") { 
master->GetXaxis()->SetTitle(xLabel.c_str()); 
master->GetXaxis()->CenterTitle(
true); }
 
  649     if (yLabel != 
"") { 
master->GetYaxis()->SetTitle(yLabel.c_str()); 
master->GetYaxis()->CenterTitle(
true); }
 
  651     master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(xmax/xmin) < 2) ||
 
  652                                          (logx >  1 &&      (xmax-xmin) < 2));
 
  654     master->GetYaxis()->SetMoreLogLabels( logy      && log10(ymax/ymin) < 2);
 
  655     master->GetYaxis()->SetNoExponent   ( logy      && log10(ymax/ymin) < 2);
 
  657     if (Ndivisions.first != 
"") {
 
  658       master->SetNdivisions(Ndivisions.second, Ndivisions.first.c_str());
 
  661     if (xTimeFormat != 
"") {
 
  663       master->GetXaxis()->SetTimeDisplay(1);
 
  665       if        (xTimeFormat == 
"utc") {
 
  666         master->GetXaxis()->SetTimeFormat(
"#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
 
  667         master->GetXaxis()->SetTimeOffset(0.0, 
"gmt");
 
  668       } 
else if (xTimeFormat == 
"UTC") {
 
  669         master->GetXaxis()->SetTimeFormat(
"%d-%m-%y");
 
  670         master->GetXaxis()->SetTimeOffset(0.0, 
"gmt");
 
  672         master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
 
  676     master->Draw(option.c_str());
 
  681       if (dynamic_cast<TH1*>(i->get()) != 
master) {
 
  690   if (grid.count(
'x') || grid.count(
'X')) { gPad->SetGridx(); }
 
  691   if (grid.count(
'y') || grid.count(
'Y')) { gPad->SetGridy(); }
 
  694     gStyle->SetOptStat(stats);
 
  696     gStyle->SetOptFit(kFALSE);
 
  701     DEBUG(
"Draw " << (*i)->GetName() << 
' ' << (*i)->GetTitle() << endl);
 
  703     string buffer(option);
 
  711     TF1*         f1 = 
dynamic_cast<TF1*
>        (i->get());
 
  712     TGraph*      g1 = 
dynamic_cast<TGraph*
>     (i->get());
 
  713     TMultiGraph* q1 = 
dynamic_cast<TMultiGraph*
>(i->get());
 
  720       if (g1->GetN() > 1 && drawLine)
 
  728       for (TIter i1(q1->GetListOfGraphs()); TGraph* gi = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  730         string zbuf = buffer;
 
  732         if (gi->GetN() > 1 && drawLine)
 
  737         gi->Draw(zbuf.c_str());
 
  742       (*i).Draw(buffer.c_str());
 
  750     Ssiz_t height = listOfObjects.size();
 
  754       width = max(width, i->getLabel().Length());
 
  757     TLegend* lg = 
getLegend(width, height, legend);
 
  760       lg->AddEntry(*i, 
" " + i->getLabel(), 
isTAttLine(*i) ? 
"L" : 
"LPF"); 
 
  776   return (
master != NULL ? 0 : 1);
 
Utility class to parse command line options. 
 
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()). 
 
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications. 
 
then echo Test string reversed by master(hit< return > to continue)." JProcess -c "JEcho" -rC fi if (( 1 ))
 
#define MAKE_CSTRING(A)
Make C-string. 
 
then for HISTOGRAM in h0 h1
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
 
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
 
bool isTAttLine(const TObject *object)
Get drawing option of TH1. 
 
T & getInstance(const T &object)
Get static instance from temporary object. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
then break fi done getCenter read X Y Z let X
 
static const char LABEL_TERMINATOR
label terminator 
 
void setRange(double &xmin, double &xmax, const bool logx)
Set axis range. 
 
TLegend * getLegend(const Int_t width, const Int_t height, const std::string option="TR")
Get legend. 
 
Auxiliary class to handle multiple boolean-like I/O. 
 
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer. 
 
#define DEBUG(A)
Message macros. 
 
Double_t g1(const Double_t x)
Function.