56   typedef JRange<double>  JRange_t;
 
   87     JParser<> zap(
"General purpose plot program for 1D ROOT objects.");
 
   89     zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
   91     zap[
'w'] = 
make_field(canvas,     
"size of canvas <nx>x<ny> [pixels]")  = JCanvas(500, 500);
 
   93     zap[
'L'] = 
make_field(legend,     
"position legend e.g. TR")            = 
"";
 
   94     zap[
'x'] = 
make_field(X,          
"abscissa range")                     = JRange_t();
 
   95     zap[
'y'] = 
make_field(Y,          
"ordinate range")                     = JRange_t();
 
   96     zap[
'z'] = 
make_field(Z,          
"ordinate range of projection)")      = JRange_t();
 
   97     zap[
'X'] = 
make_field(logx,       
"logarithmic x-axis (-XX log10 axis)");
 
   98     zap[
'Y'] = 
make_field(logy,       
"logarithmic y-axis");
 
   99     zap[
'Z'] = 
make_field(logz,       
"logarithmic y-axis; after projection");
 
  100     zap[
'P'] = 
make_field(project,    
"projection")                         = 
'\0', 
'x', 
'X', 
'y', 
'Y';
 
  101     zap[
'>'] = 
make_field(xLabel,     
"x-axis label")                       = 
"";
 
  102     zap[
'^'] = 
make_field(yLabel,     
"y-axis label")                       = 
"";
 
  105     zap[
'l'] = 
make_field(lineWidth,  
"line width")                         = 2;
 
  106     zap[
'S'] = 
make_field(markerSize, 
"marker size")                        = 1.0;
 
  107     zap[
'O'] = 
make_field(option,     
"plotting option")                    = 
"";
 
  109     zap[
'B'] = 
make_field(batch,      
"batch processing");
 
  110     zap[
'T'] = 
make_field(title,      
"title")                              = 
"KM3NeT preliminary";
 
  112     zap[
'g'] = 
make_field(group,      
"group colour codes of objects")      = 1;
 
  113     zap[
't'] = 
make_field(xTimeFormat, 
"set time format for x-axis, e.g. \%d\\/\%m\\/\\%y%F1970-01-01 00:00:00") = 
"";
 
  118   catch(
const exception &error) {
 
  119     FATAL(error.what() << endl);
 
  123   gROOT->SetBatch(batch);
 
  125   TApplication* tp = 
new TApplication(
"user", NULL, NULL);
 
  126   TCanvas*      cv = 
new TCanvas(
"c1", 
"c1", canvas.x, canvas.y);
 
  128   JSinglePointer<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh()));
 
  130   gROOT->SetStyle(
"gplot");
 
  134   cv->SetFillStyle(4000);
 
  135   cv->SetFillColor(kWhite);
 
  144   Double_t xmin = +numeric_limits<double>::max();
 
  145   Double_t xmax = -numeric_limits<double>::max();
 
  147   Double_t ymin = +numeric_limits<double>::max();
 
  148   Double_t ymax = -numeric_limits<double>::max();
 
  153   const bool px = (project == 
'x' || project == 
'X');  
 
  154   const bool py = (project == 
'y' || project == 
'Y');  
 
  156   logy = (logy || logz);
 
  171     DEBUG(
"Input: " << *input << endl);
 
  176       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  180     const TRegexp regexp(input->getObjectName());
 
  182     TIter iter(dir->GetListOfKeys());
 
  184     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  186       const TString tag(key->GetName());
 
  188       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  192       if (tag.Contains(regexp)) {
 
  195           title = key->GetName();
 
  198         JRootObject object(key->ReadObj());
 
  211           line.SetLineColor(marker.GetMarkerColor());
 
  215           TProfile& h1 = dynamic_cast<TProfile&>(*
object);
 
  217           object = h1.ProjectionX();
 
  223           TH2& h2 = dynamic_cast<TH2&>(*
object);
 
  229                                       h2.GetYaxis()->FindBin(Z.getLowerLimit()),
 
  230                                       h2.GetYaxis()->FindBin(Z.getUpperLimit()) - 1);
 
  234                                       h2.GetYaxis()->GetNbins());
 
  240                                       h2.GetXaxis()->FindBin(Z.getLowerLimit()),
 
  241                                       h2.GetXaxis()->FindBin(Z.getUpperLimit()) - 1);
 
  245                                       h2.GetXaxis()->GetNbins());
 
  249             ERROR(
"For 2D histograms, use option option -P for projections or use JPlot2D" << endl);
 
  258           dynamic_cast<TAttMarker&>(*
object) = marker; 
 
  264           dynamic_cast<TAttLine&>  (*
object) = line; 
 
  270           TH1& h1 = dynamic_cast<TH1&>(*
object);
 
  272           h1.SetStats(stats != -1);
 
  274           xmin = min(xmin, h1.GetXaxis()->GetXmin());
 
  275           xmax = max(xmax, h1.GetXaxis()->GetXmax());
 
  277           ymin = min(ymin, h1.GetMinimum());
 
  278           ymax = max(ymax, h1.GetMaximum());
 
  281             for (
int i = 1; i <= h1.GetNbinsX(); ++i) {
 
  282               h1.SetBinError(i, 0.0);
 
  292             TAttFill& fill = dynamic_cast<TAttFill&>(*
object);
 
  294             fill.SetFillColor(marker.GetMarkerColor()); 
 
  301           TGraph& 
g1 = dynamic_cast<TGraph&>(*
object);
 
  303           for (Int_t i = 0; i != 
g1.GetN(); ++i) {
 
  305             xmin = min(xmin, 
g1.GetX()[i]);
 
  306             xmax = max(xmax, 
g1.GetX()[i]);
 
  308             if (!logy || 
g1.GetY()[i] > 0.0) {
 
  309               ymin = min(ymin, 
g1.GetY()[i]);
 
  310               ymax = max(ymax, 
g1.GetY()[i]);
 
  318           TF1& f1 = dynamic_cast<TF1&>(*
object);
 
  320           if (xmin != +numeric_limits<double>::max()  &&
 
  321               xmax != -numeric_limits<double>::max()) {
 
  322             ymin = min(ymin, f1.GetMinimum(xmin, xmax));
 
  323             ymax = max(ymax, f1.GetMaximum(xmin, xmax));
 
  331           THStack& hs = dynamic_cast<THStack&>(*
object);
 
  333           NOTICE(
"THStack" << endl);
 
  335           TIterator* 
iterator = hs.GetHists()->MakeIterator();
 
  339             TH1& h1 = dynamic_cast<TH1&>(*i);
 
  341             NOTICE(
"TH1[" << index << 
"] " << h1.GetName() << endl);
 
  343             xmin = min(xmin, h1.GetXaxis()->GetXmin());
 
  344             xmax = max(xmax, h1.GetXaxis()->GetXmax());
 
  346             ymin = min(ymin, h1.GetMinimum());
 
  347             ymax = max(ymax, h1.GetMaximum());
 
  350             h1.SetLineColor(kBlack);
 
  359         for (TString buffer[] = { 
object.getLabel(), input->getFilename().c_str(), 
"" }, *i = buffer; *i != 
""; ++i) {
 
  361           *i = (*i)(TRegexp(
"\\[.*\\]"));
 
  363           DEBUG(
"Label: <" << *i << 
">" << endl); 
 
  365           if (i->Length() > 2) {
 
  366             object.setLabel((*i)(1, i->Length() - 2));
 
  370         DEBUG(
"Add object: " << tag << 
" with label " << 
object.
getLabel() << endl);
 
  372         if (master == NULL) {
 
  373           master = dynamic_cast<TH1*>(
object.
get());
 
  376         listOfObjects.push_back(
object);
 
  381   if (listOfObjects.empty()) {
 
  382     ERROR(
"Nothing to draw." << endl);
 
  387     TH1*      h1 = dynamic_cast<TH1*>     (i->get());
 
  388     TGraph*   
g1 = dynamic_cast<TGraph*>  (i->get());
 
  389     TAttLine* ls = dynamic_cast<TAttLine*>(i->get());
 
  394       iterator = h1->GetListOfFunctions()->MakeIterator();
 
  396       iterator = 
g1->GetListOfFunctions()->MakeIterator();
 
  400     Double_t x1 = +numeric_limits<Double_t>::max();
 
  401     Double_t x2 = -numeric_limits<Double_t>::max();
 
  403     for (
int ns = 0, nc = 1; TF1* f1 = (TF1*) 
iterator->Next(); ) {
 
  408       f1->GetRange(__x1, __x2);
 
  413       if (listOfObjects.size() == 1) {
 
  429         f1->SetLineColor(ls->GetLineColor());
 
  433       ymin = min(ymin, f1->GetMinimum(xmin, xmax));
 
  434       ymax = max(ymax, f1->GetMaximum(xmin, xmax));
 
  444   if (X != JRange_t()) { 
 
  445     xmin = X.getLowerLimit();
 
  446     xmax = X.getUpperLimit();
 
  449   if (Y != JRange_t()) {
 
  450     ymin = Y.getLowerLimit();
 
  451     ymax = Y.getUpperLimit();
 
  458   if (master == NULL) {
 
  460     if        (X != JRange_t()) {
 
  462       master = 
new TH1D(
"__H__", NULL, 100, X.getLowerLimit(), X.getUpperLimit());
 
  464       master->SetStats(kFALSE);
 
  466     } 
else if (xmin < xmax) {
 
  468       master = 
new TH1D(
"__H__", NULL, 100, xmin, xmax);
 
  470       master->SetStats(kFALSE);
 
  474       TText* p = 
new TText(0.5, 0.5, 
MAKE_CSTRING(
"No data"));
 
  482   if (master != NULL) {
 
  484     if (logx) { gPad->SetLogx(); }
 
  485     if (logy) { gPad->SetLogy(); }
 
  487     master->GetXaxis()->SetRangeUser(xmin, xmax);
 
  493     master->SetTitle(title.c_str());
 
  495     master->SetMinimum(ymin);
 
  496     master->SetMaximum(ymax);
 
  498     if (xLabel != 
"") { master->GetXaxis()->SetTitle(xLabel.c_str()); master->GetXaxis()->CenterTitle(
true); }
 
  499     if (yLabel != 
"") { master->GetYaxis()->SetTitle(yLabel.c_str()); master->GetYaxis()->CenterTitle(
true); }
 
  501     master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(xmax/xmin) < 2) ||
 
  502                                          (logx >  1 &&       xmax-xmin  < 2));
 
  504     master->GetYaxis()->SetMoreLogLabels( logy      && log10(ymax/ymin) < 2);
 
  505     master->GetYaxis()->SetNoExponent   ( logy      && log10(ymax/ymin) < 2);
 
  507     if (Ndivisions.first != 
"") {
 
  508       master->SetNdivisions(Ndivisions.second, Ndivisions.first.c_str());
 
  511     if (xTimeFormat != 
"") {
 
  512       master->GetXaxis()->SetTimeDisplay(1);
 
  513       master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
 
  516     master->Draw(option.c_str());
 
  523       TH1* h1 = dynamic_cast<TH1*>(i->get());
 
  527         if (logx > 0 && h1 != master) {
 
  531         TIter iter(h1->GetListOfFunctions());
 
  533         const TRegexp key(
"x[^a-zA-Z]");     
 
  534         const TString rep(
"log10(x)");       
 
  536         for (TF1* f1; (f1 = (TF1*) iter.Next()) != NULL; ) {
 
  538           TString formula(f1->GetExpFormula());
 
  540           for (Ssiz_t pos = 0; (pos = formula.Index(key, pos)) != -1; pos += rep.Length()) {
 
  541             formula.Replace(pos, 1, rep);
 
  544           TF1 f2(f1->GetName(), formula);
 
  546           f2.SetParameters(f1->GetParameters());
 
  547           f2.SetRange(f1->GetXmin(), f1->GetXmax());
 
  549           static_cast<TAttLine&>(f2) = *f1;
 
  553           if (f1->GetXmin() != 0.0 && f1->GetXmax() != 1.0)
 
  554             f1->SetRange(pow(10.0,f1->GetXmin()), pow(10.0,f1->GetXmax()));
 
  556             f1->SetRange(pow(10.0,xmin), pow(10.0,xmax));           
 
  562   if (grid.count(
'x') || grid.count(
'X')) { gPad->SetGridx(); }
 
  563   if (grid.count(
'y') || grid.count(
'Y')) { gPad->SetGridy(); }
 
  566     gStyle->SetOptStat(stats);
 
  568     gStyle->SetOptFit(kFALSE);
 
  572     DEBUG(
"Draw " << (*i)->GetName() << 
' ' << (*i)->GetTitle() << endl);
 
  574     string buffer(option);
 
  582     TGraph* p = dynamic_cast<TGraph*>(i->get());
 
  585       if (p->GetN() > 1 && drawLine)
 
  598     Ssiz_t height = listOfObjects.size();
 
  602       width = max(width, i->getLabel().Length());
 
  605     TLegend* lg = 
new JLegend(width, height, legend);
 
  608       lg->AddEntry(*i, 
" " + i->getLabel(), 
isTAttLine(*i) ? 
"L" : 
"LPF");