ATLAS Offline Software
Loading...
Searching...
No Matches
computils.h File Reference
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <exception>
#include "label.h"
#include "utils.h"
#include "DrawLabel.h"
#include "TStyle.h"
#include "TPad.h"
#include "TH1D.h"
#include "TFile.h"
#include "TH1.h"
#include "TF1.h"
#include "TGraphAsymmErrors.h"
#include "TLegend.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  data_mismatch
class  true_mean
class  AxisInfo
 class to store information about axes, limits, whether it is log or linear scale etc More...
class  Legend
 slightly more convenient legend class More...
class  tPlotter< T >
 generic plotter class - better to have one of these - make sure it can be configured however you like, line styles, marker types, legends etc now a template so can be used for TH1D and TH2D etc More...
class  Plots
 set of generic plots More...
class  HistDetails
 details of the histogram axes etc More...
class  Panel

Typedefs

typedef tPlotter< TH1F > Plotter

Functions

void band_plot (TH1 *h, double xlo, double xhi, double ylo=-999, double yhi=-999)
void ATLASFORAPP_LABEL (double x, double y, int color, double size=0.06)
void myText (Double_t x, Double_t y, Color_t color, const std::string &text, Double_t tsize)
std::string stime ()
 return the current data and time
double integral (TH1 *h)
void Norm (TH1 *h, double scale=1, double xmin=0, double xmax=0)
double Entries (TH1 *h)
bool contains (const std::string &s, const std::string &p)
 does a string contain the substring
bool contains (const std::string &s, char p) noexcept
bool fcontains (const std::string &s, const std::string &p)
 does a string contain the substring at the beginning of the string
bool exists (const std::string &filename)
 does a file exist
std::string tail (std::string s, const std::string &pattern)
 tail of a string
std::string head (std::string s, const std::string &pattern)
 head of a string
std::string globbed (const std::string &s)
 match a file name
void contents (std::vector< std::string > &keys, TDirectory *td, const std::string &directory="", const std::string &pattern="", const std::string &path="")
void contents (std::vector< std::string > &keys, TDirectory *td, const std::string &directory="", const std::vector< std::string > &patterns=std::vector< std::string >(), const std::string &path="")
double realmax (TH1 *h, bool include_error=true, double lo=0, double hi=0)
double realmin (TH1 *h, bool include_error=true, double lo=0, double hi=0)
std::string findcell (std::string name, const std::string &regex, const std::string &splitex="/")
std::string findrun (TFile *f)
double plotable (TH1 *h)
template<typename T>
std::ostream & operator<< (std::ostream &s, std::vector< T > &v)
std::vector< int > findxrange (TH1 *h, bool symmetric=false)
 automatically set the xrange on a histogram
std::vector< double > findxrangeuser (TH1 *h, bool symmetric=false)
void trim_tgraph (TH1 *h, TGraphAsymmErrors *t)
void xrange (TH1 *h, bool symmetric=true)
void copyReleaseInfo (TFile *finput, TFile *foutdir)
 copy the TTree of release info from one directory to another
std::ostream & operator<< (std::ostream &s, const AxisInfo &a)
template<typename T>
void setParameters (T *h, TGraphAsymmErrors *tg)
template<typename T>
void zeroErrors (T *)
bool empty (TH1 *h)
void hminus (TH1 *h)
std::ostream & operator<< (std::ostream &s, const HistDetails &h)
std::ostream & operator<< (std::ostream &s, const Panel &p)

Variables

bool JLflag
bool LINEF
bool LINES
static std::string release
int colours [6]
int markers [6]
double msizes [6]
template<typename T>
bool tPlotter< T >::s_plotref = true
 use non c++17 format for improved external compatability
template<typename T>
bool tPlotter< T >::s_meanplotref = true

Detailed Description

Author
mark sutton
Date
Sat Aug 30 2014 14:38:03 CEST

Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration

Definition in file computils.h.

Typedef Documentation

◆ Plotter

typedef tPlotter<TH1F> Plotter

Definition at line 1173 of file computils.h.

Function Documentation

◆ ATLASFORAPP_LABEL()

void ATLASFORAPP_LABEL ( double x,
double y,
int color,
double size = 0.06 )

Definition at line 348 of file computils.cxx.

