ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/ikstest.cc
(Generate patch)

Comparing UserCode/Jeng/scripts/ikstest.cc (file contents):
Revision 1.5 by jengbou, Tue Sep 7 03:59:59 2010 UTC vs.
Revision 1.6 by jengbou, Tue Sep 7 05:18:46 2010 UTC

# Line 1 | Line 1
1   #include "ikstest.h"
2 + #include "TopStyle/CMSTopStyle.cc"
3  
4   //=================================
5   // Program to run IKS test
# Line 28 | Line 29 | const Double_t procWjets   = 1.03;
29   const Double_t procttjets  = 1.0;
30  
31   // Output directory
32 < TString desDir = "Results_2.88pb-1/";
32 > TString baseDir = "Results_2.88pb-1/";
33   // User defined parameters
34 < bool useInv    = false; // whether to use n-1 QCD template
34 > bool useInv    = true; // whether to use n-1 QCD template
35   bool realData  = false;
36   // Ntuples to use
37 < TString suffix = "Sel0"; // Suffix of selection
37 > TString suffix = "Sel4"; // Suffix of selection
38   TString invNames[2] = {"RelIsogt0p1","D0gt0p02"};
39   map<TString,TCanvas*> cvs; // map of usual histogram
40  
# Line 41 | Line 42 | map<TString,TCanvas*> cvs; // map of usu
42   // Main program
43   //=================================
44   void ikstest() {
45 +  CMSTopStyle style;
46    gROOT->SetStyle("CMS");
47    TLatex *latex = new TLatex();
48    latex->SetNDC();
49 <  TString invName;
49 >
50    int size_ninv = (useInv ? 2 : 1);
51    for (int ninv = 0;ninv < size_ninv; ++ninv) {
52 <    invName = invNames[ninv];
52 >    TString invName = invNames[ninv];
53 >    TString desDir;
54      if (!useInv) {
55 <      if (!realData) desDir += "MC/";
56 <      else desDir += "Data_MC/";
55 >      if (!realData) desDir = baseDir + "MC/";
56 >      else desDir = baseDir + "Data_MC/";
57      } else {
58 <      if (!realData) desDir += "MC_"+invName+"/";
59 <      else desDir += "Data_"+invName+"/";
58 >      if (!realData) desDir = baseDir + "MC_"+invName+"/";
59 >      else desDir = baseDir + "Data_"+invName+"/";
60      }
61      struct stat stDir;
62      if (!stat(desDir,&stDir)){
# Line 98 | Line 101 | void ikstest() {
101      TH1F* hQCD_NEW[3];
102      TH1F* hKSres_[3];
103      TH1F* hKSvalues_[3];
104 +    TH1F* hQCD_KS[3];
105 +    TH1F* hWJets_KS[3];
106  
107      //load the histograms from the root files
108      for (int i = 0; i < 3; i++) {// 3 variables
# Line 165 | Line 170 | void ikstest() {
170  
171      //define the weight corrections for each sample
172      double NevData                = mixh_[2]->Integral();
173 <    double corr_NevQCD          = h_[2]->Integral();
173 >    double corr_NevQCD            = h_[2]->Integral();
174      double corr_NevQCD_NEW        = hQCD_NEW[2]->Integral();
175 <    double corr_NevWjets        = h_[5]->Integral();
176 <    double corr_Nevttjets       = h_[8]->Integral();
177 <    double corr_Nevmix          = procQCD*corr_NevQCD+procWjets*corr_NevWjets;
175 >    double corr_NevWjets          = h_[5]->Integral();
176 >    double corr_Nevttjets         = h_[8]->Integral();
177 >    double corr_Nevmix            = procQCD*corr_NevQCD+procWjets*corr_NevWjets;
178      //double corr_Nevmix            = procQCD*corr_NevQCD+procWjets*corr_NevWjets+procttjets*corr_Nevttjets;
179      if (!realData)
180        outprint << "Events mix sample    = " << corr_Nevmix << endl;
# Line 254 | Line 259 | void ikstest() {
259        hKSres_[i]->Rebin(2);
260        //hKSvalues_[i]->Rebin(2);
261  
262 +      // Stack Wjets and QCD after scaled by KS factors
263 +      hQCD_KS[i] = (TH1F*) hQCD_NEW[i]->Clone();
264 +      hQCD_KS[i]->Scale(SFbackg);
265 +      hQCD_KS[i]->SetLineColor(style.QCDColor);
266 +      hQCD_KS[i]->SetFillColor(style.QCDColor);
267 +      hQCD_KS[i]->SetFillStyle(style.QCDFill);
268 +
269 +      hWJets_KS[i] = (TH1F*) h_[i+3]->Clone();
270 +      hWJets_KS[i]->Scale(SFsample);
271 +      hWJets_KS[i]->SetLineColor(style.WJetsColor);
272 +      hWJets_KS[i]->SetFillColor(style.WJetsColor);
273 +      hWJets_KS[i]->SetFillStyle(style.WJetsFill);
274 +
275 +      THStack *hst = new THStack(invName,invName);
276 +      hst->Add(hQCD_KS[i]);
277 +      hst->Add(hWJets_KS[i]);
278 +
279 +      // Set plotting parameters
280        mixh_[i]     ->SetLineColor(1);
281        hQCD_NEW[i]  ->SetLineColor(2);
282        h_[i]        ->SetLineColor(4);
# Line 288 | Line 311 | void ikstest() {
311        h_[i+3]      ->SetStats(0);
312        hKSres_[i]   ->SetStats(0);
313        hKSvalues_[i]->SetStats(0);
314 +      hQCD_KS[i]   ->SetStats(0);
315 +      hWJets_KS[i] ->SetStats(0);
316  
317        hKSres_[i]->GetXaxis()->SetTitle(histoLabelX[i].c_str());
318        hKSres_[i]->GetYaxis()->SetTitle("Entries");
# Line 324 | Line 349 | void ikstest() {
349        TString cvsName2 = histoName[i]+"_dataKS";
350        if(useInv) cvsName2 = cvsName2 + "_" + invName;
351        cvs[cvsName2] = new TCanvas(cvsName2,"",600,700);
352 <      hKSres_[i]->Draw("P");
352 >      hst->Draw("hist");
353 >      hKSres_[i]->Draw("sameP");
354        mixh_[i]->Draw("sameP");
355 +
356        TLegend *legend2 = new TLegend(0.7, 0.70, 0.9, 0.85);
357        legend2->AddEntry(mixh_[i], "Data");
358        legend2->AddEntry(hKSres_[i], "KS result");
359 +      legend2->AddEntry(hWJets_KS[i], style.WJetsText);
360 +      legend2->AddEntry(hQCD_KS[i], style.QCDText);
361        legend2->Draw();
362        legend2->SetFillColor(kWhite);
363        //latex->DrawLatex(0.22,0.91,histoName[i].c_str());
364        //cvs[cvsName2]->SetLogy();
365        cvs[cvsName2]->SaveAs(nameCanvas2);
337
366      }
367  
340
368      TString cvsName3 = "KStestValues";
369      if(useInv) cvsName3 = cvsName3 + "_" + invName;
370      cvs[cvsName3] = new TCanvas(cvsName3,"",600,700);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines