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