349{
350 TLatex* lat = new TLatex(); //lat.SetTextAlign(12); lat.SetTextSize(tsize);
351 lat->SetNDC();
352 lat->SetTextFont(72);
353 lat->SetTextColor(color);
354 lat->SetTextSize(size);
355 lat->DrawLatex(x,y,"ATLAS");
356
357 TLatex* lat2 = new TLatex(); //lat.SetTextAlign(12); lat.SetTextSize(tsize);
358 lat2->SetNDC();
359 lat2->SetTextFont(52);
360 lat2->SetTextColor(color);
361 lat2->SetTextSize(size); // this 0.13 should really be calculated as a ratio of the width of the canvas
362 lat2->DrawLatex(x+0.13,y,"For Approval");
363}
size_t size() const
Number of registered mappings.
#define y
#define x

◆ band_plot()

void band_plot ( TH1 * h,
double xlo,
double xhi,
double ylo = -999,
double yhi = -999 )

Definition at line 115 of file computils.cxx.

115 {
116
117 // bool first = true;
118 bool last = true;
119
120 int ifirst = -1;
121 // int ilast = -1;
122
123 for ( int i=h->GetNbinsX()+1 ; i-- ; ) {
124 double yt = h->GetBinContent(i);
125 if ( last && ( yt<ylo || ( yt==0 && ylo==0 ) ) ) continue;
126 // ilast = i+1;
127 last = false;
128 break;
129 }
130
131 if ( JLflag ) {
132 // if ( contains( std::string(h->GetName()), "vs_mu") ) ilast = h->FindBin(80);
133 if ( contains( std::string(h->GetName()), "vs_mu") ) h->GetXaxis()->SetRangeUser( 18, 58 );
134 if ( contains( std::string(h->GetName()), "a0_eff") ) h->GetXaxis()->SetRangeUser( -190, 200 );
135 // if ( contains( std::string(h->GetName()), "a0") ) h->GetXaxis()->SetRangeUser( -200, 200 );
136 }
137
138 for ( int i=1 ; i<=h->GetNbinsX()+1 ; i++ ) {
139
140 double x0 = h->GetBinCenter(i);
141 double x1 = h->GetBinCenter(i+1);
142
143 if ( JLflag ) {
144 if ( contains( std::string(h->GetName()), "vs_mu") && x0<18 ) continue;
145 if ( contains( std::string(h->GetName()), "vs_mu") && x1>58 ) continue;
146
147 if ( contains( std::string(h->GetName()), "a0_eff") && x0<-200 ) continue;
148 if ( contains( std::string(h->GetName()), "a0_eff") && x1> 200 ) continue;
149 }
150
151 // if ( first && ( _y<ylo || ( _y==0 && ylo==0 ) ) ) continue;
152
153 if ( ifirst<0 ) ifirst = i;
154
155 // if ( ilast>0 && (i+1)>ilast ) continue;
156
157 // first = false;
158
159 double x0_1 = x0;
160 double x1_1 = x1;
161
162 if ( xlo!=-999 && x0<xlo ) continue;
163 if ( xhi!=-999 && x1>xhi ) continue;
164
165 double y0_up = h->GetBinContent(i) + h->GetBinError(i);
166 double y1_up = h->GetBinContent(i+1) + h->GetBinError(i+1);
167 double y0_lo = h->GetBinContent(i) - h->GetBinError(i);
168 double y1_lo = h->GetBinContent(i+1) - h->GetBinError(i+1);
169
170 band_intersect( x0, x1, y0_up, y1_up, ylo, yhi );
171 band_intersect( x0_1, x1_1, y0_lo, y1_lo, ylo, yhi );
172
173 TLine* t0 = new TLine( x0, y0_up, x1, y1_up );
174 TLine* t1 = new TLine( x0_1, y0_lo, x1_1, y1_lo );
175
176 t0->SetLineColor( h->GetLineColor() );
177 t0->Draw();
178
179 t1->SetLineColor( h->GetLineColor() );
180 t1->Draw();
181
182 // std::cout << h->GetName() << "\tx1: " << x1 << std::endl;
183
184 }
185
186 // if ( contains( std::string(h->GetName()), "vs_mu") ) ilast = h->FindBin(80);
187
188 // if ( ilast>0 && ifirst>0 ) h->GetXaxis()->SetRange( ifirst, ilast );
189
190 if ( h->GetLineColor()>10 ) h->SetFillStyle(3395);
191 else h->SetFillStyle(3354);
192
193 h->SetFillColor(h->GetLineColor());
194 // h->DrawCopy("same e3lhist" );
195
196
197}
static Double_t t0
#define yt
Header file for AthHistogramAlgorithm.
bool contains(const std::string &s, const std::string &p)
contains a string
void band_intersect(double &x0, double &x1, double &y0, double &y1, double ylo, double yhi)
Definition computils.cxx:53
bool JLflag
Definition computils.cxx:44
std::vector< ALFA_RawDataCollection_p1 > t1

