leave this commented here - now instead of bombing out if we don't specify the reference file, just carry on as if it was not specified at all, so as this changes the external behaviour of the code we want this retained
don't fail anymore if can't open the reference file, now continue without plotting the refereces, instead printing a warning on the plots
we divide the resolutions by these values if we have an "entries" histogram to tell us how many events there are overall
set up the correct reference chain names ...
read config in from a file if requested ...
words can not express the sheer unpleasantness in trying to do anything serious with subpanels
leave this code commented here for the time being ... if ( histo.name()=="pT" || histo.name()=="pT_rec" ) ypos = 0.19;
legends ....
leave these comments here for testing ...
get the actual chain name and track collection from the Chain histogram if present
Actually DO refit the references - if we are adding together many resplots, then the means etc may not even have been calculated
leave this code commented here since we want to know where to change this in the future it was added for a reason, so is useful to keep for now
useful test for debugging ...
leave this code commented here since we want to know where to change this in the future it was added for a reason, so useful to keep for now
debugging ...
rebin if requested ...
leave for documentation purposes ...
again, this changes the external behaviour so we want to leave this "continue" in place, but commented
replace the "/" in the filename so we don't try to make plots in subdirectories by accident
sort out the range settings for the xaxis ...
keep the original equation by way of documentation ...
leave this code commented here since we want to know where to change this in the future it was added for a reason, so it is useful to keep for now
std::exit(-1);
calculate the required range such that the histogram labels won't crowd the points
actually draw the plot here ...
NB: now, we no longer print the individual plots - only the "panels" individual plots can still be printed by creating a "panel" which contains only that plots - in fast the "histos" item that before provided details of the separate plots is now interpreted as a list of single plot panels so this is done for you
debugging ...
546 std::cout <<
"\n---------------------------------\n";
547 std::cout <<
"\n comparitor is off ...\n";
549 if (
argc<4 )
return usage(
argv[0], -1,
"too few arguments");
553 std::string
tag =
"";
554 std::string
key =
"";
556 std::string
dir =
"";
558 std::string ftestname =
"";
559 std::string frefname =
"";
568 std::string defreflabel =
"";
572 std::vector<std::string> usrlabels;
573 bool uselabels =
false;
574 bool addinglabels =
false;
576 std::vector<std::string> taglabels;
577 bool addingtags =
false;
579 bool make_ref_efficiencies =
false;
580 bool refit_resplots =
false;
581 bool refitref_resplots =
false;
583 bool nostats =
false;
584 bool nomeans =
false;
586 bool atlasstyle =
false;
587 bool deleteref =
false;
588 bool nowatermark =
false;
589 bool noplots =
false;
595 bool normref =
false;
596 bool scalepix =
false;
598 bool addchains =
false;
599 bool usechainref =
false;
602 bool RANGEMAP =
false;
603 bool ALLRANGEMAP =
false;
607 std::string atlaslabel_tmp =
"Internal";
610 double scale_eff = -1;
611 double scale_eff_ref = -1;
613 std::string configfile =
"";
621 std::string
regex =
"";
623 std::string patternr =
"";
624 std::string regexr =
"";
626 std::string patternt =
"";
627 std::string regext =
"";
629 std::string basedir =
"";
631 std::string xpattern =
"";
632 std::string xregex =
"";
634 std::vector<std::string>
chains;
635 std::vector<std::string> refchains;
637 bool addingrefchains =
false;
639 std::string mapfile =
"";
641 std::vector<std::string> chainfiles;
649 if (
arg.find(
'-')!=0 && addinglabels ) {
653 usrlabels.push_back(
label );
656 else addinglabels =
false;
658 if (
arg.find(
'-')!=0 && addingrefchains ) {
659 refchains.push_back(
arg );
662 else addingrefchains =
false;
664 if (
arg.find(
'-')!=0 && addingtags ) {
666 std::cout <<
"\tadding tag label: " << taglabels.back() << std::endl;
669 else addingtags =
false;
671 if (
arg==
"-h" ||
arg==
"--help" ) {
674 else if (
arg==
"-c" ||
arg==
"--config" ) {
676 else return usage(
argv[0], -1,
"no config file provided");
678 else if (
arg==
"-t" ||
arg==
"--tag" ) {
680 else return usage(
argv[0], -1,
"no tag provided");
682 else if (
arg==
"-l" ||
arg==
"--labels" ) {
685 else if (
arg==
"-el" ) {
688 else if (
arg==
"-k" ||
arg==
"--key" ) {
690 else return usage(
argv[0], -1,
"no key provided");
692 else if (
arg==
"-m" ||
arg==
"--mapfile" ) {
694 else return usage(
argv[0], -1,
"no mapfile provided");
696 else if (
arg==
"-d" ||
arg==
"--dir" ) {
698 else return usage(
argv[0], -1,
"no directory provided");
700 else if (
arg==
"-b" ||
arg==
"--bdir" ) {
702 else return usage(
argv[0], -1,
"no directory provided");
704 else if (
arg==
"--taglabels" ) {
707 else if (
arg==
"--unscalepix" ) {
710 else if (
arg==
"--scalepix" ) {
713 else if (
arg==
"-ac" ||
arg==
"--addchains" ) {
716 else if (
arg==
"-yrange" ) {
719 else return usage(
argv[0], -1,
"no range specified");
721 else return usage(
argv[0], -1,
"no upper y limit specified");
723 else if (
arg==
"-e" ||
arg==
"--efficiencies" ) {
724 make_ref_efficiencies =
true;
726 else if (
arg==
"-r" ||
arg==
"--refit" ) {
727 refit_resplots =
true;
729 else if (
arg==
"-rr" ||
arg==
"--refitref" ) {
730 refitref_resplots =
true;
732 else if (
arg==
"--oldrms" ) {
735 else if (
arg==
"-nw" ||
arg==
"--nowatermark" ) {
739 else if (
arg==
"--chi2" ) {
742 else if (
arg==
"-ns" ||
arg==
"--nostats" ) {
745 else if (
arg==
"-nm" ||
arg==
"--nomeans" ) {
748 else if (
arg==
"-nt" ||
arg==
"--notitle" ) {
751 else if (
arg==
"-nr" ||
arg==
"--noref" ) {
755 else if (
arg==
"--normref" ) {
758 else if (
arg==
"-rc" ||
arg==
"--refchains" ) {
759 addingrefchains =
true;
761 else if (
arg==
"-uc" ||
arg==
"--usechainref" ) {
764 else if (
arg==
"-nb" ||
arg==
"--nobayes" ) {
767 else if (
arg==
"-es" ||
arg==
"--effscale" ) {
769 else return usage(
argv[0], -1,
"no efficiency scale provided");
771 else if (
arg==
"-er" ||
arg==
"--effscaleref" ) {
773 else return usage(
argv[0], -1,
"no efficiency scale for the reference histograms provided");
775 else if (
arg==
"--ncols" ) {
777 else return usage(
argv[0], -1,
"no number of columns provided");
779 else if (
arg==
"-np" ||
arg==
"--noplots" ) {
782 else if (
arg==
"-C" ||
arg==
"--Cfiles" ) {
785 else if (
arg==
"--deleteref" ) {
788 else if (
arg==
"--nopng" ) {
791 else if (
arg==
"--nopdf" ) {
794 else if (
arg==
"-as" ||
arg==
"--atlasstyle" ) {
797 else if (
arg==
"-q" ||
arg==
"--quiet" ) {
800 else if (
arg==
"-al" ||
arg==
"--atlaslabel" ) {
802 else return usage(
argv[0], -1,
"no label provided");
804 else if (
arg==
"-xo" ||
arg==
"--xoffset" ) {
806 else return usage(
argv[0], -1,
"no xoffset provided");
808 else if (
arg==
"-yp" ||
arg==
"--ypos" ) {
810 else return usage(
argv[0], -1,
"no y position provided");
812 else if (
arg==
"-xe" ||
arg==
"--xerror" ) {
814 else return usage(
argv[0], -1,
"no x error provided");
816 else if (
arg==
"-s" ||
arg==
"--swap" ) {
818 else return usage(
argv[0], -1,
"no patterns provided");
820 else return usage(
argv[0], -1,
"no target pattern provided");
822 else if (
arg==
"--swapt" ) {
824 else return usage(
argv[0], -1,
"no patterns provided");
826 else return usage(
argv[0], -1,
"no target pattern provided");
828 else if (
arg==
"--swapr" ) {
830 else return usage(
argv[0], -1,
"no patterns provided");
832 else return usage(
argv[0], -1,
"no target pattern provided");
834 else if (
arg==
"-sx" ||
arg==
"--swapaxtitles" ) {
836 else return usage(
argv[0], -1,
"no target pattern provided");
838 else return usage(
argv[0], -1,
"no patterns provided");
840 else if (
arg.find(
'-')==0 ) {
841 std::cerr <<
"unknown option: " <<
arg <<
"\n" << std::endl;
845 if ( ftestname==
"" ) ftestname =
arg;
846 else if ( frefname==
"" ) frefname =
arg;
848 std::string
file =
"";
850 if (
arg.find(
":file:")!=std::string::npos ) {
852 chainfiles.push_back(
file );
862 std::cout <<
"file: " <<
file <<
"\tchain: " <<
chain << std::endl;
868 if ( ftestname.empty() ) {
869 std::cerr <<
"main(): test file not specified " << std::endl;
873 if ( !
exists(ftestname) ) {
874 std::cerr <<
"main(): test file " << ftestname <<
" does not exist" << std::endl;
878 std::vector<TFile*> chainTFiles;
882 if ( chainfiles.size()==0 ) ftest_ = TFile::Open( ftestname.c_str() );
885 chainTFiles.resize(chainfiles.size());
886 for (
size_t i=0 ;
i<chainfiles.size() ;
i++ ) {
887 chainTFiles[
i] = TFile::Open( chainfiles[
i].c_str() );
888 if ( chainTFiles[
i] == 0 ) {
889 std::cerr <<
"\tfile: " << chainfiles[
i] <<
" could not be opened" << std::endl;
892 else std::cout <<
"\tchainfiles: " << chainfiles[
i] <<
" " << chainTFiles[
i] << std::endl;
897 if ( noref==
false ) {
898 if ( frefname.empty() ) {
899 std::cerr <<
"main(): ref file not specified " << std::endl;
909 if ( frefname==ftestname ) fref_ = ftest_;
910 else if (
exists(frefname) ) fref_ = TFile::Open( frefname.c_str() );
912 std::cerr <<
"main(): ref file " << frefname <<
" does not exist" << std::endl;
920 if ( chainfiles.size()==0 ) {
922 std::cerr <<
"could not open test file " << ftestname << std::endl;
926 if ( noref==
false && fref_==0 ) {
927 std::cerr <<
"could not open files " << std::endl;
933 defreflabel =
"failed to open reference file";
938 if ( scale_eff == -1 ) scale_eff = 100;
939 if ( scale_eff_ref == -1 ) scale_eff_ref = scale_eff;
942 bool noreftmp = noref;
944 if (
chains.size()==0 )
return usage(
argv[0], -1,
"no chains specified");
947 if ( basedir.size()>0 ) {
948 if ( basedir[basedir.size()-1]!=
'/' ) basedir +=
"/";
952 if ( refchains.size()>0 && refchains.size()!=
chains.size() )
return usage(
argv[0], -1,
"not enough chains specified");
954 if ( refchains.size()==0 ) refchains =
chains;
956 std::vector<std::string> chainref(
chains.size(),
"");
957 std::vector<std::string> chain_name(
chains.size(),
"");
959 std::vector<std::string> refchain(chainref.size(),
"");
963 std::cout <<
argv[0] <<
" options:" << std::endl;
964 std::cout <<
"\tATLAS style: " << ( atlasstyle ?
"true" :
"false" ) << std::endl;
965 std::cout <<
"\tBayesian uncertainties: " << ( bayes ?
"true" :
"false" ) << std::endl;
966 std::cout <<
"\trefit resplot uncertainties: " << ( refit_resplots ?
"true" :
"false" ) << std::endl;
967 std::cout <<
"\tsuppress mean and rms stats: " << ( nostats ?
"true" :
"false" ) << std::endl;
968 if ( !nostats ) std::cout <<
"\tsuppress meanstats: " << ( nomeans ?
"true" :
"false" ) << std::endl;
969 std::cout <<
"\tsuppress png output: " << ( nopng ?
"true" :
"false" ) << std::endl;
970 std::cout <<
"\tsuppress pdf output: " << ( nopdf ?
"true" :
"false" ) << std::endl;
971 std::cout <<
"\tsuppress reference output: " << ( noref ?
"true" :
"false" ) << std::endl;
972 std::cout <<
"\tuse chain references: " << ( usechainref ?
"true" :
"false" ) << std::endl;
973 std::cout <<
"\tpanel ncols: " << ncols << std::endl;
975 if ( usrlabels.size()>0 ) std::cout <<
"\tlabels: " << usrlabels.size() << std::endl;
976 if ( taglabels.size()>0 ) std::cout <<
"\textra text: " << taglabels << std::endl;
979 for (
size_t il=0 ;
il<usrlabels.size() ;
il++ ) {
980 std::cout <<
"usr label[" <<
il <<
"] : " << usrlabels[
il] << std::endl;
983 std::cout <<
"atlas style : " << atlasstyle << std::endl;
991 gROOT->SetStyle(
"Plain");
993 gStyle->SetLineScalePS(1);
997 gStyle->SetErrorX(xerror);
999 gStyle->SetPadLeftMargin(0.15);
1000 gStyle->SetPadBottomMargin(0.15);
1002 gStyle->SetPadRightMargin(0.02);
1003 gStyle->SetPadTopMargin(0.05);
1005 std::cout <<
"Chains: " << std::endl;
1008 if ( usrlabels.size()>0 ) std::cout <<
"labels: " << usrlabels << std::endl;
1010 if ( usrlabels.size()>0 && usrlabels.size()==
chains.size() ) uselabels =
true;
1014 TTree* dataTree = 0;
1015 TString* releaseData =
new TString(
"");
1016 std::vector<std::string> release_data;
1018 if ( !nowatermark && ftest_ ) {
1020 dataTree = (TTree*)ftest_->Get(
"dataTree");
1023 dataTree->SetBranchAddress(
"ReleaseMetaData", &releaseData);
1025 for (
unsigned int i=0;
i<dataTree->GetEntries() ;
i++ ) {
1026 dataTree->GetEntry(
i);
1027 release_data.push_back( releaseData->Data() );
1028 std::cout <<
"main() release data: " << release_data.back() <<
" : " << *releaseData << std::endl;
1033 if ( release_data.size()>0 ) {
1034 if ( release_data.size()>1 ) std::cerr <<
"main() more than one release - using only the first" << std::endl;
1038 std::string
nightly =
chop(release_data[0],
" " );
1041 for (
int ic=0 ;
ic<4 ;
ic++ )
chop(release_data[0],
" " );
1042 release +=
" (" + release_data[0]+
")";
1046 chop( release_data[0],
" " );
1047 release +=
" " +
chop(release_data[0],
" " ) +
")";
1058 std::cout <<
"trying to make directory" << std::endl;
1061 if (
mkdir(
dir.c_str(), 0777 ) ) std::cerr <<
"main() couldn't create directory " <<
dir << std::endl;
1062 else std::cout <<
"main() output will be sent to directory " <<
dir << std::endl;
1066 if ( ftest_==0 && chainTFiles.size()>0 ) fref_ = ftest_ = chainTFiles[0];
1068 TFile* ftest = ftest_;
1069 TFile* fref = fref_;
1071 std::string testrun =
findrun( ftest );
1073 std::string rawrefrun =
"";
1074 std::string refrun =
"";
1076 if ( fref_ ) refrun = rawrefrun =
findrun( fref );
1078 std::cout <<
"testrun: " << testrun <<
"\nrefrun: " << refrun << std::endl;
1080 if ( !testrun.empty() && refrun != testrun ) {
1088 if ( !refrun.empty() ) {
1090 std::string newtag =
"Reference: ";
1092 std::cout <<
"refrun: " << refrun << std::endl;
1095 while ( (
pos=refrun.find(
'_'))!=std::string::npos ) refrun.replace(
pos, 1,
" " );
1098 std::string rawrun = refrun.erase( refrun.find(
"run"), 4 );
1100 if (
contains(frefname, rawrun) ) {
1102 std::string
release = frefname;
1117 taglabels.push_back( newtag );
1119 std::cout <<
"tag labels: " << taglabels << std::endl;
1134 if ( !nowatermark ) {
1136 TH1D* htestev = (TH1D*)ftest->Get(
"event") ;
1137 TH1D* hrefev = (TH1D*)fref->Get(
"event") ;
1139 std::cout <<
"htestev " << htestev <<
" " << hrefev << std::endl;
1141 if ( htestev ) NeventTest = htestev->GetEntries();
1142 if ( hrefev ) NeventRef = hrefev->GetEntries();
1152 if ( NeventTest>1 ) std::cout <<
"Nevents Test: " << NeventTest << std::endl;
1153 if ( NeventRef>1 ) std::cout <<
"Nevents Ref: " << NeventRef << std::endl;
1157 if ( mapfile.empty() ) mapfile = configfile;
1159 if ( !mapfile.empty() ) {
1163 if (
m.isTagDefined(
"ChainMap" ) ) {
1164 std::vector<std::string>
chains =
m.GetStringVector(
"ChainMap" );
1168 for (
size_t i=0 ;
i<
chains.size() ;
i+=2 ) {
1169 chainmap->insert( chainmap_t::value_type(
chains[
i],
chains[
i+1] ) );
1172 std::cout <<
"\nusing chain map:" << std::endl;
1175 std::cout <<
"\t" << itr->first <<
"\t" << itr->second << std::endl;
1182 std::cout <<
"\ncreating chain and reference information ..." << std::endl;
1184 for (
size_t j=0; j<
chains.size(); j++) {
1192 std::cout <<
"chain: " <<
chains[j] <<
"\taddchains: " << addchains << std::endl;
1196 TFile* fftest = ftest;
1198 if ( chainfiles.size()>0 && chainfiles.size()>j ) fftest = chainTFiles[j];
1204 std::string
name = hchain->GetTitle();
1210 std::cout <<
"new chainref: " << chainref[j] << std::endl;
1212 std::string::size_type
pos = chainref[j].find(
":for");
1213 if (
pos!=std::string::npos ) chainref[j].replace(
pos, 4,
"_for" );
1216 chainref[j] = newchain;
1218 std::cout <<
"final chainref: " << chainref[j] << std::endl;
1222 std::cout <<
"chainref: " << chainref[j] << std::endl;
1226 std::cout <<
"name: " <<
name << std::endl;
1229 else chain_name[j] =
name;
1231 if ( chain_name[j] ==
" : " ) chain_name[j] =
"";
1233 std::cout <<
"chain_name: " << chain_name[j] << std::endl;
1238 std::cout <<
"chainref size: " << chainref.size() <<
" " << refchains.size() << std::endl;
1240 for (
size_t j=0 ; j<chainref.size() ; j++ ) {
1241 std::cout <<
"chainref: " << chainref[j] <<
" :: " << refchains[j] << std::endl;
1247 if ( !patternr.empty() ) {
1248 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], patternr, regexr );
1249 else refchain[j] =
fullreplace( refchains[j], patternr, regexr );
1252 std::cout <<
"refchain: " << refchain[j] << std::endl;
1255 std::cout <<
"done chains" << std::endl;
1259 std::vector<Panel> panels;
1266 std::vector<int> ccolours;
1267 std::vector<int> cstyles;
1269 std::vector<std::string> ctags;
1270 std::vector<std::string> ctaglabels;
1273 std::cout <<
"\n" <<
argv[0] <<
"\tconfigfile: " << configfile << std::endl;
1275 bool use_file_config =
false;
1277 if ( configfile!=
"" ) {
1279 if (
exists(configfile) ) {
1281 std::cout <<
argv[0] <<
":\treading configuration file " << configfile << std::endl;
1288 if (
rc.isTagDefined(
"histos" ) ) {
1290 std::cout <<
argv[0] <<
":\treading histogram configuration from file " << configfile << std::endl;
1292 use_file_config =
true;
1294 std::vector<std::string> raw_input =
rc.GetStringVector(
"histos" );
1296 for (
size_t iraw=0 ; iraw<raw_input.size() ; iraw += 6) {
1300 panels.push_back(
p );
1305 std::cout <<
"searching for panels" << std::endl;
1309 if (
rc.isTagDefined(
"panels" ) ) {
1311 std::cout <<
argv[0] <<
":\treading histogram panel configuration from file " << configfile << std::endl;
1313 use_file_config =
true;
1315 std::vector<std::string> panel_config =
rc.GetStringVector(
"panels" );
1317 std::vector<string> panel_columns;
1319 if (
rc.isTagDefined(
"panel_columns") ) {
1320 panel_columns =
rc.GetStringVector(
"panel_columns" );
1321 if ( panel_columns.size()%2 )
return usage(
argv[0], -1,
"incorrect panel settings" );
1325 for (
size_t ipanel=panel_config.size() ; ipanel-- ; ) {
1327 std::vector<std::string> raw_input =
rc.GetStringVector( panel_config[ipanel] );
1331 if ( panel_columns.size() ) {
1333 if ( itr!=panel_columns.end() ) tncols =
std::atoi( (++itr)->c_str() );
1336 Panel p( panel_config[ipanel], tncols );
1339 for (
size_t iraw=0 ; iraw<raw_input.size() ; iraw += 6 )
p.push_back(
HistDetails( &(raw_input[iraw]) ) );
1341 panels.push_back(
p );
1347 if (
rc.isTagDefined(
"Bands" ) &&
rc.isTagDefined(
"Labels" ) ) {
1348 bnd =
bands(
rc.GetVector(
"Bands"),
rc.GetStringVector(
"Labels" ) );
1352 if (
rc.isTagDefined(
"Colours") ) ccolours =
rc.GetIntVector(
"Colours");
1353 if (
rc.isTagDefined(
"Styles") ) cstyles =
rc.GetIntVector(
"Styles");
1354 if (
rc.isTagDefined(
"Tags") ) ctags =
rc.GetStringVector(
"Tags");
1355 if (
rc.isTagDefined(
"TagLabels") ) ctaglabels =
rc.GetStringVector(
"TagLabels");
1356 if (
rc.isTagDefined(
"TagLabels") ) usrlabels =
rc.GetStringVector(
"TagLabels");
1358 if (
rc.isTagDefined(
"Styles") ) {
1359 for (
size_t is=0 ; is<cstyles.size() && is<6 ; is++ ) {
1368 std::cout <<
argv[0] <<
"\tuserlabels :" << usrlabels <<
":" << std::endl;
1372 if (
rc.isTagDefined(
"RANGEMAP") ) RANGEMAP =
true;
1373 if (
rc.isTagDefined(
"ALLRANGEMAP") ) ALLRANGEMAP =
true;
1375 std::cout <<
"Extra: " <<
rc.isTagDefined(
"Extra") << std::endl;
1377 if (
rc.isTagDefined(
"Extra") ) taglabels.push_back(
fullreplace(
rc.GetString(
"Extra"),
"__",
" " ) );
1382 std::cerr <<
argv[0] <<
":\t config file not found: " << configfile << std::endl;
1388 if ( !use_file_config ) {
1390 std::cout <<
"using default panels" << std::endl;
1404 scale_eff_ref = 100;
1410 size_t nphist[3] = { 4, 4, 10 };
1412 std::string pnames[3] = {
"eff",
"res",
"diff" };
1414 for (
size_t ip=0 ;
ip<3 ;
ip++ ) {
1416 for (
size_t iraw=0 ; iraw<nphist[
ip] ; iraw++ )
p.push_back(
HistDetails( inpanels[
ip][iraw] ) );
1417 panels.push_back(
p );
1423 std::cout <<
"taglabels" << std::endl;
1425 for (
size_t it=0 ;
it<taglabels.size() ;
it++ ) std::cout << taglabels[
it] << std::endl;
1428 std::cout <<
"\npanels: " << panels.size() << std::endl;
1430 if ( panels.size()==0 )
return usage(
argv[0], -1,
"no panels to plot");
1432 for (
size_t ip=0 ;
ip<panels.size() ;
ip++ ) std::cout << panels[
ip] << std::endl;
1437 gStyle->SetPadRightMargin(0.05);
1438 gStyle->SetPadTopMargin(0.05);
1440 const Int_t Number = 3;
1441 Double_t
Red[Number] = { 0.00, 0.00, 1.00};
1442 Double_t
Green[Number] = { 0.00, 5.00, 1.00};
1443 Double_t Blue[Number] = { 0.00, 0.50, 0.00};
1444 Double_t Length[Number] = { 0.00, 0.50, 1.00 };
1446 TColor::CreateGradientColorTable(Number,Length,
Red,
Green,Blue,
nb);
1448 else gStyle->SetPalette(1);
1450 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1452 double rightmargin = gStyle->GetPadRightMargin();
1453 gStyle->SetPadRightMargin(0.1);
1457 gStyle->SetPadRightMargin(rightmargin);
1461 for (
size_t ipanel=0 ; ipanel<panels.size() ; ipanel++ ) {
1463 Panel& panel = panels[ipanel];
1465 std::cout <<
"\n\n---------------------------------------------\n";
1467 std::cout << panel <<
"\n" << std::endl;
1469 int ncolsp = panel.
ncols();
1470 int nrowsp = panel.
nrows();
1474 std::cout <<
"\nncols: " << ncolsp <<
"\tnrows: " << nrowsp << std::endl;
1476 bool multipanel = ( panel.
size() > 1 );
1478 if ( panel.
size()==0 ) {
1479 std::cout <<
"panel empty: " << panel.
name() << std::endl;
1485 if ( panel.
size()>4 ) gStyle->SetLineScalePS(0.5);
1487 if ( multipanel ) extraw = 1.05;
1489 TCanvas* tc =
new TCanvas(
"tc",
"", extraw*ncolsp*800, nrowsp*600 );
1493 const std::string& atlaslabel = atlaslabel_tmp;
1498 gStyle->SetLineScalePS(1);
1514 tc->Divide( ncolsp, nrowsp, 0.0001, 0.0003 );
1520 std::string plotname =
"";
1522 for (
size_t i=0 ;
i<panel.
size() ;
i++ ) {
1526 bool drawmeans =
false;
1527 bool drawresiduals =
true;
1530 if (
contains(
histo.detail(),
"-residual") ) drawresiduals =
false;
1532 std::string xaxis =
histo.xtitle();
1533 std::string yaxis =
histo.ytitle();
1535 if ( !xregex.empty() ) {
1536 size_t pos = xaxis.find(xregex);
1537 if (
pos!=std::string::npos ) xaxis.replace(
pos, xregex.size(), xpattern );
1538 pos = yaxis.find(xregex);
1539 if (
pos!=std::string::npos ) yaxis.replace(
pos, xregex.size(), xpattern );
1549 bool d0rebin_flag =
false;
1562 int npanel = nrowsp*(
i/nrowsp) +
i%nrowsp + 1 ;
1564 std::cout <<
"panel: panel: " << panel.
name() <<
"\tsubpanel: " << npanel << std::endl;
1566 if ( multipanel ) tc->cd( npanel );
1574 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1576 std::cout <<
"main() processing histo[" <<
i <<
"] " << (
i<10 ?
" " :
"" ) <<
histo.name() <<
"\t" <<
histo.xaxis() << std::endl;
1584 std::string noreflabel=defreflabel;
1598 if ( ypos>0.5 ) ypos = 0.85;
1602 if ( ypos_arg!=0 ) ypos = ypos_arg;
1604 double xpos_original = xpos;
1608 if ( xinfo.
offset() != 0 ) {
1610 std::cout <<
"HA ! xinfo.offset: " << xinfo.
offset() << std::endl;
1617 if ( yinfo.
offset() != 0 ) {
1619 std::cout <<
"HA ! yinfo.offset: " << yinfo.
offset() << std::endl;
1629 size_t Nrows =
chains.size();
1631 if ( ALLRANGEMAP || (RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos && ccolours.size() ) )
1632 Nrows = ( Nrows < ccolours.size() ? Nrows : ccolours.size() );
1634 int Nlines = Nrows + taglabels.size();
1636 std::vector<double> ypositions;
1638 double deltay = (Nrows*0.055-0.005)/Nrows;
1641 double yhi = ypos-0.01;
1643 if ( ypos>0.5 )
ylo -= Nlines*deltay;
1644 else yhi += Nlines*deltay;
1646 ypositions.reserve(Nlines);
1647 for (
int ilines=0 ; ilines<Nlines ; ilines++ ) {
1648 ypositions.push_back(
yhi - deltay*(ilines+0.5) );
1659 Legend legend_eff( xpos, xpos+0.1,
ylo,
ylo+Nrows*0.06-0.005 );
1662 std::vector<std::string>
Mean;
1663 std::vector<std::string>
RMS;
1668 std::vector<std::string> Chi2;
1669 std::vector<std::string> MeanRef;
1670 std::vector<std::string> RMSRef;
1680 bool power_set =
false;
1688 for (
unsigned int j=0; j<
chains.size(); j++) {
1690 TFile* fftest = ftest;
1691 TFile* ffref = fref;
1693 if ( chainfiles.size()>0 && chainfiles.size()>j ) ffref = fftest = chainTFiles[j];
1698 std::cout <<
"chain: " <<
chains[j] <<
"\taddchains: " << addchains << std::endl;
1699 std::cout <<
"chainref: " << chainref[j] << std::endl;
1711 TGraphAsymmErrors* tgtest = 0;
1713 std::cout <<
"refchain.size() " << refchain.size() << std::endl;
1715 std::cout <<
"refchain: " << refchain[j] << std::endl;
1719 gPad->SetRightMargin(0.03);
1723 gPad->SetRightMargin(0.13);
1729 h2test->GetYaxis()->SetTitleOffset(1.55);
1730 h2test->GetXaxis()->SetTitleOffset(1.5);
1731 h2test->GetXaxis()->SetTitle(xaxis.c_str());
1732 h2test->GetYaxis()->SetTitle(yaxis.c_str());
1738 std::cout << xinfo << std::endl;
1739 std::cout << yinfo << std::endl;
1742 h2test->GetYaxis()->SetRangeUser( yinfo.
lo(), yinfo.
hi() );
1748 h2test->GetXaxis()->SetRangeUser( xinfo.
lo(), xinfo.
hi() );
1756 h2test->DrawCopy(
"colz");
1758 if (
histo.detail().find(
"logz")!=std::string::npos ) gPad->SetLogz(
true);
1759 else gPad->SetLogz(
false);
1765 bool bsigma =
false;
1771 std::cout <<
"\trefitting: " <<
histo.name() << std::endl;
1776 std::string tmp_ =
histo.name();
1779 if ( bsigma )
base =
chop( tmp_,
"/sigma" );
1780 if ( bmean )
base =
chop( tmp_,
"/mean" );
1784 std::cout <<
"ffref " << ffref << std::endl;
1787 if ( ffref ) href2d_ = Get<TH2D>( *ffref,
chains[j]+
"/"+
base+
"/2d", testrun );
1789 if ( htest2d_==0 )
continue;
1790 if ( !noreftmp && href2d_==0 ) noreftmp =
true;
1795 Resplot rtest(
"tmp", htest2d_ );
1797 if ( rtest.finalised() ) {
1806 if ( bsigma ) {
htest = (
TH1F*)rtest.Sigma()->Clone(
"rtest_sigma");
htest->SetDirectory(0); }
1807 if ( bmean ) {
htest = (
TH1F*)rtest.Mean()->Clone(
"rtest_mean");
htest->SetDirectory(0); }
1810 std::cerr <<
"missing test histogram: " << (refchain[j]+
" / "+
histo.name()) <<
" " <<
htest <<
"(test)" << std::endl;
1821 if ( refitref_resplots ) {
1823 Resplot rref(
"tmp", href2d_ );
1825 if ( rref.finalised() ) {
1834 if ( bsigma ) { hreft = (
TH1F*)rref.Sigma()->Clone(
"rref_sigma"); hreft->SetDirectory(0); }
1835 if ( bmean ) { hreft = (
TH1F*)rref.Mean()->Clone(
"rref_mean"); hreft->SetDirectory(0); }
1839 hreft =
Get( *ffref, refchain[j]+
"/"+
histo.name(), rawrefrun, chainmap );
1841 std::cerr <<
"ERROR: could not find " << (refchain[j]+
"/"+
histo.name()) << std::endl;
1846 if ( !noreftmp && hreft==0 ) {
1847 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+
histo.name()) <<
" " <<
htest <<
"(ref)" << std::endl;
1851 noreflabel=
"reference not found";
1859 href->SetDirectory(0);
1870 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1874 std::string reghist =
histo.name();
1876 std::cout <<
"hist: " << (
chains[j]+
"/"+reghist) <<
"\tftest " << ftest << std::endl;
1880 std::cout <<
"hist: " <<
htest << std::endl;
1882 std::cout << xaxis << std::endl;
1885 std::cerr <<
"missing test histogram: " << (
chains[j]+
" / "+reghist) <<
" " <<
htest<< std::endl;
1891 std::cout <<
"hreft: " << hreft << std::endl;
1893 if ( ffref ) hreft =
Get( *ffref, refchain[j]+
"/"+reghist, rawrefrun, chainmap );
1894 else noreftmp =
true;
1896 std::cout <<
"hreft: " << hreft << std::endl;
1898 if ( std::string(
htest->ClassName()).find(
"TH2")!=std::string::npos ) {
1899 std::cout <<
"Class TH2: " <<
htest->GetName() << std::endl;
1903 if ( std::string(
htest->ClassName()).find(
"TH1")!=std::string::npos ) {
1904 std::cout <<
"Class TH1: " <<
htest->GetName() << std::endl;
1906 else if ( std::string(
htest->ClassName()).find(
"TProfile")!=std::string::npos ) {
1907 std::cout <<
"Class TProf: " <<
htest->GetName() << std::endl;
1912 if ( !noreftmp && hreft==0 ) {
1913 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+reghist)
1914 <<
" " << hreft << std::endl;
1917 noreflabel=
"reference not found";
1926 href->SetDirectory(0);
1933 std::cout <<
" \tget " << (
chains[j]+
"/"+reghist) <<
"\thtest " <<
htest << std::endl;
1934 std::cout <<
" \tget " << (refchain[j]+
"/"+reghist) <<
"\thref " <<
href << std::endl;
1936 if (
htest==0 )
continue;
1938 if ( !noreftmp &&
href==0 ) {
1943 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1947 std::cout <<
"rebin: " <<
hname <<
"\t" <<
rebin << std::endl;
1950 for (
int ip=0 ;
ip<10 ;
ip++ ) std::cout << std::endl;
1956 std::cout <<
"Rebinning histogram: " <<
histo.name() << std::endl;
1957 if (
htest->GetNbinsX()>500 )
htest->Rebin(10);
1963 if (
histo.name().find(
"zed_eff")!=std::string::npos ) {
1964 if (
htest->GetNbinsX()>100 )
htest->Rebin(5);
1969 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1971 if ( scalepix && std::string(
htest->GetName()).find(
"npix")!=std::string::npos )
Scale(
htest,0.5);
1972 if ( scalepix &&
href && std::string(
htest->GetName()).find(
"npix")!=std::string::npos )
Scale(
href,0.5);
1974 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1977 htest->SetTitle(
"");
1981 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1985 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1987 if ( make_ref_efficiencies ) {
1995 std::string effhist =
histo.name();
1999 TH1F* hrefnumt =
Get( *ffref, refchain[j]+
"/"+effhist+
"_n", rawrefrun, chainmap, &
savedhistos );
2001 if ( !noreftmp && hrefnumt!=0 ) {
2002 hrefnum = (
TH1F*)hrefnumt->Clone();
2003 hrefnum->SetDirectory(0);
2015 std::string effhist =
histo.name();
2019 if (
rebin!=1 ) std::cout << effhist <<
"\trebin: " <<
rebin << std::endl;
2024 std::cout <<
"1: Bayesian error calculation " << htestnum <<
" " << htestden <<
"\tscale " << scale_eff << std::endl;
2026 if ( htestnum && htestden ) {
2028 if ( d0rebin_flag ) {
2029 htestnum =
d0rebin( htestnum );
2030 htestden =
d0rebin( htestden );
2032 else if (
rebin!=1 ) {
2037 std::cout <<
"test histogram name: : " << htestnum->GetName() <<
"\txaxis: " << xaxis <<
"\t" << std::endl;
2040 if ( std::string(htestnum->GetName()).find(
"ntrax_eff")!=std::string::npos ) {
2054 std::cout <<
"rebin " <<
histo.name() << std::endl;
2060 std::cout <<
"rebin " <<
histo.name() << std::endl;
2067 if ( RANGEMAP && (effhist.find(
"ET")!=std::string::npos ) ) {
2068 std::cout <<
"\trange: " << j <<
" " <<
htest << std::endl;
2075 tgtest =
e.Bayes(scale_eff);
2079 std::cout <<
"effhist: " << effhist << std::endl;
2085 std::cout <<
"recalculating reference efficiencies ..." << std::endl;
2089 std::cout <<
"doin ..." << std::endl;
2091 TH1F* hrefnum =
Get( *ffref, refchain[j]+
"/"+
histo.name()+
"_n", rawrefrun, chainmap );
2093 TH1F* hrefden =
Get( *ffref, refchain[j]+
"/"+
histo.name()+
"_d", rawrefrun, chainmap );
2095 std::cout <<
"2. Bayesian error calculation " << htestnum <<
" " << htestden <<
"\tscale " << scale_eff << std::endl;
2096 std::cout <<
"3. Bayesian error calculation " << hrefnum <<
" " << hrefden <<
"\tscale " << scale_eff_ref << std::endl;
2099 if ( hrefnum && hrefden ) {
2101 if ( d0rebin_flag ) {
2105 else if (
rebin!=1 ) {
2124 std::cout <<
" no test histogram : " << (
chains[j]+
"/"+
histo.name()) << std::endl;
2128 if ( !noreftmp &&
href==0 ) {
2129 std::cout <<
" no ref histogram : " << (
chains[j]+
"/"+
histo.name()) << std::endl;
2132 noreflabel=
"reference not found";
2139 htest->GetYaxis()->SetTitleOffset(1.55);
2140 htest->GetXaxis()->SetTitleOffset(1.5);
2141 htest->GetXaxis()->SetTitle(xaxis.c_str());
2142 htest->GetYaxis()->SetTitle(yaxis.c_str());
2145 href->GetYaxis()->SetTitleOffset(1.5);
2146 href->GetXaxis()->SetTitleOffset(1.5);
2147 href->GetXaxis()->SetTitle(xaxis.c_str());
2148 if (
contains(yaxis,
"Efficiency") && !
contains(yaxis,
"%") && scale_eff==100 )
href->GetYaxis()->SetTitle((yaxis+
" [%]").c_str());
2149 else href->GetYaxis()->SetTitle(yaxis.c_str());
2152 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2157 double xm =
htest->GetMean();
2160 double lxm = std::log10(xm);
2161 int newbins =
int(0.5+xm/
std::pow(10,
int(lxm)))*
pow(10,
int(lxm));
2162 int nrebin =
int( (newbins+5)/10 );
2165 std::cout <<
"rebin: " <<
htest->GetName() <<
"\tbins: " << nrebin << std::endl;
2166 htest->Rebin(nrebin);
2169 href->Rebin(nrebin);
2177 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2180 if ( plotname ==
"" ) {
2183 htest->SetTitle(
"");
2188 htest->SetTitle(
"");
2193 htest->SetTitle(
"");
2198 htest->SetTitle(
"");
2203 htest->SetTitle((
"FTK "+
histo.name()).c_str());
2208 plotname +=
histo.name();
2217 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2230 if ( collection.find(
"_InDet")!=std::string::npos ) collection.erase( 0, collection.find(
"_InDet")+1 );
2231 if ( actual_chain.find(
"_InDet")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_InDet") );
2234 std::cout <<
"raw: " <<
chains[j] << std::endl;
2236 std::cout <<
"track collection: " << collection << std::endl;
2237 std::cout <<
"actual chain: " << actual_chain << std::endl;
2242 actual_chain = std::regex_replace( actual_chain,
std::regex(
"_HLT_IDTrack.*" ),
"" );
2244 collection = std::regex_replace( collection,
std::regex(
".*HLT_IDTrack_"),
"IDTrack " );
2245 collection = std::regex_replace( collection,
std::regex(
"IDTrack "),
"" );
2246 collection = std::regex_replace( std::regex_replace( collection, rx,
"" ),
rx1,
"" );
2248 if ( actual_chain.find(
"HLT_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"HLT_IDTrack_"), 12 );
2249 if ( actual_chain.find(
"_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_IDTrack_"), 9 );
2250 if ( actual_chain.find(
"IDTrack")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"IDTrack"), 7 );
2251 if ( actual_chain.find(
"_idperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_idperf"), 7 );
2252 if ( actual_chain.find(
"_bperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_bperf"), 6 );
2253 if ( actual_chain.find(
"_boffperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_boffperf"), 9 );
2254 if ( actual_chain.find(
"_HLT_")!=std::string::npos ) actual_chain.replace( actual_chain.find(
"_HLT_"), 5,
" " );
2255 if ( actual_chain.find(
"HLT_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"HLT_"), 4 );
2257 if ( collection.find(
"_IDTrkNoCut")!=std::string::npos ) collection.erase( collection.find(
"_IDTrkNoCut"), 11 );
2258 if ( collection.find(
"xAODCnv")!=std::string::npos ) collection.erase( collection.find(
"xAODCnv"), 7 );
2259 if ( collection.find(
"HLT_IDTrack_")!=std::string::npos ) collection.erase( collection.find(
"HLT_IDTrack_"), 12 );
2260 if ( collection.find(
"HLT_IDTrack")!=std::string::npos ) collection.erase( collection.find(
"HLT_IDTrack"), 11 );
2261 if ( collection.find(
"Tracking")!=std::string::npos ) collection.replace( collection.find(
"Tracking"), 8,
"Trk" );
2262 if ( collection.find(
"InDetTrigTrk_")!=std::string::npos ) collection.erase( collection.find(
"InDetTrigTrk_"), 13 );
2263 if ( collection.find(
"HLT_xAODTracks_")!=std::string::npos ) collection.erase( collection.find(
"HLT_xAODTracks_"), 15 );
2264 if ( collection.find(
"_HLT_")!=std::string::npos ) collection.replace( collection.find(
"_HLT_"), 5,
" " );
2265 if ( collection.find(
"HLT_")!=std::string::npos ) collection.erase( collection.find(
"HLT_"), 4 );
2268 if ( actual_chain.size()>30 ) {
2269 size_t pos = actual_chain.find_last_of(
"_");
2270 while (
pos!=std::string::npos && actual_chain.size()>30 ) {
2271 actual_chain.erase(
pos, actual_chain.size()-
pos );
2272 actual_chain+=
"...";
2273 pos = actual_chain.find_last_of(
"_");
2277 std::string
c = actual_chain +
" : " + collection;
2279 std::cout <<
"track collection: " << collection <<
" <-" << std::endl;
2280 std::cout <<
"actual chain: " << actual_chain <<
" <-" << std::endl;
2286 std::cout <<
"use label: " <<
c <<
"\tchains size " <<
chains.size() <<
"\t" << usrlabels.size() << std::endl;
2288 std::cout <<
"chains.size() " <<
chains.size() <<
" " << j << std::endl;
2289 std::cout <<
"chains.size() " <<
chains.size() <<
" " << j << std::endl;
2291 std::cout <<
"chains[j] : " << j <<
" " <<
chains[j] << std::endl;
2293 std::cout <<
"userlabels.size() " << usrlabels.size() << std::endl;
2295 if ( usrlabels.size() < j+1 ) {
2296 if ( usrlabels.size()!=0 ) std::cerr <<
"userlabels not large enough - not using userlabels" << std::endl;
2298 else c = usrlabels[ j ];
2300 std::cout <<
"use label: c: " <<
c << std::endl;
2306 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2310 std::cout <<
"\n\n\n\nxaxis: " << xaxis << std::endl;
2314 if ( ALLRANGEMAP || xaxis.find(
"p_{T}")!=std::string::npos || xaxis.find(
"E_{T}")!=std::string::npos ) {
2316 if ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) {
2321 if ( RANGEMAP || ALLRANGEMAP ) {
2325 std::cout <<
"\n\n\nctags " << ctags.size() <<
"\n\n" << std::endl;
2327 for (
size_t ic=0 ;
ic<ctags.size() ;
ic++ ) {
2331 std::cout <<
"\n\nic: " <<
ic <<
" " << ctags[
ic] <<
" " << ccolours[
ic] <<
"\n\n" << std::endl;
2334 std::cout <<
"\ttag " << ctags[
ic] <<
" \tcolour: " << ccolours[
ic] <<
"\tstyle: " << cstyles[
ic] << std::endl;
2335 htest->SetLineColor( ccolours[
ic] );
2336 htest->SetMarkerColor( ccolours[
ic] );
2337 htest->SetMarkerStyle( cstyles[
ic] );
2340 tgtest->SetLineColor(
htest->GetMarkerColor());
2341 tgtest->SetMarkerStyle(
htest->GetMarkerStyle());
2342 tgtest->SetMarkerColor(
htest->GetMarkerColor());
2350 std::cout <<
"test: " <<
chains[j] <<
"chains colour: " <<
htest->GetMarkerColor() << std::endl;
2355 std::cout <<
"movin' on ..." << std::endl;
2357 std::cout <<
"chain: " <<
chains[j] <<
" \t marker colour: " <<
htest->GetMarkerColor() << std::endl;
2361 std::cout <<
"Plotter marker : " <<
htest->GetMarkerColor() <<
" " <<
htest->GetMarkerStyle() << std::endl;
2366 std::cout <<
"using label: " <<
c << std::endl;
2370 if ( ALLRANGEMAP || ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) )
plots.back().max_entries( ccolours.size() );
2372 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2374 if ( make_ref_efficiencies ) {
2376 if ( htestnum && hrefnum ) {
2381 double range =
h->GetMaximum()-
h->GetMinimum();
2383 if (
range<0.2*scale_eff ) {
2385 double max =
int( (
h->GetMaximum() + 20)*0.1 )*0.1*scale_eff;
2386 double min =
int( (
h->GetMinimum() - 10)*0.1 )*0.1*scale_eff;
2388 if (
max>1*scale_eff )
max = 1.02*scale_eff;
2396 plots_eff.push_back(
Plotter(
e.Hist(), 0,
c ) );
2406 double mean_95 =
htest->GetMean();
2407 double dmean_95 =
htest->GetMeanError();
2408 double rms_95 =
htest->GetRMS();
2409 double drms_95 =
htest->GetRMSError();
2411 Mean.push_back(
label(
" mean = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
2412 RMS.push_back(
label(
" rms = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
2420 xpos = xpos_original;
2422 std::cout <<
"calculating resolutions : " <<
histo.name() <<
" " <<
htest->GetName() << std::endl;
2426 double mean_95 = d95->GetParameter(1);
2427 double dmean_95 = d95->GetParError(1);
2428 double rms_95 = d95->GetParameter(2);
2429 double drms_95 = d95->GetParError(2);
2431 std::cout <<
"\t\t" <<
histo.name()
2432 <<
"\tmean: " << mean_95 <<
" +- " << dmean_95
2433 <<
"\trms: " << rms_95 <<
" +- " << drms_95 << std::endl;
2438 for (
int ip=-2 ;
ip<9 ;
ip++ ) {
2439 if ( std::fabs(mean_95) >=
std::pow( 10.,
double(-
ip) ) ) {
2445 for (
int ip=-2 ;
ip<9 ;
ip++ ) {
2446 if ( std::fabs(rms_95) >=
std::pow( 10.,
double(-
ip) ) ) {
2455 std::cout <<
"\t\t" <<
histo.name()
2456 <<
"\tmean: " << mean_95 <<
" +- " << dmean_95 <<
" : pow " << mean_power
2457 <<
"\trms: " << rms_95 <<
" +- " << drms_95 <<
" : pow " << rms_power << std::endl;
2460 if ( mean_power == 0 ) {
2461 Mean.push_back(
label(
"mean_{95} = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
2464 Mean.push_back(
label(
"mean_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
2465 mean_95*
std::pow(10.,
double(mean_power)), dmean_95*
std::pow(10,
double(mean_power)), -mean_power ) );
2469 if ( rms_power == 0 ) {
2470 RMS.push_back(
label(
"rms_{95} = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
2473 RMS.push_back(
label(
"rms_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
2474 rms_95*
std::pow(10.,
double(rms_power)), drms_95*
std::pow(10,
double(rms_power)), -rms_power ) );
2480 double mean_95ref = d95ref->GetParameter(1);
2481 double dmean_95ref = d95ref->GetParError(1);
2482 double rms_95ref = d95ref->GetParameter(2);
2483 double drms_95ref = d95ref->GetParError(2);
2485 std::cout <<
"\t\t" <<
histo.name()
2486 <<
"\tmean ref: " << mean_95ref <<
" +- " << dmean_95ref <<
" : pow " << mean_power
2487 <<
"\trms ref: " << rms_95ref <<
" +- " << drms_95ref <<
" : pow " << rms_power << std::endl;
2489 if ( mean_power == 0 ) {
2490 MeanRef.push_back(
label(
"mean_{95} ref = %4.2lf #pm %4.2lf", mean_95ref, dmean_95ref) );
2493 MeanRef.push_back(
label(
"mean_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
2494 mean_95ref*
std::pow(10,
double(mean_power)), dmean_95ref*
std::pow(10,
double(mean_power)), -mean_power ) );
2499 if ( rms_power == 0 ) {
2500 RMSRef.push_back(
label(
"rms_{95} ref = %4.2lf #pm %4.2lf", rms_95ref, drms_95ref ) );
2503 RMSRef.push_back(
label(
"rms_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
2504 rms_95ref*
std::pow(10,
double(rms_power)), drms_95ref*
std::pow(10,
double(rms_power)), -rms_power ) );
2527 if ( !noreftmp && normref &&
2536 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2543 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2546 plots.sortx( xinfo );
2548 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2561 rmin =
plots.realmin();
2562 rmax =
plots.realmax();
2567 int csize =
chains.size() + taglabels.size() + ( atlasstyle ? 1 : 0 );
2569 if ( yinfo.
log() && rmin>0 && rmax>0 ) {
2572 double delta = std::log10(rmax)-std::log10(rmin);
2577 yminset = rmin*
std::pow(10,-delta*0.1);
2579 double newdelta = std::log10(rmax) - std::log10(yminset) + 0.05*delta;
2581 if ( csize<10 ) ymaxset = rmin*
std::pow(10,newdelta/(1-0.07*csize));
2582 else ymaxset = rmin*
std::pow(10,newdelta*2);
2584 if ( yminset!=yminset ) {
2585 std::cerr <<
" range error " << delta <<
" " << yminset <<
" " << ymaxset <<
"\t(" << rmin <<
" " << rmax <<
")" << std::endl;
2599 double delta = rmax-rmin;
2601 yminset = rmin-0.1*delta;
2603 if ( rmin>=0 && yminset<=0 ) yminset = 0;
2605 double newdelta = rmax - yminset + 0.05*delta;
2607 if ( csize<10 ) ymaxset = yminset + newdelta/(1-0.09*csize);
2608 else ymaxset = yminset + newdelta*2;
2611 double delta = rmax-rmin;
2613 ymaxset = rmax+0.1*delta;
2615 double newdelta = ymaxset - rmin - 0.05*delta;
2617 if ( csize<10 ) yminset = ymaxset - newdelta/(1-0.09*csize);
2618 else yminset = ymaxset - newdelta*2;
2620 if ( rmin>=0 && yminset<=0 ) yminset = 0;
2629 yminset = yinfo.
lo();
2630 ymaxset = yinfo.
hi();
2634 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2643 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2645 if ( yminset>yinfo.
lo() ) yminset = yinfo.
lo();
2646 if ( ymaxset<yinfo.
hi() ) ymaxset = yinfo.
hi();
2652 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2660 if ( ymaxset!=0 || yminset!=0 ) {
2662 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2664 plots.Max( ymaxset );
2665 plots.Min( yminset );
2668 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2670 if ( yminset!=0 || ymaxset!=0 ) {
2671 if ( yminset>0 )
plots.SetLogy(yinfo.
log());
2672 else plots.SetLogy(
false);
2678 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2684 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2688 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2690 if ( atlasstyle )
ATLASLabel( xpos, ypositions[0]+deltay, atlaslabel, kBlack, ncolsp, nrowsp );
2692 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2694 for (
unsigned it=0 ;
it<taglabels.size() ;
it++ ) {
2695 DrawLabel( xpos, ypositions[
it], taglabels[
it], kBlack, 0.04 );
2699 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2702 if ( ( !nostats || !nomeans ) && !noplots ) {
2703 if ( dochi2 )
for (
unsigned j=0 ; j<Chi2.size() ; j++ )
DrawLabel( 0.75, 0.85-j*0.035, Chi2[j],
colours[j%6] );
2706 histo.name()==
"pT" ||
2711 for (
unsigned j=0 ; j<
chains.size() ; j++ ) {
2713 if ( j<MeanRef.size() ) {
2714 if ( !nomeans )
DrawLabel( xpos_original-0.02, (0.67-j*0.035), MeanRef[j],
colours[j%6] );
2718 if ( j<
Mean.size() ) {
2728 if ( xinfo.
log() ) gPad->SetLogx(
true);
2729 else gPad->SetLogx(
false);
2731 if ( yinfo.
log() ) gPad->SetLogy(
true);
2732 else gPad->SetLogy(
false);
2734 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2738 if ( make_ref_efficiencies ) {
2740 plots_eff.SetXaxisTitle(
plots.GetXaxisTitle() );
2741 plots_eff.SetYaxisTitle(
plots.GetYaxisTitle() );
2743 plots_eff.Draw( legend_eff );
2746 if ( !noreflabel.empty() )
DrawLabel(0.1, 0.06, noreflabel, kRed, 0.03 );
2765 std::string useplotname;
2767 if ( panel.
size()>1 ) {
2768 useplotname = panel.
name();
2769 replace( useplotname,
'/',
'_' );
2772 useplotname = plotname;
2775 useplotname.erase(
std::remove( useplotname.begin(), useplotname.end(),
'+' ), useplotname.end() );
2778 std::string printbase =
dir + useplotname +
tag;
2782 if ( !nopdf )
print_pad( printbase+
".pdf" );
2783 if ( !nopng )
print_pad( printbase+
".png" );
2784 if ( Cfile )
print_pad( printbase+
".C" );
2786 std::cout << std::endl;
2791 if ( tc )
delete tc;
2796 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2802 bool files_duplicated = ( fref_==ftest_ );
2804 if ( deleteref && !files_duplicated ) {
2810 std::cout <<
"main() cleaning up reference file" << std::endl;
2812 TFile* newout =
new TFile(
".newout.root",
"recreate");
2827 for (
unsigned j=0 ; j<
dirs.size()-1 ; j++ ) {
2828 std::cout <<
"\t" <<
dirs[j] << std::endl;
2829 TDirectory* renedir =
gDirectory->GetDirectory(
dirs[j].c_str() );
2836 if ( !noreftmp &&
href ) {
2838 href->Write(
dirs.back().c_str() );
2851 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2855 if ( fref_ && !files_duplicated ) fref_->Close();
2856 if ( ftest_ ) ftest_->Close();
2860 if ( deleteref && !noref ) {
2861 std::cout <<
"ref " << frefname <<
"\ttest " << ftestname << std::endl;
2862 if ( frefname != ftestname && !files_duplicated ) {
2863 std::string
cmd = std::string(
"mv ") + frefname +
" " + frefname +
".bak";
2864 std::system(
cmd.c_str() );
2866 cmd = std::string(
"mv .newout.root ") + std::string(frefname);
2867 std::system(
cmd.c_str() );
2870 std::cerr <<
"reference file and test file are the same - not replacing" << std::endl;
2876 if ( fref_ && !files_duplicated )
delete fref_;
2877 if ( ftest_ )
delete ftest_;