ATLAS Offline Software
computils.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
11 #ifndef COMPUTILS_H
12 #define COMPUTILS_H
13 
14 #include <iostream>
15 #include <string>
16 #include <vector>
17 #include <cstdio>
18 #include <cstdlib>
19 #include <exception>
20 
21 #include "label.h"
22 #include "utils.h"
23 #include "DrawLabel.h"
24 
25 
26 #include "TStyle.h"
27 #include "TPad.h"
28 #include "TH1D.h"
29 #include "TFile.h"
30 #include "TH1.h"
31 #include "TGraphAsymmErrors.h"
32 
33 #include "TLegend.h"
34 
35 
36 extern bool LINEF;
37 extern bool LINES;
38 
39 
40 void ATLASFORAPP_LABEL( double x, double y, int color, double size=0.06 );
41 
42 void myText( Double_t x, Double_t y, Color_t color, const std::string& text, Double_t tsize);
43 
44 
46 std::string stime();
47 static std::string release;
48 
49 double integral( TH1* h );
50 
51 void Norm( TH1* h, double scale=1 );
52 
53 double Entries( TH1* h );
54 
56 bool contains( const std::string& s, const std::string& p);
57 bool contains( const std::string& s, char p) noexcept;
58 
60 bool fcontains( const std::string& s, const std::string& p);
61 
63 bool exists( const std::string& filename );
64 
66 std::string tail( std::string s, const std::string& pattern );
67 
69 std::string head( std::string s, const std::string& pattern );
70 
72 std::string globbed( const std::string& s );
73 
74 void contents( std::vector<std::string>& keys,
75  TDirectory* td,
76  const std::string& directory="",
77  const std::string& pattern="",
78  const std::string& path="" );
79 
80 void contents( std::vector<std::string>& keys,
81  TDirectory* td,
82  const std::string& directory="",
83  const std::vector<std::string>& patterns=std::vector<std::string>(),
84  const std::string& path="" );
85 
86 
87 double realmax( TH1* h, bool include_error=true, double lo=0, double hi=0 );
88 double realmin( TH1* h, bool include_error=true, double lo=0, double hi=0 );
89 
90 std::string findcell( std::string name, const std::string& regex, const std::string& splitex="/" );
91 
92 std::string findrun( TFile *f );
93 
94 double plotable( TH1* h ); // , double xlo=-999, double xhi=-999 );
95 
96 
97 class data_mismatch : public std::exception {
98 public:
99  data_mismatch(const std::string& s) { std::cerr << "exception:" << data_mismatch::what() << " " << s << std::endl; };
100  virtual const char* what() const throw() { return "data don't match"; }
101 };
102 
103 
104 
105 template<typename T>
106 std::ostream& operator<<( std::ostream& s, std::vector<T>& v) {
107  for ( unsigned i=0 ; i<v.size() ; i++ ) s << "\t" << v[i];
108  return s;
109 }
110 
111 
113 std::vector<int> findxrange(TH1* h, bool symmetric=false );
114 std::vector<double> findxrangeuser(TH1* h, bool symmetric=false );
115 
116 
117 
118 void trim_tgraph( TH1* h, TGraphAsymmErrors* t );
119 
120 
121 void xrange(TH1* h, bool symmetric=true );
122 
124 void copyReleaseInfo( TFile* finput, TFile* foutdir );
125 
126 
127 class true_mean {
128 
129 public:
130 
131  true_mean( TH1F* h );
132 
133  double mean() const { return m_mean; }
134  double error() const { return m_error; }
135 
136 private:
137 
138  double m_mean;
139  double m_error;
140 
141 };
142 
143 
146 
147 class AxisInfo {
148 
149 public:
150 
151  AxisInfo( const std::string& s ) :
152  m_info(s),
153  m_log(false),
154  m_autoset(false),
155  m_symmetric(false),
156  m_rangeset(false),
157  m_lo(0),
158  m_hi(0),
159  m_norm(false),
160  m_refnorm(false),
161  m_binwidth(false),
162  m_offset(0),
163  m_trim(false)
164  {
165  // std::cout << "AxisInfo::info" << m_info << std::endl;
166 
167  std::vector<std::string> keys = split( s, ":" );
168 
169  // std::cout << "\n\n" << s << "\nnkeys " << keys.size() << std::endl;
170 
171  if ( keys.size()>0 ) m_tag = keys[0];
172 
173  bool minset = false;
174  // bool maxset = false;
175 
176  for ( size_t i=1 ; i<keys.size() ; i++ ) {
177 
178  if ( keys[i]=="lin" ) m_log = false;
179  else if ( keys[i]=="log" ) m_log = true;
180  else if ( keys[i]=="sym" ) m_symmetric = true;
181  else if ( keys[i]=="norm" ) m_norm = true;
182  else if ( keys[i]=="refn" ) m_refnorm = true;
183  else if ( keys[i]=="width" ) m_binwidth = true;
184  else if ( keys[i]=="auto" ) m_autoset = true;
185  else if ( keys[i]=="trim" ) m_trim = true;
186  else if ( keys[i].find("offset")==0 ) {
187 
188  std::cout << "offset:" << std::endl;
189  std::cout << "\tkey: " << keys[i] << std::endl;
190  std::cout << "\tpos: " << keys[i].find("offset") << std::endl;
191 
192  std::string offset = keys[i];
193  m_offset=std::atof(offset.substr(6,offset.size()-6).c_str());
194 
195  std::cout << "m_offset: " << m_offset << std::endl;
196  }
197  else if ( keys[i]=="auton" ) {
198  m_autoset = true;
199  m_norm = true;
200  }
201  else if ( keys[i]=="autow" ) {
202  m_autoset = true;
203  m_binwidth = true;
204  }
205  else if ( keys[i]=="autown" || keys[i]=="autonw" ) {
206  m_autoset = true;
207  m_norm = true;
208  m_binwidth = true;
209  }
210  else if ( keys[i]=="autosym" ) {
211  m_autoset = true;
212  m_symmetric = true;
213  }
214  else if ( keys[i]=="normw" || keys[i]=="widthn" ) {
215  m_norm = true;
216  m_binwidth = true;
217  }
218  else if ( !minset ) {
219  m_lo = std::atof(keys[i].c_str());
220  i++;
221  if ( i<keys.size() ) m_hi = std::atof(keys[i].c_str());
222  else {
223  std::cerr << "not enough values for the axis range: " << s << std::endl;
224  std::exit(-1);
225  }
226  minset = true;
227  // maxset = true;
228  m_rangeset = true;
229  }
230  }
231 
232 #if 0
233  std::cout << "AxisInfo::info" << m_info << "\n";
234  std::cout << "\tlog " << m_log << "\n";
235  std::cout << "\tauto " << m_autoset << "\n";
236  std::cout << "\tsym " << m_symmetric << "\n";
237  std::cout << "\trange " << m_rangeset << " : " << m_lo << " - " << m_hi << std::endl;
238 #endif
239 
240  }
241 
243 
244  std::string tag() const { return m_tag; }
245 
246  bool log() const { return m_log; }
247 
248  bool autoset() const { return m_autoset; }
249 
250  bool normset() const { return m_norm; }
251 
252  bool refnormset() const { return m_refnorm; }
253 
254  bool symmetric() const { return m_symmetric; }
255 
256  bool rangeset() const { return m_rangeset; }
257 
258  bool trim() const { return m_trim; }
259 
260 
261  double offset() const { return m_offset; }
262 
263 
264  double lo() const { return m_lo; }
265  double hi() const { return m_hi; }
266 
267  double binwidth() const { return m_binwidth; }
268 
269  std::string c_str() const { return m_info; }
270 
271 
272 public:
273 
274  static std::vector<std::string> split( const std::string& s, const std::string& t=":" ) {
275 
276  std::string sc = s;
277  size_t pos = sc.find(t);
278 
279  std::vector<std::string> tags;
280 
281  while ( pos!=std::string::npos ) {
282  tags.push_back( chop(sc,t) );
283  pos = sc.find(t);
284  }
285 
286  tags.push_back(sc);
287 
288  return tags;
289  }
290 
291 
292 public:
293 
294  std::string m_info;
295 
296  std::string m_tag;
297 
298  bool m_log;
299  bool m_autoset;
301 
303  double m_lo;
304  double m_hi;
305 
306  bool m_norm;
307  bool m_refnorm;
308 
310 
311  double m_offset;
312 
313  bool m_trim;
314 
315 };
316 
317 
318 inline std::ostream& operator<<( std::ostream& s, const AxisInfo& a ) {
319  s << "[ " << a.tag() << ( a.log() ? " : log" : "" ) << " ";
320  if ( a.autoset() ) s << " : auto";
321  else if ( a.rangeset() ) s << " : range " << a.lo() << " - " << a.hi();
322  s << " ]";
323  return s;
324 }
325 
326 
327 
328 
329 
330 
331 
333 class Legend {
334 
335 public:
336 
337  Legend() : m_leg(nullptr){
338  m_x[0]=0.0;
339  m_y[0]=0.0;
340  m_x[1]=0.0;
341  m_y[1]=0.0;
342  }
343 
344  Legend(double x1, double x2, double y1, double y2): m_leg(nullptr) {
345  m_x[0]=x1;
346  m_y[0]=y1;
347  m_x[1]=x2;
348  m_y[1]=y2;
349  }
350 
351 
352  // Legend( const Legend& leg ) : mleg((TLegend*)leg.mleg->Clone()) { }
353 
355  m_x{legend.m_x[0], legend.m_x[1]},
356  m_y{legend.m_y[0], legend.m_y[1]} { }
357 
358  ~Legend() { }
359 
360  TLegend* legend() { return m_leg; }
361 
362  size_t size() const {
363  return m_entries.size();
364  }
365 
366  double TextSize() const { return m_leg->GetTextSize(); }
367 
368  int TextFont() const { return m_leg->GetTextFont(); }
369 
370  double height() const { return m_y[1]-m_y[0]; }
371 
372  double width() const { return m_x[1]-m_x[0]; }
373 
374  void AddEntry( TObject* tobj, const std::string& s, const std::string& type="p" ) {
375  m_obj.push_back( tobj );
376  m_entries.push_back( s );
377  m_type.push_back( type );
378  }
379 
380  void Draw() {
381 
384 
385  double y0 = 0;
386 
387  if ( m_y[0]>0.5 ) {
388  y0 = m_y[1] - m_entries.size()*0.05;
389  }
390  else {
391  y0 = m_y[0];
392  m_y[1] = y0 + m_entries.size()*0.05;
393  }
394 
395  m_leg = new TLegend( m_x[0], y0, m_x[1], m_y[1] );
396 
397  m_leg->SetBorderSize(0);
398  m_leg->SetTextFont(42);
399  m_leg->SetTextSize(0.04);
400  m_leg->SetFillStyle(3000);
401  m_leg->SetFillColor(0);
402  m_leg->SetLineColor(0);
403 
404  for ( size_t i=0 ; i<m_entries.size() ; i++ ) {
405  m_leg->AddEntry( m_obj[i], m_entries[i].c_str(), m_type[i].c_str() );
406  }
407 
408  m_leg->Draw();
409  }
410 
411 
412 private:
413 
414  TLegend* m_leg;
415 
416  double m_x[2];
417  double m_y[2];
418 
419  std::vector<TObject*> m_obj;
420  std::vector<std::string> m_entries;
421  std::vector<std::string> m_type;
422 
423 };
424 
425 
426 extern int colours[6]; // = { 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 };
427 extern int markers[6]; // = { 20, 24, 25, 26, 25, 22 };
428 extern double msizes[6]; // = { 1, 1, 1, 1, 1, 1 };
429 
430 
431 template<typename T>
432 void setParameters( T* h, TGraphAsymmErrors* tg ) {
433  tg->SetLineColor( h->GetLineColor() );
434  tg->SetMarkerColor( h->GetMarkerColor() );
435  tg->SetMarkerStyle( h->GetMarkerStyle() );
436  tg->SetMarkerSize( h->GetMarkerSize() );
437  tg->SetLineWidth( h->GetLineWidth() );
438  tg->SetLineStyle( h->GetLineStyle() );
439 }
440 
441 
442 template<typename T>
443 void zeroErrors( T* h ) {
444  for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) h->SetBinError( i, 1e-100 );
445 }
446 
447 
448 
453 template<typename T>
454 class tPlotter {
455 
456 public:
457 
458  tPlotter(T* _htest=0, T* _href=0, const std::string& s="", TGraphAsymmErrors* _tgtest=0, TGraphAsymmErrors* _tgref=0 ) :
459  m_htest(_htest), m_href(_href),
460  m_tgtest(_tgtest), m_tgref(_tgref),
461  m_plotfilename(s),
462  m_max_entries(4),
463  m_entries(0),
464  m_trim_errors(false)
465  {
466  }
467 
468 
469  tPlotter(const tPlotter& p) :
474  m_entries(0),
476  }
477 
478 
479 
482  // ~tPlotter() { if ( m_tg ) delete m_tg; }
485  ~tPlotter() { }
486 
487  std::string plotfilename() const { return m_plotfilename; }
488 
489  void trim_errors(bool b) { m_trim_errors=b; }
490 
491  bool trim_errors() const { return m_trim_errors; }
492 
493  void Draw( int i, Legend* lleg, bool mean=false, bool first=true, bool drawlegend=false ) {
494 
495  if ( htest() ) {
496  gStyle->SetOptStat(0);
497  if ( href() ) {
498  href()->SetLineColor(colours[i%6]);
499  href()->SetLineStyle(2);
500  href()->SetMarkerStyle(0);
501  }
502 
503  if ( LINEF ) htest()->SetLineColor(colours[i%6]);
504 
505  htest()->SetLineStyle(1);
506 
507  if ( LINEF ) htest()->SetMarkerColor(htest()->GetLineColor());
508 
509  if ( LINEF ) htest()->SetMarkerStyle(markers[i%6]);
510  // if ( LINEF && htest()->GetMarkerStyle() == 20 )
511 
512  if ( LINEF ) htest()->SetMarkerSize( msizes[i%6]*htest()->GetMarkerSize() );
513 
514  if ( htest() ) std::cout << "\tentries: " << plotable( htest() );
515 
516  std::cout << std::endl;
517 
518  if ( first ) {
519 
520  if ( tgtest() ) {
521  zeroErrors(htest());
522  htest()->GetXaxis()->SetMoreLogLabels(true);
523  if ( trim_errors() ) trim_tgraph( htest(), tgtest() );
524 
525 
526  htest()->Draw("ep");
527  if ( LINES ) htest()->Draw("lhistsame");
528  setParameters( htest(), tgtest() );
529  tgtest()->Draw("esame");
530  }
531  else {
532  htest()->GetXaxis()->SetMoreLogLabels(true);
533  htest()->Draw("ep");
534  if ( LINES ) htest()->Draw("lhistsame");
535  }
536 
537  }
538 
539  if ( s_plotref && href() ) {
540  if ( contains(href()->GetName(),"_vs_") ||
541  contains(href()->GetName(),"sigma") ||
542  contains(href()->GetName(),"mean") ||
543  contains(href()->GetName(),"_eff") ||
544  contains(href()->GetName(),"Res_") ||
545  contains(href()->GetName(),"Eff_") ) href()->Draw("hist same][");
546  else href()->Draw("hist same");
547  }
548 
549  if ( tgtest() ) {
550  zeroErrors(htest());
551 
552  if ( trim_errors() ) trim_tgraph( htest(), tgtest() );
553  setParameters( htest(), tgtest() );
554  tgtest()->Draw("e1same");
555  if ( LINES ) tgtest()->Draw("lsame");
556 
557  }
558 
559 #if 0
560  if ( htest()->GetMarkerStyle()>23 ) {
562  TH1D* hnull = (TH1D*)htest()->Clone("duff"); hnull->SetDirectory(0);
563  zeroErrors( hnull );
564  hnull->SetLineColor(kWhite);
565  hnull->SetMarkerStyle( htest()->GetMarkerStyle()-4 );
566  // hnull->SetMarkerStyle( 0 );
567  hnull->SetMarkerColor(kWhite);
568  hnull->SetMarkerSize( htest()->GetMarkerSize()*0.75 );
569  // hnull->SetMarkerSize( 0 );
570  hnull->DrawCopy("l same");
571  delete hnull;
572  }
573 #endif
574 
575  htest()->Draw("ep same");
576  if ( LINES ) htest()->Draw("lhist same");
577 
578  // href()->Draw("lhistsame");
579  // htest()->Draw("lhistsame");
580 
581  std::string key = m_plotfilename;
582 
583  static TH1D* hnull = new TH1D("hnull", "", 1, 0, 1);
584  hnull->SetMarkerColor(kWhite);
585  hnull->SetLineColor(kWhite);
586  hnull->SetMarkerStyle(0);
587  hnull->SetLineStyle(0);
588  hnull->SetLineWidth(0);
589  hnull->SetMarkerSize(0);
590 
591 
592  if ( lleg ) {
593 
594  Legend& leg = *lleg;
595 
596  if ( mean ) {
597 
598  char meanrefc[64];
599  bool displayref = false;
600  if ( s_meanplotref && href() ) {
601  displayref = true;
602  true_mean muref( href() );
603  std::sprintf( meanrefc, " <t> = %3.2f #pm %3.2f ms (ref)", muref.mean(), muref.error() );
604  }
605  else {
606  std::sprintf( meanrefc, "%s", "" );
607  }
608 
609  true_mean mutest( htest() );
610  char meanc[64];
611  std::sprintf( meanc, " <t> = %3.2f #pm %3.2f ms", mutest.mean(), mutest.error() );
612 
613  std::string dkey = key;
614 
615  std::string remove[7] = { "TIME_", "Time_", "All_", "Algorithm_", "Class_", "HLT_", "Chain_HLT_" };
616 
617  if ( dkey.find("Chain")!=std::string::npos ) {
618  if ( dkey.find("__")!=std::string::npos ) dkey.erase( 0, dkey.find("__")+2 );
619  }
620 
621 
622  for ( int ir=0 ; ir<7 ; ir++ ) {
623  if ( dkey.find( remove[ir] )!=std::string::npos ) dkey.erase( dkey.find( remove[ir]), remove[ir].size() );
624  }
625 
626  std::string rkey = dkey;
627 
628 
629  if ( LINEF || leg.size() < m_max_entries ) {
630  dkey += std::string(" : ");
631 
632  if ( (dkey+meanc).size()>58 ) {
633  leg.AddEntry( htest(), dkey, "p" );
634  leg.AddEntry( hnull, meanc, "p" );
635  }
636  else {
637  leg.AddEntry( htest(), (dkey+meanc).c_str(), "p" );
638  }
639 
640  if ( displayref ) {
641  rkey += std::string(" : ");
643  // leg.AddEntry( hnull, "", "l" );
644 
645  if ( (rkey+meanrefc).size()>58 ) {
646  leg.AddEntry( href(), rkey, "l" );
647  leg.AddEntry( hnull, meanrefc, "l" );
648  }
649  else {
650  leg.AddEntry( href(), (rkey+meanrefc).c_str(), "l" );
651  }
652  }
653  }
654 
655  }
656  else {
657  if ( LINEF || leg.size()<m_max_entries ) leg.AddEntry( htest(), key, "p" );
658  }
659 
660  m_entries++;
661 
662  if ( drawlegend ) leg.Draw();
663  }
664 
665  }
666  }
667 
668 
669 
670  void DrawLegend( int i, Legend& leg, bool mean=false, bool first=true, bool drawlegend=false ) {
671 
672  if ( htest() ) {
673  gStyle->SetOptStat(0);
674  if ( href() ) {
675  href()->SetLineColor(colours[i%6]);
676  href()->SetLineStyle(2);
677  href()->SetMarkerStyle(0);
678  }
679 
680  if ( LINEF ) htest()->SetLineColor(colours[i%6]);
681  htest()->SetLineStyle(1);
682  if ( LINEF ) htest()->SetMarkerColor(htest()->GetLineColor());
683  if ( LINEF ) htest()->SetMarkerStyle(markers[i%6]);
684 
685  if ( htest() ) std::cout << "\tentries: " << plotable( htest() );
686  std::cout << std::endl;
687 
688  if ( first ) {
689 
690  if ( tgtest() ) {
691  zeroErrors(htest());
692  htest()->GetXaxis()->SetMoreLogLabels(true);
693  if ( trim_errors() ) trim_tgraph( htest(), tgtest() );
694 
695 
696  // htest()->Draw("ep");
697  if ( LINES ) htest()->Draw("lhistsame");
698  setParameters( htest(), tgtest() );
699  // tgtest()->Draw("esame");
700  }
701  else {
702  htest()->GetXaxis()->SetMoreLogLabels(true);
703  // htest()->Draw("ep");
704  // if ( LINES ) htest()->Draw("lhistsame");
705  }
706 
707  }
708 
709 
710 #if 0
711  if ( s_plotref && href() ) {
712  if ( contains(href()->GetName(),"_vs_") ||
713  contains(href()->GetName(),"sigma") ||
714  contains(href()->GetName(),"mean") ||
715  contains(href()->GetName(),"_eff") ||
716  contains(href()->GetName(),"Res_") ||
717  contains(href()->GetName(),"Eff_") ) href()->Draw("hist same][");
718  else href()->Draw("hist same");
719  }
720 
721  if ( tgtest() ) {
722  zeroErrors(htest());
723 
724  if ( trim_errors() ) trim_tgraph( htest(), tgtest() );
725  setParameters( htest(), tgtest() );
726  tgtest()->Draw("e1same");
727  if ( LINES ) tgtest()->Draw("lsame");
728 
729  }
730 #endif
731 
732 
733 #if 0
734  if ( htest()->GetMarkerStyle()>23 ) {
736  TH1D* hnull = (TH1D*)htest()->Clone("duff"); hnull->SetDirectory(0);
737  zeroErrors( hnull );
738  hnull->SetLineColor(kWhite);
739  hnull->SetMarkerStyle( htest()->GetMarkerStyle()-4 );
740  // hnull->SetMarkerStyle( 0 );
741  hnull->SetMarkerColor(kWhite);
742  hnull->SetMarkerSize( htest()->GetMarkerSize()*0.75 );
743  // hnull->SetMarkerSize( 0 );
744  hnull->DrawCopy("l same");
745  delete hnull;
746  }
747 #endif
748 
749  // htest()->Draw("ep same");
750  // if ( LINES ) htest()->Draw("lhist same");
751 
752  // href()->Draw("lhistsame");
753  // htest()->Draw("lhistsame");
754 
755  std::string key = m_plotfilename;
756 
757  static TH1D* hnull = new TH1D("hnull", "", 1, 0, 1);
758  hnull->SetMarkerColor(kWhite);
759  hnull->SetLineColor(kWhite);
760  hnull->SetMarkerStyle(0);
761  hnull->SetLineStyle(0);
762  hnull->SetLineWidth(0);
763  hnull->SetMarkerSize(0);
764 
765 
766  if ( mean ) {
767 
768  char meanrefc[64];
769  bool displayref = false;
770  if ( s_meanplotref && href() ) {
771  displayref = true;
772  true_mean muref( href() );
773  std::sprintf( meanrefc, " <t> = %3.2f #pm %3.2f ms (ref)", muref.mean(), muref.error() );
774  }
775  else {
776  std::sprintf( meanrefc, "%s", "" );
777  }
778 
779 
780  true_mean mutest( htest() );
781  char meanc[64];
782  std::sprintf( meanc, " <t> = %3.2f #pm %3.2f ms", mutest.mean(), mutest.error() );
783 
784  std::string dkey = key;
785 
786  std::string remove[7] = { "TIME_", "Time_", "All_", "Algorithm_", "Class_", "HLT_", "Chain_HLT_" };
787 
788  if ( dkey.find("Chain")!=std::string::npos ) {
789  if ( dkey.find("__")!=std::string::npos ) dkey.erase( 0, dkey.find("__")+2 );
790  }
791 
792 
793  for ( int ir=0 ; ir<7 ; ir++ ) {
794  if ( dkey.find( remove[ir] )!=std::string::npos ) dkey.erase( dkey.find( remove[ir]), remove[ir].size() );
795  }
796 
797  std::string rkey = dkey;
798 
799 
800  if ( LINEF || leg.size() < m_max_entries ) {
801  dkey += std::string(" : ");
802 
803  if ( (dkey+meanc).size()>58 ) {
804  leg.AddEntry( htest(), dkey, "p" );
805  leg.AddEntry( hnull, meanc, "p" );
806  }
807  else {
808  leg.AddEntry( htest(), (dkey+meanc).c_str(), "p" );
809  }
810 
811  if ( displayref ) {
812  rkey += std::string(" : ");
813  // leg.AddEntry( hnull, "", "l" );
814 
815  if ( (rkey+meanrefc).size()>58 ) {
816  leg.AddEntry( href(), rkey, "l" );
817  leg.AddEntry( hnull, meanrefc, "l" );
818  }
819  else {
820  leg.AddEntry( href(), (rkey+meanrefc).c_str(), "l" );
821  }
822  }
823  }
824 
825  }
826  else {
827  if ( LINEF || leg.size()<m_max_entries ) leg.AddEntry( htest(), key, "p" );
828  }
829 
830  m_entries++;
831 
832  if ( drawlegend ) leg.Draw();
833 
834  }
835  }
836 
837 
838 
840  void Print(const std::string& s="") {
841  if ( s!="" ) gPad->Print(s.c_str());
842  else gPad->Print(m_plotfilename.c_str());
843  }
844 
845  T* htest() { return m_htest; }
846  T* href() { return m_href; }
847 
848 
849  TGraphAsymmErrors* tgtest() { return m_tgtest; }
850  TGraphAsymmErrors* tgref() { return m_tgref; }
851 
852 
853  void max_entries( int i ) { m_max_entries = i; }
854 
855 public:
856 
857  static void setplotref( bool b ) { s_plotref=s_meanplotref=b; }
858  static void setmeanplotref( bool b ) { s_meanplotref=b; }
859 
860 private:
861 
865 
866  TGraphAsymmErrors* m_tgtest;
867  TGraphAsymmErrors* m_tgref;
868 
869  std::string m_plotfilename;
870 
871  static bool s_plotref;
872  static bool s_meanplotref;
873 
875  size_t m_entries;
876 
878 
879 };
880 
881 
883 
884 
886 template<typename T>
887 bool tPlotter<T>::s_plotref = true;
888 
889 
890 template<typename T>
891 bool tPlotter<T>::s_meanplotref = true;
892 
893 
894 
895 bool empty( TH1* h );
896 
897 
898 
899 inline void hminus(TH1* h) {
900  std::cout << __FUNCTION__ << std::endl;
901  for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
902  double duff = h->GetBinContent(i);
903  if ( duff<0 ) {
904  std::cout<< "\t\t" << __FUNCTION__ << " " << h->GetName() << " " << i << " " << h->GetBinContent(i) << " " << (duff*1e6) << std::endl;
905  }
906  }
907  h->DrawCopy();
908  gPad->Print( (std::string("duff-")+h->GetName()+".pdf").c_str() );
909 }
910 
911 
913 class Plots : public std::vector<Plotter> {
914 
915 public:
916 
917  Plots(const std::string& s="", bool errors=false ) :
918  m_name(s),
919  m_logx(false), m_logy(false),
920  m_maxset(false), m_max(0),
921  m_minset(false), m_min(0),
922  m_rangeset(false),
923  m_lo(0.0), m_hi(0.0),
925  { }
926 
927  double realmin( double lo=0, double hi=0 ) {
928  bool first = true;
929  double min = 1000;
930  for ( unsigned i=0 ; i<size() ; i++ ) {
931  double rmtest = ::realmin( at(i).htest(), false, lo, hi );
932  if ( rmtest!=0 && ( first || min>rmtest ) ) min = rmtest;
933  if ( rmtest!=0 ) first = false;
934  }
935  return min;
936  }
937 
938  double realmax(double lo=0, double hi=0) {
939  bool first = true;
940  double max = 0;
941  for ( unsigned i=0 ; i<size() ; i++ ) {
942  // double rmref = realmin( at(i).href(), false );
943  double rmtest = ::realmax( at(i).htest(), false, lo, hi );
944  if ( rmtest!=0 && ( first || max<rmtest ) ) max = rmtest;
945  if ( rmtest!=0 ) first = false;
946  }
947  return max;
948  }
949 
950 
951 
952  void MaxScale(double scale=1.1, double lo=0, double hi=0) {
953 
954  if ( size()<1 ) return;
955 
956  double tmax = realmax(lo,hi);
957  double tmin = realmin(lo,hi);
958 
959  m_max = scale*tmin;
960 
961  if ( m_logy ) m_min = tmin;
962 
963  for ( unsigned i=0 ; i<size() ; i++ ) {
964  if ( at(i).href() ) at(i).href()->SetMaximum(scale*tmax);
965  at(i).htest()->SetMaximum(scale*tmax);
966  }
967 
968  }
969 
970 
971  void MinScale( double scale, double lo=0, double hi=0 ) {
972 
973  if ( size()<1 ) return;
974 
975  if ( scale==0 ) {
976  for ( unsigned i=0 ; i<size() ; i++ ) {
977  if ( at(i).href() ) at(i).href()->SetMinimum(0);
978  at(i).htest()->SetMinimum(0);
979  }
980  return;
981  }
982 
983 
984  double tmin = 0;
985 
986  if ( lo!=hi ) tmin = realmin( lo, hi );
987  else tmin = realmin();
988 
989  m_min = scale*tmin;
990 
991  for ( unsigned i=0 ; i<size() ; i++ ) {
992  if ( at(i).href() ) at(i).href()->SetMinimum(scale*tmin);
993  at(i).htest()->SetMinimum(scale*tmin);
994  }
995  }
996 
997 
998  void Min( double scale ) {
999  m_minset = true;
1000  for ( unsigned i=0 ; i<size() ; i++ ) {
1001  if ( at(i).href() ) at(i).href()->SetMinimum(scale);
1002  at(i).htest()->SetMinimum(scale);
1003  if ( m_logy ) {
1004  if ( at(i).href() ) if ( at(i).href()->GetMinimum()<=0 ) at(i).href()->GetMinimum(1e-4);
1005  if ( at(i).htest()->GetMinimum()<=0 ) at(i).htest()->GetMinimum(1e-4);
1006  }
1007  }
1008  }
1009 
1010 
1011  void Max( double scale ) {
1012  m_maxset = true;
1013  for ( unsigned i=0 ; i<size() ; i++ ) {
1014  if ( at(i).href() ) at(i).href()->SetMaximum(scale);
1015  at(i).htest()->SetMaximum(scale);
1016  }
1017  }
1018 
1019  std::vector<double> findxrange( bool symmetric=false ) {
1020 
1023 
1024  std::vector<double> v(2,0);
1025 
1026  TH1F* hf = at(0).htest();
1027 
1028  double vlo = 1e21;
1029  double vhi = -1e21;
1030 
1031  if ( hf->GetBinLowEdge(1)<vlo ) vlo = hf->GetBinLowEdge(1);
1032  if ( hf->GetBinLowEdge(hf->GetNbinsX()+1)>vhi ) vhi = hf->GetBinLowEdge( hf->GetNbinsX()+1 );
1033 
1034  if ( size()>0 ) v = ::findxrangeuser( hf, symmetric );
1035 
1036  bool first = false;
1037 
1038  for ( unsigned i=1 ; i<size() ; i++ ) {
1039 
1040  hf = at(i).htest();
1041 
1042  if ( ::empty( hf ) ) continue;
1043 
1044  if ( hf->GetBinLowEdge(1)<vlo ) vlo = hf->GetBinLowEdge(1);
1045  if ( hf->GetBinLowEdge(hf->GetNbinsX()+1)>vhi ) vhi = hf->GetBinLowEdge( hf->GetNbinsX()+1 );
1046 
1047  std::vector<double> limits = ::findxrangeuser( hf, symmetric );
1048 
1049  double lo = limits[0];
1050  double hi = limits[1];
1051 
1052  if ( first ) {
1053  v[0] = lo;
1054  v[1] = hi;
1055  }
1056  else {
1057  if ( v[0]>lo ) v[0] = lo;
1058  if ( v[1]<hi ) v[1] = hi;
1059  }
1060 
1061  first = false;
1062  }
1063 
1064  double upper = ( v[1]-v[0] )*1.1 + v[0];
1065  double lower = v[0] - ( v[1]-v[0] )*0.1;
1066 
1067  if ( m_logx ) {
1068  double dx = std::log10(v[1])-std::log10(v[0]);
1069  upper = std::pow(10,dx*1.1 + std::log10(v[0]));
1070  lower = std::pow(10,std::log10(v[0]) - dx*0.1);
1071  }
1072 
1073  if ( lower<vlo ) lower = vlo;
1074  if ( upper>vhi ) upper = vhi;
1075 
1076  v[0] = lower;
1077  v[1] = upper;
1078 
1079  return v;
1080  }
1081 
1082 
1083 
1084  void sortx( const AxisInfo& xinfo ) {
1085 
1086  if ( xinfo.rangeset() ) {
1087  m_lo = xinfo.lo();
1088  m_hi = xinfo.hi();
1089  }
1090 
1091  if ( xinfo.autoset() && size() > 0 ) {
1092  std::vector<double> limits = findxrange( xinfo.symmetric() );
1093  if ( xinfo.rangeset() ) {
1094  if ( limits[0]<m_lo ) m_lo = limits[0];
1095  if ( limits[1]>m_hi ) m_hi = limits[1];
1096  }
1097  else {
1098  m_lo = limits[0];
1099  m_hi = limits[1];
1100  }
1101  }
1102  else if (size() == 0)
1103  {
1104  std::cout<<"Warning in computils.h::sortx() size=0. Setting m_lo/m_hi to 0/1. You will probably have empty figures."<<std::endl;
1105  m_lo = 0;
1106  m_hi = 1;
1107  }
1108 
1109  if ( xinfo.rangeset() || xinfo.autoset() ) {
1110  SetRangeUser( m_lo, m_hi );
1111  if ( xinfo.log() && m_lo>0 ) SetLogx(true);
1112  else SetLogx(false);
1113  }
1114 
1115  }
1116 
1117 
1118  double lo() const { return m_lo; }
1119  double hi() const { return m_hi; }
1120 
1121 
1122  void xrange(bool symmetric=false) {
1123  m_rangeset = false;
1124  for ( unsigned i=0 ; i<size() ; i++ ) {
1125  if ( at(i).href() ) ::xrange( at(i).href(), symmetric );
1126  ::xrange( at(i).htest(), symmetric );
1127  }
1128  }
1129 
1130  void SetRangeUser( double lo, double hi ){
1131  m_rangeset = true;
1132  m_lo = lo;
1133  m_hi = hi;
1134  for ( unsigned i=0 ; i<size() ; i++ ) {
1135  if ( at(i).href() ) at(i).href()->GetXaxis()->SetRangeUser( m_lo, m_hi );
1136  at(i).htest()->GetXaxis()->SetRangeUser( m_lo, m_hi );
1137  }
1138  }
1139 
1140 
1141  void limits() {
1142  double rmax = realmax();
1143  double rmin = realmin();
1144  if ( rmin<0 ) {
1145  std::cout << "\tlimits \t" << m_name << "\tmin " << rmin << "\tmax " << rmax << std::endl;
1146  }
1147  }
1148 
1149 
1150 
1151  void Draw( Legend& leg, bool means=false ) {
1152  Draw_i( leg, means );
1153  if ( LINES ) {
1154  LINES=false;
1155  Draw_i( leg, means );
1156  LINES=true;
1157  }
1158  }
1159 
1160  void Draw_i( Legend& leg, bool means=false ) {
1161 
1162  bool first = true;
1163 
1164  if ( m_logy ) {
1165  for ( unsigned i=0 ; i<size() ; i++, first=false ) {
1166  double ymax = at(i).htest()->GetMaximum();
1167  double ymin = at(i).htest()->GetMinimum();
1168  at(i).htest()->GetYaxis()->SetMoreLogLabels(true);
1169  if ( ymax/ymin>1e6 ) at(i).htest()->GetYaxis()->SetMoreLogLabels(false);
1170  break;
1171  }
1172  }
1173 
1174  for ( unsigned i=0 ; i<size() ; i++ ) at(i).trim_errors( m_trim_errors );
1175 
1178 
1179  // for ( unsigned i=0 ; i<size() ; i++, first=false ) at(i).DrawLegend( i, leg, means, first, (i==size()-1) );
1180  // for ( unsigned i=0 ; i<size() ; i++, first=false ) at(i).Draw( i, &leg, means, first, (i==size()-1) );
1181  for ( unsigned i=size() ; i-- ; first=false ) at(i).Draw( i, &leg, means, first, i==0 );
1182 
1183  if ( s_watermark ) DrawLabel(0.1, 0.02, "built "+stime()+release, kBlack, 0.03 );
1184 
1185  gPad->SetLogy(m_logy);
1186  gPad->SetLogx(m_logx);
1187  }
1188 
1189  void SetLogx( bool b=true ) { m_logx=b; }
1190  void SetLogy( bool b=true ) { m_logy=b; }
1191 
1192  std::string GetXaxisTitle() {
1193  if ( size()>0 ) return at(0).htest()->GetXaxis()->GetTitle();
1194  return "";
1195  }
1196 
1197  std::string GetYaxisTitle() {
1198  if ( size()>0 ) return at(0).htest()->GetYaxis()->GetTitle();
1199  return "";
1200  }
1201 
1202  void SetXaxisTitle(const std::string& s) {
1203  if ( size()>0 ) at(0).htest()->GetXaxis()->SetTitle(s.c_str());
1204  }
1205 
1206  void SetYaxisTitle(const std::string& s) {
1207  if ( size()>0 ) at(0).htest()->GetYaxis()->SetTitle(s.c_str());
1208  }
1209 
1210 
1213  void push_back(const Plotter& val) {
1214  std::vector<Plotter>::push_back( val );
1215  }
1216 
1217 public:
1218 
1219  static void setwatermark(bool b) { s_watermark = b; }
1220 
1221 private:
1222 
1223  std::string m_name;
1224 
1226  bool m_logx;
1227  bool m_logy;
1228 
1230  bool m_maxset;
1231  double m_max;
1232 
1233  bool m_minset;
1234  double m_min;
1235 
1238  double m_lo;
1239  double m_hi;
1240 
1242 
1243 private:
1244 
1245  static bool s_watermark;
1246 
1247 };
1248 
1249 
1250 
1251 
1253 
1254 class HistDetails {
1255 
1256 public:
1257 
1258  HistDetails( const std::vector<std::string>& v ) : m_extra(""), m_xinfo(v[2]), m_yinfo(v[4]) {
1259  if ( v.size() < 6 ) throw std::exception();
1260  m_details.reserve(6);
1261  for ( size_t i=0 ; i<6 ; i++ ) m_details.push_back(v[i]);
1262  getextra();
1263  }
1264 
1265  HistDetails( const std::string* vp ) : m_extra(""), m_xinfo(vp[2]), m_yinfo(vp[4]) {
1266  m_details.reserve(6);
1267  for ( size_t i=0 ; i<6 ; i++ ) m_details.push_back(vp[i]);
1268  getextra();
1269  }
1270 
1271  std::string name() const { return m_details[0]; }
1272 
1273  std::string detail() const { return m_extra; }
1274 
1275  std::string info() const { return m_details[1]; }
1276 
1277  std::string xtitle() const { return m_details[3]; }
1278  std::string ytitle() const { return m_details[5]; }
1279 
1280  const AxisInfo& xaxis() const { return m_xinfo; }
1281  const AxisInfo& yaxis() const { return m_yinfo; }
1282 
1283 private:
1284 
1285  void getextra() {
1286  if ( contains( m_details[0], "-" ) ) {
1287  m_extra = m_details[0].substr( m_details[0].find('-'), m_details[0].size() );
1288  m_details[0] = m_details[0].substr( 0, m_details[0].find('-') );
1289  }
1290  if ( contains( m_details[0], "+" ) ) {
1291  m_extra = m_details[0].substr( m_details[0].find('+'), m_details[0].size() );
1292  m_details[0] = m_details[0].substr( 0, m_details[0].find('+') );
1293  }
1294  }
1295 
1296 private:
1297 
1298  std::vector<std::string> m_details;
1299 
1300  std::string m_extra;
1301 
1304 
1305 };
1306 
1307 
1308 
1309 inline std::ostream& operator<<( std::ostream& s, const HistDetails& h ) {
1310  return s << "[ " << h.name() << " \tx: \"" << h.xtitle() << "\" " << h.xaxis() << "\t\ty: \"" << h.ytitle() << "\" " << h.yaxis() << " ]";
1311 }
1312 
1313 
1314 
1315 // plot panel inforamtion
1316 
1317 class Panel {
1318 
1319 public:
1320 
1323  Panel( const std::string& s, int nc ) :
1324  m_name(s), m_nhist(-1), m_nrows(-1), m_ncols(nc) {
1325  m_hist.reserve( nc );
1326  }
1327 
1329  Panel( const std::string& s, int nr, int nc ) :
1330  m_name(s), m_nhist(nr*nc), m_nrows(nr), m_ncols(nc) {
1331  m_hist.reserve( m_nhist );
1332  }
1333 
1334  void push_back( const HistDetails& h ) {
1335  m_hist.push_back( h );
1336  m_nhist = m_hist.size();
1337  m_nrows = m_nhist/m_ncols + (m_nhist%m_ncols ? 1 : 0 );
1338  }
1339 
1340  std::string name() const { return m_name; }
1341 
1342  size_t size() const { return m_hist.size(); }
1343 
1344  const HistDetails& operator[](int i) const { return m_hist.at(i); }
1345  HistDetails& operator[](int i) { return m_hist.at(i); }
1346 
1347  const HistDetails& back() const { return m_hist.back(); }
1348  HistDetails& back() { return m_hist.back(); }
1349 
1350  int nrows() const { return m_nrows; }
1351  int ncols() const { return m_ncols; }
1352 
1353 private:
1354 
1355  std::string m_name;
1356 
1357  int m_nhist;
1358 
1359  int m_nrows;
1360  int m_ncols;
1361 
1362  std::vector<HistDetails> m_hist;
1363 
1364 };
1365 
1366 
1367 
1368 inline std::ostream& operator<<( std::ostream& s, const Panel& p ) {
1369  s << "Panel: " << p.name();
1370  if ( p.size() == 1 ) s << "\t" << p[0];
1371  else for ( size_t i=0 ; i<p.size() ; i++ ) s << "\n\t" << p[i];
1372  return s;
1373 }
1374 
1375 
1376 
1377 
1378 
1379 #endif // COMPUTILS_H
trim_tgraph
void trim_tgraph(TH1 *h, TGraphAsymmErrors *t)
Definition: computils.cxx:151
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
HistDetails::HistDetails
HistDetails(const std::string *vp)
Definition: computils.h:1265
tPlotter::href
T * href()
Definition: computils.h:846
mergePhysValFiles.pattern
pattern
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:26
HistDetails::getextra
void getextra()
Definition: computils.h:1285
Legend::m_x
double m_x[2]
Definition: computils.h:416
contents
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory="", const std::string &pattern="", const std::string &path="")
Definition: computils.cxx:319
Plots::m_rangeset
bool m_rangeset
xaxis range setting
Definition: computils.h:1237
AxisInfo::log
bool log() const
Definition: computils.h:246
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
Plots::Plots
Plots(const std::string &s="", bool errors=false)
Definition: computils.h:917
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
Panel::ncols
int ncols() const
Definition: computils.h:1351
Plotter
tPlotter< TH1F > Plotter
Definition: computils.h:882
ymin
double ymin
Definition: listroot.cxx:63
Panel::name
std::string name() const
Definition: computils.h:1340
tPlotter::m_entries
size_t m_entries
Definition: computils.h:875
color
Definition: jFexInputByteStreamTool.cxx:25
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
Legend::AddEntry
void AddEntry(TObject *tobj, const std::string &s, const std::string &type="p")
Definition: computils.h:374
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
max
#define max(a, b)
Definition: cfImp.cxx:41
tPlotter::trim_errors
bool trim_errors() const
Definition: computils.h:491
Panel::Panel
Panel(const std::string &s, int nc)
don't know how many rows or total hists yet, but do know number of columns
Definition: computils.h:1323
AxisInfo::m_autoset
bool m_autoset
Definition: computils.h:299
AxisInfo::m_tag
std::string m_tag
Definition: computils.h:296
copyReleaseInfo
void copyReleaseInfo(TFile *finput, TFile *foutdir)
copy the TTree of release info from one directory to another
Definition: computils.cxx:618
data_mismatch::what
virtual const char * what() const
Definition: computils.h:100
Entries
double Entries(TH1 *h)
Definition: computils.cxx:50
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
AxisInfo::c_str
std::string c_str() const
Definition: computils.h:269
AxisInfo::AxisInfo
AxisInfo(const std::string &s)
Definition: computils.h:151
Legend::Legend
Legend(const Legend &legend)
Definition: computils.h:354
Panel::push_back
void push_back(const HistDetails &h)
Definition: computils.h:1334
Legend::m_obj
std::vector< TObject * > m_obj
Definition: computils.h:419
tPlotter::tgref
TGraphAsymmErrors * tgref()
Definition: computils.h:850
HistDetails::detail
std::string detail() const
Definition: computils.h:1273
patterns
std::vector< std::string > patterns
Definition: listroot.cxx:187
tPlotter::htest
T * htest()
Definition: computils.h:845
Legend::size
size_t size() const
Definition: computils.h:362
AxisInfo::offset
double offset() const
Definition: computils.h:261
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
Legend::~Legend
~Legend()
Definition: computils.h:358
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
Plots::Draw
void Draw(Legend &leg, bool means=false)
Definition: computils.h:1151
AxisInfo::autoset
bool autoset() const
Definition: computils.h:248
integral
double integral(TH1 *h)
Definition: computils.cxx:57
TH1D
Definition: rootspy.cxx:342
contains
bool contains(const std::string &s, const std::string &p)
does a string contain the substring
Definition: hcg.cxx:111
tPlotter::m_htest
T * m_htest
actual histograms
Definition: computils.h:863
Plots::Draw_i
void Draw_i(Legend &leg, bool means=false)
Definition: computils.h:1160
chop
std::string chop(std::string &s1, const std::string &s2)
Definition: hcg.cxx:158
AxisInfo::refnormset
bool refnormset() const
Definition: computils.h:252
AxisInfo::m_info
std::string m_info
Definition: computils.h:294
AxisInfo::lo
double lo() const
Definition: computils.h:264
tPlotter::tgtest
TGraphAsymmErrors * tgtest()
Definition: computils.h:849
tPlotter::max_entries
void max_entries(int i)
Definition: computils.h:853
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
data_mismatch::data_mismatch
data_mismatch(const std::string &s)
Definition: computils.h:99
Panel::size
size_t size() const
Definition: computils.h:1342
data_mismatch
Definition: computils.h:97
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AxisInfo::m_norm
bool m_norm
Definition: computils.h:306
AxisInfo::m_trim
bool m_trim
Definition: computils.h:313
AxisInfo::m_lo
double m_lo
Definition: computils.h:303
Plots::m_max
double m_max
Definition: computils.h:1231
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
x
#define x
hminus
void hminus(TH1 *h)
Definition: computils.h:899
HistDetails::info
std::string info() const
Definition: computils.h:1275
HistDetails::yaxis
const AxisInfo & yaxis() const
Definition: computils.h:1281
Plots::limits
void limits()
Definition: computils.h:1141
Legend::width
double width() const
Definition: computils.h:372
Legend::m_type
std::vector< std::string > m_type
Definition: computils.h:421
Legend::legend
TLegend * legend()
Definition: computils.h:360
DrawLabel
int DrawLabel(float xstart, float ystart, string label)
Definition: GraphToolKit.h:13
tPlotter::Draw
void Draw(int i, Legend *lleg, bool mean=false, bool first=true, bool drawlegend=false)
Definition: computils.h:493
fcontains
bool fcontains(const std::string &s, const std::string &p)
does a string contain the substring at the beginning of the string
Definition: computils.cxx:232
xrange
void xrange(TH1 *h, bool symmetric=true)
Definition: computils.cxx:515
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AxisInfo::symmetric
bool symmetric() const
Definition: computils.h:254
Legend::TextSize
double TextSize() const
Definition: computils.h:366
tail
std::string tail(std::string s, const std::string &pattern)
tail of a string
Definition: computils.cxx:300
Plots::lo
double lo() const
Definition: computils.h:1118
Panel::operator[]
const HistDetails & operator[](int i) const
Definition: computils.h:1344
HistDetails::name
std::string name() const
Definition: computils.h:1271
Legend::Legend
Legend()
Definition: computils.h:337
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
Legend::height
double height() const
Definition: computils.h:370
Plots::push_back
void push_back(const Plotter &val)
this is so that we can update the stats as we go along, but no updating isn't done at the moment
Definition: computils.h:1213
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
Plots::SetRangeUser
void SetRangeUser(double lo, double hi)
Definition: computils.h:1130
Panel::m_nrows
int m_nrows
Definition: computils.h:1359
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
globbed
std::string globbed(const std::string &s)
match a file name
Definition: computils.cxx:262
utils.h
tPlotter::Print
void Print(const std::string &s="")
print the output
Definition: computils.h:840
ATLASFORAPP_LABEL
void ATLASFORAPP_LABEL(double x, double y, int color, double size=0.06)
Definition: computils.cxx:186
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
tPlotter::setplotref
static void setplotref(bool b)
Definition: computils.h:857
tPlotter::tPlotter
tPlotter(T *_htest=0, T *_href=0, const std::string &s="", TGraphAsymmErrors *_tgtest=0, TGraphAsymmErrors *_tgref=0)
Definition: computils.h:458
DeMoScan.directory
string directory
Definition: DeMoScan.py:80
HistDetails
details of the histogram axes etc
Definition: computils.h:1254
lumiFormat.i
int i
Definition: lumiFormat.py:92
Plots
set of generic plots
Definition: computils.h:913
HistDetails::m_xinfo
AxisInfo m_xinfo
Definition: computils.h:1302
setParameters
void setParameters(T *h, TGraphAsymmErrors *tg)
Definition: computils.h:432
HistDetails::m_yinfo
AxisInfo m_yinfo
Definition: computils.h:1303
AxisInfo::trim
bool trim() const
Definition: computils.h:258
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
true_mean::true_mean
true_mean(TH1F *h)
Definition: computils.cxx:80
Plots::Max
void Max(double scale)
Definition: computils.h:1011
Plots::findxrange
std::vector< double > findxrange(bool symmetric=false)
Definition: computils.h:1019
Panel
Definition: computils.h:1317
AxisInfo::rangeset
bool rangeset() const
Definition: computils.h:256
calibdata.exception
exception
Definition: calibdata.py:496
Plots::realmin
double realmin(double lo=0, double hi=0)
Definition: computils.h:927
AxisInfo::binwidth
double binwidth() const
Definition: computils.h:267
operator<<
std::ostream & operator<<(std::ostream &s, std::vector< T > &v)
Definition: computils.h:106
compute_lumi.leg
leg
Definition: compute_lumi.py:95
exists
bool exists(const std::string &filename)
does a file exist
Definition: computils.cxx:254
Panel::m_name
std::string m_name
Definition: computils.h:1355
beamspotPlotBcids.y0
y0
Definition: beamspotPlotBcids.py:515
myText
void myText(Double_t x, Double_t y, Color_t color, const std::string &text, Double_t tsize)
Definition: computils.cxx:203
AxisInfo::m_hi
double m_hi
Definition: computils.h:304
true_mean::mean
double mean() const
Definition: computils.h:133
findxrangeuser
std::vector< double > findxrangeuser(TH1 *h, bool symmetric=false)
Definition: computils.cxx:523
Plots::realmax
double realmax(double lo=0, double hi=0)
Definition: computils.h:938
Panel::nrows
int nrows() const
Definition: computils.h:1350
Plots::sortx
void sortx(const AxisInfo &xinfo)
Definition: computils.h:1084
calibdata.exit
exit
Definition: calibdata.py:236
Panel::m_nhist
int m_nhist
Definition: computils.h:1357
Legend::m_entries
std::vector< std::string > m_entries
Definition: computils.h:420
colours
int colours[6]
Definition: computils.cxx:44
Plots::SetXaxisTitle
void SetXaxisTitle(const std::string &s)
Definition: computils.h:1202
Plots::GetYaxisTitle
std::string GetYaxisTitle()
Definition: computils.h:1197
Plots::MaxScale
void MaxScale(double scale=1.1, double lo=0, double hi=0)
Definition: computils.h:952
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
min
#define min(a, b)
Definition: cfImp.cxx:40
Norm
void Norm(TH1 *h, double scale=1)
Definition: computils.cxx:65
Plots::m_maxset
bool m_maxset
yaxis range setting
Definition: computils.h:1230
mergePhysValFiles.errors
list errors
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:43
HistDetails::m_extra
std::string m_extra
Definition: computils.h:1300
AxisInfo::m_offset
double m_offset
Definition: computils.h:311
tPlotter::m_max_entries
size_t m_max_entries
Definition: computils.h:874
realmax
double realmax(TH1 *h, bool include_error=true, double lo=0, double hi=0)
Definition: computils.cxx:379
tPlotter::~tPlotter
~tPlotter()
sadly, root manages all the histograms (does it really? who can tell) so we mustn't delete anything j...
Definition: computils.h:485
tPlotter::DrawLegend
void DrawLegend(int i, Legend &leg, bool mean=false, bool first=true, bool drawlegend=false)
Definition: computils.h:670
Plots::setwatermark
static void setwatermark(bool b)
Definition: computils.h:1219
tPlotter
generic plotter class - better to have one of these - make sure it can be configured however you like...
Definition: computils.h:454
tPlotter::m_tgtest
TGraphAsymmErrors * m_tgtest
Definition: computils.h:866
Panel::back
HistDetails & back()
Definition: computils.h:1348
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
tPlotter::trim_errors
void trim_errors(bool b)
Definition: computils.h:489
true_mean::error
double error() const
Definition: computils.h:134
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
label.h
true_mean::m_mean
double m_mean
Definition: computils.h:138
Panel::Panel
Panel(const std::string &s, int nr, int nc)
know number of rows and columns
Definition: computils.h:1329
Legend::Draw
void Draw()
Definition: computils.h:380
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
HistDetails::xaxis
const AxisInfo & xaxis() const
Definition: computils.h:1280
tPlotter::m_tgref
TGraphAsymmErrors * m_tgref
Definition: computils.h:867
Legend::TextFont
int TextFont() const
Definition: computils.h:368
tPlotter::setmeanplotref
static void setmeanplotref(bool b)
Definition: computils.h:858
Plots::SetLogy
void SetLogy(bool b=true)
Definition: computils.h:1190
Panel::operator[]
HistDetails & operator[](int i)
Definition: computils.h:1345
tPlotter::m_plotfilename
std::string m_plotfilename
Definition: computils.h:869
true_mean::m_error
double m_error
Definition: computils.h:139
head
std::string head(std::string s, const std::string &pattern)
head of a string
Definition: computils.cxx:310
LINEF
bool LINEF
Definition: computils.cxx:38
true_mean
Definition: computils.h:127
Panel::m_hist
std::vector< HistDetails > m_hist
Definition: computils.h:1362
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
realmin
double realmin(TH1 *h, bool include_error=true, double lo=0, double hi=0)
Definition: computils.cxx:406
Legend::Legend
Legend(double x1, double x2, double y1, double y2)
Definition: computils.h:344
tPlotter::tPlotter
tPlotter(const tPlotter &p)
Definition: computils.h:469
ir
int ir
counter of the current depth
Definition: fastadd.cxx:49
python.PyAthena.v
v
Definition: PyAthena.py:157
AxisInfo::split
static std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition: computils.h:274
Plots::m_minset
bool m_minset
Definition: computils.h:1233
AxisInfo::hi
double hi() const
Definition: computils.h:265
Plots::m_logy
bool m_logy
Definition: computils.h:1227
Plots::m_hi
double m_hi
Definition: computils.h:1239
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
h
TH1F
Definition: rootspy.cxx:320
HistDetails::ytitle
std::string ytitle() const
Definition: computils.h:1278
AxisInfo::m_binwidth
bool m_binwidth
Definition: computils.h:309
Panel::back
const HistDetails & back() const
Definition: computils.h:1347
AxisInfo::m_rangeset
bool m_rangeset
Definition: computils.h:302
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Plots::m_min
double m_min
Definition: computils.h:1234
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TH1
Definition: rootspy.cxx:268
zeroErrors
void zeroErrors(T *h)
Definition: computils.h:443
Plots::GetXaxisTitle
std::string GetXaxisTitle()
Definition: computils.h:1192
DeMoScan.first
bool first
Definition: DeMoScan.py:534
Plots::Min
void Min(double scale)
Definition: computils.h:998
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
Plots::m_lo
double m_lo
Definition: computils.h:1238
HistDetails::xtitle
std::string xtitle() const
Definition: computils.h:1277
Legend::m_y
double m_y[2]
Definition: computils.h:417
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
LINES
bool LINES
Definition: computils.cxx:39
HistDetails::HistDetails
HistDetails(const std::vector< std::string > &v)
Definition: computils.h:1258
Panel::m_ncols
int m_ncols
Definition: computils.h:1360
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
Plots::xrange
void xrange(bool symmetric=false)
Definition: computils.h:1122
tPlotter::s_meanplotref
static bool s_meanplotref
Definition: computils.h:872
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
DrawLabel.h
findcell
std::string findcell(std::string name, const std::string &regex, const std::string &splitex="/")
Definition: computils.cxx:545
atlasStyleMacro.tsize
float tsize
Definition: atlasStyleMacro.py:37
Plots::m_logx
bool m_logx
canvas log setting
Definition: computils.h:1226
msizes
double msizes[6]
Definition: computils.cxx:46
Plots::SetYaxisTitle
void SetYaxisTitle(const std::string &s)
Definition: computils.h:1206
plotable
double plotable(TH1 *h)
Definition: computils.cxx:237
HistDetails::m_details
std::vector< std::string > m_details
Definition: computils.h:1298
tPlotter::s_plotref
static bool s_plotref
use non c++17 format for improved external compatability
Definition: computils.h:871
Plots::MinScale
void MinScale(double scale, double lo=0, double hi=0)
Definition: computils.h:971
AxisInfo::m_log
bool m_log
Definition: computils.h:298
Legend::m_leg
TLegend * m_leg
Definition: computils.h:414
tPlotter::plotfilename
std::string plotfilename() const
Definition: computils.h:487
AxisInfo
class to store information about axes, limits, whether it is log or linear scale etc
Definition: computils.h:147
Plots::s_watermark
static bool s_watermark
Definition: computils.h:1245
Plots::hi
double hi() const
Definition: computils.h:1119
stime
std::string stime()
return the current data and time
Definition: computils.cxx:213
plotBeamSpotMon.nc
int nc
Definition: plotBeamSpotMon.py:83
markers
int markers[6]
Definition: computils.cxx:45
AxisInfo::m_symmetric
bool m_symmetric
Definition: computils.h:300
AxisInfo::tag
std::string tag() const
accessors
Definition: computils.h:244
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
Plots::SetLogx
void SetLogx(bool b=true)
Definition: computils.h:1189
findrun
std::string findrun(TFile *f)
Definition: computils.cxx:573
AxisInfo::normset
bool normset() const
Definition: computils.h:250
Legend
slightly more convenient legend class
Definition: computils.h:333
ymax
double ymax
Definition: listroot.cxx:64
Plots::m_name
std::string m_name
Definition: computils.h:1223
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
findxrange
std::vector< int > findxrange(TH1 *h, bool symmetric=false)
automatically set the xrange on a histogram
Definition: computils.cxx:446
tPlotter::m_trim_errors
bool m_trim_errors
Definition: computils.h:877
Plots::m_trim_errors
bool m_trim_errors
Definition: computils.h:1241
AxisInfo::m_refnorm
bool m_refnorm
Definition: computils.h:307
tPlotter::m_href
T * m_href
Definition: computils.h:864