25 ttbar.Add(
"archive/ra4skim/small_TT_*.root");
26 TChain t1tttt(
"tree");
27 t1tttt.Add(
"archive/ra4skim/small*SMS*T1tttt*PU20*.root");
48 void DrawROC(TChain &ttbar, TChain &t1tttt,
const string &lep,
int pt_bin){
49 const unsigned nbins = 1000;
50 const double reliso_low = 0.0, reliso_high = 1.0;
51 const double ptrel_low = 0.0, ptrel_high = 100.0;
52 const double ptrel_25_low = 0.0, ptrel_25_high = 100.0;
54 TH1D reliso_good(
"reliso_good",
"", nbins, reliso_low, reliso_high);
55 TH1D reliso_bad(
"reliso_bad",
"", nbins, reliso_low, reliso_high);
56 TH1D ptrel_good(
"ptrel_good",
"",nbins, ptrel_low, ptrel_high);
57 TH1D ptrel_bad(
"ptrel_bad",
"",nbins, ptrel_low, ptrel_high);
58 TH1D ptrel_25_good(
"ptrel_25_good",
"",nbins, ptrel_25_low, ptrel_25_high);
59 TH1D ptrel_25_bad(
"ptrel_25_bad",
"",nbins, ptrel_25_low, ptrel_25_high);
60 TH1D miniso_good(
"miniso_good",
"",nbins, reliso_low, reliso_high);
61 TH1D miniso_bad(
"miniso_bad",
"",nbins, reliso_low, reliso_high);
62 TH1D miniso_ch_good(
"miniso_ch_good",
"",nbins, reliso_low, reliso_high);
63 TH1D miniso_ch_bad(
"miniso_ch_bad",
"",nbins, reliso_low, reliso_high);
65 string full_lep =
"Lepton";
69 full_lep =
"Electron";
72 string pt_cut, pt_title, pt_file;
76 pt_cut = lep+
"s_pt>20";
77 pt_title =
"p_{T}^{"+lep+
"}>20";
81 pt_cut = lep+
"s_pt>20&&"+lep+
"s_pt<50";
82 pt_title =
"20<p_{T}^{"+lep+
"}<50";
86 pt_cut = lep+
"s_pt>50&&"+lep+
"s_pt<100";
87 pt_title =
"50<p_{T}^{"+lep+
"}<100";
91 pt_cut = lep+
"s_pt>100&&"+lep+
"s_pt<200";
92 pt_title =
"100<p_{T}^{"+lep+
"}<200";
96 pt_cut = lep+
"s_pt>200";
97 pt_title =
"p_{T}^{"+lep+
"}>200";
102 string good_denom_cut = lep+
"s_tru_tm&&"+lep+
"s_sigid&&"+pt_cut;
103 if(lep==
"el") good_denom_cut +=
"&&els_ispf";
104 string bad_denom_cut =
"!"+good_denom_cut;
105 t1tttt.Project(
"reliso_good",
106 (lep+
"s_reliso").c_str(),
107 good_denom_cut.c_str());
108 ttbar.Project(
"reliso_bad",
109 (lep+
"s_reliso").c_str(),
110 bad_denom_cut.c_str());
111 t1tttt.Project(
"ptrel_good",
112 (lep+
"s_ptrel_0").c_str(),
113 good_denom_cut.c_str());
114 ttbar.Project(
"ptrel_bad",
115 (lep+
"s_ptrel_0").c_str(),
116 bad_denom_cut.c_str());
117 t1tttt.Project(
"ptrel_25_good",
118 (lep+
"s_ptrel_rem_0+("+lep+
"s_ptrel_rem_0<0)*9999.").c_str(),
119 good_denom_cut.c_str());
120 ttbar.Project(
"ptrel_25_bad",
121 (lep+
"s_ptrel_rem_0+("+lep+
"s_ptrel_rem_0<0)*9999.").c_str(),
122 bad_denom_cut.c_str());
123 t1tttt.Project(
"miniso_good",
124 (lep+
"s_miniso_tr07").c_str(),
125 good_denom_cut.c_str());
126 ttbar.Project(
"miniso_bad",
127 (lep+
"s_miniso_tr07").c_str(),
128 bad_denom_cut.c_str());
129 t1tttt.Project(
"miniso_ch_good",
130 (lep+
"s_miniso_tr07_ch").c_str(),
131 good_denom_cut.c_str());
132 ttbar.Project(
"miniso_ch_bad",
133 (lep+
"s_miniso_tr07_ch").c_str(),
134 bad_denom_cut.c_str());
136 double good_count, bad_count ,junk;
140 double good_num, bad_num;
143 (good_denom_cut+
"&&((abs(els_eta)<=1.479&&els_reliso<0.2179)||abs(els_eta)>1.479&&els_reliso<0.254)"),
146 (bad_denom_cut+
"&&!((abs(els_eta)<=1.479&&els_reliso<0.2179)||abs(els_eta)>1.479&&els_reliso<0.254)"),
150 (good_denom_cut+
"&&(mus_reliso<0.12)"),
153 (bad_denom_cut+
"&&!(mus_reliso<0.12)"),
156 TMarker marker(good_num/good_count, bad_num/bad_count, 29);
157 marker.SetMarkerSize(5);
159 TGraph reliso =
MakeROC(reliso_good, reliso_bad,
true, good_count, bad_count);
160 TGraph ptrel =
MakeROC(ptrel_good, ptrel_bad,
false, good_count, bad_count);
161 TGraph ptrel_25 =
MakeROC(ptrel_25_good, ptrel_25_bad,
false, good_count, bad_count);
162 TGraph miniso =
MakeROC(miniso_good, miniso_bad,
true, good_count, bad_count);
163 TGraph miniso_ch =
MakeROC(miniso_ch_good, miniso_ch_bad,
true, good_count, bad_count);
165 reliso.SetLineColor(1); reliso.SetLineWidth(4);
166 ptrel.SetLineColor(2); ptrel.SetLineWidth(4);
167 ptrel_25.SetLineColor(3); ptrel_25.SetLineWidth(4);
168 miniso.SetLineColor(4); miniso.SetLineWidth(4);
169 miniso_ch.SetLineColor(6); miniso_ch.SetLineWidth(4);
171 TH1D dumb(
"",
"",1,0.5,1.0);
172 dumb.SetTitle((pt_title+
";Truth Matched Prompt " 174 +
" Efficiency;Non-Prompt " 176 +
" Rejection Rate").c_str());
177 dumb.SetMinimum(0.0);
178 dumb.SetMaximum(1.0);
182 reliso.Draw(
"lsame");
184 ptrel_25.Draw(
"lsame");
185 miniso.Draw(
"lsame");
186 miniso_ch.Draw(
"lsame");
189 TLegend leg(0.1,0.12,0.25,0.62);
192 leg.SetBorderSize(0);
193 leg.SetTextSize(0.05);
194 leg.AddEntry(&reliso,
"Rel. Iso.",
"l");
195 leg.AddEntry(&miniso,
"Mini Iso. Tr., kt = 15 GeV",
"l");
196 leg.AddEntry(&miniso_ch,
"Mini Iso. Tr., kt = 15 GeV (ch. only)",
"l");
197 leg.AddEntry(&ptrel,
"p_{T}^{rel}",
"l");
198 leg.AddEntry(&ptrel_25,
"p_{T}^{rel} || Isolated",
"l");
200 canvas.Print((
"eps/roc_"+lep+
"_"+pt_file+
".eps").c_str());
203 TGraph
MakeROC(TH1D &good, TH1D &bad,
const bool less_is_better,
204 double good_count,
double bad_count){
205 const int nbins = good.GetNbinsX();
206 if(bad.GetNbinsX() != nbins)
throw logic_error(
"Mismatched number of bins");
209 const double good_tot = (good_count<=0.0)?good.Integral(0, nbins+1):good_count;
210 const double bad_tot = (bad_count<=0.0)?bad.Integral(0, nbins+1):bad_count;
212 for(
int bin = nbins+1; bin>=0; --bin){
213 const double good_pass = good.Integral(0, bin);
214 const double bad_pass = bad.Integral(0, bin);
215 const double x = good_pass/good_tot;
216 const double y = 1.0-bad_pass/bad_tot;
220 for(
int bin = 0; bin<=nbins+1; ++bin){
221 const double good_pass = good.Integral(bin,nbins+1);
222 const double bad_pass = bad.Integral(bin, nbins+1);
223 const double x = good_pass/good_tot;
224 const double y = 1.0-bad_pass/bad_tot;
233 const string &lep,
const bool truth_match){
234 const unsigned reliso_nbins = 100, ptrel_nbins = 100;
235 const double reliso_low = 0.0, reliso_high = 2.0;
236 const double ptrel_low = 0.0, ptrel_high = 50.0;
238 string title_samp =
"";
239 if(sample==
"susy") title_samp =
"T1tttt(1200,800)";
240 else if(sample==
"ttbar") title_samp =
"ttbar";
242 string title_lep =
"Lepton";
243 if(lep==
"mu") title_lep =
"Muon";
244 else if(lep==
"el") title_lep =
"Electron";
246 string title_truth_match = truth_match?
"Truth-Matched":
"Anti-Truth-Matched";
248 string title = title_samp+
" "+title_truth_match+
" "+title_lep;
250 TH2D scat(
"scat", (title+
";Rel. Iso.;p_{T}^{rel}").c_str(),
251 reliso_nbins, reliso_low, reliso_high,
252 ptrel_nbins, ptrel_low, ptrel_high);
254 chain.Project(
"scat", (lep+
"s_ptrel:"+lep+
"s_reliso").c_str(),
255 ((truth_match?
"":
"!")+lep+
"s_tru_tm").c_str());
259 canvas.Print((
"eps/scat_" 260 +sample+
"_"+lep+
"_"+(truth_match?
"good":
"bad")
261 +
"_ptrel_vs_reliso.eps").c_str());
void AddPoint(TGraph &graph, const double x, const double y)
void get_count_and_uncertainty(TTree &tree, const std::string &cut, double &count, double &uncertainty)
void DrawROC(TChain &ttbar, TChain &t1tttt, const string &lep, int pt_bin)
void DrawScat(TChain &chain, const string &sample, const string &lep, const bool truth_match)
TGraph MakeROC(TH1D &good, TH1D &bad, const bool less_is_better, double good_count, double bad_count)