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