975int main(
int argc,
char** argv) {
977 gErrorIgnoreLevel = kError;
980 std::cout <<
"\n---------------------------------\n";
981 std::cout <<
"\n comparitor is off ...\n";
983 if ( argc<4 )
return usage(argv[0], -1,
"too few arguments");
989 std::string tag =
"";
990 std::string key =
"";
992 std::string dir =
"";
994 std::string ftestname =
"";
995 std::string frefname =
"";
1000 bool effset =
false;
1002 double effmax = 102;
1004 std::string defreflabel =
"";
1008 std::vector<std::string> usrlabels;
1009 bool uselabels =
false;
1010 bool addinglabels =
false;
1012 std::vector<std::string> taglabels;
1013 std::vector<std::string> taglabels2;
1014 bool addingtags =
false;
1015 bool addingtags2 =
false;
1017 bool lumiref_trans =
false;
1018 bool lumitest_trans =
false;
1020 bool make_efficiencies =
true;
1022 bool make_ref_efficiencies =
false;
1023 bool refit_resplots =
false;
1024 bool refitref_resplots =
false;
1026 bool nostats =
false;
1027 bool nomeans =
false;
1030 bool atlasstyle =
false;
1031 bool deleteref =
false;
1032 bool nowatermark =
false;
1033 bool noplots =
false;
1037 bool notitle =
true;
1038 bool dochi2 =
false;
1039 bool normref =
false;
1040 bool scalepix =
false;
1041 bool oldrms =
false;
1042 bool addchains =
false;
1043 bool usechainref =
false;
1046 bool RANGEMAP =
false;
1047 bool ALLRANGEMAP =
false;
1051 std::string atlaslabel_tmp =
"Internal";
1054 double scale_eff = -1;
1055 double scale_eff_ref = -1;
1057 std::string configfile =
"";
1064 std::string pattern =
"";
1065 std::string regex =
"";
1067 std::string patternr =
"";
1068 std::string regexr =
"";
1070 std::string patternt =
"";
1071 std::string regext =
"";
1073 std::string basedir =
"";
1075 std::string xpattern =
"";
1076 std::string xregex =
"";
1078 std::vector<std::string> chains;
1079 std::vector<std::string> refchains;
1081 bool addingrefchains =
false;
1083 std::string mapfile =
"";
1085 std::vector<std::string> chainfiles;
1091 bool refbands =
false;
1093 for(
int i=1; i<argc; i++){
1094 std::string arg = argv[i];
1096 ifdbg(
"\ncnt: " + arg );
1099 if ( arg.find(
'-')!=0 && addinglabels ) {
1100 std::string
label = arg;
1103 usrlabels.push_back(
label );
1106 else addinglabels =
false;
1108 if ( arg.find(
'-')!=0 && addingrefchains ) {
1109 refchains.push_back( arg );
1112 else addingrefchains =
false;
1114 if ( arg.find(
'-')!=0 && addingtags ) {
1115 taglabels.push_back(
fullreplace( arg,
"__",
" " ) );
1116 std::cout <<
"\tadding tag label: " << taglabels.back() << std::endl;
1119 else addingtags =
false;
1121 if ( arg.find(
'-')!=0 && addingtags2 ) {
1122 taglabels2.push_back(
fullreplace( arg,
"__",
" " ) );
1123 std::cout <<
"\tadding tag label: " << taglabels2.back() << std::endl;
1126 else addingtags2 =
false;
1128 ifdbg(
"starting if cascade: "+arg );
1130 if ( arg==
"-h" || arg==
"--help" ) {
1131 return usage(argv[0], 0);
1133 else if ( arg==
"-c" || arg==
"--config" ) {
1134 if ( ++i<argc ) configfile=argv[i];
1135 else return usage(argv[0], -1,
"no config file provided");
1138 else if ( arg==
"--jl" ) {
1142 else if ( arg==
"--eps" ) {
1146 else if ( arg==
"-t" || arg==
"--tag" ) {
1147 if ( ++i<argc ) tag=std::string(
"-")+argv[i];
1148 else return usage(argv[0], -1,
"no tag provided");
1151 else if ( arg==
"-l" || arg==
"--labels" ) {
1152 addinglabels =
true;
1155 else if ( arg==
"-el" ) {
1159 else if ( arg==
"-k" || arg==
"--key" ) {
1160 if ( ++i<argc ) key=argv[i];
1161 else return usage(argv[0], -1,
"no key provided");
1164 else if ( arg==
"--run" ) {
1166 else return usage(argv[0], -1,
"no run number provided");
1169 else if ( arg==
"-m" || arg==
"--mapfile" ) {
1170 if ( ++i<argc ) mapfile=argv[i];
1171 else return usage(argv[0], -1,
"no mapfile provided");
1174 else if ( arg==
"-d" || arg==
"--dir" ) {
1175 if ( ++i<argc ) dir=argv[i];
1176 else return usage(argv[0], -1,
"no directory provided");
1179 else if ( arg==
"--lumi" ) {
1180 lumitest_trans =
true;
1181 lumiref_trans =
true;
1184 else if ( arg==
"--lumitest" ) {
1185 lumitest_trans =
true;
1186 ifdbg(
"--lumitest");
1188 else if ( arg==
"--lumiref" ) {
1189 lumiref_trans =
true;
1192 else if ( arg==
"-rb" || arg==
"--refbands" ) {
1194 ifdbg(
"--refbands");
1196 else if ( arg==
"-b" || arg==
"--bdir" ) {
1197 if ( ++i<argc ) basedir=argv[i];
1198 else return usage(argv[0], -1,
"no directory provided");
1201 else if ( arg==
"--taglabels" ) {
1203 ifdbg(
"--taglabels");
1205 else if ( arg==
"--taglabels2" ) {
1207 ifdbg(
"--taglabels2");
1209 else if ( arg==
"--unscalepix" ) {
1211 ifdbg(
"--unscalepix");
1213 else if ( arg==
"--scalepix" ) {
1215 ifdbg(
"--scalepix");
1217 else if ( arg==
"-ac" || arg==
"--addchains" ) {
1219 ifdbg(
"--sddchains");
1221 else if ( arg==
"-yrange" ) {
1223 if ( ++i<argc ) effmin=std::atof(argv[i]);
1224 else return usage(argv[0], -1,
"no range specified");
1225 if ( ++i<argc ) effmax=std::atof(argv[i]);
1226 else return usage(argv[0], -1,
"no upper y limit specified");
1229 else if ( arg==
"-e" || arg==
"--efficiencies" ) {
1230 make_ref_efficiencies =
true;
1231 ifdbg(
"--efficiencies");
1233 else if ( arg==
"-r" || arg==
"--refit" ) {
1234 refit_resplots =
true;
1237 else if ( arg==
"-rr" || arg==
"--refitref" ) {
1238 refitref_resplots =
true;
1239 ifdbg(
"--refitref");
1241 else if ( arg==
"--oldrms" ) {
1245 else if ( arg==
"-nw" || arg==
"--nowatermark" ) {
1248 ifdbg(
"--nowatermark");
1250 else if ( arg==
"--chi2" ) {
1254 else if ( arg==
"-ns" || arg==
"--nostats" ) {
1258 else if ( arg==
"-nm" || arg==
"--nomeans" ) {
1262 else if ( arg==
"--means" ) {
1266 else if ( arg==
"-nt" || arg==
"--notitle" ) {
1270 else if ( arg==
"-nr" || arg==
"--noref" ) {
1275 else if ( arg==
"--normref" ) {
1279 else if ( arg==
"-rc" || arg==
"--refchains" ) {
1280 addingrefchains =
true;
1281 ifdbg(
"--refchains");
1283 else if ( arg==
"-uc" || arg==
"--usechainref" ) {
1285 ifdbg(
"--usechainref");
1287 else if ( arg==
"-nb" || arg==
"--nobayes" ) {
1291 else if ( arg==
"-es" || arg==
"--effscale" ) {
1292 if ( ++i<argc ) scale_eff=std::atof(argv[i]);
1293 else return usage(argv[0], -1,
"no efficiency scale provided");
1294 ifdbg(
"--effscale");
1296 else if ( arg==
"-er" || arg==
"--effscaleref" ) {
1297 if ( ++i<argc ) scale_eff_ref=std::atof(argv[i]);
1298 else return usage(argv[0], -1,
"no efficiency scale for the reference histograms provided");
1299 ifdbg(
"--effscaleref");
1301 else if ( arg==
"--ncols" ) {
1302 if ( ++i<argc ) ncols=std::atoi(argv[i]);
1303 else return usage(argv[0], -1,
"no number of columns provided");
1306 else if ( arg==
"-np" || arg==
"--noplots" ) {
1310 else if ( arg==
"-C" || arg==
"--Cfiles" ) {
1314 else if ( arg==
"--deleteref" ) {
1316 ifdbg(
"--deleteref");
1318 else if ( arg==
"--nopng" ) {
1322 else if ( arg==
"--nopdf" ) {
1326 else if ( arg==
"-as" || arg==
"--atlasstyle" ) {
1329 ifdbg(
"--atlasstyle");
1331 else if ( arg==
"--tp" ) {
1332 make_efficiencies =
false;
1335 else if ( arg==
"-q" || arg==
"--quiet" ) {
1339 else if ( arg==
"-al" || arg==
"--atlaslabel" ) {
1340 if ( ++i<argc ) atlaslabel_tmp=argv[i];
1341 else return usage(argv[0], -1,
"no label provided");
1342 ifdbg(
"--atlaslabel");
1344 else if ( arg==
"-xo" || arg==
"--xoffset" ) {
1345 if ( ++i<argc ) xoffset=std::atof(argv[i]);
1346 else return usage(argv[0], -1,
"no xoffset provided");
1349 else if ( arg==
"-yp" || arg==
"--ypos" ) {
1350 if ( ++i<argc ) ypos_in=std::atof(argv[i]);
1351 else return usage(argv[0], -1,
"no y position provided");
1354 else if ( arg==
"-xe" || arg==
"--xerror" ) {
1355 if ( ++i<argc ) xerror=std::atof(argv[i]);
1356 else return usage(argv[0], -1,
"no x error provided");
1359 else if ( arg==
"-s" || arg==
"--swap" ) {
1360 if ( ++i<argc ) pattern=argv[i];
1361 else return usage(argv[0], -1,
"no patterns provided");
1362 if ( ++i<argc ) regex=argv[i];
1363 else return usage(argv[0], -1,
"no target pattern provided");
1366 else if ( arg==
"--swapt" ) {
1367 if ( ++i<argc ) patternt=argv[i];
1368 else return usage(argv[0], -1,
"no patterns provided");
1369 if ( ++i<argc ) regext=argv[i];
1370 else return usage(argv[0], -1,
"no target pattern provided");
1373 else if ( arg==
"--swapr" ) {
1374 if ( ++i<argc ) patternr=argv[i];
1375 else return usage(argv[0], -1,
"no patterns provided");
1376 if ( ++i<argc ) regexr=argv[i];
1377 else return usage(argv[0], -1,
"no target pattern provided");
1380 else if ( arg==
"-sx" || arg==
"--swapaxtitles" ) {
1381 if ( ++i<argc ) xregex=argv[i];
1382 else return usage(argv[0], -1,
"no target pattern provided");
1383 if ( ++i<argc ) xpattern=argv[i];
1384 else return usage(argv[0], -1,
"no patterns provided");
1385 ifdbg(
"--swapxtitles");
1387 else if ( arg.find(
'-')==0 ) {
1388 std::cerr <<
"unknown option: " << arg <<
"\n" << std::endl;
1389 return usage(argv[0], -4);
1392 ifdbg(
"arg: + "+arg);
1393 if ( ftestname==
"" ) ftestname = arg;
1394 else if ( frefname==
"" ) frefname = arg;
1396 std::string
file =
"";
1398 if ( arg.find(
":file:")!=std::string::npos ) {
1399 file = arg.substr( 0, arg.find(
":file:") );
1400 chainfiles.push_back(
file );
1401 arg = arg.substr(arg.find(
":file:")+6,arg.size());
1404 std::string chain = arg;
1408 chains.push_back(chain);
1410 std::cout <<
"file: " <<
file <<
"\tchain: " << chain << std::endl;
1416 if ( ftestname.empty() ) {
1417 std::cerr <<
"main(): test file not specified " << std::endl;
1421 if ( !
exists(ftestname) ) {
1422 std::cerr <<
"main(): test file " << ftestname <<
" does not exist" << std::endl;
1426 std::vector<TFile*> chainTFiles;
1428 if ( chainfiles.size()==0 ) ftest_ = TFile::Open( ftestname.c_str() );
1431 chainTFiles.resize(chainfiles.size());
1432 for (
size_t i=0 ; i<chainfiles.size() ; i++ ) {
1433 chainTFiles[i] = TFile::Open( chainfiles[i].c_str() );
1434 if ( chainTFiles[i] == 0 ) {
1435 std::cerr <<
"\tfile: " << chainfiles[i] <<
" could not be opened" << std::endl;
1438 else std::cout <<
"\tchainfiles: " << chainfiles[i] <<
" " << chainTFiles[i] << std::endl;
1443 if ( noref==
false ) {
1444 if ( frefname.empty() ) {
1445 std::cerr <<
"main(): ref file not specified " << std::endl;
1455 if ( frefname==ftestname ) fref_ = ftest_;
1456 else if (
exists(frefname) ) fref_ = TFile::Open( frefname.c_str() );
1458 std::cerr <<
"main(): ref file " << frefname <<
" does not exist" << std::endl;
1464 else fref_ = ftest_;
1466 if ( chainfiles.size()==0 ) {
1468 std::cerr <<
"could not open test file " << ftestname << std::endl;
1472 if ( noref==
false && fref_==0 ) {
1473 std::cerr <<
"could not open files " << std::endl;
1479 defreflabel =
"failed to open reference file";
1484 if ( scale_eff == -1 ) scale_eff = 100;
1485 if ( scale_eff_ref == -1 ) scale_eff_ref = scale_eff;
1488 bool noreftmp = noref;
1490 if ( chains.size()==0 )
return usage(argv[0], -1,
"no chains specified");
1493 if ( basedir.size()>0 ) {
1494 if ( basedir[basedir.size()-1]!=
'/' ) basedir +=
"/";
1495 for (
size_t ic=chains.size() ; ic-- ; ) chains[ic] = basedir+chains[ic];
1498 if ( refchains.size()>0 && refchains.size()!=chains.size() )
return usage(argv[0], -1,
"not enough chains specified");
1500 if ( refchains.size()==0 ) refchains = chains;
1502 std::vector<std::string> chainref(chains.size(),
"");
1503 std::vector<std::string> chain_name(chains.size(),
"");
1505 std::vector<std::string> refchain(chainref.size(),
"");
1509 std::cout << argv[0] <<
" options:" << std::endl;
1510 std::cout <<
"\tATLAS style: " << ( atlasstyle ?
"true" :
"false" ) << std::endl;
1511 std::cout <<
"\tBayesian uncertainties: " << ( bayes ?
"true" :
"false" ) << std::endl;
1512 std::cout <<
"\trefit resplot uncertainties: " << ( refit_resplots ?
"true" :
"false" ) << std::endl;
1513 std::cout <<
"\tsuppress mean and rms stats: " << ( nostats ?
"true" :
"false" ) << std::endl;
1514 if ( !nostats ) std::cout <<
"\tsuppress meanstats: " << ( nomeans ?
"true" :
"false" ) << std::endl;
1515 std::cout <<
"\tsuppress png output: " << ( nopng ?
"true" :
"false" ) << std::endl;
1516 std::cout <<
"\tsuppress pdf output: " << ( nopdf ?
"true" :
"false" ) << std::endl;
1517 std::cout <<
"\tsuppress reference output: " << ( noref ?
"true" :
"false" ) << std::endl;
1518 std::cout <<
"\tuse chain references: " << ( usechainref ?
"true" :
"false" ) << std::endl;
1519 std::cout <<
"\tpanel ncols: " << ncols << std::endl;
1521 if ( usrlabels.size()>0 ) std::cout <<
"\tlabels: " << usrlabels.size() << std::endl;
1522 if ( taglabels.size()>0 ) std::cout <<
"\textra text: " << taglabels << std::endl;
1523 if ( taglabels2.size()>0 ) std::cout <<
"\textra text: " << taglabels2 << std::endl;
1526 for (
size_t il=0 ; il<usrlabels.size() ; il++ ) {
1527 std::cout <<
"usr label[" << il <<
"] : " << usrlabels[il] << std::endl;
1530 std::cout <<
"atlas style : " << atlasstyle << std::endl;
1538 gROOT->SetStyle(
"Plain");
1540 gStyle->SetLineScalePS(1);
1544 gStyle->SetErrorX(xerror);
1546 gStyle->SetPadLeftMargin(0.15);
1547 gStyle->SetPadBottomMargin(0.15);
1549 gStyle->SetPadRightMargin(0.02);
1550 gStyle->SetPadTopMargin(0.05);
1552 std::cout <<
"Chains: " << std::endl;
1553 for (
unsigned ic=0 ; ic<chains.size() ; ic++ ) std::cout <<
"\t" << chains[ic] << std::endl;
1555 if ( usrlabels.size()>0 ) std::cout <<
"labels: " << usrlabels << std::endl;
1557 if ( usrlabels.size()>0 && usrlabels.size()==chains.size() ) uselabels =
true;
1561 TTree* dataTree = 0;
1562 TString* releaseData =
new TString(
"");
1563 std::vector<std::string> release_data;
1566 if ( !nowatermark && ftest_ ) {
1568 dataTree = (TTree*)ftest_->Get(
"dataTree");
1571 dataTree->SetBranchAddress(
"ReleaseMetaData", &releaseData);
1573 for (
unsigned int i=0; i<dataTree->GetEntries() ; i++ ) {
1574 dataTree->GetEntry(i);
1575 release_data.push_back( releaseData->Data() );
1576 std::cout <<
"main() release data: " << release_data.back() <<
" : " << *releaseData << std::endl;
1580 std::cout <<
"release data size " << release_data.size() << std::endl;
1582 if ( release_data.size()>0 ) {
1583 if ( release_data.size()>1 ) std::cerr <<
"main() more than one release - using only the first" << std::endl;
1587 std::string rd = release_data[0];
1589 while ( rd.size()>0 ) {
1591 std::string nightly =
chop(rd,
" " );
1593 if (
contains(nightly,
"private" ) ) {
1594 for (
int ic=0 ; ic<4 ; ic++ )
chop(release_data[0],
" " );
1595 release +=
" (" + release_data[0]+
")";
1600 if (
contains(nightly,
"nightly") ) {
1601 chop( nightly,
"/" );
1612 std::cout <<
"release: " <<
release << std::endl;
1620 std::cout <<
"trying to make directory" << std::endl;
1623 if ( mkdir( dir.c_str(), 0777 ) ) std::cerr <<
"main() couldn't create directory " << dir << std::endl;
1624 else std::cout <<
"main() output will be sent to directory " << dir << std::endl;
1628 if ( ftest_==0 && chainTFiles.size()>0 ) fref_ = ftest_ = chainTFiles[0];
1630 TFile* ftest = ftest_;
1631 TFile* fref = fref_;
1633 std::string testrun =
findrun( ftest );
1635 std::string rawrefrun =
"";
1636 std::string refrun =
"";
1638 if ( fref_ ) refrun = rawrefrun =
findrun( fref );
1640 std::cout <<
"testrun: " << testrun <<
"\nrefrun: " << refrun << std::endl;
1642 if ( !testrun.empty() && refrun != testrun ) {
1643 if ( pattern.empty() ) {
1650 if ( !refrun.empty() ) {
1652 std::string newtag =
"Reference: ";
1654 std::cout <<
"refrun: " << refrun << std::endl;
1657 while ( (pos=refrun.find(
'_'))!=std::string::npos ) refrun.replace( pos, 1,
" " );
1660 std::string rawrun = refrun.erase( refrun.find(
"run"), 4 );
1662 if (
contains(frefname, rawrun) ) {
1664 std::string
release = frefname;
1679 taglabels.push_back( newtag );
1681 std::cout <<
"tag labels: " << taglabels << std::endl;
1696 if ( !nowatermark ) {
1699 TH1D* htestev = (TH1D*)ftest->Get(
"event") ;
1700 TH1D* hrefev = (TH1D*)fref->Get(
"event") ;
1704 std::cout <<
"htestev " << htestev <<
" " << hrefev << std::endl;
1706 if ( htestev ) NeventTest = htestev->GetEntries();
1707 if ( hrefev ) NeventRef = hrefev->GetEntries();
1717 if ( NeventTest>1 ) std::cout <<
"Nevents Test: " << NeventTest << std::endl;
1718 if ( NeventRef>1 ) std::cout <<
"Nevents Ref: " << NeventRef << std::endl;
1722 if ( mapfile.empty() ) mapfile = configfile;
1725 std::cout <<
"mapfile: " << mapfile << std::endl;
1727 if ( !mapfile.empty() ) {
1731 if ( m.isTagDefined(
"ChainMap" ) ) {
1733 std::vector<std::string> chains = m.GetStringVector(
"ChainMap" );
1735 for (
size_t i=0 ; i<chains.size() ; i+=2 ) std::cout <<
"map: " << chains[i] <<
" -> " << chains[i+1] << std::endl;
1739 for (
size_t i=0 ; i<chains.size() ; i+=2 ) {
1740 chainmap->insert( chainmap_t::value_type( chains[i], chains[i+1] ) );
1743 std::cout <<
"\nusing chain map:" << std::endl;
1745 for ( chainmap_t::iterator itr=chainmap->begin() ; itr!=chainmap->end() ; itr++ ) {
1746 std::cout <<
"\t" << itr->first <<
"\t" << itr->second << std::endl;
1753 std::cout <<
"\ncreating chain and reference information ..." << std::endl;
1755 for (
size_t j=0; j<chains.size(); j++) {
1757 if ( !regex.empty() ) chains[j] =
fullreplace( chains[j], pattern, regex );
1758 if ( !regext.empty() ) chains[j] =
fullreplace( chains[j], patternt, regext );
1763 std::cout <<
"chain: " << chains[j] <<
"\taddchains: " << addchains << std::endl;
1765 if ( addchains && (
contains(chains[j],
"Shifter") || ( !
contains(chains[j],
"HLT_") && !
contains(chains[j],
"Fullscan" ) ) ) ) {
1767 TFile* fftest = ftest;
1769 if ( chainfiles.size()>0 && chainfiles.size()>j ) fftest = chainTFiles[j];
1771 TH1F* hchain =
Get( *fftest, chains[j]+
"/Chain", testrun );
1775 std::string name = hchain->GetTitle();
1777 if ( usechainref && !
contains(chains[j],
"Purity") ) {
1781 std::cout <<
"new chainref: " << chainref[j] << std::endl;
1783 std::string::size_type pos = chainref[j].find(
":for");
1784 if ( pos!=std::string::npos ) chainref[j].replace( pos, 4,
"_for" );
1785 std::replace( chainref[j].begin(), chainref[j].end(),
':',
'/');
1786 std::string newchain =
dirname(
dirname( chains[j]) ) +
"/Expert/" + chainref[j];
1787 chainref[j] = newchain;
1789 std::cout <<
"final chainref: " << chainref[j] << std::endl;
1793 std::cout <<
"chainref: " << chainref[j] << std::endl;
1795 while (
contains( name,
"HLT_" ) ) name = name.erase( name.find(
"HLT_"), 4 );
1797 std::cout <<
"name: " << name << std::endl;
1799 if (
contains( name,
":" ) ) chain_name[j] = name.substr( 0, name.find(
':') ) +
" : ";
1800 else chain_name[j] = name;
1802 if ( chain_name[j] ==
" : " ) chain_name[j] =
"";
1804 std::cout <<
"chain_name: " << chain_name[j] << std::endl;
1809 std::cout <<
"chainref size: " << chainref.size() <<
" " << refchains.size() << std::endl;
1811 for (
size_t j=0 ; j<chainref.size() ; j++ ) {
1812 std::cout <<
"chainref: " << chainref[j] <<
" :: " << refchains[j] << std::endl;
1815 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], pattern, regex );
1816 else refchain[j] =
fullreplace( refchains[j], pattern, regex );
1818 if ( !patternr.empty() ) {
1819 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], patternr, regexr );
1820 else refchain[j] =
fullreplace( refchains[j], patternr, regexr );
1823 std::cout <<
"refchain: " << refchain[j] << std::endl;
1826 std::cout <<
"done chains" << std::endl;
1830 std::vector<Panel> panels;
1837 std::vector<int> ccolours;
1838 std::vector<int> cstyles;
1840 std::vector<std::string> ctags;
1841 std::vector<std::string> ctaglabels;
1844 std::cout <<
"\n" << argv[0] <<
"\tconfigfile: " << configfile << std::endl;
1846 bool use_file_config =
false;
1848 if ( !configfile.empty() ) {
1850 if (
exists(configfile) ) {
1852 std::cout << argv[0] <<
":\treading configuration file " << configfile << std::endl;
1858 std::cout <<
"searching for panels" << std::endl;
1862 if (
rc.isTagDefined(
"panels" ) ) {
1864 std::cout << argv[0] <<
":\treading histogram panel configuration from file " << configfile << std::endl;
1866 use_file_config =
true;
1868 std::vector<std::string> panel_config =
rc.GetStringVector(
"panels" );
1870 std::vector<string> panel_columns;
1872 if (
rc.isTagDefined(
"panel_columns") ) {
1873 panel_columns =
rc.GetStringVector(
"panel_columns" );
1874 if ( panel_columns.size()%2 )
return usage( argv[0], -1,
"incorrect panel settings" );
1878 for (
size_t ipanel=panel_config.size() ; ipanel-- ; ) {
1880 std::vector<std::string> raw_input =
rc.GetStringVector( panel_config[ipanel] );
1884 if ( panel_columns.size() ) {
1885 std::vector<string>::iterator itr =
find( panel_columns.begin(), panel_columns.end(), panel_config[ipanel] );
1886 if ( itr!=panel_columns.end() ) tncols = std::atoi( (++itr)->c_str() );
1889 Panel p( panel_config[ipanel], tncols );
1891 if ( raw_input.empty() ) {
1892 std::cerr <<
"no plots provided" << std::endl;
1896 for (
size_t iraw=0 ; iraw+6<=raw_input.size() ; iraw += 6 ) p.push_back( raw_input.begin()+iraw, raw_input.begin()+iraw+6 );
1898 panels.push_back( p );
1903 else if (
rc.isTagDefined(
"histos" ) ) {
1905 std::cout << argv[0] <<
":\treading histogram configuration from file " << configfile << std::endl;
1907 use_file_config =
true;
1909 std::vector<std::string> raw_input =
rc.GetStringVector(
"histos" );
1911 for (
size_t iraw=0 ; iraw+6<=raw_input.size() ; iraw += 6) {
1912 HistDetails h( raw_input.begin()+iraw, raw_input.begin()+iraw+6 );
1915 panels.push_back( p );
1920 if (
rc.isTagDefined(
"Bands" ) &&
rc.isTagDefined(
"Labels" ) ) {
1921 bnd =
bands(
rc.GetVector(
"Bands"),
rc.GetStringVector(
"Labels" ) );
1925 if (
rc.isTagDefined(
"Colours") ) {
1927 std::vector<int> ccolours =
rc.GetIntVector(
"Colours");
1929 std::cout <<
"remap colours: " << ccolours << std::endl;
1933 for (
size_t i=6 ; i-- ; ) new_colours[i] =
colours[i];
1935 for (
size_t i=0 ; i<ccolours.size() && i<6 ; i++ ) {
1936 if ( ccolours[i]<6 ) new_colours[i] =
colours[ccolours[i]];
1939 for (
size_t i=6 ; i-- ; )
colours[i] = new_colours[i];
1944 if (
rc.isTagDefined(
"Styles") ) {
1946 std::vector<int> cstyles =
rc.GetIntVector(
"Styles");
1948 std::cout <<
"remap markers: " << cstyles << std::endl;
1952 for (
size_t i=6 ; i-- ; ) new_markers[i] =
markers[i];
1954 for (
size_t i=0 ; i<cstyles.size() && i<6 ; i++ ) {
1955 if ( cstyles[i]<6 ) new_markers[i] =
markers[cstyles[i]];
1958 for (
size_t i=6 ; i-- ; )
markers[i] = new_markers[i];
1963 for (
int i=6 ; i-- ; ) std::cout <<
"\tcolours[" << i <<
"] = " <<
colours[i] << std::endl;
1964 for (
int i=6 ; i-- ; ) std::cout <<
"\tmarkers[" << i <<
"] = " <<
markers[i] << std::endl;
1967 if (
rc.isTagDefined(
"Tags") ) ctags =
rc.GetStringVector(
"Tags");
1968 if (
rc.isTagDefined(
"TagLabels") ) ctaglabels =
rc.GetStringVector(
"TagLabels");
1969 if (
rc.isTagDefined(
"TagLabels") ) usrlabels =
rc.GetStringVector(
"TagLabels");
1972 if (
rc.isTagDefined(
"Styles") ) {
1973 for (
size_t is=0 ; is<cstyles.size() && is<6 ; is++ ) {
1982 std::cout << argv[0] <<
"\tuserlabels :" << usrlabels <<
":" << std::endl;
1984 if (
rc.isTagDefined(
"RANGEMAP") ) RANGEMAP =
true;
1985 if (
rc.isTagDefined(
"ALLRANGEMAP") ) ALLRANGEMAP =
true;
1987 std::cout <<
"Extra: " <<
rc.isTagDefined(
"Extra") << std::endl;
1989 if (
rc.isTagDefined(
"Extra") ) taglabels.push_back(
fullreplace(
rc.GetString(
"Extra"),
"__",
" " ) );
1994 std::cerr << argv[0] <<
":\t config file not found: " << configfile << std::endl;
2000 if ( !use_file_config ) {
2002 std::cout <<
"using default panels" << std::endl;
2022 std::string pnames[3] = {
"eff",
"res",
"diff" };
2024 for (
size_t ip=0 ; ip<inpanels.size() ; ip++ ) {
2025 Panel p( pnames[ip]+
"_panel", 2 );
2026 for (
size_t ih=0 ; ih<inpanels[ip].size() ; ih++ ) p.push_back( inpanels[ip][ih] );
2027 panels.push_back( p );
2033 std::cout <<
"taglabels" << std::endl;
2035 for (
size_t it=0 ; it<taglabels.size() ; it++ ) std::cout << taglabels[it] << std::endl;
2036 for (
size_t it=0 ; it<taglabels2.size() ; it++ ) std::cout << taglabels2[it] << std::endl;
2039 std::cout <<
"\npanels: " << panels.size() << std::endl;
2041 if ( panels.size()==0 )
return usage(argv[0], -1,
"no panels to plot");
2043 for (
size_t ip=0 ; ip<panels.size() ; ip++ ) std::cout << panels[ip] << std::endl;
2048 gStyle->SetPadRightMargin(0.05);
2049 gStyle->SetPadTopMargin(0.05);
2052 const Int_t Number = 3;
2053 Double_t Red[Number] = { 0.00, 0.00, 1.00 };
2054 Double_t Green[Number] = { 0.00, 5.00, 1.00 };
2055 Double_t Blue[Number] = { 0.00, 0.50, 0.00 };
2056 Double_t Length[Number] = { 0.00, 0.50, 1.00 };
2058 TColor::CreateGradientColorTable( Number, Length, Red, Green, Blue, nb );
2060 else gStyle->SetPalette(1);
2062 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2064 double rightmargin = gStyle->GetPadRightMargin();
2065 gStyle->SetPadRightMargin(0.1);
2069 gStyle->SetPadRightMargin(rightmargin);
2073 for (
size_t ipanel=0 ; ipanel<panels.size() ; ipanel++ ) {
2075 Panel& panel = panels[ipanel];
2077 std::cout <<
blue <<
"\n\n---------------------------------------------\n" <<
reset;
2079 std::cout << panel <<
"\n" << std::endl;
2081 int ncolsp = panel.
ncols();
2082 int nrowsp = panel.
nrows();
2086 std::cout <<
"\nncols: " << ncolsp <<
"\tnrows: " << nrowsp << std::endl;
2088 bool multipanel = ( panel.
size() > 1 );
2090 if ( panel.
size()==0 ) {
2091 std::cout <<
"panel empty: " << panel.
name() << std::endl;
2097 if ( panel.
size()>4 ) gStyle->SetLineScalePS(0.5);
2099 if ( multipanel ) extraw = 1.05;
2101 TCanvas*
tc =
new TCanvas(
"tc",
"", extraw*ncolsp*800, nrowsp*600 );
2105 const std::string& atlaslabel = atlaslabel_tmp;
2109 gStyle->SetLineScalePS(1);
2125 tc->Divide( ncolsp, nrowsp, 0.0001, 0.0003 );
2131 std::string plotname =
"";
2133 for (
size_t i=0 ; i<panel.
size() ; i++ ) {
2137 bool drawmeans =
false;
2138 bool drawresiduals =
true;
2141 if (
contains(histo.detail(),
"+mean" ) ) drawmeans =
true;
2142 if (
contains(histo.detail(),
"-residual") ) drawresiduals =
false;
2144 std::string xaxis = histo.xtitle();
2145 std::string yaxis = histo.ytitle();
2147 if ( !xregex.empty() ) {
2148 size_t pos = xaxis.find(xregex);
2149 if ( pos!=std::string::npos ) xaxis.replace( pos, xregex.size(), xpattern );
2150 pos = yaxis.find(xregex);
2151 if ( pos!=std::string::npos ) yaxis.replace( pos, xregex.size(), xpattern );
2154 const AxisInfo& xinfo = histo.xaxis();
2155 const AxisInfo& yinfo = histo.yaxis();
2160 std::string hname = histo.name();
2161 std::string
detail = histo.detail();
2163 bool translate_x =
false;
2165 if ( ( lumiref_trans || lumitest_trans ) &&
contains(histo.xtitle(),
"Pile-up" ) ) translate_x =
true;
2169 if ( translate_x ) {
2170 xinfo.
lo( xinfo.
lo()*(1-0.054) );
2172 xinfo.
hi( xinfo.
hi()*(1-0.054) );
2179 bool d0rebin_flag =
false;
2185 rebin = std::atof(
detail.substr(
detail.find(
"+Rebin")+6,
detail.size() ).c_str() );
2189 rebin = std::atof(
detail.substr(
detail.find(
"+rebin")+6,
detail.size() ).c_str() );
2192 int labelcolour = kBlack;
2194 int npanel = nrowsp*(i/nrowsp) + i%nrowsp + 1 ;
2196 std::cout <<
"panel: panel: " << panel.
name() <<
"\tsubpanel: " << npanel << std::endl;
2198 if ( multipanel )
tc->cd( npanel );
2206 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2208 std::cout <<
"main() processing histo[" << i <<
"] " << (i<10 ?
" " :
"" ) << histo.name() <<
"\t" << histo.xaxis() << std::endl;
2216 std::string noreflabel=defreflabel;
2221 if (
contains(histo.name(),
"eff") ||
contains(histo.name(),
"Eff_") ) ypos = 0.19;
2230 if ( ypos>0.5 ) ypos = 0.85;
2234 if ( ypos_in!=0 ) ypos = ypos_in;
2236 double xpos_original = xpos;
2240 if ( xinfo.
offset() != 0 ) {
2242 std::cout <<
"HA ! xinfo.offset: " << xinfo.
offset() << std::endl;
2249 if ( yinfo.
offset() != 0 ) {
2251 std::cout <<
"HA ! yinfo.offset: " << yinfo.
offset() << std::endl;
2261 size_t Nrows = chains.size();
2263 if ( ALLRANGEMAP || (RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos && ccolours.size() ) ) {
2264 Nrows = ( Nrows < ccolours.size() ? Nrows : ccolours.size() );
2267 int Nlines = Nrows + taglabels.size();
2269 std::vector<double> ypositions;
2270 std::vector<double> ypositions2;
2272 double deltay = (Nrows*0.055-0.005)/Nrows;
2275 double yhi = ypos-0.01;
2277 if ( ypos>0.5 ) ylo -= Nlines*deltay;
2278 else yhi += Nlines*deltay;
2280 ypositions.reserve(Nlines);
2281 for (
int ilines=0 ; ilines<Nlines ; ilines++ ) {
2282 ypositions.push_back( yhi - deltay*(ilines+0.5) );
2283 ypositions2.push_back( yhi - deltay*(ilines-0.5) );
2294 if ( !
contains(histo.name(),
"eff") && !
contains(histo.name(),
"Eff_") ) ylo -= 0.02;
2297 Legend legend( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
2298 Legend legend_eff( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
2301 std::vector<std::string> Mean;
2302 std::vector<std::string> MeanLF;
2303 std::vector<std::string> RMS;
2309 std::vector<std::string> Chi2;
2310 std::vector<std::string> MeanRef;
2311 std::vector<std::string> RMSRef;
2321 bool power_set =
false;
2329 for (
unsigned int j=0; j<chains.size(); j++) {
2333 TFile* fftest = ftest;
2334 TFile* ffref = fref;
2336 std::string cc = ftest->GetName();
2337 std::string cr =
"";
2339 if ( fref ) cr = fref->GetName();
2341 if ( chainfiles.size()>0 && chainfiles.size()>j ) ffref = fftest = chainTFiles[j];
2346 std::cout <<
"chain: " << chains[j] <<
"\taddchains: " << addchains << std::endl;
2347 std::cout <<
"chainref: " << chainref[j] << std::endl;
2361 TGraphAsymmErrors* tgtest = 0;
2363 std::cout <<
"refchain.size() " << refchain.size() << std::endl;
2365 std::cout <<
"refchain: " << refchain[j] << std::endl;
2369 gPad->SetRightMargin(0.03);
2373 labelcolour = kBlack;
2376 if (
contains(histo.name(),
"/2d") ) {
2379 labelcolour = kWhite;
2381 gPad->SetRightMargin(0.13);
2383 std::cout <<
"\n\nsee! it is a 2d histograms !!! " << histo.name() <<
"\n\n" << std::endl;
2387 std::cout <<
"\t2d: " << h2test << std::endl;
2391 h2test->GetYaxis()->SetTitleOffset(1.55);
2392 h2test->GetXaxis()->SetTitleOffset(1.5);
2393 h2test->GetXaxis()->SetTitle(xaxis.c_str());
2394 h2test->GetYaxis()->SetTitle(yaxis.c_str());
2396 const AxisInfo& xinfo = histo.xaxis();
2397 const AxisInfo& yinfo = histo.yaxis();
2399 std::cout << xinfo << std::endl;
2400 std::cout << yinfo << std::endl;
2403 h2test->GetYaxis()->SetRangeUser( yinfo.
lo(), yinfo.
hi() );
2409 h2test->GetXaxis()->SetRangeUser( xinfo.
lo(), xinfo.
hi() );
2417 h2test->DrawCopy(
"colz");
2419 if ( histo.detail().find(
"logz")!=std::string::npos ) gPad->SetLogz(
true);
2420 else gPad->SetLogz(
false);
2424 else if ( refit_resplots && (
contains(histo.name(),
"/sigma") ||
contains(histo.name(),
"/mean") ) ) {
2429 std::cout <<
red <<
"fetch 2d: " << histo.name() <<
reset << std::endl;
2431 bool bsigma =
false;
2432 if (
contains(histo.name(),
"/sigma") ) bsigma =
true;
2435 if (
contains(histo.name(),
"/mean") ) bmean =
true;
2437 std::string tmp_ = histo.name();
2440 if ( bsigma )
base =
chop( tmp_,
"/sigma" );
2441 if ( bmean )
base =
chop( tmp_,
"/mean" );
2443 std::cout <<
"refitting: " << histo.name() <<
"\tbase: " <<
base <<
"\tbsigma: " << bsigma <<
"\tbmean: " << bmean << std::endl;
2452 if ( ffref ) href2d =
Get<TH2D>( *ffref, chains[j]+
"/"+
base+
"/2d", testrun, chainmap );
2454 if ( href2d==0 ) href2d =
Get<TH2D>( *ffref, chains[j]+
"/"+
base+
"/2D", testrun, chainmap );
2456 if ( htest2d==0 )
continue;
2457 if ( !noreftmp && href2d==0 ) noreftmp =
true;
2459 std::cout <<
"href2d : " << href2d << std::endl;
2463 std::cout <<
"plotter" << std::endl;
2469 std::cout <<
"Resplot rtest\t" << rtest.
finalised() << std::endl;
2472 std::cout <<
"refitting ..." << std::endl;
2477 std::cout <<
"refitting (finalising) ..." << std::endl;
2481 rtest.
Mean()->DrawCopy();
2482 gPad->Print(
"Duff.pdf");
2485 std::cout <<
"bsigma: " << bsigma << std::endl;
2486 std::cout <<
"bmean: " << bmean << std::endl;
2488 if ( bsigma ) { htest = (TH1F*)rtest.
Sigma()->Clone(
"rtest_sigma"); htest->SetDirectory(0); }
2489 if ( bmean ) { htest = (TH1F*)rtest.
Mean()->Clone(
"rtest_mean"); htest->SetDirectory(0); }
2491 std::cout <<
reset << std::endl;
2494 std::cerr <<
red <<
"missing test histogram: " << (refchain[j]+
" / "+histo.name()) <<
" " << htest
2495 <<
"(test)" <<
reset << std::endl;
2499 std::cout <<
green <<
"htest: " << htest->GetName() <<
reset << std::endl;
2502 std::cout <<
"\nhisto.name(): " << histo.name() << std::endl;
2504 std::cout <<
reset << std::endl;
2506 if ( !d0mod && histo.name().find(
"d0_vs_phi")!=std::string::npos ) {
2510 std::cout <<
green <<
"\n\nbeam fitting !!" << histo.name() <<
reset << std::endl;
2512 TVirtualPad* old = gPad;
2514 std::cout <<
"old canvas: " << gPad << std::endl;
2516 std::cout <<
"dbg histo name: " << histo.name() << std::endl;
2522 if ( histo.name().find(
"_rec")!=std::string::npos ) {
2530 if ( histo.name().find(
"_rec")==std::string::npos ) {
2532 fitcanvas =
new TCanvas(
"fit",
"", 700, 600 );
2538 TVirtualPad* tp = gPad;
2546 rtest.
Mean()->SetDirectory(0);
2550 if ( histo.name().find(
"_rec")!=std::string::npos ) hf->SetTitle(
";Trigger #phi;Trigger d_{0} [mm]");
2551 else hf->SetTitle(
";Offline #phi;Offline d_{0} [mm]");
2553 TF1* tf =
new TF1(
"sinus",
"[0]*sin(x+[1])+[2]" );
2555 tf->SetLineWidth(1);
2557 hf->GetYaxis()->SetTitleOffset( hf->GetYaxis()->GetTitleOffset()*1.1 );
2560 TCanvas* tfc =
new TCanvas(
"tmp",
"", 700, 600 );
2566 double phi0 = tf->GetParameter(1);
2569 double x = tf->GetParameter(0)*cos(phi0);
2570 double y = tf->GetParameter(0)*sin(phi0);
2571 double off = tf->GetParameter(2);
2573 std::cout <<
"\tx = " <<
x << std::endl;
2574 std::cout <<
"\ty = " <<
y << std::endl;
2575 std::cout <<
"\toffset = " << off << std::endl;
2577 std::string cckstr = chains[j];
2579 cckstr = cckstr.substr( cckstr.find(
"HLT_IDTrack") );
2581 std::string vstr = chains[j];
2583 vstr.resize(vstr.find(
"_boffperf"));
2584 vstr.resize(vstr.find(
"_L1"));
2586 hf->SetMinimum( -0.03 );
2587 hf->SetMaximum( 0.03 );
2591 if ( first ) hf->DrawCopy();
2593 hf->DrawCopy(
"same");
2594 hf->DrawCopy(
"samee");
2604 std::string sht = chains[j]+
"-"+histo.name()+
"-fit.pdf";
2606 size_t p = sht.find(
"/");
2608 while ( p!=std::string::npos ) {
2614 gPad->Print( sht.c_str() );
2615 gPad->Print(
"sht.pdf" );
2617 std::cout <<
"CNT !!!" << std::endl;
2633 std::cout <<
"Resplot noreftmp " << noreftmp <<
" ... " << std::endl;
2636 if ( refitref_resplots ) {
2638 std::cout <<
"Resplot rref: " << href2d << std::endl;
2642 std::cout <<
"Resplot rref: " << href2d <<
" (2)" << std::endl;
2645 std::cout <<
"refitting (2) ..." << std::endl;
2650 std::cout <<
"refitting (2 - finalising) ..." << std::endl;
2655 std::cout <<
"Resplot rref: " << href2d <<
" (3)" << std::endl;
2657 if ( bsigma ) { hreft = (TH1F*)rref.
Sigma()->Clone(
"rref_sigma"); hreft->SetDirectory(0); }
2658 if ( bmean ) { hreft = (TH1F*)rref.
Mean()->Clone(
"rref_mean"); hreft->SetDirectory(0); }
2660 std::cout <<
"Resplot rref: " << href2d <<
" (4)" << std::endl;
2665 std::cout <<
"Resplot rref: " << href2d <<
" (5)" <<
reset << std::endl;
2667 hreft =
Get( *ffref, refchain[j]+
"/"+histo.name(), rawrefrun, chainmap );
2669 std::cerr <<
"ERROR: could not find " << (refchain[j]+
"/"+histo.name()) << std::endl;
2676 std::cout <<
"Resplot rref: " << href2d <<
" (6)" << std::endl;
2679 if ( !noreftmp && hreft==0 ) {
2681 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+histo.name()) <<
" " << htest <<
"(ref)" << std::endl;
2685 noreflabel=
"reference not found";
2693 std::cout <<
"Resplot rref: " << href2d <<
" (7)" << std::endl;
2695 href = (TH1F*)hreft->Clone();
2696 href->SetDirectory(0);
2698 std::cout <<
"Resplot href: " << href <<
" (7a)" << std::endl;
2702 std::cout <<
"Resplot rref: " << href2d <<
" (8)" << std::endl;
2708 savedhistos.push_back( refchain[j]+
"/"+histo.name() );
2710 std::cout <<
"Resplot rref: " << href2d <<
" (9)" << std::endl;
2717 std::string reghist = histo.name();
2719 std::cout <<
"hist: " << (chains[j]+
"/"+reghist) <<
"\tftest " << ftest << std::endl;
2723 htest =
Get( *fftest, chains[j]+
"/"+reghist, testrun, 0, &
savedhistos );
2725 std::cout <<
"\nhist: " << htest << std::endl;
2727 std::cout <<
"fftest: " << fftest->GetName() << std::endl;
2732 if ( lumitest_trans && translate_x && !
contains( cc,
"-mc" ) ) htest =
trans( htest, translate_x );
2734 std::cout << xaxis << std::endl;
2737 std::cerr <<
"missing test histogram: " << (chains[j]+
" / "+reghist) <<
" " << htest<< std::endl;
2741 testfit( htest, htest->GetName() );
2745 if ( ffref ) hreft =
Get( *ffref, refchain[j]+
"/"+reghist, rawrefrun, chainmap );
2746 else noreftmp =
true;
2748 if ( hreft && lumiref_trans && translate_x && !
contains( cr,
"-mc" ) ) hreft =
trans( hreft, translate_x );
2750 std::cout <<
"hreft: " << hreft << std::endl;
2752 if ( std::string(htest->ClassName()).find(
"TH2")!=std::string::npos ) {
2753 std::cout <<
"Class TH2: " << htest->GetName() << std::endl;
2758 if ( std::string(htest->ClassName()).find(
"TH1")!=std::string::npos ) {
2759 std::cout <<
"Class TH1: " << htest->GetName() << std::endl;
2761 else if ( std::string(htest->ClassName()).find(
"TProfile")!=std::string::npos ) {
2762 std::cout <<
"Class TProf: " << htest->GetName() << std::endl;
2764 else if ( std::string(htest->ClassName()).find(
"TEfficiency")!=std::string::npos ) {
2765 std::cout <<
"Class TEff: " << htest->GetName() << std::endl;
2769 std::cout <<
"Resplot hreft: " << hreft <<
" (10)" <<
" " << noreftmp << std::endl;
2771 if ( !noreftmp && hreft==0 ) {
2772 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+reghist)
2773 <<
" " << hreft << std::endl;
2777 noreflabel=
"reference not found";
2784 std::cout <<
"Resplot hreft: " << hreft <<
" (10)" << std::endl;
2788 std::cout <<
"Resplot hreft: " << hreft->ClassName() <<
" (11)" << std::endl;
2790 if ( std::string(hreft->ClassName()).find(
"TH1")!=std::string::npos ) {
2791 href = (TH1F*)hreft->Clone();
2792 href->SetDirectory(0);
2803 std::cout <<
" \tget " << (chains[j]+
"/"+reghist) <<
"\thtest " << htest << std::endl;
2804 std::cout <<
" \tget " << (refchain[j]+
"/"+reghist) <<
"\thref " << href << std::endl;
2806 if ( htest==0 )
continue;
2808 if ( !noreftmp && href==0 ) {
2813 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2817 std::cout <<
"rebin: " << hname <<
"\t" << rebin << std::endl;
2818 if ( htest ) htest->Rebin(rebin);
2819 if ( href ) href->Rebin(rebin);
2820 for (
int ip=0 ; ip<10 ; ip++ ) std::cout << std::endl;
2825 if ( !
contains( histo.name(),
"rdz_vs_zed" ) &&
contains( histo.name(),
"1d") ) {
2826 std::cout <<
"Rebinning histogram: " << histo.name() << std::endl;
2827 if ( htest->GetNbinsX()>500 ) htest->Rebin(10);
2828 if ( href && href->GetNbinsX()>500 ) href->Rebin(10);
2833 if ( make_efficiencies && histo.name().find(
"zed_eff")!=std::string::npos ) {
2834 if ( htest->GetNbinsX()>100 ) htest->Rebin(5);
2835 if ( href && href->GetNbinsX()>100 ) href->Rebin(5);
2839 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2841 if ( scalepix && std::string(htest->GetName()).find(
"npix")!=std::string::npos )
Scale(htest,0.5);
2842 if ( scalepix && href && std::string(htest->GetName()).find(
"npix")!=std::string::npos )
Scale(href,0.5);
2844 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2847 htest->SetTitle(
"");
2848 if( href ) href->SetTitle(
"");
2851 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2855 std::cout <<
"done else" << std::endl;
2857 if ( do2D )
continue;
2859 std::cout <<
"done else:\t" << htest << std::endl;
2860 std::cout <<
"done else:\t" << htest->GetName() << std::endl;
2862 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2864 if ( !d0mod && histo.name().find(
"d0_vs_phi")!=std::string::npos ) {
2866 if ( htest )
d0fit( histo, htest, chains[j] );
2867 if ( href )
d0fit( histo, href, chains[j] );
2870 if ( !do2D && make_ref_efficiencies ) {
2872 std::cout <<
"make ref efficiencies" << std::endl;
2874 if ( htest && href ) {
2879 if (
contains( std::string(htest->GetName()),
"eff" ) && !
contains( std::string(htest->GetName()),
"_d" ) ){
2881 std::string effhist = histo.name();
2885 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos );
2889 TH1F* hrefnumt =
Get( *ffref, refchain[j]+
"/"+effhist+
"_n", rawrefrun, chainmap, &
savedhistos );
2893 if ( !noreftmp && hrefnumt!=0 ) {
2894 hrefnum = (TH1F*)hrefnumt->Clone();
2895 hrefnum->SetDirectory(0);
2903 std::cout <<
"done effs ? " << bayes <<
"\thtest: " << htest <<
" :: " << htest->GetName() << std::endl;
2907 std::cout <<
"make ref efficiencies " << htest->GetName() << std::endl;
2909 if ( make_efficiencies && htest &&
contains( std::string(htest->GetName()),
"eff" ) && !
contains( std::string(htest->GetName()),
"_d" ) ) {
2911 std::string effhist = histo.name();
2915 if ( rebin!=1 ) std::cout << effhist <<
"\trebin: " << rebin << std::endl;
2918 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos ) ;
2919 htestden =
Get( *fftest, chains[j]+
"/"+effhist+
"_d", testrun, 0, &
savedhistos ) ;
2921 if ( htestnum==0 && htestden==0 ) {
2922 TEfficiency* eff = 0;
2927 htestnum = (TH1F*)eff->GetPassedHistogram();
2928 htestden = (TH1F*)eff->GetTotalHistogram();
2933 std::cout <<
"eff: htestnum: " << htestnum <<
"\thtestden: " << htestden << std::endl;
2936 double ars =
total_eff( htestnum, htestden );
2938 std::cout <<
"heff: " << effhist <<
"\t" << ars << std::endl;
2941 std::cout <<
"1: Bayesian error calculation " << htestnum <<
" " << htestden <<
"\tscale " << scale_eff << std::endl;
2943 if ( htestnum && htestden ) {
2948 if ( d0rebin_flag ) {
2949 htestnum =
d0rebin( htestnum );
2950 htestden =
d0rebin( htestden );
2952 else if ( rebin!=1 ) {
2953 htestnum =
Rebin(htestnum, rebin );
2954 htestden =
Rebin(htestden, rebin );
2957 std::cout <<
"test histogram name: : " << htestnum->GetName() <<
"\txaxis: " << xaxis <<
"\t" << std::endl;
2959 if ( make_efficiencies && std::string(htestnum->GetName()).find(
"ntrax_eff")!=std::string::npos ) {
2970 if (
contains( htest->GetName(),
"_vs_lb" ) ) {
2971 std::cout <<
"rebin " << histo.name() << std::endl;
2976 if ( make_efficiencies &&
contains( htest->GetName(),
"eta_eff" ) ) {
2977 std::cout <<
"rebin " << histo.name() << std::endl;
2985 if ( RANGEMAP && (effhist.find(
"ET")!=std::string::npos ) ) {
2986 std::cout <<
"\trange: " << j <<
" " << htest << std::endl;
2987 bnd.
range( chains[j], htestnum );
2988 bnd.
range( chains[j], htestden );
2991 if ( lumitest_trans && translate_x && !
contains( cc,
"-mc" ) ) {
2992 htestnum =
trans( htestnum, translate_x );
2993 htestden =
trans( htestden, translate_x );
2998 tgtest = e.Bayes(scale_eff);
3002 htest->SetName( (std::string(htestnum->GetName())+
"_eff").c_str() );
3004 std::cout <<
"effhist: " << effhist << std::endl;
3010 std::cout <<
"recalculating reference efficiencies ..." << std::endl;
3014 std::cout <<
"doin ..." << std::endl;
3017 TH1F* hrefnum =
Get( *ffref, refchain[j]+
"/"+histo.name()+
"_n", rawrefrun, chainmap );
3018 TH1F* hrefden =
Get( *ffref, refchain[j]+
"/"+histo.name()+
"_d", rawrefrun, chainmap );
3021 if ( hrefnum==0 && hrefden==0 ) {
3022 TEfficiency* eff = 0;
3024 eff =
Get<TEfficiency>( *ffref, refchain[j]+
"/"+histo.name(), rawrefrun, chainmap ) ;
3027 hrefnum = (TH1F*)eff->GetPassedHistogram();
3028 hrefden = (TH1F*)eff->GetTotalHistogram();
3035 std::cout <<
"2. Bayesian error calculation " << htestnum <<
" " << htestden <<
"\tscale " << scale_eff << std::endl;
3036 std::cout <<
"3. Bayesian error calculation " << hrefnum <<
" " << hrefden <<
"\tscale " << scale_eff_ref << std::endl;
3039 if ( hrefnum && hrefden ) {
3041 if ( lumiref_trans && translate_x && !
contains( cr,
"-mc" ) ) {
3042 hrefnum =
trans( hrefnum, translate_x );
3043 hrefden =
trans( hrefden, translate_x );
3049 if ( d0rebin_flag ) {
3053 else if ( rebin!=1 ) {
3054 hrefnum =
Rebin(hrefnum, rebin );
3055 hrefden =
Rebin(hrefden, rebin );
3059 std::cout << hrefnum <<
" " << hrefden << std::endl;
3071 std::cout <<
"dbg: htest: " << htest << std::endl;
3072 std::cout <<
"dbg: htest name " << htest->GetName() << std::endl;
3074 if (
true && histo.name().find(
"invmass")!=std::string::npos ) {
3075 testfit( htest, histo.name() );
3082 std::cout <<
"chains[j] " << chains[j] << std::endl;
3083 std::cout <<
"histo.name() " << histo.name() << std::endl;
3084 std::cout <<
"href " << href <<
"\t (TEfficiency " <<
isTEfficiency(href) <<
")" << std::endl;
3090 std::cout <<
"efficiency" << std::endl;
3093 std::cout <<
"href " << href <<
"\t (TEfficiency " <<
isTEfficiency(href) <<
")" << std::endl;
3097 std::cout <<
" no test histogram : " << (chains[j]+
"/"+histo.name()) << std::endl;
3102 if ( !noreftmp && href==0 ) {
3103 std::cout <<
" no ref histogram : " << (chains[j]+
"/"+histo.name()) << std::endl;
3106 noreflabel=
"reference not found";
3112 std::cout <<
"htest: " <<
isTEfficiency(htest) << std::endl;
3116 htest->GetYaxis()->SetTitleOffset(1.55);
3117 htest->GetXaxis()->SetTitleOffset(1.5);
3118 htest->GetXaxis()->SetTitle(xaxis.c_str());
3119 htest->GetYaxis()->SetTitle(yaxis.c_str());
3121 std::cout <<
"htest: " << htest <<
"\t" << __LINE__ << std::endl;
3126 href->GetYaxis()->SetTitleOffset(1.5);
3127 href->GetXaxis()->SetTitleOffset(1.5);
3128 std::cout <<
"xaxis: " << href->GetXaxis()->GetTitle() << std::endl;
3132 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3135 if ( !
contains(histo.name(),
"vtx_eff") &&
contains(histo.name(),
"ntracks") ) {
3137 double xm = htest->GetMean();
3140 double lxm = std::log10(xm);
3141 int newbins = int(0.5+xm/std::pow(10,
int(lxm)))*pow(10,
int(lxm));
3142 int nrebin = int( (newbins+5)/10 );
3145 std::cout <<
"rebin: " << htest->GetName() <<
"\tbins: " << nrebin << std::endl;
3146 htest->Rebin(nrebin);
3149 href->Rebin(nrebin);
3157 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3161 if ( plotname ==
"" ) {
3164 htest->SetTitle(
"");
3165 if ( href ) href->SetTitle(
"");
3169 htest->SetTitle(
"");
3170 if ( href ) href->SetTitle(
"");
3174 htest->SetTitle(
"");
3175 if ( href ) href->SetTitle(
"");
3179 htest->SetTitle(
"");
3180 if ( href ) href->SetTitle(
"");
3184 htest->SetTitle((
"FTK "+ histo.name()).c_str());
3185 if ( href ) href->SetTitle((
"FTK "+ histo.name()).c_str());
3189 plotname += histo.name();
3198 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3200 bool residual =
false;
3202 if (
contains(histo.name(),
"_res") ||
contains(histo.name(),
"residual_") ||
contains(histo.name(),
"1d") ) residual =
true;
3204 std::string collection =
basename( chains[j] );
3208 if ( collection.find(
"_InDet")!=std::string::npos ) collection.erase( 0, collection.find(
"_InDet")+1 );
3209 if ( actual_chain.find(
"_InDet")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_InDet") );
3212 std::cout <<
"raw: " << chains[j] << std::endl;
3213 std::cout <<
"track collection: " << collection << std::endl;
3214 std::cout <<
"actual chain: " << actual_chain << std::endl;
3216 std::regex rx(
"_HLT_[^_]*RoI.*");
3217 std::regex rx1(
"_HLT_[^_]*_RoI.*");
3219 std::cout <<
"\n\n\nactual_chain: " << actual_chain << std::endl;
3221 arsaway( actual_chain,
"_L1.*",
"" );
3222 arsaway( actual_chain,
"L1.*",
"" );
3224 actual_chain = std::regex_replace( actual_chain, std::regex(
"L1.*:" ),
"" );
3226 if ( actual_chain.find(
"jvt")!=std::string::npos ) actual_chain.erase(
3227 actual_chain.find(
"jvt"),
3228 actual_chain.find(
"HLT_IDTrack")-actual_chain.find(
"jvt") );
3230 std::cout <<
" : " << actual_chain <<
"\n\n\n" << std::endl;
3233 actual_chain = std::regex_replace( actual_chain, std::regex(
"_HLT_IDTrack.*" ),
"" );
3236 collection = std::regex_replace( collection, std::regex(
".*HLT_IDTrack_"),
"IDTrack " );
3237 collection = std::regex_replace( collection, std::regex(
"IDTrack "),
"" );
3238 collection = std::regex_replace( std::regex_replace( collection, rx,
"" ), rx1,
"" );
3240 if ( actual_chain.find(
"HLT_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"HLT_IDTrack_"), 12 );
3241 if ( actual_chain.find(
"_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_IDTrack_"), 9 );
3242 if ( actual_chain.find(
"IDTrack")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"IDTrack"), 7 );
3243 if ( actual_chain.find(
"_idperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_idperf"), 7 );
3244 if ( actual_chain.find(
"_bperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_bperf"), 6 );
3245 if ( actual_chain.find(
"_boffperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_boffperf"), 9 );
3246 if ( actual_chain.find(
"_HLT_")!=std::string::npos ) actual_chain.replace( actual_chain.find(
"_HLT_"), 5,
" " );
3247 if ( actual_chain.find(
"HLT_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"HLT_"), 4 );
3251 if ( collection.find(
"_IDTrkNoCut")!=std::string::npos ) collection.erase( collection.find(
"_IDTrkNoCut"), 11 );
3252 if ( collection.find(
"xAODCnv")!=std::string::npos ) collection.erase( collection.find(
"xAODCnv"), 7 );
3253 if ( collection.find(
"HLT_IDTrack_")!=std::string::npos ) collection.erase( collection.find(
"HLT_IDTrack_"), 12 );
3254 if ( collection.find(
"HLT_IDTrack")!=std::string::npos ) collection.erase( collection.find(
"HLT_IDTrack"), 11 );
3255 if ( collection.find(
"Tracking")!=std::string::npos ) collection.replace( collection.find(
"Tracking"), 8,
"Trk" );
3256 if ( collection.find(
"InDetTrigTrk_")!=std::string::npos ) collection.erase( collection.find(
"InDetTrigTrk_"), 13 );
3257 if ( collection.find(
"HLT_xAODTracks_")!=std::string::npos ) collection.erase( collection.find(
"HLT_xAODTracks_"), 15 );
3258 if ( collection.find(
"_HLT_")!=std::string::npos ) collection.replace( collection.find(
"_HLT_"), 5,
" " );
3259 if ( collection.find(
"HLT_")!=std::string::npos ) collection.erase( collection.find(
"HLT_"), 4 );
3260 if ( collection.find(
"_extra")!=std::string::npos ) collection.resize( collection.find(
"_extra") );
3262 if ( actual_chain.size()>25 ) {
3263 size_t pos = actual_chain.find_last_of(
"_");
3264 while ( pos!=std::string::npos && actual_chain.size()>25 ) {
3265 actual_chain.resize(pos);
3266 pos = actual_chain.find_last_of(
"_");
3270 std::cout <<
blue <<
"actual chain: " << actual_chain <<
"\tcollection: " << collection <<
reset << std::endl;
3272 std::string c = actual_chain +
" : " + collection;
3274 std::cout <<
"track collection: " << collection <<
" <-" << std::endl;
3275 std::cout <<
"actual chain: " << actual_chain <<
" <-" << std::endl;
3281 std::cout <<
"use label: " << c <<
"\tchains size " << chains.size() <<
"\t" << usrlabels.size() << std::endl;
3283 std::cout <<
"chains.size() " << chains.size() <<
" " << j << std::endl;
3284 std::cout <<
"chains.size() " << chains.size() <<
" " << j << std::endl;
3286 std::cout <<
"chains[j] : " << j <<
" " << chains[j] << std::endl;
3288 std::cout <<
"userlabels.size() " << usrlabels.size() << std::endl;
3290 if ( usrlabels.size() < j+1 ) {
3291 if ( usrlabels.size()!=0 ) std::cerr <<
"userlabels not large enough - not using userlabels" << std::endl;
3293 else c = usrlabels[ j ];
3295 std::cout <<
"use label: c: " << c << std::endl;
3299 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3301 std::cout <<
blue <<
"xaxis: " << xaxis <<
reset << std::endl;
3303 if ( ALLRANGEMAP || xaxis.find(
"p_{T}")!=std::string::npos || xaxis.find(
"E_{T}")!=std::string::npos ) {
3305 if ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) {
3306 bnd.
range( chains[j], htest );
3307 if ( href ) bnd.
range( chains[j], href );
3310 if ( RANGEMAP || ALLRANGEMAP ) {
3314 std::cout <<
"\n\n\nctags " << ctags.size() <<
"\n\n" << std::endl;
3316 for (
size_t ic=0 ; ic<ctags.size() ; ic++ ) {
3318 std::cout <<
"\n\nic: " << ic <<
" " << ctags[ic] <<
" " << ccolours[ic] <<
"\n\n" << std::endl;
3320 if ( chains[j].
find(ctags[ic])!=std::string::npos ) {
3321 std::cout <<
"\ttag " << ctags[ic] <<
" \tcolour: " << ccolours[ic] <<
"\tstyle: " << cstyles[ic] << std::endl;
3322 htest->SetLineColor( ccolours[ic] );
3323 htest->SetMarkerColor( ccolours[ic] );
3324 htest->SetMarkerStyle( cstyles[ic] );
3327 tgtest->SetLineColor(htest->GetMarkerColor());
3328 tgtest->SetMarkerStyle(htest->GetMarkerStyle());
3329 tgtest->SetMarkerColor(htest->GetMarkerColor());
3337 std::cout <<
"test: " << chains[j] <<
"chains colour: " << htest->GetMarkerColor() << std::endl;
3342 std::cout <<
"movin' on ..." << std::endl;
3344 std::cout <<
"chain: " << chains[j] <<
" \t marker colour: " << htest->GetMarkerColor() << std::endl;
3346 std::cout <<
"Plotter marker : " << htest->GetMarkerColor() <<
" " << htest->GetMarkerStyle() << std::endl;
3349 if ( uselabels ) plots.push_back(
Plotter( htest, href,
" " + chain_name[j] + c, tgtest ) );
3351 std::cout <<
"using label: " << c << std::endl;
3352 plots.push_back(
Plotter( htest, href, c, tgtest ) );
3355 std::cout <<
"AxisInfo: " << xaxis << std::endl;
3357 plots.back().xaxis( &(histo.xaxis()) );
3358 plots.back().yaxis( &(histo.yaxis()) );
3360 std::cout <<
"c: " << c <<
"\t" << ftest->GetName() << std::endl;
3363 std::cout <<
"refbands: " << refbands << std::endl;
3364 plots.back().mc(
true );
3365 translate_x =
false;
3368 if ( ALLRANGEMAP || ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) ) plots.back().max_entries( ccolours.size() );
3370 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3372 if ( make_ref_efficiencies ) {
3374 if ( htestnum && hrefnum ) {
3379 double range =
h->GetMaximum()-
h->GetMinimum();
3381 if ( range<0.2*scale_eff ) {
3383 double fmax = int( (
h->GetMaximum() + 20)*0.1 )*0.1*scale_eff;
3384 double fmin = int( (
h->GetMinimum() - 10)*0.1 )*0.1*scale_eff;
3386 if ( fmax>1*scale_eff ) fmax = 1.02*scale_eff;
3387 if ( fmin<0 ) fmin = 0;
3389 h->SetMinimum(fmin);
3390 h->SetMaximum(fmax);
3400 std::cout <<
"means: " << drawmeans <<
" " << means << std::endl;
3402 std::cout <<
"chi2: " << std::endl;
3404 std::cout <<
"htest " << htest << std::endl;
3405 std::cout <<
"href " << href << std::endl;
3407 std::cout <<
"chi2: " <<
chi2( htest, href ) <<
"\t histo name: " << histo.name() << std::endl;
3409 testfit( htest, histo.name() );
3412 if ( href ) Chi2.push_back(
label(
"chi2 = %5.2lf / %2.0lf",
chi2( htest, href ),
double(htest->GetNbinsX()) ) );
3414 std::cout <<
"Chi2.push_back()" << std::endl;
3416 if ( drawmeans || means ) {
3418 double mean_95 = htest->GetMean();
3419 double dmean_95 = htest->GetMeanError();
3420 double rms_95 = htest->GetRMS();
3421 double drms_95 = htest->GetRMSError();
3423 Mean.push_back(
label(
" mean = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3424 MeanLF.push_back(
label(
"mean = %6.4lf #pm %6.4lf", mean_95, dmean_95) );
3425 RMS.push_back(
label(
" rms = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3429 std::cout <<
"residual: " << residual <<
" " << drawresiduals << std::endl;
3431 if ( residual && drawresiduals ) {
3435 xpos = xpos_original;
3437 std::cout <<
"calculating resolutions : " << histo.name() <<
" " << htest->GetName() << std::endl;
3441 double mean_95 = d95->GetParameter(1);
3442 double dmean_95 = d95->GetParError(1);
3443 double rms_95 = d95->GetParameter(2);
3444 double drms_95 = d95->GetParError(2);
3446 std::cout <<
"\t\t" << histo.name()
3447 <<
"\tmean: " << mean_95 <<
" +- " << dmean_95
3448 <<
"\trms: " << rms_95 <<
" +- " << drms_95 << std::endl;
3453 for (
int ip=-2 ; ip<9 ; ip++ ) {
3454 if ( std::fabs(mean_95) >= std::pow( 10.,
double(-ip) ) ) {
3460 for (
int ip=-2 ; ip<9 ; ip++ ) {
3461 if ( std::fabs(rms_95) >= std::pow( 10.,
double(-ip) ) ) {
3470 std::cout <<
"\t\t" << histo.name()
3471 <<
"\tmean: " << mean_95 <<
" +- " << dmean_95 <<
" : pow " << mean_power
3472 <<
"\trms: " << rms_95 <<
" +- " << drms_95 <<
" : pow " << rms_power << std::endl;
3475 if ( mean_power == 0 ) {
3476 Mean.push_back(
label(
"mean_{95} = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3479 Mean.push_back(
label(
"mean_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3480 mean_95*std::pow(10.,
double(mean_power)), dmean_95*std::pow(10,
double(mean_power)), -mean_power ) );
3484 if ( rms_power == 0 ) {
3485 RMS.push_back(
label(
"rms_{95} = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3488 RMS.push_back(
label(
"rms_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3489 rms_95*std::pow(10.,
double(rms_power)), drms_95*std::pow(10,
double(rms_power)), -rms_power ) );
3495 double mean_95ref = d95ref->GetParameter(1);
3496 double dmean_95ref = d95ref->GetParError(1);
3497 double rms_95ref = d95ref->GetParameter(2);
3498 double drms_95ref = d95ref->GetParError(2);
3500 std::cout <<
"\t\t" << histo.name()
3501 <<
"\tmean ref: " << mean_95ref <<
" +- " << dmean_95ref <<
" : pow " << mean_power
3502 <<
"\trms ref: " << rms_95ref <<
" +- " << drms_95ref <<
" : pow " << rms_power << std::endl;
3504 if ( mean_power == 0 ) {
3505 MeanRef.push_back(
label(
"mean_{95} ref = %4.2lf #pm %4.2lf", mean_95ref, dmean_95ref) );
3508 MeanRef.push_back(
label(
"mean_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3509 mean_95ref*std::pow(10,
double(mean_power)), dmean_95ref*std::pow(10,
double(mean_power)), -mean_power ) );
3514 if ( rms_power == 0 ) {
3515 RMSRef.push_back(
label(
"rms_{95} ref = %4.2lf #pm %4.2lf", rms_95ref, drms_95ref ) );
3518 RMSRef.push_back(
label(
"rms_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3519 rms_95ref*std::pow(10,
double(rms_power)), drms_95ref*std::pow(10,
double(rms_power)), -rms_power ) );
3524 if ( href ) href->Sumw2();
3529 if ( href )
Norm( href );
3531 Norm( htest, 1, xinfo.
lo(), xinfo.
hi() );
3532 if ( href )
Norm( href, 1, xinfo.
lo(), xinfo.
hi() );
3539 Norm( href, 1, xinfo.
lo(), xinfo.
hi() );
3549 if ( !noreftmp && normref &&
3558 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3565 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3567 std::cout <<
"duff: " << xinfo << std::endl;
3570 plots.sortx( xinfo );
3572 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3581 rmin = plots.realmin( plots.lo(), plots.hi() );
3582 rmax = plots.realmax( plots.lo(), plots.hi() );
3591 rmin = plots.realmin();
3592 rmax = plots.realmax();
3597 int csize = chains.size() + taglabels.size() + ( atlasstyle ? 1 : 0 );
3599 if ( yinfo.
log() && rmin>0 && rmax>0 ) {
3602 double delta = std::log10(rmax)-std::log10(rmin);
3607 yminset = rmin*std::pow(10,-delta*0.1);
3609 double newdelta = std::log10(rmax) - std::log10(yminset) + 0.05*delta;
3611 if ( csize<10 ) ymaxset = rmin*std::pow(10,newdelta/(1-0.07*csize));
3612 else ymaxset = rmin*std::pow(10,newdelta*2);
3614 if ( yminset!=yminset ) {
3615 std::cerr <<
" range error " << delta <<
" " << yminset <<
" " << ymaxset <<
"\t(" << rmin <<
" " << rmax <<
")" << std::endl;
3629 double delta = rmax-rmin;
3631 yminset = rmin-0.1*delta;
3633 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3635 double newdelta = rmax - yminset + 0.05*delta;
3637 if ( csize<10 ) ymaxset = yminset + newdelta/(1-0.09*csize);
3638 else ymaxset = yminset + newdelta*2;
3641 double delta = rmax-rmin;
3643 ymaxset = rmax+0.1*delta;
3645 double newdelta = ymaxset - rmin - 0.05*delta;
3647 if ( csize<10 ) yminset = ymaxset - newdelta/(1-0.09*csize);
3648 else yminset = ymaxset - newdelta*2;
3650 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3659 yminset = yinfo.
lo();
3660 ymaxset = yinfo.
hi();
3664 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3673 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3675 if ( yminset>yinfo.
lo() ) yminset = yinfo.
lo();
3676 if ( ymaxset<yinfo.
hi() ) ymaxset = yinfo.
hi();
3680 if ( make_efficiencies &&
contains(histo.name(),
"_eff") ) {
3682 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3690 if ( ymaxset!=0 || yminset!=0 ) {
3692 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3694 plots.Max( ymaxset );
3695 plots.Min( yminset );
3698 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3700 if ( yminset!=0 || ymaxset!=0 ) {
3701 if ( yminset>0 ) plots.SetLogy(yinfo.
log());
3702 else plots.SetLogy(
false);
3704 else plots.SetLogy(yinfo.
log());
3708 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3714 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3716 plots.Draw( legend );
3718 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3720 if ( atlasstyle )
ATLASLabel( xpos, ypositions[0]+deltay, atlaslabel, labelcolour, ncolsp, nrowsp );
3722 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3724 for (
unsigned it=0 ; it<taglabels.size() ; it++ ) {
3725 DrawLabel( xpos, ypositions[it], taglabels[it], labelcolour, 0.04 );
3728 for (
unsigned it=0 ; it<taglabels2.size() ; it++ ) {
3729 DrawLabel( xpos+0.35, ypositions2[it], taglabels2[it], labelcolour, 0.04 );
3734 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3736 std::cout <<
"means: " << means << std::endl;
3741 for (
unsigned j=0 ; j<MeanLF.size() ; j++ )
DrawLabel( 0.2, (0.85-(j+chains.size()-1)*0.035), MeanLF[j],
colours[j%6] );
3748 if ( ( !nostats || !nomeans ) && !noplots ) {
3749 if ( dochi2 )
for (
unsigned j=0 ; j<Chi2.size() ; j++ )
DrawLabel( 0.75, 0.85-j*0.035, Chi2[j],
colours[j%6] );
3750 if ( ( (
contains(histo.name(),
"_res") ||
3752 histo.name()==
"pT" ||
3753 contains(histo.name(),
"residual_") ||
3754 contains(histo.name(),
"vs_pt") ) && !
contains(histo.name(),
"sigma") ) || drawmeans ) {
3756 if (
contains(histo.name(),
"_res") ||
contains(histo.name(),
"residual_") ||
contains(histo.name(),
"1d") || drawresiduals ) {
3757 for (
unsigned j=0 ; j<chains.size() ; j++ ) {
3759 if ( j<MeanRef.size() ) {
3760 if ( !nomeans )
DrawLabel( xpos_original, (ytop-j*0.035), MeanRef[j],
colours[j%6] );
3761 DrawLabel( xpos_original, (ytop-0.035*chains.size()-j*0.035)-0.01, RMSRef[j],
colours[j%6] );
3764 if ( j<Mean.size() ) {
3766 DrawLabel( 0.62, (ytop-0.035*chains.size()-j*0.035)-0.01, RMS[j],
colours[j%6] );
3773 if ( xinfo.
log() ) gPad->SetLogx(
true);
3774 else gPad->SetLogx(
false);
3776 if ( yinfo.
log() ) gPad->SetLogy(
true);
3777 else gPad->SetLogy(
false);
3779 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3783 if ( make_ref_efficiencies ) {
3788 plots_eff.
Draw( legend_eff );
3791 if ( !noreflabel.empty() )
DrawLabel(0.1, 0.06, noreflabel, kRed, 0.03 );
3810 std::string useplotname;
3812 if ( panel.
size()>1 ) {
3813 useplotname = panel.
name();
3814 replace( useplotname,
'/',
'_' );
3817 useplotname = plotname;
3820 useplotname.erase(
std::remove( useplotname.begin(), useplotname.end(),
'+' ), useplotname.end() );
3822 std::string printbase = dir + useplotname + tag;
3826 if ( !nopdf )
print_pad( printbase+
".pdf" );
3827 if ( !nopng )
print_pad( printbase+
".png" );
3828 if ( Cfile )
print_pad( printbase+
".C" );
3830 std::cout << std::endl;
3835 if (
tc )
delete tc;
3840 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3846 bool files_duplicated = ( fref_==ftest_ );
3848 if ( deleteref && !files_duplicated ) {
3854 std::cout <<
"main() cleaning up reference file" << std::endl;
3856 TFile* newout =
new TFile(
".newout.root",
"recreate");
3862 TDirectory*
base = gDirectory;
3864 for (
unsigned i=0 ; i<
savedhistos.size() ; i++ ) {
3871 for (
unsigned j=0 ; j<
dirs.size()-1 ; j++ ) {
3872 std::cout <<
"\t" <<
dirs[j] << std::endl;
3873 TDirectory* renedir = gDirectory->GetDirectory(
dirs[j].c_str() );
3874 if ( renedir==0 ) gDirectory->mkdir(
dirs[j].c_str() );
3875 gDirectory->cd(
dirs[j].c_str() );
3880 if ( !noreftmp && href ) {
3881 std::cout << i <<
" " <<
savedhistos[i] <<
" 0x" << href << std::endl;
3882 href->Write(
dirs.back().c_str() );
3895 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3899 if ( fref_ && !files_duplicated ) fref_->Close();
3900 if ( ftest_ ) ftest_->Close();
3904 if ( deleteref && !noref ) {
3905 std::cout <<
"ref " << frefname <<
"\ttest " << ftestname << std::endl;
3906 if ( frefname != ftestname && !files_duplicated ) {
3907 std::string cmd = std::string(
"mv ") + frefname +
" " + frefname +
".bak";
3908 std::system( cmd.c_str() );
3910 cmd = std::string(
"mv .newout.root ") + std::string(frefname);
3911 std::system( cmd.c_str() );
3914 std::cerr <<
"reference file and test file are the same - not replacing" << std::endl;
3918 std::cout <<
"deleting at " << __LINE__ << std::endl;
3920 if ( fref_ && !files_duplicated )
delete fref_;
3921 if ( ftest_ )
delete ftest_;