◆ contains() [1/2]

bool contains ( const std::string & s,
char p )
noexcept

Definition at line 39 of file chainparser.cxx.

39 {
40 return s.find( c )!=std::string::npos;
41}

◆ contains() [2/2]

bool contains ( const std::string & s,
const std::string & p )

does a string contain the substring

Definition at line 116 of file hcg.cxx.

116{ return s.find(regx)!=std::string::npos; }

◆ contents() [1/2]

void contents ( std::vector< std::string > & keys,
TDirectory * td,
const std::string & directory = "",
const std::string & pattern = "",
const std::string & path = "" )

Definition at line 480 of file computils.cxx.

481 {
482 std::vector<std::string> patterns;
483 patterns.push_back(pattern);
484 contents( keys, td, directory, patterns, path );
485}
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory, const std::string &pattern, const std::string &path)
std::vector< std::string > patterns
Definition listroot.cxx:187

◆ contents() [2/2]

void contents ( std::vector< std::string > & keys,
TDirectory * td,
const std::string & directory = "",
const std::vector< std::string > & patterns = std::vector< std::string >(),
const std::string & path = "" )

directory, cd to it ...

test to see whether we are searhing for a specific directory name not a directory so include this ...

Definition at line 490 of file computils.cxx.

491 {
492
493 bool print = false;
494
495 TList* tl = td->GetListOfKeys();
496
497 for ( int i=tl->GetSize() ; i-- ; ) {
498
499 TKey* tobj = (TKey*)tl->At(i);
500
501 if ( tobj==0 ) continue;
502
503 if ( std::string(tobj->GetClassName()).find("TDirectory")!=std::string::npos ) {
504
505 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
506
508 std::string dname = tnd->GetName();
509
510 std::string newpath = path+dname+"/";
511 contents( keys, tnd, directory, patterns, newpath );
512
513 }
514 else {
517 if ( directory == "" || contains( path, directory ) ) {
518
519
520 bool matched = true;
521 for ( size_t i=patterns.size() ; i-- ; ) {
522 std::string pattern = patterns[i];
523 if ( contains(std::string(tobj->GetName()), pattern ) ) matched &=true;
524 else matched = false;
525 }
526 if ( matched ) {
527 if ( print ) std::cout << "will process " << td->GetName() << " \t:: " << tobj->GetName() << "\tpatterns: " << patterns.size() << std::endl;
528 print = false;
529 keys.push_back( path+tobj->GetName() );
530 }
531 }
532 }
533 }
534}
void print(char *figname, TCanvas *c1)
path
python interpreter configuration --------------------------------------—
Definition athena.py:130

◆ copyReleaseInfo()

void copyReleaseInfo ( TFile * finput,
TFile * foutdir )

copy the TTree of release info from one directory to another

copy the release info TTree

copy the TTree of release info from one directory to another

Definition at line 780 of file computils.cxx.

780 {
781
782 std::vector<std::string> release_data;
783
784 if ( finput && foutdir ) {
785
786 TTree* tree = (TTree*)finput->Get("dataTree");
787 TTree* clone = tree->CloneTree();
788
789 foutdir->cd();
790 clone->Write("", TObject::kOverwrite);
791
792 delete clone;
793
794 }
795
796}
TChain * tree

◆ empty()

bool empty ( TH1 * h)

Definition at line 455 of file computils.cxx.

455 {
456 for ( int i=h->GetNbinsX() ; i>0 ; i-- ) if ( h->GetBinContent(i)!=0 ) return false;
457 return true;
458}

