ATLAS Offline Software
Loading...
Searching...
No Matches
computils.cxx File Reference
#include <stdlib.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <glob.h>
#include <stdint.h>
#include <iostream>
#include <string>
#include <vector>
#include "label.h"
#include "DrawLabel.h"
#include "TFile.h"
#include "TKey.h"
#include "TTree.h"
#include "TList.h"
#include "TObject.h"
#include "TDirectory.h"
#include "TH1D.h"
#include "TLine.h"
#include "TLegend.h"
#include "TColor.h"
#include "computils.h"

Go to the source code of this file.

Classes

union  floaty_t

Functions

void band_intersect (double &x0, double &x1, double &y0, double &y1, double ylo, double yhi)
void band_plot (TH1 *h, double xlo, double xhi, double ylo, double yhi)
double Entries (TH1 *h)
double integral (TH1 *h)
void Norm (TH1 *h, double scale, double xmin, double xmax)
bool almost_equal (floaty_t a, floaty_t b, int max_diff)
bool almost_equal (float a, float b, int max_diff)
bool operator== (floaty_t a, floaty_t b)
void trim_tgraph (TH1 *h, TGraphAsymmErrors *t)
void ATLASFORAPP_LABEL (double x, double y, int color, double size)
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
bool contains (const std::string &s, const std::string &p)
 contains a string
bool contains (const std::string &s, char p) noexcept
bool fcontains (const std::string &s, const std::string &p)
 contains a string at the beginning of the string
double plotable (TH1 *h)
bool exists (const std::string &filename)
 does a file exist
std::string globbed (const std::string &s)
 match a file name
bool empty (TH1 *h)
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
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, const std::string &path)
double realmax (TH1 *h, bool include_error, double lo, double hi)
double realmin (TH1 *h, bool, double lo, double hi)
double hmean (TH1 *h)
std::vector< int > findxrange (TH1 *h, bool symmetric)
 automatically set the xrange on a histogram
void xrange (TH1 *h, bool symmetric)
std::vector< double > findxrangeuser (TH1 *h, bool symmetric)
void xrangeuser (TH1 *h, bool symmetric)
std::string findcell (std::string name, const std::string &regex, const std::string &splitex)
std::string findrun (TFile *f)
void copyReleaseInfo (TFile *finput, TFile *foutdir)
 copy the release info TTree

Variables

bool LINEF = true
bool LINES = false
bool JLflag = false
int colours [6] = { 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 }
int markers [6] = { 20, 24, 25, 26, 25, 22 }
double msizes [6] = { 0.85, 1, 1, 1, 1, 1 }

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.cxx.

Function Documentation

◆ almost_equal() [1/2]

bool almost_equal ( float a,
float b,
int max_diff )

Definition at line 302 of file computils.cxx.

302 {
303 return almost_equal( floaty_t(a), floaty_t(b), max_diff );
304}
static Double_t a
bool almost_equal(floaty_t a, floaty_t b, int max_diff)

◆ almost_equal() [2/2]

bool almost_equal ( floaty_t a,
floaty_t b,
int max_diff )

Definition at line 286 of file computils.cxx.

286 {
287
288 // Check for trivial equality to make sure +0==-0
289 if ( a.f == b.f ) return true;
290
291 // Different signs means they do not match.
292 if ( a.negative() != b.negative() ) return false;
293
294 // Find the difference in last place units
295 int ulps_diff = std::abs( a.i - b.i );
296 if (ulps_diff <= max_diff) return true;
297
298 return false;
299}

◆ ATLASFORAPP_LABEL()

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

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_intersect()

void band_intersect ( double & x0,
double & x1,
double & y0,
double & y1,
double ylo,
double yhi )

Definition at line 53 of file computils.cxx.

53 {
54
55 double x0t = x0;
56 double x1t = x1;
57
58 double y0t = y0;
59 double y1t = y1;
60
61 if ( ylo!=-999 ) {
62 if ( y0>ylo && y1<ylo) {
63 double y = ylo;
64 double x = (ylo-y0)*(x1-x0)/(y1-y0)+x0;
65 x1t = x;
66 y1t = y;
67 }
68
69 if ( y0<ylo && y1>ylo) {
70 double y = ylo;
71 double x = x1-(y1-ylo)*(x1-x0)/(y1-y0);
72 x0t = x;
73 y0t = y;
74 }
75
76 if ( y0<ylo && y1<ylo) {
77 y0t = ylo;
78 y1t = ylo;
79 }
80
81 x0 = x0t;
82 x1 = x1t;
83 y0 = y0t;
84 y1 = y1t;
85
86 return;
87 }
88
89 if ( yhi!=-999 ) {
90 if ( y0<yhi && y1>yhi) {
91 double y = yhi;
92 double x = (yhi-y0)*(x1-x0)/(y1-y0)+x0;
93 x1t = x;
94 y1t = y;
95 }
96
97 if ( y0>yhi && y1<yhi) {
98 double y = yhi;
99 double x = x1-(y1-yhi)*(x1-x0)/(y1-y0);
100 x0t = x;
101 y0t = y;
102 }
103
104 x0 = x0t;
105 x1 = x1t;
106 y0 = y0t;
107 y1 = y1t;
108
109 return;
110 }
111
112}

◆ band_plot()

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

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 387 of file computils.cxx.

387 {
388 return (s.find(p)!=std::string::npos);
389}

◆ contains() [2/2]

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

contains a string

does a string contain the substring

Definition at line 382 of file computils.cxx.

382 {
383 return (s.find(p)!=std::string::npos);
384}

◆ 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,
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 release info TTree

copy the TTree of release info from one directory to another

copy the release info TTree

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 )

contains a string at the beginning of the string

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

contains a string 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 )

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 )

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}

◆ hmean()

double hmean ( TH1 * h)

Definition at line 595 of file computils.cxx.

595 {
596 double N = integral(h);
597 double n=0;
598 for ( int i=h->GetNbinsX() ; i>0 ; i-- ) {
599 n += h->GetBinContent(i);
600 if ( 2*n>N ) return h->GetBinCenter(i);
601 }
602 return 0;
603}
double integral(TH1 *h)
constexpr std::size_t N

◆ 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,
double xmin,
double xmax )

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==()

bool operator== ( floaty_t a,
floaty_t b )

use a maximum 5 float separation between the two - could be more precise

Definition at line 307 of file computils.cxx.

307 {
309 return almost_equal( a, b, 5 );
310}

◆ 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,
double lo,
double hi )

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,
double lo,
double hi )

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}

◆ 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

◆ xrange()

void xrange ( TH1 * h,
bool symmetric )

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}

◆ xrangeuser()

void xrangeuser ( TH1 * h,
bool symmetric )

Definition at line 700 of file computils.cxx.

700 {
701 std::vector<double> limits = findxrangeuser( h, symmetric );
702 h->GetXaxis()->SetRangeUser( limits[0], limits[1] );
703}
std::vector< double > findxrangeuser(TH1 *h, bool symmetric)

Variable Documentation

◆ colours

int colours[6] = { 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 }

Definition at line 48 of file computils.cxx.

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

◆ JLflag

bool JLflag = false

Definition at line 44 of file computils.cxx.

◆ LINEF

bool LINEF = true

Definition at line 40 of file computils.cxx.

◆ LINES

bool LINES = false

Definition at line 41 of file computils.cxx.

◆ markers

int markers[6] = { 20, 24, 25, 26, 25, 22 }

Definition at line 49 of file computils.cxx.

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

◆ msizes

double msizes[6] = { 0.85, 1, 1, 1, 1, 1 }

Definition at line 50 of file computils.cxx.

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