no longer adjust the legend if no reference times are to be plotted as we now more properly set the legend size automatically depending on the number of entries
skip TH2 and TProfiles for the moment ...
if we cannot find the reference histogram, try replacing all patterns that are requested in the reference hist name
could simply run gPad->SetLogyx( logx ); but that would interfere with the individual plot setting from the config file
95 std::string output_dir =
"";
99 gStyle->SetPadRightMargin(0.05);
100 gStyle->SetPadTopMargin(0.05);
102 gStyle->SetPadLeftMargin(0.14);
103 gStyle->SetPadBottomMargin(0.14);
111 bool atlasstyle =
false;
112 bool atlaslabel =
false;
116 bool autochains =
false;
118 std::string autopattern =
"";
120 std::vector<std::string> taglabels;
131 std::string frefname =
"";
133 double xoffset = 0.17;
135 bool show_directory =
true;
137 bool norm_width =
true;
141 bool withlumiblock =
false;
143 bool withfractional =
false;
145 std::vector<std::string> replace_list;
148 std::vector<std::string> algorithms;
149 for(
int argnum = 1; argnum <
argc; argnum++){
150 std::string
arg =
argv[argnum];
152 if (
arg ==
"-h" ||
arg ==
"--help") {
155 else if (
arg ==
"-o" ||
arg ==
"--outputfolder") {
156 if (++argnum <
argc) { output_dir =
argv[argnum]; }
159 else if (
arg ==
"-x" ||
arg ==
"--xoffset") {
163 else if (
arg ==
"-t" ||
arg ==
"--tag") {
164 if (++argnum <
argc) {
tag = std::string(
"-") +
argv[argnum]; }
167 else if (
arg ==
"-k" ||
arg ==
"--key") {
168 if (++argnum <
argc) {
key =
argv[argnum] + std::string(
"-"); }
171 else if (
arg ==
"-r" ||
arg ==
"--replace") {
172 if (++argnum <
argc) replace_list.push_back(
argv[argnum] );
174 if (++argnum <
argc) replace_list.push_back(
argv[argnum] );
177 else if (
arg ==
"--logx") {
180 else if (
arg ==
"-np" ||
arg ==
"--nopng") {
183 else if (
arg ==
"-f" ||
arg ==
"--frac" ) {
184 withfractional =
true;
186 else if (
arg ==
"-a" ||
arg ==
"--auto") {
189 else if (
arg ==
"--nodir") {
190 show_directory =
false;
192 else if (
arg ==
"-v" ||
arg ==
"--verbose") {
195 else if (
arg ==
"-lb" ) {
196 withlumiblock =
true;
198 else if (
arg ==
"-nr" ||
arg ==
"--noref") {
201 else if (
arg ==
"-w" ||
arg ==
"--binwidth") {
204 else if (
arg ==
"-as" ||
arg ==
"--atlasstyle") {
207 else if (
arg ==
"-al" ||
arg ==
"--atlaslabel") {
210 else if (
arg ==
"-ap" ||
arg ==
"--autopattern") {
211 if (++argnum <
argc) autopattern =
argv[argnum];
214 else if (
arg ==
"-d" ||
arg ==
"--directory") {
218 else if (
arg ==
"-p" ||
arg ==
"--pattern") {
226 ftest =
new TFile(
file.c_str() );
229 std::cerr <<
"main(): test file " <<
arg <<
" does not exist" << std::endl;
233 else if ( frefname==
"" ) frefname =
arg;
235 algorithms.push_back(
arg);
243 if (ftest == 0 || ( noref==
false && frefname==
"" ) ) {
247 if ( fref == 0 && !noref ) {
250 fref =
new TFile(
file.c_str() );
253 std::cerr <<
"main(): ref file " << frefname <<
" does not exist" << std::endl;
260 gStyle->SetErrorX(0);
262 if ( noref ) fref = ftest;
266 if ( ftest && autochains ) {
270 std::vector<std::string>
dirs;
274 if ( autopattern==
"" ) {
275 for (
unsigned j=0 ; j<
dirs.size() ; j++ ) {
276 if (
verbose ) std::cout <<
"\talgorithm " <<
dirs[j] << std::endl;
277 algorithms.push_back(
dirs[j] );
281 std::cout <<
"autopattern : " << autopattern << std::endl;
282 for (
unsigned j=0 ; j<
dirs.size() ; j++ ) {
283 if (
dirs[j].
find(autopattern)!=std::string::npos ) {
284 algorithms.push_back(
dirs[j] );
285 std::cout <<
"adding " << algorithms.back() << std::endl;
295 if ( output_dir !=
"" ) {
296 if (
mkdir( output_dir.c_str(), 0777 ) ) {
297 if (
exists(output_dir) ) std::cerr <<
"main() directory " << output_dir <<
" aleady exists" << std::endl;
298 else std::cerr <<
"main() could not create directory " << output_dir << std::endl;
306 TDirectory* testtimers = 0;
309 else testtimers = ftest;
311 if (testtimers == 0 ) {
312 std::cerr <<
"main(): can not find timers in test file" << std::endl;
317 TDirectory* reftimers = 0;
320 else reftimers = fref;
322 if (reftimers == 0 ) {
323 std::cerr <<
"main(): can not find timers in ref file" << std::endl;
328 TFile fcck(
"fcck.root",
"recreate" );
343 std::cout <<
"\nhistogram " <<
histograms.at(
histogram) <<
" : with " << algorithms.size() <<
" algorithms" << std::endl;
347 std::string yaxis =
"Entries";
354 if ( !withlumiblock && algorithms[
algorithm].
find(
"LumiBlock")!=std::string::npos )
continue;
356 if ( !withfractional && algorithms[
algorithm].
find(
"Fractional")!=std::string::npos )
continue;
358 std::cout <<
"\nmain() processing algorithm : " << algorithms[
algorithm] << std::endl;
360 TCanvas*
c1 =
new TCanvas(
label(
"canvas-%d",
int(
histogram)).c_str(),
"histogram", 800, 600 );
364 double x2 = xoffset+0.25;
377 std::string xaxis_tmp = xaxis;
389 if (testhist == 0 ) {
390 std::cerr <<
"main(): can not find hist " <<
histname <<
" in test file" << std::endl;
394 std::cout <<
"mean time: " << testhist->GetMean() <<
"\t:: " << testhist->GetName() << std::endl;
396 if ( norm_width )
binwidth( testhist );
399 if ( std::string(testhist->ClassName()).find(
"TH1")==std::string::npos )
continue;
401 testhist->SetName(
tail(algorithms[
algorithm],
"/").c_str() );
409 TH1F* refhist = (
TH1F*)fref->Get(refhistname.c_str());
415 if ( refhist==0 && replace_list.size()>=2 ) {
417 for (
size_t ir=0 ;
ir<replace_list.size()-1 ;
ir+=2 ) {
419 size_t pos = refhistname.find(replace_list[
ir]);
420 if (
pos != std::string::npos ) {
422 while(
pos!=std::string::npos ) {
423 refhistname.replace(
pos, replace_list[
ir].
size(),
"XXXX" );
424 pos = refhistname.find(replace_list[
ir]);
427 pos = refhistname.find(
"XXXX");
428 while(
pos!=std::string::npos ) {
429 refhistname.replace(
pos, 4, replace_list[
ir+1] );
430 pos = refhistname.find(
"XXXX");
436 refhist = (
TH1F*)fref->Get(refhistname.c_str());
441 std::cerr <<
"main(): can not find hist " << refhistname <<
" in ref file" << std::endl;
445 if ( norm_width )
binwidth( refhist );
447 testhist->GetYaxis()->SetTitle(yaxis.c_str());
448 testhist->GetYaxis()->SetTitleOffset(1.5);
450 refhist->GetYaxis()->SetTitle(yaxis.c_str());
451 refhist->GetYaxis()->SetTitleOffset(1.5);
453 testhist->GetXaxis()->SetTitle(xaxis_tmp.c_str());
454 testhist->GetXaxis()->SetTitleOffset(1.5);
456 refhist->GetXaxis()->SetTitle(xaxis_tmp.c_str());
457 refhist->GetXaxis()->SetTitleOffset(1.5);
464 std::string algpname = algorithms[
algorithm];
474 std::string plotname =
key + algpname +
tag;
481 while ( plotname.find(
stub)!=std::string::npos ) {
482 plotname.erase( 0, plotname.find(
stub)+
stub.size() );
485 while ( plotname.find(
'_')==0 ) plotname.erase( 0, 1 );
487 plotname = output_dir + plotname;
489 std::cout <<
"output dir " << output_dir <<
"\tkey " <<
key <<
"\talgname " <<
algname <<
"\ttag " <<
tag << std::endl;
494 std::vector<std::string>
chains;
500 double Nent_ref =
plotable( refhist );
502 if ( fractional ) ylogt =
false;
504 if ( Nent==0 || Nent_ref==0 ) {
506 std::cerr <<
"histograms empty: " << testhist->GetName() << std::endl;
511 testhist->SetTitle(
"");
512 refhist->SetTitle(
"");
515 plots.SetLogy(ylogt);
517 if ( logx )
plots.SetLogx(
true);
519 double rmin =
plots.realmin();
520 double rmax =
plots.realmax();
522 if ( rmin == rmax ) rmin = 0;
525 if ( rmin == 0 ) rmin = rmax*0.0001;
526 double delta = std::log10(rmax)-std::log10(rmin);
527 if ( atlasstyle )
plots.Max( rmax*
std::pow(10,delta*0.15*2*(
chains.size()+taglabels.size()+1.5)) );
532 double delta = rmax-rmin;
535 double pmin = rmin-delta*0.1;
536 if ( pmin>0 )
plots.Min( pmin );
541 std::vector<double>
range =
plots.findxrange();
543 double lower =
range[0];
546 if ( lower<0 ) lower = 0;
552 std::string dirtitle =
dirname;
553 if ( dirtitle.find(
"HLT_")==0 && dirtitle.find(
"__")!=std::string::npos ) dirtitle.erase( dirtitle.find(
"__"), dirtitle.size() );
557 if ( atlasstyle && atlaslabel )
ATLASLabel(0.68, 0.88,
"Internal");
562 if ( logx ) gPad->SetLogx(
true);
564 plots.back().Print( (plotname+
".pdf").c_str() );
565 if ( !nopng )
plots.back().Print( (plotname+
".png").c_str() );
569 std::cout <<
"done algorithm " <<
algorithm <<
" " << algorithms[
algorithm] << std::endl;
581 #ifdef USE_SLOW_ROOT_FILE_DELETION
583 std::cout <<
"deleting ftest" << std::endl;
590 std::cout <<
"deleting fref" << std::endl;
601 std::cout <<
"done" << std::endl;