◆ Entries()

double Entries ( TH1 * h)

Definition at line 202 of file computils.cxx.

202 {
203 double n = 0;
204 for ( int i=h->GetNbinsX()+1 ; --i ; ) n += h->GetBinContent(i);
205 return n;
206}

◆ exists()

bool exists ( const std::string & filename)

does a file exist

Definition at line 415 of file computils.cxx.

415 {
416 struct stat sb;
417 if ( stat( filename.c_str(), &sb)==0 ) return true; // && S_ISREG(sb.st_mode ))
418 else return false;
419}

◆ fcontains()

bool fcontains ( const std::string & s,
const std::string & p )

does a string contain the substring at the beginning of the string

contains a string at the beginning of the string

does a string contain the substring at the beginning of the string

Definition at line 393 of file computils.cxx.

393 {
394 return (s.find(p)==0);
395}

◆ findcell()

std::string findcell ( std::string name,
const std::string & regex,
const std::string & splitex = "/" )

Definition at line 707 of file computils.cxx.

707 {
708
709 size_t posex = name.find( regex );
710
711 if ( posex==std::string::npos ) return "";
712
713 size_t pos = name.find_last_of( splitex );
714
715 std::string duff = name;
716
717 while ( pos!=std::string::npos && pos>posex+regex.size() ) {
718 name.resize(pos); //pos must be <=string length
719 pos = name.find_last_of( splitex );
720 }
721
722 pos = name.find( regex );
723
724 name = name.substr( pos, name.size() );
725
726 pos = name.find( splitex );
727
728 if ( pos!=std::string::npos ) return name.substr( 0, pos );
729
730 return name;
731}

◆ findrun()

std::string findrun ( TFile * f)

go through sub directories

Definition at line 735 of file computils.cxx.

735 {
736
737 TDirectory* here = gDirectory;
738
739 f->cd();
740
741 std::cout << "gDirectory::GetName() " << gDirectory->GetName() << std::endl;
742
743 // gDirectory->pwd();
744
745 // gDirectory->ls();
746
747 TList* tl = gDirectory->GetListOfKeys();
748
750
751 for ( int i=0 ; i<tl->GetSize() ; i++ ) {
752
753 TKey* tobj = (TKey*)tl->At(i);
754
755 if ( tobj==0 ) continue;
756
757 if ( std::string(tobj->GetClassName()).find("TDirectory")!=std::string::npos ) {
758
759 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
760
761 std::string name = tnd->GetName();
762
763 if ( name.find( "run_" )==0 ) {
764 here->cd();
765 return name;
766 }
767 }
768 }
769
770 here->cd();
771
772 return "";
773}

◆ findxrange()

std::vector< int > findxrange ( TH1 * h,
bool symmetric = false )

automatically set the xrange on a histogram

zoom on non-empty bins

Definition at line 608 of file computils.cxx.

608 {
609
610 int ilo = 1;
611 int ihi = h->GetNbinsX();
612
613 h->GetXaxis()->SetRange( ilo, ihi );
614
615 std::vector<int> limits(2,0);
616 limits[0] = ilo;
617 limits[1] = ihi;
618
619 if ( empty(h) ) return limits;
620
621#if 1
622
624 for ( ; ilo<=ihi ; ilo++ ) if ( h->GetBinContent(ilo)!=0 ) break;
625 for ( ; ihi>=ilo ; ihi-- ) if ( h->GetBinContent(ihi)!=0 ) break;
626
627#else
628
630
632
633 double icont = 1/content;
634
635 double flo = 0;
636 double fhi = 0;
637 for ( ; ilo<=ihi ; ilo++ ) {
638 flo += h->GetBinContent(ilo);
639 if ( (flo*icont)>0.0005 ) break;
640 }
641
642 for ( ; ihi>=ilo ; ihi-- ) {
643 fhi += h->GetBinContent(ihi);
644 if ( (fhi*icont)>0.0005 ) break;
645 }
646
647#endif
648
649 int delta_lo = ilo-1;
650 int delta_hi = h->GetNbinsX()-ihi;
651
652 if ( symmetric ) {
653 if ( delta_hi<delta_lo ) {
654 limits[0] = 1+delta_hi;
655 limits[1] = ihi;
656 }
657 else {
658 limits[0] = 1+delta_lo;
659 limits[1] = h->GetNbinsX()-delta_lo;
660 }
661 }
662 else {
663
664 if ( ilo>1 ) ilo--;
665 if ( ihi<h->GetNbinsX() ) ihi++;
666
667 limits[0] = ilo;
668 limits[1] = ihi;
669 }
670
671 return limits;
672
673}
static const Attributes_t empty
str content
Definition grepfile.py:56

