Jpp  19.0.0
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 "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 206 of file JPlot1D.cc.

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