21 void maketable(
const vector<double> &tot_entries,
const vector<vector<vector<double> > > &entries);
25 TChain* tt =
new TChain(
"tree");
26 tt->Add(
"/afs/cern.ch/user/m/manuelf/work/babies/"+
ntuple_date+
"/mc/skim_1lht500met200/*TTJets*HT*");
27 tt->Add(
"/afs/cern.ch/user/m/manuelf/work/babies/"+
ntuple_date+
"/mc/skim_1lht500met200/*TTJets*Lept*");
33 TString Baseline =
"ht>500&&met>200&&njets>=6&&nbm>=1&&nleps==1&&mj>250";
38 TString OneTruLep =
"ntruleps==1";
39 TString hmt =
"mt>140";
41 TString OneRecoEl =
"nels==1";
42 TString OneRecoMu =
"nmus==1";
44 TString ZeroGoodLeps =
"(nleps_tm==0)";
46 TString LostFakeEl =
"("+OneRecoEl+And+ZeroGoodLeps+
")";
47 TString LostFakeMu =
"("+OneRecoMu+And+ZeroGoodLeps+
")";
49 TString LostFake =
"("+LostFakeEl+Or+LostFakeMu+
")";
50 TString NotLostFake =
"!"+LostFake;
52 TString LowGenMt =
"(mt_tru<=140)";
53 TString LowGenMtFromW =
"(mt_tru_nuw<=140)";
55 TString BadRecoMtEl =
"("+OneRecoEl+And+LowGenMt+
")";
56 TString BadRecoMtMu =
"("+OneRecoMu+And+LowGenMt+
")";
59 vector<TString> nbcuts;
60 nbcuts.push_back(
"nbm>=1");
61 nbcuts.push_back(
"nbm>=2");
62 nbcuts.push_back(
"nbm>=3");
64 vector<vector<TString> > syscuts;
65 syscuts.push_back(vector<TString>());
66 syscuts.push_back(vector<TString>());
67 syscuts[0].push_back(LostFakeEl);
68 syscuts[0].push_back(NotLostFake+And+BadRecoMtEl);
69 syscuts[0].push_back(NotLostFake+And+OneRecoEl+And+
"!"+LowGenMt);
70 syscuts[1].push_back(LostFakeMu);
71 syscuts[1].push_back(NotLostFake+And+BadRecoMtMu);
72 syscuts[1].push_back(NotLostFake+And+OneRecoMu+And+
"!"+LowGenMt);
75 vector<int> tot_entries; vector<double> tot_yield, tot_err;
76 vector<vector<vector<int> > > Nentries;
77 vector<vector<vector<double> > > yield, err;
78 for(
unsigned int iNb=0; iNb<nbcuts.size(); iNb++){
79 Nentries.push_back(vector<vector<int> >()); yield.push_back(vector<vector<double> >()); err.push_back(vector<vector<double> >());
80 TString totcut_hmt =
lumi+
"*weight*("+Baseline+And+hmt+And+nbcuts[iNb]+
")";
82 double tot_baseline, tot_baseline_err;
83 getYieldErr(*tt, totcut_hmt, tot_baseline, tot_baseline_err);
85 TString totcut =
lumi+
"*weight*("+Baseline+And+OneTruLep+And+hmt+And+nbcuts[iNb]+
")";
87 int tot_tempentry(-1);
double tot_tempyield, tot_temperr;
88 tot_tempentry =
getYieldErr(*tt, totcut, tot_tempyield, tot_temperr);
90 tot_entries.push_back(tot_tempentry); tot_yield.push_back(tot_tempyield); tot_err.push_back(tot_temperr);
92 cout<<
"Totals for Nb="<<iNb+1<<
" high mT, 1l events: Entries = "<<tot_entries[iNb]<<
", Yield = "<<
RoundNumber(tot_yield[iNb],2)<<
" out of "<<
RoundNumber(tot_baseline,2)<<
" high mT tt events ("<<
RoundNumber(tot_yield[iNb]/tot_baseline*100,2)<<
"%)"<<endl;
94 for(
unsigned int iSys=0; iSys<(syscuts[0].size()); iSys++){
95 Nentries[iNb].push_back(vector<int>()); yield[iNb].push_back(vector<double>()); err[iNb].push_back(vector<double>());
96 for(
unsigned int iLep=0; iLep<syscuts.size(); iLep++){
98 totcut =
lumi+
"*weight*("+Baseline+And+OneTruLep+And+hmt+And+nbcuts[iNb]+And+syscuts[iLep][iSys]+
")";
103 double temp_yield(0.), temp_err(0.);
104 temp_entries =
getYieldErr(*tt, totcut, temp_yield, temp_err);
106 Nentries[iNb][iSys].push_back(temp_entries); yield[iNb][iSys].push_back(temp_yield); err[iNb][iSys].push_back(temp_err);
108 cout<<
"Nentries = "<<Nentries[iNb][iSys][iLep]<<
", yield = "<<yield[iNb][iSys][iLep]<<
", err = "<<err[iNb][iSys][iLep]<<endl;
118 void maketable(
const vector<double> &tot_entries,
const vector<vector<vector<double> > > &entries){
120 for(
int iNb=0; iNb<3; iNb++){
122 TString tname(
"txt/table_hmol_Nb");
126 ifstream header(
"txt/header.tex");
127 ifstream footer(
"txt/footer.tex");
128 ofstream
file(tname);
129 file<<header.rdbuf();
132 file<<
"\\begin{tabular}[tbp!]{l|c|c|c} \\hline \\hline"<<endl;
134 file <<
"Baseline (${\\cal L} = "<<
lumi<<
"$ fb$^{-1}$) & Reco Lepton & MC Predicted Events & \\% (for both flavors) \\\\"<<endl;
135 file <<
"\\hline \\hline"<<endl;
136 file <<
"Lost-Fake Lepton & e & "<<
RoundNumber(entries[iNb][0][0],1)<<
" & \\multirow{2}{*}{"<<
RoundNumber((entries[iNb][0][0]+entries[iNb][0][1])/tot_entries[iNb]*100.,0)<<
"\\%} \\\\"<<endl;
137 file <<
"& $\\mu$ & "<<
RoundNumber(entries[iNb][0][1],1)<<
" & \\\\"<<endl;
138 file <<
"\\hline"<<endl;
139 file <<
"Jet Mismeasurement & e & "<<
RoundNumber(entries[iNb][1][0],1)<<
" & \\multirow{2}{*}{"<<
RoundNumber((entries[iNb][1][0]+entries[iNb][1][1])/tot_entries[iNb]*100.,0)<<
"\\%} \\\\"<<endl;
140 file <<
"& $\\mu$ & "<<
RoundNumber(entries[iNb][1][1],1)<<
" & \\\\"<<endl;
141 file <<
"\\hline"<<endl;
142 file <<
"Non-Prompt Neutrinos & e & "<<
RoundNumber(entries[iNb][2][0],1)<<
" & \\multirow{2}{*}{"<<
RoundNumber((entries[iNb][2][0]+entries[iNb][2][1])/tot_entries[iNb]*100.,0)<<
"\\%} \\\\"<<endl;
143 file <<
"& $\\mu$ & "<<
RoundNumber(entries[iNb][2][1],1)<<
" & \\\\"<<endl;
144 file <<
"\\hline \\hline"<<endl;
146 file <<
"\\end{tabular}"<<endl;
148 file<<footer.rdbuf();
150 cout<<
"Written "<<tname<<endl;
long getYieldErr(TChain &tree, TString cut, double &yield, double &uncertainty)
void maketable(const vector< double > &tot_entries, const vector< vector< vector< double > > > &entries)
TString RoundNumber(double num, int decimals, double denom=1.)
TString ntuple_date("2015_10_19")