16 #include "TSystemDirectory.h" 17 #include "TSystemFile.h" 20 #include "TCollection.h" 31 if(file.Contains(
"Run2015")) xsec = 1.;
35 if(file.Contains(
"T1tttt") && file.Contains(
"825_")) xsec = 1.2167;
36 if(file.Contains(
"T1tttt") && file.Contains(
"1025_")) xsec = 0.272778;
37 if(file.Contains(
"T1tttt") && file.Contains(
"1150_")) xsec = 0.117687;
38 if(file.Contains(
"T1tttt") && file.Contains(
"1200_")) xsec = 0.0856418;
39 if(file.Contains(
"T1tttt") && file.Contains(
"1500_")) xsec = 0.0141903;
41 if(file.Contains(
"T2tt") && file.Contains(
"650_")) xsec = 0.107045;
42 if(file.Contains(
"T2tt") && file.Contains(
"850_")) xsec = 0.0189612;
44 if(file.Contains(
"SMS-T2tt_2J_mStop-425_mLSP-325")) xsec = 1.31169;
45 if(file.Contains(
"SMS-T2tt_2J_mStop-500_mLSP-325")) xsec = 0.51848;
46 if(file.Contains(
"SMS-T1bbbb_2J_mGl-1500_mLSP-100")) xsec = 0.0141903;
47 if(file.Contains(
"SMS-T1bbbb_2J_mGl-1000_mLSP-900")) xsec = 0.325388;
48 if(file.Contains(
"SMS-T1qqqq_2J_mGl-1400_mLSP-100")) xsec = 0.0252977;
49 if(file.Contains(
"SMS-T1qqqq_2J_mGl-1000_mLSP-800")) xsec = 0.325388;
50 if(file.Contains(
"SMS-T2bb_2J_mStop-600_mLSP-580")) xsec = 0.174599;
51 if(file.Contains(
"SMS-T2bb_2J_mStop-900_mLSP-100")) xsec = 0.0128895;
55 if(file.Contains(
"TTJets_Tune") || file.Contains(
"TT_")) xsec = 815.96;
56 if(file.Contains(
"TTJets_HT")){
57 if(file.Contains(
"2500toInf")) xsec = 0.0023234211;
58 if(file.Contains(
"1200to2500")) xsec = 0.194972521;
59 if(file.Contains(
"800to1200")) xsec = 1.07722318;
60 if(file.Contains(
"600to800")) xsec = 2.61537118;
64 if(file.Contains(
"TTJets_DiLept")) xsec = 85.66;
65 if(file.Contains(
"TTJets_SingleLept")) xsec = 178.7;
75 if(file.Contains(
"WJetsToLNu") && file.Contains(
"amcatnloFXFX")) xsec=61526.7;
78 if (file.Contains(
"RunIISpring15DR74")){
79 if(file.Contains(
"WJetsToLNu_HT-100To200")) xsec = 1347.*1.21;
80 if(file.Contains(
"WJetsToLNu_HT-200To400")) xsec = 360.*1.21;
81 if(file.Contains(
"WJetsToLNu_HT-400To600")) xsec = 48.9*1.21;
82 if(file.Contains(
"WJetsToLNu_HT-600ToInf")) xsec = 18.77*1.21;
84 if(file.Contains(
"WJetsToLNu_HT-100to200")) xsec = 1817.0*1.23;
85 if(file.Contains(
"WJetsToLNu_HT-200to400")) xsec = 471.6*1.23;
86 if(file.Contains(
"WJetsToLNu_HT-400to600")) xsec = 55.61*1.23;
87 if(file.Contains(
"WJetsToLNu_HT-600toInf")) xsec = 18.81*1.23;
89 if(file.Contains(
"WToENu")) xsec = 16000.0;
90 if(file.Contains(
"WToMuNu")) xsec = 16100.0;
92 if(file.Contains(
"QCD_HT-100To250_13TeV-madgraph")) xsec = 28730000.;
93 if(file.Contains(
"QCD_HT_250To500_13TeV-madgraph")) xsec = 670500.0;
94 if(file.Contains(
"QCD_HT-500To1000_13TeV-madgraph")) xsec = 26740.0;
95 if(file.Contains(
"QCD_HT_1000ToInf_13TeV-madgraph")) xsec = 769.7;
97 if(file.Contains(
"QCD_HT200to300_TuneCUETP8M1_13TeV-madgraphMLM-pythia8")) xsec = 1735000;
98 if(file.Contains(
"QCD_HT300to500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8")) xsec = 366800;
99 if(file.Contains(
"QCD_HT500to700_TuneCUETP8M1_13TeV-madgraphMLM-pythia8")) xsec = 29370;
100 if(file.Contains(
"QCD_HT700to1000_TuneCUETP8M1_13TeV-madgraphMLM-pythia8")) xsec = 6524;
101 if(file.Contains(
"QCD_HT1000to1500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8")) xsec = 1064;
102 if(file.Contains(
"QCD_HT1500to2000_TuneCUETP8M1_13TeV-madgraphMLM-pythia8")) xsec = 121.5;
103 if(file.Contains(
"QCD_HT2000toInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8")) xsec = 25.42;
105 if(file.Contains(
"QCD_Pt-1800_")) xsec = 0.1091;
108 if (file.Contains(
"QCD_Pt")){
109 if(file.Contains(
"5to10")) xsec = 80710000000;
110 if(file.Contains(
"10to15")) xsec = 7528000000;
111 if(file.Contains(
"15to30")) xsec = 2237000000;
112 if(file.Contains(
"30to50")) xsec = 161500000;
113 if(file.Contains(
"50to80")) xsec = 22110000;
114 if(file.Contains(
"80to120")) xsec = 2762530;
115 if(file.Contains(
"120to170")) xsec = 471100;
116 if(file.Contains(
"170to300")) xsec = 117276;
117 if(file.Contains(
"300to470")) xsec = 7823;
118 if(file.Contains(
"470to600")) xsec = 648.2;
119 if(file.Contains(
"600to800")) xsec = 186.9;
120 if(file.Contains(
"800to1000")) xsec = 32.293;
121 if(file.Contains(
"1000to1400")) xsec = 9.4183;
122 if(file.Contains(
"1400to1800")) xsec = 0.84265;
123 if(file.Contains(
"1800to2400")) xsec = 0.114943;
124 if(file.Contains(
"2400to3200")) xsec = 0.00682981;
125 if(file.Contains(
"3200toInf")) xsec = 0.000165445;
130 if (file.Contains(
"RunIISpring15DR74")){
131 if (file.Contains(
"ST_s-channel_4f_leptonDecays_13TeV-amcatnlo-pythia8")) xsec = 3.34;
132 if (file.Contains(
"ST_t-channel_antitop_4f_leptonDecays_13TeV-powheg-pythia8")) xsec = 26.23;
133 if (file.Contains(
"ST_t-channel_top_4f_leptonDecays_13TeV-powheg-pythia8")) xsec = 44.07;
134 if (file.Contains(
"ST_tW_antitop_5f_inclusiveDecays_13TeV-powheg-pythia8")) xsec = 35.8;
135 if (file.Contains(
"ST_tW_top_5f_inclusiveDecays_13TeV-powheg-pythia8")) xsec = 35.8;
137 if(file.Contains(
"TBarToLeptons_s-channel")) xsec = 1.29;
138 if(file.Contains(
"TToLeptons_s-channel")) xsec = 2.06;
139 if(file.Contains(
"TBarToLeptons_t-channel")) xsec = 26.23;
140 if(file.Contains(
"TToLeptons_t-channel")) xsec = 44.07;
141 if(file.Contains(
"Tbar_tW-channel-DR")) xsec = 35.8;
142 if(file.Contains(
"T_tW-channel-DR")) xsec = 35.8;
145 if(file.Contains(
"DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8")) xsec = 18610;
146 if(file.Contains(
"DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8")) xsec = 6104;
148 if(file.Contains(
"madgraphMLM")){
149 if(file.Contains(
"DYJetsToLL_M-50_HT-100to200")) xsec = 171.46;
150 if(file.Contains(
"DYJetsToLL_M-50_HT-200to400")) xsec = 52.58;
151 if(file.Contains(
"DYJetsToLL_M-50_HT-400to600")) xsec = 6.761;
152 if(file.Contains(
"DYJetsToLL_M-50_HT-600toInf")) xsec = 2.713;
155 if(file.Contains(
"DYJetsToLL_M-50_HT-100to200")) xsec = 194.3*1.27;
156 if(file.Contains(
"DYJetsToLL_M-50_HT-200to400")) xsec = 52.24*1.27;
157 if(file.Contains(
"DYJetsToLL_M-50_HT-400to600")) xsec = 6.546*1.27;
158 if(file.Contains(
"DYJetsToLL_M-50_HT-600toInf")) xsec = 2.179*1.27;
161 if(file.Contains(
"ZJetsToNuNu_HT-100to200_Tune4C_13TeV-madgraph-tauola")) xsec =372.6*1.27;
162 if(file.Contains(
"ZJetsToNuNu_HT-200to400_Tune4C_13TeV-madgraph-tauola")) xsec =100.8*1.27;
163 if(file.Contains(
"ZJetsToNuNu_HT-400to600_Tune4C_13TeV-madgraph-tauola")) xsec =11.99*1.27;
164 if(file.Contains(
"ZJetsToNuNu_HT-600toInf_Tune4C_13TeV-madgraph-tauola")) xsec =4.113*1.27;
166 if(file.Contains(
"TTZJets_Tune4C_13TeV-madgraph-tauola")) xsec = 0.7598;
167 if(file.Contains(
"TTWJets_Tune4C_13TeV-madgraph-tauola")) xsec = 0.5662;
172 if(file.Contains(
"ZH_HToBB_ZToLL_M-125_13TeV_powheg-herwigpp")) xsec = 0.569*0.033658*0.8696;
173 if(file.Contains(
"ZH_HToBB_ZToNuNu_M-125_13TeV_powheg-herwigpp")) xsec = 0.569*0.2*0.8696;
174 if(file.Contains(
"WH_HToBB_WToLNu_M-125_13TeV_powheg-herwigpp")) xsec = 0.569*0.1086*1.380;
176 if(xsec<=0) cout<<
"Cross section not found for "<<file<<endl;
182 vector<TString>
dirlist(
const TString &folder,
183 const TString &inname,
185 TString pwd(gSystem->pwd());
186 vector<TString> v_dirs;
187 TSystemDirectory dir(folder, folder);
188 TList *
files = dir.GetListOfFiles();
193 while ((file=static_cast<TSystemFile*>(next()))) {
194 fname = file->GetName();
196 if ((file->IsDirectory() && !fname.Contains(
".") && fname.Contains(tag))) v_dirs.push_back(fname);
197 }
else if(fname.Contains(inname)) v_dirs.push_back(fname);
204 bool eigen2x2(
float matrix[2][2],
float &eig1,
float &eig2){
205 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];
206 if(root<0)
return false;
208 eig1 = (matrix[0][0]+matrix[1][1]+sqrt(root))/2.;
209 eig2 = (matrix[0][0]+matrix[1][1]-sqrt(root))/2.;
214 return left.second > right.second;
218 return left.first < right.first;
222 return left.first > right.first;
225 long double DeltaPhi(
long double phi1,
long double phi2){
226 long double dphi = fmod(fabs(phi2-phi1), 2.L*
PI);
227 return dphi>PI ? 2.L*PI-dphi : dphi;
231 long double dphi = fmod(phi2-phi1, 2.L*
PI);
241 float dR(
float eta1,
float eta2,
float phi1,
float phi2) {
246 if(denom==0)
return " - ";
247 double neg = 1;
if(num*denom<0) neg = -1;
248 num /= neg*denom; num += 0.5*pow(10.,-decimals);
249 long num_int =
static_cast<long>(num);
250 long num_dec =
static_cast<long>((1+num-num_int)*pow(10.,decimals));
251 TString s_dec =
""; s_dec += num_dec; s_dec.Remove(0,1);
253 if(neg<0) result+=
"-";
256 result+=
"."; result+=s_dec;
259 TString afterdot = result;
260 afterdot.Remove(0,afterdot.First(
".")+1);
261 for(
int i=0; i<decimals-afterdot.Length(); i++)
267 TString result(
""); result += num;
268 int posdot(result.First(
'.'));
269 if(posdot==-1) posdot = result.Length();
270 for(
int ind(posdot-3); ind > 0; ind -= 3)
271 result.Insert(ind,
",");
277 const long double temp = y;
282 const long double rat=y/x;
283 return fabs(x)*sqrt(1.0L+rat*rat);
286 long double GetMass(
long double e,
long double px,
long double py,
long double pz){
288 return fabs(e)*sqrt(1.0L-px*px-py*py-pz*pz);
291 long double GetMT(
long double m1,
long double pt1,
long double phi1,
292 long double m2,
long double pt2,
long double phi2){
293 return sqrt(m1*m1+m2*m2+2.L*(sqrt((m1*m1+pt1*pt1)*(m2*m2+pt2*pt2))-pt1*pt2*cos(phi2-phi1)));
296 long double GetMT(
long double pt1,
long double phi1,
297 long double pt2,
long double phi2){
299 return sqrt(2.L*pt1*pt2*(1.L-cos(phi2-phi1)));
302 bool Contains(
const string& text,
const string& pattern){
303 return text.find(pattern) != string::npos;
307 const string& tokens){
308 char* ipt(
new char[input.size()+1]);
309 memcpy(ipt, input.data(), input.size());
310 ipt[input.size()]=
static_cast<char>(0);
311 char* ptr(strtok(ipt, tokens.c_str()));
312 vector<string> output(0);
314 output.push_back(ptr);
315 ptr=strtok(NULL, tokens.c_str());
323 double& uncertainty){
324 const string hist_name(
"temp");
325 TH1D temp(hist_name.c_str(),
"", 1, -1.0, 1.0);
326 tree.Project(hist_name.c_str(),
"0.0", cut.c_str());
327 count=temp.IntegralAndError(0,2,uncertainty);
330 void AddPoint(TGraph& graph,
const double x,
const double y){
331 graph.SetPoint(graph.GetN(), x, y);
335 FILE *pipe = popen(cmd.c_str(),
"r");
336 if(!pipe)
throw runtime_error(
"Could not open pipe.");
337 const size_t buffer_size = 128;
338 char buffer[buffer_size];
341 if(fgets(buffer, buffer_size, pipe) != NULL) result += buffer;
349 while(!str.empty() && str.at(str.length()-1) ==
'\n'){
350 str.erase(str.length()-1);
356 vector<double> pts(npts,low+0.5*(high-low));
358 double gap = (high-low)/(npts-1.0);
359 for(
size_t pt = 0; pt < npts; ++pt){
360 pts.at(pt) = low+pt*gap;
bool dd_small2big(const double_double &left, const double_double &right)
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)
TString addCommas(double num)
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)
TString roundNumber(double num, int decimals, double denom)
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)