// 1. merge background files // 2. make PS with weights // 3. printout nentries and nweightedentries // Root related #include "TSystem.h" #include "TObject.h" #include "TObjArray.h" #include "TObjString.h" #include "TDirectory.h" #include "TKey.h" #include "TIterator.h" #include "TList.h" #include "TString.h" #include "TCollection.h" #include "TStyle.h" #include "TROOT.h" #include "TPad.h" #include "Riostream.h" #include "TLegend.h" #include "TH1.h" TString ParseInputLine(TString& readline) { std::string delim = "]//"; TString histoname; std::vector result; TObjArray *tokens = readline.Tokenize(delim.c_str()); TObject *p; { TIter iter(tokens); while(p = iter.Next()) { TObjString *item = (TObjString*)p; TString pbackitem = item->GetString(); pbackitem = pbackitem.Strip(TString::kBoth); result.push_back(pbackitem.Data()); } } delete tokens; if(result.size() > 1) { histoname = result[1].data(); } return histoname; } BackgroundControlPlots(const char *version, const char *process) { gStyle->SetOptStat(0); gROOT->ForceStyle(); char* outpath = "./ps/"; //write control plots to.. char* path2 = "./rootuples/"; //read rootuples from... char path[256]; float Lumi = 1050.81; double WjjScale=1.4; double WbbScale=1.; double WccScale=1.; double ZjjScale=1.3; double ZbbScale=1.35; double ZccScale=1.35; if(process == "wjj") { // gStyle->SetOptStat(222222222); std::string temp; TString line,histname; TFile *wjj[6]; char psfile[256]; sprintf(psfile,"%s%swjj.ps",outpath,version); TCanvas *tempC = new TCanvas("","",600,800); tempC->SetFillColor(0); tempC->SetFillStyle(4000); TPostScript* PS = new TPostScript(psfile,111); gROOT->SetStyle("Plain"); PS -> NewPage(); sprintf(path,"%s%swlepnu0lp_exclMCmu.root",path2,version); wjj[0] = new TFile(path); sprintf(path,"%s%swlepnu1lp_exclMCmu.root",path2,version); wjj[1] = new TFile(path); sprintf(path,"%s%swlepnu2lp_exclMCmu.root",path2,version); wjj[2] = new TFile(path); sprintf(path,"%s%swlepnu3lp_exclMCmu.root",path2,version); wjj[3] = new TFile(path); sprintf(path,"%s%swlepnu4lp_exclMCmu.root",path2,version); wjj[4] = new TFile(path); sprintf(path,"%s%swlepnu5lp_inclMCmu.root",path2,version); wjj[5] = new TFile(path); TH1F *hL[6]; TH1F *hT[6]; double scale[6]; scale[0]=WjjScale*298.5643*Lumi/1563955; scale[1]=WjjScale*4574.3616*Lumi/2257330; scale[2]=WjjScale*1273.94*Lumi/2754645; scale[3]=WjjScale*70.5607*Lumi/789021; scale[4]=WjjScale*15.8305*Lumi/778522; scale[5]=WjjScale*11.2901*Lumi/57973; ifstream fstr("./TestNames",ios::in); while ( fstr.good() && fstr ) { getline(fstr,temp); line = temp.c_str(); histname = ParseInputLine(line); for(int file=0 ; file < 6 ; file++) { if(wjj[file] == NULL) { wjj[file] = new TFile("./rootuples/dummymacro.root"); scale[file] = 0; cout << "::WARNING:: At least one missing file for process wjj" << endl; } hL[file] = (TH1F *) wjj[file]->Get(Form(histname.Data(),0,0,0)); hT[file] = (TH1F *) wjj[file]->Get(Form(histname.Data(),0,1,0)); } if(hL[0] && hT[0] && hL[1] && hT[1] && hL[2] && hT[2] && hL[3] && hT[3] && hL[4] && hT[4] && hL[5] && hT[5]) { for(int file=0 ; file < 6 ; file++) { hL[file]->UseCurrentStyle(); hT[file]->UseCurrentStyle(); } hL[0]->Scale(scale[0]); hL[0]->Add(hL[1],scale[1]); hL[0]->Add(hL[2],scale[2]); hL[0]->Add(hL[3],scale[3]); hL[0]->Add(hL[4],scale[4]); hL[0]->Add(hL[5],scale[5]); hT[0]->Scale(scale[0]); hT[0]->Add(hT[1],scale[1]); hT[0]->Add(hT[2],scale[2]); hT[0]->Add(hT[3],scale[3]); hT[0]->Add(hT[4],scale[4]); hT[0]->Add(hT[5],scale[5]); tempC -> Divide(1,2); tempC -> cd(1); hL[0] -> Draw(); tempC -> Update(); tempC -> cd(2); hT[0] -> Draw(); tempC -> Update(); tempC -> Clear(); } } tempC -> Close(); PS -> Close(); //gROOT -> SetBatch(kFALSE); fstr.close(); } }