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