ra4_macros  bede988c286599a3a84b77a4d788ac0a971e89f9
plot_eff_scan_1d.cxx
Go to the documentation of this file.
1 
3 #include <iostream>
4 #include <fstream>
5 #include <sstream>
6 #include <string>
7 
8 #include "TCanvas.h"
9 #include "TGraph2D.h"
10 #include "TH1D.h"
11 #include "TH2D.h"
12 #include "TStyle.h"
13 #include "TLegend.h"
14 #include "TFile.h"
15 
16 #include "utilities.hpp"
17 #include "styles.hpp"
18 
19 using namespace std;
20 
21 int main(){
22  styles style("RA4"); style.setDefaultStyle();
23  TCanvas can;
24 
25 
26  double xmin = 600;
27  double xmax = 2000;
28  double ymin = 0;
29  double ymax = 1400;
30  double bin_size = 10;
31  int nxbins = max(1, min(500, static_cast<int>(ceil((xmax-xmin)/bin_size))));
32  int nybins = max(1, min(500, static_cast<int>(ceil((ymax-ymin)/bin_size))));
33 
34  TFile gfile("t1tttt_eff.root");
35 
36  TGraph2D* geff = static_cast<TGraph2D*>(gfile.Get("effmap"));
37  geff->SetNpx(nxbins);
38  geff->SetNpy(nybins);
39 
40 
41  TH2D *heff = geff->GetHistogram();
42  if(heff == nullptr) {
43  cout<<endl<<"Could not retrieve histogram"<<endl<<endl;
44  return 1;
45  }
46  heff->SetTitle(";m_{gluino} [GeV];m_{LST} [GeV]; Efficiency");
47  heff->Draw("cont4z");
48 
49  int nbins=64;
50  float hmin=200, hmax=1800;
51  vector<float> glus = {1800, 1400, 1000};
52  vector<int> colors = {1,2,4};
53  vector<TH1D*> histos;
54  float eff_1l = 0.37;
55 
56  // Legend
57  double legSingle = 0.06;
58  double legX=style.PadLeftMargin+0.02, legY=1-style.PadTopMargin-0.02, legW=0.1, legH=legSingle*glus.size();
59  TLegend leg(legX,legY-legH, legX+legW, legY);
60  leg.SetTextSize(0.05); leg.SetFillColor(0); leg.SetBorderSize(0); leg.SetFillStyle(0);
61 
62  for(size_t iglu=0; iglu<glus.size(); iglu++){
63  TString hname = "histo"; hname += iglu;
64  TH1D* histo = new TH1D(hname,"",nbins,hmin,hmax);
65  histo->SetLineWidth(3); histo->SetLineColor(colors[iglu]);
66  histo->SetXTitle("m_{#tilde{g}} - m_{#chi^{0}_{1}} [GeV]");
67  histo->SetYTitle("Efficiency in R4 [%]");
68  for(int bin=1; bin<nbins; bin++){
69  float dm = histo->GetBinCenter(bin);
70  float mglu = (glus[iglu]+dm)/2., mlsp = (glus[iglu]-dm)/2.;
71  if(mlsp<0) continue;
72  float eff = 100*heff->GetBinContent(heff->FindBin(mglu, mlsp))/eff_1l;
73  //cout<<"Efficiency for mglu = "<<mglu<<", mlsp = "<<mlsp<<" is "<<eff<<" %"<<endl;
74  histo->SetBinContent(bin, eff);
75  }
76 
77  histos.push_back(histo);
78  leg.AddEntry(histo, "m_{#tilde{g}} + m_{#chi^{0}_{1}} = "+RoundNumber(glus[iglu],0)+" GeV");
79  if(iglu==0) histos[iglu]->Draw("");
80  else histos[iglu]->Draw("same");
81  }
82  leg.Draw();
83 
84  can.SaveAs("plots/eff_1d.pdf");
85 
86  leg.SetX1NDC(0.56); leg.SetX2NDC(0.56+legW);
87  float eff_step = 50;
88  for(size_t iglu=0; iglu<glus.size(); iglu++){
89  histos[iglu]->SetBinContent(0,0);
90  for(int bin=1; bin<nbins; bin++){
91  float dm0 = histos[iglu]->GetBinCenter(bin);
92  float dm1 = histos[iglu]->GetBinCenter(bin+1);
93  float valbin0 = histos[iglu]->GetBinContent(bin);
94  float valbin1 = histos[iglu]->GetBinContent(bin+1);
95  histos[iglu]->SetBinContent(bin, eff_step*(valbin1-valbin0)/(dm1-dm0));
96  float valbinm1 = histos[iglu]->GetBinContent(bin-1);
97  valbin0 = histos[iglu]->GetBinContent(bin);
98  histos[iglu]->SetBinContent(bin, (valbinm1+valbin0)/2);
99 
100  }
101  histos[iglu]->SetYTitle("Change in efficiency [%/("+RoundNumber(eff_step,0)+" GeV)]");
102  histos[iglu]->SetMinimum(-0.002*eff_step);
103  //histos[iglu]->SetMaximum(0.05*eff_step);
104  if(iglu==0) histos[iglu]->Draw("");
105  else histos[iglu]->Draw("same");
106  }
107  leg.Draw();
108 
109  can.SaveAs("plots/deff_1d.pdf");
110 
111 
112 }
void setDefaultStyle()
Definition: styles.cpp:36
float PadTopMargin
Definition: styles.hpp:36
STL namespace.
TString RoundNumber(double num, int decimals, double denom=1.)
Definition: utilities.cpp:191
int main()
int mlsp
Definition: make_cards.py:8
float PadLeftMargin
Definition: styles.hpp:36