babymaker  e95a6a9342d4604277fe7cc6149b6b5b24447d89
find_w_isr.cxx
Go to the documentation of this file.
1 // find_w_isr: Finds the average w_isr in the TTJets HT bins for renormalization
2 
3 
4 #include "utilities.hh"
5 
6 #include <ctime>
7 #include <fstream>
8 #include <iostream>
9 #include <vector>
10 
11 #include "TChain.h"
12 #include "TString.h"
13 #include "TH1D.h"
14 
15 using namespace std;
16 
17 
18 int main(){
19  time_t startTime;
20  time(&startTime);
21 
22  TString hname="histo";
23  TH1D histo(hname,"",1000,0,1.5);
24  TString folder="/net/cms26/cms26r0/babymaker/babies/2016_08_10/to_renormalize/manuelf/tt/";
25  vector<TString> files({"TTJets_Tune", "TTJets_HT-600to800", "TTJets_HT-800to1200", "TTJets_HT-1200to2500",
26  "TTJets_HT-2500toInf"});
27  vector<TString> vars({"w_isr", "sys_isr[0]", "sys_isr[1]"});
28  vector<double> average;
29 
30  vector<TChain*> chains;
31  for(size_t ind=0; ind<files.size(); ind++){
32  chains.push_back(new TChain("tree"));
33  chains.back()->Add(folder+"/*"+files[ind]+"*.root");
34  // cout<<endl<<"== "<<files[ind]<<": "<<addCommas(chains.back()->GetEntries())<<" entries in "
35  // <<nfiles<<" files"<<endl;
36  if(ind>0) cout<<" if(sample.Contains(\""<<files[ind]<<"\")) {"<<endl;
37  for(size_t ivar=0; ivar<vars.size(); ivar++){
38  chains.back()->Project(hname, vars[ivar],"","goff");
39  double mean = histo.GetMean();
40  if(ind==0) average.push_back(mean);
41  else {
42  TString wanted = "wanted_"+vars[ivar];
43  //wanted.ReplaceAll("[",""); wanted.ReplaceAll("]","");
44  cout<<" "<<wanted<<" = "<<roundNumber(mean,4,average[ivar])<<";"<<endl;
45  }
46  } // Loop over variables
47  if(ind>0) cout<<" }"<<endl;
48  }
49 
50 
51 
52  time_t curTime;
53  time(&curTime);
54  int seconds = difftime(curTime,startTime);
55  cout<<endl<<"Took "<< seconds << " seconds ("<<hoursMinSec(seconds)<<") to find average weights"<<endl<<endl;
56 }
57 
TString hoursMinSec(long seconds)
Definition: utilities.cc:599
STL namespace.
int main()
Definition: find_w_isr.cxx:18
TString roundNumber(double num, int decimals, double denom=1.)
Definition: utilities.cc:478
tuple ind
Definition: resubmit.py:140