15 #include <sys/types.h>
31 #include "TDirectory.h"
46 int colours[6] = { 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 };
47 int markers[6] = { 20, 24, 25, 26, 25, 22 };
48 double msizes[6] = { 0.85, 1, 1, 1, 1, 1 };
54 for (
int i=
h->GetNbinsX()+1 ; --
i ; )
n +=
h->GetBinContent(
i);
61 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- )
n +=
h->GetBinContent(
i);
69 for (
int i=
h->GetNbinsX()+2 ; --
i ; )
n +=
h->GetBinContent(
i);
72 for (
int i=
h->GetNbinsX()+2 ; --
i ; ) {
73 h->SetBinContent(
i,
h->GetBinContent(
i)*in );
74 h->SetBinError(
i,
h->GetBinError(
i)*in );
83 m_mean(0), m_error(0) {
89 for (
int i=0 ;
i<
h->GetNbinsX() ;
i++ ) {
90 double w =
h->GetBinLowEdge(
i+2)-
h->GetBinLowEdge(
i+1);
91 f +=
h->GetBinContent(
i+1)*
w;
92 fx +=
h->GetBinContent(
i+1)*
w*
h->GetBinCenter(
i+1);
93 fx2 +=
h->GetBinContent(
i+1)*
w*
h->GetBinCenter(
i+1)*
h->GetBinCenter(
i+1);
129 if (
a.f ==
b.f )
return true;
132 if (
a.negative() !=
b.negative() )
return false;
135 int ulps_diff = std::abs(
a.i -
b.i );
136 if (ulps_diff <= max_diff)
return true;
155 double ylo =
h->GetMinimum();
159 for (
int i=0 ;
i<
t->GetN() && ih<=h->GetNbinsX() ;
i++, ih++ ) {
166 ye =
t->GetErrorYlow(
i );
168 double yh =
h->GetBinContent(ih);
169 double xh =
h->GetBinCenter(ih);
173 yh =
h->GetBinContent(ih);
174 xh =
h->GetBinCenter(ih);
179 if ( (
yt-ye) <
ylo ) {
180 h->SetBinContent(ih,
ylo-100 );
190 TLatex*
lat =
new TLatex();
192 lat->SetTextFont(72);
195 lat->DrawLatex(
x,
y,
"ATLAS");
197 TLatex* lat2 =
new TLatex();
199 lat2->SetTextFont(52);
200 lat2->SetTextColor(
color);
201 lat2->SetTextSize(
size);
202 lat2->DrawLatex(
x+0.13,
y,
"For Approval");
218 return label(
"%s", ctime(&
t) );
224 return (
s.find(
p)!=std::string::npos);
229 return (
s.find(
p)!=std::string::npos);
235 return (
s.find(
p)==0);
242 double xlo =
h->GetBinLowEdge(1);
243 double xhi =
h->GetBinLowEdge(
h->GetNbinsX()+1);
248 for (
int i=
h->GetNbinsX()+1 ; --
i ; ) {
249 if (
h->GetBinCenter(
i)>
xlo &&
h->GetBinCenter(
i)<
xhi )
n +=
h->GetBinContent(
i);
269 glob(
s.c_str(), GLOB_TILDE, 0, &glob_result );
271 std::vector<std::string> ret;
272 for(
unsigned i=0 ;
i<glob_result.gl_pathc ;
i++ ){
273 ret.push_back( std::string(glob_result.gl_pathv[
i]) );
275 globfree(&glob_result);
279 std::cerr <<
"no matching file: " <<
s << std::endl;
283 if ( ret.size()>1 ) {
284 for (
unsigned i=0 ;
i<ret.size() ;
i++ ) {
285 std::cout <<
"matched " << ret[
i] << std::endl;
297 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- )
if (
h->GetBinContent(
i)!=0 )
return false;
304 while (
pos != std::string::npos ) {
314 if (
pos != std::string::npos ) {
315 s.erase(
pos,
s.size() );
336 TList*
tl = td->GetListOfKeys();
338 for (
int i=
tl->GetSize() ;
i-- ; ) {
340 TKey* tobj = (TKey*)
tl->At(
i);
342 if ( tobj==0 )
continue;
344 if ( std::string(tobj->GetClassName()).find(
"TDirectory")!=std::string::npos ) {
346 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
349 std::string
dname = tnd->GetName();
368 if (
print ) std::cout <<
"will process " << td->GetName() <<
" \t:: " << tobj->GetName() <<
"\tpatterns: " <<
patterns.size() << std::endl;
370 keys.push_back(
path+tobj->GetName() );
381 double realmax( TH1*
h,
bool include_error,
double lo,
double hi ) {
383 if (
h->GetNbinsX()==0 )
return 0;
386 for (
int i=1 ;
i<=
h->GetNbinsX() ;
i++ ) {
389 double c =
h->GetBinCenter(
i);
390 if ( lo>
c || hi<
c )
continue;
393 double re =
h->GetBinContent(
i);
394 if ( include_error )
re +=
h->GetBinError(
i);
408 double realmin( TH1*
h,
bool ,
double lo,
double hi ) {
410 if (
h->GetNbinsX()==0 )
return 0;
415 for (
int i=1 ;
i<=
h->GetNbinsX() ;
i++ ) {
418 double c =
h->GetBinCenter(
i);
419 if ( lo>
c || hi<
c )
continue;
422 double re =
h->GetBinContent(
i);
438 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- ) {
439 n +=
h->GetBinContent(
i);
440 if ( 2*
n>
N )
return h->GetBinCenter(
i);
451 int ihi =
h->GetNbinsX();
453 h->GetXaxis()->SetRange( ilo, ihi );
455 std::vector<int> limits(2,0);
459 if (
empty(
h) )
return limits;
464 for ( ; ilo<=ihi ; ilo++ )
if (
h->GetBinContent(ilo)!=0 )
break;
465 for ( ; ihi>=ilo ; ihi-- )
if (
h->GetBinContent(ihi)!=0 )
break;
477 for ( ; ilo<=ihi ; ilo++ ) {
478 flo +=
h->GetBinContent(ilo);
479 if ( (flo*icont)>0.0005 )
break;
482 for ( ; ihi>=ilo ; ihi-- ) {
483 fhi +=
h->GetBinContent(ihi);
484 if ( (fhi*icont)>0.0005 )
break;
489 int delta_lo = ilo-1;
490 int delta_hi =
h->GetNbinsX()-ihi;
493 if ( delta_hi<delta_lo ) {
494 limits[0] = 1+delta_hi;
498 limits[0] = 1+delta_lo;
499 limits[1] =
h->GetNbinsX()-delta_lo;
505 if ( ihi<h->GetNbinsX() ) ihi++;
518 std::vector<int> limits =
findxrange(
h, symmetric );
519 h->GetXaxis()->SetRange( limits[0], limits[1] );
527 std::vector<int> limits =
findxrange(
h, symmetric );
529 std::vector<double> dlimits(2,0);
531 double dx =
h->GetBinLowEdge(limits[1]+1)-
h->GetBinLowEdge(limits[1]);
533 dlimits[0] =
h->GetBinLowEdge(limits[0]);
534 dlimits[1] =
h->GetBinLowEdge(limits[1]+1)-
dx*1
e-11;
542 h->GetXaxis()->SetRangeUser( limits[0], limits[1] );
547 std::string
findcell( std::string
name,
const std::string&
regex,
const std::string& splitex ) {
551 if ( posex==std::string::npos )
return "";
553 size_t pos =
name.find_last_of( splitex );
555 std::string duff =
name;
557 while (
pos!=std::string::npos &&
pos>posex+
regex.size() ) {
559 pos =
name.find_last_of( splitex );
568 if (
pos!=std::string::npos )
return name.substr( 0,
pos );
581 std::cout <<
"gDirectory::GetName() " <<
gDirectory->GetName() << std::endl;
591 for (
int i=0 ;
i<
tl->GetSize() ;
i++ ) {
593 TKey* tobj = (TKey*)
tl->At(
i);
595 if ( tobj==0 )
continue;
597 if ( std::string(tobj->GetClassName()).find(
"TDirectory")!=std::string::npos ) {
599 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
601 std::string
name = tnd->GetName();
603 if (
name.find(
"run_" )==0 ) {
622 std::vector<std::string> release_data;
624 if ( finput && foutdir ) {
626 TTree*
tree = (TTree*)finput->Get(
"dataTree");
630 clone->Write(
"", TObject::kOverwrite);