Jpp  16.0.0-rc.2
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  DEBUG("Label: <" << *i << ">" << endl);
547 
548  if (i->Length() > 2) {
549  object.setLabel((*i)(1, i->Length() - 2));
550  }
551  }
552 
553  DEBUG("Add object: " << tag << " with label " << object.getLabel() << endl);
554 
555  if (master == NULL) {
556  master = dynamic_cast<TH1*>(object.get());
557  }
558 
559  listOfObjects.push_back(object);
560  }
561  }
562  }
563 
564  if (listOfObjects.empty()) {
565  ERROR("Nothing to draw." << endl);
566  }
567 
568  for (vector<JRootObject>::iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
569 
570  // set line attributes of associated functions
571  // for single objects, change colour if same range else change style
572  // for multiple objecs, keep colour and change style
573 
574  TH1* h1 = dynamic_cast<TH1*> (i->get());
575  TGraph* g1 = dynamic_cast<TGraph*> (i->get());
576  TMultiGraph* m1 = dynamic_cast<TMultiGraph*>(i->get());
577  TAttLine* ls = dynamic_cast<TAttLine*> (i->get());
578 
579  TList list;
580  TIterator* iterator = NULL;
581 
582  if (h1 != NULL) {
583 
584  iterator = h1->GetListOfFunctions()->MakeIterator();
585 
586  } else if (g1 != NULL) {
587 
588  iterator = g1->GetListOfFunctions()->MakeIterator();
589 
590  } else if (m1 != NULL) {
591 
592  for (TIter i1(m1->GetListOfGraphs()); TGraph* gi = dynamic_cast<TGraph*>(i1()); ) {
593  for (TIter i2(gi->GetListOfFunctions()); TF1* fi = dynamic_cast<TF1*>(i2()); ) {
594  list.Add(fi);
595  }
596  }
597 
598  iterator = list.MakeIterator();
599  }
600 
601  if (iterator != NULL) {
602 
603  Double_t x1[] = { numeric_limits<Double_t>::max(), numeric_limits<Double_t>::max() };
604  Double_t x2[] = { numeric_limits<Double_t>::lowest(), numeric_limits<Double_t>::lowest() };
605 
606  for (int nf = 0, ns = 0, nc = 1; TF1* f1 = (TF1*) iterator->Next(); ++nf) {
607 
608  f1->GetRange(x1[1], x2[1]);
609  f1->SetNpx(1000);
610 
611  dynamic_cast<TAttLine&>(*f1) = JLineAttributes::getInstance().get(0);
612 
613  if (listOfObjects.size() == 1) {
614 
615  if (x1[0] == x1[1] &&
616  x2[0] == x2[1])
617  ++nc; // change colour
618  else if (nf != 0)
619  ++ns; // change style
620 
621  f1->SetLineStyle(JLineAttributes ::getInstance().get(ns).GetLineStyle());
622  f1->SetLineColor(JMarkerAttributes::getInstance().get(nc).GetMarkerColor());
623 
624  } else {
625 
626  // keep colour of base object and accordingly modify line style.
627 
628  f1->SetLineColor(ls->GetLineColor());
629  f1->SetLineStyle(JLineAttributes::getInstance().get(ns++).GetLineStyle());
630  }
631 
632  x1[0] = x1[1];
633  x2[0] = x2[1];
634 
635  // set limits
636 
637  double __xmin;
638  double __xmax;
639 
640  f1->GetRange(__xmin, __xmax);
641 
642  ymin = min(ymin, f1->GetMinimum(__xmin, __xmax));
643  ymax = max(ymax, f1->GetMaximum(__xmin, __xmax));
644  }
645  }
646  }
647 
648  // plot frame
649 
650  if (X != JRange_t()) {
651  xmin = X.getLowerLimit();
652  xmax = X.getUpperLimit();
653  }
654 
655  if (Y != JRange_t()) {
656  ymin = Y.getLowerLimit();
657  ymax = Y.getUpperLimit();
658  } else {
659  setRange(ymin, ymax, logy);
660  }
661 
662  cv->cd(1);
663 
664  if (!listOfObjects.empty()) {
665 
666  if (master == NULL || master->GetXaxis()->GetXmin() > xmin || master->GetXaxis()->GetXmax() < xmax) {
667 
668  if (X != JRange_t()) {
669 
670  master = new TH1D(MASTER.c_str(), NULL, 100, X.getLowerLimit(), X.getUpperLimit());
671 
672  master->SetStats(kFALSE);
673 
674  } else if (xmin < xmax) {
675 
676  master = new TH1D(MASTER.c_str(), NULL, 100, xmin, xmax);
677 
678  master->SetStats(kFALSE);
679  }
680  }
681  }
682 
683  if (master == NULL) {
684 
685  TText* p = new TText(0.5, 0.5, MAKE_CSTRING("No data"));
686 
687  p->SetTextAlign(21);
688  p->SetTextAngle(45);
689  p->Draw();
690 
691  } else {
692 
693  if (logx) { gPad->SetLogx(); }
694  if (logy) { gPad->SetLogy(); }
695 
696  master->GetXaxis()->SetRangeUser(xmin, xmax);
697 
698  if (logx > 1) {
700  }
701 
702  master->SetTitle(title.c_str());
703 
704  master->SetMinimum(ymin);
705  master->SetMaximum(ymax);
706 
707  if (xLabel != "") { master->GetXaxis()->SetTitle(xLabel.c_str()); master->GetXaxis()->CenterTitle(true); }
708  if (yLabel != "") { master->GetYaxis()->SetTitle(yLabel.c_str()); master->GetYaxis()->CenterTitle(true); }
709 
710  master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(xmax/xmin) < 2) ||
711  (logx > 1 && (xmax-xmin) < 2));
712 
713  master->GetYaxis()->SetMoreLogLabels( logy && log10(ymax/ymin) < 2);
714  master->GetYaxis()->SetNoExponent ( logy && log10(ymax/ymin) < 2);
715 
716  if (Ndivisions.first != "") {
717  master->SetNdivisions(Ndivisions.second, Ndivisions.first.c_str());
718  }
719 
720  if (xTimeFormat != "") {
721 
722  master->GetXaxis()->SetTimeDisplay(1);
723 
724  if (xTimeFormat == "utc") {
725  master->GetXaxis()->SetTimeFormat("#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
726  master->GetXaxis()->SetTimeOffset(0.0, "gmt");
727  } else if (xTimeFormat == "UTC") {
728  master->GetXaxis()->SetTimeFormat("%d-%m-%y");
729  master->GetXaxis()->SetTimeOffset(0.0, "gmt");
730  } else {
731  master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
732  }
733  }
734 
735  master->Draw(MAKE_CSTRING(option << (MASTER == master->GetName() ? "AXIS" : "")));
736  }
737 
738  if (logx > 1) {
739  for (vector<JRootObject>::iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
740  if (dynamic_cast<TH1*>(i->get()) != master) {
741  if (setLogX<TH1> (i->get())) {}
742  else if (setLogX<TF1> (i->get())) {}
743  else if (setLogX<TGraphErrors>(i->get())) {}
744  else if (setLogX<TGraph> (i->get())) {}
745  else if (setLogX<TMultiGraph> (i->get())) {}
746  else if (setLogX<TLine> (i->get())) {}
747  else if (setLogX<TEllipse> (i->get())) {}
748  }
749  }
750  }
751 
752  if (grid.count('x') || grid.count('X')) { gPad->SetGridx(); }
753  if (grid.count('y') || grid.count('Y')) { gPad->SetGridy(); }
754 
755  if (stats != -1)
756  gStyle->SetOptStat(stats);
757  else
758  gStyle->SetOptFit(kFALSE);
759 
760 
761  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
762 
763  DEBUG("Draw " << (*i)->GetName() << ' ' << (*i)->GetTitle() << endl);
764 
765  string buffer(option);
766 
767  //if (!dynamic_cast<THStack*>(i->get())) {
768  // buffer += "SAMES";
769  //}
770 
771  buffer += "SAME";
772 
773  TF1* f1 = dynamic_cast<TF1*> (i->get());
774  TGraph* g1 = dynamic_cast<TGraph*> (i->get());
775  TMultiGraph* q1 = dynamic_cast<TMultiGraph*>(i->get());
776 
777  if (f1 != NULL) {
778  f1->SetNpx(1000);
779  }
780 
781  if (g1 != NULL) {
782  if (g1->GetN() > 1 && drawLine)
783  buffer += "L"; // drawing cut line
784  else
785  buffer += "P"; // drawing point(s)
786  }
787 
788  if (q1 != NULL) {
789 
790  for (TIter i1(q1->GetListOfGraphs()); TGraph* gi = dynamic_cast<TGraph*>(i1()); ) {
791 
792  string zbuf = buffer;
793 
794  if (gi->GetN() > 1 && drawLine)
795  zbuf += "L"; // drawing cut line
796  else
797  zbuf += "P"; // drawing point(s)
798 
799  gi->Draw(zbuf.c_str());
800  }
801 
802  } else {
803 
804  (*i).Draw(buffer.c_str());
805  }
806  }
807 
808  //gPad->RedrawAxis();
809 
810  if (legend != "") {
811 
812  Ssiz_t height = listOfObjects.size();
813  Ssiz_t width = 1;
814 
815  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
816  width = max(width, i->getLabel().Length());
817  }
818 
819  TLegend* lg = getLegend(width, height, legend);
820 
821  for (vector<JRootObject>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
822  lg->AddEntry(*i, " " + i->getLabel(), isTAttLine(*i) ? "L" : "LPF");
823  }
824 
825  lg->Draw();
826  }
827 
828  cv->Update();
829 
830  if (outputFile != "") {
831  cv->SaveAs(outputFile.c_str());
832  }
833 
834  if (!batch) {
835  tp->Run();
836  }
837 
838  return (master != NULL ? 0 : 1);
839 }
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