leave this commented here - now instead of bombing out if we don't specify the reference file, just carry on as if it was not specified at all, so as this changes the external behaviour of the code we want this retained
don't fail anymore if can't open the reference file, now continue without plotting the refereces, instead printing a warning on the plots
we divide the resolutions by these values if we have an "entries" histogram to tell us how many events there are overall
set up the correct reference chain names ...
read config in from a file if requested ...
pointless root data types ...
words can not express the sheer unpleasantness in trying to do anything serious with subpanels
leave this code commented here for the time being ... if ( histo.name()=="pT" || histo.name()=="pT_rec" ) ypos = 0.19;
legends ....
leave these comments here for testing ...
get the actual chain name and track collection from the Chain histogram if present
do we need these ? - keep for the time being ...
Actually DO refit the references - if we are adding together many resplots, then the means etc may not even have been calculated
leave this code commented here since we want to know where to change this in the future it was added for a reason, so is useful to keep for now
useful test for debugging ...
do we still need to prevent the x transaltion ? need to check ...
leave this code commented here since we want to know where to change this in the future it was added for a reason, so useful to keep for now
debugging ...
rebin if requested ...
leave for documentation purposes ...
again, this changes the external behaviour so we want to leave this "continue" in place, but commented
replace the "/" in the filename so we don't try to make plots in subdirectories by accident
sort out the range settings for the xaxis ...
this stuff is tricky to get right - leave this here until we know it will no loner be needed
keep the original equation by way of documentation ...
leave this code commented here since we want to know where to change this in the future it was added for a reason, so it is useful to keep for now
std::exit(-1);
calculate the required range such that the histogram labels won't crowd the points
actually draw the plot here ...
NB: now, we no longer print the individual plots - only the "panels" individual plots can still be printed by creating a "panel" which contains only that plots - in fast the "histos" item that before provided details of the separate plots is now interpreted as a list of single plot panels so this is done for you
debugging ...
833 {
834
836
838 std::cout << "\n---------------------------------\n";
839 std::cout << "\n comparitor is off ...\n";
840
841 if ( argc<4 )
return usage(argv[0], -1,
"too few arguments");
842
844
845 std::string
tag =
"";
846 std::string
key =
"";
847
848 std::string
dir =
"";
849
850 std::string ftestname = "";
851 std::string frefname = "";
852
853 TFile* ftest_ = 0;
854 TFile* fref_ = 0;
855
856 bool effset = false;
857 double effmin = 90;
858 double effmax = 102;
859
860 std::string defreflabel = "";
861
863
864 std::vector<std::string> usrlabels;
865 bool uselabels = false;
866 bool addinglabels = false;
867
868 std::vector<std::string> taglabels;
869 std::vector<std::string> taglabels2;
870 bool addingtags = false;
871 bool addingtags2 = false;
872
873 bool lumiref_trans = false;
874 bool lumitest_trans = false;
875
876 bool make_efficiencies = true;
877
878 bool make_ref_efficiencies = false;
879 bool refit_resplots = false;
880 bool refitref_resplots = false;
881 bool bayes = true;
882 bool nostats = false;
883 bool nomeans = false;
884 bool means = false;
885 bool noref = false;
886 bool atlasstyle = false;
887 bool deleteref = false;
888 bool nowatermark = false;
889 bool noplots = false;
890 bool nopng = false;
891 bool nopdf = false;
892 bool Cfile = false;
893 bool notitle = true;
894 bool dochi2 = false;
895 bool normref = false;
896 bool scalepix = false;
897 bool oldrms = false;
898 bool addchains = false;
899 bool usechainref = false;
901
902 bool RANGEMAP = false;
903 bool ALLRANGEMAP = false;
904
905 double xerror = 0;
906
907 std::string atlaslabel_tmp = "Internal";
908
909
910 double scale_eff = -1;
911 double scale_eff_ref = -1;
912
913 std::string configfile = "";
914
915 double xoffset = 0;
916
917
918 double ypos_in = 0;
919
921 std::string
regex =
"";
922
923 std::string patternr = "";
924 std::string regexr = "";
925
926 std::string patternt = "";
927 std::string regext = "";
928
929 std::string basedir = "";
930
931 std::string xpattern = "";
932 std::string xregex = "";
933
934 std::vector<std::string>
chains;
935 std::vector<std::string> refchains;
936
937 bool addingrefchains = false;
938
939 std::string mapfile = "";
940
941 std::vector<std::string> chainfiles;
942
943 int ncols = 2;
944
946
947 bool refbands = false;
948
949 for(
int i=1;
i<
argc;
i++){
951
952 ifdbg(
"\ncnt: " + arg );
953
954
955 if (
arg.find(
'-')!=0 && addinglabels ) {
959 usrlabels.push_back(
label );
960 continue;
961 }
962 else addinglabels = false;
963
964 if (
arg.find(
'-')!=0 && addingrefchains ) {
965 refchains.push_back( arg );
966 continue;
967 }
968 else addingrefchains = false;
969
970 if (
arg.find(
'-')!=0 && addingtags ) {
971 taglabels.push_back(
fullreplace( arg,
"__",
" " ) );
972 std::cout << "\tadding tag label: " << taglabels.back() << std::endl;
973 continue;
974 }
975 else addingtags = false;
976
977 if (
arg.find(
'-')!=0 && addingtags2 ) {
978 taglabels2.push_back(
fullreplace( arg,
"__",
" " ) );
979 std::cout << "\tadding tag label: " << taglabels2.back() << std::endl;
980 continue;
981 }
982 else addingtags2 = false;
983
984 ifdbg(
"starting if cascade: "+arg );
985
986 if ( arg=="-h" || arg=="--help" ) {
987 return usage(argv[0], 0);
988 }
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");
993 }
994 else if ( arg=="--jl" ) {
997 }
998 else if ( arg=="--eps" ) {
1001 }
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");
1006 }
1007 else if ( arg=="-l" || arg=="--labels" ) {
1008 addinglabels = true;
1010 }
1011 else if ( arg=="-el" ) {
1014 }
1015 else if ( arg=="-k" || arg=="--key" ) {
1017 else return usage(argv[0], -1,
"no key provided");
1019 }
1020 else if ( arg=="--run" ) {
1022 else return usage(argv[0], -1,
"no run number provided");
1024 }
1025 else if ( arg=="-m" || arg=="--mapfile" ) {
1026 if ( ++i<argc ) mapfile=
argv[
i];
1027 else return usage(argv[0], -1,
"no mapfile provided");
1029 }
1030 else if ( arg=="-d" || arg=="--dir" ) {
1032 else return usage(argv[0], -1,
"no directory provided");
1034 }
1035 else if ( arg=="--lumi" ) {
1036 lumitest_trans = true;
1037 lumiref_trans = true;
1039 }
1040 else if ( arg=="--lumitest" ) {
1041 lumitest_trans = true;
1042 ifdbg(
"--lumitest");
1043 }
1044 else if ( arg=="--lumiref" ) {
1045 lumiref_trans = true;
1047 }
1048 else if ( arg=="-rb" || arg=="--refbands" ) {
1049 refbands = true;
1050 ifdbg(
"--refbands");
1051 }
1052 else if ( arg=="-b" || arg=="--bdir" ) {
1053 if ( ++i<argc ) basedir=
argv[
i];
1054 else return usage(argv[0], -1,
"no directory provided");
1056 }
1057 else if ( arg=="--taglabels" ) {
1058 addingtags = true;
1059 ifdbg(
"--taglabels");
1060 }
1061 else if ( arg=="--taglabels2" ) {
1062 addingtags2 = true;
1063 ifdbg(
"--taglabels2");
1064 }
1065 else if ( arg=="--unscalepix" ) {
1066 scalepix = false;
1067 ifdbg(
"--unscalepix");
1068 }
1069 else if ( arg=="--scalepix" ) {
1070 scalepix = true;
1071 ifdbg(
"--scalepix");
1072 }
1073 else if ( arg=="-ac" || arg=="--addchains" ) {
1074 addchains = true;
1075 ifdbg(
"--sddchains");
1076 }
1077 else if ( arg=="-yrange" ) {
1078 effset = true;
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");
1084 }
1085 else if ( arg=="-e" || arg=="--efficiencies" ) {
1086 make_ref_efficiencies = true;
1087 ifdbg(
"--efficiencies");
1088 }
1089 else if ( arg=="-r" || arg=="--refit" ) {
1090 refit_resplots = true;
1092 }
1093 else if ( arg=="-rr" || arg=="--refitref" ) {
1094 refitref_resplots = true;
1095 ifdbg(
"--refitref");
1096 }
1097 else if ( arg=="--oldrms" ) {
1098 oldrms = true;
1100 }
1101 else if ( arg=="-nw" || arg=="--nowatermark" ) {
1102 nowatermark = true;
1104 ifdbg(
"--nowatermark");
1105 }
1106 else if ( arg=="--chi2" ) {
1107 dochi2 = true;
1109 }
1110 else if ( arg=="-ns" || arg=="--nostats" ) {
1111 nostats = true;
1113 }
1114 else if ( arg=="-nm" || arg=="--nomeans" ) {
1115 nomeans = true;
1117 }
1118 else if ( arg=="--means" ) {
1119 means = true;
1121 }
1122 else if ( arg=="-nt" || arg=="--notitle" ) {
1123 notitle = true;
1125 }
1126 else if ( arg=="-nr" || arg=="--noref" ) {
1128 noref = true;
1130 }
1131 else if ( arg=="--normref" ) {
1132 normref = true;
1134 }
1135 else if ( arg=="-rc" || arg=="--refchains" ) {
1136 addingrefchains = true;
1137 ifdbg(
"--refchains");
1138 }
1139 else if ( arg=="-uc" || arg=="--usechainref" ) {
1140 usechainref = true;
1141 ifdbg(
"--usechainref");
1142 }
1143 else if ( arg=="-nb" || arg=="--nobayes" ) {
1144 bayes = false;
1146 }
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");
1151 }
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");
1156 }
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");
1161 }
1162 else if ( arg=="-np" || arg=="--noplots" ) {
1163 noplots = true;
1165 }
1166 else if ( arg=="-C" || arg=="--Cfiles" ) {
1167 Cfile = true;
1169 }
1170 else if ( arg=="--deleteref" ) {
1171 deleteref = true;
1172 ifdbg(
"--deleteref");
1173 }
1174 else if ( arg=="--nopng" ) {
1175 nopng = true;
1177 }
1178 else if ( arg=="--nopdf" ) {
1179 nopdf = true;
1181 }
1182 else if ( arg=="-as" || arg=="--atlasstyle" ) {
1183 atlasstyle = true;
1184
1185 ifdbg(
"--atlasstyle");
1186 }
1187 else if ( arg=="--tp" ) {
1188 make_efficiencies = false;
1190 }
1191 else if ( arg=="-q" || arg=="--quiet" ) {
1194 }
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");
1199 }
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");
1204 }
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");
1209 }
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");
1214 }
1215 else if ( arg=="-s" || arg=="--swap" ) {
1217 else return usage(argv[0], -1,
"no patterns provided");
1219 else return usage(argv[0], -1,
"no target pattern provided");
1221 }
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");
1228 }
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");
1235 }
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");
1242 }
1243 else if (
arg.find(
'-')==0 ) {
1244 std::cerr <<
"unknown option: " <<
arg <<
"\n" << std::endl;
1245 return usage(argv[0], -4);
1246 }
1247 else {
1248 ifdbg(
"arg: + "+arg);
1249 if ( ftestname==
"" ) ftestname =
arg;
1250 else if ( frefname==
"" ) frefname =
arg;
1251 else {
1252 std::string
file =
"";
1253
1254 if (
arg.find(
":file:")!=std::string::npos ) {
1256 chainfiles.push_back(
file );
1258 }
1259
1261
1265
1266 std::cout <<
"file: " <<
file <<
"\tchain: " <<
chain << std::endl;
1267
1268 }
1269 }
1270 }
1271
1272 if ( ftestname.empty() ) {
1273 std::cerr << "main(): test file not specified " << std::endl;
1274 return -1;
1275 }
1276
1277 if ( !
exists(ftestname) ) {
1278 std::cerr << "main(): test file " << ftestname << " does not exist" << std::endl;
1279 return -1;
1280 }
1281
1282 std::vector<TFile*> chainTFiles;
1283
1284 if ( chainfiles.size()==0 ) ftest_ = TFile::Open( ftestname.c_str() );
1285 else {
1286 noref=true;
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;
1292 return -1;
1293 }
1294 else std::cout <<
"\tchainfiles: " << chainfiles[
i] <<
" " << chainTFiles[
i] << std::endl;
1295 }
1296 }
1297
1298
1299 if ( noref==false ) {
1300 if ( frefname.empty() ) {
1301 std::cerr << "main(): ref file not specified " << std::endl;
1303 noref = true;
1308
1309 }
1310
1311 if ( frefname==ftestname ) fref_ = ftest_;
1312 else if (
exists(frefname) ) fref_ = TFile::Open( frefname.c_str() );
1313 else {
1314 std::cerr << "main(): ref file " << frefname << " does not exist" << std::endl;
1315
1317 noref=true;
1318 }
1319 }
1320 else fref_ = ftest_;
1321
1322 if ( chainfiles.size()==0 ) {
1323 if ( ftest_==0 ) {
1324 std::cerr << "could not open test file " << ftestname << std::endl;
1325 return -1;
1326 }
1327
1328 if ( noref==false && fref_==0 ) {
1329 std::cerr << "could not open files " << std::endl;
1333 noref=true;
1334 fref_=ftest_;
1335 defreflabel = "failed to open reference file";
1336 }
1337
1338 }
1339
1340 if ( scale_eff == -1 ) scale_eff = 100;
1341 if ( scale_eff_ref == -1 ) scale_eff_ref = scale_eff;
1342
1343
1344 bool noreftmp = noref;
1345
1346 if (
chains.size()==0 )
return usage(argv[0], -1,
"no chains specified");
1347
1348
1349 if ( basedir.size()>0 ) {
1350 if ( basedir[basedir.size()-1]!='/' ) basedir += "/";
1352 }
1353
1354 if ( refchains.size()>0 && refchains.size()!=
chains.size() )
return usage(argv[0], -1,
"not enough chains specified");
1355
1356 if ( refchains.size()==0 ) refchains =
chains;
1357
1358 std::vector<std::string> chainref(
chains.size(),
"");
1359 std::vector<std::string> chain_name(
chains.size(),
"");
1360
1361 std::vector<std::string> refchain(chainref.size(),"");
1362
1363
1364
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;
1376
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;
1380
1381
1382 for (
size_t il=0 ;
il<usrlabels.size() ;
il++ ) {
1383 std::cout <<
"usr label[" <<
il <<
"] : " << usrlabels[
il] << std::endl;
1384 }
1385
1386 std::cout << "atlas style : " << atlasstyle << std::endl;
1387
1388 if ( atlasstyle ) {
1391 gStyle->cd();
1392 }
1393 else {
1394 gROOT->SetStyle("Plain");
1395 gStyle->cd();
1396 gStyle->SetLineScalePS(1);
1397 xoffset += 0.02;
1398 }
1399
1400 gStyle->SetErrorX(xerror);
1401
1402 gStyle->SetPadLeftMargin(0.15);
1403 gStyle->SetPadBottomMargin(0.15);
1404
1405 gStyle->SetPadRightMargin(0.02);
1406 gStyle->SetPadTopMargin(0.05);
1407
1408 std::cout << "Chains: " << std::endl;
1409 for (
unsigned ic=0 ;
ic<
chains.size() ;
ic++ ) std::cout <<
"\t" << chains[ic] << std::endl;
1410
1411 if ( usrlabels.size()>0 ) std::cout << "labels: " << usrlabels << std::endl;
1412
1413 if ( usrlabels.size()>0 && usrlabels.size()==
chains.size() ) uselabels =
true;
1414
1416
1417 TTree* dataTree = 0;
1418 TString* releaseData = new TString("");
1419 std::vector<std::string> release_data;
1420
1421
1422 if ( !nowatermark && ftest_ ) {
1423
1424 dataTree = (TTree*)ftest_->Get("dataTree");
1425
1426 if ( dataTree ) {
1427 dataTree->SetBranchAddress( "ReleaseMetaData", &releaseData);
1428
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;
1433 }
1434 }
1435
1436 std::cout << "release data size " << release_data.size() << std::endl;
1437
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;
1440
1441
1442
1443 std::string rd = release_data[0];
1444
1445 while ( rd.size()>0 ) {
1446
1448
1449 if (
contains(nightly,
"private" ) ) {
1450 for (
int ic=0 ;
ic<4 ;
ic++ )
chop(release_data[0],
" " );
1451 release +=
" (" + release_data[0]+
")";
1452 break;
1453 }
1454 else {
1455
1456 if (
contains(nightly,
"nightly") ) {
1457 chop( nightly,
"/" );
1460 break;
1461 }
1462
1463 }
1464 }
1465 }
1466 }
1467
1468 std::cout <<
"release: " <<
release << std::endl;
1469
1470
1471
1473
1475
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;
1481 }
1482 }
1483
1484 if ( ftest_==0 && chainTFiles.size()>0 ) fref_ = ftest_ = chainTFiles[0];
1485
1486 TFile* ftest = ftest_;
1487 TFile* fref = fref_;
1488
1490
1491 std::string rawrefrun = "";
1492 std::string refrun = "";
1493
1494 if ( fref_ ) refrun = rawrefrun =
findrun( fref );
1495
1496 std::cout <<
"testrun: " <<
testrun <<
"\nrefrun: " << refrun << std::endl;
1497
1498 if ( !
testrun.empty() && refrun != testrun ) {
1502 }
1503
1504 }
1505
1506 if ( !refrun.empty() ) {
1507
1508 std::string newtag = "Reference: ";
1509
1510 std::cout << "refrun: " << refrun << std::endl;
1511
1513 while ( (pos=refrun.find('_'))!=std::string::npos ) refrun.replace( pos, 1, " " );
1514 newtag += refrun;
1515
1516 std::string rawrun = refrun.erase( refrun.find("run"), 4 );
1517
1518 if (
contains(frefname, rawrun) ) {
1519
1520 std::string
release = frefname;
1521
1523
1529
1530 newtag += " ";
1532
1533 }
1534
1535 taglabels.push_back( newtag );
1536
1537 std::cout << "tag labels: " << taglabels << std::endl;
1538
1539 }
1540
1545 int NeventTest = 1;
1546 int NeventRef = 1;
1547
1548
1550
1551
1552 if ( !nowatermark ) {
1553
1554
1555 TH1D* htestev = (TH1D*)ftest->Get("event") ;
1556 TH1D* hrefev = (TH1D*)fref->Get("event") ;
1557
1558
1559
1560 std::cout << "htestev " << htestev << " " << hrefev << std::endl;
1561
1562 if ( htestev ) NeventTest = htestev->GetEntries();
1563 if ( hrefev ) NeventRef = hrefev->GetEntries();
1564
1566 }
1567 else {
1568 NeventTest = 1;
1569 NeventRef = 1;
1570 }
1571
1572
1573 if ( NeventTest>1 ) std::cout << "Nevents Test: " << NeventTest << std::endl;
1574 if ( NeventRef>1 ) std::cout << "Nevents Ref: " << NeventRef << std::endl;
1575
1577
1578 if ( mapfile.empty() ) mapfile = configfile;
1579
1580
1581 std::cout << "mapfile: " << mapfile << std::endl;
1582
1583 if ( !mapfile.empty() ) {
1584
1586
1587 if (
m.isTagDefined(
"ChainMap" ) ) {
1588
1589 std::vector<std::string>
chains =
m.GetStringVector(
"ChainMap" );
1590
1591 for (
size_t i=0 ;
i<
chains.size() ;
i+=2 ) std::cout <<
"map: " << chains[i] <<
" -> " << chains[i+1] << std::endl;
1592
1594
1595 for (
size_t i=0 ;
i<
chains.size() ;
i+=2 ) {
1596 chainmap->insert( chainmap_t::value_type( chains[i], chains[i+1] ) );
1597 }
1598
1599 std::cout << "\nusing chain map:" << std::endl;
1600
1601 for ( chainmap_t::iterator itr=chainmap->begin() ; itr!=chainmap->end() ; itr++ ) {
1602 std::cout << "\t" << itr->first << "\t" << itr->second << std::endl;
1603 }
1604 }
1605 }
1606
1608
1609 std::cout << "\ncreating chain and reference information ..." << std::endl;
1610
1611 for (
size_t j=0;
j<
chains.size();
j++) {
1612
1615
1617
1619 std::cout <<
"chain: " <<
chains[
j] <<
"\taddchains: " << addchains << std::endl;
1620
1621 if ( addchains && (
contains(chains[j],
"Shifter") || ( !
contains(chains[j],
"HLT_") && !
contains(chains[j],
"Fullscan" ) ) ) ) {
1622
1623 TFile* fftest = ftest;
1624
1625 if ( chainfiles.size()>0 && chainfiles.size()>j ) fftest = chainTFiles[
j];
1626
1627 TH1F* hchain =
Get( *fftest, chains[j]+
"/Chain", testrun );
1628
1629 if ( hchain ) {
1630
1631 std::string
name = hchain->GetTitle();
1632
1633 if ( usechainref && !
contains(chains[j],
"Purity") ) {
1634
1636
1637 std::cout <<
"new chainref: " << chainref[
j] << std::endl;
1638
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;
1644
1645 std::cout <<
"final chainref: " << chainref[
j] << std::endl;
1646
1647 }
1648
1649 std::cout <<
"chainref: " << chainref[
j] << std::endl;
1650
1652
1653 std::cout <<
"name: " <<
name << std::endl;
1654
1655 if (
contains( name,
":" ) ) chain_name[
j] =
name.substr( 0,
name.find(
':') ) +
" : ";
1656 else chain_name[
j] =
name;
1657
1658 if ( chain_name[j] ==
" : " ) chain_name[
j] =
"";
1659
1660 std::cout <<
"chain_name: " << chain_name[
j] << std::endl;
1661 }
1662 }
1663 }
1664
1665 std::cout << "chainref size: " << chainref.size() << " " << refchains.size() << std::endl;
1666
1667 for (
size_t j=0 ;
j<chainref.size() ;
j++ ) {
1668 std::cout <<
"chainref: " << chainref[
j] <<
" :: " << refchains[
j] << std::endl;
1669
1671 if ( chainref[j]!=
"" ) refchain[
j] =
fullreplace( chainref[j], pattern, regex );
1672 else refchain[
j] =
fullreplace( refchains[j], pattern, regex );
1673
1674 if ( !patternr.empty() ) {
1675 if ( chainref[j]!=
"" ) refchain[
j] =
fullreplace( chainref[j], patternr, regexr );
1676 else refchain[
j] =
fullreplace( refchains[j], patternr, regexr );
1677 }
1678
1679 std::cout <<
"refchain: " << refchain[
j] << std::endl;
1680 }
1681
1682 std::cout << "done chains" << std::endl;
1683
1685
1686 std::vector<Panel> panels;
1687
1689
1691
1692
1693 std::vector<int> ccolours;
1694 std::vector<int> cstyles;
1695
1696 std::vector<std::string> ctags;
1697 std::vector<std::string> ctaglabels;
1698
1699
1700 std::cout <<
"\n" <<
argv[0] <<
"\tconfigfile: " << configfile << std::endl;
1701
1702 bool use_file_config = false;
1703
1704 if ( !configfile.empty() ) {
1705
1706 if (
exists(configfile) ) {
1707
1708 std::cout <<
argv[0] <<
":\treading configuration file " << configfile << std::endl;
1709
1711
1713
1714 std::cout << "searching for panels" << std::endl;
1715
1717
1718 if (
rc.isTagDefined(
"panels" ) ) {
1719
1720 std::cout <<
argv[0] <<
":\treading histogram panel configuration from file " << configfile << std::endl;
1721
1722 use_file_config = true;
1723
1724 std::vector<std::string> panel_config =
rc.GetStringVector(
"panels" );
1725
1726 std::vector<string> panel_columns;
1727
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" );
1731 }
1732
1733
1734 for ( size_t ipanel=panel_config.size() ; ipanel-- ; ) {
1735
1736 std::vector<std::string> raw_input =
rc.GetStringVector( panel_config[ipanel] );
1737
1738 int tncols = ncols;
1739
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() );
1743 }
1744
1745 Panel p( panel_config[ipanel], tncols );
1746
1747 if ( raw_input.empty() ) {
1748 std::cerr << "no plots provided" << std::endl;
1749 return 1;
1750 }
1751
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 );
1753
1754 panels.push_back( p );
1755
1756 }
1757
1758 }
1759 else if (
rc.isTagDefined(
"histos" ) ) {
1760
1761 std::cout <<
argv[0] <<
":\treading histogram configuration from file " << configfile << std::endl;
1762
1763 use_file_config = true;
1764
1765 std::vector<std::string> raw_input =
rc.GetStringVector(
"histos" );
1766
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 );
1772 }
1773
1774 }
1775
1776 if (
rc.isTagDefined(
"Bands" ) &&
rc.isTagDefined(
"Labels" ) ) {
1777 bnd =
bands(
rc.GetVector(
"Bands"),
rc.GetStringVector(
"Labels" ) );
1778 }
1779
1780
1781 if (
rc.isTagDefined(
"Colours") ) {
1782
1783 std::vector<int> ccolours =
rc.GetIntVector(
"Colours");
1784
1785 std::cout << "remap colours: " << ccolours << std::endl;
1786
1787 int new_colours[6];
1788
1789 for (
size_t i=6 ;
i-- ; ) new_colours[i] =
colours[i];
1790
1791 for (
size_t i=0 ;
i<ccolours.size() && i<6 ;
i++ ) {
1792 if ( ccolours[i]<6 ) new_colours[
i] =
colours[ccolours[
i]];
1793 }
1794
1795 for (
size_t i=6 ;
i-- ; )
colours[i] = new_colours[i];
1796
1797 }
1798
1799
1800 if (
rc.isTagDefined(
"Styles") ) {
1801
1802 std::vector<int> cstyles =
rc.GetIntVector(
"Styles");
1803
1804 std::cout << "remap markers: " << cstyles << std::endl;
1805
1806 int new_markers[6];
1807
1808 for (
size_t i=6 ;
i-- ; ) new_markers[i] =
markers[i];
1809
1810 for (
size_t i=0 ;
i<cstyles.size() && i<6 ;
i++ ) {
1811 if ( cstyles[i]<6 ) new_markers[
i] =
markers[cstyles[
i]];
1812 }
1813
1814 for (
size_t i=6 ;
i-- ; )
markers[i] = new_markers[i];
1815
1816 }
1817
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;
1821 }
1822
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");
1826
1827
1828 if (
rc.isTagDefined(
"Styles") ) {
1829 for ( size_t is=0 ; is<cstyles.size() && is<6 ; is++ ) {
1831 }
1832 }
1833
1834
1835 uselabels = true;
1836
1837
1838 std::cout <<
argv[0] <<
"\tuserlabels :" << usrlabels <<
":" << std::endl;
1839
1840 if (
rc.isTagDefined(
"RANGEMAP") ) RANGEMAP =
true;
1841 if (
rc.isTagDefined(
"ALLRANGEMAP") ) ALLRANGEMAP =
true;
1842
1843 std::cout <<
"Extra: " <<
rc.isTagDefined(
"Extra") << std::endl;
1844
1845 if (
rc.isTagDefined(
"Extra") ) taglabels.push_back(
fullreplace(
rc.GetString(
"Extra"),
"__",
" " ) );
1846
1847
1848 }
1849 else {
1850 std::cerr <<
argv[0] <<
":\t config file not found: " << configfile << std::endl;
1851 return -1;
1852 }
1853
1854 }
1855
1856 if ( !use_file_config ) {
1857
1858 std::cout << "using default panels" << std::endl;
1859
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871 scale_eff = 1;
1872 scale_eff_ref = 1;
1873
1875
1877
1878 std::string pnames[3] = { "eff", "res", "diff" };
1879
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 );
1884 }
1885
1886 }
1887
1888
1889 std::cout << "taglabels" << std::endl;
1890
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;
1893
1894
1895 std::cout << "\npanels: " << panels.size() << std::endl;
1896
1897 if ( panels.size()==0 )
return usage(argv[0], -1,
"no panels to plot");
1898
1899 for (
size_t ip=0 ;
ip<panels.size() ;
ip++ ) std::cout << panels[ip] << std::endl;
1900
1901
1903 if ( true ) {
1904 gStyle->SetPadRightMargin(0.05);
1905 gStyle->SetPadTopMargin(0.05);
1906
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 );
1915 }
1916 else gStyle->SetPalette(1);
1917
1918 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1919
1920 double rightmargin = gStyle->GetPadRightMargin();
1921 gStyle->SetPadRightMargin(0.1);
1922
1924
1925 gStyle->SetPadRightMargin(rightmargin);
1926
1927
1928
1929 for ( size_t ipanel=0 ; ipanel<panels.size() ; ipanel++ ) {
1930
1931 Panel& panel = panels[ipanel];
1932
1933 std::cout <<
blue <<
"\n\n---------------------------------------------\n" <<
reset;
1934
1935 std::cout << panel << "\n" << std::endl;
1936
1937 int ncolsp = panel.
ncols();
1938 int nrowsp = panel.
nrows();
1939
1940 double extraw = 1;
1941
1942 std::cout << "\nncols: " << ncolsp << "\tnrows: " << nrowsp << std::endl;
1943
1944 bool multipanel = ( panel.
size() > 1 );
1945
1946 if ( panel.
size()==0 ) {
1947 std::cout <<
"panel empty: " << panel.
name() << std::endl;
1948 continue;
1949 }
1950
1951 gStyle->cd();
1952
1953 if ( panel.
size()>4 ) gStyle->SetLineScalePS(0.5);
1954
1955 if ( multipanel ) extraw = 1.05;
1956
1957 TCanvas*
tc =
new TCanvas(
"tc",
"", extraw*ncolsp*800, nrowsp*600 );
1958
1960
1961 const std::string& atlaslabel = atlaslabel_tmp;
1962
1963 if ( multipanel ) {
1964
1965 gStyle->SetLineScalePS(1);
1966
1969
1977
1980
1981 tc->Divide( ncolsp, nrowsp, 0.0001, 0.0003 );
1982
1983 }
1984
1986
1987 std::string plotname = "";
1988
1989 for (
size_t i=0 ;
i<panel.
size() ;
i++ ) {
1990
1992
1993 bool drawmeans = false;
1994 bool drawresiduals = true;
1995
1996
1998 if (
contains(
histo.detail(),
"-residual") ) drawresiduals =
false;
1999
2000 std::string xaxis =
histo.xtitle();
2001 std::string yaxis =
histo.ytitle();
2002
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 );
2008 }
2009
2012
2013
2014
2015
2018
2019 bool translate_x = false;
2020
2021 if ( ( lumiref_trans || lumitest_trans ) &&
contains(
histo.xtitle(),
"Pile-up" ) ) translate_x =
true;
2022
2023#if 0
2025 if ( translate_x ) {
2026 xinfo.
lo( xinfo.
lo()*(1-0.054) );
2028 xinfo.
hi( xinfo.
hi()*(1-0.054) );
2029 }
2030#endif
2031
2033
2034#ifdef D0REBIN
2035 bool d0rebin_flag = false;
2036
2038#endif
2039
2042 }
2043
2046 }
2047
2048 int labelcolour = kBlack;
2049
2050 int npanel = nrowsp*(
i/nrowsp) + i%nrowsp + 1 ;
2051
2052 std::cout <<
"panel: panel: " << panel.
name() <<
"\tsubpanel: " << npanel << std::endl;
2053
2054 if ( multipanel )
tc->cd( npanel );
2055
2057
2058 noreftmp = noref;
2059
2061
2062 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2063
2064 std::cout <<
"main() processing histo[" <<
i <<
"] " << (
i<10 ?
" " :
"" ) <<
histo.name() <<
"\t" <<
histo.xaxis() << std::endl;
2065
2067 plots_eff.clear();
2068
2071
2072 std::string noreflabel=defreflabel;
2073
2074 double xpos = 0.18;
2075 double ypos = 0.91;
2076
2078
2079
2080
2083
2084 if ( atlasstyle ) {
2085 xpos = 0.18;
2086 if ( ypos>0.5 ) ypos = 0.85;
2087 else ypos = 0.18;
2088 }
2089
2090 if ( ypos_in!=0 ) ypos = ypos_in;
2091
2092 double xpos_original = xpos;
2093
2094 xpos += xoffset;
2095
2096 if ( xinfo.
offset() != 0 ) {
2097
2098 std::cout <<
"HA ! xinfo.offset: " << xinfo.
offset() << std::endl;
2099
2101
2102 }
2103
2104
2105 if ( yinfo.
offset() != 0 ) {
2106
2107 std::cout <<
"HA ! yinfo.offset: " << yinfo.
offset() << std::endl;
2108
2110
2111 }
2112
2113
2114
2116
2117 size_t Nrows =
chains.size();
2118
2119 if ( ALLRANGEMAP || (RANGEMAP && xaxis.find("p_{T}")!=std::string::npos && ccolours.size() ) ) {
2120 Nrows = ( Nrows < ccolours.size() ? Nrows : ccolours.size() );
2121 }
2122
2123 int Nlines = Nrows + taglabels.size();
2124
2125 std::vector<double> ypositions;
2126 std::vector<double> ypositions2;
2127
2128 double deltay = (Nrows*0.055-0.005)/Nrows;
2129
2131 double yhi = ypos-0.01;
2132
2133 if ( ypos>0.5 )
ylo -= Nlines*deltay;
2134 else yhi += Nlines*deltay;
2135
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) );
2140 }
2141
2142
2143
2145
2148 }
2149 else {
2151 }
2152
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 );
2155
2156
2157 std::vector<std::string>
Mean;
2158 std::vector<std::string> MeanLF;
2159 std::vector<std::string>
RMS;
2160
2162 MeanLF.clear();
2164
2165 std::vector<std::string> Chi2;
2166 std::vector<std::string> MeanRef;
2167 std::vector<std::string> RMSRef;
2168
2169
2170
2171 Chi2.clear();
2172 MeanRef.clear();
2173 RMSRef.clear();
2174
2175 int mean_power = 0;
2176 int rms_power = 0;
2177 bool power_set = false;
2178
2180
2182
2183
2184
2185 for (
unsigned int j=0;
j<
chains.size();
j++) {
2186
2187 TFile* fftest = ftest;
2188 TFile* ffref = fref;
2189
2190 std::string
cc = ftest->GetName();
2191 std::string cr = "";
2192
2193 if ( fref ) cr = fref->GetName();
2194
2195 if ( chainfiles.size()>0 && chainfiles.size()>j ) ffref = fftest = chainTFiles[
j];
2196
2199
2200 std::cout <<
"chain: " <<
chains[
j] <<
"\taddchains: " << addchains << std::endl;
2201 std::cout <<
"chainref: " << chainref[
j] << std::endl;
2202
2203 noreftmp = noref;
2205
2208
2212
2213 TH2D* h2test = 0;
2214
2215
2216 TGraphAsymmErrors* tgtest = 0;
2217
2218 std::cout << "refchain.size() " << refchain.size() << std::endl;
2219
2220 std::cout <<
"refchain: " << refchain[
j] << std::endl;
2221
2223
2224 gPad->SetRightMargin(0.03);
2225
2226 bool do2D = false;
2227
2228 labelcolour = kBlack;
2229
2230
2232
2233 do2D = true;
2234 labelcolour = kWhite;
2235
2236 gPad->SetRightMargin(0.13);
2237
2238 std::cout <<
"\n\nsee! it is a 2d histograms !!! " <<
histo.name() <<
"\n\n" << std::endl;
2239
2241
2242 std::cout << "\t2d: " << h2test << std::endl;
2243
2245
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());
2250
2253
2254 std::cout << xinfo << std::endl;
2255 std::cout << yinfo << std::endl;
2256
2258 h2test->GetYaxis()->SetRangeUser( yinfo.
lo(), yinfo.
hi() );
2259 }
2260
2262
2264 h2test->GetXaxis()->SetRangeUser( xinfo.
lo(), xinfo.
hi() );
2265 }
2266
2269
2271
2272 h2test->DrawCopy("colz");
2273
2274 if (
histo.detail().find(
"logz")!=std::string::npos ) gPad->SetLogz(
true);
2275 else gPad->SetLogz(false);
2276
2277
2278 }
2280
2283
2284 std::cout <<
red <<
"fetch 2d: " <<
histo.name() <<
reset << std::endl;
2285
2286 bool bsigma = false;
2288
2289 bool bmean = false;
2291
2292 std::string tmp_ =
histo.name();
2294
2295 if ( bsigma )
base =
chop( tmp_,
"/sigma" );
2296 if ( bmean )
base =
chop( tmp_,
"/mean" );
2297
2298 std::cout <<
"refitting: " <<
histo.name() <<
"\tbase: " <<
base <<
"\tbsigma: " << bsigma <<
"\tbmean: " << bmean << std::endl;
2299
2301
2303
2304
2305 TH2D* href2d = 0;
2306
2307 if ( ffref ) href2d =
Get<TH2D>( *ffref, chains[j]+
"/"+
base+
"/2d", testrun, chainmap );
2308
2309 if ( href2d==0 ) href2d =
Get<TH2D>( *ffref, chains[j]+
"/"+
base+
"/2D", testrun, chainmap );
2310
2311 if ( htest2d==0 ) continue;
2312 if ( !noreftmp && href2d==0 ) noreftmp = true;
2313
2314 std::cout << "href2d : " << href2d << std::endl;
2315
2317
2318 std::cout << "plotter" << std::endl;
2319
2321
2322 Resplot rtest(
"tmp", htest2d );
2323
2324 std::cout << "Resplot rtest\t" << rtest.finalised() << std::endl;
2325
2326 if ( rtest.finalised() ) {
2327 std::cout << "refitting ..." << std::endl;
2330 }
2331 else {
2332 std::cout << "refitting (finalising) ..." << std::endl;
2335
2336 rtest.Mean()->DrawCopy();
2337 gPad->Print("Duff.pdf");
2338 }
2339
2340 std::cout << "bsigma: " << bsigma << std::endl;
2341 std::cout << "bmean: " << bmean << std::endl;
2342
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); }
2345
2346 std::cout <<
reset << std::endl;
2347
2348 if ( htest==0 ) {
2349 std::cerr <<
red <<
"missing test histogram: " << (refchain[
j]+
" / "+
histo.name()) <<
" " <<
htest
2350 <<
"(test)" <<
reset << std::endl;
2351 continue;
2352 }
2353 else {
2354 std::cout <<
green <<
"htest: " <<
htest->GetName() <<
reset << std::endl;
2355 }
2356
2357 std::cout <<
"\nhisto.name(): " <<
histo.name() << std::endl;
2358
2359 std::cout <<
reset << std::endl;
2360
2361 if (
true &&
histo.name().find(
"d0_vs_phi")!=std::string::npos ) {
2362
2363 TVirtualPad*
old = gPad;
2364
2365 std::cout << "old canvas: " << gPad << std::endl;
2366
2367 std::cout <<
"dbg histo name: " <<
histo.name() << std::endl;
2368
2370
2372
2373 if (
histo.name().find(
"_rec")!=std::string::npos ) {
2374
2377
2379 }
2380
2381 if (
histo.name().find(
"_rec")==std::string::npos ) {
2382
2383 fitcanvas =
new TCanvas(
"fit",
"", 700, 600 );
2385
2387 }
2388
2389 TVirtualPad* tp = gPad;
2390
2392
2394
2395
2396
2397 rtest.Mean()->SetDirectory(0);
2398
2400
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]");
2403
2404 TF1* tf = new TF1( "sinus", "[0]*sin(x+[1])+[2]" );
2405
2406 tf->SetLineWidth(1);
2407
2408 hf->GetYaxis()->SetTitleOffset( hf->GetYaxis()->GetTitleOffset()*1.1 );
2409
2410 {
2411 TCanvas* tfc = new TCanvas( "tmp", "", 700, 600 );
2412 tfc->cd();
2413 hf->Fit( tf );
2414 delete tfc;
2415 }
2416
2417 double phi0 = tf->GetParameter(1);
2418
2419
2420 double x = tf->GetParameter(0)*
cos(phi0);
2421 double y = tf->GetParameter(0)*
sin(phi0);
2422 double off = tf->GetParameter(2);
2423
2424 std::cout <<
"\tx = " <<
x << std::endl;
2425 std::cout <<
"\ty = " <<
y << std::endl;
2426 std::cout << "\toffset = " << off << std::endl;
2427
2428 std::string cckstr =
chains[
j];
2429
2430 cckstr = cckstr.substr( cckstr.find("HLT_IDTrack") );
2431
2433
2434 vstr.resize(vstr.find("_boffperf"));
2435 vstr.resize(vstr.find("_L1"));
2436
2437 hf->SetMinimum( -0.03 );
2438 hf->SetMaximum( 0.03 );
2439
2441
2442 if ( first ) hf->DrawCopy();
2443
2444 hf->DrawCopy("same");
2445 hf->DrawCopy("samee");
2446
2447
2450
2454
2455 std::string sht =
chains[
j]+
"-"+
histo.name()+
"-fit.pdf";
2456
2457 size_t p = sht.find(
"/");
2458
2459 while ( p!=std::string::npos ) {
2460 sht.erase( p, 1 );
2462 }
2463
2464
2465 gPad->Print( sht.c_str() );
2466 gPad->Print( "sht.pdf" );
2467
2468 std::cout << "CNT !!!" << std::endl;
2469
2470 delete tf;
2471
2472 tp->cd();
2473
2475
2476 }
2477
2478
2481
2483
2484 std::cout << "Resplot noreftmp " << noreftmp << " ... " << std::endl;
2485
2486 if ( !noreftmp ) {
2487 if ( refitref_resplots ) {
2488
2489 std::cout << "Resplot rref: " << href2d << std::endl;
2490
2492
2493 std::cout << "Resplot rref: " << href2d << " (2)" << std::endl;
2494
2495 if ( rref.finalised() ) {
2496 std::cout << "refitting (2) ..." << std::endl;
2499 }
2500 else {
2501 std::cout << "refitting (2 - finalising) ..." << std::endl;
2504 }
2505
2506 std::cout << "Resplot rref: " << href2d << " (3)" << std::endl;
2507
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); }
2510
2511 std::cout << "Resplot rref: " << href2d << " (4)" << std::endl;
2512
2513 }
2514 else {
2515
2516 std::cout <<
"Resplot rref: " << href2d <<
" (5)" <<
reset << std::endl;
2517
2518 hreft =
Get( *ffref, refchain[j]+
"/"+
histo.name(), rawrefrun, chainmap );
2519 if ( hreft==0 ) {
2520 std::cerr <<
"ERROR: could not find " << (refchain[
j]+
"/"+
histo.name()) << std::endl;
2521 }
2522
2523
2524 }
2525 }
2526
2527 std::cout << "Resplot rref: " << href2d << " (6)" << std::endl;
2528
2529
2530 if ( !noreftmp && hreft==0 ) {
2531
2532 std::cerr <<
"missing ref histogram: " << (refchain[
j]+
" / "+
histo.name()) <<
" " <<
htest <<
"(ref)" << std::endl;
2533
2534 noreftmp = true;
2536 noreflabel="reference not found";
2539
2540 }
2541
2542 if ( !noreftmp ) {
2543
2544 std::cout << "Resplot rref: " << href2d << " (7)" << std::endl;
2545
2547 href->SetDirectory(0);
2548
2549 std::cout <<
"Resplot href: " <<
href <<
" (7a)" << std::endl;
2550
2551 }
2552
2553 std::cout << "Resplot rref: " << href2d << " (8)" << std::endl;
2554
2555
2557
2558
2560
2561 std::cout << "Resplot rref: " << href2d << " (9)" << std::endl;
2562
2563 }
2564 else {
2565
2567
2568 std::string reghist =
histo.name();
2569
2570 std::cout <<
"hist: " << (
chains[
j]+
"/"+reghist) <<
"\tftest " << ftest << std::endl;
2571
2572
2573
2575
2576 std::cout <<
"\nhist: " <<
htest << std::endl;
2577
2578 std::cout << "fftest: " << fftest->GetName() << std::endl;
2579
2581
2582
2583 if ( lumitest_trans && translate_x && !
contains( cc,
"-mc" ) )
htest =
trans( htest, translate_x );
2584
2585 std::cout << xaxis << std::endl;
2586
2587 if ( htest==0 ) {
2588 std::cerr <<
"missing test histogram: " << (
chains[
j]+
" / "+reghist) <<
" " << htest<< std::endl;
2589 continue;
2590 }
2591
2593
2595
2596 if ( ffref ) hreft =
Get( *ffref, refchain[j]+
"/"+reghist, rawrefrun, chainmap );
2597 else noreftmp = true;
2598
2599 if ( hreft && lumiref_trans && translate_x && !
contains( cr,
"-mc" ) ) hreft =
trans( hreft, translate_x );
2600
2601 std::cout << "hreft: " << hreft << std::endl;
2602
2603 if ( std::string(
htest->ClassName()).find(
"TH2")!=std::string::npos ) {
2604 std::cout <<
"Class TH2: " <<
htest->GetName() << std::endl;
2605 continue;
2606 }
2607
2608
2609 if ( std::string(
htest->ClassName()).find(
"TH1")!=std::string::npos ) {
2610 std::cout <<
"Class TH1: " <<
htest->GetName() << std::endl;
2611 }
2612 else if ( std::string(
htest->ClassName()).find(
"TProfile")!=std::string::npos ) {
2613 std::cout <<
"Class TProf: " <<
htest->GetName() << std::endl;
2614 }
2615 else if ( std::string(
htest->ClassName()).find(
"TEfficiency")!=std::string::npos ) {
2616 std::cout <<
"Class TEff: " <<
htest->GetName() << std::endl;
2617 }
2618
2619
2620 std::cout << "Resplot hreft: " << hreft << " (10)" << " " << noreftmp << std::endl;
2621
2622 if ( !noreftmp && hreft==0 ) {
2623 std::cerr <<
"missing ref histogram: " << (refchain[
j]+
" / "+reghist)
2624 << " " << hreft << std::endl;
2625
2626 noreftmp = true;
2628 noreflabel="reference not found";
2631
2632
2633 }
2634
2635 std::cout << "Resplot hreft: " << hreft << " (10)" << std::endl;
2636
2637 if ( hreft!=0 ) {
2638
2639 std::cout << "Resplot hreft: " << hreft->ClassName() << " (11)" << std::endl;
2640
2641 if ( std::string(hreft->ClassName()).find("TH1")!=std::string::npos ) {
2643 href->SetDirectory(0);
2644 }
2647 }
2648 }
2649 else {
2650 noreftmp = true;
2652 }
2653
2654 std::cout <<
" \tget " << (
chains[
j]+
"/"+reghist) <<
"\thtest " << htest << std::endl;
2655 std::cout <<
" \tget " << (refchain[
j]+
"/"+reghist) <<
"\thref " << href << std::endl;
2656
2657 if ( htest==0 ) continue;
2658
2659 if ( !noreftmp && href==0 ) {
2660 noreftmp = true;
2662 }
2663
2664 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2665
2666
2667 if ( rebin!=1 ) {
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;
2672 }
2673
2674#if 0
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);
2680 }
2681#endif
2682
2683
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);
2687 }
2688
2689
2690 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2691
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);
2694
2695 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2696
2697 if ( notitle ) {
2698 htest->SetTitle(
"");
2699 if( href )
href->SetTitle(
"");
2700 }
2701
2702 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2703
2704 }
2705
2706 std::cout << "done else" << std::endl;
2707
2708 if ( do2D ) continue;
2709
2710 std::cout <<
"done else:\t" <<
htest << std::endl;
2711 std::cout <<
"done else:\t" <<
htest->GetName() << std::endl;
2712
2713 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2714
2715 if ( !do2D && make_ref_efficiencies ) {
2716
2717 std::cout << "make ref efficiencies" << std::endl;
2718
2719 if ( htest && href ) {
2720
2722
2723
2725
2726 std::string effhist =
histo.name();
2727
2728
2729
2730 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos );
2731
2732
2733
2734 TH1F* hrefnumt =
Get( *ffref, refchain[j]+
"/"+effhist+
"_n", rawrefrun, chainmap, &
savedhistos );
2735
2736
2737
2738 if ( !noreftmp && hrefnumt!=0 ) {
2739 hrefnum = (
TH1F*)hrefnumt->Clone();
2740 hrefnum->SetDirectory(0);
2741 }
2742
2743 }
2744 }
2745
2746 }
2747
2748 std::cout <<
"done effs ? " << bayes <<
"\thtest: " <<
htest <<
" :: " <<
htest->GetName() << std::endl;
2749
2750 if ( bayes ) {
2751
2752 std::cout <<
"make ref efficiencies " <<
htest->GetName() << std::endl;
2753
2754 if ( make_efficiencies && htest &&
contains( std::string(
htest->GetName()),
"eff" ) && !
contains( std::string(
htest->GetName()),
"_d" ) ) {
2755
2756 std::string effhist =
histo.name();
2757
2759
2760 if ( rebin!=1 ) std::cout << effhist <<
"\trebin: " <<
rebin << std::endl;
2761
2762
2763 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos ) ;
2764 htestden =
Get( *fftest, chains[j]+
"/"+effhist+
"_d", testrun, 0, &
savedhistos ) ;
2765
2766 if ( htestnum==0 && htestden==0 ) {
2767 TEfficiency*
eff = 0;
2768
2770
2771 if ( eff ) {
2772 htestnum = (
TH1F*)
eff->GetPassedHistogram();
2773 htestden = (
TH1F*)
eff->GetTotalHistogram();
2774 }
2775
2776 }
2777
2778 std::cout << "eff: htestnum: " << htestnum << "\thtestden: " << htestden << std::endl;
2779
2780
2782
2783 std::cout <<
"heff: " << effhist <<
"\t" <<
ars << std::endl;
2784
2785
2786 std::cout << "1: Bayesian error calculation " << htestnum << " " << htestden << "\tscale " << scale_eff << std::endl;
2787
2788 if ( htestnum && htestden ) {
2789
2790#ifdef D0REBIN
2793 if ( d0rebin_flag ) {
2794 htestnum =
d0rebin( htestnum );
2795 htestden =
d0rebin( htestden );
2796 }
2797 else if ( rebin!=1 ) {
2798 htestnum =
Rebin(htestnum, rebin );
2799 htestden =
Rebin(htestden, rebin );
2800 }
2801#endif
2802 std::cout << "test histogram name: : " << htestnum->GetName() << "\txaxis: " << xaxis << "\t" << std::endl;
2803
2804 if ( make_efficiencies && std::string(htestnum->GetName()).find("ntrax_eff")!=std::string::npos ) {
2805
2806 bool low = true;
2807
2810 }
2811
2812#if 0
2816 std::cout <<
"rebin " <<
histo.name() << std::endl;
2817 htestnum->Rebin(3);
2818 htestden->Rebin(3);
2819 }
2820
2821 if ( make_efficiencies &&
contains(
htest->GetName(),
"eta_eff" ) ) {
2822 std::cout <<
"rebin " <<
histo.name() << std::endl;
2823 htestnum->Rebin(2);
2824 htestden->Rebin(2);
2825 }
2826
2827#endif
2828
2829
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 );
2834 }
2835
2836 if ( lumitest_trans && translate_x && !
contains( cc,
"-mc" ) ) {
2837 htestnum =
trans( htestnum, translate_x );
2838 htestden =
trans( htestden, translate_x );
2839 }
2840
2842
2843 tgtest =
e.Bayes(scale_eff);
2844
2846
2847 htest->SetName( (std::string(htestnum->GetName())+
"_eff").c_str() );
2848
2849 std::cout << "effhist: " << effhist << std::endl;
2850
2851 }
2852
2854
2855 std::cout << "recalculating reference efficiencies ..." << std::endl;
2856
2857 if ( href ) {
2858
2859 std::cout << "doin ..." << std::endl;
2860
2861
2862 TH1F* hrefnum =
Get( *ffref, refchain[j]+
"/"+
histo.name()+
"_n", rawrefrun, chainmap );
2863 TH1F* hrefden =
Get( *ffref, refchain[j]+
"/"+
histo.name()+
"_d", rawrefrun, chainmap );
2864
2865
2866 if ( hrefnum==0 && hrefden==0 ) {
2867 TEfficiency*
eff = 0;
2868
2870
2871 if ( eff ) {
2872 hrefnum = (
TH1F*)
eff->GetPassedHistogram();
2873 hrefden = (
TH1F*)
eff->GetTotalHistogram();
2874 }
2875
2876 }
2877
2878
2879
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;
2882
2883
2884 if ( hrefnum && hrefden ) {
2885
2886 if ( lumiref_trans && translate_x && !
contains( cr,
"-mc" ) ) {
2887 hrefnum =
trans( hrefnum, translate_x );
2888 hrefden =
trans( hrefden, translate_x );
2889 }
2890
2891#ifdef D0REBIN
2894 if ( d0rebin_flag ) {
2897 }
2898 else if ( rebin!=1 ) {
2899 hrefnum =
Rebin(hrefnum, rebin );
2900 hrefden =
Rebin(hrefden, rebin );
2901 }
2902#endif
2903
2904 std::cout << hrefnum << " " << hrefden << std::endl;
2905
2908
2909
2911
2912 }
2913 }
2914 }
2915
2916 std::cout <<
"dbg: htest: " <<
htest << std::endl;
2917 std::cout <<
"dbg: htest name " <<
htest->GetName() << std::endl;
2918
2919 if (
true &&
histo.name().find(
"invmass")!=std::string::npos ) {
2921 }
2922
2923
2924 }
2925
2926
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;
2930
2932
2935 std::cout << "efficiency" << std::endl;
2936 }
2937
2938 std::cout <<
"href " <<
href <<
"\t (TEfficiency " <<
isTEfficiency(href) <<
")" << std::endl;
2939
2940
2941 if ( htest==0 ) {
2942 std::cout <<
" no test histogram : " << (
chains[
j]+
"/"+
histo.name()) << std::endl;
2943 continue;
2944 }
2945
2946
2947 if ( !noreftmp && href==0 ) {
2948 std::cout <<
" no ref histogram : " << (
chains[
j]+
"/"+
histo.name()) << std::endl;
2949 noreftmp = true;
2951 noreflabel="reference not found";
2954
2955 }
2956
2957 std::cout <<
"htest: " <<
isTEfficiency(htest) << std::endl;
2958
2960
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());
2965
2966 std::cout <<
"htest: " <<
htest <<
"\t" << __LINE__ << std::endl;
2967
2968
2969 if ( !noreftmp ) {
2970
2971 href->GetYaxis()->SetTitleOffset(1.5);
2972 href->GetXaxis()->SetTitleOffset(1.5);
2973 std::cout <<
"xaxis: " <<
href->GetXaxis()->GetTitle() << std::endl;
2974
2975 }
2976
2977 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2978
2979#if 0
2981
2982 double xm =
htest->GetMean();
2983
2984 if ( xm>=10 ) {
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 );
2988
2989 if ( nrebin>1 ) {
2990 std::cout <<
"rebin: " <<
htest->GetName() <<
"\tbins: " << nrebin << std::endl;
2991 htest->Rebin(nrebin);
2993 if ( !noreftmp ) {
2994 href->Rebin(nrebin);
2996 }
2997 }
2998 }
2999 }
3000#endif
3001
3002 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3003
3004
3006 if ( plotname == "" ) {
3007
3008 if ( key!="" ) {
3009 htest->SetTitle(
"");
3010 if ( href )
href->SetTitle(
"");
3012 }
3014 htest->SetTitle(
"");
3015 if ( href )
href->SetTitle(
"");
3016 plotname = "HLT_";
3017 }
3019 htest->SetTitle(
"");
3020 if ( href )
href->SetTitle(
"");
3021 plotname = "EF_";
3022 }
3024 htest->SetTitle(
"");
3025 if ( href )
href->SetTitle(
"");
3026 plotname = "L2_";
3027 }
3029 htest->SetTitle((
"FTK "+
histo.name()).c_str());
3030 if ( href )
href->SetTitle((
"FTK "+
histo.name()).c_str());
3031 plotname = "FTK_";
3032 }
3033
3034 plotname +=
histo.name();
3035
3039
3040 }
3041
3042
3043 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3044
3046
3048
3049 std::string collection =
basename( chains[j] );
3050
3052
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") );
3055
3056
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;
3060
3061 std::regex rx("_HLT_[^_]*RoI.*");
3062 std::regex
rx1(
"_HLT_[^_]*_RoI.*");
3063
3064 std::cout << "\n\n\nactual_chain: " << actual_chain << std::endl;
3065
3066 arsaway( actual_chain,
"_L1.*",
"" );
3067 arsaway( actual_chain,
"L1.*",
"" );
3068
3069 actual_chain = std::regex_replace( actual_chain, std::regex( "L1.*:" ), "" );
3070
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") );
3074
3075 std::cout << " : " << actual_chain << "\n\n\n" << std::endl;
3076
3077
3078 actual_chain = std::regex_replace( actual_chain, std::regex( "_HLT_IDTrack.*" ), "" );
3079
3080
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, "" );
3084
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 );
3093
3094
3095
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") );
3106
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(
"_");
3112 }
3113 }
3114
3115 std::cout <<
blue <<
"actual chain: " << actual_chain <<
"\tcollection: " << collection <<
reset << std::endl;
3116
3117 std::string
c = actual_chain +
" : " + collection;
3118
3119 std::cout << "track collection: " << collection << " <-" << std::endl;
3120 std::cout << "actual chain: " << actual_chain << " <-" << std::endl;
3121
3123
3125
3126 std::cout <<
"use label: " <<
c <<
"\tchains size " <<
chains.size() <<
"\t" << usrlabels.size() << std::endl;
3127
3128 std::cout <<
"chains.size() " <<
chains.size() <<
" " <<
j << std::endl;
3129 std::cout <<
"chains.size() " <<
chains.size() <<
" " <<
j << std::endl;
3130
3131 std::cout <<
"chains[j] : " <<
j <<
" " <<
chains[
j] << std::endl;
3132
3133 std::cout << "userlabels.size() " << usrlabels.size() << std::endl;
3134
3135 if ( usrlabels.size() < j+1 ) {
3136 if ( usrlabels.size()!=0 ) std::cerr << "userlabels not large enough - not using userlabels" << std::endl;
3137 }
3138 else c = usrlabels[
j ];
3139
3140 std::cout <<
"use label: c: " <<
c << std::endl;
3141
3143
3144 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3145
3146 std::cout <<
blue <<
"xaxis: " << xaxis <<
reset << std::endl;
3147
3148 if ( ALLRANGEMAP || xaxis.find("p_{T}")!=std::string::npos || xaxis.find("E_{T}")!=std::string::npos ) {
3149
3150 if ( RANGEMAP && xaxis.find("p_{T}")!=std::string::npos ) {
3151 bnd.
range( chains[j], htest );
3152 if ( href ) bnd.
range( chains[j], href );
3153 }
3154
3155 if ( RANGEMAP || ALLRANGEMAP ) {
3156
3158
3159 std::cout << "\n\n\nctags " << ctags.size() << "\n\n" << std::endl;
3160
3161 for (
size_t ic=0 ;
ic<ctags.size() ;
ic++ ) {
3162
3163 std::cout <<
"\n\nic: " <<
ic <<
" " << ctags[
ic] <<
" " << ccolours[
ic] <<
"\n\n" << std::endl;
3164
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] );
3171 if ( tgtest ) {
3172 tgtest->SetLineColor(
htest->GetMarkerColor());
3173 tgtest->SetMarkerStyle(
htest->GetMarkerStyle());
3174 tgtest->SetMarkerColor(
htest->GetMarkerColor());
3175 }
3176 break;
3177 }
3178 }
3179
3180 }
3181
3182 std::cout <<
"test: " <<
chains[
j] <<
"chains colour: " <<
htest->GetMarkerColor() << std::endl;
3183
3184 }
3185
3186
3187 std::cout << "movin' on ..." << std::endl;
3188
3189 std::cout <<
"chain: " <<
chains[
j] <<
" \t marker colour: " <<
htest->GetMarkerColor() << std::endl;
3190
3191 std::cout <<
"Plotter marker : " <<
htest->GetMarkerColor() <<
" " <<
htest->GetMarkerStyle() << std::endl;
3192
3193
3194 if ( uselabels )
plots.push_back(
Plotter( htest, href,
" " + chain_name[j] + c, tgtest ) );
3195 else {
3196 std::cout <<
"using label: " <<
c << std::endl;
3198 }
3199
3200 std::cout << "AxisInfo: " << xaxis << std::endl;
3201
3204
3205 std::cout <<
"c: " <<
c <<
"\t" << ftest->GetName() << std::endl;
3206
3207 if ( refbands ) {
3208 std::cout << "refbands: " << refbands << std::endl;
3209 plots.back().mc(
true );
3210 translate_x = false;
3211 }
3212
3213 if ( ALLRANGEMAP || ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) )
plots.back().max_entries( ccolours.size() );
3214
3215 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3216
3217 if ( make_ref_efficiencies ) {
3218
3219 if ( htestnum && hrefnum ) {
3221
3223
3224 double range =
h->GetMaximum()-
h->GetMinimum();
3225
3226 if ( range<0.2*scale_eff ) {
3227
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;
3230
3231 if ( fmax>1*scale_eff ) fmax = 1.02*scale_eff;
3232 if ( fmin<0 ) fmin = 0;
3233
3234 h->SetMinimum(fmin);
3235 h->SetMaximum(fmax);
3236
3237 }
3238
3239 plots_eff.push_back(
Plotter(
e.Hist(), 0, c ) );
3240
3241 }
3242 }
3243
3244
3245 std::cout << "means: " << drawmeans << " " << means << std::endl;
3246
3247 std::cout << "chi2: " << std::endl;
3248
3249 std::cout <<
"htest " <<
htest << std::endl;
3250 std::cout <<
"href " <<
href << std::endl;
3251
3252 std::cout <<
"chi2: " <<
chi2( htest, href ) <<
"\t histo name: " <<
histo.name() << std::endl;
3253
3255
3256
3257 if ( href ) Chi2.push_back(
label(
"chi2 = %5.2lf / %2.0lf",
chi2( htest, href ),
double(
htest->GetNbinsX()) ) );
3258
3259 std::cout << "Chi2.push_back()" << std::endl;
3260
3261 if ( drawmeans || means ) {
3262
3263 double mean_95 =
htest->GetMean();
3264 double dmean_95 =
htest->GetMeanError();
3265 double rms_95 =
htest->GetRMS();
3266 double drms_95 =
htest->GetRMSError();
3267
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 ) );
3271
3272 }
3273
3274 std::cout <<
"residual: " <<
residual <<
" " << drawresiduals << std::endl;
3275
3276 if ( residual && drawresiduals ) {
3277
3279
3280 xpos = xpos_original;
3281
3282 std::cout <<
"calculating resolutions : " <<
histo.name() <<
" " <<
htest->GetName() << std::endl;
3283
3285
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);
3290
3291 std::cout <<
"\t\t" <<
histo.name()
3292 << "\tmean: " << mean_95 << " +- " << dmean_95
3293 << "\trms: " << rms_95 << " +- " << drms_95 << std::endl;
3294
3296
3297 if ( !power_set ) {
3298 for (
int ip=-2 ;
ip<9 ;
ip++ ) {
3299 if ( std::fabs(mean_95) >= std::pow( 10., double(-ip) ) ) {
3301 break;
3302 }
3303 }
3304
3305 for (
int ip=-2 ;
ip<9 ;
ip++ ) {
3306 if ( std::fabs(rms_95) >= std::pow( 10., double(-ip) ) ) {
3308 break;
3309 }
3310 }
3311 }
3312
3313 power_set = true;
3314
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;
3318
3319
3320 if ( mean_power == 0 ) {
3321 Mean.push_back(
label(
"mean_{95} = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3322 }
3323 else {
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 ) );
3326
3327 }
3328
3329 if ( rms_power == 0 ) {
3330 RMS.push_back(
label(
"rms_{95} = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3331 }
3332 else {
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 ) );
3335 }
3336
3337 if ( href ) {
3339
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);
3344
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;
3348
3349 if ( mean_power == 0 ) {
3350 MeanRef.push_back(
label(
"mean_{95} ref = %4.2lf #pm %4.2lf", mean_95ref, dmean_95ref) );
3351 }
3352 else {
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 ) );
3355
3356 }
3357
3358
3359 if ( rms_power == 0 ) {
3360 RMSRef.push_back(
label(
"rms_{95} ref = %4.2lf #pm %4.2lf", rms_95ref, drms_95ref ) );
3361 }
3362 else {
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 ) );
3365 }
3366 }
3367
3369 if ( href )
href->Sumw2();
3370 }
3371
3374 if ( href )
Norm( href );
3376 Norm( htest, 1, xinfo.
lo(), xinfo.
hi() );
3377 if ( href )
Norm( href, 1, xinfo.
lo(), xinfo.
hi() );
3378 }
3379 }
3381 if ( href ) {
3384 Norm( href, 1, xinfo.
lo(), xinfo.
hi() );
3385 }
3386 }
3387 }
3388
3392 }
3393
3394 if ( !noreftmp && normref &&
3399 }
3400
3401 }
3402
3403 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3404
3405 if ( !noplots ) {
3406
3409
3410 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3411
3412 std::cout << "duff: " << xinfo << std::endl;
3413
3415 plots.sortx( xinfo );
3416
3417 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3418
3419 double yminset = 0;
3420 double ymaxset = 0;
3421
3422 double rmin = 0;
3423 double rmax = 0;
3424
3430
3431
3432
3433
3434 }
3435 else {
3436 rmin =
plots.realmin();
3437 rmax =
plots.realmax();
3438 }
3439
3441
3442 int csize =
chains.size() + taglabels.size() + ( atlasstyle ? 1 : 0 );
3443
3444 if ( yinfo.
log() && rmin>0 && rmax>0 ) {
3445
3447 double delta = std::log10(rmax)-std::log10(rmin);
3448
3450
3451
3452 yminset = rmin*std::pow(10,-delta*0.1);
3453
3454 double newdelta = std::log10(rmax) - std::log10(yminset) + 0.05*delta;
3455
3456 if ( csize<10 ) ymaxset = rmin*std::pow(10,newdelta/(1-0.07*csize));
3457 else ymaxset = rmin*std::pow(10,newdelta*2);
3458
3459 if ( yminset!=yminset ) {
3460 std::cerr << " range error " << delta << " " << yminset << " " << ymaxset << "\t(" << rmin << " " << rmax << ")" << std::endl;
3464 continue;
3465 }
3466
3467 }
3468 else {
3469
3472
3473 if ( ypos>0.5 ) {
3474 double delta = rmax-rmin;
3475
3476 yminset = rmin-0.1*delta;
3477
3478 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3479
3480 double newdelta = rmax - yminset + 0.05*delta;
3481
3482 if ( csize<10 ) ymaxset = yminset + newdelta/(1-0.09*csize);
3483 else ymaxset = yminset + newdelta*2;
3484 }
3485 else {
3486 double delta = rmax-rmin;
3487
3488 ymaxset = rmax+0.1*delta;
3489
3490 double newdelta = ymaxset - rmin - 0.05*delta;
3491
3492 if ( csize<10 ) yminset = ymaxset - newdelta/(1-0.09*csize);
3493 else yminset = ymaxset - newdelta*2;
3494
3495 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3496
3497 }
3498
3499 }
3500
3501 }
3502 else {
3504 yminset = yinfo.
lo();
3505 ymaxset = yinfo.
hi();
3506 }
3507 }
3508
3509 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3510
3511
3512
3513
3514
3515
3517
3518 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3519
3520 if ( yminset>yinfo.
lo() ) yminset = yinfo.
lo();
3521 if ( ymaxset<yinfo.
hi() ) ymaxset = yinfo.
hi();
3522 }
3523
3524
3526
3527 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3528
3529 if ( effset ) {
3530 ymaxset = effmax;
3531 yminset = effmin;
3532 }
3533 }
3534
3535 if ( ymaxset!=0 || yminset!=0 ) {
3536
3537 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3538
3539 plots.Max( ymaxset );
3540 plots.Min( yminset );
3541 }
3542
3543 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3544
3545 if ( yminset!=0 || ymaxset!=0 ) {
3546 if ( yminset>0 )
plots.SetLogy(yinfo.
log());
3547 else plots.SetLogy(
false);
3548 }
3550
3551
3552
3553 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3554
3555
3556
3558
3559 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3560
3561 plots.Draw( legend );
3562
3563 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3564
3565 if ( atlasstyle )
ATLASLabel( xpos, ypositions[0]+deltay, atlaslabel, labelcolour, ncolsp, nrowsp );
3566
3567 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3568
3569 for (
unsigned it=0 ;
it<taglabels.size() ;
it++ ) {
3570 DrawLabel( xpos, ypositions[it], taglabels[it], labelcolour, 0.04 );
3571 }
3572
3573 for (
unsigned it=0 ;
it<taglabels2.size() ;
it++ ) {
3574 DrawLabel( xpos+0.35, ypositions2[it], taglabels2[it], labelcolour, 0.04 );
3575 }
3576
3577 }
3578
3579 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3580
3581 std::cout << "means: " << means << std::endl;
3582
3583
3584 if ( means ) {
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] );
3587 }
3588
3589
3590
3591 double ytop = 0.5;
3592
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] );
3597 histo.name()==
"pT" ||
3600
3602 for (
unsigned j=0 ;
j<
chains.size() ;
j++ ) {
3603 if ( !noreftmp ) {
3604 if ( j<MeanRef.size() ) {
3605 if ( !nomeans )
DrawLabel( xpos_original, (ytop-j*0.035), MeanRef[j],
colours[j%6] );
3607 }
3608 }
3609 if ( j<
Mean.size() ) {
3612 }
3613 }
3614 }
3615 }
3616 }
3617
3618 if ( xinfo.
log() ) gPad->SetLogx(
true);
3619 else gPad->SetLogx(false);
3620
3621 if ( yinfo.
log() ) gPad->SetLogy(
true);
3622 else gPad->SetLogy(false);
3623
3624 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3625
3626 if ( !noplots ) {
3627
3628 if ( make_ref_efficiencies ) {
3629
3630 plots_eff.SetXaxisTitle(
plots.GetXaxisTitle() );
3631 plots_eff.SetYaxisTitle(
plots.GetYaxisTitle() );
3632
3633 plots_eff.Draw( legend_eff );
3634 }
3635
3636 if ( !noreflabel.empty() )
DrawLabel(0.1, 0.06, noreflabel, kRed, 0.03 );
3637
3638 }
3639
3640 }
3641
3642
3648
3649 if ( !noplots ) {
3650
3652
3654
3655 std::string useplotname;
3656
3657 if ( panel.
size()>1 ) {
3658 useplotname = panel.
name();
3659 replace( useplotname,
'/',
'_' );
3660 }
3661 else {
3662 useplotname = plotname;
3663 }
3664
3665 useplotname.erase(
std::remove( useplotname.begin(), useplotname.end(),
'+' ), useplotname.end() );
3666
3667 std::string printbase =
dir + useplotname +
tag;
3668
3670
3671 if ( !nopdf )
print_pad( printbase+
".pdf" );
3672 if ( !nopng )
print_pad( printbase+
".png" );
3673 if ( Cfile )
print_pad( printbase+
".C" );
3674
3675 std::cout << std::endl;
3676 }
3677
3678 }
3679
3680 if (
tc )
delete tc;
3681
3682 }
3683
3684
3685 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3686
3688
3689
3691 bool files_duplicated = ( fref_==ftest_ );
3692
3693 if ( deleteref && !files_duplicated ) {
3694
3695 if ( fref_ ) {
3696
3698
3699 std::cout << "main() cleaning up reference file" << std::endl;
3700
3701 TFile* newout = new TFile(".newout.root","recreate");
3702 newout->cd();
3703
3706
3708
3710
3712
3713
3715
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() );
3721 }
3722
3723
3725 if ( !noreftmp && href ) {
3727 href->Write(
dirs.back().c_str() );
3728 }
3729
3730
3732 }
3733
3734 newout->Close();
3735
3736 }
3737 }
3738
3739
3740 if (
fulldbg ) std::cout << __LINE__ << std::endl;
3741
3743
3744 if ( fref_ && !files_duplicated ) fref_->Close();
3745 if ( ftest_ ) ftest_->Close();
3746
3748
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() );
3754
3755 cmd = std::string(
"mv .newout.root ") + std::string(frefname);
3756 std::system(
cmd.c_str() );
3757 }
3758 else {
3759 std::cerr << "reference file and test file are the same - not replacing" << std::endl;
3760 }
3761 }
3762
3763 std::cout << "deleting at " << __LINE__ << std::endl;
3764
3765 if ( fref_ && !files_duplicated ) delete fref_;
3766 if ( ftest_ ) delete ftest_;
3767
3768 return 0;
3769}
void ATLASLabel(Double_t x, Double_t y, char *text=NULL, Color_t color=1)
class to store information about axes, limits, whether it is log or linear scale etc
static std::vector< std::string > split(const std::string &s, const std::string &t=":")
details of the histogram axes etc
slightly more convenient legend class
const std::string & name() const
static void setwatermark(bool b)
Get tag-value pairs from a file.
static bool setscalerms95(bool b)
static TF1 * FitNull(TH1D *s, double a=-999, double b=-999)
static TF1 * FitNull95(TH1D *s, double a=0, double b=0)
static bool setoldrms95(bool b)
void range(const std::string &chain, TH1F *h)
static void setplotref(bool b)
void autoy(TH2 *h)
get the auto y range of a 2d histogram
TH1F * rebin_log(TH1F *h, bool low=false)
void normy(TH2 *h)
zero the contents of a 2d histogram
TH1F * trans(TH1F *h, bool t=false)
void print_pad(const std::string &s)
void arsaway(std::string &s, const std::string &pattern, const std::string &rep)
void testfit(TH1 *htest, const std::string &s)
double total_eff(TH1 *hn, TH1 *hd)
std::string fullreplace(std::string s, const std::string &s2, const std::string &s3)
void ifdbg(const std::string &)
void autox(TH2 *h, bool t=false)
get the auto x range of a 2d histogram
std::map< std::string, std::string > chainmap_t
global typedef here is ok, since this is a standalone executable, including a main().
double chi2(TH1 *h0, TH1 *h1)
TH1F * makeplot(TObject *hreft)
TH1F * Rebin(TH1F *h, double f)
std::string eround(double x, int decfigs=4)
void Scale(TH1 *h, double d=1)
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...
void copyReleaseInfo(TFile *finput, TFile *foutdir)
copy the release info TTree
void Norm(TH1 *h, double scale, double xmin, double xmax)
std::string findrun(TFile *f)
bool exists(const std::string &filename)
does a file exist
bool fcontains(const std::string &s, const std::string &p)
contains a string at the beginning of the string
static std::string release
std::vector< std::string > savedhistos
std::string replace(std::string s, const std::string &s2, const std::string &s3)
std::string find(const std::string &s)
return a remapped string
std::map< std::string, int > dirs
list of directories to be explicitly included, together with corresponding depths of subdirectories
std::string chop(std::string &s1, const std::string &s2)
static std::vector< uint32_t > runnumber
std::string label(const std::string &format, int i)
const std::regex rx1(R"(_v[0-9]+$)")
mkdir(path, recursive=True)
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.
std::string dirname(std::string name)
std::string basename(std::string name)