50   typedef JRange<double>  JRange_t;
 
   75     JParser<> zap(
"General purpose plot program for 2D ROOT objects.");
 
   77     zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
   79     zap[
'w'] = 
make_field(canvas,     
"size of canvas <nx>x<ny> [pixels]")  = JCanvas(500, 500);
 
   81     zap[
'x'] = 
make_field(X,          
"x-abscissa range")                   = JRange_t();
 
   82     zap[
'y'] = 
make_field(Y,          
"y-abscissa range")                   = JRange_t();
 
   83     zap[
'z'] = 
make_field(Z,          
"ordinate range")                     = JRange_t();
 
   84     zap[
'X'] = 
make_field(logx,       
"logarithmic x-axis (-XX log10 axis)");
 
   85     zap[
'Y'] = 
make_field(logy,       
"logarithmic y-axis (-YY log10 axis)");
 
   86     zap[
'Z'] = 
make_field(logz,       
"logarithmic z-axis");
 
   87     zap[
'>'] = 
make_field(xLabel,     
"x-axis label")                       = 
"";
 
   88     zap[
'<'] = 
make_field(yLabel,     
"y-axis label")                       = 
"";
 
   89     zap[
'^'] = 
make_field(zLabel,     
"z-axis label")                       = 
"";
 
   90     zap[
'l'] = 
make_field(lineWidth,  
"line width")                         = 2;
 
   91     zap[
'O'] = 
make_field(option,     
"plotting option")                    = 
"";
 
   92     zap[
'B'] = 
make_field(batch,      
"batch processing");
 
   93     zap[
'T'] = 
make_field(title,      
"title")                              = 
"KM3NeT preliminary";
 
   95     zap[
'p'] = 
make_field(palette,    
"palette")                            = 53;
 
  100   catch(
const exception &error) {
 
  101     FATAL(error.what() << endl);
 
  105   gROOT->SetBatch(batch);
 
  107   TApplication* tp = 
new TApplication(
"user", NULL, NULL);
 
  108   TCanvas*      cv = 
new TCanvas(
"c1", 
"c1", canvas.x, canvas.y);
 
  110   JSinglePointer<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh()));
 
  112   gStyle->SetPalette(palette);
 
  114   gROOT->SetStyle(
"gplot");
 
  118   cv->SetFillStyle(4000);
 
  119   cv->SetFillColor(kWhite);
 
  125   lineAttributes.push_back(TAttLine(kBlack,   1, lineWidth));
 
  126   lineAttributes.push_back(TAttLine(kRed,     1, lineWidth));
 
  127   lineAttributes.push_back(TAttLine(kBlue,    1, lineWidth));
 
  128   lineAttributes.push_back(TAttLine(kGreen,   1, lineWidth));
 
  129   lineAttributes.push_back(TAttLine(kMagenta, 1, lineWidth));
 
  130   lineAttributes.push_back(TAttLine(kYellow,  1, lineWidth));
 
  131   lineAttributes.push_back(TAttLine(kCyan,    1, lineWidth));
 
  134   Double_t xmin = +numeric_limits<double>::max();
 
  135   Double_t xmax = -numeric_limits<double>::max();
 
  136   Double_t ymin = +numeric_limits<double>::max();
 
  137   Double_t ymax = -numeric_limits<double>::max();
 
  138   Double_t zmin = +numeric_limits<double>::max();
 
  139   Double_t zmax = -numeric_limits<double>::max();
 
  147     DEBUG(
"Input: " << *input << endl);
 
  152       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  156     const TRegexp regexp(input->getObjectName());
 
  158     TIter iter(dir->GetListOfKeys());
 
  160     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  162       const TString tag(key->GetName());
 
  164       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  168       if (tag.Contains(regexp)) {
 
  171           title = key->GetName();
 
  174         JRootObject object(key->ReadObj());
 
  178           dynamic_cast<TAttLine&>(*
object) = lineAttributes[listOfObjects.size() % lineAttributes.size()];
 
  184           TH2& h2 = dynamic_cast<TH2&>(*
object);
 
  186           h2.SetStats(stats != -1);
 
  188           xmin = min(xmin, h2.GetXaxis()->GetXmin());
 
  189           xmax = max(xmax, h2.GetXaxis()->GetXmax());
 
  190           ymin = min(ymin, h2.GetYaxis()->GetXmin());
 
  191           ymax = max(ymax, h2.GetYaxis()->GetXmax());
 
  192           zmin = min(zmin, h2.GetMinimum());
 
  193           zmax = max(zmax, h2.GetMaximum());
 
  199           TGraph& 
g1 = dynamic_cast<TGraph&>(*
object);
 
  201           for (Int_t i = 0; i != 
g1.GetN(); ++i) {
 
  203             xmin = min(xmin, 
g1.GetX()[i]);
 
  204             xmax = max(xmax, 
g1.GetX()[i]);
 
  205             ymin = min(ymin, 
g1.GetY()[i]);
 
  206             ymax = max(ymax, 
g1.GetY()[i]);
 
  212             if (dynamic_cast<TGraph*>(i->get()) != NULL) {
 
  223           TGraph2D& g2 = dynamic_cast<TGraph2D&>(*
object);
 
  225           for (Int_t i = 0; i != g2.GetN(); ++i) {
 
  227             if (!logy || g2.GetZ()[i] > 0.0) {
 
  228               xmin = min(xmin, g2.GetX()[i]);
 
  229               xmax = max(xmax, g2.GetX()[i]);
 
  230               ymin = min(ymin, g2.GetY()[i]);
 
  231               ymax = max(ymax, g2.GetY()[i]);
 
  232               zmin = min(zmin, g2.GetZ()[i]);
 
  233               zmax = max(zmax, g2.GetZ()[i]);
 
  237           if (Z != JRange_t()) {
 
  238             g2.SetMinimum(Z.getLowerLimit());
 
  239             g2.SetMaximum(Z.getUpperLimit());
 
  248           TF2& f2 = dynamic_cast<TF2&>(*
object);
 
  250           f2.SetLineColor(kRed);
 
  251           f2.SetTitle((title +  
";" + xLabel + 
";" + yLabel + 
";" + zLabel).c_str());
 
  253           if (xmin != +numeric_limits<double>::max()  &&
 
  254               xmax != -numeric_limits<double>::max()  &&
 
  255               ymin != +numeric_limits<double>::max()  &&
 
  256               ymax != -numeric_limits<double>::max()) {
 
  257             zmin = min(zmin, f2.GetMinimum(xmin, xmax, ymin, ymax));
 
  258             zmax = max(zmax, f2.GetMaximum(xmin, xmax, ymin, ymax));
 
  263         for (TString buffer[] = { 
object.getLabel(), input->getFilename().c_str(), 
"" }, *i = buffer; *i != 
""; ++i) {
 
  265           *i = (*i)(TRegexp(
"\\[.*\\]"));
 
  267           if ((*i).Length() > 2) {
 
  268             object.setLabel((*i)(1, (*i).Length() - 2));
 
  272         DEBUG(
"Add object: " << tag << 
" with label " << 
object.
getLabel() << endl);
 
  274         if (dynamic_cast<TH2*>     (
object.
get())  !=  NULL ||
 
  275             dynamic_cast<TGraph*>  (
object.
get())  !=  NULL ||
 
  276             dynamic_cast<TGraph2D*>(
object.
get())  !=  NULL ||
 
  277             dynamic_cast<TF2*>     (
object.
get())  !=  NULL) {
 
  279           if (master == NULL) {
 
  280             master = dynamic_cast<TH2*>(
object.
get());
 
  283           listOfObjects.push_back(
object);
 
  286           ERROR(
"For other objects than 2D histograms, use JPlot1D" << endl);
 
  292   if (listOfObjects.empty()) {
 
  293     ERROR(
"Nothing to draw." << endl);
 
  300   if (option.find(
"COLZ") != string::npos ||
 
  301       option.find(
"colz") != string::npos) {
 
  302     gPad->SetRightMargin(0.20);
 
  305   if (X != JRange_t()) {    
 
  306     xmin = X.getLowerLimit();
 
  307     xmax = X.getUpperLimit();
 
  310   if (Y != JRange_t()) {    
 
  311     ymin = Y.getLowerLimit();
 
  312     ymax = Y.getUpperLimit();
 
  315   if (Z != JRange_t()) {
 
  316     zmin = Z.getLowerLimit();
 
  317     zmax = Z.getUpperLimit();
 
  322   if (master == NULL) {
 
  324     if        (X != JRange_t() && 
 
  327       master = 
new TH2D(
"__H__", NULL, 
 
  328                         100, X.getLowerLimit(), X.getUpperLimit(),
 
  329                         100, Y.getLowerLimit(), Y.getUpperLimit());
 
  331       master->SetStats(kFALSE);
 
  333     } 
else if (xmin < xmax && ymin < ymax) {
 
  335       master = 
new TH2D(
"__H__", NULL, 
 
  339       master->SetStats(kFALSE);
 
  343       TText* p = 
new TText(0.5, 0.5, 
MAKE_CSTRING(
"No data"));
 
  351   if (master != NULL) {
 
  353     if (logx) { gPad->SetLogx(); }
 
  354     if (logy) { gPad->SetLogy(); }
 
  355     if (logz) { gPad->SetLogz(); }
 
  357     master->GetXaxis()->SetRangeUser(xmin, xmax);
 
  358     master->GetYaxis()->SetRangeUser(ymin, ymax);
 
  363     master->SetTitle(title.c_str());
 
  365     master->SetMinimum(zmin);
 
  366     master->SetMaximum(zmax);
 
  368     if (xLabel != 
"") { master->GetXaxis()->SetTitle(xLabel.c_str()); master->GetXaxis()->CenterTitle(
true); }
 
  369     if (yLabel != 
"") { master->GetYaxis()->SetTitle(yLabel.c_str()); master->GetYaxis()->CenterTitle(
true); }
 
  370     if (zLabel != 
"") { master->GetZaxis()->SetTitle(zLabel.c_str()); master->GetZaxis()->CenterTitle(
true); }
 
  372     master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(xmax/xmin) < 2) ||
 
  373                                          (logx >  1 &&       xmax-xmin  < 2));
 
  374     master->GetYaxis()->SetMoreLogLabels((logy == 1 && log10(ymax/ymin) < 2) ||
 
  375                                          (logy >  1 &&       ymax-ymin  < 2));
 
  377     if (Ndivisions.first != 
"") {
 
  378       master->SetNdivisions(Ndivisions.second, Ndivisions.first.c_str());
 
  381     master->Draw(option.c_str());
 
  384   if (logx > 1 || logy > 1) {
 
  388       TH2* h2 = dynamic_cast<TH2*>(i->get());
 
  390       if (h2 != NULL && h2 != master) {
 
  398     gStyle->SetOptStat(stats);
 
  400     gStyle->SetOptFit(kFALSE);
 
  404     DEBUG(
"Draw " << (*i)->GetName() << 
' ' << (*i)->GetTitle() << endl);
 
  406     string buffer(option);
 
  412       TH2& h2 = dynamic_cast<TH2&>(*(*i));
 
  421       TGraph& 
g1 = dynamic_cast<TGraph&>(*(*i));
 
  429       TGraph2D& g2 = dynamic_cast<TGraph2D&>(*(*i));
 
  438       TF2& f2 = dynamic_cast<TF2&>(*(*i));
 
  440       f2.SetRange(xmin, ymin, zmin,
 
  445     (*i)->Draw(buffer.c_str());