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

61 {
62  using namespace std;
63  using namespace JPP;
64 
65  typedef JRange<double> JRange_t;
66 
67  vector<JRootObjectID> inputFile;
68  string outputFile;
69  JCanvas canvas;
70  int stats;
71  string legend;
72  JRange_t X;
73  JRange_t Y;
74  JRange_t Z;
75  JCounter logx;
76  bool logy;
77  bool logz;
78  char project;
79  string xLabel;
80  string yLabel;
81  JCounter drawLine;
82  bool fillArea;
83  int lineWidth;
84  double markerSize;
85  string option;
86  set<char> grid;
87  bool batch;
88  string title;
89  pair<string, int> Ndivisions;
90  int group;
91  int debug;
92  string xTimeFormat;
93 
94  try {
95 
96  JParser<> zap("General purpose plot program for 1D ROOT objects.");
97 
98  zap['f'] = make_field(inputFile, "<input file>:<object name>");
99  zap['o'] = make_field(outputFile, "graphics output") = "";
100  zap['w'] = make_field(canvas, "size of canvas <nx>x<ny> [pixels]") = JCanvas(500, 500);
101  zap['s'] = make_field(stats) = -1;
102  zap['L'] = make_field(legend, "position legend e.g. TR") = "", "TL", "TR", "BR", "BL";
103  zap['x'] = make_field(X, "abscissa range") = JRange_t();
104  zap['y'] = make_field(Y, "ordinate range") = JRange_t();
105  zap['z'] = make_field(Z, "ordinate range of projection)") = JRange_t();
106  zap['X'] = make_field(logx, "logarithmic x-axis (-XX log10 axis)");
107  zap['Y'] = make_field(logy, "logarithmic y-axis");
108  zap['Z'] = make_field(logz, "logarithmic y-axis; after projection");
109  zap['P'] = make_field(project, "projection") = '\0', 'x', 'X', 'y', 'Y';
110  zap['>'] = make_field(xLabel, "x-axis label") = "";
111  zap['^'] = make_field(yLabel, "y-axis label") = "";
112  zap['C'] = make_field(drawLine);
113  zap['F'] = make_field(fillArea);
114  zap['l'] = make_field(lineWidth, "line width") = 2;
115  zap['S'] = make_field(markerSize, "marker size") = 1.0;
116  zap['O'] = make_field(option, "plotting option") = "";
117  zap['G'] = make_field(grid, "grid lines [X][Y]") = JPARSER::initialised();
118  zap['B'] = make_field(batch, "batch processing");
119  zap['T'] = make_field(title, "title") = "KM3NeT preliminary";
120  zap['N'] = make_field(Ndivisions, "axis divisioning (e.g. \"X 505\")") = JPARSER::initialised();
121  zap['g'] = make_field(group, "group colour codes of objects") = 1;
122  zap['t'] = make_field(xTimeFormat, "set time format for x-axis, e.g. \%d\\/\%m\\/\\%y%F1970-01-01 00:00:00") = "";
123  zap['d'] = make_field(debug) = 0;
124 
125  zap(argc, argv);
126  }
127  catch(const exception &error) {
128  FATAL(error.what() << endl);
129  }
130 
131 
132  gROOT->SetBatch(batch);
133 
134  TApplication* tp = new TApplication("user", NULL, NULL);
135  TCanvas* cv = new TCanvas("c1", "c1", canvas.x, canvas.y);
136 
137  JSinglePointer<TStyle> gStyle(new JStyle("gplot", cv->GetWw(), cv->GetWh()));
138 
139  gROOT->SetStyle("gplot");
140  gROOT->ForceStyle();
141 
142 
143  cv->SetFillStyle(4000);
144  cv->SetFillColor(kWhite);
145  cv->Divide(1,1);
146  cv->cd(1);
147 
148 
149  JMarkerAttributes::getInstance().setMarkerSize(markerSize);
150  JLineAttributes ::getInstance().setLineWidth (lineWidth);
151 
152 
153  Double_t xmin = numeric_limits<double>::max();
154  Double_t xmax = numeric_limits<double>::lowest();
155 
156  Double_t ymin = numeric_limits<double>::max();
157  Double_t ymax = numeric_limits<double>::lowest();
158 
159 
160  vector<JRootObject> listOfObjects;
161 
162  const bool px = (project == 'x' || project == 'X'); // projection on x-axis of (2|3)D histogram
163  const bool py = (project == 'y' || project == 'Y'); // projection on y-axis of (2|3)D histogram
164  const bool pz = (project == 'z' || project == 'Z'); // projection on z-axis of 3D histogram
165 
166  logy = (logy || logz);
167 
168  if (px) {
169  swap(Y, Z); // Y becomes range in TH2::ProjectionX() and Z becomes y-axis range
170  }
171 
172  if (py) {
173  swap(X, Z); // X becomes range in TH2::ProjectionY()
174  swap(Y, X); // Y becomes x-axis range and Z becomes y-axis range
175  }
176 
177  TH1* master = NULL;
178 
179  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
180 
181  DEBUG("Input: " << *input << endl);
182 
183  TDirectory* dir = getDirectory(*input);
184 
185  if (dir == NULL) {
186  ERROR("File: " << input->getFullFilename() << " not opened." << endl);
187  continue;
188  }
189 
190  const TRegexp regexp(input->getObjectName());
191 
192  TIter iter(dir->GetListOfKeys());
193 
194  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
195 
196  const TString tag(key->GetName());
197 
198  DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl);
199 
200  // option match
201 
202  if (tag.Contains(regexp)) {
203 
204  if (title == JName_t) {
205  title = key->GetName();
206  } else if (title == JTitle_t) {
207  title = key->GetTitle();
208  }
209 
210  JRootObject object(key->ReadObj());
211 
212  TAttMarker marker = JMarkerAttributes::getInstance().get(0);
213  TAttLine line = JLineAttributes ::getInstance().get(0);
214 
215  if (group > 1)
216  marker.SetMarkerColor(JMarkerAttributes::getInstance().get(listOfObjects.size()/group).GetMarkerColor());
217  else
218  marker = JMarkerAttributes::getInstance().get(listOfObjects.size());
219 
220  if (drawLine == 1)
221  line = JLineAttributes::getInstance().get(listOfObjects.size());
222  else
223  line.SetLineColor(marker.GetMarkerColor());
224 
225  try {
226 
227  TProfile& h1 = dynamic_cast<TProfile&>(*object);
228 
229  object = h1.ProjectionX();
230  }
231  catch(exception&) {}
232 
233  try {
234 
235  TH2& h2 = dynamic_cast<TH2&>(*object);
236 
237  if (px) {
238 
239  if (Z != JRange_t())
240  object = h2.ProjectionX(MAKE_CSTRING(h2.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()),
241  h2.GetYaxis()->FindBin(Z.getLowerLimit()),
242  h2.GetYaxis()->FindBin(Z.getUpperLimit()) - 1);
243  else
244  object = h2.ProjectionX(MAKE_CSTRING(h2.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()),
245  1,
246  h2.GetYaxis()->GetNbins());
247 
248  } else if (py) {
249 
250  if (Z != JRange_t())
251  object = h2.ProjectionY(MAKE_CSTRING(h2.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()),
252  h2.GetXaxis()->FindBin(Z.getLowerLimit()),
253  h2.GetXaxis()->FindBin(Z.getUpperLimit()) - 1);
254  else
255  object = h2.ProjectionY(MAKE_CSTRING(h2.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()),
256  1,
257  h2.GetXaxis()->GetNbins());
258 
259  } else {
260 
261  ERROR("For 2D histograms, use option option -P for projections or use JPlot2D" << endl);
262 
263  continue;
264  }
265  }
266  catch(exception&) {}
267 
268  try {
269 
270  TH3& h3 = dynamic_cast<TH3&>(*object);
271 
272  if (px) {
273 
274  object = h3.ProjectionX(MAKE_CSTRING(h3.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()));
275 
276  } else if (py) {
277 
278  object = h3.ProjectionY(MAKE_CSTRING(h3.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()));
279 
280  } else if (pz) {
281 
282  object = h3.ProjectionZ(MAKE_CSTRING(h3.GetName() << "_pz" << LABEL_TERMINATOR << listOfObjects.size()));
283 
284  } else {
285 
286  ERROR("For 3D histograms, use option option -P for projections or use JPlot2D -P <projection>" << endl);
287 
288  continue;
289  }
290  }
291  catch(exception&) {}
292 
293  try {
294 
295  dynamic_cast<TAttMarker&>(*object) = marker;
296  }
297  catch(exception&) {}
298 
299  try {
300 
301  dynamic_cast<TAttLine&> (*object) = line;
302  }
303  catch(exception&) {}
304 
305  try {
306 
307  TH1& h1 = dynamic_cast<TH1&>(*object);
308 
309  h1.SetStats(stats != -1);
310 
311  xmin = min(xmin, h1.GetXaxis()->GetXmin());
312  xmax = max(xmax, h1.GetXaxis()->GetXmax());
313  ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
314  ymax = max(ymax, h1.GetMaximum());
315 
316  if (drawLine) {
317  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
318  h1.SetBinError(i, 0.0);
319  }
320  }
321  }
322  catch(exception&) {}
323 
324  if (fillArea) {
325 
326  try {
327 
328  TAttFill& fill = dynamic_cast<TAttFill&>(*object);
329 
330  fill.SetFillColor(marker.GetMarkerColor());
331  }
332  catch(exception&) {}
333  }
334 
335  try {
336 
337  TGraph& g1 = dynamic_cast<TGraph&>(*object);
338 
339  for (Int_t i = 0; i != g1.GetN(); ++i) {
340 
341  xmin = min(xmin, g1.GetX()[i]);
342  xmax = max(xmax, g1.GetX()[i]);
343 
344  if (!logy || g1.GetY()[i] > 0.0) {
345  ymin = min(ymin, g1.GetY()[i]);
346  ymax = max(ymax, g1.GetY()[i]);
347  }
348  }
349  }
350  catch(exception&) {}
351 
352  try {
353 
354  TGraphErrors& g1 = dynamic_cast<TGraphErrors&>(*object);
355 
356  if (drawLine) {
357  for (Int_t i = 0; i != g1.GetN(); ++i) {
358  g1.GetEX()[i] = 0.0;
359  g1.GetEY()[i] = 0.0;
360  }
361  } else {
362  for (Int_t i = 0; i != g1.GetN(); ++i) {
363  if (!logy || g1.GetY()[i] - g1.GetEY()[i] > 0.0) { ymin = min(ymin, g1.GetY()[i] - g1.GetEY()[i]); }
364  if (!logy || g1.GetY()[i] + g1.GetEY()[i] > 0.0) { ymax = max(ymax, g1.GetY()[i] + g1.GetEY()[i]); }
365  }
366  }
367  }
368  catch(exception&) {}
369 
370  try {
371 
372  TMultiGraph& m1 = dynamic_cast<TMultiGraph&>(*object);
373 
374  for (TIter i1(m1.GetListOfGraphs()); TGraph* g1 = dynamic_cast<TGraph*>(i1()); ) {
375 
376  for (Int_t i = 0; i != g1->GetN(); ++i) {
377 
378  xmin = min(xmin, g1->GetX()[i]);
379  xmax = max(xmax, g1->GetX()[i]);
380 
381  if (!logy || g1->GetY()[i] > 0.0) {
382  ymin = min(ymin, g1->GetY()[i]);
383  ymax = max(ymax, g1->GetY()[i]);
384  }
385  }
386  }
387  }
388  catch(exception&) {}
389 
390  try {
391 
392  TF2& f2 = dynamic_cast<TF2&>(*object);
393  TF1* f1 = NULL;
394 
395  TString formula = f2.GetExpFormula();
396  TString _z_ = TString::Format("%f", 0.5 * (Z.getLowerLimit() + Z.getUpperLimit()));
397 
398  double __xmin;
399  double __xmax;
400  double __ymin;
401  double __ymax;
402 
403  f2.GetRange(__xmin, __ymin, __xmax, __ymax);
404 
405  if (px) {
406 
407  formula.ReplaceAll("y", _z_);
408 
409  f1 = new TF1(MAKE_CSTRING(f2.GetName() << "_px" << LABEL_TERMINATOR << listOfObjects.size()), formula);
410 
411  f1->SetRange(__xmin, __xmax);
412 
413  } else if (py) {
414 
415  formula.ReplaceAll("x", _z_);
416  formula.ReplaceAll("y", "x");
417 
418  f1 = new TF1(MAKE_CSTRING(f2.GetName() << "_py" << LABEL_TERMINATOR << listOfObjects.size()), formula);
419 
420  f1->SetRange(__ymin, __ymax);
421 
422  } else {
423 
424  ERROR("For 2D functions, use option option -P for projections or use JPlot2D" << endl);
425 
426  continue;
427  }
428 
429  DEBUG("TF1: " << f1->GetExpFormula() << endl);
430 
431  f1->SetParameters(f2.GetParameters());
432 
433  object = f1;
434  }
435  catch(exception&) {}
436 
437  try {
438 
439  TF1& f1 = dynamic_cast<TF1&>(*object);
440 
441  double __xmin;
442  double __xmax;
443 
444  f1.GetRange(__xmin, __xmax);
445 
446  xmin = min(xmin, __xmin);
447  xmax = max(xmax, __xmax);
448  ymin = min(ymin, f1.GetMinimum());
449  ymax = max(ymax, f1.GetMaximum());
450  }
451  catch(exception&) {}
452 
453  try {
454 
455  THStack& hs = dynamic_cast<THStack&>(*object);
456 
457  NOTICE("THStack" << endl);
458 
459  TIterator* iterator = hs.GetHists()->MakeIterator();
460 
461  for (size_t index = 1; TObject* i = iterator->Next(); ++index) {
462 
463  TH1& h1 = dynamic_cast<TH1&>(*i);
464 
465  NOTICE("TH1[" << index << "] " << h1.GetName() << endl);
466 
467  xmin = min(xmin, h1.GetXaxis()->GetXmin());
468  xmax = max(xmax, h1.GetXaxis()->GetXmax());
469 
470  ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
471  ymax = max(ymax, h1.GetMaximum());
472 
473  h1.SetLineWidth(1);
474  h1.SetLineColor(kBlack);
475 
476  h1.SetFillColor(JMarkerAttributes::getInstance().get(index).GetMarkerColor());
477  }
478  }
479  catch(exception&) {}
480 
481  for (TString buffer[] = { object.getLabel(), input->getFilename().c_str(), "" }, *i = buffer; *i != ""; ++i) {
482 
483  *i = (*i)(TRegexp("\\[.*\\]"));
484 
485  DEBUG("Label: <" << *i << ">" << endl);
486 
487  if (i->Length() > 2) {
488  object.setLabel((*i)(1, i->Length() - 2));
489  }
490  }
491 
492  DEBUG("Add object: " << tag << " with label " << object.getLabel() << endl);
493 
494  if (master == NULL) {
495  master = dynamic_cast<TH1*>(object.get());
496  }
497 
498  listOfObjects.push_back(object);
499  }
500  }
501  }
502 
503  if (listOfObjects.empty()) {
504  ERROR("Nothing to draw." << endl);
505  }
506 
507  for (vector<JRootObject>::iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
508 
509  TH1* h1 = dynamic_cast<TH1*> (i->get());
510  TGraph* g1 = dynamic_cast<TGraph*> (i->get());
511  TMultiGraph* m1 = dynamic_cast<TMultiGraph*>(i->get());
512  TAttLine* ls = dynamic_cast<TAttLine*> (i->get());
513 
514  TList list;
515  TIterator* iterator = NULL;
516 
517  if (h1 != NULL) {
518 
519  iterator = h1->GetListOfFunctions()->MakeIterator();
520 
521  } else if (g1 != NULL) {
522 
523  iterator = g1->GetListOfFunctions()->MakeIterator();
524 
525  } else if (m1 != NULL) {
526 
527  for (TIter i1(m1->GetListOfGraphs()); TGraph* gi = dynamic_cast<TGraph*>(i1()); ) {
528  for (TIter i2(gi->GetListOfFunctions()); TF1* fi = dynamic_cast<TF1*>(i2()); ) {
529  list.Add(fi);
530  }
531  }
532 
533  iterator = list.MakeIterator();
534  }
535 
536  if (iterator != NULL) {
537 
538  Double_t x1 = numeric_limits<Double_t>::max();
539  Double_t x2 = numeric_limits<Double_t>::lowest();
540 
541  for (int ns = 0, nc = 1; TF1* f1 = (TF1*) iterator->Next(); ) {
542 
543  Double_t __x1;
544  Double_t __x2;
545 
546  f1->GetRange(__x1, __x2);
547  f1->SetNpx(1000);
548 
549  dynamic_cast<TAttLine&>(*f1) = JLineAttributes::getInstance().get(0);
550 
551  if (listOfObjects.size() == 1) {
552 
553  f1->SetLineStyle(JLineAttributes::getInstance().get(ns).GetLineStyle());
554 
555  if (x1 != numeric_limits<Double_t>::max() &&
556  x2 != numeric_limits<Double_t>::lowest()) {
557 
558  if (x1 == __x1 &&
559  x2 == __x2)
560  ++nc; // follow colour style
561  else
562  ++ns; // follow line style
563  }
564 
565  f1->SetLineColor(JMarkerAttributes::getInstance().get(nc).GetMarkerColor());
566 
567  } else {
568 
569  // keep colour of base object and accordingly modify line style.
570 
571  f1->SetLineColor(ls->GetLineColor());
572  f1->SetLineStyle(JLineAttributes::getInstance().get(ns++).GetLineStyle());
573  }
574 
575  double __xmin;
576  double __xmax;
577 
578  f1->GetRange(__xmin, __xmax);
579 
580  ymin = min(ymin, f1->GetMinimum(__xmin, __xmax));
581  ymax = max(ymax, f1->GetMaximum(__xmin, __xmax));
582 
583  x1 = __x1;
584  x2 = __x2;
585  }
586  }
587  }
588 
589  // plot frame
590 
591  if (X != JRange_t()) {
592  xmin = X.getLowerLimit();
593  xmax = X.getUpperLimit();
594  }
595 
596  if (Y != JRange_t()) {
597  ymin = Y.getLowerLimit();
598  ymax = Y.getUpperLimit();
599  } else {
600  setRange(ymin, ymax, logy);
601  }
602 
603  cv->cd(1);
604 
605  if (!listOfObjects.empty()) {
606 
607  if (master == NULL || master->GetXaxis()->GetXmin() > xmin || master->GetXaxis()->GetXmax() < xmax) {
608 
609  if (X != JRange_t()) {
610 
611  master = new TH1D("__H__", NULL, 100, X.getLowerLimit(), X.getUpperLimit());
612 
613  master->SetStats(kFALSE);
614 
615  } else if (xmin < xmax) {
616 
617  master = new TH1D("__H__", NULL, 100, xmin, xmax);
618 
619  master->SetStats(kFALSE);
620  }
621  }
622  }
623 
624  if (master == NULL) {
625 
626  TText* p = new TText(0.5, 0.5, MAKE_CSTRING("No data"));
627 
628  p->SetTextAlign(21);
629  p->SetTextAngle(45);
630  p->Draw();
631 
632  } else {
633 
634  if (logx) { gPad->SetLogx(); }
635  if (logy) { gPad->SetLogy(); }
636 
637  master->GetXaxis()->SetRangeUser(xmin, xmax);
638 
639  if (logx > 1) {
641  }
642 
643  master->SetTitle(title.c_str());
644 
645  master->SetMinimum(ymin);
646  master->SetMaximum(ymax);
647 
648  if (xLabel != "") { master->GetXaxis()->SetTitle(xLabel.c_str()); master->GetXaxis()->CenterTitle(true); }
649  if (yLabel != "") { master->GetYaxis()->SetTitle(yLabel.c_str()); master->GetYaxis()->CenterTitle(true); }
650 
651  master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(xmax/xmin) < 2) ||
652  (logx > 1 && (xmax-xmin) < 2));
653 
654  master->GetYaxis()->SetMoreLogLabels( logy && log10(ymax/ymin) < 2);
655  master->GetYaxis()->SetNoExponent ( logy && log10(ymax/ymin) < 2);
656 
657  if (Ndivisions.first != "") {
658  master->SetNdivisions(Ndivisions.second, Ndivisions.first.c_str());
659  }
660 
661  if (xTimeFormat != "") {
662 
663  master->GetXaxis()->SetTimeDisplay(1);
664 
665  if (xTimeFormat == "utc") {
666  master->GetXaxis()->SetTimeFormat("#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
667  master->GetXaxis()->SetTimeOffset(0.0, "gmt");
668  } else if (xTimeFormat == "UTC") {
669  master->GetXaxis()->SetTimeFormat("%d-%m-%y");
670  master->GetXaxis()->SetTimeOffset(0.0, "gmt");
671  } else {
672  master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
673  }
674  }
675 
676  master->Draw(option.c_str());
677  }
678 
679  if (logx > 1) {
680  for (vector<JRootObject>::iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
681  if (dynamic_cast<TH1*>(i->get()) != master) {
682  setLogarithmicX(dynamic_cast<TH1*> (i->get()));
683  setLogarithmicX(dynamic_cast<TGraph*> (i->get()));
684  setLogarithmicX(dynamic_cast<TMultiGraph*>(i->get()));
685  setLogarithmicX(dynamic_cast<TF1*> (i->get()));
686  }
687  }
688  }
689 
690  if (grid.count('x') || grid.count('X')) { gPad->SetGridx(); }
691  if (grid.count('y') || grid.count('Y')) { gPad->SetGridy(); }
692 
693  if (stats != -1)
694  gStyle->SetOptStat(stats);
695  else
696  gStyle->SetOptFit(kFALSE);
697 
698 
699  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
700 
701  DEBUG("Draw " << (*i)->GetName() << ' ' << (*i)->GetTitle() << endl);
702 
703  string buffer(option);
704 
705  //if (!dynamic_cast<THStack*>(i->get())) {
706  // buffer += "SAMES";
707  //}
708 
709  buffer += "SAME";
710 
711  TF1* f1 = dynamic_cast<TF1*> (i->get());
712  TGraph* g1 = dynamic_cast<TGraph*> (i->get());
713  TMultiGraph* q1 = dynamic_cast<TMultiGraph*>(i->get());
714 
715  if (f1 != NULL) {
716  f1->SetNpx(1000);
717  }
718 
719  if (g1 != NULL) {
720  if (g1->GetN() > 1 && drawLine)
721  buffer += "L"; // drawing cut line
722  else
723  buffer += "P"; // drawing point(s)
724  }
725 
726  if (q1 != NULL) {
727 
728  for (TIter i1(q1->GetListOfGraphs()); TGraph* gi = dynamic_cast<TGraph*>(i1()); ) {
729 
730  string zbuf = buffer;
731 
732  if (gi->GetN() > 1 && drawLine)
733  zbuf += "L"; // drawing cut line
734  else
735  zbuf += "P"; // drawing point(s)
736 
737  gi->Draw(zbuf.c_str());
738  }
739 
740  } else {
741 
742  (*i).Draw(buffer.c_str());
743  }
744  }
745 
746  //gPad->RedrawAxis();
747 
748  if (legend != "") {
749 
750  Ssiz_t height = listOfObjects.size();
751  Ssiz_t width = 1;
752 
753  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
754  width = max(width, i->getLabel().Length());
755  }
756 
757  TLegend* lg = getLegend(width, height, legend);
758 
759  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
760  lg->AddEntry(*i, " " + i->getLabel(), isTAttLine(*i) ? "L" : "LPF");
761  }
762 
763  lg->Draw();
764  }
765 
766  cv->Update();
767 
768  if (outputFile != "") {
769  cv->SaveAs(outputFile.c_str());
770  }
771 
772  if (!batch) {
773  tp->Run();
774  }
775 
776  return (master != NULL ? 0 : 1);
777 }
Utility class to parse command line options.
Definition: JParser.hh:1500
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition: JLocation.hh:246
then echo Test string reversed by master(hit< return > to continue)." JProcess -c "JEcho" -rC fi if (( 1 ))
Definition: JRoot.hh:19
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
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
bool isTAttLine(const TObject *object)
Get drawing option of TH1.
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
#define NOTICE(A)
Definition: JMessage.hh:64
#define ERROR(A)
Definition: JMessage.hh:66
then break fi done getCenter read X Y Z let X
int debug
debug level
Definition: JSirene.cc:63
static const char LABEL_TERMINATOR
label terminator
Definition: JRootObject.hh:23
#define FATAL(A)
Definition: JMessage.hh:67
void setRange(double &xmin, double &xmax, const bool logx)
Set axis range.
TLegend * getLegend(const Int_t width, const Int_t height, const std::string option="TR")
Get legend.
Definition: JLegend.hh:28
Auxiliary class to handle multiple boolean-like I/O.
Definition: JParser.hh:221
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25