Jpp  19.1.0
the software that should make you happy
Functions
JPlot1D.cc File Reference

General purpose plot program for 1D ROOT objects. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <cmath>
#include <memory>
#include "TROOT.h"
#include "TFile.h"
#include "TClass.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TKey.h"
#include "TStyle.h"
#include "TAttMarker.h"
#include "TAttLine.h"
#include "TH1.h"
#include "TH2.h"
#include "TH3.h"
#include "TF1.h"
#include "TF2.h"
#include "THStack.h"
#include "TGraph.h"
#include "TGraphErrors.h"
#include "TGraphAsymmErrors.h"
#include "TMultiGraph.h"
#include "TProfile.h"
#include "TEllipse.h"
#include "TMarker.h"
#include "TLine.h"
#include "TLegend.h"
#include "TString.h"
#include "TRegexp.h"
#include "TText.h"
#include "JTools/JRange.hh"
#include "JROOT/JStyle.hh"
#include "JROOT/JCanvas.hh"
#include "JROOT/JMarkerAttributes.hh"
#include "JROOT/JLineAttributes.hh"
#include "JROOT/JLegend.hh"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JRootObject.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "Jeep/JProperties.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

General purpose plot program for 1D ROOT objects.

The option -f corresponds to <file name>:<object name>.

Author
mdejong

Definition in file JPlot1D.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 207 of file JPlot1D.cc.

