babymaker  e95a6a9342d4604277fe7cc6149b6b5b24447d89
merge_glu_stop.cxx
Go to the documentation of this file.
1 // merge_glu_stop: Merges gluino and stop scans
2 
3 #include <iostream>
4 #include <ctime>
5 #include <string>
6 #include <vector>
7 
8 #include "TChain.h"
9 #include "TError.h"
10 #include "TSystem.h"
11 #include "TDirectory.h"
12 
13 #include "utilities.hh"
14 
15 using namespace std;
16 
17 int main(int argc, char *argv[]){
18  time_t begtime, endtime;
19  time(&begtime);
20 
21  if(argc<1){
22  cout<<"Format: ./run/merge_glu_stop.exe glufile <outfolder> <stopfolder>"<<endl;
23  return 1;
24  }
25 
26  // Take command line arguments
27  TString glufile, stopfolder("/net/cms2/cms2r0/babymaker/babies/2016_02_09/mc/T2tt/");
28  TString outfolder("mergedGluStop/");
29  if(argc>=2) glufile = argv[1];
30  if(argc>=3) outfolder=argv[2];
31  if(argc>=4) stopfolder=argv[3];
32  if(!outfolder.EndsWith("/")) outfolder.Append("/");
33  gSystem->mkdir(outfolder, kTRUE);
34 
35  TString outfile(glufile);
36  outfile.Remove(0, outfile.Last('/')+1);
37  outfile.ReplaceAll("T5tttt","T5tttt-Stop");
38  outfile = outfolder+"/"+outfile;
39 
40  // Parsing masses
41  TString mlsp_s(glufile);
42  mlsp_s.Remove(0,mlsp_s.Index("LSP-")+4);
43  mlsp_s.Remove(mlsp_s.Index('_'), mlsp_s.Length());
44  int mlsp(mlsp_s.Atoi());
45 
46  // Finding desired stop mass
47  int mstop = mlsp + 175;
48  TString stop_lsp("*mGluino-"+to_string(mstop)+"_mLSP-"+mlsp_s+"*");
49  vector<TString> stopfiles = dirlist(stopfolder, stop_lsp);
50  if(stopfiles.size()==0){
51  stopfolder = "new_stops/";
52  stopfiles = dirlist(stopfolder, stop_lsp);
53  }
54  if(stopfiles.size()==0 || stopfiles.size()>=2){
55  cout<<"Found "<<stopfiles.size()<<" files matching "<<stop_lsp<<". Exiting"<<endl<<endl;
56  exit(1);
57  }
58 
59  vector<TString> ntuples = {glufile, stopfolder+stopfiles[0]};
60  mergeNtuples(ntuples, outfile);
61  cout<<endl<<"Merged T5tttt and T2tt ntuples at "<<outfile<<endl;
62 
63  time(&endtime);
64  int seconds = difftime(endtime, begtime);
65  cout<<endl<<"Took "<<seconds<<" seconds ("<<hoursMinSec(seconds)<<") "<<endl<<endl;
66 }
TString hoursMinSec(long seconds)
Definition: utilities.cc:599
STL namespace.
int main(int argc, char *argv[])
void mergeNtuples(std::vector< TString > ntuples, TString outname)
Definition: utilities.cc:632
std::vector< TString > dirlist(const TString &folder, const TString &inname="dir", const TString &tag="")
Definition: utilities.cc:287