◆ findxrangeuser()

std::vector< double > findxrangeuser ( TH1 * h,
bool symmetric = false )

Definition at line 685 of file computils.cxx.

685 {
686
687 std::vector<int> limits = findxrange( h, symmetric );
688
689 std::vector<double> dlimits(2,0);
690
691 double dx = h->GetBinLowEdge(limits[1]+1)-h->GetBinLowEdge(limits[1]);
692
693 dlimits[0] = h->GetBinLowEdge(limits[0]);
694 dlimits[1] = h->GetBinLowEdge(limits[1]+1)-dx*1e-11;
695
696 return dlimits;
697}
std::vector< int > findxrange(TH1 *h, bool symmetric)
automatically set the xrange on a histogram

◆ globbed()

std::string globbed ( const std::string & s)

match a file name

glob for a file based on the pattern, then return the name of the first matching file

Definition at line 423 of file computils.cxx.

423 {
426
427 glob_t glob_result;
428 glob( s.c_str(), GLOB_TILDE, 0, &glob_result );
429
430 std::vector<std::string> ret;
431 for( unsigned i=0 ; i<glob_result.gl_pathc ; i++ ){
432 ret.push_back( std::string(glob_result.gl_pathv[i]) );
433 }
434 globfree(&glob_result);
435
436
437 if ( ret.empty() ) {
438 std::cerr << "no matching file: " << s << std::endl;
439 return "";
440 }
441
442 if ( ret.size()>1 ) {
443 for ( unsigned i=0 ; i<ret.size() ; i++ ) {
444 std::cout << "matched " << ret[i] << std::endl;
445 }
446 }
447
448 return ret[0];
449}

◆ head()

std::string head ( std::string s,
const std::string & pattern )

head of a string

Definition at line 471 of file computils.cxx.

471 {
472 size_t pos = s.find_last_of(pattern);
473 if ( pos != std::string::npos ) {
474 s.erase( pos, s.size() );
475 }
476 return s;
477}

◆ hminus()

void hminus ( TH1 * h)
inline

Definition at line 1190 of file computils.h.

1190 {
1191 std::cout << __FUNCTION__ << std::endl;
1192 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
1193 double duff = h->GetBinContent(i);
1194 if ( duff<0 ) {
1195 std::cout<< "\t\t" << __FUNCTION__ << " " << h->GetName() << " " << i << " " << h->GetBinContent(i) << " " << (duff*1e6) << std::endl;
1196 }
1197 }
1198 h->DrawCopy();
1199 gPad->Print( (std::string("duff-")+h->GetName()+".pdf").c_str() );
1200}

◆ integral()

double integral ( TH1 * h)

Definition at line 209 of file computils.cxx.

209 {
210 double n=0;
211 for ( int i=h->GetNbinsX() ; i>0 ; i-- ) n += h->GetBinContent(i);
212 return n;
213}

◆ myText()

void myText ( Double_t x,
Double_t y,
Color_t color,
const std::string & text,
Double_t tsize )

Definition at line 365 of file computils.cxx.

365 {
366 //Double_t tsize=0.05;
367 TLatex lat; lat.SetTextAlign(12); lat.SetTextSize(tsize);
368 lat.SetNDC();
369 lat.SetTextColor(color);
370 lat.DrawLatex(x,y,text.c_str());
371}

◆ Norm()

void Norm ( TH1 * h,
double scale = 1,
double xmin = 0,
double xmax = 0 )

Definition at line 217 of file computils.cxx.

217 {
218 double n = 0;
219
220 if ( xmin==0 && xmax==0 ) {
221 for ( int i=h->GetNbinsX()+2 ; --i ; ) n += h->GetBinContent(i);
222 }
223 else {
224 for ( int i=h->GetNbinsX()+2 ; --i ; ) {
225 double x = h->GetBinCenter(i);
226 if ( x>xmin && x<xmax ) n += h->GetBinContent(i);
227 }
228 }
229
230 if ( n!=0 ) {
231 double in=scale/n;
232 for ( int i=h->GetNbinsX()+2 ; --i ; ) {
233 h->SetBinContent(i, h->GetBinContent(i)*in );
234 h->SetBinError(i, h->GetBinError(i)*in );
235 }
236 }
237
238}
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60

◆ operator<<() [1/4]

std::ostream & operator<< ( std::ostream & s,
const AxisInfo & a )
inline

Definition at line 335 of file computils.h.

335 {
336 s << "[ " << a.tag() << ( a.log() ? " : log" : "" ) << " ";
337 if ( a.autoset() ) s << " : auto";
338 else if ( a.rangeset() ) s << " : range " << a.lo() << " - " << a.hi();
339 s << " ]";
340 return s;
341}
static Double_t a

◆ operator<<() [2/4]

std::ostream & operator<< ( std::ostream & s,
const HistDetails & h )
inline

Definition at line 1619 of file computils.h.

1619 {
1620 return s << "[ " << h.name() << " \tx: \"" << h.xtitle() << "\" " << h.xaxis() << "\t\ty: \"" << h.ytitle() << "\" " << h.yaxis() << " ]";
1621}

◆ operator<<() [3/4]

std::ostream & operator<< ( std::ostream & s,
const Panel & p )
inline

Definition at line 1692 of file computils.h.

1692 {
1693 s << "Panel: " << p.name();
1694 if ( p.size() == 1 ) s << "\t" << p[0];
1695 else for ( size_t i=0 ; i<p.size() ; i++ ) s << "\n\t" << p[i];
1696 return s;
1697}

◆ operator<<() [4/4]

template<typename T>
std::ostream & operator<< ( std::ostream & s,
std::vector< T > & v )

Definition at line 113 of file computils.h.

113 {
114 for ( unsigned i=0 ; i<v.size() ; i++ ) s << "\t" << v[i];
115 return s;
116}

◆ plotable()

double plotable ( TH1 * h)

Definition at line 398 of file computils.cxx.

398 { // , double xlo, double xhi ) {
399 double n = 0;
400
401 double xlo = h->GetBinLowEdge(1);
402 double xhi = h->GetBinLowEdge(h->GetNbinsX()+1);
403
404 // if ( xlo!=-999 ) _xlo = xlo;
405 // if ( xhi!=-999 ) _xhi = xhi;
406
407 for ( int i=h->GetNbinsX()+1 ; --i ; ) {
408 if ( h->GetBinCenter(i)>xlo && h->GetBinCenter(i)<xhi ) n += h->GetBinContent(i);
409 }
410 return n;
411}

◆ realmax()

double realmax ( TH1 * h,
bool include_error = true,
double lo = 0,
double hi = 0 )

Definition at line 540 of file computils.cxx.

540 {
541
542 double rm = 0;
543 if ( h->GetNbinsX()==0 ) return 0;
544
545 bool first = true;
546 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
547
548 if ( lo!=hi ) {
549 double c = h->GetBinCenter(i);
550 if ( lo>c || hi<c ) continue;
551 }
552
553 double re = h->GetBinContent(i);
554 if ( include_error ) re += h->GetBinError(i);
555 if ( re!=0 ) {
556 if ( first || rm<re ) {
557 rm = re;
558 first = false;
559 }
560 }
561 }
562
563 return rm;
564}
const std::regex re(r_e)
bool first
Definition DeMoScan.py:534

◆ realmin()

double realmin ( TH1 * h,
bool include_error = true,
double lo = 0,
double hi = 0 )

Definition at line 568 of file computils.cxx.

568 {
569
570 if ( h->GetNbinsX()==0 ) return 0;
571
572 double rm = 0;
573
574 bool first = true;
575 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
576
577 if ( lo!=hi ) {
578 double c = h->GetBinCenter(i);
579 if ( lo>c || hi<c ) continue;
580 }
581
582 double re = h->GetBinContent(i);
583
584 if ( re!=0 ) {
585 // if ( include_error ) re -= h->GetBinError(i);
586 if ( first || rm>re ) rm = re;
587 first = false;
588 }
589 }
590
591 return rm;
592}

◆ setParameters()

template<typename T>
void setParameters ( T * h,
TGraphAsymmErrors * tg )

Definition at line 451 of file computils.h.

451 {
452 tg->SetLineColor( h->GetLineColor() );
453 tg->SetMarkerColor( h->GetMarkerColor() );
454 tg->SetMarkerStyle( h->GetMarkerStyle() );
455 tg->SetMarkerSize( h->GetMarkerSize() );
456 tg->SetLineWidth( h->GetLineWidth() );
457 tg->SetLineStyle( h->GetLineStyle() );
458}

◆ stime()

std::string stime ( )

return the current data and time

Definition at line 374 of file computils.cxx.

374 {
375 time_t t;
376 time(&t);
377 return label("%s", ctime(&t) );
378}
std::string label(const std::string &format, int i)
Definition label.h:19
time(flags, cells_name, *args, **kw)

◆ tail()

std::string tail ( std::string s,
const std::string & pattern )

tail of a string

Definition at line 461 of file computils.cxx.

461 {
462 size_t pos = s.find(pattern);
463 while ( pos != std::string::npos ) {
464 s.erase( 0, pos+1 );
465 pos = s.find(pattern);
466 }
467 return s;
468}

◆ trim_tgraph()

void trim_tgraph ( TH1 * h,
TGraphAsymmErrors * t )

Definition at line 313 of file computils.cxx.

313 {
314
315 double ylo = h->GetMinimum();
316
317 int ih=1;
318
319 for ( int i=0 ; i<t->GetN() && ih<=h->GetNbinsX() ; i++, ih++ ) {
320
321 double yt = 0;
322 double xt = 0;
323 double ye = 0;
324
325 t->GetPoint( i, xt, yt );
326 ye = t->GetErrorYlow( i );
327
328 double yh = h->GetBinContent(ih);
329 double xh = h->GetBinCenter(ih);
330
331 while( !almost_equal( xh, xt, 5 ) && ih<=h->GetNbinsX() ) {
332 ih++;
333 yh = h->GetBinContent(ih);
334 xh = h->GetBinCenter(ih);
335 }
336
337 if ( !almost_equal( yh, yt, 5 ) ) throw data_mismatch(std::string("for histogram ")+h->GetName());
338
339 if ( (yt-ye) < ylo ) {
340 h->SetBinContent(ih, ylo-100 );
341 t->SetPoint( i, xt, ylo-10000 );
342 }
343
344 }
345}
#define xt
bool almost_equal(floaty_t a, floaty_t b, int max_diff)

◆ xrange()

void xrange ( TH1 * h,
bool symmetric = true )

Definition at line 677 of file computils.cxx.

677 {
678 std::vector<int> limits = findxrange( h, symmetric );
679 h->GetXaxis()->SetRange( limits[0], limits[1] );
680}

◆ zeroErrors()

template<typename T>
void zeroErrors ( T * )

Definition at line 462 of file computils.h.

462 {
463 // for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) h->SetBinError( i, 1e-100 );
464}

Variable Documentation

◆ colours

int colours[6]
extern

Definition at line 48 of file computils.cxx.

48{ 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 };

◆ JLflag

bool JLflag
extern

Definition at line 44 of file computils.cxx.

◆ LINEF

bool LINEF
extern

Definition at line 40 of file computils.cxx.

◆ LINES

bool LINES
extern

Definition at line 41 of file computils.cxx.

◆ markers

int markers[6]
extern

Definition at line 49 of file computils.cxx.

49{ 20, 24, 25, 26, 25, 22 };

◆ msizes

double msizes[6]
extern

Definition at line 50 of file computils.cxx.

50{ 0.85, 1, 1, 1, 1, 1 };

◆ release

std::string release
static

Definition at line 54 of file computils.h.

◆ tPlotter< T >::s_meanplotref

template<typename T>
bool tPlotter< T >::s_meanplotref = true

Definition at line 1182 of file computils.h.

◆ tPlotter< T >::s_plotref

template<typename T>
bool tPlotter< T >::s_plotref = true

use non c++17 format for improved external compatability

Definition at line 1178 of file computils.h.