833int main(
int argc,
char** argv) {
835 gErrorIgnoreLevel = kError;
838 std::cout <<
"\n---------------------------------\n";
839 std::cout <<
"\n comparitor is off ...\n";
841 if ( argc<4 )
return usage(argv[0], -1,
"too few arguments");
845 std::string tag =
"";
846 std::string key =
"";
848 std::string dir =
"";
850 std::string ftestname =
"";
851 std::string frefname =
"";
860 std::string defreflabel =
"";
864 std::vector<std::string> usrlabels;
865 bool uselabels =
false;
866 bool addinglabels =
false;
868 std::vector<std::string> taglabels;
869 std::vector<std::string> taglabels2;
870 bool addingtags =
false;
871 bool addingtags2 =
false;
873 bool lumiref_trans =
false;
874 bool lumitest_trans =
false;
876 bool make_efficiencies =
true;
878 bool make_ref_efficiencies =
false;
879 bool refit_resplots =
false;
880 bool refitref_resplots =
false;
882 bool nostats =
false;
883 bool nomeans =
false;
886 bool atlasstyle =
false;
887 bool deleteref =
false;
888 bool nowatermark =
false;
889 bool noplots =
false;
895 bool normref =
false;
896 bool scalepix =
false;
898 bool addchains =
false;
899 bool usechainref =
false;
902 bool RANGEMAP =
false;
903 bool ALLRANGEMAP =
false;
907 std::string atlaslabel_tmp =
"Internal";
910 double scale_eff = -1;
911 double scale_eff_ref = -1;
913 std::string configfile =
"";
920 std::string pattern =
"";
921 std::string regex =
"";
923 std::string patternr =
"";
924 std::string regexr =
"";
926 std::string patternt =
"";
927 std::string regext =
"";
929 std::string basedir =
"";
931 std::string xpattern =
"";
932 std::string xregex =
"";
934 std::vector<std::string> chains;
935 std::vector<std::string> refchains;
937 bool addingrefchains =
false;
939 std::string mapfile =
"";
941 std::vector<std::string> chainfiles;
947 bool refbands =
false;
949 for(
int i=1; i<argc; i++){
950 std::string arg = argv[i];
952 ifdbg(
"\ncnt: " + arg );
955 if ( arg.find(
'-')!=0 && addinglabels ) {
956 std::string
label = arg;
959 usrlabels.push_back(
label );
962 else addinglabels =
false;
964 if ( arg.find(
'-')!=0 && addingrefchains ) {
965 refchains.push_back( arg );
968 else addingrefchains =
false;
970 if ( arg.find(
'-')!=0 && addingtags ) {
971 taglabels.push_back(
fullreplace( arg,
"__",
" " ) );
972 std::cout <<
"\tadding tag label: " << taglabels.back() << std::endl;
975 else addingtags =
false;
977 if ( arg.find(
'-')!=0 && addingtags2 ) {
978 taglabels2.push_back(
fullreplace( arg,
"__",
" " ) );
979 std::cout <<
"\tadding tag label: " << taglabels2.back() << std::endl;
982 else addingtags2 =
false;
984 ifdbg(
"starting if cascade: "+arg );
986 if ( arg==
"-h" || arg==
"--help" ) {
987 return usage(argv[0], 0);
989 else if ( arg==
"-c" || arg==
"--config" ) {
990 if ( ++i<argc ) configfile=argv[i];
991 else return usage(argv[0], -1,
"no config file provided");
994 else if ( arg==
"--jl" ) {
998 else if ( arg==
"--eps" ) {
1002 else if ( arg==
"-t" || arg==
"--tag" ) {
1003 if ( ++i<argc ) tag=std::string(
"-")+argv[i];
1004 else return usage(argv[0], -1,
"no tag provided");
1007 else if ( arg==
"-l" || arg==
"--labels" ) {
1008 addinglabels =
true;
1011 else if ( arg==
"-el" ) {
1015 else if ( arg==
"-k" || arg==
"--key" ) {
1016 if ( ++i<argc ) key=argv[i];
1017 else return usage(argv[0], -1,
"no key provided");
1020 else if ( arg==
"--run" ) {
1022 else return usage(argv[0], -1,
"no run number provided");
1025 else if ( arg==
"-m" || arg==
"--mapfile" ) {
1026 if ( ++i<argc ) mapfile=argv[i];
1027 else return usage(argv[0], -1,
"no mapfile provided");
1030 else if ( arg==
"-d" || arg==
"--dir" ) {
1031 if ( ++i<argc ) dir=argv[i];
1032 else return usage(argv[0], -1,
"no directory provided");
1035 else if ( arg==
"--lumi" ) {
1036 lumitest_trans =
true;
1037 lumiref_trans =
true;
1040 else if ( arg==
"--lumitest" ) {
1041 lumitest_trans =
true;
1042 ifdbg(
"--lumitest");
1044 else if ( arg==
"--lumiref" ) {
1045 lumiref_trans =
true;
1048 else if ( arg==
"-rb" || arg==
"--refbands" ) {
1050 ifdbg(
"--refbands");
1052 else if ( arg==
"-b" || arg==
"--bdir" ) {
1053 if ( ++i<argc ) basedir=argv[i];
1054 else return usage(argv[0], -1,
"no directory provided");
1057 else if ( arg==
"--taglabels" ) {
1059 ifdbg(
"--taglabels");
1061 else if ( arg==
"--taglabels2" ) {
1063 ifdbg(
"--taglabels2");
1065 else if ( arg==
"--unscalepix" ) {
1067 ifdbg(
"--unscalepix");
1069 else if ( arg==
"--scalepix" ) {
1071 ifdbg(
"--scalepix");
1073 else if ( arg==
"-ac" || arg==
"--addchains" ) {
1075 ifdbg(
"--sddchains");
1077 else if ( arg==
"-yrange" ) {
1079 if ( ++i<argc ) effmin=std::atof(argv[i]);
1080 else return usage(argv[0], -1,
"no range specified");
1081 if ( ++i<argc ) effmax=std::atof(argv[i]);
1082 else return usage(argv[0], -1,
"no upper y limit specified");
1085 else if ( arg==
"-e" || arg==
"--efficiencies" ) {
1086 make_ref_efficiencies =
true;
1087 ifdbg(
"--efficiencies");
1089 else if ( arg==
"-r" || arg==
"--refit" ) {
1090 refit_resplots =
true;
1093 else if ( arg==
"-rr" || arg==
"--refitref" ) {
1094 refitref_resplots =
true;
1095 ifdbg(
"--refitref");
1097 else if ( arg==
"--oldrms" ) {
1101 else if ( arg==
"-nw" || arg==
"--nowatermark" ) {
1104 ifdbg(
"--nowatermark");
1106 else if ( arg==
"--chi2" ) {
1110 else if ( arg==
"-ns" || arg==
"--nostats" ) {
1114 else if ( arg==
"-nm" || arg==
"--nomeans" ) {
1118 else if ( arg==
"--means" ) {
1122 else if ( arg==
"-nt" || arg==
"--notitle" ) {
1126 else if ( arg==
"-nr" || arg==
"--noref" ) {
1131 else if ( arg==
"--normref" ) {
1135 else if ( arg==
"-rc" || arg==
"--refchains" ) {
1136 addingrefchains =
true;
1137 ifdbg(
"--refchains");
1139 else if ( arg==
"-uc" || arg==
"--usechainref" ) {
1141 ifdbg(
"--usechainref");
1143 else if ( arg==
"-nb" || arg==
"--nobayes" ) {
1147 else if ( arg==
"-es" || arg==
"--effscale" ) {
1148 if ( ++i<argc ) scale_eff=std::atof(argv[i]);
1149 else return usage(argv[0], -1,
"no efficiency scale provided");
1150 ifdbg(
"--effscale");
1152 else if ( arg==
"-er" || arg==
"--effscaleref" ) {
1153 if ( ++i<argc ) scale_eff_ref=std::atof(argv[i]);
1154 else return usage(argv[0], -1,
"no efficiency scale for the reference histograms provided");
1155 ifdbg(
"--effscaleref");
1157 else if ( arg==
"--ncols" ) {
1158 if ( ++i<argc ) ncols=std::atoi(argv[i]);
1159 else return usage(argv[0], -1,
"no number of columns provided");
1162 else if ( arg==
"-np" || arg==
"--noplots" ) {
1166 else if ( arg==
"-C" || arg==
"--Cfiles" ) {
1170 else if ( arg==
"--deleteref" ) {
1172 ifdbg(
"--deleteref");
1174 else if ( arg==
"--nopng" ) {
1178 else if ( arg==
"--nopdf" ) {
1182 else if ( arg==
"-as" || arg==
"--atlasstyle" ) {
1185 ifdbg(
"--atlasstyle");
1187 else if ( arg==
"--tp" ) {
1188 make_efficiencies =
false;
1191 else if ( arg==
"-q" || arg==
"--quiet" ) {
1195 else if ( arg==
"-al" || arg==
"--atlaslabel" ) {
1196 if ( ++i<argc ) atlaslabel_tmp=argv[i];
1197 else return usage(argv[0], -1,
"no label provided");
1198 ifdbg(
"--atlaslabel");
1200 else if ( arg==
"-xo" || arg==
"--xoffset" ) {
1201 if ( ++i<argc ) xoffset=std::atof(argv[i]);
1202 else return usage(argv[0], -1,
"no xoffset provided");
1205 else if ( arg==
"-yp" || arg==
"--ypos" ) {
1206 if ( ++i<argc ) ypos_in=std::atof(argv[i]);
1207 else return usage(argv[0], -1,
"no y position provided");
1210 else if ( arg==
"-xe" || arg==
"--xerror" ) {
1211 if ( ++i<argc ) xerror=std::atof(argv[i]);
1212 else return usage(argv[0], -1,
"no x error provided");
1215 else if ( arg==
"-s" || arg==
"--swap" ) {
1216 if ( ++i<argc ) pattern=argv[i];
1217 else return usage(argv[0], -1,
"no patterns provided");
1218 if ( ++i<argc ) regex=argv[i];
1219 else return usage(argv[0], -1,
"no target pattern provided");
1222 else if ( arg==
"--swapt" ) {
1223 if ( ++i<argc ) patternt=argv[i];
1224 else return usage(argv[0], -1,
"no patterns provided");
1225 if ( ++i<argc ) regext=argv[i];
1226 else return usage(argv[0], -1,
"no target pattern provided");
1229 else if ( arg==
"--swapr" ) {
1230 if ( ++i<argc ) patternr=argv[i];
1231 else return usage(argv[0], -1,
"no patterns provided");
1232 if ( ++i<argc ) regexr=argv[i];
1233 else return usage(argv[0], -1,
"no target pattern provided");
1236 else if ( arg==
"-sx" || arg==
"--swapaxtitles" ) {
1237 if ( ++i<argc ) xregex=argv[i];
1238 else return usage(argv[0], -1,
"no target pattern provided");
1239 if ( ++i<argc ) xpattern=argv[i];
1240 else return usage(argv[0], -1,
"no patterns provided");
1241 ifdbg(
"--swapxtitles");
1243 else if ( arg.find(
'-')==0 ) {
1244 std::cerr <<
"unknown option: " << arg <<
"\n" << std::endl;
1245 return usage(argv[0], -4);
1248 ifdbg(
"arg: + "+arg);
1249 if ( ftestname==
"" ) ftestname = arg;
1250 else if ( frefname==
"" ) frefname = arg;
1252 std::string
file =
"";
1254 if ( arg.find(
":file:")!=std::string::npos ) {
1255 file = arg.substr( 0, arg.find(
":file:") );
1256 chainfiles.push_back(
file );
1257 arg = arg.substr(arg.find(
":file:")+6,arg.size());
1260 std::string chain = arg;
1264 chains.push_back(chain);
1266 std::cout <<
"file: " <<
file <<
"\tchain: " << chain << std::endl;
1272 if ( ftestname.empty() ) {
1273 std::cerr <<
"main(): test file not specified " << std::endl;
1277 if ( !
exists(ftestname) ) {
1278 std::cerr <<
"main(): test file " << ftestname <<
" does not exist" << std::endl;
1282 std::vector<TFile*> chainTFiles;
1284 if ( chainfiles.size()==0 ) ftest_ = TFile::Open( ftestname.c_str() );
1287 chainTFiles.resize(chainfiles.size());
1288 for (
size_t i=0 ; i<chainfiles.size() ; i++ ) {
1289 chainTFiles[i] = TFile::Open( chainfiles[i].c_str() );
1290 if ( chainTFiles[i] == 0 ) {
1291 std::cerr <<
"\tfile: " << chainfiles[i] <<
" could not be opened" << std::endl;
1294 else std::cout <<
"\tchainfiles: " << chainfiles[i] <<
" " << chainTFiles[i] << std::endl;
1299 if ( noref==
false ) {
1300 if ( frefname.empty() ) {
1301 std::cerr <<
"main(): ref file not specified " << std::endl;
1311 if ( frefname==ftestname ) fref_ = ftest_;
1312 else if (
exists(frefname) ) fref_ = TFile::Open( frefname.c_str() );
1314 std::cerr <<
"main(): ref file " << frefname <<
" does not exist" << std::endl;
1320 else fref_ = ftest_;
1322 if ( chainfiles.size()==0 ) {
1324 std::cerr <<
"could not open test file " << ftestname << std::endl;
1328 if ( noref==
false && fref_==0 ) {
1329 std::cerr <<
"could not open files " << std::endl;
1335 defreflabel =
"failed to open reference file";
1340 if ( scale_eff == -1 ) scale_eff = 100;
1341 if ( scale_eff_ref == -1 ) scale_eff_ref = scale_eff;
1344 bool noreftmp = noref;
1346 if ( chains.size()==0 )
return usage(argv[0], -1,
"no chains specified");
1349 if ( basedir.size()>0 ) {
1350 if ( basedir[basedir.size()-1]!=
'/' ) basedir +=
"/";
1351 for (
size_t ic=chains.size() ; ic-- ; ) chains[ic] = basedir+chains[ic];
1354 if ( refchains.size()>0 && refchains.size()!=chains.size() )
return usage(argv[0], -1,
"not enough chains specified");
1356 if ( refchains.size()==0 ) refchains = chains;
1358 std::vector<std::string> chainref(chains.size(),
"");
1359 std::vector<std::string> chain_name(chains.size(),
"");
1361 std::vector<std::string> refchain(chainref.size(),
"");
1365 std::cout << argv[0] <<
" options:" << std::endl;
1366 std::cout <<
"\tATLAS style: " << ( atlasstyle ?
"true" :
"false" ) << std::endl;
1367 std::cout <<
"\tBayesian uncertainties: " << ( bayes ?
"true" :
"false" ) << std::endl;
1368 std::cout <<
"\trefit resplot uncertainties: " << ( refit_resplots ?
"true" :
"false" ) << std::endl;
1369 std::cout <<
"\tsuppress mean and rms stats: " << ( nostats ?
"true" :
"false" ) << std::endl;
1370 if ( !nostats ) std::cout <<
"\tsuppress meanstats: " << ( nomeans ?
"true" :
"false" ) << std::endl;
1371 std::cout <<
"\tsuppress png output: " << ( nopng ?
"true" :
"false" ) << std::endl;
1372 std::cout <<
"\tsuppress pdf output: " << ( nopdf ?
"true" :
"false" ) << std::endl;
1373 std::cout <<
"\tsuppress reference output: " << ( noref ?
"true" :
"false" ) << std::endl;
1374 std::cout <<
"\tuse chain references: " << ( usechainref ?
"true" :
"false" ) << std::endl;
1375 std::cout <<
"\tpanel ncols: " << ncols << std::endl;
1377 if ( usrlabels.size()>0 ) std::cout <<
"\tlabels: " << usrlabels.size() << std::endl;
1378 if ( taglabels.size()>0 ) std::cout <<
"\textra text: " << taglabels << std::endl;
1379 if ( taglabels2.size()>0 ) std::cout <<
"\textra text: " << taglabels2 << std::endl;
1382 for (
size_t il=0 ; il<usrlabels.size() ; il++ ) {
1383 std::cout <<
"usr label[" << il <<
"] : " << usrlabels[il] << std::endl;
1386 std::cout <<
"atlas style : " << atlasstyle << std::endl;
1394 gROOT->SetStyle(
"Plain");
1396 gStyle->SetLineScalePS(1);
1400 gStyle->SetErrorX(xerror);
1402 gStyle->SetPadLeftMargin(0.15);
1403 gStyle->SetPadBottomMargin(0.15);
1405 gStyle->SetPadRightMargin(0.02);
1406 gStyle->SetPadTopMargin(0.05);
1408 std::cout <<
"Chains: " << std::endl;
1409 for (
unsigned ic=0 ; ic<chains.size() ; ic++ ) std::cout <<
"\t" << chains[ic] << std::endl;
1411 if ( usrlabels.size()>0 ) std::cout <<
"labels: " << usrlabels << std::endl;
1413 if ( usrlabels.size()>0 && usrlabels.size()==chains.size() ) uselabels =
true;
1417 TTree* dataTree = 0;
1418 TString* releaseData =
new TString(
"");
1419 std::vector<std::string> release_data;
1422 if ( !nowatermark && ftest_ ) {
1424 dataTree = (TTree*)ftest_->Get(
"dataTree");
1427 dataTree->SetBranchAddress(
"ReleaseMetaData", &releaseData);
1429 for (
unsigned int i=0; i<dataTree->GetEntries() ; i++ ) {
1430 dataTree->GetEntry(i);
1431 release_data.push_back( releaseData->Data() );
1432 std::cout <<
"main() release data: " << release_data.back() <<
" : " << *releaseData << std::endl;
1436 std::cout <<
"release data size " << release_data.size() << std::endl;
1438 if ( release_data.size()>0 ) {
1439 if ( release_data.size()>1 ) std::cerr <<
"main() more than one release - using only the first" << std::endl;
1443 std::string rd = release_data[0];
1445 while ( rd.size()>0 ) {
1447 std::string nightly =
chop(rd,
" " );
1449 if (
contains(nightly,
"private" ) ) {
1450 for (
int ic=0 ; ic<4 ; ic++ )
chop(release_data[0],
" " );
1451 release +=
" (" + release_data[0]+
")";
1456 if (
contains(nightly,
"nightly") ) {
1457 chop( nightly,
"/" );
1468 std::cout <<
"release: " <<
release << std::endl;
1476 std::cout <<
"trying to make directory" << std::endl;
1479 if ( mkdir( dir.c_str(), 0777 ) ) std::cerr <<
"main() couldn't create directory " << dir << std::endl;
1480 else std::cout <<
"main() output will be sent to directory " << dir << std::endl;
1484 if ( ftest_==0 && chainTFiles.size()>0 ) fref_ = ftest_ = chainTFiles[0];
1486 TFile* ftest = ftest_;
1487 TFile* fref = fref_;
1489 std::string testrun =
findrun( ftest );
1491 std::string rawrefrun =
"";
1492 std::string refrun =
"";
1494 if ( fref_ ) refrun = rawrefrun =
findrun( fref );
1496 std::cout <<
"testrun: " << testrun <<
"\nrefrun: " << refrun << std::endl;
1498 if ( !testrun.empty() && refrun != testrun ) {
1499 if ( pattern.empty() ) {
1506 if ( !refrun.empty() ) {
1508 std::string newtag =
"Reference: ";
1510 std::cout <<
"refrun: " << refrun << std::endl;
1513 while ( (pos=refrun.find(
'_'))!=std::string::npos ) refrun.replace( pos, 1,
" " );
1516 std::string rawrun = refrun.erase( refrun.find(
"run"), 4 );
1518 if (
contains(frefname, rawrun) ) {
1520 std::string
release = frefname;
1535 taglabels.push_back( newtag );
1537 std::cout <<
"tag labels: " << taglabels << std::endl;
1552 if ( !nowatermark ) {
1555 TH1D* htestev = (TH1D*)ftest->Get(
"event") ;
1556 TH1D* hrefev = (TH1D*)fref->Get(
"event") ;
1560 std::cout <<
"htestev " << htestev <<
" " << hrefev << std::endl;
1562 if ( htestev ) NeventTest = htestev->GetEntries();
1563 if ( hrefev ) NeventRef = hrefev->GetEntries();
1573 if ( NeventTest>1 ) std::cout <<
"Nevents Test: " << NeventTest << std::endl;
1574 if ( NeventRef>1 ) std::cout <<
"Nevents Ref: " << NeventRef << std::endl;
1578 if ( mapfile.empty() ) mapfile = configfile;
1581 std::cout <<
"mapfile: " << mapfile << std::endl;
1583 if ( !mapfile.empty() ) {
1587 if ( m.isTagDefined(
"ChainMap" ) ) {
1589 std::vector<std::string> chains = m.GetStringVector(
"ChainMap" );
1591 for (
size_t i=0 ; i<chains.size() ; i+=2 ) std::cout <<
"map: " << chains[i] <<
" -> " << chains[i+1] << std::endl;
1595 for (
size_t i=0 ; i<chains.size() ; i+=2 ) {
1596 chainmap->insert( chainmap_t::value_type( chains[i], chains[i+1] ) );
1599 std::cout <<
"\nusing chain map:" << std::endl;
1601 for ( chainmap_t::iterator itr=chainmap->begin() ; itr!=chainmap->end() ; itr++ ) {
1602 std::cout <<
"\t" << itr->first <<
"\t" << itr->second << std::endl;
1609 std::cout <<
"\ncreating chain and reference information ..." << std::endl;
1611 for (
size_t j=0; j<chains.size(); j++) {
1613 if ( !regex.empty() ) chains[j] =
fullreplace( chains[j], pattern, regex );
1614 if ( !regext.empty() ) chains[j] =
fullreplace( chains[j], patternt, regext );
1619 std::cout <<
"chain: " << chains[j] <<
"\taddchains: " << addchains << std::endl;
1621 if ( addchains && (
contains(chains[j],
"Shifter") || ( !
contains(chains[j],
"HLT_") && !
contains(chains[j],
"Fullscan" ) ) ) ) {
1623 TFile* fftest = ftest;
1625 if ( chainfiles.size()>0 && chainfiles.size()>j ) fftest = chainTFiles[j];
1627 TH1F* hchain =
Get( *fftest, chains[j]+
"/Chain", testrun );
1631 std::string name = hchain->GetTitle();
1633 if ( usechainref && !
contains(chains[j],
"Purity") ) {
1637 std::cout <<
"new chainref: " << chainref[j] << std::endl;
1639 std::string::size_type pos = chainref[j].find(
":for");
1640 if ( pos!=std::string::npos ) chainref[j].replace( pos, 4,
"_for" );
1641 std::replace( chainref[j].begin(), chainref[j].end(),
':',
'/');
1642 std::string newchain =
dirname(
dirname( chains[j]) ) +
"/Expert/" + chainref[j];
1643 chainref[j] = newchain;
1645 std::cout <<
"final chainref: " << chainref[j] << std::endl;
1649 std::cout <<
"chainref: " << chainref[j] << std::endl;
1651 while (
contains( name,
"HLT_" ) ) name = name.erase( name.find(
"HLT_"), 4 );
1653 std::cout <<
"name: " << name << std::endl;
1655 if (
contains( name,
":" ) ) chain_name[j] = name.substr( 0, name.find(
':') ) +
" : ";
1656 else chain_name[j] = name;
1658 if ( chain_name[j] ==
" : " ) chain_name[j] =
"";
1660 std::cout <<
"chain_name: " << chain_name[j] << std::endl;
1665 std::cout <<
"chainref size: " << chainref.size() <<
" " << refchains.size() << std::endl;
1667 for (
size_t j=0 ; j<chainref.size() ; j++ ) {
1668 std::cout <<
"chainref: " << chainref[j] <<
" :: " << refchains[j] << std::endl;
1671 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], pattern, regex );
1672 else refchain[j] =
fullreplace( refchains[j], pattern, regex );
1674 if ( !patternr.empty() ) {
1675 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], patternr, regexr );
1676 else refchain[j] =
fullreplace( refchains[j], patternr, regexr );
1679 std::cout <<
"refchain: " << refchain[j] << std::endl;
1682 std::cout <<
"done chains" << std::endl;
1686 std::vector<Panel> panels;
1693 std::vector<int> ccolours;
1694 std::vector<int> cstyles;
1696 std::vector<std::string> ctags;
1697 std::vector<std::string> ctaglabels;
1700 std::cout <<
"\n" << argv[0] <<
"\tconfigfile: " << configfile << std::endl;
1702 bool use_file_config =
false;
1704 if ( !configfile.empty() ) {
1706 if (
exists(configfile) ) {
1708 std::cout << argv[0] <<
":\treading configuration file " << configfile << std::endl;
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+6<=raw_input.size() ; iraw += 6 ) p.push_back( raw_input.begin()+iraw, raw_input.begin()+iraw+6 );
1754 panels.push_back( p );
1759 else if (
rc.isTagDefined(
"histos" ) ) {
1761 std::cout << argv[0] <<
":\treading histogram configuration from file " << configfile << std::endl;
1763 use_file_config =
true;
1765 std::vector<std::string> raw_input =
rc.GetStringVector(
"histos" );
1767 for (
size_t iraw=0 ; iraw+6<=raw_input.size() ; iraw += 6) {
1768 HistDetails h( raw_input.begin()+iraw, raw_input.begin()+iraw+6 );
1771 panels.push_back( p );
1776 if (
rc.isTagDefined(
"Bands" ) &&
rc.isTagDefined(
"Labels" ) ) {
1777 bnd =
bands(
rc.GetVector(
"Bands"),
rc.GetStringVector(
"Labels" ) );
1781 if (
rc.isTagDefined(
"Colours") ) {
1783 std::vector<int> ccolours =
rc.GetIntVector(
"Colours");
1785 std::cout <<
"remap colours: " << ccolours << std::endl;
1789 for (
size_t i=6 ; i-- ; ) new_colours[i] =
colours[i];
1791 for (
size_t i=0 ; i<ccolours.size() && i<6 ; i++ ) {
1792 if ( ccolours[i]<6 ) new_colours[i] =
colours[ccolours[i]];
1795 for (
size_t i=6 ; i-- ; )
colours[i] = new_colours[i];
1800 if (
rc.isTagDefined(
"Styles") ) {
1802 std::vector<int> cstyles =
rc.GetIntVector(
"Styles");
1804 std::cout <<
"remap markers: " << cstyles << std::endl;
1808 for (
size_t i=6 ; i-- ; ) new_markers[i] =
markers[i];
1810 for (
size_t i=0 ; i<cstyles.size() && i<6 ; i++ ) {
1811 if ( cstyles[i]<6 ) new_markers[i] =
markers[cstyles[i]];
1814 for (
size_t i=6 ; i-- ; )
markers[i] = new_markers[i];
1819 for (
int i=6 ; i-- ; ) std::cout <<
"\tcolours[" << i <<
"] = " <<
colours[i] << std::endl;
1820 for (
int i=6 ; i-- ; ) std::cout <<
"\tmarkers[" << i <<
"] = " <<
markers[i] << std::endl;
1823 if (
rc.isTagDefined(
"Tags") ) ctags =
rc.GetStringVector(
"Tags");
1824 if (
rc.isTagDefined(
"TagLabels") ) ctaglabels =
rc.GetStringVector(
"TagLabels");
1825 if (
rc.isTagDefined(
"TagLabels") ) usrlabels =
rc.GetStringVector(
"TagLabels");
1828 if (
rc.isTagDefined(
"Styles") ) {
1829 for (
size_t is=0 ; is<cstyles.size() && is<6 ; is++ ) {
1838 std::cout << argv[0] <<
"\tuserlabels :" << usrlabels <<
":" << std::endl;
1840 if (
rc.isTagDefined(
"RANGEMAP") ) RANGEMAP =
true;
1841 if (
rc.isTagDefined(
"ALLRANGEMAP") ) ALLRANGEMAP =
true;
1843 std::cout <<
"Extra: " <<
rc.isTagDefined(
"Extra") << std::endl;
1845 if (
rc.isTagDefined(
"Extra") ) taglabels.push_back(
fullreplace(
rc.GetString(
"Extra"),
"__",
" " ) );
1850 std::cerr << argv[0] <<
":\t config file not found: " << configfile << std::endl;
1856 if ( !use_file_config ) {
1858 std::cout <<
"using default panels" << std::endl;
1878 std::string pnames[3] = {
"eff",
"res",
"diff" };
1880 for (
size_t ip=0 ; ip<inpanels.size() ; ip++ ) {
1881 Panel p( pnames[ip]+
"_panel", 2 );
1882 for (
size_t ih=0 ; ih<inpanels[ip].size() ; ih++ ) p.push_back( inpanels[ip][ih] );
1883 panels.push_back( p );
1889 std::cout <<
"taglabels" << std::endl;
1891 for (
size_t it=0 ; it<taglabels.size() ; it++ ) std::cout << taglabels[it] << std::endl;
1892 for (
size_t it=0 ; it<taglabels2.size() ; it++ ) std::cout << taglabels2[it] << std::endl;
1895 std::cout <<
"\npanels: " << panels.size() << std::endl;
1897 if ( panels.size()==0 )
return usage(argv[0], -1,
"no panels to plot");
1899 for (
size_t ip=0 ; ip<panels.size() ; ip++ ) std::cout << panels[ip] << std::endl;
1904 gStyle->SetPadRightMargin(0.05);
1905 gStyle->SetPadTopMargin(0.05);
1908 const Int_t Number = 3;
1909 Double_t Red[Number] = { 0.00, 0.00, 1.00 };
1910 Double_t Green[Number] = { 0.00, 5.00, 1.00 };
1911 Double_t Blue[Number] = { 0.00, 0.50, 0.00 };
1912 Double_t Length[Number] = { 0.00, 0.50, 1.00 };
1914 TColor::CreateGradientColorTable( Number, Length, Red, Green, Blue, nb );
1916 else gStyle->SetPalette(1);
1918 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1920 double rightmargin = gStyle->GetPadRightMargin();
1921 gStyle->SetPadRightMargin(0.1);
1925 gStyle->SetPadRightMargin(rightmargin);
1929 for (
size_t ipanel=0 ; ipanel<panels.size() ; ipanel++ ) {
1931 Panel& panel = panels[ipanel];
1933 std::cout <<
blue <<
"\n\n---------------------------------------------\n" <<
reset;
1935 std::cout << panel <<
"\n" << std::endl;
1937 int ncolsp = panel.
ncols();
1938 int nrowsp = panel.
nrows();
1942 std::cout <<
"\nncols: " << ncolsp <<
"\tnrows: " << nrowsp << std::endl;
1944 bool multipanel = ( panel.
size() > 1 );
1946 if ( panel.
size()==0 ) {
1947 std::cout <<
"panel empty: " << panel.
name() << std::endl;
1953 if ( panel.
size()>4 ) gStyle->SetLineScalePS(0.5);
1955 if ( multipanel ) extraw = 1.05;
1957 TCanvas*
tc =
new TCanvas(
"tc",
"", extraw*ncolsp*800, nrowsp*600 );
1961 const std::string& atlaslabel = atlaslabel_tmp;
1965 gStyle->SetLineScalePS(1);
1981 tc->Divide( ncolsp, nrowsp, 0.0001, 0.0003 );
1987 std::string plotname =
"";
1989 for (
size_t i=0 ; i<panel.
size() ; i++ ) {
1993 bool drawmeans =
false;
1994 bool drawresiduals =
true;
1997 if (
contains(histo.detail(),
"+mean" ) ) drawmeans =
true;
1998 if (
contains(histo.detail(),
"-residual") ) drawresiduals =
false;
2000 std::string xaxis = histo.xtitle();
2001 std::string yaxis = histo.ytitle();
2003 if ( !xregex.empty() ) {
2004 size_t pos = xaxis.find(xregex);
2005 if ( pos!=std::string::npos ) xaxis.replace( pos, xregex.size(), xpattern );
2006 pos = yaxis.find(xregex);
2007 if ( pos!=std::string::npos ) yaxis.replace( pos, xregex.size(), xpattern );
2010 const AxisInfo& xinfo = histo.xaxis();
2011 const AxisInfo& yinfo = histo.yaxis();
2016 std::string hname = histo.name();
2017 std::string
detail = histo.detail();
2019 bool translate_x =
false;
2021 if ( ( lumiref_trans || lumitest_trans ) &&
contains(histo.xtitle(),
"Pile-up" ) ) translate_x =
true;
2025 if ( translate_x ) {
2026 xinfo.
lo( xinfo.
lo()*(1-0.054) );
2028 xinfo.
hi( xinfo.
hi()*(1-0.054) );
2035 bool d0rebin_flag =
false;
2041 rebin = std::atof(
detail.substr(
detail.find(
"+Rebin")+6,
detail.size() ).c_str() );
2045 rebin = std::atof(
detail.substr(
detail.find(
"+rebin")+6,
detail.size() ).c_str() );
2048 int labelcolour = kBlack;
2050 int npanel = nrowsp*(i/nrowsp) + i%nrowsp + 1 ;
2052 std::cout <<
"panel: panel: " << panel.
name() <<
"\tsubpanel: " << npanel << std::endl;
2054 if ( multipanel )
tc->cd( npanel );
2062 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2064 std::cout <<
"main() processing histo[" << i <<
"] " << (i<10 ?
" " :
"" ) << histo.name() <<
"\t" << histo.xaxis() << std::endl;
2072 std::string noreflabel=defreflabel;
2077 if (
contains(histo.name(),
"eff") ||
contains(histo.name(),
"Eff_") ) ypos = 0.19;
2086 if ( ypos>0.5 ) ypos = 0.85;
2090 if ( ypos_in!=0 ) ypos = ypos_in;
2092 double xpos_original = xpos;
2096 if ( xinfo.
offset() != 0 ) {
2098 std::cout <<
"HA ! xinfo.offset: " << xinfo.
offset() << std::endl;
2105 if ( yinfo.
offset() != 0 ) {
2107 std::cout <<
"HA ! yinfo.offset: " << yinfo.
offset() << std::endl;
2117 size_t Nrows = chains.size();
2119 if ( ALLRANGEMAP || (RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos && ccolours.size() ) ) {
2120 Nrows = ( Nrows < ccolours.size() ? Nrows : ccolours.size() );
2123 int Nlines = Nrows + taglabels.size();
2125 std::vector<double> ypositions;
2126 std::vector<double> ypositions2;
2128 double deltay = (Nrows*0.055-0.005)/Nrows;
2131 double yhi = ypos-0.01;
2133 if ( ypos>0.5 ) ylo -= Nlines*deltay;
2134 else yhi += Nlines*deltay;
2136 ypositions.reserve(Nlines);
2137 for (
int ilines=0 ; ilines<Nlines ; ilines++ ) {
2138 ypositions.push_back( yhi - deltay*(ilines+0.5) );
2139 ypositions2.push_back( yhi - deltay*(ilines-0.5) );
2150 if ( !
contains(histo.name(),
"eff") && !
contains(histo.name(),
"Eff_") ) ylo -= 0.02;
2153 Legend legend( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
2154 Legend legend_eff( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
2157 std::vector<std::string> Mean;
2158 std::vector<std::string> MeanLF;
2159 std::vector<std::string> RMS;
2165 std::vector<std::string> Chi2;
2166 std::vector<std::string> MeanRef;
2167 std::vector<std::string> RMSRef;
2177 bool power_set =
false;
2185 for (
unsigned int j=0; j<chains.size(); j++) {
2187 TFile* fftest = ftest;
2188 TFile* ffref = fref;
2190 std::string cc = ftest->GetName();
2191 std::string cr =
"";
2193 if ( fref ) cr = fref->GetName();
2195 if ( chainfiles.size()>0 && chainfiles.size()>j ) ffref = fftest = chainTFiles[j];
2200 std::cout <<
"chain: " << chains[j] <<
"\taddchains: " << addchains << std::endl;
2201 std::cout <<
"chainref: " << chainref[j] << std::endl;
2216 TGraphAsymmErrors* tgtest = 0;
2218 std::cout <<
"refchain.size() " << refchain.size() << std::endl;
2220 std::cout <<
"refchain: " << refchain[j] << std::endl;
2224 gPad->SetRightMargin(0.03);
2228 labelcolour = kBlack;
2231 if (
contains(histo.name(),
"/2d") ) {
2234 labelcolour = kWhite;
2236 gPad->SetRightMargin(0.13);
2238 std::cout <<
"\n\nsee! it is a 2d histograms !!! " << histo.name() <<
"\n\n" << std::endl;
2242 std::cout <<
"\t2d: " << h2test << std::endl;
2246 h2test->GetYaxis()->SetTitleOffset(1.55);
2247 h2test->GetXaxis()->SetTitleOffset(1.5);
2248 h2test->GetXaxis()->SetTitle(xaxis.c_str());
2249 h2test->GetYaxis()->SetTitle(yaxis.c_str());
2251 const AxisInfo& xinfo = histo.xaxis();
2252 const AxisInfo& yinfo = histo.yaxis();
2254 std::cout << xinfo << std::endl;
2255 std::cout << yinfo << std::endl;
2258 h2test->GetYaxis()->SetRangeUser( yinfo.
lo(), yinfo.
hi() );
2264 h2test->GetXaxis()->SetRangeUser( xinfo.
lo(), xinfo.
hi() );
2272 h2test->DrawCopy(
"colz");
2274 if ( histo.detail().find(
"logz")!=std::string::npos ) gPad->SetLogz(
true);
2275 else gPad->SetLogz(
false);
2279 else if ( refit_resplots && (
contains(histo.name(),
"/sigma") ||
contains(histo.name(),
"/mean") ) ) {
2284 std::cout <<
red <<
"fetch 2d: " << histo.name() <<
reset << std::endl;
2286 bool bsigma =
false;
2287 if (
contains(histo.name(),
"/sigma") ) bsigma =
true;
2290 if (
contains(histo.name(),
"/mean") ) bmean =
true;
2292 std::string tmp_ = histo.name();
2295 if ( bsigma )
base =
chop( tmp_,
"/sigma" );
2296 if ( bmean )
base =
chop( tmp_,
"/mean" );
2298 std::cout <<
"refitting: " << histo.name() <<
"\tbase: " <<
base <<
"\tbsigma: " << bsigma <<
"\tbmean: " << bmean << std::endl;
2307 if ( ffref ) href2d =
Get<TH2D>( *ffref, chains[j]+
"/"+
base+
"/2d", testrun, chainmap );
2309 if ( href2d==0 ) href2d =
Get<TH2D>( *ffref, chains[j]+
"/"+
base+
"/2D", testrun, chainmap );
2311 if ( htest2d==0 )
continue;
2312 if ( !noreftmp && href2d==0 ) noreftmp =
true;
2314 std::cout <<
"href2d : " << href2d << std::endl;
2318 std::cout <<
"plotter" << std::endl;
2322 Resplot rtest(
"tmp", htest2d );
2324 std::cout <<
"Resplot rtest\t" << rtest.
finalised() << std::endl;
2327 std::cout <<
"refitting ..." << std::endl;
2332 std::cout <<
"refitting (finalising) ..." << std::endl;
2336 rtest.
Mean()->DrawCopy();
2337 gPad->Print(
"Duff.pdf");
2340 std::cout <<
"bsigma: " << bsigma << std::endl;
2341 std::cout <<
"bmean: " << bmean << std::endl;
2343 if ( bsigma ) { htest = (TH1F*)rtest.
Sigma()->Clone(
"rtest_sigma"); htest->SetDirectory(0); }
2344 if ( bmean ) { htest = (TH1F*)rtest.
Mean()->Clone(
"rtest_mean"); htest->SetDirectory(0); }
2346 std::cout <<
reset << std::endl;
2349 std::cerr <<
red <<
"missing test histogram: " << (refchain[j]+
" / "+histo.name()) <<
" " << htest
2350 <<
"(test)" <<
reset << std::endl;
2354 std::cout <<
green <<
"htest: " << htest->GetName() <<
reset << std::endl;
2357 std::cout <<
"\nhisto.name(): " << histo.name() << std::endl;
2359 std::cout <<
reset << std::endl;
2361 if (
true && histo.name().find(
"d0_vs_phi")!=std::string::npos ) {
2363 TVirtualPad* old = gPad;
2365 std::cout <<
"old canvas: " << gPad << std::endl;
2367 std::cout <<
"dbg histo name: " << histo.name() << std::endl;
2373 if ( histo.name().find(
"_rec")!=std::string::npos ) {
2381 if ( histo.name().find(
"_rec")==std::string::npos ) {
2383 fitcanvas =
new TCanvas(
"fit",
"", 700, 600 );
2389 TVirtualPad* tp = gPad;
2397 rtest.
Mean()->SetDirectory(0);
2401 if ( histo.name().find(
"_rec")!=std::string::npos ) hf->SetTitle(
";Trigger #phi;Trigger d_{0} [mm]");
2402 else hf->SetTitle(
";Offline #phi;Offline d_{0} [mm]");
2404 TF1* tf =
new TF1(
"sinus",
"[0]*sin(x+[1])+[2]" );
2406 tf->SetLineWidth(1);
2408 hf->GetYaxis()->SetTitleOffset( hf->GetYaxis()->GetTitleOffset()*1.1 );
2411 TCanvas* tfc =
new TCanvas(
"tmp",
"", 700, 600 );
2417 double phi0 = tf->GetParameter(1);
2420 double x = tf->GetParameter(0)*cos(phi0);
2421 double y = tf->GetParameter(0)*sin(phi0);
2422 double off = tf->GetParameter(2);
2424 std::cout <<
"\tx = " <<
x << std::endl;
2425 std::cout <<
"\ty = " <<
y << std::endl;
2426 std::cout <<
"\toffset = " << off << std::endl;
2428 std::string cckstr = chains[j];
2430 cckstr = cckstr.substr( cckstr.find(
"HLT_IDTrack") );
2432 std::string vstr = chains[j];
2434 vstr.resize(vstr.find(
"_boffperf"));
2435 vstr.resize(vstr.find(
"_L1"));
2437 hf->SetMinimum( -0.03 );
2438 hf->SetMaximum( 0.03 );
2442 if ( first ) hf->DrawCopy();
2444 hf->DrawCopy(
"same");
2445 hf->DrawCopy(
"samee");
2455 std::string sht = chains[j]+
"-"+histo.name()+
"-fit.pdf";
2457 size_t p = sht.find(
"/");
2459 while ( p!=std::string::npos ) {
2465 gPad->Print( sht.c_str() );
2466 gPad->Print(
"sht.pdf" );
2468 std::cout <<
"CNT !!!" << std::endl;
2484 std::cout <<
"Resplot noreftmp " << noreftmp <<
" ... " << std::endl;
2487 if ( refitref_resplots ) {
2489 std::cout <<
"Resplot rref: " << href2d << std::endl;
2493 std::cout <<
"Resplot rref: " << href2d <<
" (2)" << std::endl;
2496 std::cout <<
"refitting (2) ..." << std::endl;
2501 std::cout <<
"refitting (2 - finalising) ..." << std::endl;
2506 std::cout <<
"Resplot rref: " << href2d <<
" (3)" << std::endl;
2508 if ( bsigma ) { hreft = (TH1F*)rref.
Sigma()->Clone(
"rref_sigma"); hreft->SetDirectory(0); }
2509 if ( bmean ) { hreft = (TH1F*)rref.
Mean()->Clone(
"rref_mean"); hreft->SetDirectory(0); }
2511 std::cout <<
"Resplot rref: " << href2d <<
" (4)" << std::endl;
2516 std::cout <<
"Resplot rref: " << href2d <<
" (5)" <<
reset << std::endl;
2518 hreft =
Get( *ffref, refchain[j]+
"/"+histo.name(), rawrefrun, chainmap );
2520 std::cerr <<
"ERROR: could not find " << (refchain[j]+
"/"+histo.name()) << std::endl;
2527 std::cout <<
"Resplot rref: " << href2d <<
" (6)" << std::endl;
2530 if ( !noreftmp && hreft==0 ) {
2532 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+histo.name()) <<
" " << htest <<
"(ref)" << std::endl;
2536 noreflabel=
"reference not found";
2544 std::cout <<
"Resplot rref: " << href2d <<
" (7)" << std::endl;
2546 href = (TH1F*)hreft->Clone();
2547 href->SetDirectory(0);
2549 std::cout <<
"Resplot href: " << href <<
" (7a)" << std::endl;
2553 std::cout <<
"Resplot rref: " << href2d <<
" (8)" << std::endl;
2559 savedhistos.push_back( refchain[j]+
"/"+histo.name() );
2561 std::cout <<
"Resplot rref: " << href2d <<
" (9)" << std::endl;
2568 std::string reghist = histo.name();
2570 std::cout <<
"hist: " << (chains[j]+
"/"+reghist) <<
"\tftest " << ftest << std::endl;
2574 htest =
Get( *fftest, chains[j]+
"/"+reghist, testrun, 0, &
savedhistos );
2576 std::cout <<
"\nhist: " << htest << std::endl;
2578 std::cout <<
"fftest: " << fftest->GetName() << std::endl;
2583 if ( lumitest_trans && translate_x && !
contains( cc,
"-mc" ) ) htest =
trans( htest, translate_x );
2585 std::cout << xaxis << std::endl;
2588 std::cerr <<
"missing test histogram: " << (chains[j]+
" / "+reghist) <<
" " << htest<< std::endl;
2592 testfit( htest, htest->GetName() );
2596 if ( ffref ) hreft =
Get( *ffref, refchain[j]+
"/"+reghist, rawrefrun, chainmap );
2597 else noreftmp =
true;
2599 if ( hreft && lumiref_trans && translate_x && !
contains( cr,
"-mc" ) ) hreft =
trans( hreft, translate_x );
2601 std::cout <<
"hreft: " << hreft << std::endl;
2603 if ( std::string(htest->ClassName()).find(
"TH2")!=std::string::npos ) {
2604 std::cout <<
"Class TH2: " << htest->GetName() << std::endl;
2609 if ( std::string(htest->ClassName()).find(
"TH1")!=std::string::npos ) {
2610 std::cout <<
"Class TH1: " << htest->GetName() << std::endl;
2612 else if ( std::string(htest->ClassName()).find(
"TProfile")!=std::string::npos ) {
2613 std::cout <<
"Class TProf: " << htest->GetName() << std::endl;
2615 else if ( std::string(htest->ClassName()).find(
"TEfficiency")!=std::string::npos ) {
2616 std::cout <<
"Class TEff: " << htest->GetName() << std::endl;
2620 std::cout <<
"Resplot hreft: " << hreft <<
" (10)" <<
" " << noreftmp << std::endl;
2622 if ( !noreftmp && hreft==0 ) {
2623 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+reghist)
2624 <<
" " << hreft << std::endl;
2628 noreflabel=
"reference not found";
2635 std::cout <<
"Resplot hreft: " << hreft <<
" (10)" << std::endl;
2639 std::cout <<
"Resplot hreft: " << hreft->ClassName() <<
" (11)" << std::endl;
2641 if ( std::string(hreft->ClassName()).find(
"TH1")!=std::string::npos ) {
2642 href = (TH1F*)hreft->Clone();
2643 href->SetDirectory(0);
2654 std::cout <<
" \tget " << (chains[j]+
"/"+reghist) <<
"\thtest " << htest << std::endl;
2655 std::cout <<
" \tget " << (refchain[j]+
"/"+reghist) <<
"\thref " << href << std::endl;
2657 if ( htest==0 )
continue;
2659 if ( !noreftmp && href==0 ) {
2664 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2668 std::cout <<
"rebin: " << hname <<
"\t" << rebin << std::endl;
2669 if ( htest ) htest->Rebin(rebin);
2670 if ( href ) href->Rebin(rebin);
2671 for (
int ip=0 ; ip<10 ; ip++ ) std::cout << std::endl;
2676 if ( !
contains( histo.name(),
"rdz_vs_zed" ) &&
contains( histo.name(),
"1d") ) {
2677 std::cout <<
"Rebinning histogram: " << histo.name() << std::endl;
2678 if ( htest->GetNbinsX()>500 ) htest->Rebin(10);
2679 if ( href && href->GetNbinsX()>500 ) href->Rebin(10);
2684 if ( make_efficiencies && histo.name().find(
"zed_eff")!=std::string::npos ) {
2685 if ( htest->GetNbinsX()>100 ) htest->Rebin(5);
2686 if ( href && href->GetNbinsX()>100 ) href->Rebin(5);
2690 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2692 if ( scalepix && std::string(htest->GetName()).find(
"npix")!=std::string::npos )
Scale(htest,0.5);
2693 if ( scalepix && href && std::string(htest->GetName()).find(
"npix")!=std::string::npos )
Scale(href,0.5);
2695 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2698 htest->SetTitle(
"");
2699 if( href ) href->SetTitle(
"");
2702 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2706 std::cout <<
"done else" << std::endl;
2708 if ( do2D )
continue;
2710 std::cout <<
"done else:\t" << htest << std::endl;
2711 std::cout <<
"done else:\t" << htest->GetName() << std::endl;
2713 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2715 if ( !do2D && make_ref_efficiencies ) {
2717 std::cout <<
"make ref efficiencies" << std::endl;
2719 if ( htest && href ) {
2724 if (
contains( std::string(htest->GetName()),
"eff" ) && !
contains( std::string(htest->GetName()),
"_d" ) ){
2726 std::string effhist = histo.name();
2730 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos );
2734 TH1F* hrefnumt =
Get( *ffref, refchain[j]+
"/"+effhist+
"_n", rawrefrun, chainmap, &
savedhistos );
2738 if ( !noreftmp && hrefnumt!=0 ) {
2739 hrefnum = (TH1F*)hrefnumt->Clone();
2740 hrefnum->SetDirectory(0);
2748 std::cout <<
"done effs ? " << bayes <<
"\thtest: " << htest <<
" :: " << htest->GetName() << std::endl;
2752 std::cout <<
"make ref efficiencies " << htest->GetName() << std::endl;
2754 if ( make_efficiencies && htest &&
contains( std::string(htest->GetName()),
"eff" ) && !
contains( std::string(htest->GetName()),
"_d" ) ) {
2756 std::string effhist = histo.name();
2760 if ( rebin!=1 ) std::cout << effhist <<
"\trebin: " << rebin << std::endl;
2763 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos ) ;
2764 htestden =
Get( *fftest, chains[j]+
"/"+effhist+
"_d", testrun, 0, &
savedhistos ) ;
2766 if ( htestnum==0 && htestden==0 ) {
2767 TEfficiency* eff = 0;
2772 htestnum = (TH1F*)eff->GetPassedHistogram();
2773 htestden = (TH1F*)eff->GetTotalHistogram();
2778 std::cout <<
"eff: htestnum: " << htestnum <<
"\thtestden: " << htestden << std::endl;
2781 double ars =
total_eff( htestnum, htestden );
2783 std::cout <<
"heff: " << effhist <<
"\t" << ars << std::endl;
2786 std::cout <<
"1: Bayesian error calculation " << htestnum <<
" " << htestden <<
"\tscale " << scale_eff << std::endl;
2788 if ( htestnum && htestden ) {
2793 if ( d0rebin_flag ) {
2794 htestnum =
d0rebin( htestnum );
2795 htestden =
d0rebin( htestden );
2797 else if ( rebin!=1 ) {
2798 htestnum =
Rebin(htestnum, rebin );
2799 htestden =
Rebin(htestden, rebin );
2802 std::cout <<
"test histogram name: : " << htestnum->GetName() <<
"\txaxis: " << xaxis <<
"\t" << std::endl;
2804 if ( make_efficiencies && std::string(htestnum->GetName()).find(
"ntrax_eff")!=std::string::npos ) {
2815 if (
contains( htest->GetName(),
"_vs_lb" ) ) {
2816 std::cout <<
"rebin " << histo.name() << std::endl;
2821 if ( make_efficiencies &&
contains( htest->GetName(),
"eta_eff" ) ) {
2822 std::cout <<
"rebin " << histo.name() << std::endl;
2830 if ( RANGEMAP && (effhist.find(
"ET")!=std::string::npos ) ) {
2831 std::cout <<
"\trange: " << j <<
" " << htest << std::endl;
2832 bnd.
range( chains[j], htestnum );
2833 bnd.
range( chains[j], htestden );
2836 if ( lumitest_trans && translate_x && !
contains( cc,
"-mc" ) ) {
2837 htestnum =
trans( htestnum, translate_x );
2838 htestden =
trans( htestden, translate_x );
2843 tgtest = e.Bayes(scale_eff);
2847 htest->SetName( (std::string(htestnum->GetName())+
"_eff").c_str() );
2849 std::cout <<
"effhist: " << effhist << std::endl;
2855 std::cout <<
"recalculating reference efficiencies ..." << std::endl;
2859 std::cout <<
"doin ..." << std::endl;
2862 TH1F* hrefnum =
Get( *ffref, refchain[j]+
"/"+histo.name()+
"_n", rawrefrun, chainmap );
2863 TH1F* hrefden =
Get( *ffref, refchain[j]+
"/"+histo.name()+
"_d", rawrefrun, chainmap );
2866 if ( hrefnum==0 && hrefden==0 ) {
2867 TEfficiency* eff = 0;
2869 eff =
Get<TEfficiency>( *ffref, refchain[j]+
"/"+histo.name(), rawrefrun, chainmap ) ;
2872 hrefnum = (TH1F*)eff->GetPassedHistogram();
2873 hrefden = (TH1F*)eff->GetTotalHistogram();
2880 std::cout <<
"2. Bayesian error calculation " << htestnum <<
" " << htestden <<
"\tscale " << scale_eff << std::endl;
2881 std::cout <<
"3. Bayesian error calculation " << hrefnum <<
" " << hrefden <<
"\tscale " << scale_eff_ref << std::endl;
2884 if ( hrefnum && hrefden ) {
2886 if ( lumiref_trans && translate_x && !
contains( cr,
"-mc" ) ) {
2887 hrefnum =
trans( hrefnum, translate_x );
2888 hrefden =
trans( hrefden, translate_x );
2894 if ( d0rebin_flag ) {
2898 else if ( rebin!=1 ) {
2899 hrefnum =
Rebin(hrefnum, rebin );
2900 hrefden =
Rebin(hrefden, rebin );
2904 std::cout << hrefnum <<
" " << hrefden << std::endl;
2916 std::cout <<
"dbg: htest: " << htest << std::endl;
2917 std::cout <<
"dbg: htest name " << htest->GetName() << std::endl;
2919 if (
true && histo.name().find(
"invmass")!=std::string::npos ) {
2920 testfit( htest, histo.name() );
2927 std::cout <<
"chains[j] " << chains[j] << std::endl;
2928 std::cout <<
"histo.name() " << histo.name() << std::endl;
2929 std::cout <<
"href " << href <<
"\t (TEfficiency " <<
isTEfficiency(href) <<
")" << std::endl;
2935 std::cout <<
"efficiency" << std::endl;
2938 std::cout <<
"href " << href <<
"\t (TEfficiency " <<
isTEfficiency(href) <<
")" << std::endl;
2942 std::cout <<
" no test histogram : " << (chains[j]+
"/"+histo.name()) << std::endl;
2947 if ( !noreftmp && href==0 ) {
2948 std::cout <<
" no ref histogram : " << (chains[j]+
"/"+histo.name()) << std::endl;
2951 noreflabel=
"reference not found";
2957 std::cout <<
"htest: " <<
isTEfficiency(htest) << std::endl;
2961 htest->GetYaxis()->SetTitleOffset(1.55);
2962 htest->GetXaxis()->SetTitleOffset(1.5);
2963 htest->GetXaxis()->SetTitle(xaxis.c_str());
2964 htest->GetYaxis()->SetTitle(yaxis.c_str());
2966 std::cout <<
"htest: " << htest <<
"\t" << __LINE__ << std::endl;
2971 href->GetYaxis()->SetTitleOffset(1.5);
2972 href->GetXaxis()->SetTitleOffset(1.5);
2973 std::cout <<
"xaxis: " << href->GetXaxis()->GetTitle() << std::endl;
2977 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2980 if ( !
contains(histo.name(),
"vtx_eff") &&
contains(histo.name(),
"ntracks") ) {
2982 double xm = htest->GetMean();
2985 double lxm = std::log10(xm);
2986 int newbins = int(0.5+xm/std::pow(10,
int(lxm)))*pow(10,
int(lxm));
2987 int nrebin = int( (newbins+5)/10 );
2990 std::cout <<
"rebin: " << htest->GetName() <<
"\tbins: " << nrebin << std::endl;
2991 htest->Rebin(nrebin);
2994 href->Rebin(nrebin);
3002 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3006 if ( plotname ==
"" ) {
3009 htest->SetTitle(
"");
3010 if ( href ) href->SetTitle(
"");
3014 htest->SetTitle(
"");
3015 if ( href ) href->SetTitle(
"");
3019 htest->SetTitle(
"");
3020 if ( href ) href->SetTitle(
"");
3024 htest->SetTitle(
"");
3025 if ( href ) href->SetTitle(
"");
3029 htest->SetTitle((
"FTK "+ histo.name()).c_str());
3030 if ( href ) href->SetTitle((
"FTK "+ histo.name()).c_str());
3034 plotname += histo.name();
3043 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3045 bool residual =
false;
3047 if (
contains(histo.name(),
"_res") ||
contains(histo.name(),
"residual_") ||
contains(histo.name(),
"1d") ) residual =
true;
3049 std::string collection =
basename( chains[j] );
3053 if ( collection.find(
"_InDet")!=std::string::npos ) collection.erase( 0, collection.find(
"_InDet")+1 );
3054 if ( actual_chain.find(
"_InDet")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_InDet") );
3057 std::cout <<
"raw: " << chains[j] << std::endl;
3058 std::cout <<
"track collection: " << collection << std::endl;
3059 std::cout <<
"actual chain: " << actual_chain << std::endl;
3061 std::regex rx(
"_HLT_[^_]*RoI.*");
3062 std::regex rx1(
"_HLT_[^_]*_RoI.*");
3064 std::cout <<
"\n\n\nactual_chain: " << actual_chain << std::endl;
3066 arsaway( actual_chain,
"_L1.*",
"" );
3067 arsaway( actual_chain,
"L1.*",
"" );
3069 actual_chain = std::regex_replace( actual_chain, std::regex(
"L1.*:" ),
"" );
3071 if ( actual_chain.find(
"jvt")!=std::string::npos ) actual_chain.erase(
3072 actual_chain.find(
"jvt"),
3073 actual_chain.find(
"HLT_IDTrack")-actual_chain.find(
"jvt") );
3075 std::cout <<
" : " << actual_chain <<
"\n\n\n" << std::endl;
3078 actual_chain = std::regex_replace( actual_chain, std::regex(
"_HLT_IDTrack.*" ),
"" );
3081 collection = std::regex_replace( collection, std::regex(
".*HLT_IDTrack_"),
"IDTrack " );
3082 collection = std::regex_replace( collection, std::regex(
"IDTrack "),
"" );
3083 collection = std::regex_replace( std::regex_replace( collection, rx,
"" ), rx1,
"" );
3085 if ( actual_chain.find(
"HLT_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"HLT_IDTrack_"), 12 );
3086 if ( actual_chain.find(
"_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_IDTrack_"), 9 );
3087 if ( actual_chain.find(
"IDTrack")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"IDTrack"), 7 );
3088 if ( actual_chain.find(
"_idperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_idperf"), 7 );
3089 if ( actual_chain.find(
"_bperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_bperf"), 6 );
3090 if ( actual_chain.find(
"_boffperf")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"_boffperf"), 9 );
3091 if ( actual_chain.find(
"_HLT_")!=std::string::npos ) actual_chain.replace( actual_chain.find(
"_HLT_"), 5,
" " );
3092 if ( actual_chain.find(
"HLT_")!=std::string::npos ) actual_chain.erase( actual_chain.find(
"HLT_"), 4 );
3096 if ( collection.find(
"_IDTrkNoCut")!=std::string::npos ) collection.erase( collection.find(
"_IDTrkNoCut"), 11 );
3097 if ( collection.find(
"xAODCnv")!=std::string::npos ) collection.erase( collection.find(
"xAODCnv"), 7 );
3098 if ( collection.find(
"HLT_IDTrack_")!=std::string::npos ) collection.erase( collection.find(
"HLT_IDTrack_"), 12 );
3099 if ( collection.find(
"HLT_IDTrack")!=std::string::npos ) collection.erase( collection.find(
"HLT_IDTrack"), 11 );
3100 if ( collection.find(
"Tracking")!=std::string::npos ) collection.replace( collection.find(
"Tracking"), 8,
"Trk" );
3101 if ( collection.find(
"InDetTrigTrk_")!=std::string::npos ) collection.erase( collection.find(
"InDetTrigTrk_"), 13 );
3102 if ( collection.find(
"HLT_xAODTracks_")!=std::string::npos ) collection.erase( collection.find(
"HLT_xAODTracks_"), 15 );
3103 if ( collection.find(
"_HLT_")!=std::string::npos ) collection.replace( collection.find(
"_HLT_"), 5,
" " );
3104 if ( collection.find(
"HLT_")!=std::string::npos ) collection.erase( collection.find(
"HLT_"), 4 );
3105 if ( collection.find(
"_extra")!=std::string::npos ) collection.resize( collection.find(
"_extra") );
3107 if ( actual_chain.size()>25 ) {
3108 size_t pos = actual_chain.find_last_of(
"_");
3109 while ( pos!=std::string::npos && actual_chain.size()>25 ) {
3110 actual_chain.resize(pos);
3111 pos = actual_chain.find_last_of(
"_");
3115 std::cout <<
blue <<
"actual chain: " << actual_chain <<
"\tcollection: " << collection <<
reset << std::endl;
3117 std::string c = actual_chain +
" : " + collection;
3119 std::cout <<
"track collection: " << collection <<
" <-" << std::endl;
3120 std::cout <<
"actual chain: " << actual_chain <<
" <-" << std::endl;
3126 std::cout <<
"use label: " << c <<
"\tchains size " << chains.size() <<
"\t" << usrlabels.size() << std::endl;
3128 std::cout <<
"chains.size() " << chains.size() <<
" " << j << std::endl;
3129 std::cout <<
"chains.size() " << chains.size() <<
" " << j << std::endl;
3131 std::cout <<
"chains[j] : " << j <<
" " << chains[j] << std::endl;
3133 std::cout <<
"userlabels.size() " << usrlabels.size() << std::endl;
3135 if ( usrlabels.size() < j+1 ) {
3136 if ( usrlabels.size()!=0 ) std::cerr <<
"userlabels not large enough - not using userlabels" << std::endl;
3138 else c = usrlabels[ j ];
3140 std::cout <<
"use label: c: " << c << std::endl;
3144 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3146 std::cout <<
blue <<
"xaxis: " << xaxis <<
reset << std::endl;
3148 if ( ALLRANGEMAP || xaxis.find(
"p_{T}")!=std::string::npos || xaxis.find(
"E_{T}")!=std::string::npos ) {
3150 if ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) {
3151 bnd.
range( chains[j], htest );
3152 if ( href ) bnd.
range( chains[j], href );
3155 if ( RANGEMAP || ALLRANGEMAP ) {
3159 std::cout <<
"\n\n\nctags " << ctags.size() <<
"\n\n" << std::endl;
3161 for (
size_t ic=0 ; ic<ctags.size() ; ic++ ) {
3163 std::cout <<
"\n\nic: " << ic <<
" " << ctags[ic] <<
" " << ccolours[ic] <<
"\n\n" << std::endl;
3165 if ( chains[j].
find(ctags[ic])!=std::string::npos ) {
3166 std::cout <<
"\ttag " << ctags[ic] <<
" \tcolour: " << ccolours[ic] <<
"\tstyle: " << cstyles[ic] << std::endl;
3167 htest->SetLineColor( ccolours[ic] );
3168 htest->SetMarkerColor( ccolours[ic] );
3169 htest->SetMarkerStyle( cstyles[ic] );
3172 tgtest->SetLineColor(htest->GetMarkerColor());
3173 tgtest->SetMarkerStyle(htest->GetMarkerStyle());
3174 tgtest->SetMarkerColor(htest->GetMarkerColor());
3182 std::cout <<
"test: " << chains[j] <<
"chains colour: " << htest->GetMarkerColor() << std::endl;
3187 std::cout <<
"movin' on ..." << std::endl;
3189 std::cout <<
"chain: " << chains[j] <<
" \t marker colour: " << htest->GetMarkerColor() << std::endl;
3191 std::cout <<
"Plotter marker : " << htest->GetMarkerColor() <<
" " << htest->GetMarkerStyle() << std::endl;
3194 if ( uselabels ) plots.push_back(
Plotter( htest, href,
" " + chain_name[j] + c, tgtest ) );
3196 std::cout <<
"using label: " << c << std::endl;
3197 plots.push_back(
Plotter( htest, href, c, tgtest ) );
3200 std::cout <<
"AxisInfo: " << xaxis << std::endl;
3202 plots.back().xaxis( &(histo.xaxis()) );
3203 plots.back().yaxis( &(histo.yaxis()) );
3205 std::cout <<
"c: " << c <<
"\t" << ftest->GetName() << std::endl;
3208 std::cout <<
"refbands: " << refbands << std::endl;
3209 plots.back().mc(
true );
3210 translate_x =
false;
3213 if ( ALLRANGEMAP || ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) ) plots.back().max_entries( ccolours.size() );
3215 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3217 if ( make_ref_efficiencies ) {
3219 if ( htestnum && hrefnum ) {
3224 double range =
h->GetMaximum()-
h->GetMinimum();
3226 if ( range<0.2*scale_eff ) {
3228 double fmax = int( (
h->GetMaximum() + 20)*0.1 )*0.1*scale_eff;
3229 double fmin = int( (
h->GetMinimum() - 10)*0.1 )*0.1*scale_eff;
3231 if ( fmax>1*scale_eff ) fmax = 1.02*scale_eff;
3232 if ( fmin<0 ) fmin = 0;
3234 h->SetMinimum(fmin);
3235 h->SetMaximum(fmax);
3245 std::cout <<
"means: " << drawmeans <<
" " << means << std::endl;
3247 std::cout <<
"chi2: " << std::endl;
3249 std::cout <<
"htest " << htest << std::endl;
3250 std::cout <<
"href " << href << std::endl;
3252 std::cout <<
"chi2: " <<
chi2( htest, href ) <<
"\t histo name: " << histo.name() << std::endl;
3254 testfit( htest, histo.name() );
3257 if ( href ) Chi2.push_back(
label(
"chi2 = %5.2lf / %2.0lf",
chi2( htest, href ),
double(htest->GetNbinsX()) ) );
3259 std::cout <<
"Chi2.push_back()" << std::endl;
3261 if ( drawmeans || means ) {
3263 double mean_95 = htest->GetMean();
3264 double dmean_95 = htest->GetMeanError();
3265 double rms_95 = htest->GetRMS();
3266 double drms_95 = htest->GetRMSError();
3268 Mean.push_back(
label(
" mean = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3269 MeanLF.push_back(
label(
"mean = %6.4lf #pm %6.4lf", mean_95, dmean_95) );
3270 RMS.push_back(
label(
" rms = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3274 std::cout <<
"residual: " << residual <<
" " << drawresiduals << std::endl;
3276 if ( residual && drawresiduals ) {
3280 xpos = xpos_original;
3282 std::cout <<
"calculating resolutions : " << histo.name() <<
" " << htest->GetName() << std::endl;
3286 double mean_95 = d95->GetParameter(1);
3287 double dmean_95 = d95->GetParError(1);
3288 double rms_95 = d95->GetParameter(2);
3289 double drms_95 = d95->GetParError(2);
3291 std::cout <<
"\t\t" << histo.name()
3292 <<
"\tmean: " << mean_95 <<
" +- " << dmean_95
3293 <<
"\trms: " << rms_95 <<
" +- " << drms_95 << std::endl;
3298 for (
int ip=-2 ; ip<9 ; ip++ ) {
3299 if ( std::fabs(mean_95) >= std::pow( 10.,
double(-ip) ) ) {
3305 for (
int ip=-2 ; ip<9 ; ip++ ) {
3306 if ( std::fabs(rms_95) >= std::pow( 10.,
double(-ip) ) ) {
3315 std::cout <<
"\t\t" << histo.name()
3316 <<
"\tmean: " << mean_95 <<
" +- " << dmean_95 <<
" : pow " << mean_power
3317 <<
"\trms: " << rms_95 <<
" +- " << drms_95 <<
" : pow " << rms_power << std::endl;
3320 if ( mean_power == 0 ) {
3321 Mean.push_back(
label(
"mean_{95} = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3324 Mean.push_back(
label(
"mean_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3325 mean_95*std::pow(10.,
double(mean_power)), dmean_95*std::pow(10,
double(mean_power)), -mean_power ) );
3329 if ( rms_power == 0 ) {
3330 RMS.push_back(
label(
"rms_{95} = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3333 RMS.push_back(
label(
"rms_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3334 rms_95*std::pow(10.,
double(rms_power)), drms_95*std::pow(10,
double(rms_power)), -rms_power ) );
3340 double mean_95ref = d95ref->GetParameter(1);
3341 double dmean_95ref = d95ref->GetParError(1);
3342 double rms_95ref = d95ref->GetParameter(2);
3343 double drms_95ref = d95ref->GetParError(2);
3345 std::cout <<
"\t\t" << histo.name()
3346 <<
"\tmean ref: " << mean_95ref <<
" +- " << dmean_95ref <<
" : pow " << mean_power
3347 <<
"\trms ref: " << rms_95ref <<
" +- " << drms_95ref <<
" : pow " << rms_power << std::endl;
3349 if ( mean_power == 0 ) {
3350 MeanRef.push_back(
label(
"mean_{95} ref = %4.2lf #pm %4.2lf", mean_95ref, dmean_95ref) );
3353 MeanRef.push_back(
label(
"mean_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3354 mean_95ref*std::pow(10,
double(mean_power)), dmean_95ref*std::pow(10,
double(mean_power)), -mean_power ) );
3359 if ( rms_power == 0 ) {
3360 RMSRef.push_back(
label(
"rms_{95} ref = %4.2lf #pm %4.2lf", rms_95ref, drms_95ref ) );
3363 RMSRef.push_back(
label(
"rms_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3364 rms_95ref*std::pow(10,
double(rms_power)), drms_95ref*std::pow(10,
double(rms_power)), -rms_power ) );
3369 if ( href ) href->Sumw2();
3374 if ( href )
Norm( href );
3376 Norm( htest, 1, xinfo.
lo(), xinfo.
hi() );
3377 if ( href )
Norm( href, 1, xinfo.
lo(), xinfo.
hi() );
3384 Norm( href, 1, xinfo.
lo(), xinfo.
hi() );
3394 if ( !noreftmp && normref &&
3403 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3410 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3412 std::cout <<
"duff: " << xinfo << std::endl;
3415 plots.sortx( xinfo );
3417 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3426 rmin = plots.realmin( plots.lo(), plots.hi() );
3427 rmax = plots.realmax( plots.lo(), plots.hi() );
3436 rmin = plots.realmin();
3437 rmax = plots.realmax();
3442 int csize = chains.size() + taglabels.size() + ( atlasstyle ? 1 : 0 );
3444 if ( yinfo.
log() && rmin>0 && rmax>0 ) {
3447 double delta = std::log10(rmax)-std::log10(rmin);
3452 yminset = rmin*std::pow(10,-delta*0.1);
3454 double newdelta = std::log10(rmax) - std::log10(yminset) + 0.05*delta;
3456 if ( csize<10 ) ymaxset = rmin*std::pow(10,newdelta/(1-0.07*csize));
3457 else ymaxset = rmin*std::pow(10,newdelta*2);
3459 if ( yminset!=yminset ) {
3460 std::cerr <<
" range error " << delta <<
" " << yminset <<
" " << ymaxset <<
"\t(" << rmin <<
" " << rmax <<
")" << std::endl;
3474 double delta = rmax-rmin;
3476 yminset = rmin-0.1*delta;
3478 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3480 double newdelta = rmax - yminset + 0.05*delta;
3482 if ( csize<10 ) ymaxset = yminset + newdelta/(1-0.09*csize);
3483 else ymaxset = yminset + newdelta*2;
3486 double delta = rmax-rmin;
3488 ymaxset = rmax+0.1*delta;
3490 double newdelta = ymaxset - rmin - 0.05*delta;
3492 if ( csize<10 ) yminset = ymaxset - newdelta/(1-0.09*csize);
3493 else yminset = ymaxset - newdelta*2;
3495 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3504 yminset = yinfo.
lo();
3505 ymaxset = yinfo.
hi();
3509 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3518 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3520 if ( yminset>yinfo.
lo() ) yminset = yinfo.
lo();
3521 if ( ymaxset<yinfo.
hi() ) ymaxset = yinfo.
hi();
3525 if ( make_efficiencies &&
contains(histo.name(),
"_eff") ) {
3527 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3535 if ( ymaxset!=0 || yminset!=0 ) {
3537 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3539 plots.Max( ymaxset );
3540 plots.Min( yminset );
3543 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3545 if ( yminset!=0 || ymaxset!=0 ) {
3546 if ( yminset>0 ) plots.SetLogy(yinfo.
log());
3547 else plots.SetLogy(
false);
3549 else plots.SetLogy(yinfo.
log());
3553 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3559 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3561 plots.Draw( legend );
3563 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3565 if ( atlasstyle )
ATLASLabel( xpos, ypositions[0]+deltay, atlaslabel, labelcolour, ncolsp, nrowsp );
3567 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3569 for (
unsigned it=0 ; it<taglabels.size() ; it++ ) {
3570 DrawLabel( xpos, ypositions[it], taglabels[it], labelcolour, 0.04 );
3573 for (
unsigned it=0 ; it<taglabels2.size() ; it++ ) {
3574 DrawLabel( xpos+0.35, ypositions2[it], taglabels2[it], labelcolour, 0.04 );
3579 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3581 std::cout <<
"means: " << means << std::endl;
3586 for (
unsigned j=0 ; j<MeanLF.size() ; j++ )
DrawLabel( 0.2, (0.85-(j+chains.size()-1)*0.035), MeanLF[j],
colours[j%6] );
3593 if ( ( !nostats || !nomeans ) && !noplots ) {
3594 if ( dochi2 )
for (
unsigned j=0 ; j<Chi2.size() ; j++ )
DrawLabel( 0.75, 0.85-j*0.035, Chi2[j],
colours[j%6] );
3595 if ( ( (
contains(histo.name(),
"_res") ||
3597 histo.name()==
"pT" ||
3598 contains(histo.name(),
"residual_") ||
3599 contains(histo.name(),
"vs_pt") ) && !
contains(histo.name(),
"sigma") ) || drawmeans ) {
3601 if (
contains(histo.name(),
"_res") ||
contains(histo.name(),
"residual_") ||
contains(histo.name(),
"1d") || drawresiduals ) {
3602 for (
unsigned j=0 ; j<chains.size() ; j++ ) {
3604 if ( j<MeanRef.size() ) {
3605 if ( !nomeans )
DrawLabel( xpos_original, (ytop-j*0.035), MeanRef[j],
colours[j%6] );
3606 DrawLabel( xpos_original, (ytop-0.035*chains.size()-j*0.035)-0.01, RMSRef[j],
colours[j%6] );
3609 if ( j<Mean.size() ) {
3611 DrawLabel( 0.62, (ytop-0.035*chains.size()-j*0.035)-0.01, RMS[j],
colours[j%6] );
3618 if ( xinfo.
log() ) gPad->SetLogx(
true);
3619 else gPad->SetLogx(
false);
3621 if ( yinfo.
log() ) gPad->SetLogy(
true);
3622 else gPad->SetLogy(
false);
3624 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3628 if ( make_ref_efficiencies ) {
3633 plots_eff.
Draw( legend_eff );
3636 if ( !noreflabel.empty() )
DrawLabel(0.1, 0.06, noreflabel, kRed, 0.03 );
3655 std::string useplotname;
3657 if ( panel.
size()>1 ) {
3658 useplotname = panel.
name();
3659 replace( useplotname,
'/',
'_' );
3662 useplotname = plotname;
3665 useplotname.erase(
std::remove( useplotname.begin(), useplotname.end(),
'+' ), useplotname.end() );
3667 std::string printbase = dir + useplotname + tag;
3671 if ( !nopdf )
print_pad( printbase+
".pdf" );
3672 if ( !nopng )
print_pad( printbase+
".png" );
3673 if ( Cfile )
print_pad( printbase+
".C" );
3675 std::cout << std::endl;
3680 if (
tc )
delete tc;
3685 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3691 bool files_duplicated = ( fref_==ftest_ );
3693 if ( deleteref && !files_duplicated ) {
3699 std::cout <<
"main() cleaning up reference file" << std::endl;
3701 TFile* newout =
new TFile(
".newout.root",
"recreate");
3707 TDirectory*
base = gDirectory;
3709 for (
unsigned i=0 ; i<
savedhistos.size() ; i++ ) {
3716 for (
unsigned j=0 ; j<
dirs.size()-1 ; j++ ) {
3717 std::cout <<
"\t" <<
dirs[j] << std::endl;
3718 TDirectory* renedir = gDirectory->GetDirectory(
dirs[j].c_str() );
3719 if ( renedir==0 ) gDirectory->mkdir(
dirs[j].c_str() );
3720 gDirectory->cd(
dirs[j].c_str() );
3725 if ( !noreftmp && href ) {
3726 std::cout << i <<
" " <<
savedhistos[i] <<
" 0x" << href << std::endl;
3727 href->Write(
dirs.back().c_str() );
3740 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3744 if ( fref_ && !files_duplicated ) fref_->Close();
3745 if ( ftest_ ) ftest_->Close();
3749 if ( deleteref && !noref ) {
3750 std::cout <<
"ref " << frefname <<
"\ttest " << ftestname << std::endl;
3751 if ( frefname != ftestname && !files_duplicated ) {
3752 std::string cmd = std::string(
"mv ") + frefname +
" " + frefname +
".bak";
3753 std::system( cmd.c_str() );
3755 cmd = std::string(
"mv .newout.root ") + std::string(frefname);
3756 std::system( cmd.c_str() );
3759 std::cerr <<
"reference file and test file are the same - not replacing" << std::endl;
3763 std::cout <<
"deleting at " << __LINE__ << std::endl;
3765 if ( fref_ && !files_duplicated )
delete fref_;
3766 if ( ftest_ )
delete ftest_;