20 #include "TSystemDirectory.h" 21 #include "TSystemFile.h" 24 #include "TCollection.h" 36 if(file.Contains(
"T1tttt") && file.Contains(
"825_")) xsec = 1.2167;
37 if(file.Contains(
"T1tttt") && file.Contains(
"1025_")) xsec = 0.272778;
38 if(file.Contains(
"T1tttt") && file.Contains(
"1150_")) xsec = 0.117687;
39 if(file.Contains(
"T1tttt") && file.Contains(
"1200_")) xsec = 0.0856418;
40 if(file.Contains(
"T1tttt") && file.Contains(
"1500_")) xsec = 0.0141903;
42 if(file.Contains(
"T2tt") && file.Contains(
"650_")) xsec = 0.107045;
43 if(file.Contains(
"T2tt") && file.Contains(
"850_")) xsec = 0.0189612;
45 if(file.Contains(
"SMS-T2tt_2J_mStop-425_mLSP-325")) xsec = 1.31169;
46 if(file.Contains(
"SMS-T2tt_2J_mStop-500_mLSP-325")) xsec = 0.51848;
47 if(file.Contains(
"SMS-T1bbbb_2J_mGl-1500_mLSP-100")) xsec = 0.0141903;
48 if(file.Contains(
"SMS-T1bbbb_2J_mGl-1000_mLSP-900")) xsec = 0.325388;
49 if(file.Contains(
"SMS-T1qqqq_2J_mGl-1400_mLSP-100")) xsec = 0.0252977;
50 if(file.Contains(
"SMS-T1qqqq_2J_mGl-1000_mLSP-800")) xsec = 0.325388;
51 if(file.Contains(
"SMS-T2bb_2J_mStop-600_mLSP-580")) xsec = 0.174599;
52 if(file.Contains(
"SMS-T2bb_2J_mStop-900_mLSP-100")) xsec = 0.0128895;
56 if(file.Contains(
"TTJet") || file.Contains(
"TT_")) xsec = 815.96;
62 if(file.Contains(
"WJetsToLNu_HT-100to200")) xsec = 1817.0*1.23;
63 if(file.Contains(
"WJetsToLNu_HT-200to400")) xsec = 471.6*1.23;
64 if(file.Contains(
"WJetsToLNu_HT-400to600")) xsec = 55.61*1.23;
65 if(file.Contains(
"WJetsToLNu_HT-600toInf")) xsec = 18.81*1.23;
67 if(file.Contains(
"WToENu")) xsec = 16000.0;
68 if(file.Contains(
"WToMuNu")) xsec = 16100.0;
70 if(file.Contains(
"QCD_HT-100To250_13TeV-madgraph")) xsec = 28730000.;
71 if(file.Contains(
"QCD_HT_250To500_13TeV-madgraph")) xsec = 670500.0;
72 if(file.Contains(
"QCD_HT-500To1000_13TeV-madgraph")) xsec = 26740.0;
73 if(file.Contains(
"QCD_HT_1000ToInf_13TeV-madgraph")) xsec = 769.7;
75 if(file.Contains(
"QCD_Pt-1800_")) xsec = 0.1091;
77 if(file.Contains(
"QCD_Pt-5to10")) xsec = 80710000000;
78 if(file.Contains(
"QCD_Pt-10to15")) xsec = 7528000000;
79 if(file.Contains(
"QCD_Pt-15to30")) xsec = 2237000000;
80 if(file.Contains(
"QCD_Pt-30to50")) xsec = 161500000;
81 if(file.Contains(
"QCD_Pt-50to80")) xsec = 22110000;
82 if(file.Contains(
"QCD_Pt-80to120")) xsec = 3000114.3;
83 if(file.Contains(
"QCD_Pt-120to170")) xsec = 493200;
84 if(file.Contains(
"QCD_Pt-170to300")) xsec = 120300;
85 if(file.Contains(
"QCD_Pt-300to470")) xsec = 7475;
86 if(file.Contains(
"QCD_Pt-470to600")) xsec = 587.1;
87 if(file.Contains(
"QCD_Pt-600to800")) xsec = 167;
88 if(file.Contains(
"QCD_Pt-800to1000")) xsec = 28.25;
89 if(file.Contains(
"QCD_Pt-1000to1400")) xsec = 8.195;
90 if(file.Contains(
"QCD_Pt-1400to1800")) xsec = 0.7346;
91 if(file.Contains(
"QCD_Pt-1800to2400")) xsec = 0.102;
92 if(file.Contains(
"QCD_Pt-2400to3200")) xsec = 0.00644;
93 if(file.Contains(
"QCD_Pt-3200")) xsec = 0.000163;
95 if(file.Contains(
"TToLeptons_s-channel")) xsec = 2.0;
96 if(file.Contains(
"TToLeptons_t-channel")) xsec = 103.4;
97 if(file.Contains(
"T_tW-channel-DR")) xsec = 35.0;
98 if(file.Contains(
"TBarToLeptons_s-channel")) xsec = 1.0;
99 if(file.Contains(
"TBarToLeptons_t-channel")) xsec = 61.6;
100 if(file.Contains(
"Tbar_tW-channel-DR")) xsec = 35.0;
102 if(file.Contains(
"DYJetsToLL_M-50_HT-100to200")) xsec = 194.3*1.27;
103 if(file.Contains(
"DYJetsToLL_M-50_HT-200to400")) xsec = 52.24*1.27;
104 if(file.Contains(
"DYJetsToLL_M-50_HT-400to600")) xsec = 6.546*1.27;
105 if(file.Contains(
"DYJetsToLL_M-50_HT-600toInf")) xsec = 2.179*1.27;
107 if(file.Contains(
"ZJetsToNuNu_HT-100to200_Tune4C_13TeV-madgraph-tauola")) xsec =372.6*1.27;
108 if(file.Contains(
"ZJetsToNuNu_HT-200to400_Tune4C_13TeV-madgraph-tauola")) xsec =100.8*1.27;
109 if(file.Contains(
"ZJetsToNuNu_HT-400to600_Tune4C_13TeV-madgraph-tauola")) xsec =11.99*1.27;
110 if(file.Contains(
"ZJetsToNuNu_HT-600toInf_Tune4C_13TeV-madgraph-tauola")) xsec =4.113*1.27;
112 if(file.Contains(
"TTZJets_Tune4C_13TeV-madgraph-tauola")) xsec = 0.7598;
113 if(file.Contains(
"TTWJets_Tune4C_13TeV-madgraph-tauola")) xsec = 0.5662;
118 if(file.Contains(
"ZH_HToBB_ZToLL_M-125_13TeV_powheg-herwigpp")) xsec = 0.569*0.033658*0.8696;
119 if(file.Contains(
"ZH_HToBB_ZToNuNu_M-125_13TeV_powheg-herwigpp")) xsec = 0.569*0.2*0.8696;
120 if(file.Contains(
"WH_HToBB_WToLNu_M-125_13TeV_powheg-herwigpp")) xsec = 0.569*0.1086*1.380;
122 if(xsec<=0) cout<<
"Cross section not found for "<<file<<endl;
128 vector<TString>
dirlist(
const TString &folder,
129 const TString &inname,
131 TString pwd(gSystem->pwd());
132 vector<TString> v_dirs;
133 TSystemDirectory dir(folder, folder);
134 TList *files = dir.GetListOfFiles();
139 while ((file=static_cast<TSystemFile*>(next()))) {
140 fname = file->GetName();
142 if ((file->IsDirectory() && !fname.Contains(
".") && fname.Contains(tag))) v_dirs.push_back(fname);
143 }
else if(fname.Contains(inname)) v_dirs.push_back(fname);
150 bool eigen2x2(
float matrix[2][2],
float &eig1,
float &eig2){
151 float root = pow(matrix[0][0],2) + pow(matrix[1][1],2)-2*matrix[0][0]*matrix[1][1]+4*matrix[0][1]*matrix[1][0];
152 if(root<0)
return false;
154 eig1 = (matrix[0][0]+matrix[1][1]+sqrt(root))/2.;
155 eig2 = (matrix[0][0]+matrix[1][1]-sqrt(root))/2.;
160 return left.second > right.second;
164 return left.first < right.first;
168 return left.first > right.first;
171 long double DeltaPhi(
long double phi1,
long double phi2){
172 long double dphi = fmod(fabs(phi2-phi1), 2.L*
PI);
173 return dphi>PI ? 2.L*PI-dphi : dphi;
177 long double dphi = fmod(phi2-phi1, 2.L*
PI);
187 float dR(
float eta1,
float eta2,
float phi1,
float phi2) {
192 if(denom==0)
return " - ";
193 double neg = 1;
if(num*denom<0) neg = -1;
194 num /= neg*denom; num += 0.5*pow(10.,-decimals);
195 long num_int =
static_cast<long>(
num);
196 long num_dec =
static_cast<long>((1+num-num_int)*pow(10.,decimals));
197 TString s_dec =
""; s_dec += num_dec; s_dec.Remove(0,1);
199 if(neg<0) result+=
"-";
202 result+=
"."; result+=s_dec;
205 TString afterdot = result;
206 afterdot.Remove(0,afterdot.First(
".")+1);
207 for(
int i=0; i<decimals-afterdot.Length(); i++)
214 const long double temp = y;
219 const long double rat=y/x;
220 return fabs(x)*sqrt(1.0L+rat*rat);
223 long double GetMass(
long double e,
long double px,
long double py,
long double pz){
225 return fabs(e)*sqrt(1.0L-px*px-py*py-pz*pz);
228 long double GetMT(
long double m1,
long double pt1,
long double phi1,
229 long double m2,
long double pt2,
long double phi2){
230 return sqrt(m1*m1+m2*m2+2.L*(sqrt((m1*m1+pt1*pt1)*(m2*m2+pt2*pt2))-pt1*pt2*cos(phi2-phi1)));
233 long double GetMT(
long double pt1,
long double phi1,
234 long double pt2,
long double phi2){
236 return sqrt(2.L*pt1*pt2*(1.L-cos(phi2-phi1)));
239 bool Contains(
const string& text,
const string& pattern){
240 return text.find(pattern) != string::npos;
244 const string& tokens){
245 char* ipt(
new char[input.size()+1]);
246 memcpy(ipt, input.data(), input.size());
247 ipt[input.size()]=
static_cast<char>(0);
248 char* ptr(strtok(ipt, tokens.c_str()));
249 vector<string> output(0);
251 output.push_back(ptr);
252 ptr=strtok(NULL, tokens.c_str());
260 double& uncertainty){
261 const string hist_name(
"temp");
262 TH1D temp(hist_name.c_str(),
"", 1, -1.0, 1.0);
263 tree.Project(hist_name.c_str(),
"0.0", cut.c_str());
264 count=temp.IntegralAndError(0,2,uncertainty);
268 graph.SetPoint(graph.GetN(), x, y);
272 FILE *pipe = popen(cmd.c_str(),
"r");
273 if(!pipe)
throw runtime_error(
"Could not open pipe.");
274 const size_t buffer_size = 128;
275 char buffer[buffer_size];
278 if(fgets(buffer, buffer_size, pipe) != NULL) result += buffer;
286 while(!str.empty() && str.at(str.length()-1) ==
'\n'){
287 str.erase(str.length()-1);
293 vector<double> pts(npts,low+0.5*(high-low));
295 double gap = (high-low)/(npts-1.0);
296 for(
size_t pt = 0; pt < npts; ++pt){
297 pts.at(pt) = low+pt*gap;
bool dd_small2big(const double_double &left, const double_double &right)
TString RoundNumber(double num, int decimals, double denom)
diff git a run rpv_bkg_syst py b run rpv_bkg_syst py index a run rpv_bkg_syst py b run rpv_bkg_syst py
bool Contains(const string &text, const string &pattern)
bool id_big2small(const int_double &left, const int_double &right)
void get_count_and_uncertainty(TTree &tree, const string &cut, double &count, double &uncertainty)
long double SignedDeltaPhi(long double phi1, long double phi2)
vector< TString > dirlist(const TString &folder, const TString &inname, const TString &tag)
long double GetMass(long double e, long double px, long double py, long double pz)
long double AddInQuadrature(long double x, long double y)
vector< string > Tokenize(const string &input, const string &tokens)
long double GetMT(long double m1, long double pt1, long double phi1, long double m2, long double pt2, long double phi2)
long double DeltaPhi(long double phi1, long double phi2)
bool dd_big2small(const double_double &left, const double_double &right)
std::pair< int, double > int_double
void AddPoint(TGraph &graph, const double x, const double y)
std::pair< double, double > double_double
vector< double > LinearSpacing(size_t npts, double low, double high)
float cross_section(const TString &file)
bool eigen2x2(float matrix[2][2], float &eig1, float &eig2)
float dR(float eta1, float eta2, float phi1, float phi2)
string RemoveTrailingNewlines(string str)
string execute(const string &cmd)