208 {
209  using namespace std;
210  using namespace JPP;
211 
212  typedef JRange<double> JRange_t;
213 
214  vector<JRootObjectID> inputFile;
215  string outputFile;
216  JCanvas canvas;
217  JStyle::JParameters parameters;
218  int stats;
219  JLegend legend;
220  JRange_t X;
221  JRange_t Y;
222  JRange_t Z;
223  JCounter logx;
224  bool logy;
225  bool logz;
226  char project;
227  string xLabel;
228  string yLabel;
229  JCounter drawLine;
230  int fillArea;
231  int lineWidth;
232  double markerSize;
233  string option;
234  set<char> grid;
235  bool batch;
236  string title;
237  map<string, int> Ndivisions;
238  size_t group;
239  int debug;
240  string xTimeFormat;
241 
242  try {
243 
244  JProperties properties = parameters.getProperties();
245 
246  JParser<> zap("General purpose plot program for 1D ROOT objects.");
247 
248  zap['f'] = make_field(inputFile, "<input file>:<object name>");
249  zap['o'] = make_field(outputFile, "graphics output") = "";
250  zap['w'] = make_field(canvas, "size of canvas <nx>x<ny> [pixels]") = JCanvas(500, 500);
251  zap['@'] = make_field(properties) = JPARSER::initialised();
252  zap['s'] = make_field(stats) = -1;
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");
260  zap['P'] = make_field(project, "projection") = '\0', 'x', 'X', 'y', 'Y';
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") = "";
268  zap['G'] = make_field(grid, "grid lines [X][Y]") = JPARSER::initialised();
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";
273  zap['N'] = make_field(Ndivisions, "axis divisioning (e.g. \"X 505\")") = JPARSER::initialised();
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") = "";
276  zap['d'] = make_field(debug) = 0;
277 
278  zap(argc, argv);
279  }
280  catch(const exception &error) {
281  FATAL(error.what() << endl);
282  }
283 
284 
285  gROOT->SetBatch(batch);
286 
287  TApplication* tp = new TApplication("user", NULL, NULL);
288  TCanvas* cv = new TCanvas("c1", "c1", canvas.x, canvas.y);
289 
290  unique_ptr<TStyle> gStyle(new JStyle("gplot", cv->GetWw(), cv->GetWh(), parameters));
291 
292  if (logy || logz) {
293  gStyle->SetTitleOffset(gStyle->GetTitleOffset() * 1.3, "Y");
294  }
295 
296  gROOT->SetStyle("gplot");
297  gROOT->ForceStyle();
298 
299  cv->SetFillStyle(4000);
300  cv->SetFillColor(kWhite);
301  cv->Divide(1,1);
302  cv->cd(1);
303 
304 
305  JMarkerAttributes::getInstance().setMarkerSize(markerSize);
306  JLineAttributes ::getInstance().setLineWidth (lineWidth);
307 
308 
309  Double_t xmin = numeric_limits<double>::max();
310  Double_t xmax = numeric_limits<double>::lowest();
311 
312  Double_t ymin = numeric_limits<double>::max();
313  Double_t ymax = numeric_limits<double>::lowest();
314 
315 
316  vector<JRootObject> listOfObjects;
317 
318  const bool px = (project == 'x' || project == 'X'); // projection on x-axis of (2|3)D histogram
319  const bool py = (project == 'y' || project == 'Y'); // projection on y-axis of (2|3)D histogram
320  const bool pz = (project == 'z' || project == 'Z'); // projection on z-axis of 3D histogram
321 
322  logy = (logy || logz);
323 
324  if (px) {
325  swap(Y, Z); // Y becomes range in TH2::ProjectionX() and Z becomes y-axis range
326  }
327 
328  if (py) {
329  swap(X, Z); // X becomes range in TH2::ProjectionY()
330  swap(Y, X); // Y becomes x-axis range and Z becomes y-axis range
331  }
332 
333  TH1* master = NULL;
334 
335  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
336 
337  DEBUG("Input: " << *input << endl);
338 
339  TDirectory* dir = getDirectory(*input);
340 
341  if (dir == NULL) {
342  ERROR("File: " << input->getFullFilename() << " not opened." << endl);
343  continue;
344  }
345 
346  const TRegexp regexp(input->getObjectName());
347 
348  TIter iter(dir->GetListOfKeys());
349 
350  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
351 
352  const TString tag(key->GetName());
353 
354  DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl);
355 
356  // option match
357 
358  if (tag.Contains(regexp) && isTObject(key)) {
359 
360  if (title == JName_t) {
361  title = key->GetName();
362  } else if (title == JTitle_t) {
363  title = key->GetTitle();
364  }
365 
366  JRootObject object(key->ReadObj());
367 
368  TAttMarker marker = JMarkerAttributes::getInstance().get(0);
369  TAttLine line = JLineAttributes ::getInstance().get(0);
370 
371  if (group != 0) {
372  marker.SetMarkerColor(JMarkerAttributes::getInstance().get(listOfObjects.size()/group).GetMarkerColor());
373  }
374 
375  if (drawLine == 1)
376  line = JLineAttributes::getInstance().get(listOfObjects.size());
377  else
378  line.SetLineColor(marker.GetMarkerColor());
379 
380  // projections
381 
382  try {
383 
384  TProfile& h1 = dynamic_cast<TProfile&>(*object);
385 
386  object = h1.ProjectionX();
387  }
388  catch(exception&) {}
389 
390  try {
391 
392  TH2& h2 = dynamic_cast<TH2&>(*object);
393 
394  if (px) {
395 
396  if (Z.is_valid())
397  object = h2.ProjectionX(MAKE_CSTRING(h2.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()),
398  h2.GetYaxis()->FindBin(Z.getLowerLimit()),
399  h2.GetYaxis()->FindBin(Z.getUpperLimit()) - 1);
400  else
401  object = h2.ProjectionX(MAKE_CSTRING(h2.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()),
402  1,
403  h2.GetYaxis()->GetNbins());
404 
405  } else if (py) {
406 
407  if (Z.is_valid())
408  object = h2.ProjectionY(MAKE_CSTRING(h2.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()),
409  h2.GetXaxis()->FindBin(Z.getLowerLimit()),
410  h2.GetXaxis()->FindBin(Z.getUpperLimit()) - 1);
411  else
412  object = h2.ProjectionY(MAKE_CSTRING(h2.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()),
413  1,
414  h2.GetXaxis()->GetNbins());
415 
416  } else {
417 
418  ERROR("For 2D histograms, use option option -P for projections or use JPlot2D" << endl);
419 
420  continue;
421  }
422  }
423  catch(exception&) {}
424 
425  try {
426 
427  TH3& h3 = dynamic_cast<TH3&>(*object);
428 
429  if (px) {
430 
431  object = h3.ProjectionX(MAKE_CSTRING(h3.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()));
432 
433  } else if (py) {
434 
435  object = h3.ProjectionY(MAKE_CSTRING(h3.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()));
436 
437  } else if (pz) {
438 
439  object = h3.ProjectionZ(MAKE_CSTRING(h3.GetName() << "_pz" << LABEL_TERMINATOR << listOfObjects.size()));
440 
441  } else {
442 
443  ERROR("For 3D histograms, use option option -P for projections or use JPlot2D -P <projection>" << endl);
444 
445  continue;
446  }
447  }
448  catch(exception&) {}
449 
450  // colouring
451 
452  try {
453  if (dynamic_cast<TMarker*>(object.get()) == NULL) {
454  dynamic_cast<TAttMarker&>(*object) = marker;
455  }
456  }
457  catch(exception&) {}
458 
459  try {
460  if (dynamic_cast<TLine*>(object.get()) == NULL) {
461  dynamic_cast<TAttLine&> (*object) = line;
462  }
463  }
464  catch(exception&) {}
465 
466  if (fillArea != 0) {
467 
468  try {
469 
470  TAttFill& fill = dynamic_cast<TAttFill&>(*object);
471 
472  if (!isTAttLine(object) || fillArea < 0) {
473  fill.SetFillColor(marker.GetMarkerColor());
474  fill.SetFillStyle(abs(fillArea));
475  }
476  }
477  catch(exception&) {}
478  }
479 
480  // set errors
481 
482  if (drawLine) {
483 
484  try {
485 
486  TH1& h1 = dynamic_cast<TH1&>(*object);
487 
488  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
489  h1.SetBinError(i, 0.0);
490  }
491  }
492  catch(exception&) {}
493 
494  try {
495 
496  TGraphErrors& g1 = dynamic_cast<TGraphErrors&>(*object);
497 
498  for (Int_t i = 0; i != g1.GetN(); ++i) {
499  g1.GetEX()[i] = 0.0;
500  g1.GetEY()[i] = 0.0;
501  }
502  }
503  catch(exception&) {}
504  }
505 
506  // min-max
507 
508  try {
509 
510  TH1& h1 = dynamic_cast<TH1&>(*object);
511 
512  h1.SetStats(stats != -1);
513 
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());
518 
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()));
523  }
524  }
525  }
526  catch(exception&) {}
527 
528  try {
529 
530  TGraph& g1 = dynamic_cast<TGraph&>(*object);
531 
532  for (Int_t i = 0; i != g1.GetN(); ++i) {
533 
534  xmin = min(xmin, g1.GetX()[i]);
535  xmax = max(xmax, g1.GetX()[i]);
536 
537  if (!logy || g1.GetY()[i] > 0.0) {
538  ymin = min(ymin, g1.GetY()[i]);
539  ymax = max(ymax, g1.GetY()[i]);
540  }
541  }
542  }
543  catch(exception&) {}
544 
545  try {
546 
547  TGraphErrors& g1 = dynamic_cast<TGraphErrors&>(*object);
548 
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]); }
552  }
553  }
554  catch(exception&) {}
555 
556  try {
557 
558  TMultiGraph& m1 = dynamic_cast<TMultiGraph&>(*object);
559 
560  for (TIter i1(m1.GetListOfGraphs()); TGraph* g1 = dynamic_cast<TGraph*>(i1()); ) {
561 
562  for (Int_t i = 0; i != g1->GetN(); ++i) {
563 
564  xmin = min(xmin, g1->GetX()[i]);
565  xmax = max(xmax, g1->GetX()[i]);
566 
567  if (!logy || g1->GetY()[i] > 0.0) {
568  ymin = min(ymin, g1->GetY()[i]);
569  ymax = max(ymax, g1->GetY()[i]);
570  }
571  }
572  }
573  }
574  catch(exception&) {}
575 
576  try {
577 
578  TF2& f2 = dynamic_cast<TF2&>(*object);
579  TF1* f1 = NULL;
580 
581  TString formula = f2.GetExpFormula();
582  TString _z_ = TString::Format("%f", 0.5 * (Z.getLowerLimit() + Z.getUpperLimit()));
583 
584  double __xmin;
585  double __xmax;
586  double __ymin;
587  double __ymax;
588 
589  f2.GetRange(__xmin, __ymin, __xmax, __ymax);
590 
591  if (px) {
592 
593  formula.ReplaceAll("y", _z_);
594 
595  f1 = new TF1(MAKE_CSTRING(f2.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()), formula);
596 
597  f1->SetRange(__xmin, __xmax);
598 
599  } else if (py) {
600 
601  formula.ReplaceAll("x", _z_);
602  formula.ReplaceAll("y", "x");
603 
604  f1 = new TF1(MAKE_CSTRING(f2.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()), formula);
605 
606  f1->SetRange(__ymin, __ymax);
607 
608  } else {
609 
610  ERROR("For 2D functions, use option option -P for projections or use JPlot2D" << endl);
611 
612  continue;
613  }
614 
615  DEBUG("TF1: " << f1->GetExpFormula() << endl);
616 
617  f1->SetParameters(f2.GetParameters());
618 
619  object = f1;
620  }
621  catch(exception&) {}
622 
623  try {
624 
625  TF1& f1 = dynamic_cast<TF1&>(*object);
626 
627  double __xmin;
628  double __xmax;
629 
630  f1.GetRange(__xmin, __xmax);
631 
632  xmin = min(xmin, __xmin);
633  xmax = max(xmax, __xmax);
634  ymin = min(ymin, f1.GetMinimum());
635  ymax = max(ymax, f1.GetMaximum());
636  }
637  catch(exception&) {}
638 
639  try {
640 
641  THStack& hs = dynamic_cast<THStack&>(*object);
642 
643  NOTICE("THStack" << endl);
644 
645  unique_ptr<TIterator> iterator(hs.GetHists()->MakeIterator());
646 
647  for (size_t index = 1; TObject* i = iterator->Next(); ++index) {
648 
649  TH1& h1 = dynamic_cast<TH1&>(*i);
650 
651  NOTICE("TH1[" << index << "] " << h1.GetName() << endl);
652 
653  xmin = min(xmin, h1.GetXaxis()->GetXmin());
654  xmax = max(xmax, h1.GetXaxis()->GetXmax());
655 
656  ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
657  ymax = max(ymax, h1.GetMaximum());
658 
659  h1.SetLineWidth(1);
660  h1.SetLineColor(kBlack);
661 
662  h1.SetFillColor(JMarkerAttributes::getInstance().get(index).GetMarkerColor());
663  }
664  }
665  catch(exception&) {}
666 
667  try {
668 
669  TLine& h1 = dynamic_cast<TLine&>(*object);
670 
671  xmin = min(xmin, h1.GetX1());
672  xmax = max(xmax, h1.GetX2());
673  ymin = min(ymin, h1.GetY1());
674  ymax = max(ymax, h1.GetY2());
675  }
676  catch(exception&) {}
677 
678  // label
679 
680  for (TString buffer[] = { object.getLabel(), input->getFilename().c_str(), "" }, *i = buffer; *i != ""; ++i) {
681 
682  *i = (*i)(TRegexp("\\[.*\\]"));
683 
684  if (i->Length() > 2) {
685  object.setLabel((*i)(1, i->Length() - 2));
686  }
687  }
688 
689  DEBUG("Add object: " << tag << " with label <" << object.getLabel() << ">" << endl);
690 
691  if (master == NULL) {
692  master = dynamic_cast<TH1*>(object.get());
693  }
694 
695  listOfObjects.push_back(object);
696  }
697  }
698  }
699 
700  if (listOfObjects.empty()) {
701  ERROR("Nothing to draw." << endl);
702  }
703 
704  for (vector<JRootObject>::iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
705 
706  // set line attributes of associated functions
707  // for single objects, change colour if same range else change style
708  // for multiple objecs, keep colour and change style
709 
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());
714 
715  TList list;
716 
717  unique_ptr<TIterator> iterator;
718 
719  if (h1 != NULL) {
720 
721  iterator.reset(h1->GetListOfFunctions()->MakeIterator());
722 
723  } else if (g1 != NULL) {
724 
725  iterator.reset(g1->GetListOfFunctions()->MakeIterator());
726 
727  } else if (m1 != NULL) {
728 
729  for (TIter i1(m1->GetListOfGraphs()); TGraph* gi = dynamic_cast<TGraph*>(i1()); ) {
730  for (TIter i2(gi->GetListOfFunctions()); TF1* fi = dynamic_cast<TF1*>(i2()); ) {
731  list.Add(fi);
732  }
733  }
734 
735  iterator.reset(list.MakeIterator());
736  }
737 
738  if (iterator != NULL) {
739 
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() };
742 
743  for (int nf = 0, ns = 0, nc = 1; TF1* f1 = (TF1*) iterator->Next(); ++nf) {
744 
745  f1->GetRange(x1[1], x2[1]);
746  f1->SetNpx(5000);
747 
748  dynamic_cast<TAttLine&>(*f1) = JLineAttributes::getInstance().get(0);
749 
750  if (listOfObjects.size() == 1) {
751 
752  if (x1[0] == x1[1] &&
753  x2[0] == x2[1])
754  ++nc; // change colour
755  else if (nf != 0)
756  ++ns; // change style
757 
758  f1->SetLineStyle(JLineAttributes ::getInstance().get(ns).GetLineStyle());
759  f1->SetLineColor(JMarkerAttributes::getInstance().get(nc).GetMarkerColor());
760 
761  } else {
762 
763  // keep colour of base object and accordingly modify line style.
764 
765  f1->SetLineColor(ls->GetLineColor());
766  f1->SetLineStyle(JLineAttributes::getInstance().get(ns++).GetLineStyle());
767  }
768 
769  x1[0] = x1[1];
770  x2[0] = x2[1];
771 
772  // set limits
773  /*
774  double __xmin;
775  double __xmax;
776 
777  f1->GetRange(__xmin, __xmax);
778 
779  ymin = min(ymin, f1->GetMinimum(__xmin, __xmax));
780  ymax = max(ymax, f1->GetMaximum(__xmin, __xmax));
781  */
782  }
783  }
784  }
785 
786  // plot frame
787 
788  if (X.is_valid()) {
789  xmin = X.getLowerLimit();
790  xmax = X.getUpperLimit();
791  }
792 
793  if (Y.is_valid()) {
794  ymin = Y.getLowerLimit();
795  ymax = Y.getUpperLimit();
796  } else if (ymax > ymin) {
797  setRange(ymin, ymax, logy);
798  }
799 
800  cv->cd(1);
801 
802  if (!listOfObjects.empty()) {
803 
804  if (master == NULL) {
805 
806  master = new TH1D(MASTER.c_str(), NULL, 1000, xmin, xmax);
807 
808  master->SetStats(kFALSE);
809 
810  for (Int_t i = 1; i <= master->GetXaxis()->GetNbins(); ++i) {
811  master->SetBinContent(i, ymin);
812  }
813  }
814  }
815 
816  if (master == NULL) {
817 
818  TText* p = new TText(0.5, 0.5, MAKE_CSTRING("No data"));
819 
820  p->SetTextAlign(21);
821  p->SetTextAngle(45);
822  p->Draw();
823 
824  } else {
825 
826  if (logx) { gPad->SetLogx(); }
827  if (logy) { gPad->SetLogy(); }
828 
829  master->GetXaxis()->SetRangeUser(xmin, xmax);
830  master->SetTitle(title.c_str());
831 
832  if (logx > 1) {
833  setLogarithmicX(master);
834  }
835 
836  master->SetMinimum(ymin);
837  master->SetMaximum(ymax);
838 
839  if (xLabel != "") { master->GetXaxis()->SetTitle(xLabel.c_str()); master->GetXaxis()->CenterTitle(true); }
840  if (yLabel != "") { master->GetYaxis()->SetTitle(yLabel.c_str()); master->GetYaxis()->CenterTitle(true); }
841 
842  master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(xmax/xmin) < 2) ||
843  (logx > 1 && (xmax-xmin) < 2));
844 
845  master->GetYaxis()->SetMoreLogLabels( logy && log10(ymax/ymin) < 2);
846  master->GetYaxis()->SetNoExponent ( logy && log10(ymax/ymin) < 2);
847 
848  for (map<string, int>::const_iterator i = Ndivisions.begin(); i != Ndivisions.end(); ++i) {
849  master->SetNdivisions(i->second, i->first.c_str());
850  }
851 
852  if (xTimeFormat != "") {
853 
854  master->GetXaxis()->SetTimeDisplay(1);
855 
856  if (xTimeFormat == "utc") {
857  master->GetXaxis()->SetTimeFormat("#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
858  master->GetXaxis()->SetTimeOffset(0.0, "gmt");
859  } else if (xTimeFormat == "UTC") {
860  master->GetXaxis()->SetTimeFormat("%d-%m-%y");
861  master->GetXaxis()->SetTimeOffset(0.0, "gmt");
862  } else {
863  master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
864  }
865  }
866 
867  master->Draw(option.c_str());
868  }
869 
870  if (logx > 1) {
871  for (vector<JRootObject>::iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
872  if (dynamic_cast<TH1*>(i->get()) != master) {
873  if (setLogX<TH1> (i->get())) {}
874  else if (setLogX<TF1> (i->get())) {}
875  else if (setLogX<TGraphErrors>(i->get())) {}
876  else if (setLogX<TGraph> (i->get())) {}
877  else if (setLogX<TMultiGraph> (i->get())) {}
878  else if (setLogX<TLine> (i->get())) {}
879  else if (setLogX<TEllipse> (i->get())) {}
880  }
881  }
882  }
883 
884  if (grid.count('x') || grid.count('X')) { gPad->SetGridx(); }
885  if (grid.count('y') || grid.count('Y')) { gPad->SetGridy(); }
886 
887  if (stats != -1)
888  gStyle->SetOptStat(stats);
889  else
890  gStyle->SetOptFit(kFALSE);
891 
892 
893  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
894 
895  DEBUG("Draw " << (*i)->GetName() << ' ' << (*i)->GetTitle() << endl);
896 
897  string buffer(option);
898 
899  //if (!dynamic_cast<THStack*>(i->get())) {
900  // buffer += "SAMES";
901  //}
902 
903  buffer += "SAME";
904 
905  TF1* f1 = dynamic_cast<TF1*> (i->get());
906  TGraph* g1 = dynamic_cast<TGraph*> (i->get());
907  TMultiGraph* q1 = dynamic_cast<TMultiGraph*>(i->get());
908 
909  if (f1 != NULL) {
910  f1->SetNpx(5000);
911  }
912 
913  if (g1 != NULL) {
914  if (g1->GetN() > 1 && drawLine)
915  buffer += "L"; // drawing cut line
916  else if (fillArea == 0 ||
917  (dynamic_cast<TGraphErrors*> (g1) == NULL &&
918  dynamic_cast<TGraphAsymmErrors*>(g1) == NULL))
919  buffer += "P"; // drawing point(s)
920  }
921 
922  if (q1 != NULL) {
923 
924  for (TIter i1(q1->GetListOfGraphs()); TGraph* gi = dynamic_cast<TGraph*>(i1()); ) {
925 
926  string zbuf = buffer;
927 
928  if (gi->GetN() > 1 && drawLine)
929  zbuf += "L"; // drawing cut line
930  else
931  zbuf += "P"; // drawing point(s)
932 
933  gi->Draw(zbuf.c_str());
934  }
935 
936  } else {
937 
938  (*i).Draw(buffer.c_str());
939  }
940  }
941 
942  //gPad->RedrawAxis();
943 
944  if (legend.is_valid()) {
945 
946  if (group == 0) {
947  group = listOfObjects.size();
948  }
949 
950  Ssiz_t height = listOfObjects.size()/group;
951  Ssiz_t width = 1;
952 
953  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
954  width = max(width, getWidth(i->getLabel()));
955  }
956 
957  TLegend* lg = getLegend(width, height, legend.location, legend.factor);
958 
959  for (size_t i = 0; i < listOfObjects.size(); i += group) {
960 
961  const JRootObject& object = listOfObjects[i];
962 
963  if (dynamic_cast<TMarker*>(object.get()) == NULL &&
964  dynamic_cast<TLine*> (object.get()) == NULL &&
965  dynamic_cast<TText*> (object.get()) == NULL) {
966  lg->AddEntry(object, " " + object.getLabel(), isTAttLine(object) ? "L" : isTAttFill(object) && fillArea != 0 ? "F" : "P");
967  }
968  }
969 
970  lg->Draw();
971  }
972 
973  cv->Update();
974 
975  if (outputFile != "") {
976  cv->SaveAs(outputFile.c_str());
977  }
978 
979  if (!batch) {
980  tp->Run();
981  }
982 
983  return (master != NULL ? 0 : 1);
984 }
string outputFile
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define ERROR(A)
Definition: JMessage.hh:66
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:72
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
Utility class to parse parameter values.
Definition: JProperties.hh:501
Auxiliary data structure for TObject with a user defined label.
Definition: JRootObject.hh:31
Utility class to parse command line options.
Definition: JParser.hh:1698
Data structure for size of TCanvas.
Definition: JCanvas.hh:26
int y
number of pixels in Y
Definition: JCanvas.hh:99
int x
number of pixels in X
Definition: JCanvas.hh:98
Wrapper class around ROOT TStyle.
Definition: JStyle.hh:24
bool is_valid() const
Check validity of range.
Definition: JRange.hh:311
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
const JPolynome f1(1.0, 2.0, 3.0)
Function.
const double xmax
Definition: JQuadrature.cc:24
const double xmin
Definition: JQuadrature.cc:23
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition: JLocation.hh:247
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
Definition: JRootObject.hh:23
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
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.
Definition: JLegend.hh:29
std::vector< size_t > ns
Definition: JSTDTypes.hh:14
Type definition of range.
Definition: JHead.hh:43
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:68
JProperties getProperties()
Get properties of this class.
Definition: JStyle.hh:44
Auxiliary data structure to list files in directory.
Definition: JFilesystem.hh:20
Definition: JRoot.hh:19