14 #include <sys/types.h>
30 #include "TDirectory.h"
44 int colours[6] = { 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 };
45 int markers[6] = { 20, 24, 25, 26, 25, 22 };
46 double msizes[6] = { 0.85, 1, 1, 1, 1, 1 };
52 for (
int i=
h->GetNbinsX()+1 ; --
i ; )
n +=
h->GetBinContent(
i);
59 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- )
n +=
h->GetBinContent(
i);
67 for (
int i=
h->GetNbinsX()+2 ; --
i ; )
n +=
h->GetBinContent(
i);
70 for (
int i=
h->GetNbinsX()+2 ; --
i ; ) {
71 h->SetBinContent(
i,
h->GetBinContent(
i)*in );
72 h->SetBinError(
i,
h->GetBinError(
i)*in );
81 m_mean(0), m_error(0) {
87 for (
int i=0 ;
i<
h->GetNbinsX() ;
i++ ) {
88 double w =
h->GetBinLowEdge(
i+2)-
h->GetBinLowEdge(
i+1);
89 f +=
h->GetBinContent(
i+1)*
w;
90 fx +=
h->GetBinContent(
i+1)*
w*
h->GetBinCenter(
i+1);
91 fx2 +=
h->GetBinContent(
i+1)*
w*
h->GetBinCenter(
i+1)*
h->GetBinCenter(
i+1);
127 if (
a.f ==
b.f )
return true;
130 if (
a.negative() !=
b.negative() )
return false;
133 int ulps_diff = std::abs(
a.i -
b.i );
134 if (ulps_diff <= max_diff)
return true;
153 double ylo =
h->GetMinimum();
157 for (
int i=0 ;
i<
t->GetN() && ih<=h->GetNbinsX() ;
i++, ih++ ) {
164 ye =
t->GetErrorYlow(
i );
166 double yh =
h->GetBinContent(ih);
167 double xh =
h->GetBinCenter(ih);
171 yh =
h->GetBinContent(ih);
172 xh =
h->GetBinCenter(ih);
177 if ( (
yt-ye) <
ylo ) {
178 h->SetBinContent(ih,
ylo-100 );
188 TLatex*
lat =
new TLatex();
190 lat->SetTextFont(72);
193 lat->DrawLatex(
x,
y,
"ATLAS");
195 TLatex* lat2 =
new TLatex();
197 lat2->SetTextFont(52);
198 lat2->SetTextColor(
color);
199 lat2->SetTextSize(
size);
200 lat2->DrawLatex(
x+0.13,
y,
"For Approval");
216 return label(
"%s", ctime(&
t) );
222 return (
s.find(
p)!=std::string::npos);
227 return (
s.find(
p)!=std::string::npos);
233 return (
s.find(
p)==0);
240 double xlo =
h->GetBinLowEdge(1);
241 double xhi =
h->GetBinLowEdge(
h->GetNbinsX()+1);
246 for (
int i=
h->GetNbinsX()+1 ; --
i ; ) {
247 if (
h->GetBinCenter(
i)>
xlo &&
h->GetBinCenter(
i)<
xhi )
n +=
h->GetBinContent(
i);
267 glob(
s.c_str(), GLOB_TILDE, 0, &glob_result );
269 std::vector<std::string> ret;
270 for(
unsigned i=0 ;
i<glob_result.gl_pathc ;
i++ ){
271 ret.push_back( std::string(glob_result.gl_pathv[
i]) );
273 globfree(&glob_result);
277 std::cerr <<
"no matching file: " <<
s << std::endl;
281 if ( ret.size()>1 ) {
282 for (
unsigned i=0 ;
i<ret.size() ;
i++ ) {
283 std::cout <<
"matched " << ret[
i] << std::endl;
295 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- )
if (
h->GetBinContent(
i)!=0 )
return false;
302 while (
pos != std::string::npos ) {
312 if (
pos != std::string::npos ) {
313 s.erase(
pos,
s.size() );
334 TList*
tl = td->GetListOfKeys();
336 for (
int i=
tl->GetSize() ;
i-- ; ) {
338 TKey* tobj = (TKey*)
tl->At(
i);
340 if ( tobj==0 )
continue;
342 if ( std::string(tobj->GetClassName()).find(
"TDirectory")!=std::string::npos ) {
344 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
347 std::string
dname = tnd->GetName();
366 if (
print ) std::cout <<
"will process " << td->GetName() <<
" \t:: " << tobj->GetName() <<
"\tpatterns: " <<
patterns.size() << std::endl;
368 keys.push_back(
path+tobj->GetName() );
379 double realmax( TH1*
h,
bool include_error,
double lo,
double hi ) {
381 if (
h->GetNbinsX()==0 )
return 0;
384 for (
int i=1 ;
i<=
h->GetNbinsX() ;
i++ ) {
387 double c =
h->GetBinCenter(
i);
388 if ( lo>
c || hi<
c )
continue;
391 double re =
h->GetBinContent(
i);
392 if ( include_error )
re +=
h->GetBinError(
i);
406 double realmin( TH1*
h,
bool ,
double lo,
double hi ) {
408 if (
h->GetNbinsX()==0 )
return 0;
413 for (
int i=1 ;
i<=
h->GetNbinsX() ;
i++ ) {
416 double c =
h->GetBinCenter(
i);
417 if ( lo>
c || hi<
c )
continue;
420 double re =
h->GetBinContent(
i);
436 for (
int i=
h->GetNbinsX() ;
i>0 ;
i-- ) {
437 n +=
h->GetBinContent(
i);
438 if ( 2*
n>
N )
return h->GetBinCenter(
i);
449 int ihi =
h->GetNbinsX();
451 h->GetXaxis()->SetRange( ilo, ihi );
453 std::vector<int> limits(2,0);
457 if (
empty(
h) )
return limits;
462 for ( ; ilo<=ihi ; ilo++ )
if (
h->GetBinContent(ilo)!=0 )
break;
463 for ( ; ihi>=ilo ; ihi-- )
if (
h->GetBinContent(ihi)!=0 )
break;
475 for ( ; ilo<=ihi ; ilo++ ) {
476 flo +=
h->GetBinContent(ilo);
477 if ( (flo*icont)>0.0005 )
break;
480 for ( ; ihi>=ilo ; ihi-- ) {
481 fhi +=
h->GetBinContent(ihi);
482 if ( (fhi*icont)>0.0005 )
break;
487 int delta_lo = ilo-1;
488 int delta_hi =
h->GetNbinsX()-ihi;
491 if ( delta_hi<delta_lo ) {
492 limits[0] = 1+delta_hi;
496 limits[0] = 1+delta_lo;
497 limits[1] =
h->GetNbinsX()-delta_lo;
503 if ( ihi<h->GetNbinsX() ) ihi++;
516 std::vector<int> limits =
findxrange(
h, symmetric );
517 h->GetXaxis()->SetRange( limits[0], limits[1] );
525 std::vector<int> limits =
findxrange(
h, symmetric );
527 std::vector<double> dlimits(2,0);
529 double dx =
h->GetBinLowEdge(limits[1]+1)-
h->GetBinLowEdge(limits[1]);
531 dlimits[0] =
h->GetBinLowEdge(limits[0]);
532 dlimits[1] =
h->GetBinLowEdge(limits[1]+1)-
dx*1
e-11;
540 h->GetXaxis()->SetRangeUser( limits[0], limits[1] );
545 std::string
findcell( std::string
name,
const std::string&
regex,
const std::string& splitex ) {
549 if ( posex==std::string::npos )
return "";
551 size_t pos =
name.find_last_of( splitex );
553 std::string duff =
name;
555 while (
pos!=std::string::npos &&
pos>posex+
regex.size() ) {
557 pos =
name.find_last_of( splitex );
566 if (
pos!=std::string::npos )
return name.substr( 0,
pos );
579 std::cout <<
"gDirectory::GetName() " <<
gDirectory->GetName() << std::endl;
589 for (
int i=0 ;
i<
tl->GetSize() ;
i++ ) {
591 TKey* tobj = (TKey*)
tl->At(
i);
593 if ( tobj==0 )
continue;
595 if ( std::string(tobj->GetClassName()).find(
"TDirectory")!=std::string::npos ) {
597 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
599 std::string
name = tnd->GetName();
601 if (
name.find(
"run_" )==0 ) {
620 std::vector<std::string> release_data;
622 if ( finput && foutdir ) {
624 TTree*
tree = (TTree*)finput->Get(
"dataTree");
628 clone->Write(
"", TObject::kOverwrite);