leave this commented here - now instead of bombing out if we don't specify the reference file, just carry on as if it was not specified at all, so as this changes the external behaviour of the code we want this retained
don't fail anymore if can't open the reference file, now continue without plotting the refereces, instead printing a warning on the plots
we divide the resolutions by these values if we have an "entries" histogram to tell us how many events there are overall
set up the correct reference chain names ...
read config in from a file if requested ...
words can not express the sheer unpleasantness in trying to do anything serious with subpanels
leave this code commented here for the time being ... if ( histo.name()=="pT" || histo.name()=="pT_rec" ) ypos = 0.19;
legends ....
leave these comments here for testing ...
get the actual chain name and track collection from the Chain histogram if present
Actually DO refit the references - if we are adding together many resplots, then the means etc may not even have been calculated
leave this code commented here since we want to know where to change this in the future it was added for a reason, so is useful to keep for now
useful test for debugging ...
leave this code commented here since we want to know where to change this in the future it was added for a reason, so useful to keep for now
debugging ...
rebin if requested ...
leave for documentation purposes ...
again, this changes the external behaviour so we want to leave this "continue" in place, but commented
replace the "/" in the filename so we don't try to make plots in subdirectories by accident
sort out the range settings for the xaxis ...
keep the original equation by way of documentation ...
leave this code commented here since we want to know where to change this in the future it was added for a reason, so it is useful to keep for now
std::exit(-1);
calculate the required range such that the histogram labels won't crowd the points
actually draw the plot here ...
NB: now, we no longer print the individual plots - only the "panels" individual plots can still be printed by creating a "panel" which contains only that plots - in fast the "histos" item that before provided details of the separate plots is now interpreted as a list of single plot panels so this is done for you
debugging ...
546 {
547
548 std::cout << "\n---------------------------------\n";
549 std::cout << "\n comparitor is off ...\n";
550
551 if ( argc<4 )
return usage(argv[0], -1,
"too few arguments");
552
554
555 std::string
tag =
"";
556 std::string
key =
"";
557
558 std::string
dir =
"";
559
560 std::string ftestname = "";
561 std::string frefname = "";
562
563 TFile* ftest_ = 0;
564 TFile* fref_ = 0;
565
566 bool effset = false;
567 double effmin = 90;
568 double effmax = 102;
569
570 std::string defreflabel = "";
571
573
574 std::vector<std::string> usrlabels;
575 bool uselabels = false;
576 bool addinglabels = false;
577
578 std::vector<std::string> taglabels;
579 bool addingtags = false;
580
581 bool make_ref_efficiencies = false;
582 bool refit_resplots = false;
583 bool refitref_resplots = false;
584 bool bayes = true;
585 bool nostats = false;
586 bool nomeans = false;
587 bool noref = false;
588 bool atlasstyle = false;
589 bool deleteref = false;
590 bool nowatermark = false;
591 bool noplots = false;
592 bool nopng = false;
593 bool nopdf = false;
594 bool Cfile = false;
595 bool notitle = true;
596 bool dochi2 = false;
597 bool normref = false;
598 bool scalepix = false;
599 bool oldrms = false;
600 bool addchains = false;
601 bool usechainref = false;
603
604 bool RANGEMAP = false;
605 bool ALLRANGEMAP = false;
606
607 double xerror = 0;
608
609 std::string atlaslabel_tmp = "Internal";
610
611
612 double scale_eff = -1;
613 double scale_eff_ref = -1;
614
615 std::string configfile = "";
616
617 double xoffset = 0;
618
619
620 double ypos_arg = 0;
621
623 std::string
regex =
"";
624
625 std::string patternr = "";
626 std::string regexr = "";
627
628 std::string patternt = "";
629 std::string regext = "";
630
631 std::string basedir = "";
632
633 std::string xpattern = "";
634 std::string xregex = "";
635
636 std::vector<std::string>
chains;
637 std::vector<std::string> refchains;
638
639 bool addingrefchains = false;
640
641 std::string mapfile = "";
642
643 std::vector<std::string> chainfiles;
644
645 int ncols = 2;
646
647 for(
int i=1;
i<
argc;
i++){
649
650
651 if (
arg.find(
'-')!=0 && addinglabels ) {
655 usrlabels.push_back(
label );
656 continue;
657 }
658 else addinglabels = false;
659
660 if (
arg.find(
'-')!=0 && addingrefchains ) {
661 refchains.push_back( arg );
662 continue;
663 }
664 else addingrefchains = false;
665
666 if (
arg.find(
'-')!=0 && addingtags ) {
667 taglabels.push_back(
fullreplace( arg,
"__",
" " ) );
668 std::cout << "\tadding tag label: " << taglabels.back() << std::endl;
669 continue;
670 }
671 else addingtags = false;
672
673 if ( arg=="-h" || arg=="--help" ) {
674 return usage(argv[0], 0);
675 }
676 else if ( arg=="-c" || arg=="--config" ) {
677 if ( ++i<argc ) configfile=
argv[
i];
678 else return usage(argv[0], -1,
"no config file provided");
679 }
680 else if ( arg=="-t" || arg=="--tag" ) {
681 if ( ++i<argc )
tag=std::string(
"-")+
argv[
i];
682 else return usage(argv[0], -1,
"no tag provided");
683 }
684 else if ( arg=="-l" || arg=="--labels" ) {
685 addinglabels = true;
686 }
687 else if ( arg=="-el" ) {
689 }
690 else if ( arg=="-k" || arg=="--key" ) {
692 else return usage(argv[0], -1,
"no key provided");
693 }
694 else if ( arg=="-m" || arg=="--mapfile" ) {
695 if ( ++i<argc ) mapfile=
argv[
i];
696 else return usage(argv[0], -1,
"no mapfile provided");
697 }
698 else if ( arg=="-d" || arg=="--dir" ) {
700 else return usage(argv[0], -1,
"no directory provided");
701 }
702 else if ( arg=="-b" || arg=="--bdir" ) {
703 if ( ++i<argc ) basedir=
argv[
i];
704 else return usage(argv[0], -1,
"no directory provided");
705 }
706 else if ( arg=="--taglabels" ) {
707 addingtags = true;
708 }
709 else if ( arg=="--unscalepix" ) {
710 scalepix = false;
711 }
712 else if ( arg=="--scalepix" ) {
713 scalepix = true;
714 }
715 else if ( arg=="-ac" || arg=="--addchains" ) {
716 addchains = true;
717 }
718 else if ( arg=="-yrange" ) {
719 effset = true;
720 if ( ++i<argc ) effmin=std::atof(argv[i]);
721 else return usage(argv[0], -1,
"no range specified");
722 if ( ++i<argc ) effmax=std::atof(argv[i]);
723 else return usage(argv[0], -1,
"no upper y limit specified");
724 }
725 else if ( arg=="-e" || arg=="--efficiencies" ) {
726 make_ref_efficiencies = true;
727 }
728 else if ( arg=="-r" || arg=="--refit" ) {
729 refit_resplots = true;
730 }
731 else if ( arg=="-rr" || arg=="--refitref" ) {
732 refitref_resplots = true;
733 }
734 else if ( arg=="--oldrms" ) {
735 oldrms = true;
736 }
737 else if ( arg=="-nw" || arg=="--nowatermark" ) {
738 nowatermark = true;
740 }
741 else if ( arg=="--chi2" ) {
742 dochi2 = true;
743 }
744 else if ( arg=="-ns" || arg=="--nostats" ) {
745 nostats = true;
746 }
747 else if ( arg=="-nm" || arg=="--nomeans" ) {
748 nomeans = true;
749 }
750 else if ( arg=="-nt" || arg=="--notitle" ) {
751 notitle = true;
752 }
753 else if ( arg=="-nr" || arg=="--noref" ) {
755 noref = true;
756 }
757 else if ( arg=="--normref" ) {
758 normref = true;
759 }
760 else if ( arg=="-rc" || arg=="--refchains" ) {
761 addingrefchains = true;
762 }
763 else if ( arg=="-uc" || arg=="--usechainref" ) {
764 usechainref = true;
765 }
766 else if ( arg=="-nb" || arg=="--nobayes" ) {
767 bayes = false;
768 }
769 else if ( arg=="-es" || arg=="--effscale" ) {
770 if ( ++i<argc ) scale_eff=std::atof(argv[i]);
771 else return usage(argv[0], -1,
"no efficiency scale provided");
772 }
773 else if ( arg=="-er" || arg=="--effscaleref" ) {
774 if ( ++i<argc ) scale_eff_ref=std::atof(argv[i]);
775 else return usage(argv[0], -1,
"no efficiency scale for the reference histograms provided");
776 }
777 else if ( arg=="--ncols" ) {
778 if ( ++i<argc ) ncols=std::atoi(argv[i]);
779 else return usage(argv[0], -1,
"no number of columns provided");
780 }
781 else if ( arg=="-np" || arg=="--noplots" ) {
782 noplots = true;
783 }
784 else if ( arg=="-C" || arg=="--Cfiles" ) {
785 Cfile = true;
786 }
787 else if ( arg=="--deleteref" ) {
788 deleteref = true;
789 }
790 else if ( arg=="--nopng" ) {
791 nopng = true;
792 }
793 else if ( arg=="--nopdf" ) {
794 nopdf = true;
795 }
796 else if ( arg=="-as" || arg=="--atlasstyle" ) {
797 atlasstyle = true;
798 }
799 else if ( arg=="-q" || arg=="--quiet" ) {
801 }
802 else if ( arg=="-al" || arg=="--atlaslabel" ) {
803 if ( ++i<argc ) atlaslabel_tmp=
argv[
i];
804 else return usage(argv[0], -1,
"no label provided");
805 }
806 else if ( arg=="-xo" || arg=="--xoffset" ) {
807 if ( ++i<argc ) xoffset=std::atof(argv[i]);
808 else return usage(argv[0], -1,
"no xoffset provided");
809 }
810 else if ( arg=="-yp" || arg=="--ypos" ) {
811 if ( ++i<argc ) ypos_arg=std::atof(argv[i]);
812 else return usage(argv[0], -1,
"no y position provided");
813 }
814 else if ( arg=="-xe" || arg=="--xerror" ) {
815 if ( ++i<argc ) xerror=std::atof(argv[i]);
816 else return usage(argv[0], -1,
"no x error provided");
817 }
818 else if ( arg=="-s" || arg=="--swap" ) {
820 else return usage(argv[0], -1,
"no patterns provided");
822 else return usage(argv[0], -1,
"no target pattern provided");
823 }
824 else if ( arg=="--swapt" ) {
825 if ( ++i<argc ) patternt=
argv[
i];
826 else return usage(argv[0], -1,
"no patterns provided");
827 if ( ++i<argc ) regext=
argv[
i];
828 else return usage(argv[0], -1,
"no target pattern provided");
829 }
830 else if ( arg=="--swapr" ) {
831 if ( ++i<argc ) patternr=
argv[
i];
832 else return usage(argv[0], -1,
"no patterns provided");
833 if ( ++i<argc ) regexr=
argv[
i];
834 else return usage(argv[0], -1,
"no target pattern provided");
835 }
836 else if ( arg=="-sx" || arg=="--swapaxtitles" ) {
837 if ( ++i<argc ) xregex=
argv[
i];
838 else return usage(argv[0], -1,
"no target pattern provided");
839 if ( ++i<argc ) xpattern=
argv[
i];
840 else return usage(argv[0], -1,
"no patterns provided");
841 }
842 else if (
arg.find(
'-')==0 ) {
843 std::cerr <<
"unknown option: " <<
arg <<
"\n" << std::endl;
844 return usage(argv[0], -4);
845 }
846 else {
847 if ( ftestname==
"" ) ftestname =
arg;
848 else if ( frefname==
"" ) frefname =
arg;
849 else {
850 std::string
file =
"";
851
852 if (
arg.find(
":file:")!=std::string::npos ) {
854 chainfiles.push_back(
file );
856 }
857
859
861
865
866 std::cout <<
"file: " <<
file <<
"\tchain: " <<
chain << std::endl;
867
868 }
869 }
870 }
871
872 if ( ftestname.empty() ) {
873 std::cerr << "main(): test file not specified " << std::endl;
874 return -1;
875 }
876
877 if ( !
exists(ftestname) ) {
878 std::cerr << "main(): test file " << ftestname << " does not exist" << std::endl;
879 return -1;
880 }
881
882 std::vector<TFile*> chainTFiles;
883
884
885
886 if ( chainfiles.size()==0 ) ftest_ = TFile::Open( ftestname.c_str() );
887 else {
888 noref=true;
889 chainTFiles.resize(chainfiles.size());
890 for (
size_t i=0 ;
i<chainfiles.size() ;
i++ ) {
891 chainTFiles[
i] = TFile::Open( chainfiles[i].c_str() );
892 if ( chainTFiles[i] == 0 ) {
893 std::cerr <<
"\tfile: " << chainfiles[
i] <<
" could not be opened" << std::endl;
894 return -1;
895 }
896 else std::cout <<
"\tchainfiles: " << chainfiles[
i] <<
" " << chainTFiles[
i] << std::endl;
897 }
898 }
899
900
901 if ( noref==false ) {
902 if ( frefname.empty() ) {
903 std::cerr << "main(): ref file not specified " << std::endl;
905 noref = true;
910
911 }
912
913 if ( frefname==ftestname ) fref_ = ftest_;
914 else if (
exists(frefname) ) fref_ = TFile::Open( frefname.c_str() );
915 else {
916 std::cerr << "main(): ref file " << frefname << " does not exist" << std::endl;
917
919 noref=true;
920 }
921 }
922 else fref_ = ftest_;
923
924 if ( chainfiles.size()==0 ) {
925 if ( ftest_==0 ) {
926 std::cerr << "could not open test file " << ftestname << std::endl;
927 return -1;
928 }
929
930 if ( noref==false && fref_==0 ) {
931 std::cerr << "could not open files " << std::endl;
935 noref=true;
936 fref_=ftest_;
937 defreflabel = "failed to open reference file";
938 }
939
940 }
941
942 if ( scale_eff == -1 ) scale_eff = 100;
943 if ( scale_eff_ref == -1 ) scale_eff_ref = scale_eff;
944
945
946 bool noreftmp = noref;
947
948 if (
chains.size()==0 )
return usage(argv[0], -1,
"no chains specified");
949
950
951 if ( basedir.size()>0 ) {
952 if ( basedir[basedir.size()-1]!='/' ) basedir += "/";
954 }
955
956 if ( refchains.size()>0 && refchains.size()!=
chains.size() )
return usage(argv[0], -1,
"not enough chains specified");
957
958 if ( refchains.size()==0 ) refchains =
chains;
959
960 std::vector<std::string> chainref(
chains.size(),
"");
961 std::vector<std::string> chain_name(
chains.size(),
"");
962
963 std::vector<std::string> refchain(chainref.size(),"");
964
965
966
967 std::cout <<
argv[0] <<
" options:" << std::endl;
968 std::cout << "\tATLAS style: " << ( atlasstyle ? "true" : "false" ) << std::endl;
969 std::cout << "\tBayesian uncertainties: " << ( bayes ? "true" : "false" ) << std::endl;
970 std::cout << "\trefit resplot uncertainties: " << ( refit_resplots ? "true" : "false" ) << std::endl;
971 std::cout << "\tsuppress mean and rms stats: " << ( nostats ? "true" : "false" ) << std::endl;
972 if ( !nostats ) std::cout << "\tsuppress meanstats: " << ( nomeans ? "true" : "false" ) << std::endl;
973 std::cout << "\tsuppress png output: " << ( nopng ? "true" : "false" ) << std::endl;
974 std::cout << "\tsuppress pdf output: " << ( nopdf ? "true" : "false" ) << std::endl;
975 std::cout << "\tsuppress reference output: " << ( noref ? "true" : "false" ) << std::endl;
976 std::cout << "\tuse chain references: " << ( usechainref ? "true" : "false" ) << std::endl;
977 std::cout << "\tpanel ncols: " << ncols << std::endl;
978
979 if ( usrlabels.size()>0 ) std::cout << "\tlabels: " << usrlabels.size() << std::endl;
980 if ( taglabels.size()>0 ) std::cout << "\textra text: " << taglabels << std::endl;
981
982
983 for (
size_t il=0 ;
il<usrlabels.size() ;
il++ ) {
984 std::cout <<
"usr label[" <<
il <<
"] : " << usrlabels[
il] << std::endl;
985 }
986
987 std::cout << "atlas style : " << atlasstyle << std::endl;
988
989 if ( atlasstyle ) {
992 gStyle->cd();
993 }
994 else {
995 gROOT->SetStyle("Plain");
996 gStyle->cd();
997 gStyle->SetLineScalePS(1);
998 xoffset += 0.02;
999 }
1000
1001 gStyle->SetErrorX(xerror);
1002
1003 gStyle->SetPadLeftMargin(0.15);
1004 gStyle->SetPadBottomMargin(0.15);
1005
1006 gStyle->SetPadRightMargin(0.02);
1007 gStyle->SetPadTopMargin(0.05);
1008
1009 std::cout << "Chains: " << std::endl;
1010 for (
unsigned ic=0 ;
ic<
chains.size() ;
ic++ ) std::cout <<
"\t" << chains[ic] << std::endl;
1011
1012 if ( usrlabels.size()>0 ) std::cout << "labels: " << usrlabels << std::endl;
1013
1014 if ( usrlabels.size()>0 && usrlabels.size()==
chains.size() ) uselabels =
true;
1015
1017
1018 TTree* dataTree = 0;
1019 TString* releaseData = new TString("");
1020 std::vector<std::string> release_data;
1021
1022 if ( !nowatermark && ftest_ ) {
1023
1024 dataTree = (TTree*)ftest_->Get("dataTree");
1025
1026 if ( dataTree ) {
1027 dataTree->SetBranchAddress( "ReleaseMetaData", &releaseData);
1028
1029 for (
unsigned int i=0;
i<dataTree->GetEntries() ;
i++ ) {
1030 dataTree->GetEntry(i);
1031 release_data.push_back( releaseData->Data() );
1032 std::cout << "main() release data: " << release_data.back() << " : " << *releaseData << std::endl;
1033 }
1034 }
1035
1036
1037 if ( release_data.size()>0 ) {
1038 if ( release_data.size()>1 ) std::cerr << "main() more than one release - using only the first" << std::endl;
1039
1040
1041
1042 std::string
nightly =
chop(release_data[0],
" " );
1043
1044 if (
contains(nightly,
"private" ) ) {
1045 for (
int ic=0 ;
ic<4 ;
ic++ )
chop(release_data[0],
" " );
1046 release +=
" (" + release_data[0]+
")";
1047 }
1048 else {
1050 chop( release_data[0],
" " );
1051 release +=
" " +
chop(release_data[0],
" " ) +
")";
1052 }
1053 }
1054 }
1055
1056
1057
1059
1061
1062 std::cout << "trying to make directory" << std::endl;
1065 if (
mkdir(
dir.c_str(), 0777 ) ) std::cerr <<
"main() couldn't create directory " <<
dir << std::endl;
1066 else std::cout <<
"main() output will be sent to directory " <<
dir << std::endl;
1067 }
1068 }
1069
1070 if ( ftest_==0 && chainTFiles.size()>0 ) fref_ = ftest_ = chainTFiles[0];
1071
1072 TFile* ftest = ftest_;
1073 TFile* fref = fref_;
1074
1076
1077 std::string rawrefrun = "";
1078 std::string refrun = "";
1079
1080 if ( fref_ ) refrun = rawrefrun =
findrun( fref );
1081
1082 std::cout <<
"testrun: " <<
testrun <<
"\nrefrun: " << refrun << std::endl;
1083
1084 if ( !
testrun.empty() && refrun != testrun ) {
1088 }
1089
1090 }
1091
1092 if ( !refrun.empty() ) {
1093
1094 std::string newtag = "Reference: ";
1095
1096 std::cout << "refrun: " << refrun << std::endl;
1097
1099 while ( (pos=refrun.find('_'))!=std::string::npos ) refrun.replace( pos, 1, " " );
1100 newtag += refrun;
1101
1102 std::string rawrun = refrun.erase( refrun.find("run"), 4 );
1103
1104 if (
contains(frefname, rawrun) ) {
1105
1106 std::string
release = frefname;
1107
1109
1115
1116 newtag += " ";
1118
1119 }
1120
1121 taglabels.push_back( newtag );
1122
1123 std::cout << "tag labels: " << taglabels << std::endl;
1124
1125 }
1126
1131 int NeventTest = 1;
1132 int NeventRef = 1;
1133
1134
1136
1137
1138 if ( !nowatermark ) {
1139
1140 TH1D* htestev = (TH1D*)ftest->Get("event") ;
1141 TH1D* hrefev = (TH1D*)fref->Get("event") ;
1142
1143 std::cout << "htestev " << htestev << " " << hrefev << std::endl;
1144
1145 if ( htestev ) NeventTest = htestev->GetEntries();
1146 if ( hrefev ) NeventRef = hrefev->GetEntries();
1147
1149 }
1150 else {
1151 NeventTest = 1;
1152 NeventRef = 1;
1153 }
1154
1155
1156 if ( NeventTest>1 ) std::cout << "Nevents Test: " << NeventTest << std::endl;
1157 if ( NeventRef>1 ) std::cout << "Nevents Ref: " << NeventRef << std::endl;
1158
1160
1161 if ( mapfile.empty() ) mapfile = configfile;
1162
1163 if ( !mapfile.empty() ) {
1164
1166
1167 if (
m.isTagDefined(
"ChainMap" ) ) {
1168 std::vector<std::string>
chains =
m.GetStringVector(
"ChainMap" );
1169
1171
1172 for (
size_t i=0 ;
i<
chains.size() ;
i+=2 ) {
1173 chainmap->insert( chainmap_t::value_type( chains[i], chains[i+1] ) );
1174 }
1175
1176 std::cout << "\nusing chain map:" << std::endl;
1177
1178 for ( chainmap_t::iterator itr=chainmap->begin() ; itr!=chainmap->end() ; ++itr ) {
1179 std::cout << "\t" << itr->first << "\t" << itr->second << std::endl;
1180 }
1181 }
1182 }
1183
1185
1186 std::cout << "\ncreating chain and reference information ..." << std::endl;
1187
1188 for (
size_t j=0; j<
chains.size(); j++) {
1189
1192
1194
1196 std::cout <<
"chain: " <<
chains[j] <<
"\taddchains: " << addchains << std::endl;
1197
1198 if ( addchains && (
contains(chains[j],
"Shifter") || ( !
contains(chains[j],
"HLT_") && !
contains(chains[j],
"Fullscan" ) ) ) ) {
1199
1200 TFile* fftest = ftest;
1201
1202 if ( chainfiles.size()>0 && chainfiles.size()>j ) fftest = chainTFiles[j];
1203
1204 TH1F* hchain =
Get( *fftest, chains[j]+
"/Chain", testrun );
1205
1206 if ( hchain ) {
1207
1208 std::string
name = hchain->GetTitle();
1209
1210 if ( usechainref && !
contains(chains[j],
"Purity") ) {
1211
1213
1214 std::cout << "new chainref: " << chainref[j] << std::endl;
1215
1216 std::string::size_type
pos = chainref[j].find(
":for");
1217 if ( pos!=std::string::npos ) chainref[j].replace( pos, 4, "_for" );
1218 std::replace( chainref[j].
begin(), chainref[j].
end(),
':',
'/');
1219 std::string newchain =
dirname(
dirname( chains[j]) ) +
"/Expert/" + chainref[j];
1220 chainref[j] = newchain;
1221
1222 std::cout << "final chainref: " << chainref[j] << std::endl;
1223
1224 }
1225
1226 std::cout << "chainref: " << chainref[j] << std::endl;
1227
1229
1230 std::cout <<
"name: " <<
name << std::endl;
1231
1232 if (
contains( name,
":" ) ) chain_name[j] =
name.substr( 0,
name.find(
':') ) +
" : ";
1233 else chain_name[j] =
name;
1234
1235 if ( chain_name[j] == " : " ) chain_name[j] = "";
1236
1237 std::cout << "chain_name: " << chain_name[j] << std::endl;
1238 }
1239 }
1240 }
1241
1242 std::cout << "chainref size: " << chainref.size() << " " << refchains.size() << std::endl;
1243
1244 for ( size_t j=0 ; j<chainref.size() ; j++ ) {
1245 std::cout << "chainref: " << chainref[j] << " :: " << refchains[j] << std::endl;
1246
1248 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], pattern, regex );
1249 else refchain[j] =
fullreplace( refchains[j], pattern, regex );
1250
1251 if ( !patternr.empty() ) {
1252 if ( chainref[j]!=
"" ) refchain[j] =
fullreplace( chainref[j], patternr, regexr );
1253 else refchain[j] =
fullreplace( refchains[j], patternr, regexr );
1254 }
1255
1256 std::cout << "refchain: " << refchain[j] << std::endl;
1257 }
1258
1259 std::cout << "done chains" << std::endl;
1260
1262
1263 std::vector<Panel> panels;
1264
1266
1268
1269
1270 std::vector<int> ccolours;
1271 std::vector<int> cstyles;
1272
1273 std::vector<std::string> ctags;
1274 std::vector<std::string> ctaglabels;
1275
1276
1277 std::cout <<
"\n" <<
argv[0] <<
"\tconfigfile: " << configfile << std::endl;
1278
1279 bool use_file_config = false;
1280
1281 if ( configfile!="" ) {
1282
1283 if (
exists(configfile) ) {
1284
1285 std::cout <<
argv[0] <<
":\treading configuration file " << configfile << std::endl;
1286
1288
1289
1291
1292 if (
rc.isTagDefined(
"histos" ) ) {
1293
1294 std::cout <<
argv[0] <<
":\treading histogram configuration from file " << configfile << std::endl;
1295
1296 use_file_config = true;
1297
1298 std::vector<std::string> raw_input =
rc.GetStringVector(
"histos" );
1299
1300 for ( size_t iraw=0 ; iraw<raw_input.size() ; iraw += 6) {
1304 panels.push_back( p );
1305 }
1306
1307 }
1308
1309 std::cout << "searching for panels" << std::endl;
1310
1312
1313 if (
rc.isTagDefined(
"panels" ) ) {
1314
1315 std::cout <<
argv[0] <<
":\treading histogram panel configuration from file " << configfile << std::endl;
1316
1317 use_file_config = true;
1318
1319 std::vector<std::string> panel_config =
rc.GetStringVector(
"panels" );
1320
1321 std::vector<string> panel_columns;
1322
1323 if (
rc.isTagDefined(
"panel_columns") ) {
1324 panel_columns =
rc.GetStringVector(
"panel_columns" );
1325 if ( panel_columns.size()%2 )
return usage( argv[0], -1,
"incorrect panel settings" );
1326 }
1327
1328
1329 for ( size_t ipanel=panel_config.size() ; ipanel-- ; ) {
1330
1331 std::vector<std::string> raw_input =
rc.GetStringVector( panel_config[ipanel] );
1332
1333 int tncols = ncols;
1334
1335 if ( panel_columns.size() ) {
1336 std::vector<string>::iterator itr =
find( panel_columns.begin(), panel_columns.end(), panel_config[ipanel] );
1337 if ( itr!=panel_columns.end() ) tncols = std::atoi( (++itr)->c_str() );
1338 }
1339
1340 Panel p( panel_config[ipanel], tncols );
1341
1342 if ( raw_input.empty() ) {
1343 std::cerr <<
argv[0] <<
":\t panel " << panel_config[ipanel] <<
" is empty";
1344 return -1;
1345 }
1346 for (
size_t iraw=0 ; iraw<raw_input.size() ; iraw += 6 )
p.push_back(
HistDetails( &(raw_input[iraw]) ) );
1347
1348 panels.push_back( p );
1349
1350 }
1351
1352 }
1353
1354 if (
rc.isTagDefined(
"Bands" ) &&
rc.isTagDefined(
"Labels" ) ) {
1355 bnd =
bands(
rc.GetVector(
"Bands"),
rc.GetStringVector(
"Labels" ) );
1356 }
1357
1358
1359 if (
rc.isTagDefined(
"Colours") ) ccolours =
rc.GetIntVector(
"Colours");
1360 if (
rc.isTagDefined(
"Styles") ) cstyles =
rc.GetIntVector(
"Styles");
1361 if (
rc.isTagDefined(
"Tags") ) ctags =
rc.GetStringVector(
"Tags");
1362 if (
rc.isTagDefined(
"TagLabels") ) ctaglabels =
rc.GetStringVector(
"TagLabels");
1363 if (
rc.isTagDefined(
"TagLabels") ) usrlabels =
rc.GetStringVector(
"TagLabels");
1364
1365 if (
rc.isTagDefined(
"Styles") ) {
1366 for ( size_t is=0 ; is<cstyles.size() && is<6 ; is++ ) {
1368 }
1369 }
1370
1371
1372 uselabels = true;
1373
1374
1375 std::cout <<
argv[0] <<
"\tuserlabels :" << usrlabels <<
":" << std::endl;
1376
1377
1378
1379 if (
rc.isTagDefined(
"RANGEMAP") ) RANGEMAP =
true;
1380 if (
rc.isTagDefined(
"ALLRANGEMAP") ) ALLRANGEMAP =
true;
1381
1382 std::cout <<
"Extra: " <<
rc.isTagDefined(
"Extra") << std::endl;
1383
1384 if (
rc.isTagDefined(
"Extra") ) taglabels.push_back(
fullreplace(
rc.GetString(
"Extra"),
"__",
" " ) );
1385
1386
1387 }
1388 else {
1389 std::cerr <<
argv[0] <<
":\t config file not found: " << configfile << std::endl;
1390 return -1;
1391 }
1392
1393 }
1394
1395 if ( !use_file_config ) {
1396
1397 std::cout << "using default panels" << std::endl;
1398
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410 scale_eff = 100;
1411 scale_eff_ref = 100;
1412
1414
1416
1417 size_t nphist[3] = { 4, 4, 10 };
1418
1419 std::string pnames[3] = { "eff", "res", "diff" };
1420
1421 for (
size_t ip=0 ;
ip<3 ;
ip++ ) {
1422 Panel p( pnames[ip]+
"_panel", 2 );
1423 for (
size_t iraw=0 ; iraw<nphist[
ip] ; iraw++ )
p.push_back(
HistDetails( inpanels[ip][iraw] ) );
1424 panels.push_back( p );
1425 }
1426
1427 }
1428
1429
1430 std::cout << "taglabels" << std::endl;
1431
1432 for (
size_t it=0 ;
it<taglabels.size() ;
it++ ) std::cout << taglabels[it] << std::endl;
1433
1434
1435 std::cout << "\npanels: " << panels.size() << std::endl;
1436
1437 if ( panels.size()==0 )
return usage(argv[0], -1,
"no panels to plot");
1438
1439 for (
size_t ip=0 ;
ip<panels.size() ;
ip++ ) std::cout << panels[ip] << std::endl;
1440
1441
1443 if ( true ) {
1444 gStyle->SetPadRightMargin(0.05);
1445 gStyle->SetPadTopMargin(0.05);
1446
1447 const Int_t Number = 3;
1448 Double_t
Red[Number] = { 0.00, 0.00, 1.00};
1449 Double_t
Green[Number] = { 0.00, 5.00, 1.00};
1450 Double_t Blue[Number] = { 0.00, 0.50, 0.00};
1451 Double_t Length[Number] = { 0.00, 0.50, 1.00 };
1453 TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);
1454 }
1455 else gStyle->SetPalette(1);
1456
1457 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1458
1459 double rightmargin = gStyle->GetPadRightMargin();
1460 gStyle->SetPadRightMargin(0.1);
1461
1463
1464 gStyle->SetPadRightMargin(rightmargin);
1465
1466
1467
1468 for ( size_t ipanel=0 ; ipanel<panels.size() ; ipanel++ ) {
1469
1470 Panel& panel = panels[ipanel];
1471
1472 std::cout << "\n\n---------------------------------------------\n";
1473
1474 std::cout << panel << "\n" << std::endl;
1475
1476 int ncolsp = panel.
ncols();
1477 int nrowsp = panel.
nrows();
1478
1479 double extraw = 1;
1480
1481 std::cout << "\nncols: " << ncolsp << "\tnrows: " << nrowsp << std::endl;
1482
1483 bool multipanel = ( panel.
size() > 1 );
1484
1485 if ( panel.
size()==0 ) {
1486 std::cout <<
"panel empty: " << panel.
name() << std::endl;
1487 continue;
1488 }
1489
1490 gStyle->cd();
1491
1492 if ( panel.
size()>4 ) gStyle->SetLineScalePS(0.5);
1493
1494 if ( multipanel ) extraw = 1.05;
1495
1496 TCanvas*
tc =
new TCanvas(
"tc",
"", extraw*ncolsp*800, nrowsp*600 );
1497
1499
1500 const std::string& atlaslabel = atlaslabel_tmp;
1501
1502
1503 if ( multipanel ) {
1504
1505 gStyle->SetLineScalePS(1);
1506
1509
1517
1520
1521 tc->Divide( ncolsp, nrowsp, 0.0001, 0.0003 );
1522
1523 }
1524
1526
1527 std::string plotname = "";
1528
1529 for (
size_t i=0 ;
i<panel.
size() ;
i++ ) {
1530
1532
1533 bool drawmeans = false;
1534 bool drawresiduals = true;
1535
1537 if (
contains(
histo.detail(),
"-residual") ) drawresiduals =
false;
1538
1539 std::string xaxis =
histo.xtitle();
1540 std::string yaxis =
histo.ytitle();
1541
1542 if ( !xregex.empty() ) {
1543 size_t pos = xaxis.find(xregex);
1544 if ( pos!=std::string::npos ) xaxis.replace( pos, xregex.size(), xpattern );
1545 pos = yaxis.find(xregex);
1546 if ( pos!=std::string::npos ) yaxis.replace( pos, xregex.size(), xpattern );
1547 }
1548
1551
1554
1556 bool d0rebin_flag = false;
1557
1559
1562 }
1563
1566 }
1567
1568
1569 int npanel = nrowsp*(
i/nrowsp) + i%nrowsp + 1 ;
1570
1571 std::cout <<
"panel: panel: " << panel.
name() <<
"\tsubpanel: " << npanel << std::endl;
1572
1573 if ( multipanel )
tc->cd( npanel );
1574
1576
1577 noreftmp = noref;
1578
1580
1581 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1582
1583 std::cout <<
"main() processing histo[" <<
i <<
"] " << (
i<10 ?
" " :
"" ) <<
histo.name() <<
"\t" <<
histo.xaxis() << std::endl;
1584
1586 plots_eff.clear();
1587
1590
1591 std::string noreflabel=defreflabel;
1592
1593 double xpos = 0.18;
1594 double ypos = 0.91;
1595
1597
1598
1599
1602
1603 if ( atlasstyle ) {
1604 xpos = 0.18;
1605 if ( ypos>0.5 ) ypos = 0.85;
1606 else ypos = 0.18;
1607 }
1608
1609 if ( ypos_arg!=0 ) ypos = ypos_arg;
1610
1611 double xpos_original = xpos;
1612
1613 xpos += xoffset;
1614
1615 if ( xinfo.
offset() != 0 ) {
1616
1617 std::cout <<
"HA ! xinfo.offset: " << xinfo.
offset() << std::endl;
1618
1620
1621 }
1622
1623
1624 if ( yinfo.
offset() != 0 ) {
1625
1626 std::cout <<
"HA ! yinfo.offset: " << yinfo.
offset() << std::endl;
1627
1629
1630 }
1631
1632
1633
1635
1636 size_t Nrows =
chains.size();
1637
1638 if ( ALLRANGEMAP || (RANGEMAP && xaxis.find("p_{T}")!=std::string::npos && ccolours.size() ) )
1639 Nrows = ( Nrows < ccolours.size() ? Nrows : ccolours.size() );
1640
1641 int Nlines = Nrows + taglabels.size();
1642
1643 std::vector<double> ypositions;
1644
1645 double deltay = (Nrows*0.055-0.005)/Nrows;
1646
1648 double yhi = ypos-0.01;
1649
1650 if ( ypos>0.5 )
ylo -= Nlines*deltay;
1651 else yhi += Nlines*deltay;
1652
1653 ypositions.reserve(Nlines);
1654 for ( int ilines=0 ; ilines<Nlines ; ilines++ ) {
1655 ypositions.push_back( yhi - deltay*(ilines+0.5) );
1656 }
1657
1658
1659
1661
1662
1664
1665 Legend legend( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
1666 Legend legend_eff( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
1667
1668
1669 std::vector<std::string>
Mean;
1670 std::vector<std::string>
RMS;
1671
1674
1675 std::vector<std::string> Chi2;
1676 std::vector<std::string> MeanRef;
1677 std::vector<std::string> RMSRef;
1678
1679
1680
1681 Chi2.clear();
1682 MeanRef.clear();
1683 RMSRef.clear();
1684
1685 int mean_power = 0;
1686 int rms_power = 0;
1687 bool power_set = false;
1688
1690
1692
1693
1694
1695 for (
unsigned int j=0; j<
chains.size(); j++) {
1696
1697 TFile* fftest = ftest;
1698 TFile* ffref = fref;
1699
1700 if ( chainfiles.size()>0 && chainfiles.size()>j ) ffref = fftest = chainTFiles[j];
1701
1704
1705 std::cout <<
"chain: " <<
chains[j] <<
"\taddchains: " << addchains << std::endl;
1706 std::cout << "chainref: " << chainref[j] << std::endl;
1707
1708 noreftmp = noref;
1710
1713
1717
1718 TGraphAsymmErrors* tgtest = 0;
1719
1720 std::cout << "refchain.size() " << refchain.size() << std::endl;
1721
1722 std::cout << "refchain: " << refchain[j] << std::endl;
1723
1725
1726 gPad->SetRightMargin(0.03);
1727
1729
1730 gPad->SetRightMargin(0.13);
1731
1733
1735
1736 h2test->GetYaxis()->SetTitleOffset(1.55);
1737 h2test->GetXaxis()->SetTitleOffset(1.5);
1738 h2test->GetXaxis()->SetTitle(xaxis.c_str());
1739 h2test->GetYaxis()->SetTitle(yaxis.c_str());
1740
1743
1744
1745 std::cout << xinfo << std::endl;
1746 std::cout << yinfo << std::endl;
1747
1749 h2test->GetYaxis()->SetRangeUser( yinfo.
lo(), yinfo.
hi() );
1750 }
1751
1753
1755 h2test->GetXaxis()->SetRangeUser( xinfo.
lo(), xinfo.
hi() );
1756 }
1757
1760
1762
1763 h2test->DrawCopy("colz");
1764
1765 if (
histo.detail().find(
"logz")!=std::string::npos ) gPad->SetLogz(
true);
1766 else gPad->SetLogz(false);
1767
1768
1769 }
1771
1772 bool bsigma = false;
1774
1775 bool bmean = false;
1777
1778 std::cout <<
"\trefitting: " <<
histo.name() << std::endl;
1779
1782
1783 std::string tmp_ =
histo.name();
1785
1786 if ( bsigma )
base =
chop( tmp_,
"/sigma" );
1787 if ( bmean )
base =
chop( tmp_,
"/mean" );
1788
1790
1791 std::cout << "ffref " << ffref << std::endl;
1792 TH2D* href2d_ = 0;
1793
1794 if ( ffref ) href2d_ =
Get<TH2D>( *ffref, chains[j]+
"/"+
base+
"/2d", testrun );
1795
1796 if ( htest2d_==0 ) continue;
1797 if ( !noreftmp && href2d_==0 ) noreftmp = true;
1799
1801
1802 Resplot rtest(
"tmp", htest2d_ );
1803
1804 if ( rtest.finalised() ) {
1807 }
1808 else {
1811 }
1812
1813 if ( bsigma ) {
htest = (
TH1F*)rtest.Sigma()->Clone(
"rtest_sigma");
htest->SetDirectory(0); }
1814 if ( bmean ) {
htest = (
TH1F*)rtest.Mean()->Clone(
"rtest_mean");
htest->SetDirectory(0); }
1815
1816 if ( htest==0 ) {
1817 std::cerr <<
"missing test histogram: " << (refchain[j]+
" / "+
histo.name()) <<
" " <<
htest <<
"(test)" << std::endl;
1818 continue;
1819 }
1820
1821
1824
1826
1827 if ( !noreftmp ) {
1828 if ( refitref_resplots ) {
1829
1830 Resplot rref(
"tmp", href2d_ );
1831
1832 if ( rref.finalised() ) {
1835 }
1836 else {
1839 }
1840
1841 if ( bsigma ) { hreft = (
TH1F*)rref.Sigma()->Clone(
"rref_sigma"); hreft->SetDirectory(0); }
1842 if ( bmean ) { hreft = (
TH1F*)rref.Mean()->Clone(
"rref_mean"); hreft->SetDirectory(0); }
1843
1844 }
1845 else {
1846 hreft =
Get( *ffref, refchain[j]+
"/"+
histo.name(), rawrefrun, chainmap );
1847 if ( hreft==0 ) {
1848 std::cerr <<
"ERROR: could not find " << (refchain[j]+
"/"+
histo.name()) << std::endl;
1849 }
1850 }
1851 }
1852
1853 if ( !noreftmp && hreft==0 ) {
1854 std::cerr <<
"missing ref histogram: " << (refchain[j]+
" / "+
histo.name()) <<
" " <<
htest <<
"(ref)" << std::endl;
1855
1856 noreftmp = true;
1858 noreflabel="reference not found";
1861
1862 }
1863
1864 if ( !noreftmp ) {
1866 href->SetDirectory(0);
1867 }
1868
1870
1871
1873
1874 }
1875 else {
1876
1877 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1878
1880
1881 std::string reghist =
histo.name();
1882
1883 std::cout <<
"hist: " << (
chains[j]+
"/"+reghist) <<
"\tftest " << ftest << std::endl;
1884
1886
1887 std::cout <<
"hist: " <<
htest << std::endl;
1888
1889 std::cout << xaxis << std::endl;
1890
1891 if ( htest==0 ) {
1892 std::cerr <<
"missing test histogram: " << (
chains[j]+
" / "+reghist) <<
" " << htest<< std::endl;
1893 continue;
1894 }
1895
1897
1898 std::cout << "hreft: " << hreft << std::endl;
1899
1900 if ( ffref ) hreft =
Get( *ffref, refchain[j]+
"/"+reghist, rawrefrun, chainmap );
1901 else noreftmp = true;
1902
1903 std::cout << "hreft: " << hreft << std::endl;
1904
1905 if ( std::string(
htest->ClassName()).find(
"TH2")!=std::string::npos ) {
1906 std::cout <<
"Class TH2: " <<
htest->GetName() << std::endl;
1907 continue;
1908 }
1909
1910 if ( std::string(
htest->ClassName()).find(
"TH1")!=std::string::npos ) {
1911 std::cout <<
"Class TH1: " <<
htest->GetName() << std::endl;
1912 }
1913 else if ( std::string(
htest->ClassName()).find(
"TProfile")!=std::string::npos ) {
1914 std::cout <<
"Class TProf: " <<
htest->GetName() << std::endl;
1915 }
1916
1917
1918
1919 if ( !noreftmp && hreft==0 ) {
1920 std::cerr << "missing ref histogram: " << (refchain[j]+" / "+reghist)
1921 << " " << hreft << std::endl;
1922 noreftmp = true;
1924 noreflabel="reference not found";
1927
1928
1929 }
1930
1931 if ( hreft!=0 ) {
1933 href->SetDirectory(0);
1934 }
1935 else {
1936 noreftmp = true;
1938 }
1939
1940 std::cout <<
" \tget " << (
chains[j]+
"/"+reghist) <<
"\thtest " << htest << std::endl;
1941 std::cout << " \tget " << (refchain[j]+"/"+reghist) << "\thref " << href << std::endl;
1942
1943 if ( htest==0 ) continue;
1944
1945 if ( !noreftmp && href==0 ) {
1946 noreftmp = true;
1948 }
1949
1950 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1951
1952
1953 if ( rebin!=1 ) {
1954 std::cout <<
"rebin: " <<
hname <<
"\t" <<
rebin << std::endl;
1955 if ( htest )
htest->Rebin(rebin);
1956 if ( href )
href->Rebin(rebin);
1957 for (
int ip=0 ;
ip<10 ;
ip++ ) std::cout << std::endl;
1958 }
1959
1960#if 0
1963 std::cout <<
"Rebinning histogram: " <<
histo.name() << std::endl;
1964 if (
htest->GetNbinsX()>500 )
htest->Rebin(10);
1965 if ( href &&
href->GetNbinsX()>500 )
href->Rebin(10);
1966 }
1967#endif
1968
1969
1970 if (
histo.name().find(
"zed_eff")!=std::string::npos ) {
1971 if (
htest->GetNbinsX()>100 )
htest->Rebin(5);
1972 if ( href &&
href->GetNbinsX()>100 )
href->Rebin(5);
1973 }
1974
1975
1976 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1977
1978 if ( scalepix && std::string(
htest->GetName()).find(
"npix")!=std::string::npos )
Scale(htest,0.5);
1979 if ( scalepix && href && std::string(
htest->GetName()).find(
"npix")!=std::string::npos )
Scale(href,0.5);
1980
1981 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1982
1983 if ( notitle ) {
1984 htest->SetTitle(
"");
1985 if( href )
href->SetTitle(
"");
1986 }
1987
1988 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1989
1990 }
1991
1992 if (
fulldbg ) std::cout << __LINE__ << std::endl;
1993
1994 if ( make_ref_efficiencies ) {
1995 if ( htest && href ) {
1996
1998
1999
2001
2002 std::string effhist =
histo.name();
2003
2004 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos );
2005
2006 TH1F* hrefnumt =
Get( *ffref, refchain[j]+
"/"+effhist+
"_n", rawrefrun, chainmap, &
savedhistos );
2007
2008 if ( !noreftmp && hrefnumt!=0 ) {
2009 hrefnum = (
TH1F*)hrefnumt->Clone();
2010 hrefnum->SetDirectory(0);
2011 }
2012
2013 }
2014 }
2015 }
2016
2017
2018 if ( bayes ) {
2019
2020 if ( htest &&
contains( std::string(
htest->GetName()),
"eff" ) ) {
2021
2022 std::string effhist =
histo.name();
2023
2025
2026 if ( rebin!=1 ) std::cout << effhist <<
"\trebin: " <<
rebin << std::endl;
2027
2028 htestnum =
Get( *fftest, chains[j]+
"/"+effhist+
"_n", testrun, 0, &
savedhistos ) ;
2029 htestden =
Get( *fftest, chains[j]+
"/"+effhist+
"_d", testrun, 0, &
savedhistos ) ;
2030
2031 std::cout << "1: Bayesian error calculation " << htestnum << " " << htestden << "\tscale " << scale_eff << std::endl;
2032
2033 if ( htestnum && htestden ) {
2034
2035 if ( d0rebin_flag ) {
2036 htestnum =
d0rebin( htestnum );
2037 htestden =
d0rebin( htestden );
2038 }
2039 else if ( rebin!=1 ) {
2040 htestnum =
Rebin(htestnum, rebin );
2041 htestden =
Rebin(htestden, rebin );
2042 }
2043
2044 std::cout << "test histogram name: : " << htestnum->GetName() << "\txaxis: " << xaxis << "\t" << std::endl;
2045
2046
2047 if ( std::string(htestnum->GetName()).find("ntrax_eff")!=std::string::npos ) {
2048
2049 bool low = true;
2050
2051
2052
2055 }
2056
2057#if 0
2061 std::cout <<
"rebin " <<
histo.name() << std::endl;
2062 htestnum->Rebin(3);
2063 htestden->Rebin(3);
2064 }
2065
2067 std::cout <<
"rebin " <<
histo.name() << std::endl;
2068 htestnum->Rebin(2);
2069 htestden->Rebin(2);
2070 }
2071#endif
2072
2073
2074 if ( RANGEMAP && (effhist.find("ET")!=std::string::npos ) ) {
2075 std::cout <<
"\trange: " << j <<
" " <<
htest << std::endl;
2076 bnd.
range( chains[j], htestnum );
2077 bnd.
range( chains[j], htestden );
2078 }
2079
2080
2082 tgtest =
e.Bayes(scale_eff);
2083
2085
2086 std::cout << "effhist: " << effhist << std::endl;
2087
2088 }
2089
2091
2092 std::cout << "recalculating reference efficiencies ..." << std::endl;
2093
2094 if ( href ) {
2095
2096 std::cout << "doin ..." << std::endl;
2097
2098 TH1F* hrefnum =
Get( *ffref, refchain[j]+
"/"+
histo.name()+
"_n", rawrefrun, chainmap );
2099
2100 TH1F* hrefden =
Get( *ffref, refchain[j]+
"/"+
histo.name()+
"_d", rawrefrun, chainmap );
2101
2102 std::cout << "2. Bayesian error calculation " << htestnum << " " << htestden << "\tscale " << scale_eff << std::endl;
2103 std::cout << "3. Bayesian error calculation " << hrefnum << " " << hrefden << "\tscale " << scale_eff_ref << std::endl;
2104
2105
2106 if ( hrefnum && hrefden ) {
2107
2108 if ( d0rebin_flag ) {
2111 }
2112 else if ( rebin!=1 ) {
2113 hrefnum =
Rebin(hrefnum, rebin );
2114 hrefden =
Rebin(hrefden, rebin );
2115 }
2116
2119
2120
2122
2123 }
2124 }
2125 }
2126
2127 }
2128
2129
2130 if ( htest==0 ) {
2131 std::cout <<
" no test histogram : " << (
chains[j]+
"/"+
histo.name()) << std::endl;
2132 continue;
2133 }
2134
2135 if ( !noreftmp && href==0 ) {
2136 std::cout <<
" no ref histogram : " << (
chains[j]+
"/"+
histo.name()) << std::endl;
2137 noreftmp = true;
2139 noreflabel="reference not found";
2142
2143 }
2144
2145
2146 htest->GetYaxis()->SetTitleOffset(1.55);
2147 htest->GetXaxis()->SetTitleOffset(1.5);
2148 htest->GetXaxis()->SetTitle(xaxis.c_str());
2149 htest->GetYaxis()->SetTitle(yaxis.c_str());
2150
2151 if ( !noreftmp ) {
2152 href->GetYaxis()->SetTitleOffset(1.5);
2153 href->GetXaxis()->SetTitleOffset(1.5);
2154 href->GetXaxis()->SetTitle(xaxis.c_str());
2155 if (
contains(yaxis,
"Efficiency") && !
contains(yaxis,
"%") && scale_eff==100 )
href->GetYaxis()->SetTitle((yaxis+
" [%]").c_str());
2156 else href->GetYaxis()->SetTitle(yaxis.c_str());
2157 }
2158
2159 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2160
2161#if 1
2163
2164 double xm =
htest->GetMean();
2165
2166 if ( xm>=10 ) {
2167 double lxm = std::log10(xm);
2168 int newbins = int(0.5+xm/std::pow(10,
int(lxm)))*
pow(10,
int(lxm));
2169 int nrebin = int( (newbins+5)/10 );
2170
2171 if ( nrebin>1 ) {
2172 std::cout <<
"rebin: " <<
htest->GetName() <<
"\tbins: " << nrebin << std::endl;
2173 htest->Rebin(nrebin);
2175 if ( !noreftmp ) {
2176 href->Rebin(nrebin);
2178 }
2179 }
2180 }
2181 }
2182#endif
2183
2184 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2185
2187 if ( plotname == "" ) {
2188
2189 if ( key!="" ) {
2190 htest->SetTitle(
"");
2191 if ( href )
href->SetTitle(
"");
2193 }
2195 htest->SetTitle(
"");
2196 if ( href )
href->SetTitle(
"");
2197 plotname = "HLT_";
2198 }
2200 htest->SetTitle(
"");
2201 if ( href )
href->SetTitle(
"");
2202 plotname = "EF_";
2203 }
2205 htest->SetTitle(
"");
2206 if ( href )
href->SetTitle(
"");
2207 plotname = "L2_";
2208 }
2210 htest->SetTitle((
"FTK "+
histo.name()).c_str());
2211 if ( href )
href->SetTitle((
"FTK "+
histo.name()).c_str());
2212 plotname = "FTK_";
2213 }
2214
2215 plotname +=
histo.name();
2216
2220
2221 }
2222
2223
2224 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2225
2227
2229
2230
2231
2232
2233 std::string collection =
basename( chains[j] );
2234
2236
2237 if ( collection.find("_InDet")!=std::string::npos ) collection.erase( 0, collection.find("_InDet")+1 );
2238 if ( actual_chain.find("_InDet")!=std::string::npos ) actual_chain.erase( actual_chain.find("_InDet") );
2239
2240
2241 std::cout <<
"raw: " <<
chains[j] << std::endl;
2242
2243 std::cout << "track collection: " << collection << std::endl;
2244 std::cout << "actual chain: " << actual_chain << std::endl;
2245
2246 std::regex rx("_HLT_[^_]*RoI.*");
2247 std::regex
rx1(
"_HLT_[^_]*_RoI.*");
2248
2249 actual_chain = std::regex_replace( actual_chain, std::regex( "_HLT_IDTrack.*" ), "" );
2250
2251 collection = std::regex_replace( collection, std::regex(".*HLT_IDTrack_"), "IDTrack " );
2252 collection = std::regex_replace( collection, std::regex("IDTrack "), "" );
2253 collection = std::regex_replace( std::regex_replace( collection, rx, "" ), rx1, "" );
2254
2255 if ( actual_chain.find("HLT_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find("HLT_IDTrack_"), 12 );
2256 if ( actual_chain.find("_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find("_IDTrack_"), 9 );
2257 if ( actual_chain.find("IDTrack")!=std::string::npos ) actual_chain.erase( actual_chain.find("IDTrack"), 7 );
2258 if ( actual_chain.find("_idperf")!=std::string::npos ) actual_chain.erase( actual_chain.find("_idperf"), 7 );
2259 if ( actual_chain.find("_bperf")!=std::string::npos ) actual_chain.erase( actual_chain.find("_bperf"), 6 );
2260 if ( actual_chain.find("_boffperf")!=std::string::npos ) actual_chain.erase( actual_chain.find("_boffperf"), 9 );
2261 if ( actual_chain.find("_HLT_")!=std::string::npos ) actual_chain.replace( actual_chain.find("_HLT_"), 5, " " );
2262 if ( actual_chain.find("HLT_")!=std::string::npos ) actual_chain.erase( actual_chain.find("HLT_"), 4 );
2263
2264 if ( collection.find("_IDTrkNoCut")!=std::string::npos ) collection.erase( collection.find("_IDTrkNoCut"), 11 );
2265 if ( collection.find("xAODCnv")!=std::string::npos ) collection.erase( collection.find("xAODCnv"), 7 );
2266 if ( collection.find("HLT_IDTrack_")!=std::string::npos ) collection.erase( collection.find("HLT_IDTrack_"), 12 );
2267 if ( collection.find("HLT_IDTrack")!=std::string::npos ) collection.erase( collection.find("HLT_IDTrack"), 11 );
2268 if ( collection.find("Tracking")!=std::string::npos ) collection.replace( collection.find("Tracking"), 8, "Trk" );
2269 if ( collection.find("InDetTrigTrk_")!=std::string::npos ) collection.erase( collection.find("InDetTrigTrk_"), 13 );
2270 if ( collection.find("HLT_xAODTracks_")!=std::string::npos ) collection.erase( collection.find("HLT_xAODTracks_"), 15 );
2271 if ( collection.find("_HLT_")!=std::string::npos ) collection.replace( collection.find("_HLT_"), 5, " " );
2272 if ( collection.find("HLT_")!=std::string::npos ) collection.erase( collection.find("HLT_"), 4 );
2273
2274
2275 if ( actual_chain.size()>30 ) {
2276 size_t pos = actual_chain.find_last_of(
"_");
2277 while ( pos!=std::string::npos && actual_chain.size()>30 ) {
2278 actual_chain.erase( pos, actual_chain.size()-pos );
2279 actual_chain+="...";
2280 pos = actual_chain.find_last_of(
"_");
2281 }
2282 }
2283
2284 std::string
c = actual_chain +
" : " + collection;
2285
2286 std::cout << "track collection: " << collection << " <-" << std::endl;
2287 std::cout << "actual chain: " << actual_chain << " <-" << std::endl;
2288
2290
2292
2293 std::cout <<
"use label: " <<
c <<
"\tchains size " <<
chains.size() <<
"\t" << usrlabels.size() << std::endl;
2294
2295 std::cout <<
"chains.size() " <<
chains.size() <<
" " << j << std::endl;
2296 std::cout <<
"chains.size() " <<
chains.size() <<
" " << j << std::endl;
2297
2298 std::cout <<
"chains[j] : " << j <<
" " <<
chains[j] << std::endl;
2299
2300 std::cout << "userlabels.size() " << usrlabels.size() << std::endl;
2301
2302 if ( usrlabels.size() < j+1 ) {
2303 if ( usrlabels.size()!=0 ) std::cerr << "userlabels not large enough - not using userlabels" << std::endl;
2304 }
2305 else c = usrlabels[ j ];
2306
2307 std::cout <<
"use label: c: " <<
c << std::endl;
2308
2310
2311
2312
2313 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2314
2315
2316
2317 std::cout << "\n\n\n\nxaxis: " << xaxis << std::endl;
2318
2319
2320
2321 if ( ALLRANGEMAP || xaxis.find("p_{T}")!=std::string::npos || xaxis.find("E_{T}")!=std::string::npos ) {
2322
2323 if ( RANGEMAP && xaxis.find("p_{T}")!=std::string::npos ) {
2324 bnd.
range( chains[j], htest );
2325 if ( href ) bnd.
range( chains[j], href );
2326 }
2327
2328 if ( RANGEMAP || ALLRANGEMAP ) {
2329
2331
2332 std::cout << "\n\n\nctags " << ctags.size() << "\n\n" << std::endl;
2333
2334 for (
size_t ic=0 ;
ic<ctags.size() ;
ic++ ) {
2335
2336
2337
2338 std::cout <<
"\n\nic: " <<
ic <<
" " << ctags[
ic] <<
" " << ccolours[
ic] <<
"\n\n" << std::endl;
2339
2340 if ( chains[j].
find(ctags[ic])!=std::string::npos ) {
2341 std::cout <<
"\ttag " << ctags[
ic] <<
" \tcolour: " << ccolours[
ic] <<
"\tstyle: " << cstyles[
ic] << std::endl;
2342 htest->SetLineColor( ccolours[ic] );
2343 htest->SetMarkerColor( ccolours[ic] );
2344 htest->SetMarkerStyle( cstyles[ic] );
2346 if ( tgtest ) {
2347 tgtest->SetLineColor(
htest->GetMarkerColor());
2348 tgtest->SetMarkerStyle(
htest->GetMarkerStyle());
2349 tgtest->SetMarkerColor(
htest->GetMarkerColor());
2350 }
2351 break;
2352 }
2353 }
2354
2355 }
2356
2357 std::cout <<
"test: " <<
chains[j] <<
"chains colour: " <<
htest->GetMarkerColor() << std::endl;
2358
2359 }
2360
2361
2362 std::cout << "movin' on ..." << std::endl;
2363
2364 std::cout <<
"chain: " <<
chains[j] <<
" \t marker colour: " <<
htest->GetMarkerColor() << std::endl;
2365
2366
2367
2368 std::cout <<
"Plotter marker : " <<
htest->GetMarkerColor() <<
" " <<
htest->GetMarkerStyle() << std::endl;
2369
2370
2371 if ( uselabels )
plots.push_back(
Plotter( htest, href,
" " + chain_name[j] + c, tgtest ) );
2372 else {
2373 std::cout <<
"using label: " <<
c << std::endl;
2375 }
2376
2377 if ( ALLRANGEMAP || ( RANGEMAP && xaxis.find(
"p_{T}")!=std::string::npos ) )
plots.back().max_entries( ccolours.size() );
2378
2379 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2380
2381 if ( make_ref_efficiencies ) {
2382
2383 if ( htestnum && hrefnum ) {
2385
2387
2388 double range =
h->GetMaximum()-
h->GetMinimum();
2389
2390 if ( range<0.2*scale_eff ) {
2391
2392 double max = int( (
h->GetMaximum() + 20)*0.1 )*0.1*scale_eff;
2393 double min = int( (
h->GetMinimum() - 10)*0.1 )*0.1*scale_eff;
2394
2395 if (
max>1*scale_eff )
max = 1.02*scale_eff;
2397
2400
2401 }
2402
2403 plots_eff.push_back(
Plotter(
e.Hist(), 0, c ) );
2404
2405 }
2406 }
2407
2408
2409 if ( href ) Chi2.push_back(
label(
"chi2 = %5.2lf / %2.0lf",
chi2( htest, href ),
double(
htest->GetNbinsX()) ) );
2410
2411 if ( drawmeans ) {
2412
2413 double mean_95 =
htest->GetMean();
2414 double dmean_95 =
htest->GetMeanError();
2415 double rms_95 =
htest->GetRMS();
2416 double drms_95 =
htest->GetRMSError();
2417
2418 Mean.push_back(
label(
" mean = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
2419 RMS.push_back(
label(
" rms = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
2420
2421 }
2422
2423 if ( residual && drawresiduals ) {
2424
2426
2427 xpos = xpos_original;
2428
2429 std::cout <<
"calculating resolutions : " <<
histo.name() <<
" " <<
htest->GetName() << std::endl;
2430
2432
2433 double mean_95 = d95->GetParameter(1);
2434 double dmean_95 = d95->GetParError(1);
2435 double rms_95 = d95->GetParameter(2);
2436 double drms_95 = d95->GetParError(2);
2437
2438 std::cout <<
"\t\t" <<
histo.name()
2439 << "\tmean: " << mean_95 << " +- " << dmean_95
2440 << "\trms: " << rms_95 << " +- " << drms_95 << std::endl;
2441
2443
2444 if ( !power_set ) {
2445 for (
int ip=-2 ;
ip<9 ;
ip++ ) {
2446 if ( std::fabs(mean_95) >= std::pow( 10., double(-ip) ) ) {
2448 break;
2449 }
2450 }
2451
2452 for (
int ip=-2 ;
ip<9 ;
ip++ ) {
2453 if ( std::fabs(rms_95) >= std::pow( 10., double(-ip) ) ) {
2455 break;
2456 }
2457 }
2458 }
2459
2460 power_set = true;
2461
2462 std::cout <<
"\t\t" <<
histo.name()
2463 << "\tmean: " << mean_95 << " +- " << dmean_95 << " : pow " << mean_power
2464 << "\trms: " << rms_95 << " +- " << drms_95 << " : pow " << rms_power << std::endl;
2465
2466
2467 if ( mean_power == 0 ) {
2468 Mean.push_back(
label(
"mean_{95} = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
2469 }
2470 else {
2471 Mean.push_back(
label(
"mean_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
2472 mean_95*std::pow(10.,double(mean_power)), dmean_95*std::pow(10,double(mean_power)), -mean_power ) );
2473
2474 }
2475
2476 if ( rms_power == 0 ) {
2477 RMS.push_back(
label(
"rms_{95} = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
2478 }
2479 else {
2480 RMS.push_back(
label(
"rms_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
2481 rms_95*std::pow(10.,double(rms_power)), drms_95*std::pow(10,double(rms_power)), -rms_power ) );
2482 }
2483
2484 if ( href ) {
2485
2487
2488 double mean_95ref = d95ref->GetParameter(1);
2489 double dmean_95ref = d95ref->GetParError(1);
2490 double rms_95ref = d95ref->GetParameter(2);
2491 double drms_95ref = d95ref->GetParError(2);
2492
2493 std::cout <<
"\t\t" <<
histo.name()
2494 << "\tmean ref: " << mean_95ref << " +- " << dmean_95ref << " : pow " << mean_power
2495 << "\trms ref: " << rms_95ref << " +- " << drms_95ref << " : pow " << rms_power << std::endl;
2496
2497 if ( mean_power == 0 ) {
2498 MeanRef.push_back(
label(
"mean_{95} ref = %4.2lf #pm %4.2lf", mean_95ref, dmean_95ref) );
2499 }
2500 else {
2501 MeanRef.push_back(
label(
"mean_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
2502 mean_95ref*std::pow(10,double(mean_power)), dmean_95ref*std::pow(10,double(mean_power)), -mean_power ) );
2503
2504 }
2505
2506
2507 if ( rms_power == 0 ) {
2508 RMSRef.push_back(
label(
"rms_{95} ref = %4.2lf #pm %4.2lf", rms_95ref, drms_95ref ) );
2509 }
2510 else {
2511 RMSRef.push_back(
label(
"rms_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
2512 rms_95ref*std::pow(10,double(rms_power)), drms_95ref*std::pow(10,double(rms_power)), -rms_power ) );
2513 }
2514 }
2515
2517 if ( href )
href->Sumw2();
2518 }
2519
2522 if ( href )
Norm( href );
2523 }
2526 }
2527
2531 }
2532
2533
2534
2535 if ( !noreftmp && normref &&
2540 }
2541
2542 }
2543
2544 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2545
2546 if ( !noplots ) {
2547
2550
2551 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2552
2554 plots.sortx( xinfo );
2555
2556 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2557
2558 double yminset = 0;
2559 double ymaxset = 0;
2560
2561 double rmin = 0;
2562 double rmax = 0;
2563
2567 }
2568 else {
2569 rmin =
plots.realmin();
2570 rmax =
plots.realmax();
2571 }
2572
2574
2575 int csize =
chains.size() + taglabels.size() + ( atlasstyle ? 1 : 0 );
2576
2577 if ( yinfo.
log() && rmin>0 && rmax>0 ) {
2578
2580 double delta = std::log10(rmax)-std::log10(rmin);
2581
2583
2584
2585 yminset = rmin*std::pow(10,-delta*0.1);
2586
2587 double newdelta = std::log10(rmax) - std::log10(yminset) + 0.05*delta;
2588
2589 if ( csize<10 ) ymaxset = rmin*std::pow(10,newdelta/(1-0.07*csize));
2590 else ymaxset = rmin*std::pow(10,newdelta*2);
2591
2592 if ( yminset!=yminset ) {
2593 std::cerr << " range error " << delta << " " << yminset << " " << ymaxset << "\t(" << rmin << " " << rmax << ")" << std::endl;
2597 continue;
2598 }
2599
2600 }
2601 else {
2602
2605
2606 if ( ypos>0.5 ) {
2607 double delta = rmax-rmin;
2608
2609 yminset = rmin-0.1*delta;
2610
2611 if ( rmin>=0 && yminset<=0 ) yminset = 0;
2612
2613 double newdelta = rmax - yminset + 0.05*delta;
2614
2615 if ( csize<10 ) ymaxset = yminset + newdelta/(1-0.09*csize);
2616 else ymaxset = yminset + newdelta*2;
2617 }
2618 else {
2619 double delta = rmax-rmin;
2620
2621 ymaxset = rmax+0.1*delta;
2622
2623 double newdelta = ymaxset - rmin - 0.05*delta;
2624
2625 if ( csize<10 ) yminset = ymaxset - newdelta/(1-0.09*csize);
2626 else yminset = ymaxset - newdelta*2;
2627
2628 if ( rmin>=0 && yminset<=0 ) yminset = 0;
2629
2630 }
2631
2632 }
2633
2634 }
2635 else {
2637 yminset = yinfo.
lo();
2638 ymaxset = yinfo.
hi();
2639 }
2640 }
2641
2642 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2643
2644
2645
2646
2647
2648
2650
2651 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2652
2653 if ( yminset>yinfo.
lo() ) yminset = yinfo.
lo();
2654 if ( ymaxset<yinfo.
hi() ) ymaxset = yinfo.
hi();
2655 }
2656
2657
2659
2660 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2661
2662 if ( effset ) {
2663 ymaxset = effmax;
2664 yminset = effmin;
2665 }
2666 }
2667
2668 if ( ymaxset!=0 || yminset!=0 ) {
2669
2670 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2671
2672 plots.Max( ymaxset );
2673 plots.Min( yminset );
2674 }
2675
2676 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2677
2678 if ( yminset!=0 || ymaxset!=0 ) {
2679 if ( yminset>0 )
plots.SetLogy(yinfo.
log());
2680 else plots.SetLogy(
false);
2681 }
2683
2684
2685
2686 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2687
2688
2689
2691
2692 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2693
2694 plots.Draw( legend );
2695
2696 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2697
2698 if ( atlasstyle )
ATLASLabel( xpos, ypositions[0]+deltay, atlaslabel, kBlack, ncolsp, nrowsp );
2699
2700 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2701
2702 for (
unsigned it=0 ;
it<taglabels.size() ;
it++ ) {
2703 DrawLabel( xpos, ypositions[it], taglabels[it], kBlack, 0.04 );
2704 }
2705 }
2706
2707 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2708
2709
2710 if ( ( !nostats || !nomeans ) && !noplots ) {
2711 if ( dochi2 )
for (
unsigned j=0 ; j<Chi2.size() ; j++ )
DrawLabel( 0.75, 0.85-j*0.035, Chi2[j],
colours[j%6] );
2714 histo.name()==
"pT" ||
2717
2719 for (
unsigned j=0 ; j<
chains.size() ; j++ ) {
2720 if ( !noreftmp ) {
2721 if ( j<MeanRef.size() ) {
2722 if ( !nomeans )
DrawLabel( xpos_original-0.02, (0.67-j*0.035), MeanRef[j],
colours[j%6] );
2724 }
2725 }
2726 if ( j<
Mean.size() ) {
2729 }
2730 }
2731 }
2732 }
2733
2734 }
2735
2736 if ( xinfo.
log() ) gPad->SetLogx(
true);
2737 else gPad->SetLogx(false);
2738
2739 if ( yinfo.
log() ) gPad->SetLogy(
true);
2740 else gPad->SetLogy(false);
2741
2742 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2743
2744 if ( !noplots ) {
2745
2746 if ( make_ref_efficiencies ) {
2747
2748 plots_eff.SetXaxisTitle(
plots.GetXaxisTitle() );
2749 plots_eff.SetYaxisTitle(
plots.GetYaxisTitle() );
2750
2751 plots_eff.Draw( legend_eff );
2752 }
2753
2754 if ( !noreflabel.empty() )
DrawLabel(0.1, 0.06, noreflabel, kRed, 0.03 );
2755
2756 }
2757
2758 }
2759
2760
2766
2767 if ( !noplots ) {
2768
2770
2772
2773 std::string useplotname;
2774
2775 if ( panel.
size()>1 ) {
2776 useplotname = panel.
name();
2777 replace( useplotname,
'/',
'_' );
2778 }
2779 else {
2780 useplotname = plotname;
2781 }
2782
2783 useplotname.erase(
std::remove( useplotname.begin(), useplotname.end(),
'+' ), useplotname.end() );
2784
2785
2786 std::string printbase =
dir + useplotname +
tag;
2787
2789
2790 if ( !nopdf )
print_pad( printbase+
".pdf" );
2791 if ( !nopng )
print_pad( printbase+
".png" );
2792 if ( Cfile )
print_pad( printbase+
".C" );
2793
2794 std::cout << std::endl;
2795 }
2796
2797 }
2798
2799 if (
tc )
delete tc;
2800
2801 }
2802
2803
2804 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2805
2807
2808
2810 bool files_duplicated = ( fref_==ftest_ );
2811
2812 if ( deleteref && !files_duplicated ) {
2813
2814 if ( fref_ ) {
2815
2817
2818 std::cout << "main() cleaning up reference file" << std::endl;
2819
2820 TFile* newout = new TFile(".newout.root","recreate");
2821 newout->cd();
2822
2825
2827
2829
2831
2832
2834
2835 for (
unsigned j=0 ; j<
dirs.size()-1 ; j++ ) {
2836 std::cout <<
"\t" <<
dirs[j] << std::endl;
2837 TDirectory* renedir =
gDirectory->GetDirectory(
dirs[j].c_str() );
2840 }
2841
2842
2844 if ( !noreftmp && href ) {
2846 href->Write(
dirs.back().c_str() );
2847 }
2848
2849
2851 }
2852
2853 newout->Close();
2854
2855 }
2856 }
2857
2858
2859 if (
fulldbg ) std::cout << __LINE__ << std::endl;
2860
2862
2863 if ( fref_ && !files_duplicated ) fref_->Close();
2864 if ( ftest_ ) ftest_->Close();
2865
2867
2868 if ( deleteref && !noref ) {
2869 std::cout << "ref " << frefname << "\ttest " << ftestname << std::endl;
2870 if ( frefname != ftestname && !files_duplicated ) {
2871 std::string
cmd = std::string(
"mv ") + frefname +
" " + frefname +
".bak";
2872 std::system(
cmd.c_str() );
2873
2874 cmd = std::string(
"mv .newout.root ") + std::string(frefname);
2875 std::system(
cmd.c_str() );
2876 }
2877 else {
2878 std::cerr << "reference file and test file are the same - not replacing" << std::endl;
2879 }
2880 }
2881
2882
2883
2884 if ( fref_ && !files_duplicated ) delete fref_;
2885 if ( ftest_ ) delete ftest_;
2886
2887 return 0;
2888}
void ATLASLabel(Double_t x, Double_t y, char *text=NULL, Color_t color=1)
constexpr int pow(int base, int exp) noexcept
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
void print_pad(const std::string &s)
std::string fullreplace(std::string s, const std::string &s2, const std::string &s3)
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 * Rebin(TH1F *h, double f)
void autox(TH2 *h)
get the auto x range of a 2d histogram
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 Norm(TH1 *h, double scale)
void copyReleaseInfo(TFile *finput, TFile *foutdir)
copy the release info TTree
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::string diff_panel[10][6]
std::string res_panel[4][6]
std::string eff_panel[4][6]
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)
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)