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 "TEllipse.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 62 of file JPlot1D.cc.

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