28 const double lumi = 4.0;
33 TH1::SetDefaultSumw2(
true);
35 int pos_cols[999], sym_cols[999];
40 string basefolder(
"/cms5r0/ald77/archive/20150108/");
41 vector<string> treenames;
42 vector<TString> samplenames;
43 treenames.push_back(basefolder+
"*T1tttt_2J_mGl-1500_mLSP-100*"); samplenames.push_back(
"t1tttt1500");
44 treenames.push_back(basefolder+
"skim/small_TTJet_ht750_met200.root"); samplenames.push_back(
"ttbar");
54 for(
unsigned itree(0); itree<treenames.size(); itree++){
55 small_tree tree(treenames[itree]); sample = samplenames[itree];
56 vector<CutBase*> base_cuts;
57 TString cut_string =
"UNKNOWN";
60 cut_string =
"inclusive";
71 base_cuts.push_back(
NewCut(&tree, &small_tree::ht30, 800.f,
kGreater));
79 vector<pair<IsoCut,TString> > iso_cuts;
83 iso_cuts.push_back(pair<IsoCut, TString>(
VetoStandardIso,
"vetostandard"));
84 iso_cuts.push_back(pair<IsoCut, TString>(
VetoMiniIso,
"vetominiso"));
86 iso_cuts.push_back(pair<IsoCut, TString>(
StandardIso,
"standard"));
87 iso_cuts.push_back(pair<IsoCut, TString>(
MiniIso,
"miniso"));
94 vector<TH2D> histos(iso_cuts.size(),
95 TH2D(
"",
";Num Reco "+isveto+
"e+#mu;Num Gen e+#mu", 6, -1.5, 4.5, 6, -1.5, 4.5));
96 TLine hline(-1.5, -0.5, 4.5, -0.5);
97 TLine vline(-0.5, -1.5, -0.5, 4.5);
102 Timer timer(num_entries, 1.0);
104 for(
long entry = 0; entry < num_entries; ++entry){
110 for(
size_t icut = 0; icut < iso_cuts.size(); ++icut){
111 int best_el = -1, best_mu = -1;
112 int count = (iso_cuts.at(icut).first)(tree, best_el, best_mu);
126 float lep_pt(0), lep_phi(0);
128 lep_pt = tree.
els_pt()[best_el];
129 lep_phi = tree.
els_phi()[best_el];
130 }
else if(best_mu>=0) {
131 lep_pt = tree.
mus_pt()[best_mu];
132 lep_phi = tree.
mus_phi()[best_mu];
133 }
else {cout<<
"Either mu or el have to be best"<<endl;
return 1;}
134 mt = sqrt(2*lep_pt* tree.
met()*(1-cos(tree.
met_phi()-lep_phi)));
136 if(
false && mt<150)
continue;
138 histos.at(icut).Fill(count, (tree.mc_type() & 0xF00) >> 8, lumi*tree.
weight());
144 for(
size_t ihist = 0; ihist < histos.size(); ++ihist){
145 TH2D &hist = histos.at(ihist);
146 hist.SetMarkerSize(3.4);
147 hist.SetMarkerStyle(20);
150 for(
int xbin = 0; xbin <= hist.GetNbinsX()+1; ++xbin){
152 double integral = hist.IntegralAndError(xbin, xbin, 2, hist.GetNbinsY()+1, error);
153 hist.SetBinContent(xbin, 1, integral);
154 hist.SetBinError(xbin, 1, error);
158 for(
int ybin = 0; ybin <= hist.GetNbinsY()+1; ++ybin){
160 double integral = hist.IntegralAndError(2, hist.GetNbinsX()+1, ybin, ybin, error);
161 hist.SetBinContent(1, ybin, integral);
162 hist.SetBinError(1, ybin, error);
165 hist.GetXaxis()->SetBinLabel(1,
"Any");
166 for(
int i = 2; i <= hist.GetNbinsX(); ++i){
167 hist.GetXaxis()->SetBinLabel(i, TString::Itoa(i-2,10));
169 hist.GetYaxis()->SetBinLabel(1,
"Any");
170 for(
int i = 2; i <= hist.GetNbinsY(); ++i){
171 hist.GetYaxis()->SetBinLabel(i, TString::Itoa(i-2,10));
175 for(
size_t ihist = 0; ihist < histos.size(); ++ihist){
176 gStyle->SetPalette(999, pos_cols);
177 TString title =
"eps/trans_single_" 180 +iso_cuts.at(ihist).second+
".eps";
182 TString htitle(
"Yields for ");
183 htitle += lumi; htitle +=
" fb^{-1}";
184 histos.at(ihist).SetTitle(htitle);
185 gStyle->SetPaintTextFormat(
".1f");
186 histos.at(ihist).Draw(
"col");
188 histos.at(ihist).Draw(
"textsame");
192 gStyle->SetPaintTextFormat(
".1f");
193 for(
size_t jhist = 0; jhist < histos.size(); ++jhist){
194 if(jhist==ihist)
continue;
195 gStyle->SetPalette(999, sym_cols);
196 TH2D delta = histos.at(ihist);
197 for(
int x = 0; x <= delta.GetNbinsX()+1; ++x){
198 for(
int y = 0; y <= delta.GetNbinsY()+1; ++y){
199 delta.SetBinContent(x, y,
200 histos.at(ihist).GetBinContent(x, y)
201 -histos.at(jhist).GetBinContent(x, y));
204 double maxi = fabs(delta.GetBinContent(delta.GetMaximumBin()));
205 double mini = fabs(delta.GetBinContent(delta.GetMinimumBin()));
206 if(mini>maxi) maxi=mini;
207 delta.SetMinimum(-maxi);
208 delta.SetMaximum(maxi);
209 title =
"eps/trans_delta_" 212 +iso_cuts.at(ihist).second
214 +iso_cuts.at(jhist).second+
".eps";
215 htitle =
"Yield difference for Miniso - Reliso";
216 delta.SetTitle(htitle);
218 delta.Draw(
"textsame");
221 if(!title.Contains(
"minus_miniso") && !title.Contains(
"minus_vetominiso")) c.Print(title);
223 gStyle->SetPaintTextFormat(
".0f");
224 for(
size_t jhist = 0; jhist < histos.size(); ++jhist){
225 if(jhist==ihist)
continue;
226 gStyle->SetPalette(999, sym_cols);
227 TH2D delta = histos.at(ihist);
228 for(
int x = 0; x <= delta.GetNbinsX()+1; ++x){
229 for(
int y = 0; y <= delta.GetNbinsY()+1; ++y){
230 float den(histos.at(jhist).GetBinContent(x, y));
232 if(den>0.2) z = 100*(histos.at(ihist).GetBinContent(x, y)-den)/den;
234 if(fabs(z)<0.5) z = 0;
235 delta.SetBinContent(x, y, z);
238 double maxi = fabs(delta.GetBinContent(delta.GetMaximumBin()));
239 double mini = fabs(delta.GetBinContent(delta.GetMinimumBin()));
240 if(mini>maxi) maxi=mini;
241 delta.SetMinimum(-maxi);
242 delta.SetMaximum(maxi);
243 title =
"eps/trans_ratio_" 246 +iso_cuts.at(ihist).second
248 +iso_cuts.at(jhist).second+
".eps";
249 htitle =
"Yield difference for Miniso - Reliso (%)";
250 delta.SetTitle(htitle);
252 delta.Draw(
"textsame");
255 if(!title.Contains(
"over_miniso") && !title.Contains(
"over_vetominiso")) c.Print(title);
263 for(vector<CutBase*>::const_iterator cut = cuts.begin();
266 if(!(*cut)->Pass())
return false;
275 return cut(tree, best_el, best_mu);
279 int &best_el,
int &best_mu){
280 if(best_el < 0 || static_cast<unsigned>(best_el) >= tree.
els_pt().size()) best_el = -1;
281 if(best_mu < 0 || static_cast<unsigned>(best_mu) >= tree.
mus_pt().size()) best_mu = -1;
282 if(best_el != -1 && best_mu != -1){
283 if(tree.
els_pt().at(best_el) >= tree.
mus_pt().at(best_mu)){
296 Fix(tree, best_el, best_mu);
303 double max_pt = -1.0;
305 for(
size_t iel = 0; iel < tree.
els_eta().size(); ++iel){
306 if((fabs(tree.
els_eta().at(iel))<=1.479 && tree.els_reliso_r03().at(iel)<0.2179)
307 || (fabs(tree.
els_eta().at(iel))>1.479&& fabs(tree.
els_eta().at(iel))<2.5
308 && tree.els_reliso_r03().at(iel)<0.254)){
311 if(tree.
els_pt().at(iel) > max_pt){
312 max_pt = tree.
els_pt().at(iel);
324 double max_pt = -1.0;
326 for(
size_t imu = 0; imu < tree.mus_reliso_r04().size(); ++imu){
327 if(tree.mus_reliso_r04().at(imu) < 0.2){
330 if(tree.
mus_pt().at(imu) > max_pt){
331 max_pt = tree.
mus_pt().at(imu);
343 int leps =
MiniEl(tree, best_el);
344 leps +=
MiniMu(tree, best_mu);
345 Fix(tree, best_el, best_mu);
352 double max_pt = -1.0;
354 for(
size_t iel = 0; iel < tree.els_miniso_tr10().size(); ++iel){
355 if(min(tree.els_reliso_r02().at(iel),tree.els_miniso_tr10().at(iel)) <
SigMiniEl){
358 if(tree.
els_pt().at(iel) > max_pt){
359 max_pt = tree.
els_pt().at(iel);
370 double max_pt = -1.0;
372 for(
size_t imu = 0; imu < tree.mus_miniso_tr10().size(); ++imu){
373 if(min(tree.mus_reliso_r02().at(imu),tree.mus_miniso_tr10().at(imu)) <
SigMiniMu){
376 if(tree.
mus_pt().at(imu) > max_pt){
377 max_pt = tree.
mus_pt().at(imu);
390 Fix(tree, best_el, best_mu);
397 double max_pt = -1.0;
399 for(
size_t iel = 0; iel < tree.
els_eta().size(); ++iel){
400 if((fabs(tree.
els_eta().at(iel))<=1.479 && tree.els_reliso_r03().at(iel)<0.3313)
401 || (fabs(tree.
els_eta().at(iel))>1.479&& fabs(tree.
els_eta().at(iel))<2.5
402 && tree.els_reliso_r03().at(iel)<0.3816)){
403 if(!(tree.
els_ispf().at(iel)))
continue;
405 if(tree.
els_pt().at(iel) > max_pt){
406 max_pt = tree.
els_pt().at(iel);
418 double max_pt = -1.0;
420 for(
size_t imu = 0; imu < tree.mus_reliso_r04().size(); ++imu){
421 if(tree.mus_reliso_r04().at(imu) < 0.2){
423 if(tree.
mus_pt().at(imu) > max_pt){
424 max_pt = tree.
mus_pt().at(imu);
438 Fix(tree, best_el, best_mu);
445 double max_pt = -1.0;
447 for(
size_t iel = 0; iel < tree.els_miniso_tr10().size(); ++iel){
448 if(min(tree.els_reliso_r02().at(iel),tree.els_miniso_tr10().at(iel)) <
VetMiniEl){
449 if(!(tree.
els_ispf().at(iel)))
continue;
451 if(tree.
els_pt().at(iel) > max_pt){
452 max_pt = tree.
els_pt().at(iel);
463 double max_pt = -1.0;
465 for(
size_t imu = 0; imu < tree.mus_miniso_tr10().size(); ++imu){
466 if(min(tree.mus_reliso_r02().at(imu),tree.mus_miniso_tr10().at(imu)) <
VetMiniMu){
468 if(tree.
mus_pt().at(imu) > max_pt){
469 max_pt = tree.
mus_pt().at(imu);
478 const unsigned num_conts = 999;
479 const unsigned num_stops = 2;
480 double stops[num_stops] = {0., 1.};
481 double red[num_stops] = {1., 0.3};
482 double green[num_stops] = {1., 0.3};
483 double blue[num_stops] = {1., 1.};
484 gStyle->SetNumberContours(num_conts);
485 int index = TColor::CreateGradientColorTable(num_stops, stops, red, green, blue, num_conts);
486 for(
int i = 0; i < 999; ++i){
487 pos_cols[i] = index+i;
492 const unsigned num_conts = 999;
493 const unsigned num_stops = 3;
494 double stops[num_stops] = {0., 0.5, 1.};
495 double red[num_stops] = {1., 1., 0.};
496 double green[num_stops] = {0., 1., 1.};
497 double blue[num_stops] = {0., 1., 0.};
498 gStyle->SetNumberContours(num_conts);
499 int index = TColor::CreateGradientColorTable(num_stops, stops, red, green, blue, num_conts);
500 for(
int i = 0; i < 999; ++i){
501 sym_cols[i] = index+i;
506 line.SetLineWidth(4);
507 line.SetLineColor(1);
508 line.SetLineStyle(1);
const float SigLepPt(20.)
std::vector< bool > const & els_ispf() const
int VetoStandardMu(const small_tree &tree, int &best_mu)
const float VetMiniMu(0.025)
void Fix(const small_tree &tree, int &best_el, int &best_mu)
float const & weight() const
void SymmetricColors(int sym_cols[])
int MiniIso(const small_tree &tree, int &best_el, int &best_mu)
int VetoMiniMu(const small_tree &tree, int &best_mu)
std::vector< float > const & els_eta() const
std::vector< float > const & mus_phi() const
void PositiveColors(int pos_cols[])
std::vector< bool > const & els_sigid() const
int StandardEl(const small_tree &tree, int &best_el)
float const & met_phi() const
float const & met() const
const float SigMiniEl(0.12)
int VetoMiniIso(const small_tree &tree, int &best_el, int &best_mu)
int MiniEl(const small_tree &tree, int &best_el)
std::vector< float > const & mus_pt() const
void SetLineStyle(TLine &line)
int StandardMu(const small_tree &tree, int &best_mu)
Cut< T > * NewCut(small_tree const *tree, const T &(small_tree::*func)() const, const T &cut_val, InequalityType compare=kGreaterEqual)
int(* IsoCut)(const small_tree &, int &, int &)
const float VetMiniEl(0.12)
int VetoMiniEl(const small_tree &tree, int &best_el)
int const & njets() const
const float SigMiniMu(0.08)
std::vector< bool > const & mus_sigid() const
std::vector< float > const & els_phi() const
bool PassesCuts(const vector< CutBase * > &cuts)
int VetoStandardEl(const small_tree &tree, int &best_el)
float const & mindphin_metjet() const
int MiniMu(const small_tree &tree, int &best_mu)
int StandardIso(const small_tree &tree, int &best_el, int &best_mu)
virtual void GetEntry(const long entry)
int GetLeptons(const small_tree &tree, IsoCut cut, int &best_el, int &best_mu)
int VetoStandardIso(const small_tree &tree, int &best_el, int &best_mu)
std::vector< float > const & els_pt() const