Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "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 "JLang/JSinglePointer.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

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  bool 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");
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) {
467 
468  try {
469 
470  TAttFill& fill = dynamic_cast<TAttFill&>(*object);
471 
472  fill.SetFillColor(marker.GetMarkerColor());
473  }
474  catch(exception&) {}
475  }
476 
477  // set errors
478 
479  if (drawLine) {
480 
481  try {
482 
483  TH1& h1 = dynamic_cast<TH1&>(*object);
484 
485  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
486  h1.SetBinError(i, 0.0);
487  }
488  }
489  catch(exception&) {}
490 
491  try {
492 
493  TGraphErrors& g1 = dynamic_cast<TGraphErrors&>(*object);
494 
495  for (Int_t i = 0; i != g1.GetN(); ++i) {
496  g1.GetEX()[i] = 0.0;
497  g1.GetEY()[i] = 0.0;
498  }
499  }
500  catch(exception&) {}
501  }
502 
503  // min-max
504 
505  try {
506 
507  TH1& h1 = dynamic_cast<TH1&>(*object);
508 
509  h1.SetStats(stats != -1);
510 
511  xmin = min(xmin, h1.GetXaxis()->GetXmin());
512  xmax = max(xmax, h1.GetXaxis()->GetXmax());
513  ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
514  ymax = max(ymax, h1.GetMaximum());
515 
516  if (!logy && h1.GetListOfFunctions() != NULL) {
517  for (unique_ptr<TIterator> iterator(h1.GetListOfFunctions()->MakeIterator()); TF1* f1 = (TF1*) iterator->Next(); ) {
518  ymin = min(ymin, f1->GetMinimum(h1.GetXaxis()->GetXmin(), h1.GetXaxis()->GetXmax()));
519  ymax = max(ymax, f1->GetMaximum(h1.GetXaxis()->GetXmin(), h1.GetXaxis()->GetXmax()));
520  }
521  }
522  }
523  catch(exception&) {}
524 
525  try {
526 
527  TGraph& g1 = dynamic_cast<TGraph&>(*object);
528 
529  for (Int_t i = 0; i != g1.GetN(); ++i) {
530 
531  xmin = min(xmin, g1.GetX()[i]);
532  xmax = max(xmax, g1.GetX()[i]);
533 
534  if (!logy || g1.GetY()[i] > 0.0) {
535  ymin = min(ymin, g1.GetY()[i]);
536  ymax = max(ymax, g1.GetY()[i]);
537  }
538  }
539  }
540  catch(exception&) {}
541 
542  try {
543 
544  TGraphErrors& g1 = dynamic_cast<TGraphErrors&>(*object);
545 
546  for (Int_t i = 0; i != g1.GetN(); ++i) {
547  if (!logy || g1.GetY()[i] - g1.GetEY()[i] > 0.0) { ymin = min(ymin, g1.GetY()[i] - g1.GetEY()[i]); }
548  if (!logy || g1.GetY()[i] + g1.GetEY()[i] > 0.0) { ymax = max(ymax, g1.GetY()[i] + g1.GetEY()[i]); }
549  }
550  }
551  catch(exception&) {}
552 
553  try {
554 
555  TMultiGraph& m1 = dynamic_cast<TMultiGraph&>(*object);
556 
557  for (TIter i1(m1.GetListOfGraphs()); TGraph* g1 = dynamic_cast<TGraph*>(i1()); ) {
558 
559  for (Int_t i = 0; i != g1->GetN(); ++i) {
560 
561  xmin = min(xmin, g1->GetX()[i]);
562  xmax = max(xmax, g1->GetX()[i]);
563 
564  if (!logy || g1->GetY()[i] > 0.0) {
565  ymin = min(ymin, g1->GetY()[i]);
566  ymax = max(ymax, g1->GetY()[i]);
567  }
568  }
569  }
570  }
571  catch(exception&) {}
572 
573  try {
574 
575  TF2& f2 = dynamic_cast<TF2&>(*object);
576  TF1* f1 = NULL;
577 
578  TString formula = f2.GetExpFormula();
579  TString _z_ = TString::Format("%f", 0.5 * (Z.getLowerLimit() + Z.getUpperLimit()));
580 
581  double __xmin;
582  double __xmax;
583  double __ymin;
584  double __ymax;
585 
586  f2.GetRange(__xmin, __ymin, __xmax, __ymax);
587 
588  if (px) {
589 
590  formula.ReplaceAll("y", _z_);
591 
592  f1 = new TF1(MAKE_CSTRING(f2.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()), formula);
593 
594  f1->SetRange(__xmin, __xmax);
595 
596  } else if (py) {
597 
598  formula.ReplaceAll("x", _z_);
599  formula.ReplaceAll("y", "x");
600 
601  f1 = new TF1(MAKE_CSTRING(f2.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()), formula);
602 
603  f1->SetRange(__ymin, __ymax);
604 
605  } else {
606 
607  ERROR("For 2D functions, use option option -P for projections or use JPlot2D" << endl);
608 
609  continue;
610  }
611 
612  DEBUG("TF1: " << f1->GetExpFormula() << endl);
613 
614  f1->SetParameters(f2.GetParameters());
615 
616  object = f1;
617  }
618  catch(exception&) {}
619 
620  try {
621 
622  TF1& f1 = dynamic_cast<TF1&>(*object);
623 
624  double __xmin;
625  double __xmax;
626 
627  f1.GetRange(__xmin, __xmax);
628 
629  xmin = min(xmin, __xmin);
630  xmax = max(xmax, __xmax);
631  ymin = min(ymin, f1.GetMinimum());
632  ymax = max(ymax, f1.GetMaximum());
633  }
634  catch(exception&) {}
635 
636  try {
637 
638  THStack& hs = dynamic_cast<THStack&>(*object);
639 
640  NOTICE("THStack" << endl);
641 
642  unique_ptr<TIterator> iterator(hs.GetHists()->MakeIterator());
643 
644  for (size_t index = 1; TObject* i = iterator->Next(); ++index) {
645 
646  TH1& h1 = dynamic_cast<TH1&>(*i);
647 
648  NOTICE("TH1[" << index << "] " << h1.GetName() << endl);
649 
650  xmin = min(xmin, h1.GetXaxis()->GetXmin());
651  xmax = max(xmax, h1.GetXaxis()->GetXmax());
652 
653  ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
654  ymax = max(ymax, h1.GetMaximum());
655 
656  h1.SetLineWidth(1);
657  h1.SetLineColor(kBlack);
658 
659  h1.SetFillColor(JMarkerAttributes::getInstance().get(index).GetMarkerColor());
660  }
661  }
662  catch(exception&) {}
663 
664  try {
665 
666  TLine& h1 = dynamic_cast<TLine&>(*object);
667 
668  xmin = min(xmin, h1.GetX1());
669  xmax = max(xmax, h1.GetX2());
670  ymin = min(ymin, h1.GetY1());
671  ymax = max(ymax, h1.GetY2());
672  }
673  catch(exception&) {}
674 
675  // label
676 
677  for (TString buffer[] = { object.getLabel(), input->getFilename().c_str(), "" }, *i = buffer; *i != ""; ++i) {
678 
679  *i = (*i)(TRegexp("\\[.*\\]"));
680 
681  if (i->Length() > 2) {
682  object.setLabel((*i)(1, i->Length() - 2));
683  }
684  }
685 
686  DEBUG("Add object: " << tag << " with label <" << object.getLabel() << ">" << endl);
687 
688  if (master == NULL) {
689  master = dynamic_cast<TH1*>(object.get());
690  }
691 
692  listOfObjects.push_back(object);
693  }
694  }
695  }
696 
697  if (listOfObjects.empty()) {
698  ERROR("Nothing to draw." << endl);
699  }
700 
701  for (vector<JRootObject>::iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
702 
703  // set line attributes of associated functions
704  // for single objects, change colour if same range else change style
705  // for multiple objecs, keep colour and change style
706 
707  TH1* h1 = dynamic_cast<TH1*> (i->get());
708  TGraph* g1 = dynamic_cast<TGraph*> (i->get());
709  TMultiGraph* m1 = dynamic_cast<TMultiGraph*>(i->get());
710  TAttLine* ls = dynamic_cast<TAttLine*> (i->get());
711 
712  TList list;
713 
714  unique_ptr<TIterator> iterator;
715 
716  if (h1 != NULL) {
717 
718  iterator.reset(h1->GetListOfFunctions()->MakeIterator());
719 
720  } else if (g1 != NULL) {
721 
722  iterator.reset(g1->GetListOfFunctions()->MakeIterator());
723 
724  } else if (m1 != NULL) {
725 
726  for (TIter i1(m1->GetListOfGraphs()); TGraph* gi = dynamic_cast<TGraph*>(i1()); ) {
727  for (TIter i2(gi->GetListOfFunctions()); TF1* fi = dynamic_cast<TF1*>(i2()); ) {
728  list.Add(fi);
729  }
730  }
731 
732  iterator.reset(list.MakeIterator());
733  }
734 
735  if (iterator != NULL) {
736 
737  Double_t x1[] = { numeric_limits<Double_t>::max(), numeric_limits<Double_t>::max() };
738  Double_t x2[] = { numeric_limits<Double_t>::lowest(), numeric_limits<Double_t>::lowest() };
739 
740  for (int nf = 0, ns = 0, nc = 1; TF1* f1 = (TF1*) iterator->Next(); ++nf) {
741 
742  f1->GetRange(x1[1], x2[1]);
743  f1->SetNpx(5000);
744 
745  dynamic_cast<TAttLine&>(*f1) = JLineAttributes::getInstance().get(0);
746 
747  if (listOfObjects.size() == 1) {
748 
749  if (x1[0] == x1[1] &&
750  x2[0] == x2[1])
751  ++nc; // change colour
752  else if (nf != 0)
753  ++ns; // change style
754 
755  f1->SetLineStyle(JLineAttributes ::getInstance().get(ns).GetLineStyle());
756  f1->SetLineColor(JMarkerAttributes::getInstance().get(nc).GetMarkerColor());
757 
758  } else {
759 
760  // keep colour of base object and accordingly modify line style.
761 
762  f1->SetLineColor(ls->GetLineColor());
763  f1->SetLineStyle(JLineAttributes::getInstance().get(ns++).GetLineStyle());
764  }
765 
766  x1[0] = x1[1];
767  x2[0] = x2[1];
768 
769  // set limits
770  /*
771  double __xmin;
772  double __xmax;
773 
774  f1->GetRange(__xmin, __xmax);
775 
776  ymin = min(ymin, f1->GetMinimum(__xmin, __xmax));
777  ymax = max(ymax, f1->GetMaximum(__xmin, __xmax));
778  */
779  }
780  }
781  }
782 
783  // plot frame
784 
785  if (X.is_valid()) {
786  xmin = X.getLowerLimit();
787  xmax = X.getUpperLimit();
788  }
789 
790  if (Y.is_valid()) {
791  ymin = Y.getLowerLimit();
792  ymax = Y.getUpperLimit();
793  } else if (ymax > ymin) {
794  setRange(ymin, ymax, logy);
795  }
796 
797  cv->cd(1);
798 
799  if (!listOfObjects.empty()) {
800 
801  if (master == NULL) {
802 
803  master = new TH1D(MASTER.c_str(), NULL, 1000, xmin, xmax);
804 
805  master->SetStats(kFALSE);
806 
807  for (Int_t i = 1; i <= master->GetXaxis()->GetNbins(); ++i) {
808  master->SetBinContent(i, ymin);
809  }
810  }
811  }
812 
813  if (master == NULL) {
814 
815  TText* p = new TText(0.5, 0.5, MAKE_CSTRING("No data"));
816 
817  p->SetTextAlign(21);
818  p->SetTextAngle(45);
819  p->Draw();
820 
821  } else {
822 
823  if (logx) { gPad->SetLogx(); }
824  if (logy) { gPad->SetLogy(); }
825 
826  master->GetXaxis()->SetRangeUser(xmin, xmax);
827  master->SetTitle(title.c_str());
828 
829  if (logx > 1) {
831  }
832 
833  master->SetMinimum(ymin);
834  master->SetMaximum(ymax);
835 
836  if (xLabel != "") { master->GetXaxis()->SetTitle(xLabel.c_str()); master->GetXaxis()->CenterTitle(true); }
837  if (yLabel != "") { master->GetYaxis()->SetTitle(yLabel.c_str()); master->GetYaxis()->CenterTitle(true); }
838 
839  master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(xmax/xmin) < 2) ||
840  (logx > 1 && (xmax-xmin) < 2));
841 
842  master->GetYaxis()->SetMoreLogLabels( logy && log10(ymax/ymin) < 2);
843  master->GetYaxis()->SetNoExponent ( logy && log10(ymax/ymin) < 2);
844 
845  for (map<string, int>::const_iterator i = Ndivisions.begin(); i != Ndivisions.end(); ++i) {
846  master->SetNdivisions(i->second, i->first.c_str());
847  }
848 
849  if (xTimeFormat != "") {
850 
851  master->GetXaxis()->SetTimeDisplay(1);
852 
853  if (xTimeFormat == "utc") {
854  master->GetXaxis()->SetTimeFormat("#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
855  master->GetXaxis()->SetTimeOffset(0.0, "gmt");
856  } else if (xTimeFormat == "UTC") {
857  master->GetXaxis()->SetTimeFormat("%d-%m-%y");
858  master->GetXaxis()->SetTimeOffset(0.0, "gmt");
859  } else {
860  master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
861  }
862  }
863 
864  master->Draw(option.c_str());
865  }
866 
867  if (logx > 1) {
868  for (vector<JRootObject>::iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
869  if (dynamic_cast<TH1*>(i->get()) != master) {
870  if (setLogX<TH1> (i->get())) {}
871  else if (setLogX<TF1> (i->get())) {}
872  else if (setLogX<TGraphErrors>(i->get())) {}
873  else if (setLogX<TGraph> (i->get())) {}
874  else if (setLogX<TMultiGraph> (i->get())) {}
875  else if (setLogX<TLine> (i->get())) {}
876  else if (setLogX<TEllipse> (i->get())) {}
877  }
878  }
879  }
880 
881  if (grid.count('x') || grid.count('X')) { gPad->SetGridx(); }
882  if (grid.count('y') || grid.count('Y')) { gPad->SetGridy(); }
883 
884  if (stats != -1)
885  gStyle->SetOptStat(stats);
886  else
887  gStyle->SetOptFit(kFALSE);
888 
889 
890  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
891 
892  DEBUG("Draw " << (*i)->GetName() << ' ' << (*i)->GetTitle() << endl);
893 
894  string buffer(option);
895 
896  //if (!dynamic_cast<THStack*>(i->get())) {
897  // buffer += "SAMES";
898  //}
899 
900  buffer += "SAME";
901 
902  TF1* f1 = dynamic_cast<TF1*> (i->get());
903  TGraph* g1 = dynamic_cast<TGraph*> (i->get());
904  TMultiGraph* q1 = dynamic_cast<TMultiGraph*>(i->get());
905 
906  if (f1 != NULL) {
907  f1->SetNpx(5000);
908  }
909 
910  if (g1 != NULL) {
911  if (g1->GetN() > 1 && drawLine)
912  buffer += "L"; // drawing cut line
913  else
914  buffer += "P"; // drawing point(s)
915  }
916 
917  if (q1 != NULL) {
918 
919  for (TIter i1(q1->GetListOfGraphs()); TGraph* gi = dynamic_cast<TGraph*>(i1()); ) {
920 
921  string zbuf = buffer;
922 
923  if (gi->GetN() > 1 && drawLine)
924  zbuf += "L"; // drawing cut line
925  else
926  zbuf += "P"; // drawing point(s)
927 
928  gi->Draw(zbuf.c_str());
929  }
930 
931  } else {
932 
933  (*i).Draw(buffer.c_str());
934  }
935  }
936 
937  //gPad->RedrawAxis();
938 
939  if (legend.is_valid()) {
940 
941  if (group == 0) {
942  group = listOfObjects.size();
943  }
944 
945  Ssiz_t height = listOfObjects.size()/group;
946  Ssiz_t width = 1;
947 
948  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
949  width = max(width, getWidth(i->getLabel()));
950  }
951 
952  TLegend* lg = getLegend(width, height, legend.location, legend.factor);
953 
954  for (size_t i = 0; i < listOfObjects.size(); i += group) {
955 
956  const JRootObject& object = listOfObjects[i];
957 
958  if (dynamic_cast<TMarker*>(object.get()) == NULL &&
959  dynamic_cast<TLine*> (object.get()) == NULL &&
960  dynamic_cast<TText*> (object.get()) == NULL) {
961  lg->AddEntry(object, " " + object.getLabel(), isTAttLine(object) ? "L" : "LPF");
962  }
963  }
964 
965  lg->Draw();
966  }
967 
968  cv->Update();
969 
970  if (outputFile != "") {
971  cv->SaveAs(outputFile.c_str());
972  }
973 
974  if (!batch) {
975  tp->Run();
976  }
977 
978  return (master != NULL ? 0 : 1);
979 }
const double xmax
Definition: JQuadrature.cc:24
Utility class to parse command line options.
Definition: JParser.hh:1711
then echo Test string reversed by master(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho" -rC fi if (( 1 ))
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition: JLocation.hh:246
std::vector< size_t > ns
Utility class to parse parameter values.
Definition: JProperties.hh:497
Definition: JRoot.hh:19
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
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
string outputFile
const JPolynome f1(1.0, 2.0, 3.0)
Function.
bool isTAttLine(const TObject *object)
Get drawing option of TH1.
void setLogarithmicX(TList *list)
Make x-axis of objects in list logarithmic (e.g. after using log10()).
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
set_variable E_E log10(E_{fit}/E_{#mu})"
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
#define NOTICE(A)
Definition: JMessage.hh:64
#define ERROR(A)
Definition: JMessage.hh:66
static const char LABEL_TERMINATOR
label terminator
Definition: JRootObject.hh:23
#define FATAL(A)
Definition: JMessage.hh:67
const double xmin
Definition: JQuadrature.cc:23
void setRange(double &xmin, double &xmax, const bool logx)
Set axis range.
Auxiliary class to handle multiple boolean-like I/O.
Definition: JParser.hh:435
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
no fit printf nominal n $STRING awk v X
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25