Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPlot1D.cc File Reference

General purpose plot program for 1D ROOT objects. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TClass.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TKey.h"
#include "TStyle.h"
#include "TAttMarker.h"
#include "TAttLine.h"
#include "TH1.h"
#include "TH2.h"
#include "TH3.h"
#include "TF1.h"
#include "TF2.h"
#include "THStack.h"
#include "TGraph.h"
#include "TGraphErrors.h"
#include "TMultiGraph.h"
#include "TProfile.h"
#include "TEllipse.h"
#include "TMarker.h"
#include "TLine.h"
#include "TLegend.h"
#include "TString.h"
#include "TRegexp.h"
#include "TText.h"
#include "JTools/JRange.hh"
#include "JLang/JSinglePointer.hh"
#include "JROOT/JStyle.hh"
#include "JROOT/JCanvas.hh"
#include "JROOT/JMarkerAttributes.hh"
#include "JROOT/JLineAttributes.hh"
#include "JROOT/JLegend.hh"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JRootObject.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

General purpose plot program for 1D ROOT objects.

The option -f corresponds to <file name>:<object name>.

Author
mdejong

Definition in file JPlot1D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 63 of file JPlot1D.cc.

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