Jpp  16.0.3
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 88 of file JPlot1D.cc.

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