|
ATLAS Offline Software
|
Go to the documentation of this file.
25 #include "TDirectory.h"
40 static TFile* fout = 0;
51 int colours[4] = { kBlack, kRed, kBlue, kMagenta };
67 bool contains(
const std::string&
s,
const std::string&
regex ) {
return s.find(
regex)!=std::string::npos; }
74 std::ostream&
operator<<( std::ostream&
s,
const std::vector<T*>&
t ) {
75 for (
size_t i=0 ;
i<
t.size() ;
i++ )
s << *
t[
i] <<
"\n";
81 for (
int i=1 ;
i<=
h->GetNbinsX() ;
i++ ) {
82 double d =
h->GetBinLowEdge(
i+1)-
h->GetBinLowEdge(
i);
83 h->SetBinContent(
i,
h->GetBinContent(
i)/
d );
84 h->SetBinError(
i,
h->GetBinError(
i)/
d );
89 std::ostream&
operator<<( std::ostream&
s,
const std::vector<T>&
t ) {
90 for (
size_t i=0 ;
i<
t.size() ;
i++ )
s <<
t[
i] <<
"\n";
98 for (
int i=
h->GetNbinsX()+1 ;
i-- ; ) {
99 double d =
h->GetBinContent(
i);
100 if (
d!=0 && unset ) {
110 h->SetMinimum(
mn*0.1);
111 h->SetMaximum(
mx*10);
117 if (
h &&
h->GetEntries()>0 &&
h->GetNbinsX()>0 ) {
122 TH1D* nh =
new TH1D(
h->GetName(),
h->GetTitle(),
123 h->GetNbinsX(),
h->GetBinLowEdge(1),
h->GetBinLowEdge(
h->GetNbinsX()+1 ) );
126 TH1D* nh = (TH1D*)
h->Clone();
130 for (
int i=1 ;
i<
h->GetNbinsX()+1 ;
i++ ) {
131 n +=
h->GetBinContent(
i);
132 nh->SetBinContent(
i,
h->GetBinContent(
i) );
144 double vhmax =
h->GetBinContent(1);
145 for (
int i=2 ;
i<
h->GetNbinsX() ;
i++ ) {
146 double vm =
h->GetBinContent(
i);
147 if ( vm>vhmax ) vhmax = vm;
158 const std::string&
t,
159 TKey*
k, TDirectory*
d=0,
160 const std::vector<inode>& in=std::vector<inode>() )
178 s <<
t.m_name <<
" " <<
t.m_type;
225 std::string inspace =
spacer;
229 int deptht =
depth-1;
238 if ( deptht>=0 &&
size_t(deptht)<
directories.size() ) {
259 TList*
tl =
m_dir->GetListOfKeys();
262 for (
int i=
tl->GetSize() ;
i-- ; ) {
264 TKey* tobj = (TKey*)
tl->At(
i);
267 std::vector<inode> nodes;
273 if ( std::string(tobj->GetClassName()).find(
"TDirectory")!=std::string::npos ) {
274 tnd = (TDirectory*)tobj->ReadObj();
276 m_nodes.push_back(
inode( tobj->GetName(), tobj->GetClassName(), tobj, tnd, nodes ) );
285 if ( std::string( tobj->GetName()).find(
patterns[
ip] )!=std::string::npos )
accept =
true;
291 if ( std::string( tobj->GetName()).find(
Patterns[
ip] )==std::string::npos )
accept =
false;
298 m_nodes.push_back(
inode( tobj->GetName(), tobj->GetClassName(), tobj ) );
305 if ( std::string( tobj->GetClassName()).find(
"TH1")!=std::string::npos ) {
306 TH1*
h = (TH1*)tobj->ReadObj();
310 std::cout <<
"\tentries " <<
h->GetEntries() <<
" \tmean " <<
h->GetMean() <<
"\tplot " <<
plot <<
"\t";
319 h->SetMaximum(
hmax(
h)*1.2 );
321 std::string
t = tobj->GetName();
323 if (
t.find(
"____")!=std::string::npos )
t.erase( 0,
t.find(
"___")+4);
324 if (
t.find(
"_FirstTime")!=std::string::npos )
t.erase(
t.find(
"_FirstTime"),
t.size());
326 h->SetTitle(
t.c_str());
338 h->SetMaximum(
ymax );
344 h->DrawCopy(
"samehist");
349 if (
logy ) gPad->SetLogy(
true);
350 gPad->Print( (std::string(tobj->GetName())+
".pdf").c_str() );
359 std::cout << std::endl;
364 std::string cckname = tobj->GetName();
368 std::string tdir =
chop( cckname,
"____" );
370 if ( cckname.size()==0 ) {
371 h->SetName( tdir.c_str() );
378 h->SetName( cckname.c_str() );
386 std::cout << std::endl;
393 if ( cck ) cck->cd();
416 std::vector<std::string>
split( std::string
s,
const std::string&
regex ) {
418 std::vector<std::string>
out;
422 while (
pos!=std::string::npos ) {
423 out.push_back(
s.substr( 0,
pos ) );
444 std::cout <<
t.scan(
depth ) << std::endl;
458 gStyle->SetPadLeftMargin(0.15);
459 gStyle->SetPadBottomMargin(0.15);
461 std::vector<std::string>
files;
463 std::string
dir =
"";
470 for (
int i=1 ;
i<
argc ;
i++ ) {
478 else if (
arg==
"--depth" ) {
482 else if (
arg==
"-d" ) {
486 else if (
arg==
"-p" ) {
490 else if (
arg==
"-v" ) {
494 else if (
arg==
"--min" ) {
498 else if (
arg==
"--max" ) {
502 else if (
arg==
"--entries" ) {
506 else if (
arg==
"-P" ) {
510 else if (
arg==
"--xmax" ) {
514 else if (
arg==
"--xmax" ) {
518 else if (
arg==
"--xmin" ) {
522 else if (
arg==
"--ymin" ) {
526 else if (
arg==
"--ymax" ) {
530 else if (
arg==
"--plot" )
plot =
true;
531 else if (
arg==
"--logy" )
logy =
true;
544 fout =
new TFile(
outfile.c_str(),
"recreate" );
545 std::cout <<
"saving to file: " <<
outfile << std::endl;
549 for (
size_t i=0 ;
i<
files.size() ;
i++ ) {
551 TFile*
f =
new TFile(
files[
i].c_str() );
556 std::cout <<
"closing" << std::endl;
562 std::cout <<
"done" << std::endl;
@ depth
pointing depth of the shower as calculated in egammaqgcld
TDirectory * m_dir
if this node is, itself a directory
std::vector< std::string > directories
std::vector< std::string > patterns
StatusCode accept(const xAOD::Muon *mu)
std::string chop(std::string &s1, const std::string &s2)
std::vector< inode > m_nodes
TCck(TDirectory *d, int depth=0)
double minmean
these patterns are vetoed
bool isvetoed(const std::string &s)
class to keep a directory for each object in a root sort of way, but needed to keep the root objects ...
bool contains(const std::string &s, const std::string ®ex)
does a string contain the substring
std::vector< std::string > Patterns
these patterns are ored
int main(int argc, char **argv)
std::ostream & operator<<(std::ostream &s, const std::vector< T * > &t)
std::vector< inode > scan(int depth=0)
std::vector< inode > m_nodes
double atof(std::string_view str)
Converts a string into a double / float.
inode(const std::string &n, const std::string &t, TKey *k, TDirectory *d=0, const std::vector< inode > &in=std::vector< inode >())
static std::string spacer
void scan(TDirectory *td=0, int depth=0)
std::vector< std::string > split(std::string s, const std::string ®ex)
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
std::vector< std::string > veto
these patterns are anded