ATLAS Offline Software
Loading...
Searching...
No Matches
computils.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
10
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
39extern bool LINEF;
40extern bool LINES;
41
42
43void ATLASFORAPP_LABEL( double x, double y, int color, double size=0.06 );
44
45void myText( Double_t x, Double_t y, Color_t color, const std::string& text, Double_t tsize);
46
47
49std::string stime();
50static std::string release;
51
52double integral( TH1* h );
53
54void Norm( TH1* h, double scale=1 );
55
56double Entries( TH1* h );
57
59bool contains( const std::string& s, const std::string& p);
60bool contains( const std::string& s, char p) noexcept;
61
63bool fcontains( const std::string& s, const std::string& p);
64
66bool exists( const std::string& filename );
67
69std::string tail( std::string s, const std::string& pattern );
70
72std::string head( std::string s, const std::string& pattern );
73
75std::string globbed( const std::string& s );
76
77void 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
83void 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
90double realmax( TH1* h, bool include_error=true, double lo=0, double hi=0 );
91double realmin( TH1* h, bool include_error=true, double lo=0, double hi=0 );
92
93std::string findcell( std::string name, const std::string& regex, const std::string& splitex="/" );
94
95std::string findrun( TFile *f );
96
97double plotable( TH1* h ); // , double xlo=-999, double xhi=-999 );
98
99
100class data_mismatch : public std::exception {
101public:
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
108template<typename T>
109std::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
116std::vector<int> findxrange(TH1* h, bool symmetric=false );
117std::vector<double> findxrangeuser(TH1* h, bool symmetric=false );
118
119
120
121void trim_tgraph( TH1* h, TGraphAsymmErrors* t );
122
123
124void xrange(TH1* h, bool symmetric=true );
125
127void copyReleaseInfo( TFile* finput, TFile* foutdir );
128
129
130class true_mean {
131
132public:
133
134 true_mean( TH1F* h );
135
136 double mean() const { return m_mean; }
137 double error() const { return m_error; }
138
139private:
140
141 double m_mean;
142 double m_error;
143
144};
145
146
149
150class AxisInfo {
151
152public:
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
276public:
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(std::move(sc));
291
292 return tags;
293 }
294
295
296public:
297
298 std::string m_info;
299
300 std::string m_tag;
301
302 bool m_log;
305
307 double m_lo;
308 double m_hi;
309
310 bool m_norm;
312
314
315 double m_offset;
316
317 bool m_trim;
318
319};
320
321
322inline 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
337class Legend {
338
339public:
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
416private:
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
430extern int colours[6]; // = { 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 };
431extern int markers[6]; // = { 20, 24, 25, 26, 25, 22 };
432extern double msizes[6]; // = { 1, 1, 1, 1, 1, 1 };
433
434
435template<typename T>
436void 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
446template<typename T>
447void zeroErrors( T* h ) {
448 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) h->SetBinError( i, 1e-100 );
449}
450
451
452
457template<typename T>
458class tPlotter {
459
460public:
461
462 tPlotter(T* htest=0, T* href=0, const std::string& s="", TGraphAsymmErrors* tgtest=0, TGraphAsymmErrors* tgref=0 ) :
466 m_max_entries(4),
467 m_entries(0),
468 m_trim_errors(false)
469 {
470 }
471
472
481
482
483
486 // ~tPlotter() { if ( m_tg ) delete m_tg; }
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
565 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 = std::move(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
739 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
859public:
860
861 static void setplotref( bool b ) { s_plotref=s_meanplotref=b; }
862 static void setmeanplotref( bool b ) { s_meanplotref=b; }
863
864private:
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
890template<typename T>
892
893
894template<typename T>
896
897
898
899bool empty( TH1* h );
900
901
902
903inline 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
917class Plots : public std::vector<Plotter> {
918
919public:
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),
928 m_trim_errors(errors)
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 //coverity[dead_error_condition]
1056 if ( first ) {
1057 //coverity[dead_error_begin]
1058 v[0] = lo;
1059 v[1] = hi;
1060 }
1061 else {
1062 if ( v[0]>lo ) v[0] = lo;
1063 if ( v[1]<hi ) v[1] = hi;
1064 }
1065
1066 first = false;
1067 }
1068
1069 double upper = ( v[1]-v[0] )*1.1 + v[0];
1070 double lower = v[0] - ( v[1]-v[0] )*0.1;
1071
1072 if ( m_logx ) {
1073 double dx = std::log10(v[1])-std::log10(v[0]);
1074 upper = std::pow(10,dx*1.1 + std::log10(v[0]));
1075 lower = std::pow(10,std::log10(v[0]) - dx*0.1);
1076 }
1077
1078 if ( lower<vlo ) lower = vlo;
1079 if ( upper>vhi ) upper = vhi;
1080
1081 v[0] = lower;
1082 v[1] = upper;
1083
1084 return v;
1085 }
1086
1087
1088
1089 void sortx( const AxisInfo& xinfo ) {
1090
1091 if ( xinfo.rangeset() ) {
1092 m_lo = xinfo.lo();
1093 m_hi = xinfo.hi();
1094 }
1095
1096 if ( xinfo.autoset() && size() > 0 ) {
1097 std::vector<double> limits = findxrange( xinfo.symmetric() );
1098 if ( xinfo.rangeset() ) {
1099 if ( limits[0]<m_lo ) m_lo = limits[0];
1100 if ( limits[1]>m_hi ) m_hi = limits[1];
1101 }
1102 else {
1103 m_lo = limits[0];
1104 m_hi = limits[1];
1105 }
1106 }
1107 else if (size() == 0)
1108 {
1109 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;
1110 m_lo = 0;
1111 m_hi = 1;
1112 }
1113
1114 if ( xinfo.rangeset() || xinfo.autoset() ) {
1116 if ( xinfo.log() && m_lo>0 ) SetLogx(true);
1117 else SetLogx(false);
1118 }
1119
1120 }
1121
1122
1123 double lo() const { return m_lo; }
1124 double hi() const { return m_hi; }
1125
1126
1127 void xrange(bool symmetric=false) {
1128 m_rangeset = false;
1129 for ( unsigned i=0 ; i<size() ; i++ ) {
1130 if ( at(i).href() ) ::xrange( at(i).href(), symmetric );
1131 ::xrange( at(i).htest(), symmetric );
1132 }
1133 }
1134
1135 void SetRangeUser( double lo, double hi ){
1136 m_rangeset = true;
1137 m_lo = lo;
1138 m_hi = hi;
1139 for ( unsigned i=0 ; i<size() ; i++ ) {
1140 if ( at(i).href() ) at(i).href()->GetXaxis()->SetRangeUser( m_lo, m_hi );
1141 at(i).htest()->GetXaxis()->SetRangeUser( m_lo, m_hi );
1142 }
1143 }
1144
1145
1146 void limits() {
1147 double rmax = realmax();
1148 double rmin = realmin();
1149 if ( rmin<0 ) {
1150 std::cout << "\tlimits \t" << m_name << "\tmin " << rmin << "\tmax " << rmax << std::endl;
1151 }
1152 }
1153
1154
1155
1156 void Draw( Legend& leg, bool means=false ) {
1157 Draw_i( leg, means );
1158 if ( LINES ) {
1159 LINES=false;
1160 Draw_i( leg, means );
1161 LINES=true;
1162 }
1163 }
1164
1165 void Draw_i( Legend& leg, bool means=false ) {
1166
1167 bool first = true;
1168
1169 if ( m_logy ) {
1170 for ( unsigned i=0 ; i<size() ; i++, first=false ) {
1171 double ymax = at(i).htest()->GetMaximum();
1172 double ymin = at(i).htest()->GetMinimum();
1173 at(i).htest()->GetYaxis()->SetMoreLogLabels(true);
1174 if ( ymax/ymin>1e6 ) at(i).htest()->GetYaxis()->SetMoreLogLabels(false);
1175 break;
1176 }
1177 }
1178
1179 for ( unsigned i=0 ; i<size() ; i++ ) at(i).trim_errors( m_trim_errors );
1180
1183
1184 // for ( unsigned i=0 ; i<size() ; i++, first=false ) at(i).DrawLegend( i, leg, means, first, (i==size()-1) );
1185 // for ( unsigned i=0 ; i<size() ; i++, first=false ) at(i).Draw( i, &leg, means, first, (i==size()-1) );
1186 for ( unsigned i=size() ; i-- ; first=false ) at(i).Draw( i, &leg, means, first, i==0 );
1187
1188 if ( s_watermark ) DrawLabel(0.1, 0.02, "built "+stime()+release, kBlack, 0.03 );
1189
1190 gPad->SetLogy(m_logy);
1191 gPad->SetLogx(m_logx);
1192 }
1193
1194 void SetLogx( bool b=true ) { m_logx=b; }
1195 void SetLogy( bool b=true ) { m_logy=b; }
1196
1197 std::string GetXaxisTitle() {
1198 if ( size()>0 ) return at(0).htest()->GetXaxis()->GetTitle();
1199 return "";
1200 }
1201
1202 std::string GetYaxisTitle() {
1203 if ( size()>0 ) return at(0).htest()->GetYaxis()->GetTitle();
1204 return "";
1205 }
1206
1207 void SetXaxisTitle(const std::string& s) {
1208 if ( size()>0 ) at(0).htest()->GetXaxis()->SetTitle(s.c_str());
1209 }
1210
1211 void SetYaxisTitle(const std::string& s) {
1212 if ( size()>0 ) at(0).htest()->GetYaxis()->SetTitle(s.c_str());
1213 }
1214
1215
1218 void push_back(const Plotter& val) {
1219 std::vector<Plotter>::push_back( val );
1220 }
1221
1222public:
1223
1224 static void setwatermark(bool b) { s_watermark = b; }
1225
1226private:
1227
1228 std::string m_name;
1229
1233
1236 double m_max;
1237
1239 double m_min;
1240
1243 double m_lo;
1244 double m_hi;
1245
1247
1248private:
1249
1250 static bool s_watermark;
1251
1252};
1253
1254
1255
1256
1258
1260
1261public:
1262
1263 HistDetails( const std::vector<std::string>& v ) : m_extra(""), m_xinfo(v[2]), m_yinfo(v[4]) {
1264 if ( v.size() < 6 ) throw std::exception();
1265 m_details.reserve(6);
1266 for ( size_t i=0 ; i<6 ; i++ ) m_details.push_back(v[i]);
1267 getextra();
1268 }
1269
1270 HistDetails( const std::string* vp ) : m_extra(""), m_xinfo(vp[2]), m_yinfo(vp[4]) {
1271 m_details.reserve(6);
1272 for ( size_t i=0 ; i<6 ; i++ ) m_details.push_back(vp[i]);
1273 getextra();
1274 }
1275
1276 std::string name() const { return m_details[0]; }
1277
1278 const std::string& detail() const { return m_extra; }
1279
1280 std::string info() const { return m_details[1]; }
1281
1282 std::string xtitle() const { return m_details[3]; }
1283 std::string ytitle() const { return m_details[5]; }
1284
1285 const AxisInfo& xaxis() const { return m_xinfo; }
1286 const AxisInfo& yaxis() const { return m_yinfo; }
1287
1288private:
1289
1290 void getextra() {
1291 if ( contains( m_details[0], "-" ) ) {
1292 m_extra = m_details[0].substr( m_details[0].find('-'), m_details[0].size() );
1293 m_details[0] = m_details[0].substr( 0, m_details[0].find('-') );
1294 }
1295 if ( contains( m_details[0], "+" ) ) {
1296 m_extra = m_details[0].substr( m_details[0].find('+'), m_details[0].size() );
1297 m_details[0] = m_details[0].substr( 0, m_details[0].find('+') );
1298 }
1299 }
1300
1301private:
1302
1303 std::vector<std::string> m_details;
1304
1305 std::string m_extra;
1306
1309
1310};
1311
1312
1313
1314inline std::ostream& operator<<( std::ostream& s, const HistDetails& h ) {
1315 return s << "[ " << h.name() << " \tx: \"" << h.xtitle() << "\" " << h.xaxis() << "\t\ty: \"" << h.ytitle() << "\" " << h.yaxis() << " ]";
1316}
1317
1318
1319
1320// plot panel inforamtion
1321
1322class Panel {
1323
1324public:
1325
1328 Panel( const std::string& s, int nc ) :
1329 m_name(s), m_nhist(-1), m_nrows(-1), m_ncols(nc) {
1330 m_hist.reserve( nc );
1331 }
1332
1334 Panel( const std::string& s, int nr, int nc ) :
1335 m_name(s), m_nhist(nr*nc), m_nrows(nr), m_ncols(nc) {
1336 m_hist.reserve( m_nhist );
1337 }
1338
1339 void push_back( const HistDetails& h ) {
1340 m_hist.push_back( h );
1341 m_nhist = m_hist.size();
1342 m_nrows = m_nhist/m_ncols + (m_nhist%m_ncols ? 1 : 0 );
1343 }
1344
1345 const std::string& name() const { return m_name; }
1346
1347 size_t size() const { return m_hist.size(); }
1348
1349 const HistDetails& operator[](int i) const { return m_hist.at(i); }
1350 HistDetails& operator[](int i) { return m_hist.at(i); }
1351
1352 const HistDetails& back() const { return m_hist.back(); }
1353 HistDetails& back() { return m_hist.back(); }
1354
1355 int nrows() const { return m_nrows; }
1356 int ncols() const { return m_ncols; }
1357
1358private:
1359
1360 std::string m_name;
1361
1363
1366
1367 std::vector<HistDetails> m_hist;
1368
1369};
1370
1371
1372
1373inline std::ostream& operator<<( std::ostream& s, const Panel& p ) {
1374 s << "Panel: " << p.name();
1375 if ( p.size() == 1 ) s << "\t" << p[0];
1376 else for ( size_t i=0 ; i<p.size() ; i++ ) s << "\n\t" << p[i];
1377 return s;
1378}
1379
1380
1381
1382
1383
1384#endif // COMPUTILS_H
int DrawLabel(float xstart, float ystart, string label)
int upper(int c)
static Double_t a
static Double_t sc
#define y
#define x
static const Attributes_t empty
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
Header file for AthHistogramAlgorithm.
class to store information about axes, limits, whether it is log or linear scale etc
Definition computils.h:150
bool m_binwidth
Definition computils.h:313
bool autoset() const
Definition computils.h:252
bool m_autoset
Definition computils.h:303
double m_lo
Definition computils.h:307
bool symmetric() const
Definition computils.h:258
double binwidth() const
Definition computils.h:271
bool rangeset() const
Definition computils.h:260
bool refnormset() const
Definition computils.h:256
bool trim() const
Definition computils.h:262
bool m_norm
Definition computils.h:310
double hi() const
Definition computils.h:269
bool log() const
Definition computils.h:250
AxisInfo(const std::string &s)
Definition computils.h:154
double m_offset
Definition computils.h:315
bool m_log
Definition computils.h:302
static std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition computils.h:278
bool m_symmetric
Definition computils.h:304
double offset() const
Definition computils.h:265
bool m_rangeset
Definition computils.h:306
double m_hi
Definition computils.h:308
const std::string & c_str() const
Definition computils.h:273
std::string m_info
Definition computils.h:298
const std::string & tag() const
accessors
Definition computils.h:248
bool normset() const
Definition computils.h:254
bool m_trim
Definition computils.h:317
double lo() const
Definition computils.h:268
std::string m_tag
Definition computils.h:300
bool m_refnorm
Definition computils.h:311
details of the histogram axes etc
Definition computils.h:1259
AxisInfo m_xinfo
Definition computils.h:1307
const AxisInfo & xaxis() const
Definition computils.h:1285
std::string ytitle() const
Definition computils.h:1283
std::vector< std::string > m_details
Definition computils.h:1303
std::string m_extra
Definition computils.h:1305
std::string xtitle() const
Definition computils.h:1282
HistDetails(const std::vector< std::string > &v)
Definition computils.h:1263
void getextra()
Definition computils.h:1290
const std::string & detail() const
Definition computils.h:1278
HistDetails(const std::string *vp)
Definition computils.h:1270
AxisInfo m_yinfo
Definition computils.h:1308
const AxisInfo & yaxis() const
Definition computils.h:1286
std::string info() const
Definition computils.h:1280
std::string name() const
Definition computils.h:1276
slightly more convenient legend class
Definition computils.h:337
std::vector< TObject * > m_obj
Definition computils.h:423
~Legend()
Definition computils.h:362
void Draw()
Definition computils.h:384
TLegend * m_leg
Definition computils.h:418
std::vector< std::string > m_entries
Definition computils.h:424
int TextFont() const
Definition computils.h:372
Legend(double x1, double x2, double y1, double y2)
Definition computils.h:348
double m_y[2]
Definition computils.h:421
double width() const
Definition computils.h:376
double TextSize() const
Definition computils.h:370
void AddEntry(TObject *tobj, const std::string &s, const std::string &type="p")
Definition computils.h:378
double height() const
Definition computils.h:374
size_t size() const
Definition computils.h:366
double m_x[2]
Definition computils.h:420
TLegend * legend()
Definition computils.h:364
Legend(const Legend &legend)
Definition computils.h:358
std::vector< std::string > m_type
Definition computils.h:425
void push_back(const HistDetails &h)
Definition computils.h:1339
HistDetails & back()
Definition computils.h:1353
int ncols() const
Definition computils.h:1356
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:1328
int m_nrows
Definition computils.h:1364
std::vector< HistDetails > m_hist
Definition computils.h:1367
size_t size() const
Definition computils.h:1347
const std::string & name() const
Definition computils.h:1345
HistDetails & operator[](int i)
Definition computils.h:1350
std::string m_name
Definition computils.h:1360
const HistDetails & operator[](int i) const
Definition computils.h:1349
int m_ncols
Definition computils.h:1365
Panel(const std::string &s, int nr, int nc)
know number of rows and columns
Definition computils.h:1334
int m_nhist
Definition computils.h:1362
const HistDetails & back() const
Definition computils.h:1352
int nrows() const
Definition computils.h:1355
void sortx(const AxisInfo &xinfo)
Definition computils.h:1089
double hi() const
Definition computils.h:1124
static bool s_watermark
Definition computils.h:1250
double m_hi
Definition computils.h:1244
void xrange(bool symmetric=false)
Definition computils.h:1127
double realmax(double lo=0, double hi=0)
Definition computils.h:942
double m_lo
Definition computils.h:1243
void Max(double scale)
Definition computils.h:1015
double m_min
Definition computils.h:1239
void Draw_i(Legend &leg, bool means=false)
Definition computils.h:1165
void SetXaxisTitle(const std::string &s)
Definition computils.h:1207
void limits()
Definition computils.h:1146
void MaxScale(double scale=1.1, double lo=0, double hi=0)
Definition computils.h:956
std::vector< double > findxrange(bool symmetric=false)
Definition computils.h:1023
double lo() const
Definition computils.h:1123
bool m_maxset
yaxis range setting
Definition computils.h:1235
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:1218
bool m_trim_errors
Definition computils.h:1246
void Min(double scale)
Definition computils.h:1002
Plots(const std::string &s="", bool errors=false)
Definition computils.h:921
double realmin(double lo=0, double hi=0)
Definition computils.h:931
void Draw(Legend &leg, bool means=false)
Definition computils.h:1156
std::string GetYaxisTitle()
Definition computils.h:1202
bool m_logy
Definition computils.h:1232
bool m_logx
canvas log setting
Definition computils.h:1231
void MinScale(double scale, double lo=0, double hi=0)
Definition computils.h:975
bool m_rangeset
xaxis range setting
Definition computils.h:1242
double m_max
Definition computils.h:1236
void SetLogy(bool b=true)
Definition computils.h:1195
void SetLogx(bool b=true)
Definition computils.h:1194
void SetYaxisTitle(const std::string &s)
Definition computils.h:1211
std::string m_name
Definition computils.h:1228
bool m_minset
Definition computils.h:1238
std::string GetXaxisTitle()
Definition computils.h:1197
void SetRangeUser(double lo, double hi)
Definition computils.h:1135
static void setwatermark(bool b)
Definition computils.h:1224
virtual const char * what() const
Definition computils.h:103
data_mismatch(const std::string &s)
Definition computils.h:102
generic plotter class - better to have one of these - make sure it can be configured however you like...
Definition computils.h:458
tPlotter(T *htest=0, T *href=0, const std::string &s="", TGraphAsymmErrors *tgtest=0, TGraphAsymmErrors *tgref=0)
Definition computils.h:462
~tPlotter()
sadly, root manages all the histograms (does it really?
Definition computils.h:489
const std::string & plotfilename() const
Definition computils.h:491
bool trim_errors() const
Definition computils.h:495
void Draw(int i, Legend *lleg, bool mean=false, bool first=true, bool drawlegend=false)
Definition computils.h:497
tPlotter(const tPlotter &p)
Definition computils.h:473
void DrawLegend(int i, Legend &leg, bool mean=false, bool first=true, bool drawlegend=false)
Definition computils.h:674
TGraphAsymmErrors * tgref()
Definition computils.h:854
void max_entries(int i)
Definition computils.h:857
std::string m_plotfilename
Definition computils.h:873
static bool s_meanplotref
Definition computils.h:876
void Print(const std::string &s="")
print the output
Definition computils.h:844
size_t m_max_entries
Definition computils.h:878
TGraphAsymmErrors * m_tgtest
Definition computils.h:870
static void setplotref(bool b)
Definition computils.h:861
static void setmeanplotref(bool b)
Definition computils.h:862
static bool s_plotref
Definition computils.h:875
TGraphAsymmErrors * tgtest()
Definition computils.h:853
void trim_errors(bool b)
Definition computils.h:493
TGraphAsymmErrors * m_tgref
Definition computils.h:871
true_mean(TH1F *h)
Definition computils.cxx:82
double error() const
Definition computils.h:137
double m_mean
Definition computils.h:141
double m_error
Definition computils.h:142
double mean() const
Definition computils.h:136
bool LINES
Definition computils.cxx:41
int markers[6]
Definition computils.cxx:47
bool LINEF
Definition computils.cxx:40
int colours[6]
Definition computils.cxx:46
double msizes[6]
Definition computils.cxx:48
double plotable(TH1 *h)
void zeroErrors(T *h)
Definition computils.h:447
void xrange(TH1 *h, bool symmetric=true)
std::ostream & operator<<(std::ostream &s, std::vector< T > &v)
Definition computils.h:109
bool contains(const std::string &s, const std::string &p)
does a string contain the substring
Definition hcg.cxx:114
double realmin(TH1 *h, bool include_error=true, double lo=0, double hi=0)
void Norm(TH1 *h, double scale=1)
Definition computils.cxx:67
void copyReleaseInfo(TFile *finput, TFile *foutdir)
copy the TTree of release info from one directory to another
bool LINES
Definition computils.cxx:41
std::string stime()
return the current data and time
bool empty(TH1 *h)
std::string globbed(const std::string &s)
match a file name
double Entries(TH1 *h)
Definition computils.cxx:52
std::string findcell(std::string name, const std::string &regex, const std::string &splitex="/")
std::string findrun(TFile *f)
void ATLASFORAPP_LABEL(double x, double y, int color, double size=0.06)
bool exists(const std::string &filename)
does a file exist
std::string tail(std::string s, const std::string &pattern)
tail of a string
tPlotter< TH1F > Plotter
Definition computils.h:886
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory="", const std::string &pattern="", const std::string &path="")
static std::string release
Definition computils.h:50
std::vector< int > findxrange(TH1 *h, bool symmetric=false)
automatically set the xrange on a histogram
double integral(TH1 *h)
Definition computils.cxx:59
double realmax(TH1 *h, bool include_error=true, double lo=0, double hi=0)
void trim_tgraph(TH1 *h, TGraphAsymmErrors *t)
void hminus(TH1 *h)
Definition computils.h:903
void setParameters(T *h, TGraphAsymmErrors *tg)
Definition computils.h:436
void myText(Double_t x, Double_t y, Color_t color, const std::string &text, Double_t tsize)
std::string head(std::string s, const std::string &pattern)
head of a string
bool fcontains(const std::string &s, const std::string &p)
does a string contain the substring at the beginning of the string
std::vector< double > findxrangeuser(TH1 *h, bool symmetric=false)
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="")
int ir
counter of the current depth
Definition fastadd.cxx:49
std::vector< std::string > tags
Definition hcg.cxx:105
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
std::string chop(std::string &s1, const std::string &s2)
Definition hcg.cxx:161
double ymin
Definition listroot.cxx:63
std::vector< std::string > patterns
Definition listroot.cxx:187
double ymax
Definition listroot.cxx:64