15 #include <sys/types.h>
31 #include "TDirectory.h"
45 int colours[6] = { 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 };
46 int markers[6] = { 20, 24, 25, 26, 25, 22 };
47 double msizes[6] = { 0.85, 1, 1, 1, 1, 1 };
53 for (
int i=
h->GetNbinsX()+1 ; --
i ; )
n +=
h->GetBinContent(
i);
60 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- )
n +=
h->GetBinContent(
i);
68 for (
int i=
h->GetNbinsX()+2 ; --
i ; )
n +=
h->GetBinContent(
i);
71 for (
int i=
h->GetNbinsX()+2 ; --
i ; ) {
72 h->SetBinContent(
i,
h->GetBinContent(
i)*in );
73 h->SetBinError(
i,
h->GetBinError(
i)*in );
82 m_mean(0), m_error(0) {
88 for (
int i=0 ;
i<
h->GetNbinsX() ;
i++ ) {
89 double w =
h->GetBinLowEdge(
i+2)-
h->GetBinLowEdge(
i+1);
90 f +=
h->GetBinContent(
i+1)*
w;
91 fx +=
h->GetBinContent(
i+1)*
w*
h->GetBinCenter(
i+1);
92 fx2 +=
h->GetBinContent(
i+1)*
w*
h->GetBinCenter(
i+1)*
h->GetBinCenter(
i+1);
128 if (
a.f ==
b.f )
return true;
131 if (
a.negative() !=
b.negative() )
return false;
134 int ulps_diff = std::abs(
a.i -
b.i );
135 if (ulps_diff <= max_diff)
return true;
154 double ylo =
h->GetMinimum();
158 for (
int i=0 ;
i<
t->GetN() && ih<=h->GetNbinsX() ;
i++, ih++ ) {
165 ye =
t->GetErrorYlow(
i );
167 double yh =
h->GetBinContent(ih);
168 double xh =
h->GetBinCenter(ih);
172 yh =
h->GetBinContent(ih);
173 xh =
h->GetBinCenter(ih);
178 if ( (
yt-ye) <
ylo ) {
179 h->SetBinContent(ih,
ylo-100 );
189 TLatex*
lat =
new TLatex();
191 lat->SetTextFont(72);
194 lat->DrawLatex(
x,
y,
"ATLAS");
196 TLatex* lat2 =
new TLatex();
198 lat2->SetTextFont(52);
199 lat2->SetTextColor(
color);
200 lat2->SetTextSize(
size);
201 lat2->DrawLatex(
x+0.13,
y,
"For Approval");
217 return label(
"%s", ctime(&
t) );
223 return (
s.find(
p)!=std::string::npos);
228 return (
s.find(
p)!=std::string::npos);
234 return (
s.find(
p)==0);
241 double xlo =
h->GetBinLowEdge(1);
242 double xhi =
h->GetBinLowEdge(
h->GetNbinsX()+1);
247 for (
int i=
h->GetNbinsX()+1 ; --
i ; ) {
248 if (
h->GetBinCenter(
i)>
xlo &&
h->GetBinCenter(
i)<
xhi )
n +=
h->GetBinContent(
i);
268 glob(
s.c_str(), GLOB_TILDE, 0, &glob_result );
270 std::vector<std::string> ret;
271 for(
unsigned i=0 ;
i<glob_result.gl_pathc ;
i++ ){
272 ret.push_back( std::string(glob_result.gl_pathv[
i]) );
274 globfree(&glob_result);
278 std::cerr <<
"no matching file: " <<
s << std::endl;
282 if ( ret.size()>1 ) {
283 for (
unsigned i=0 ;
i<ret.size() ;
i++ ) {
284 std::cout <<
"matched " << ret[
i] << std::endl;
296 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- )
if (
h->GetBinContent(
i)!=0 )
return false;
303 while (
pos != std::string::npos ) {
313 if (
pos != std::string::npos ) {
314 s.erase(
pos,
s.size() );
335 TList*
tl = td->GetListOfKeys();
337 for (
int i=
tl->GetSize() ;
i-- ; ) {
339 TKey* tobj = (TKey*)
tl->At(
i);
341 if ( tobj==0 )
continue;
343 if ( std::string(tobj->GetClassName()).find(
"TDirectory")!=std::string::npos ) {
345 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
348 std::string
dname = tnd->GetName();
367 if (
print ) std::cout <<
"will process " << td->GetName() <<
" \t:: " << tobj->GetName() <<
"\tpatterns: " <<
patterns.size() << std::endl;
369 keys.push_back(
path+tobj->GetName() );
380 double realmax( TH1*
h,
bool include_error,
double lo,
double hi ) {
382 if (
h->GetNbinsX()==0 )
return 0;
385 for (
int i=1 ;
i<=
h->GetNbinsX() ;
i++ ) {
388 double c =
h->GetBinCenter(
i);
389 if ( lo>
c || hi<
c )
continue;
392 double re =
h->GetBinContent(
i);
393 if ( include_error )
re +=
h->GetBinError(
i);
407 double realmin( TH1*
h,
bool ,
double lo,
double hi ) {
409 if (
h->GetNbinsX()==0 )
return 0;
414 for (
int i=1 ;
i<=
h->GetNbinsX() ;
i++ ) {
417 double c =
h->GetBinCenter(
i);
418 if ( lo>
c || hi<
c )
continue;
421 double re =
h->GetBinContent(
i);
437 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- ) {
438 n +=
h->GetBinContent(
i);
439 if ( 2*
n>
N )
return h->GetBinCenter(
i);
450 int ihi =
h->GetNbinsX();
452 h->GetXaxis()->SetRange( ilo, ihi );
454 std::vector<int> limits(2,0);
458 if (
empty(
h) )
return limits;
463 for ( ; ilo<=ihi ; ilo++ )
if (
h->GetBinContent(ilo)!=0 )
break;
464 for ( ; ihi>=ilo ; ihi-- )
if (
h->GetBinContent(ihi)!=0 )
break;
476 for ( ; ilo<=ihi ; ilo++ ) {
477 flo +=
h->GetBinContent(ilo);
478 if ( (flo*icont)>0.0005 )
break;
481 for ( ; ihi>=ilo ; ihi-- ) {
482 fhi +=
h->GetBinContent(ihi);
483 if ( (fhi*icont)>0.0005 )
break;
488 int delta_lo = ilo-1;
489 int delta_hi =
h->GetNbinsX()-ihi;
492 if ( delta_hi<delta_lo ) {
493 limits[0] = 1+delta_hi;
497 limits[0] = 1+delta_lo;
498 limits[1] =
h->GetNbinsX()-delta_lo;
504 if ( ihi<h->GetNbinsX() ) ihi++;
517 std::vector<int> limits =
findxrange(
h, symmetric );
518 h->GetXaxis()->SetRange( limits[0], limits[1] );
526 std::vector<int> limits =
findxrange(
h, symmetric );
528 std::vector<double> dlimits(2,0);
530 double dx =
h->GetBinLowEdge(limits[1]+1)-
h->GetBinLowEdge(limits[1]);
532 dlimits[0] =
h->GetBinLowEdge(limits[0]);
533 dlimits[1] =
h->GetBinLowEdge(limits[1]+1)-
dx*1
e-11;
541 h->GetXaxis()->SetRangeUser( limits[0], limits[1] );
546 std::string
findcell( std::string
name,
const std::string&
regex,
const std::string& splitex ) {
550 if ( posex==std::string::npos )
return "";
552 size_t pos =
name.find_last_of( splitex );
554 std::string duff =
name;
556 while (
pos!=std::string::npos &&
pos>posex+
regex.size() ) {
558 pos =
name.find_last_of( splitex );
567 if (
pos!=std::string::npos )
return name.substr( 0,
pos );
580 std::cout <<
"gDirectory::GetName() " <<
gDirectory->GetName() << std::endl;
590 for (
int i=0 ;
i<
tl->GetSize() ;
i++ ) {
592 TKey* tobj = (TKey*)
tl->At(
i);
594 if ( tobj==0 )
continue;
596 if ( std::string(tobj->GetClassName()).find(
"TDirectory")!=std::string::npos ) {
598 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
600 std::string
name = tnd->GetName();
602 if (
name.find(
"run_" )==0 ) {
621 std::vector<std::string> release_data;
623 if ( finput && foutdir ) {
625 TTree*
tree = (TTree*)finput->Get(
"dataTree");
629 clone->Write(
"", TObject::kOverwrite);