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