818int main(
int argc,
char** argv) {
820 gErrorIgnoreLevel = kError;
822 std::cout <<
"\n---------------------------------\n";
823 std::cout <<
"\n comparitor is off ...\n";
825 if ( argc<4 )
return usage(argv[0], -1,
"too few arguments");
829 std::string tag =
"";
830 std::string key =
"";
832 std::string dir =
"";
834 std::string ftestname =
"";
835 std::string frefname =
"";
844 std::string defreflabel =
"";
848 std::vector<std::string> usrlabels;
849 bool uselabels =
false;
850 bool addinglabels =
false;
852 std::vector<std::string> taglabels;
853 std::vector<std::string> taglabels2;
854 bool addingtags =
false;
855 bool addingtags2 =
false;
857 bool lumiref_trans =
false;
858 bool lumitest_trans =
false;
860 bool make_efficiencies =
true;
862 bool make_ref_efficiencies =
false;
863 bool refit_resplots =
false;
864 bool refitref_resplots =
false;
866 bool nostats =
false;
867 bool nomeans =
false;
870 bool atlasstyle =
false;
871 bool deleteref =
false;
872 bool nowatermark =
false;
873 bool noplots =
false;
879 bool normref =
false;
880 bool scalepix =
false;
882 bool addchains =
false;
883 bool usechainref =
false;
886 bool RANGEMAP =
false;
887 bool ALLRANGEMAP =
false;
891 std::string atlaslabel_tmp =
"Internal";
894 double scale_eff = -1;
895 double scale_eff_ref = -1;
897 std::string configfile =
"";
904 std::string pattern =
"";
905 std::string regex =
"";
907 std::string patternr =
"";
908 std::string regexr =
"";
910 std::string patternt =
"";
911 std::string regext =
"";
913 std::string basedir =
"";
915 std::string xpattern =
"";
916 std::string xregex =
"";
918 std::vector<std::string> chains;
919 std::vector<std::string> refchains;
921 bool addingrefchains =
false;
923 std::string mapfile =
"";
925 std::vector<std::string> chainfiles;
932 for(
int i=1; i<argc; i++){
933 std::string arg = argv[i];
935 ifdbg(
"\ncnt: " + arg );
938 if ( arg.find(
'-')!=0 && addinglabels ) {
939 std::string
label = arg;
942 usrlabels.push_back(
label );
945 else addinglabels =
false;
947 if ( arg.find(
'-')!=0 && addingrefchains ) {
948 refchains.push_back( arg );
951 else addingrefchains =
false;
953 if ( arg.find(
'-')!=0 && addingtags ) {
954 taglabels.push_back(
fullreplace( arg,
"__",
" " ) );
955 std::cout <<
"\tadding tag label: " << taglabels.back() << std::endl;
958 else addingtags =
false;
960 if ( arg.find(
'-')!=0 && addingtags2 ) {
961 taglabels2.push_back(
fullreplace( arg,
"__",
" " ) );
962 std::cout <<
"\tadding tag label: " << taglabels2.back() << std::endl;
965 else addingtags2 =
false;
967 ifdbg(
"starting if cascade: "+arg );
969 if ( arg==
"-h" || arg==
"--help" ) {
970 return usage(argv[0], 0);
972 else if ( arg==
"-c" || arg==
"--config" ) {
973 if ( ++i<argc ) configfile=argv[i];
974 else return usage(argv[0], -1,
"no config file provided");
977 else if ( arg==
"--jl" ) {
981 else if ( arg==
"--eps" ) {
985 else if ( arg==
"-t" || arg==
"--tag" ) {
986 if ( ++i<argc ) tag=std::string(
"-")+argv[i];
987 else return usage(argv[0], -1,
"no tag provided");
990 else if ( arg==
"-l" || arg==
"--labels" ) {
994 else if ( arg==
"-el" ) {
998 else if ( arg==
"-k" || arg==
"--key" ) {
999 if ( ++i<argc ) key=argv[i];
1000 else return usage(argv[0], -1,
"no key provided");
1003 else if ( arg==
"--run" ) {
1005 else return usage(argv[0], -1,
"no run number provided");
1008 else if ( arg==
"-m" || arg==
"--mapfile" ) {
1009 if ( ++i<argc ) mapfile=argv[i];
1010 else return usage(argv[0], -1,
"no mapfile provided");
1013 else if ( arg==
"-d" || arg==
"--dir" ) {
1014 if ( ++i<argc ) dir=argv[i];
1015 else return usage(argv[0], -1,
"no directory provided");
1018 else if ( arg==
"--lumi" ) {
1019 lumitest_trans =
true;
1020 lumiref_trans =
true;
1023 else if ( arg==
"--lumitest" ) {
1024 lumitest_trans =
true;
1025 ifdbg(
"--lumitest");
1027 else if ( arg==
"--lumiref" ) {
1028 lumiref_trans =
true;
1031 else if ( arg==
"-b" || arg==
"--bdir" ) {
1032 if ( ++i<argc ) basedir=argv[i];
1033 else return usage(argv[0], -1,
"no directory provided");
1036 else if ( arg==
"--taglabels" ) {
1038 ifdbg(
"--taglabels");
1040 else if ( arg==
"--taglabels2" ) {
1042 ifdbg(
"--taglabels2");
1044 else if ( arg==
"--unscalepix" ) {
1046 ifdbg(
"--unscalepix");
1048 else if ( arg==
"--scalepix" ) {
1050 ifdbg(
"--scalepix");
1052 else if ( arg==
"-ac" || arg==
"--addchains" ) {
1054 ifdbg(
"--sddchains");
1056 else if ( arg==
"-yrange" ) {
1058 if ( ++i<argc ) effmin=std::atof(argv[i]);
1059 else return usage(argv[0], -1,
"no range specified");
1060 if ( ++i<argc ) effmax=std::atof(argv[i]);
1061 else return usage(argv[0], -1,
"no upper y limit specified");
1064 else if ( arg==
"-e" || arg==
"--efficiencies" ) {
1065 make_ref_efficiencies =
true;
1066 ifdbg(
"--efficiencies");
1068 else if ( arg==
"-r" || arg==
"--refit" ) {
1069 refit_resplots =
true;
1072 else if ( arg==
"-rr" || arg==
"--refitref" ) {
1073 refitref_resplots =
true;
1074 ifdbg(
"--refitref");
1076 else if ( arg==
"--oldrms" ) {
1080 else if ( arg==
"-nw" || arg==
"--nowatermark" ) {
1083 ifdbg(
"--nowatermark");
1085 else if ( arg==
"--chi2" ) {
1089 else if ( arg==
"-ns" || arg==
"--nostats" ) {
1093 else if ( arg==
"-nm" || arg==
"--nomeans" ) {
1097 else if ( arg==
"--means" ) {
1101 else if ( arg==
"-nt" || arg==
"--notitle" ) {
1105 else if ( arg==
"-nr" || arg==
"--noref" ) {
1110 else if ( arg==
"--normref" ) {
1114 else if ( arg==
"-rc" || arg==
"--refchains" ) {
1115 addingrefchains =
true;
1116 ifdbg(
"--refchains");
1118 else if ( arg==
"-uc" || arg==
"--usechainref" ) {
1120 ifdbg(
"--usechainref");
1122 else if ( arg==
"-nb" || arg==
"--nobayes" ) {
1126 else if ( arg==
"-es" || arg==
"--effscale" ) {
1127 if ( ++i<argc ) scale_eff=std::atof(argv[i]);
1128 else return usage(argv[0], -1,
"no efficiency scale provided");
1129 ifdbg(
"--effscale");
1131 else if ( arg==
"-er" || arg==
"--effscaleref" ) {
1132 if ( ++i<argc ) scale_eff_ref=std::atof(argv[i]);
1133 else return usage(argv[0], -1,
"no efficiency scale for the reference histograms provided");
1134 ifdbg(
"--effscaleref");
1136 else if ( arg==
"--ncols" ) {
1137 if ( ++i<argc ) ncols=std::atoi(argv[i]);
1138 else return usage(argv[0], -1,
"no number of columns provided");
1141 else if ( arg==
"-np" || arg==
"--noplots" ) {
1145 else if ( arg==
"-C" || arg==
"--Cfiles" ) {
1149 else if ( arg==
"--deleteref" ) {
1151 ifdbg(
"--deleteref");
1153 else if ( arg==
"--nopng" ) {
1157 else if ( arg==
"--nopdf" ) {
1161 else if ( arg==
"-as" || arg==
"--atlasstyle" ) {
1164 ifdbg(
"--atlasstyle");
1166 else if ( arg==
"--tp" ) {
1167 make_efficiencies =
false;
1170 else if ( arg==
"-q" || arg==
"--quiet" ) {
1174 else if ( arg==
"-al" || arg==
"--atlaslabel" ) {
1175 if ( ++i<argc ) atlaslabel_tmp=argv[i];
1176 else return usage(argv[0], -1,
"no label provided");
1177 ifdbg(
"--atlaslabel");
1179 else if ( arg==
"-xo" || arg==
"--xoffset" ) {
1180 if ( ++i<argc ) xoffset=std::atof(argv[i]);
1181 else return usage(argv[0], -1,
"no xoffset provided");
1184 else if ( arg==
"-yp" || arg==
"--ypos" ) {
1185 if ( ++i<argc ) ypos_in=std::atof(argv[i]);
1186 else return usage(argv[0], -1,
"no y position provided");
1189 else if ( arg==
"-xe" || arg==
"--xerror" ) {
1190 if ( ++i<argc ) xerror=std::atof(argv[i]);
1191 else return usage(argv[0], -1,
"no x error provided");
1194 else if ( arg==
"-s" || arg==
"--swap" ) {
1195 if ( ++i<argc ) pattern=argv[i];
1196 else return usage(argv[0], -1,
"no patterns provided");
1197 if ( ++i<argc ) regex=argv[i];
1198 else return usage(argv[0], -1,
"no target pattern provided");
1201 else if ( arg==
"--swapt" ) {
1202 if ( ++i<argc ) patternt=argv[i];
1203 else return usage(argv[0], -1,
"no patterns provided");
1204 if ( ++i<argc ) regext=argv[i];
1205 else return usage(argv[0], -1,
"no target pattern provided");
1208 else if ( arg==
"--swapr" ) {
1209 if ( ++i<argc ) patternr=argv[i];
1210 else return usage(argv[0], -1,
"no patterns provided");
1211 if ( ++i<argc ) regexr=argv[i];
1212 else return usage(argv[0], -1,
"no target pattern provided");
1215 else if ( arg==
"-sx" || arg==
"--swapaxtitles" ) {
1216 if ( ++i<argc ) xregex=argv[i];
1217 else return usage(argv[0], -1,
"no target pattern provided");
1218 if ( ++i<argc ) xpattern=argv[i];
1219 else return usage(argv[0], -1,
"no patterns provided");
1220 ifdbg(
"--swapxtitles");
1222 else if ( arg.find(
'-')==0 ) {
1223 std::cerr <<
"unknown option: " << arg <<
"\n" << std::endl;
1224 return usage(argv[0], -4);
1227 ifdbg(
"arg: + "+arg);
1228 if ( ftestname==
"" ) ftestname = arg;
1229 else if ( frefname==
"" ) frefname = arg;
1231 std::string
file =
"";
1233 if ( arg.find(
":file:")!=std::string::npos ) {
1234 file = arg.substr( 0, arg.find(
":file:") );
1235 chainfiles.push_back(
file );
1236 arg = arg.substr(arg.find(
":file:")+6,arg.size());
1239 std::string chain = arg;
1243 chains.push_back(chain);
1245 std::cout <<
"file: " <<
file <<
"\tchain: " << chain << std::endl;
1251 if ( ftestname.empty() ) {
1252 std::cerr <<
"main(): test file not specified " << std::endl;
1256 if ( !
exists(ftestname) ) {
1257 std::cerr <<
"main(): test file " << ftestname <<
" does not exist" << std::endl;
1261 std::vector<TFile*> chainTFiles;
1263 if ( chainfiles.size()==0 ) ftest_ = TFile::Open( ftestname.c_str() );
1266 chainTFiles.resize(chainfiles.size());
1267 for (
size_t i=0 ; i<chainfiles.size() ; i++ ) {
1268 chainTFiles[i] = TFile::Open( chainfiles[i].c_str() );
1269 if ( chainTFiles[i] == 0 ) {
1270 std::cerr <<
"\tfile: " << chainfiles[i] <<
" could not be opened" << std::endl;
1273 else std::cout <<
"\tchainfiles: " << chainfiles[i] <<
" " << chainTFiles[i] << std::endl;
1278 if ( noref==
false ) {
1279 if ( frefname.empty() ) {
1280 std::cerr <<
"main(): ref file not specified " << std::endl;
1290 if ( frefname==ftestname ) fref_ = ftest_;
1291 else if (
exists(frefname) ) fref_ = TFile::Open( frefname.c_str() );
1293 std::cerr <<
"main(): ref file " << frefname <<
" does not exist" << std::endl;
1299 else fref_ = ftest_;
1301 if ( chainfiles.size()==0 ) {
1303 std::cerr <<
"could not open test file " << ftestname << std::endl;
1307 if ( noref==
false && fref_==0 ) {
1308 std::cerr <<
"could not open files " << std::endl;
1314 defreflabel =
"failed to open reference file";
1319 if ( scale_eff == -1 ) scale_eff = 100;
1320 if ( scale_eff_ref == -1 ) scale_eff_ref = scale_eff;
1323 bool noreftmp = noref;
1325 if ( chains.size()==0 )
return usage(argv[0], -1,
"no chains specified");
1328 if ( basedir.size()>0 ) {
1329 if ( basedir[basedir.size()-1]!=
'/' ) basedir +=
"/";
1330 for (
size_t ic=chains.size() ; ic-- ; ) chains[ic] = basedir+chains[ic];
1333 if ( refchains.size()>0 && refchains.size()!=chains.size() )
return usage(argv[0], -1,
"not enough chains specified");
1335 if ( refchains.size()==0 ) refchains = chains;
1337 std::vector<std::string> chainref(chains.size(),
"");
1338 std::vector<std::string> chain_name(chains.size(),
"");
1340 std::vector<std::string> refchain(chainref.size(),
"");
1344 std::cout << argv[0] <<
" options:" << std::endl;
1345 std::cout <<
"\tATLAS style: " << ( atlasstyle ?
"true" :
"false" ) << std::endl;
1346 std::cout <<
"\tBayesian uncertainties: " << ( bayes ?
"true" :
"false" ) << std::endl;
1347 std::cout <<
"\trefit resplot uncertainties: " << ( refit_resplots ?
"true" :
"false" ) << std::endl;
1348 std::cout <<
"\tsuppress mean and rms stats: " << ( nostats ?
"true" :
"false" ) << std::endl;
1349 if ( !nostats ) std::cout <<
"\tsuppress meanstats: " << ( nomeans ?
"true" :
"false" ) << std::endl;
1350 std::cout <<
"\tsuppress png output: " << ( nopng ?
"true" :
"false" ) << std::endl;
1351 std::cout <<
"\tsuppress pdf output: " << ( nopdf ?
"true" :
"false" ) << std::endl;
1352 std::cout <<
"\tsuppress reference output: " << ( noref ?
"true" :
"false" ) << std::endl;
1353 std::cout <<
"\tuse chain references: " << ( usechainref ?
"true" :
"false" ) << std::endl;
1354 std::cout <<
"\tpanel ncols: " << ncols << std::endl;
1356 if ( usrlabels.size()>0 ) std::cout <<
"\tlabels: " << usrlabels.size() << std::endl;
1357 if ( taglabels.size()>0 ) std::cout <<
"\textra text: " << taglabels << std::endl;
1358 if ( taglabels2.size()>0 ) std::cout <<
"\textra text: " << taglabels2 << std::endl;
1361 for (
size_t il=0 ; il<usrlabels.size() ; il++ ) {
1362 std::cout <<
"usr label[" << il <<
"] : " << usrlabels[il] << std::endl;
1365 std::cout <<
"atlas style : " << atlasstyle << std::endl;
1373 gROOT->SetStyle(
"Plain");
1375 gStyle->SetLineScalePS(1);
1379 gStyle->SetErrorX(xerror);
1381 gStyle->SetPadLeftMargin(0.15);
1382 gStyle->SetPadBottomMargin(0.15);
1384 gStyle->SetPadRightMargin(0.02);
1385 gStyle->SetPadTopMargin(0.05);
1387 std::cout <<
"Chains: " << std::endl;
1388 for (
unsigned ic=0 ; ic<chains.size() ; ic++ ) std::cout <<
"\t" << chains[ic] << std::endl;
1390 if ( usrlabels.size()>0 ) std::cout <<
"labels: " << usrlabels << std::endl;
1392 if ( usrlabels.size()>0 && usrlabels.size()==chains.size() ) uselabels =
true;
1396 TTree* dataTree = 0;
1397 TString* releaseData =
new TString(
"");
1398 std::vector<std::string> release_data;
1401 if ( !nowatermark && ftest_ ) {
1403 dataTree = (TTree*)ftest_->Get(
"dataTree");
1406 dataTree->SetBranchAddress(
"ReleaseMetaData", &releaseData);
1408 for (
unsigned int i=0; i<dataTree->GetEntries() ; i++ ) {
1409 dataTree->GetEntry(i);
1410 release_data.push_back( releaseData->Data() );
1411 std::cout <<
"main() release data: " << release_data.back() <<
" : " << *releaseData << std::endl;
1415 std::cout <<
"\n\n\n\n\n" << std::endl;
1417 std::cout <<
"\n\nrd size " << release_data.size() << std::endl;
1420 if ( release_data.size()>0 ) {
1421 if ( release_data.size()>1 ) std::cerr <<
"main() more than one release - using only the first" << std::endl;
1425 std::string rd = release_data[0];
1427 while ( rd.size()>0 ) {
1429 std::string nightly =
chop(rd,
" " );
1431 if (
contains(nightly,
"private" ) ) {
1432 for (
int ic=0 ; ic<4 ; ic++ )
chop(release_data[0],
" " );
1433 release +=
" (" + release_data[0]+
")";
1438 if (
contains(nightly,
"nightly") ) {
1439 chop( nightly,
"/" );
1450 std::cout <<
"release: " <<
release << std::endl;
1458 std::cout <<
"trying to make directory" << std::endl;
1461 if ( mkdir( dir.c_str(), 0777 ) ) std::cerr <<
"main() couldn't create directory " << dir << std::endl;
1462 else std::cout <<
"main() output will be sent to directory " << dir << std::endl;
1466 if ( ftest_==0 && chainTFiles.size()>0 ) fref_ = ftest_ = chainTFiles[0];
1468 TFile* ftest = ftest_;
1469 TFile* fref = fref_;
1471 std::string testrun =
findrun( ftest );
1473 std::string rawrefrun =
"";
1474 std::string refrun =
"";
1476 if ( fref_ ) refrun = rawrefrun =
findrun( fref );
1478 std::cout <<
"testrun: " << testrun <<
"\nrefrun: " << refrun << std::endl;
1480 if ( !testrun.empty() && refrun != testrun ) {
1481 if ( pattern.empty() ) {
1488 if ( !refrun.empty() ) {
1490 std::string newtag =
"Reference: ";
1492 std::cout <<
"refrun: " << refrun << std::endl;
1495 while ( (pos=refrun.find(
'_'))!=std::string::npos ) refrun.replace( pos, 1,
" " );
1498 std::string rawrun = refrun.erase( refrun.find(
"run"), 4 );
1500 if (
contains(frefname, rawrun) ) {
1502 std::string
release = frefname;
1517 taglabels.push_back( newtag );
1519 std::cout <<
"tag labels: " << taglabels << std::endl;
1534 if ( !nowatermark ) {
1537 TH1D* htestev = (TH1D*)ftest->Get(
"event") ;
1538 TH1D* hrefev = (TH1D*)fref->Get(
"event") ;
1542 std::cout <<
"htestev " << htestev <<
" " << hrefev << std::endl;
1544 if ( htestev ) NeventTest = htestev->GetEntries();
1545 if ( hrefev ) NeventRef = hrefev->GetEntries();
1555 if ( NeventTest>1 ) std::cout <<
"Nevents Test: " << NeventTest << std::endl;
1556 if ( NeventRef>1 ) std::cout <<
"Nevents Ref: " << NeventRef << std::endl;
1560 if ( mapfile.empty() ) mapfile = configfile;
1563 std::cout <<
"mapfile: " << mapfile << std::endl;
1565 if ( !mapfile.empty() ) {
1569 if ( m.isTagDefined(
"ChainMap" ) ) {
1571 std::vector<std::string> chains = m.GetStringVector(
"ChainMap" );
1573 for (
size_t i=0 ; i<chains.size() ; i+=2 ) std::cout <<
"map: " << chains[i] <<
" -> " << chains[i+1] << std::endl;
1577 for (
size_t i=0 ; i<chains.size() ; i+=2 ) {
1578 chainmap->insert( chainmap_t::value_type( chains[i], chains[i+1] ) );
1581 std::cout <<
"\nusing chain map:" << std::endl;
1583 for ( chainmap_t::iterator itr=chainmap->begin() ; itr!=chainmap->end() ; itr++ ) {
1584 std::cout <<
"\t" << itr->first <<
"\t" << itr->second << std::endl;
1591 std::cout <<
"\ncreating chain and reference information ..." << std::endl;
1593 for (
size_t j=0; j<chains.size(); j++) {
1595 if ( !regex.empty() ) chains[j] =
fullreplace( chains[j], pattern, regex );
1596 if ( !regext.empty() ) chains[j] =
fullreplace( chains[j], patternt, regext );
1601 std::cout <<
"chain: " << chains[j] <<
"\taddchains: " << addchains << std::endl;
1603 if ( addchains && (
contains(chains[j],
"Shifter") || ( !
contains(chains[j],
"HLT_") && !
contains(chains[j],
"Fullscan" ) ) ) ) {
1605 TFile* fftest = ftest;
1607 if ( chainfiles.size()>0 && chainfiles.size()>j ) fftest = chainTFiles[j];
1609 TH1F* hchain =
Get( *fftest, chains[j]+
"/Chain", testrun );
1613 std::string name = hchain->GetTitle();
1615 if ( usechainref && !
contains(chains[j],
"Purity") ) {
1619 std::cout <<
"new chainref: " << chainref[j] << std::endl;
1621 std::string::size_type pos = chainref[j].find(
":for");
1622 if ( pos!=std::string::npos ) chainref[j].replace( pos, 4,
"_for" );
1623 std::replace( chainref[j].begin(), chainref[j].end(),
':',
'/');
1624 std::string newchain =
dirname(
dirname( chains[j]) ) +
"/Expert/" + chainref[j];
1625 chainref[j] = newchain;
1627 std::cout <<
"final chainref: " << chainref[j] << std::endl;
1631 std::cout <<
"chainref: " << chainref[j] << std::endl;
1633 while (
contains( name,
"HLT_" ) ) name = name.erase( name.find(
"HLT_"), 4 );
1635 std::cout <<
"name: " << name << std::endl;
1637 if (
contains( name,
":" ) ) chain_name[j] = name.substr( 0, name.find(
':') ) +
" : ";
1638 else chain_name[j] = name;
1640 if ( chain_name[j] ==
" : " ) chain_name[j] =
"";
1642 std::cout <<
"chain_name: " << chain_name[j] << std::endl;
1647 std::cout <<
"chainref size: " << chainref.size() <<
" " << refchains.size() << std::endl;
1649 for (
size_t j=0 ; j<chainref.size() ; j++ ) {
1650 std::cout <<
"chainref: " << chainref[j] <<
" :: " << refchains[j] << std::endl;
1653 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], pattern, regex );
1654 else refchain[j] =
fullreplace( refchains[j], pattern, regex );
1656 if ( !patternr.empty() ) {
1657 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], patternr, regexr );
1658 else refchain[j] =
fullreplace( refchains[j], patternr, regexr );
1661 std::cout <<
"refchain: " << refchain[j] << std::endl;
1664 std::cout <<
"done chains" << std::endl;
1668 std::vector<Panel> panels;
1675 std::vector<int> ccolours;
1676 std::vector<int> cstyles;
1678 std::vector<std::string> ctags;
1679 std::vector<std::string> ctaglabels;
1682 std::cout <<
"\n" << argv[0] <<
"\tconfigfile: " << configfile << std::endl;
1684 bool use_file_config =
false;
1686 if ( configfile!=
"" ) {
1688 if (
exists(configfile) ) {
1690 std::cout << argv[0] <<
":\treading configuration file " << configfile << std::endl;
1697 if (
rc.isTagDefined(
"histos" ) ) {
1699 std::cout << argv[0] <<
":\treading histogram configuration from file " << configfile << std::endl;
1701 use_file_config =
true;
1703 std::vector<std::string> raw_input =
rc.GetStringVector(
"histos" );
1705 for (
size_t iraw=0 ; iraw<raw_input.size() ; iraw += 6) {
1709 panels.push_back( p );
1714 std::cout <<
"searching for panels" << std::endl;
1718 if (
rc.isTagDefined(
"panels" ) ) {
1720 std::cout << argv[0] <<
":\treading histogram panel configuration from file " << configfile << std::endl;
1722 use_file_config =
true;
1724 std::vector<std::string> panel_config =
rc.GetStringVector(
"panels" );
1726 std::vector<string> panel_columns;
1728 if (
rc.isTagDefined(
"panel_columns") ) {
1729 panel_columns =
rc.GetStringVector(
"panel_columns" );
1730 if ( panel_columns.size()%2 )
return usage( argv[0], -1,
"incorrect panel settings" );
1734 for (
size_t ipanel=panel_config.size() ; ipanel-- ; ) {
1736 std::vector<std::string> raw_input =
rc.GetStringVector( panel_config[ipanel] );
1740 if ( panel_columns.size() ) {
1741 std::vector<string>::iterator itr =
find( panel_columns.begin(), panel_columns.end(), panel_config[ipanel] );
1742 if ( itr!=panel_columns.end() ) tncols = std::atoi( (++itr)->c_str() );
1745 Panel p( panel_config[ipanel], tncols );
1747 if ( raw_input.empty() ) {
1748 std::cerr <<
"no plots provided" << std::endl;
1752 for (
size_t iraw=0 ; iraw<raw_input.size() ; iraw += 6 ) p.push_back(
HistDetails( &(raw_input[iraw]) ) );
1754 panels.push_back( p );
1760 if (
rc.isTagDefined(
"Bands" ) &&
rc.isTagDefined(
"Labels" ) ) {
1761 bnd =
bands(
rc.GetVector(
"Bands"),
rc.GetStringVector(
"Labels" ) );
1765 if (
rc.isTagDefined(
"Colours") ) {
1767 std::vector<int> ccolours =
rc.GetIntVector(
"Colours");
1769 std::cout <<
"remap colours: " << ccolours << std::endl;
1773 for (
size_t i=6 ; i-- ; ) new_colours[i] =
colours[i];
1775 for (
size_t i=0 ; i<ccolours.size() && i<6 ; i++ ) {
1776 if ( ccolours[i]<6 ) new_colours[i] =
colours[ccolours[i]];
1779 for (
size_t i=6 ; i-- ; )
colours[i] = new_colours[i];
1784 if (
rc.isTagDefined(
"Styles") ) {
1786 std::vector<int> cstyles =
rc.GetIntVector(
"Styles");
1788 std::cout <<
"remap markers: " << cstyles << std::endl;
1792 for (
size_t i=6 ; i-- ; ) new_markers[i] =
markers[i];
1794 for (
size_t i=0 ; i<cstyles.size() && i<6 ; i++ ) {
1795 if ( cstyles[i]<6 ) new_markers[i] =
markers[cstyles[i]];
1798 for (
size_t i=6 ; i-- ; )
markers[i] = new_markers[i];
1803 for (
int i=6 ; i-- ; ) std::cout <<
"\tcolours[" << i <<
"] = " <<
colours[i] << std::endl;
1804 for (
int i=6 ; i-- ; ) std::cout <<
"\tmarkers[" << i <<
"] = " <<
markers[i] << std::endl;
1807 if (
rc.isTagDefined(
"Tags") ) ctags =
rc.GetStringVector(
"Tags");
1808 if (
rc.isTagDefined(
"TagLabels") ) ctaglabels =
rc.GetStringVector(
"TagLabels");
1809 if (
rc.isTagDefined(
"TagLabels") ) usrlabels =
rc.GetStringVector(
"TagLabels");
1812 if (
rc.isTagDefined(
"Styles") ) {
1813 for (
size_t is=0 ; is<cstyles.size() && is<6 ; is++ ) {
1822 std::cout << argv[0] <<
"\tuserlabels :" << usrlabels <<
":" << std::endl;
1826 if (
rc.isTagDefined(
"RANGEMAP") ) RANGEMAP =
true;
1827 if (
rc.isTagDefined(
"ALLRANGEMAP") ) ALLRANGEMAP =
true;
1829 std::cout <<
"Extra: " <<
rc.isTagDefined(
"Extra") << std::endl;
1831 if (
rc.isTagDefined(
"Extra") ) taglabels.push_back(
fullreplace(
rc.GetString(
"Extra"),
"__",
" " ) );
1836 std::cerr << argv[0] <<
":\t config file not found: " << configfile << std::endl;
1842 if ( !use_file_config ) {
1844 std::cout <<
"using default panels" << std::endl;
1858 scale_eff_ref = 100;
1864 size_t nphist[3] = { 4, 4, 10 };
1866 std::string pnames[3] = {
"eff",
"res",
"diff" };
1868 for (
size_t ip=0 ; ip<3 ; ip++ ) {
1869 Panel p( pnames[ip]+
"_panel", 2 );
1870 for (
size_t iraw=0 ; iraw<nphist[ip] ; iraw++ ) p.push_back(
HistDetails( inpanels[ip][iraw] ) );
1871 panels.push_back( p );
1877 std::cout <<
"taglabels" << std::endl;
1879 for (
size_t it=0 ; it<taglabels.size() ; it++ ) std::cout << taglabels[it] << std::endl;
1880 for (
size_t it=0 ; it<taglabels2.size() ; it++ ) std::cout << taglabels2[it] << std::endl;
1883 std::cout <<
"\npanels: " << panels.size() << std::endl;
1885 if ( panels.size()==0 )
return usage(argv[0], -1,
"no panels to plot");
1887 for (
size_t ip=0 ; ip<panels.size() ; ip++ ) std::cout << panels[ip] << std::endl;
1892 gStyle->SetPadRightMargin(0.05);
1893 gStyle->SetPadTopMargin(0.05);
1895 const Int_t Number = 3;
1896 Double_t Red[Number] = { 0.00, 0.00, 1.00};
1897 Double_t Green[Number] = { 0.00, 5.00, 1.00};
1898 Double_t Blue[Number] = { 0.00, 0.50, 0.00};
1899 Double_t Length[Number] = { 0.00, 0.50, 1.00 };
1901 TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);
1903 else gStyle->SetPalette(1);
1905 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1907 double rightmargin = gStyle->GetPadRightMargin();
1908 gStyle->SetPadRightMargin(0.1);
1912 gStyle->SetPadRightMargin(rightmargin);
1916 for (
size_t ipanel=0 ; ipanel<panels.size() ; ipanel++ ) {
1918 Panel& panel = panels[ipanel];
1920 std::cout <<
"\n\n---------------------------------------------\n";
1922 std::cout << panel <<
"\n" << std::endl;
1924 int ncolsp = panel.
ncols();
1925 int nrowsp = panel.
nrows();
1929 std::cout <<
"\nncols: " << ncolsp <<
"\tnrows: " << nrowsp << std::endl;
1931 bool multipanel = ( panel.
size() > 1 );
1933 if ( panel.
size()==0 ) {
1934 std::cout <<
"panel empty: " << panel.
name() << std::endl;
1940 if ( panel.
size()>4 ) gStyle->SetLineScalePS(0.5);
1942 if ( multipanel ) extraw = 1.05;
1944 TCanvas*
tc =
new TCanvas(
"tc",
"", extraw*ncolsp*800, nrowsp*600 );
1948 const std::string& atlaslabel = atlaslabel_tmp;
1952 gStyle->SetLineScalePS(1);
1968 tc->Divide( ncolsp, nrowsp, 0.0001, 0.0003 );
1974 std::string plotname =
"";
1976 for (
size_t i=0 ; i<panel.
size() ; i++ ) {
1980 bool drawmeans =
false;
1981 bool drawresiduals =
true;
1984 if (
contains(histo.detail(),
"+mean" ) ) drawmeans =
true;
1985 if (
contains(histo.detail(),
"-residual") ) drawresiduals =
false;
1987 std::string xaxis = histo.xtitle();
1988 std::string yaxis = histo.ytitle();
1990 if ( !xregex.empty() ) {
1991 size_t pos = xaxis.find(xregex);
1992 if ( pos!=std::string::npos ) xaxis.replace( pos, xregex.size(), xpattern );
1993 pos = yaxis.find(xregex);
1994 if ( pos!=std::string::npos ) yaxis.replace( pos, xregex.size(), xpattern );
1997 const AxisInfo& xinfo = histo.xaxis();
1998 const AxisInfo& yinfo = histo.yaxis();
2003 std::string hname = histo.name();
2004 std::string
detail = histo.detail();
2006 bool translate_x =
false;
2008 if ( ( lumiref_trans || lumitest_trans ) &&
contains(histo.xtitle(),
"Pile-up" ) ) translate_x =
true;
2012 if ( translate_x ) {
2013 xinfo.
lo( xinfo.
lo()*(1-0.054) );
2015 xinfo.
hi( xinfo.
hi()*(1-0.054) );
2022 bool d0rebin_flag =
false;
2028 rebin = std::atof(
detail.substr(
detail.find(
"+Rebin")+6,
detail.size() ).c_str() );
2032 rebin = std::atof(
detail.substr(
detail.find(
"+rebin")+6,
detail.size() ).c_str() );
2035 int labelcolour = kBlack;
2037 int npanel = nrowsp*(i/nrowsp) + i%nrowsp + 1 ;
2039 std::cout <<
"panel: panel: " << panel.
name() <<
"\tsubpanel: " << npanel << std::endl;
2041 if ( multipanel )
tc->cd( npanel );
2049 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2051 std::cout <<
"main() processing histo[" << i <<
"] " << (i<10 ?
" " :
"" ) << histo.name() <<
"\t" << histo.xaxis() << std::endl;
2059 std::string noreflabel=defreflabel;
2064 if (
contains(histo.name(),
"eff") ||
contains(histo.name(),
"Eff_") ) ypos = 0.19;
2073 if ( ypos>0.5 ) ypos = 0.85;
2077 if ( ypos_in!=0 ) ypos = ypos_in;
2079 double xpos_original = xpos;
2083 if ( xinfo.
offset() != 0 ) {
2085 std::cout <<
"HA ! xinfo.offset: " << xinfo.
offset() << std::endl;
2092 if ( yinfo.
offset() != 0 ) {
2094 std::cout <<
"HA ! yinfo.offset: " << yinfo.
offset() << std::endl;
2104 size_t Nrows = chains.size();
2106 if ( ALLRANGEMAP || (RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos && ccolours.size() ) ) {
2107 Nrows = ( Nrows < ccolours.size() ? Nrows : ccolours.size() );
2110 int Nlines = Nrows + taglabels.size();
2112 std::vector<double> ypositions;
2113 std::vector<double> ypositions2;
2115 double deltay = (Nrows*0.055-0.005)/Nrows;
2118 double yhi = ypos-0.01;
2120 if ( ypos>0.5 ) ylo -= Nlines*deltay;
2121 else yhi += Nlines*deltay;
2123 ypositions.reserve(Nlines);
2124 for (
int ilines=0 ; ilines<Nlines ; ilines++ ) {
2125 ypositions.push_back( yhi - deltay*(ilines+0.5) );
2126 ypositions2.push_back( yhi - deltay*(ilines-0.5) );
2137 if ( !
contains(histo.name(),
"eff") && !
contains(histo.name(),
"Eff_") ) ylo -= 0.02;
2140 Legend legend( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
2141 Legend legend_eff( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
2144 std::vector<std::string> Mean;
2145 std::vector<std::string> MeanLF;
2146 std::vector<std::string> RMS;
2152 std::vector<std::string> Chi2;
2153 std::vector<std::string> MeanRef;
2154 std::vector<std::string> RMSRef;
2164 bool power_set =
false;
2172 for (
unsigned int j=0; j<chains.size(); j++) {
2174 TFile* fftest = ftest;
2175 TFile* ffref = fref;
2177 std::string cc = ftest->GetName();
2178 std::string cr =
"";
2180 if ( fref ) cr = fref->GetName();
2182 if ( chainfiles.size()>0 && chainfiles.size()>j ) ffref = fftest = chainTFiles[j];
2187 std::cout <<
"chain: " << chains[j] <<
"\taddchains: " << addchains << std::endl;
2188 std::cout <<
"chainref: " << chainref[j] << std::endl;
2203 TGraphAsymmErrors* tgtest = 0;
2205 std::cout <<
"refchain.size() " << refchain.size() << std::endl;
2207 std::cout <<
"refchain: " << refchain[j] << std::endl;
2211 gPad->SetRightMargin(0.03);
2215 labelcolour = kBlack;
2218 if (
contains(histo.name(),
"/2d") ) {
2221 labelcolour = kWhite;
2223 gPad->SetRightMargin(0.13);
2225 std::cout <<
"\n\nsee! it is a 2d histograms !!! " << histo.name() <<
"\n\n" << std::endl;
2229 std::cout <<
"\t2d: " << h2test << std::endl;
2233 h2test->GetYaxis()->SetTitleOffset(1.55);
2234 h2test->GetXaxis()->SetTitleOffset(1.5);
2235 h2test->GetXaxis()->SetTitle(xaxis.c_str());
2236 h2test->GetYaxis()->SetTitle(yaxis.c_str());
2238 const AxisInfo& xinfo = histo.xaxis();
2239 const AxisInfo& yinfo = histo.yaxis();
2241 std::cout << xinfo << std::endl;
2242 std::cout << yinfo << std::endl;
2245 h2test->GetYaxis()->SetRangeUser( yinfo.
lo(), yinfo.
hi() );
2251 h2test->GetXaxis()->SetRangeUser( xinfo.
lo(), xinfo.
hi() );
2259 h2test->DrawCopy(
"colz");
2261 if ( histo.detail().find(
"logz")!=std::string::npos ) gPad->SetLogz(
true);
2262 else gPad->SetLogz(
false);
2266 else if ( refit_resplots && (
contains(histo.name(),
"/sigma") ||
contains(histo.name(),
"/mean") ) ) {
2268 std::cout <<
"\n\n2d: " << histo.name() <<
"\n\n" << std::endl;
2270 bool bsigma =
false;
2271 if (
contains(histo.name(),
"/sigma") ) bsigma =
true;
2274 if (
contains(histo.name(),
"/mean") ) bmean =
true;
2276 std::cout <<
"\trefitting: " << histo.name() << std::endl;
2281 std::string tmp_ = histo.name();
2284 if ( bsigma )
base =
chop( tmp_,
"/sigma" );
2285 if ( bmean )
base =
chop( tmp_,
"/mean" );
2289 std::cout <<
"ffref " << ffref <<
" :: " <<
base << std::endl;
2293 if ( ffref ) href2d_ =
Get<TH2D>( *ffref, chains[j]+
"/"+
base+
"/2d", testrun, chainmap );
2295 std::cout <<
"htest2d_ : " << htest2d_ << std::endl;
2297 if ( htest2d_==0 )
continue;
2298 if ( !noreftmp && href2d_==0 ) noreftmp =
true;
2300 std::cout <<
"href2d_ : " << href2d_ << std::endl;
2304 std::cout <<
"plotter" << std::endl;
2308 Resplot rtest(
"tmp", htest2d_ );
2310 std::cout <<
"Resplot rtest" << std::endl;
2313 std::cout <<
"refitting ..." << std::endl;
2318 std::cout <<
"refitting (finalising) ..." << std::endl;
2322 rtest.
Mean()->DrawCopy();
2323 gPad->Print(
"Duff.pdf");
2326 std::cout <<
"bsigma: " << bsigma << std::endl;
2327 std::cout <<
"bmean: " << bmean << std::endl;
2329 if ( bsigma ) { htest = (TH1F*)rtest.
Sigma()->Clone(
"rtest_sigma"); htest->SetDirectory(0); }
2330 if ( bmean ) { htest = (TH1F*)rtest.
Mean()->Clone(
"rtest_mean"); htest->SetDirectory(0); }
2333 std::cerr <<
red <<
"missing test histogram: " << (refchain[j]+
" / "+histo.name()) <<
" " << htest
2334 <<
"(test)" <<
reset << std::endl;
2338 std::cout <<
green <<
"htest: " << htest->GetName() <<
reset << std::endl;
2341 std::cout <<
"\nhisto.name(): " << histo.name() << std::endl;
2344 if (
true && histo.name().find(
"d0_vs_phi")!=std::string::npos ) {
2346 TVirtualPad* old = gPad;
2348 std::cout <<
"old canvas: " << gPad << std::endl;
2350 std::cout <<
"dbg histo name: " << histo.name() << std::endl;
2356 if ( histo.name().find(
"_rec")!=std::string::npos ) {
2364 if ( histo.name().find(
"_rec")==std::string::npos ) {
2366 fitcanvas =
new TCanvas(
"fit",
"", 700, 600 );
2372 TVirtualPad* tp = gPad;
2380 rtest.
Mean()->SetDirectory(0);
2384 if ( histo.name().find(
"_rec")!=std::string::npos ) hf->SetTitle(
";Trigger #phi;Trigger d_{0} [mm]");
2385 else hf->SetTitle(
";Offline #phi;Offline d_{0} [mm]");
2387 TF1* tf =
new TF1(
"sinus",
"[0]*sin(x+[1])+[2]" );
2389 tf->SetLineWidth(1);
2391 hf->GetYaxis()->SetTitleOffset( hf->GetYaxis()->GetTitleOffset()*1.1 );
2394 TCanvas* tfc =
new TCanvas(
"tmp",
"", 700, 600 );
2400 double phi0 = tf->GetParameter(1);
2403 double x = tf->GetParameter(0)*cos(phi0);
2404 double y = tf->GetParameter(0)*sin(phi0);
2405 double off = tf->GetParameter(2);
2407 std::cout <<
"\tx = " <<
x << std::endl;
2408 std::cout <<
"\ty = " <<
y << std::endl;
2409 std::cout <<
"\toffset = " << off << std::endl;
2411 std::string cckstr = chains[j];
2413 cckstr = cckstr.substr( cckstr.find(
"HLT_IDTrack") );
2415 std::string vstr = chains[j];
2417 vstr.resize(vstr.find(
"_boffperf"));
2418 vstr.resize(vstr.find(
"_L1"));
2420 hf->SetMinimum( -0.03 );
2421 hf->SetMaximum( 0.03 );
2425 if ( first ) hf->DrawCopy();
2427 hf->DrawCopy(
"same");
2428 hf->DrawCopy(
"samee");
2438 std::string sht = chains[j]+
"-"+histo.name()+
"-fit.pdf";
2440 size_t p = sht.find(
"/");
2442 while ( p!=std::string::npos ) {
2448 gPad->Print( sht.c_str() );
2449 gPad->Print(
"sht.pdf" );
2451 std::cout <<
"CNT !!!" << std::endl;
2467 std::cout <<
"Resplot hreft " << noreftmp <<
" ... " << std::endl;
2470 if ( refitref_resplots ) {
2473 std::cout <<
"Resplot rref: " << href2d_ << std::endl;
2476 Resplot rref(
"tmp", href2d_ );
2479 std::cout <<
"Resplot rref: " << href2d_ <<
" (2)" << std::endl;
2483 std::cout <<
"refitting (2) ..." << std::endl;
2488 std::cout <<
"refitting (2 - finalising) ..." << std::endl;
2493 std::cout <<
"Resplot rref: " << href2d_ <<
" (3)" << std::endl;
2496 if ( bsigma ) { hreft = (TH1F*)rref.
Sigma()->Clone(
"rref_sigma"); hreft->SetDirectory(0); }
2497 if ( bmean ) { hreft = (TH1F*)rref.
Mean()->Clone(
"rref_mean"); hreft->SetDirectory(0); }
2499 std::cout <<
"Resplot rref: " << href2d_ <<
" (4)" << std::endl;
2505 std::cout <<
"Resplot rref: " << href2d_ <<
" (5)" << std::endl;
2508 hreft =
Get( *ffref, refchain[j]+
"/"+histo.name(), rawrefrun, chainmap );
2510 std::cerr <<
"ERROR: could not find " << (refchain[j]+
"/"+histo.name()) << std::endl;
2517 std::cout <<
"Resplot rref: " << href2d_ <<
" (6)" << std::endl;
2520 if ( !noreftmp && hreft==0 ) {
2522 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+histo.name()) <<
" " << htest <<
"(ref)" << std::endl;
2526 noreflabel=
"reference not found";
2534 std::cout <<
"Resplot rref: " << href2d_ <<
" (7)" << std::endl;
2536 href = (TH1F*)hreft->Clone();
2537 href->SetDirectory(0);
2539 std::cout <<
"Resplot href: " << href <<
" (7a)" << std::endl;
2543 std::cout <<
"Resplot rref: " << href2d_ <<
" (8)" << std::endl;
2549 savedhistos.push_back( refchain[j]+
"/"+histo.name() );
2551 std::cout <<
"Resplot rref: " << href2d_ <<
" (9)" << std::endl;
2558 std::string reghist = histo.name();
2560 std::cout <<
"hist: " << (chains[j]+
"/"+reghist) <<
"\tftest " << ftest << std::endl;
2564 htest =
Get( *fftest, chains[j]+
"/"+reghist, testrun, 0, &
savedhistos );
2566 std::cout <<
"\nhist: " << htest << std::endl;
2568 std::cout <<
"fftest: " << fftest->GetName() << std::endl;
2571 if (
contains( fftest->GetName(),
"-mc" ) ) translate_x =
false;
2573 if ( lumitest_trans && translate_x && !
contains( cc,
"-mc" ) ) htest =
trans( htest, translate_x );
2575 std::cout << xaxis << std::endl;
2578 std::cerr <<
"missing test histogram: " << (chains[j]+
" / "+reghist) <<
" " << htest<< std::endl;
2582 testfit( htest, htest->GetName() );
2590 if ( ffref ) hreft =
Get( *ffref, refchain[j]+
"/"+reghist, rawrefrun, chainmap );
2591 else noreftmp =
true;
2593 if ( hreft && lumiref_trans && translate_x && !
contains( cr,
"-mc" ) ) hreft =
trans( hreft, translate_x );
2595 std::cout <<
"hreft: " << hreft << std::endl;
2597 if ( std::string(htest->ClassName()).find(
"TH2")!=std::string::npos ) {
2598 std::cout <<
"Class TH2: " << htest->GetName() << std::endl;
2605 if ( std::string(htest->ClassName()).find(
"TH1")!=std::string::npos ) {
2606 std::cout <<
"Class TH1: " << htest->GetName() << std::endl;
2608 else if ( std::string(htest->ClassName()).find(
"TProfile")!=std::string::npos ) {
2609 std::cout <<
"Class TProf: " << htest->GetName() << std::endl;
2611 else if ( std::string(htest->ClassName()).find(
"TEfficiency")!=std::string::npos ) {
2612 std::cout <<
"Class TEff: " << htest->GetName() << std::endl;
2616 std::cout <<
"Resplot hreft: " << hreft <<
" (10)" <<
" " << noreftmp << std::endl;
2618 if ( !noreftmp && hreft==0 ) {
2619 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+reghist)
2620 <<
" " << hreft << std::endl;
2624 noreflabel=
"reference not found";
2631 std::cout <<
"Resplot hreft: " << hreft <<
" (10)" << std::endl;
2636 std::cout <<
"Resplot hreft: " << hreft->ClassName() <<
" (11)" << std::endl;
2638 if ( std::string(hreft->ClassName()).find(
"TH1")!=std::string::npos ) {
2639 href = (TH1F*)hreft->Clone();
2640 href->SetDirectory(0);
2651 std::cout <<
" \tget " << (chains[j]+
"/"+reghist) <<
"\thtest " << htest << std::endl;
2652 std::cout <<
" \tget " << (refchain[j]+
"/"+reghist) <<
"\thref " << href << std::endl;
2654 if ( htest==0 )
continue;
2656 if ( !noreftmp && href==0 ) {
2661 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2665 std::cout <<
"rebin: " << hname <<
"\t" << rebin << std::endl;
2666 if ( htest ) htest->Rebin(rebin);
2667 if ( href ) href->Rebin(rebin);
2668 for (
int ip=0 ; ip<10 ; ip++ ) std::cout << std::endl;
2673 if ( !
contains( histo.name(),
"rdz_vs_zed" ) &&
contains( histo.name(),
"1d") ) {
2674 std::cout <<
"Rebinning histogram: " << histo.name() << std::endl;
2675 if ( htest->GetNbinsX()>500 ) htest->Rebin(10);
2676 if ( href && href->GetNbinsX()>500 ) href->Rebin(10);
2681 if ( make_efficiencies && histo.name().find(
"zed_eff")!=std::string::npos ) {
2682 if ( htest->GetNbinsX()>100 ) htest->Rebin(5);
2683 if ( href && href->GetNbinsX()>100 ) href->Rebin(5);
2687 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2689 if ( scalepix && std::string(htest->GetName()).find(
"npix")!=std::string::npos )
Scale(htest,0.5);
2690 if ( scalepix && href && std::string(htest->GetName()).find(
"npix")!=std::string::npos )
Scale(href,0.5);
2692 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2695 htest->SetTitle(
"");
2696 if( href ) href->SetTitle(
"");
2699 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2704 std::cout <<
"done else" << std::endl;
2706 if ( do2D )
continue;
2708 std::cout <<
"done else:\t" << htest << std::endl;
2709 std::cout <<
"done else:\t" << htest->GetName() << std::endl;
2711 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2713 if ( !do2D && make_ref_efficiencies ) {
2715 std::cout <<
"make ref efficiencies" << std::endl;
2717 if ( htest && href ) {
2722 if (
contains( std::string(htest->GetName()),
"eff" ) && !
contains( std::string(htest->GetName()),
"_d" ) ){
2724 std::string effhist = histo.name();
2728 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos );
2732 TH1F* hrefnumt =
Get( *ffref, refchain[j]+
"/"+effhist+
"_n", rawrefrun, chainmap, &
savedhistos );
2736 if ( !noreftmp && hrefnumt!=0 ) {
2737 hrefnum = (TH1F*)hrefnumt->Clone();
2738 hrefnum->SetDirectory(0);
2748 std::cout <<
"done effs ? " << bayes <<
"\thtest: " << htest << std::endl;
2750 std::cout <<
"done effs ? " << bayes <<
"\t" << htest <<
" :: " << htest->GetName() << std::endl;
2754 std::cout <<
"make ref efficiencies" << std::endl;
2755 std::cout <<
"make ref efficiencies " << htest->GetName() << std::endl;
2757 if ( make_efficiencies && htest &&
contains( std::string(htest->GetName()),
"eff" ) && !
contains( std::string(htest->GetName()),
"_d" ) ) {
2759 std::string effhist = histo.name();
2763 if ( rebin!=1 ) std::cout << effhist <<
"\trebin: " << rebin << std::endl;
2766 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos ) ;
2767 htestden =
Get( *fftest, chains[j]+
"/"+effhist+
"_d", testrun, 0, &
savedhistos ) ;
2769 if ( htestnum==0 && htestden==0 ) {
2770 TEfficiency* eff = 0;
2775 htestnum = (TH1F*)eff->GetPassedHistogram();
2776 htestden = (TH1F*)eff->GetTotalHistogram();
2781 std::cout <<
"eff: htestnum: " << htestnum <<
"\thtestden: " << htestden << std::endl;
2784 double ars =
total_eff( htestnum, htestden );
2786 std::cout <<
"heff: " << effhist <<
"\t" << ars << std::endl;
2789 std::cout <<
"1: Bayesian error calculation " << htestnum <<
" " << htestden <<
"\tscale " << scale_eff << std::endl;
2791 if ( htestnum && htestden ) {
2796 if ( d0rebin_flag ) {
2797 htestnum =
d0rebin( htestnum );
2798 htestden =
d0rebin( htestden );
2800 else if ( rebin!=1 ) {
2801 htestnum =
Rebin(htestnum, rebin );
2802 htestden =
Rebin(htestden, rebin );
2805 std::cout <<
"test histogram name: : " << htestnum->GetName() <<
"\txaxis: " << xaxis <<
"\t" << std::endl;
2807 if ( make_efficiencies && std::string(htestnum->GetName()).find(
"ntrax_eff")!=std::string::npos ) {
2818 if (
contains( htest->GetName(),
"_vs_lb" ) ) {
2819 std::cout <<
"rebin " << histo.name() << std::endl;
2824 if ( make_efficiencies &&
contains( htest->GetName(),
"eta_eff" ) ) {
2825 std::cout <<
"rebin " << histo.name() << std::endl;
2833 if ( RANGEMAP && (effhist.find(
"ET")!=std::string::npos ) ) {
2834 std::cout <<
"\trange: " << j <<
" " << htest << std::endl;
2835 bnd.
range( chains[j], htestnum );
2836 bnd.
range( chains[j], htestden );
2839 if ( lumitest_trans && translate_x && !
contains( cc,
"-mc" ) ) {
2840 htestnum =
trans( htestnum, translate_x );
2841 htestden =
trans( htestden, translate_x );
2846 tgtest = e.Bayes(scale_eff);
2850 htest->SetName( (std::string(htestnum->GetName())+
"_eff").c_str() );
2852 std::cout <<
"effhist: " << effhist << std::endl;
2858 std::cout <<
"recalculating reference efficiencies ..." << std::endl;
2862 std::cout <<
"doin ..." << std::endl;
2865 TH1F* hrefnum =
Get( *ffref, refchain[j]+
"/"+histo.name()+
"_n", rawrefrun, chainmap );
2866 TH1F* hrefden =
Get( *ffref, refchain[j]+
"/"+histo.name()+
"_d", rawrefrun, chainmap );
2869 if ( hrefnum==0 && hrefden==0 ) {
2870 TEfficiency* eff = 0;
2872 eff =
Get<TEfficiency>( *ffref, refchain[j]+
"/"+histo.name(), rawrefrun, chainmap ) ;
2875 hrefnum = (TH1F*)eff->GetPassedHistogram();
2876 hrefden = (TH1F*)eff->GetTotalHistogram();
2883 std::cout <<
"2. Bayesian error calculation " << htestnum <<
" " << htestden <<
"\tscale " << scale_eff << std::endl;
2884 std::cout <<
"3. Bayesian error calculation " << hrefnum <<
" " << hrefden <<
"\tscale " << scale_eff_ref << std::endl;
2887 if ( hrefnum && hrefden ) {
2889 if ( lumiref_trans && translate_x && !
contains( cr,
"-mc" ) ) {
2890 hrefnum =
trans( hrefnum, translate_x );
2891 hrefden =
trans( hrefden, translate_x );
2897 if ( d0rebin_flag ) {
2901 else if ( rebin!=1 ) {
2902 hrefnum =
Rebin(hrefnum, rebin );
2903 hrefden =
Rebin(hrefden, rebin );
2907 std::cout << hrefnum <<
" " << hrefden << std::endl;
2919 std::cout <<
"dbg: htest: " << htest << std::endl;
2920 std::cout <<
"dbg: htest name " << htest->GetName() << std::endl;
2922 if (
true && histo.name().find(
"invmass")!=std::string::npos ) {
2923 testfit( htest, histo.name() );
2930 std::cout <<
"chains[j] " << chains[j] << std::endl;
2931 std::cout <<
"histo.name() " << histo.name() << std::endl;
2932 std::cout <<
"href " << href <<
"\t (TEfficiency " <<
isTEfficiency(href) <<
")" << std::endl;
2938 std::cout <<
"efficiency" << std::endl;
2941 std::cout <<
"href " << href <<
"\t (TEfficiency " <<
isTEfficiency(href) <<
")" << std::endl;
2945 std::cout <<
" no test histogram : " << (chains[j]+
"/"+histo.name()) << std::endl;
2950 if ( !noreftmp && href==0 ) {
2951 std::cout <<
" no ref histogram : " << (chains[j]+
"/"+histo.name()) << std::endl;
2954 noreflabel=
"reference not found";
2960 std::cout <<
"htest: " <<
isTEfficiency(htest) << std::endl;
2964 htest->GetYaxis()->SetTitleOffset(1.55);
2965 htest->GetXaxis()->SetTitleOffset(1.5);
2966 htest->GetXaxis()->SetTitle(xaxis.c_str());
2967 htest->GetYaxis()->SetTitle(yaxis.c_str());
2969 std::cout <<
"htest: " << htest <<
"\t" << __LINE__ << std::endl;
2974 std::cout <<
"cck: " << -1 << std::endl;
2976 href->GetYaxis()->SetTitleOffset(1.5);
2978 href->GetXaxis()->SetTitleOffset(1.5);
2980 std::cout <<
"xaxis: " << xaxis << std::endl;
2982 std::cout <<
"xaxis: " << href->GetXaxis()->GetTitle() << std::endl;
2986 std::cout <<
"cck: " << htest <<
" CNT" << std::endl;
2989 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2992 if ( !
contains(histo.name(),
"vtx_eff") &&
contains(histo.name(),
"ntracks") ) {
2994 double xm = htest->GetMean();
2997 double lxm = std::log10(xm);
2998 int newbins = int(0.5+xm/std::pow(10,
int(lxm)))*pow(10,
int(lxm));
2999 int nrebin = int( (newbins+5)/10 );
3002 std::cout <<
"rebin: " << htest->GetName() <<
"\tbins: " << nrebin << std::endl;
3003 htest->Rebin(nrebin);
3006 href->Rebin(nrebin);
3014 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3018 if ( plotname ==
"" ) {
3021 htest->SetTitle(
"");
3022 if ( href ) href->SetTitle(
"");
3026 htest->SetTitle(
"");
3027 if ( href ) href->SetTitle(
"");
3031 htest->SetTitle(
"");
3032 if ( href ) href->SetTitle(
"");
3036 htest->SetTitle(
"");
3037 if ( href ) href->SetTitle(
"");
3041 htest->SetTitle((
"FTK "+ histo.name()).c_str());
3042 if ( href ) href->SetTitle((
"FTK "+ histo.name()).c_str());
3046 plotname += histo.name();
3055 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3057 bool residual =
false;
3059 if (
contains(histo.name(),
"_res") ||
contains(histo.name(),
"residual_") ||
contains(histo.name(),
"1d") ) residual =
true;
3061 std::string collection =
basename( chains[j] );
3065 if ( collection.find(
"_InDet")!=std::string::npos ) collection.erase( 0, collection.find(
"_InDet")+1 );
3066 if ( actual_chain.find(
"_InDet")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_InDet") );
3069 std::cout <<
"raw: " << chains[j] << std::endl;
3071 std::cout <<
"track collection: " << collection << std::endl;
3072 std::cout <<
"actual chain: " << actual_chain << std::endl;
3074 std::regex rx(
"_HLT_[^_]*RoI.*");
3075 std::regex rx1(
"_HLT_[^_]*_RoI.*");
3077 std::cout <<
"\n\n\nactual_chain: " << actual_chain << std::endl;
3079 arsaway( actual_chain,
"_L1.*",
"" );
3080 arsaway( actual_chain,
"L1.*",
"" );
3082 actual_chain = std::regex_replace( actual_chain, std::regex(
"L1.*:" ),
"" );
3084 if ( actual_chain.find(
"jvt")!=std::string::npos ) actual_chain.erase(
3085 actual_chain.find(
"jvt"),
3086 actual_chain.find(
"HLT_IDTrack")-actual_chain.find(
"jvt") );
3088 std::cout <<
" : " << actual_chain <<
"\n\n\n" << std::endl;
3091 actual_chain = std::regex_replace( actual_chain, std::regex(
"_HLT_IDTrack.*" ),
"" );
3094 collection = std::regex_replace( collection, std::regex(
".*HLT_IDTrack_"),
"IDTrack " );
3095 collection = std::regex_replace( collection, std::regex(
"IDTrack "),
"" );
3096 collection = std::regex_replace( std::regex_replace( collection, rx,
"" ), rx1,
"" );
3098 if ( actual_chain.find(
"HLT_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"HLT_IDTrack_"), 12 );
3099 if ( actual_chain.find(
"_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_IDTrack_"), 9 );
3100 if ( actual_chain.find(
"IDTrack")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"IDTrack"), 7 );
3101 if ( actual_chain.find(
"_idperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_idperf"), 7 );
3102 if ( actual_chain.find(
"_bperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_bperf"), 6 );
3103 if ( actual_chain.find(
"_boffperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_boffperf"), 9 );
3104 if ( actual_chain.find(
"_HLT_")!=std::string::npos ) actual_chain.replace( actual_chain.find(
"_HLT_"), 5,
" " );
3105 if ( actual_chain.find(
"HLT_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"HLT_"), 4 );
3109 if ( collection.find(
"_IDTrkNoCut")!=std::string::npos ) collection.erase( collection.find(
"_IDTrkNoCut"), 11 );
3110 if ( collection.find(
"xAODCnv")!=std::string::npos ) collection.erase( collection.find(
"xAODCnv"), 7 );
3111 if ( collection.find(
"HLT_IDTrack_")!=std::string::npos ) collection.erase( collection.find(
"HLT_IDTrack_"), 12 );
3112 if ( collection.find(
"HLT_IDTrack")!=std::string::npos ) collection.erase( collection.find(
"HLT_IDTrack"), 11 );
3113 if ( collection.find(
"Tracking")!=std::string::npos ) collection.replace( collection.find(
"Tracking"), 8,
"Trk" );
3114 if ( collection.find(
"InDetTrigTrk_")!=std::string::npos ) collection.erase( collection.find(
"InDetTrigTrk_"), 13 );
3115 if ( collection.find(
"HLT_xAODTracks_")!=std::string::npos ) collection.erase( collection.find(
"HLT_xAODTracks_"), 15 );
3116 if ( collection.find(
"_HLT_")!=std::string::npos ) collection.replace( collection.find(
"_HLT_"), 5,
" " );
3117 if ( collection.find(
"HLT_")!=std::string::npos ) collection.erase( collection.find(
"HLT_"), 4 );
3119 std::string c = actual_chain +
" : " + collection;
3121 std::cout <<
"track collection: " << collection <<
" <-" << std::endl;
3122 std::cout <<
"actual chain: " << actual_chain <<
" <-" << std::endl;
3128 std::cout <<
"use label: " << c <<
"\tchains size " << chains.size() <<
"\t" << usrlabels.size() << std::endl;
3130 std::cout <<
"chains.size() " << chains.size() <<
" " << j << std::endl;
3131 std::cout <<
"chains.size() " << chains.size() <<
" " << j << std::endl;
3133 std::cout <<
"chains[j] : " << j <<
" " << chains[j] << std::endl;
3135 std::cout <<
"userlabels.size() " << usrlabels.size() << std::endl;
3137 if ( usrlabels.size() < j+1 ) {
3138 if ( usrlabels.size()!=0 ) std::cerr <<
"userlabels not large enough - not using userlabels" << std::endl;
3140 else c = usrlabels[ j ];
3142 std::cout <<
"use label: c: " << c << std::endl;
3148 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3152 std::cout <<
"\n\n\n\nxaxis: " << xaxis << std::endl;
3156 if ( ALLRANGEMAP || xaxis.find(
"p_{T}")!=std::string::npos || xaxis.find(
"E_{T}")!=std::string::npos ) {
3158 if ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) {
3159 bnd.
range( chains[j], htest );
3160 if ( href ) bnd.
range( chains[j], href );
3163 if ( RANGEMAP || ALLRANGEMAP ) {
3167 std::cout <<
"\n\n\nctags " << ctags.size() <<
"\n\n" << std::endl;
3169 for (
size_t ic=0 ; ic<ctags.size() ; ic++ ) {
3173 std::cout <<
"\n\nic: " << ic <<
" " << ctags[ic] <<
" " << ccolours[ic] <<
"\n\n" << std::endl;
3175 if ( chains[j].
find(ctags[ic])!=std::string::npos ) {
3176 std::cout <<
"\ttag " << ctags[ic] <<
" \tcolour: " << ccolours[ic] <<
"\tstyle: " << cstyles[ic] << std::endl;
3177 htest->SetLineColor( ccolours[ic] );
3178 htest->SetMarkerColor( ccolours[ic] );
3179 htest->SetMarkerStyle( cstyles[ic] );
3182 tgtest->SetLineColor(htest->GetMarkerColor());
3183 tgtest->SetMarkerStyle(htest->GetMarkerStyle());
3184 tgtest->SetMarkerColor(htest->GetMarkerColor());
3192 std::cout <<
"test: " << chains[j] <<
"chains colour: " << htest->GetMarkerColor() << std::endl;
3198 std::cout <<
"movin' on ..." << std::endl;
3200 std::cout <<
"chain: " << chains[j] <<
" \t marker colour: " << htest->GetMarkerColor() << std::endl;
3204 std::cout <<
"Plotter marker : " << htest->GetMarkerColor() <<
" " << htest->GetMarkerStyle() << std::endl;
3206 std::cout <<
"SHT CNT " << htest << std::endl;
3209 if ( uselabels ) plots.push_back(
Plotter( htest, href,
" " + chain_name[j] + c, tgtest ) );
3211 std::cout <<
"using label: " << c << std::endl;
3212 plots.push_back(
Plotter( htest, href, c, tgtest ) );
3215 std::cout <<
"AxisInfo: " << xaxis << std::endl;
3217 plots.back().xaxis( &(histo.xaxis()) );
3218 plots.back().yaxis( &(histo.yaxis()) );
3220 std::cout <<
"c: " << c <<
"\t" << ftest->GetName() << std::endl;
3223 plots.back().mc(
true );
3224 translate_x =
false;
3229 if ( ALLRANGEMAP || ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) ) plots.back().max_entries( ccolours.size() );
3231 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3233 if ( make_ref_efficiencies ) {
3235 if ( htestnum && hrefnum ) {
3240 double range =
h->GetMaximum()-
h->GetMinimum();
3242 if ( range<0.2*scale_eff ) {
3244 double fmax = int( (
h->GetMaximum() + 20)*0.1 )*0.1*scale_eff;
3245 double fmin = int( (
h->GetMinimum() - 10)*0.1 )*0.1*scale_eff;
3247 if ( fmax>1*scale_eff ) fmax = 1.02*scale_eff;
3248 if ( fmin<0 ) fmin = 0;
3250 h->SetMinimum(fmin);
3251 h->SetMaximum(fmax);
3261 std::cout <<
"means: " << drawmeans <<
" " << means << std::endl;
3263 std::cout <<
"chi2: " << std::endl;
3265 std::cout <<
"htest " << htest << std::endl;
3266 std::cout <<
"href " << href << std::endl;
3268 std::cout <<
"chi2: " <<
chi2( htest, href ) <<
"\t histo name: " << histo.name() << std::endl;
3270 testfit( htest, histo.name() );
3273 if ( href ) Chi2.push_back(
label(
"chi2 = %5.2lf / %2.0lf",
chi2( htest, href ),
double(htest->GetNbinsX()) ) );
3275 std::cout <<
"Chi2.push_back()" << std::endl;
3277 if ( drawmeans || means ) {
3279 double mean_95 = htest->GetMean();
3280 double dmean_95 = htest->GetMeanError();
3281 double rms_95 = htest->GetRMS();
3282 double drms_95 = htest->GetRMSError();
3284 Mean.push_back(
label(
" mean = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3286 MeanLF.push_back(
label(
"mean = %6.4lf #pm %6.4lf", mean_95, dmean_95) );
3287 RMS.push_back(
label(
" rms = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3291 std::cout <<
"residual: " << residual <<
" " << drawresiduals << std::endl;
3293 if ( residual && drawresiduals ) {
3297 xpos = xpos_original;
3299 std::cout <<
"calculating resolutions : " << histo.name() <<
" " << htest->GetName() << std::endl;
3303 double mean_95 = d95->GetParameter(1);
3304 double dmean_95 = d95->GetParError(1);
3305 double rms_95 = d95->GetParameter(2);
3306 double drms_95 = d95->GetParError(2);
3308 std::cout <<
"\t\t" << histo.name()
3309 <<
"\tmean: " << mean_95 <<
" +- " << dmean_95
3310 <<
"\trms: " << rms_95 <<
" +- " << drms_95 << std::endl;
3315 for (
int ip=-2 ; ip<9 ; ip++ ) {
3316 if ( std::fabs(mean_95) >= std::pow( 10.,
double(-ip) ) ) {
3322 for (
int ip=-2 ; ip<9 ; ip++ ) {
3323 if ( std::fabs(rms_95) >= std::pow( 10.,
double(-ip) ) ) {
3332 std::cout <<
"\t\t" << histo.name()
3333 <<
"\tmean: " << mean_95 <<
" +- " << dmean_95 <<
" : pow " << mean_power
3334 <<
"\trms: " << rms_95 <<
" +- " << drms_95 <<
" : pow " << rms_power << std::endl;
3337 if ( mean_power == 0 ) {
3338 Mean.push_back(
label(
"mean_{95} = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3341 Mean.push_back(
label(
"mean_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3342 mean_95*std::pow(10.,
double(mean_power)), dmean_95*std::pow(10,
double(mean_power)), -mean_power ) );
3346 if ( rms_power == 0 ) {
3347 RMS.push_back(
label(
"rms_{95} = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3350 RMS.push_back(
label(
"rms_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3351 rms_95*std::pow(10.,
double(rms_power)), drms_95*std::pow(10,
double(rms_power)), -rms_power ) );
3357 double mean_95ref = d95ref->GetParameter(1);
3358 double dmean_95ref = d95ref->GetParError(1);
3359 double rms_95ref = d95ref->GetParameter(2);
3360 double drms_95ref = d95ref->GetParError(2);
3362 std::cout <<
"\t\t" << histo.name()
3363 <<
"\tmean ref: " << mean_95ref <<
" +- " << dmean_95ref <<
" : pow " << mean_power
3364 <<
"\trms ref: " << rms_95ref <<
" +- " << drms_95ref <<
" : pow " << rms_power << std::endl;
3366 if ( mean_power == 0 ) {
3367 MeanRef.push_back(
label(
"mean_{95} ref = %4.2lf #pm %4.2lf", mean_95ref, dmean_95ref) );
3370 MeanRef.push_back(
label(
"mean_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3371 mean_95ref*std::pow(10,
double(mean_power)), dmean_95ref*std::pow(10,
double(mean_power)), -mean_power ) );
3376 if ( rms_power == 0 ) {
3377 RMSRef.push_back(
label(
"rms_{95} ref = %4.2lf #pm %4.2lf", rms_95ref, drms_95ref ) );
3380 RMSRef.push_back(
label(
"rms_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3381 rms_95ref*std::pow(10,
double(rms_power)), drms_95ref*std::pow(10,
double(rms_power)), -rms_power ) );
3386 if ( href ) href->Sumw2();
3391 if ( href )
Norm( href );
3393 Norm( htest, 1, xinfo.
lo(), xinfo.
hi() );
3394 if ( href )
Norm( href, 1, xinfo.
lo(), xinfo.
hi() );
3401 Norm( href, 1, xinfo.
lo(), xinfo.
hi() );
3411 if ( !noreftmp && normref &&
3420 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3427 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3429 std::cout <<
"duff: " << xinfo << std::endl;
3432 plots.sortx( xinfo );
3434 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3443 rmin = plots.realmin( plots.lo(), plots.hi() );
3444 rmax = plots.realmax( plots.lo(), plots.hi() );
3453 rmin = plots.realmin();
3454 rmax = plots.realmax();
3459 int csize = chains.size() + taglabels.size() + ( atlasstyle ? 1 : 0 );
3461 if ( yinfo.
log() && rmin>0 && rmax>0 ) {
3464 double delta = std::log10(rmax)-std::log10(rmin);
3469 yminset = rmin*std::pow(10,-delta*0.1);
3471 double newdelta = std::log10(rmax) - std::log10(yminset) + 0.05*delta;
3473 if ( csize<10 ) ymaxset = rmin*std::pow(10,newdelta/(1-0.07*csize));
3474 else ymaxset = rmin*std::pow(10,newdelta*2);
3476 if ( yminset!=yminset ) {
3477 std::cerr <<
" range error " << delta <<
" " << yminset <<
" " << ymaxset <<
"\t(" << rmin <<
" " << rmax <<
")" << std::endl;
3491 double delta = rmax-rmin;
3493 yminset = rmin-0.1*delta;
3495 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3497 double newdelta = rmax - yminset + 0.05*delta;
3499 if ( csize<10 ) ymaxset = yminset + newdelta/(1-0.09*csize);
3500 else ymaxset = yminset + newdelta*2;
3503 double delta = rmax-rmin;
3505 ymaxset = rmax+0.1*delta;
3507 double newdelta = ymaxset - rmin - 0.05*delta;
3509 if ( csize<10 ) yminset = ymaxset - newdelta/(1-0.09*csize);
3510 else yminset = ymaxset - newdelta*2;
3512 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3521 yminset = yinfo.
lo();
3522 ymaxset = yinfo.
hi();
3526 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3535 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3537 if ( yminset>yinfo.
lo() ) yminset = yinfo.
lo();
3538 if ( ymaxset<yinfo.
hi() ) ymaxset = yinfo.
hi();
3542 if ( make_efficiencies &&
contains(histo.name(),
"_eff") ) {
3544 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3552 if ( ymaxset!=0 || yminset!=0 ) {
3554 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3556 plots.Max( ymaxset );
3557 plots.Min( yminset );
3560 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3562 if ( yminset!=0 || ymaxset!=0 ) {
3563 if ( yminset>0 ) plots.SetLogy(yinfo.
log());
3564 else plots.SetLogy(
false);
3566 else plots.SetLogy(yinfo.
log());
3570 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3576 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3578 plots.Draw( legend );
3580 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3582 if ( atlasstyle )
ATLASLabel( xpos, ypositions[0]+deltay, atlaslabel, labelcolour, ncolsp, nrowsp );
3584 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3586 for (
unsigned it=0 ; it<taglabels.size() ; it++ ) {
3587 DrawLabel( xpos, ypositions[it], taglabels[it], labelcolour, 0.04 );
3590 for (
unsigned it=0 ; it<taglabels2.size() ; it++ ) {
3591 DrawLabel( xpos+0.35, ypositions2[it], taglabels2[it], labelcolour, 0.04 );
3596 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3598 std::cout <<
"means: " << means << std::endl;
3603 for (
unsigned j=0 ; j<MeanLF.size() ; j++ )
DrawLabel( 0.2, (0.85-(j+chains.size()-1)*0.035), MeanLF[j],
colours[j%6] );
3610 if ( ( !nostats || !nomeans ) && !noplots ) {
3611 if ( dochi2 )
for (
unsigned j=0 ; j<Chi2.size() ; j++ )
DrawLabel( 0.75, 0.85-j*0.035, Chi2[j],
colours[j%6] );
3612 if ( ( (
contains(histo.name(),
"_res") ||
3614 histo.name()==
"pT" ||
3615 contains(histo.name(),
"residual_") ||
3616 contains(histo.name(),
"vs_pt") ) && !
contains(histo.name(),
"sigma") ) || drawmeans ) {
3618 if (
contains(histo.name(),
"_res") ||
contains(histo.name(),
"residual_") ||
contains(histo.name(),
"1d") || drawresiduals ) {
3619 for (
unsigned j=0 ; j<chains.size() ; j++ ) {
3621 if ( j<MeanRef.size() ) {
3622 if ( !nomeans )
DrawLabel( xpos_original, (ytop-j*0.035), MeanRef[j],
colours[j%6] );
3623 DrawLabel( xpos_original, (ytop-0.035*chains.size()-j*0.035)-0.01, RMSRef[j],
colours[j%6] );
3626 if ( j<Mean.size() ) {
3628 DrawLabel( 0.62, (ytop-0.035*chains.size()-j*0.035)-0.01, RMS[j],
colours[j%6] );
3635 if ( xinfo.
log() ) gPad->SetLogx(
true);
3636 else gPad->SetLogx(
false);
3638 if ( yinfo.
log() ) gPad->SetLogy(
true);
3639 else gPad->SetLogy(
false);
3641 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3645 if ( make_ref_efficiencies ) {
3650 plots_eff.
Draw( legend_eff );
3653 if ( !noreflabel.empty() )
DrawLabel(0.1, 0.06, noreflabel, kRed, 0.03 );
3672 std::string useplotname;
3674 if ( panel.
size()>1 ) {
3675 useplotname = panel.
name();
3676 replace( useplotname,
'/',
'_' );
3679 useplotname = plotname;
3682 useplotname.erase(
std::remove( useplotname.begin(), useplotname.end(),
'+' ), useplotname.end() );
3685 std::string printbase = dir + useplotname + tag;
3689 if ( !nopdf )
print_pad( printbase+
".pdf" );
3690 if ( !nopng )
print_pad( printbase+
".png" );
3691 if ( Cfile )
print_pad( printbase+
".C" );
3693 std::cout << std::endl;
3698 if (
tc )
delete tc;
3703 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3709 bool files_duplicated = ( fref_==ftest_ );
3711 if ( deleteref && !files_duplicated ) {
3717 std::cout <<
"main() cleaning up reference file" << std::endl;
3719 TFile* newout =
new TFile(
".newout.root",
"recreate");
3725 TDirectory*
base = gDirectory;
3727 for (
unsigned i=0 ; i<
savedhistos.size() ; i++ ) {
3734 for (
unsigned j=0 ; j<
dirs.size()-1 ; j++ ) {
3735 std::cout <<
"\t" <<
dirs[j] << std::endl;
3736 TDirectory* renedir = gDirectory->GetDirectory(
dirs[j].c_str() );
3737 if ( renedir==0 ) gDirectory->mkdir(
dirs[j].c_str() );
3738 gDirectory->cd(
dirs[j].c_str() );
3745 if ( !noreftmp && href ) {
3746 std::cout << i <<
" " <<
savedhistos[i] <<
" 0x" << href << std::endl;
3747 href->Write(
dirs.back().c_str() );
3761 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3765 if ( fref_ && !files_duplicated ) fref_->Close();
3766 if ( ftest_ ) ftest_->Close();
3770 if ( deleteref && !noref ) {
3771 std::cout <<
"ref " << frefname <<
"\ttest " << ftestname << std::endl;
3772 if ( frefname != ftestname && !files_duplicated ) {
3773 std::string cmd = std::string(
"mv ") + frefname +
" " + frefname +
".bak";
3774 std::system( cmd.c_str() );
3776 cmd = std::string(
"mv .newout.root ") + std::string(frefname);
3777 std::system( cmd.c_str() );
3780 std::cerr <<
"reference file and test file are the same - not replacing" << std::endl;
3786 if ( fref_ && !files_duplicated )
delete fref_;
3787 if ( ftest_ )
delete ftest_;