Jpp  17.1.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 "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/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 173 of file JPlot1D.cc.

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