2 #include "utilities.hh" 17 #include "TDirectory.h" 22 int main(
int argc,
char *argv[]){
27 cout<<endl<<
"Requires 1 argument: "<<
"./run/skim_scan_onefile.exe infile";
34 if (argc>1) outpath = argv[2];
37 TChain treeglobal(
"treeglobal");
38 treeglobal.Add(infiles);
42 outfolder.Remove(outfolder.Last(
'/')+1, outfolder.Length());
43 if(outfolder!=
"") gSystem->mkdir(outfolder, kTRUE);
46 TH2F * mass_plane =
new TH2F(
"mglu_vs_mlsp",
"mglu_vs_mlsp",3000,-0.5,2999.5,3000,-0.5,2999.5);
47 tree.Project(
"mglu_vs_mlsp",
"mgluino:mlsp",
"",
"colz");
50 int ini_x = mass_plane->FindFirstBinAbove(0,1);
51 int last_x = mass_plane->FindLastBinAbove(0,1);
52 int ini_y = mass_plane->FindFirstBinAbove(0,2);
53 int last_y = mass_plane->FindLastBinAbove(0,2);
56 vector<TString> pair_cuts;
57 vector<TString> mass_tag;
59 for(
int iy=ini_y; iy<=last_y; iy++){
60 for(
int ix=ini_x; ix<=last_x; ix++){
61 if(mass_plane->GetBinContent(ix,iy) > 0){
62 int mglui =
static_cast<int>(mass_plane->GetYaxis()->GetBinCenter(iy));
63 int mlsp =
static_cast<int>(mass_plane->GetXaxis()->GetBinCenter(ix));
64 pair_cuts.push_back(Form(
"mgluino==%i&&mlsp==%i",mglui,mlsp));
65 mass_tag.push_back(Form(
"mGluino-%i_mLSP-%i",mglui,mlsp));
66 cout<<
"Found mass point "<<mass_tag.back()<<endl;
77 int seconds(floor(difftime(curTime,startTime)+0.5));
78 cout<<endl<<
"Took "<<seconds<<
" seconds to fill chain, project and find the "<<Npoints<<
" mass pairs"<<endl<<endl;
81 for(
unsigned int ip = 0; ip<pair_cuts.size(); ip++){
88 if(outfile.Contains(
".root")) outfile.ReplaceAll(
".root",
"_"+pair_cuts.at(ip)+
".root");
89 else outfile += (
"_"+pair_cuts.at(ip)+
".root");
90 outfile.ReplaceAll(
">=",
"ge"); outfile.ReplaceAll(
"<=",
"se"); outfile.ReplaceAll(
"&&",
"_");
91 outfile.ReplaceAll(
">",
"g"); outfile.ReplaceAll(
"<",
"s"); outfile.ReplaceAll(
"=",
"");
92 outfile.ReplaceAll(
"(",
""); outfile.ReplaceAll(
")",
""); outfile.ReplaceAll(
"+",
"");
93 outfile.ReplaceAll(
"[",
""); outfile.ReplaceAll(
"]",
""); outfile.ReplaceAll(
"|",
"_");
94 outfile.ReplaceAll(
"/",
"");
98 outfile.ReplaceAll(
"MASS_TAG",mass_tag[ip]);
101 TFile out_rootfile(outfile.Data(),
"RECREATE");
102 if(out_rootfile.IsZombie() || !out_rootfile.IsOpen())
return 1;
106 TTree * ctree = tree.CopyTree(pair_cuts.at(ip));
107 TTree * ctreeglobal = treeglobal.CopyTree(
"1");
108 if(ctree) ctree->Write();
109 else cout<<
"Could not find tree in "<<infiles<<endl;
110 if(ctreeglobal) ctreeglobal->Write();
111 else cout<<
"Could not find treeglobal in "<<infiles<<endl;
115 int secs(floor(difftime(endloop,startloop)+0.5));
116 cout<<
"Written "<<outfile<<
" with "<<ctree->GetEntries()<<
" entries in "<<secs<<
" seconds"<<endl;
117 out_rootfile.Close();
120 cout<<
"Took "<< difftime(curTime,startTime)<<
" seconds to skim "<< pair_cuts.size()<<
" files."<<endl;
tuple infiles
Finding tags for each dataset.
int main(int argc, char *argv[])