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.6 by jengbou, Tue Sep 7 05:18:46 2010 UTC vs.
Revision 1.7 by jengbou, Wed Sep 8 04:51:35 2010 UTC

# Line 20 | Line 20
20   using namespace std;
21  
22   //define the constants: 2.88/pb
23 < const double weight_[3]    = {0.0524313, //QCD
24 <                              0.0091395, //WJets
25 <                              0.000306   //TTbar
23 > const Double_t weight_[5]  = {0.0524313, //QCD
24 >                              0.0089567, //WJets
25 >                              0.000306,  //TTbar
26 >                              0.0080911, //ZJets
27 >                              0.000114   //STtch
28   };
29   const Double_t procQCD     = 1.46;
30 < const Double_t procWjets   = 1.03;
31 < const Double_t procttjets  = 1.0;
30 > const Double_t procWJets   = 1.03;
31 > const Double_t procTTbar   = 1.;
32 > const Double_t procZJets   = 1.;
33 > const Double_t procSTtch   = 1.;
34  
35   // Output directory
36 < TString baseDir = "Results_2.88pb-1/";
36 > TString baseDir = "Results_2.88pb-1_NEW/";
37   // User defined parameters
38 < bool useInv    = true; // whether to use n-1 QCD template
38 > bool useInv    = false; // whether to use n-1 QCD template
39   bool realData  = false;
40   // Ntuples to use
41 < TString suffix = "Sel4"; // Suffix of selection
41 > TString suffix = "Sel0"; // Suffix of selection
42   TString invNames[2] = {"RelIsogt0p1","D0gt0p02"};
43   map<TString,TCanvas*> cvs; // map of usual histogram
44 + bool debug_ = false;
45  
46   //=================================
47   // Main program
# Line 75 | Line 80 | void ikstest() {
80      ofstream outprint(TString(desDir+"Results_"+suffix+".txt"));
81      //open the files with histograms
82      map<string,TFile*> mfile;
83 +    mfile.clear();
84      mfile["Data"] = TFile::Open(TString("skimmed_Data_2.88pb-1/Data_"+suffix+".root"));
85      // n-1 cuts
86      if (useInv) {
# Line 87 | Line 93 | void ikstest() {
93      mfile["0"] = TFile::Open(TString("skimmed_MC/v5/QCD_"+suffix+".root"));
94      mfile["1"] = TFile::Open(TString("skimmed_MC/v5/WJets_"+suffix+".root"));
95      mfile["2"] = TFile::Open(TString("skimmed_MC/v5/TTbar_"+suffix+".root"));
96 +    mfile["3"] = TFile::Open(TString("skimmed_MC/v5/ZJets_"+suffix+".root"));
97 +    mfile["4"] = TFile::Open(TString("skimmed_MC/v5/STtch_"+suffix+".root"));
98  
99      //define histograms and related parameters
100      string histoName[3] = {"h_mu_pt_calo","h_met_calo","h_mt_calo"};
# Line 94 | Line 102 | void ikstest() {
102      Int_t xbins[3] = {20,20,40};
103      Double_t xlow[3] = {0.,0.,0.};
104      Double_t xhigh[3] = {100.,100.,200.};
105 <    string sample[3] = {"QCD","Wjets","ttjets"};
105 >    string sample[5] = {"QCD","WJets","TTbar","ZJets","STtch"};
106  
107 <    TH1F* h_[9];
108 <    TH1F* mixh_[3];
109 <    TH1F* hQCD_NEW[3];
107 >    TH1F* hMC_[5][3];   // MC histograms
108 >    TH1F* hData_[3];    // Data or mix MC
109 >    TH1F* hQCD_NEW[3];  // InvSel QCD shape
110      TH1F* hKSres_[3];
111      TH1F* hKSvalues_[3];
112      TH1F* hQCD_KS[3];
113      TH1F* hWJets_KS[3];
114  
115      //load the histograms from the root files
116 <    for (int i = 0; i < 3; i++) {// 3 variables
117 <      //cout << "file[" << i << "] : " << endl;
118 <      string nameNewHisto = "mix_"+histoName[i];
119 <      string nameNewHistoSFKS = "finalSF_"+histoName[i];
120 <      string nameNewHistoKSvalues = "KSvalues_"+histoLabelX[i];
121 <
122 <      mixh_[i] = new TH1F(nameNewHisto.c_str(),"",xbins[i],xlow[i],xhigh[i]);
123 <      hKSres_[i] = new TH1F(nameNewHistoSFKS.c_str(),"",xbins[i],xlow[i],xhigh[i]);
124 <      hKSvalues_[i] = new TH1F(nameNewHistoKSvalues.c_str(),"",2./stepsize, stepsize, 2.+stepsize);
116 >    for (int vi = 0; vi < 3; ++vi) {// 3 variables
117 >      //cout << "file[" << vi << "] : " << endl;
118 >      string nameNewHisto = "mix_"+histoName[vi];
119 >      string nameNewHistoSFKS = "finalSF_"+histoName[vi];
120 >      string nameNewHistoKSvalues = "KSvalues_"+histoLabelX[vi];
121 >
122 >      hData_[vi] = new TH1F(nameNewHisto.c_str(),"",xbins[vi],xlow[vi],xhigh[vi]);
123 >      hKSres_[vi] = new TH1F(nameNewHistoSFKS.c_str(),"",xbins[vi],xlow[vi],xhigh[vi]);
124 >      hKSvalues_[vi] = new TH1F(nameNewHistoKSvalues.c_str(),"",2./stepsize, stepsize, 2.+stepsize);
125 >
126 >      ostringstream ssc;
127 >      ssc << vi;
128  
129        if (!useInv) {//use QCD MC sample
130 <        hQCD_NEW[i] = (TH1F*) mfile["0"]->Get(TString(histoName[i]))->Clone();
131 <        hQCD_NEW[i] -> Scale(weight_[0]);
132 <        hQCD_NEW[i] -> SetName((histoName[i]).c_str());
130 >        hQCD_NEW[vi] = (TH1F*) mfile["0"]->Get(TString(histoName[vi]))->Clone();
131 >        hQCD_NEW[vi] -> Scale(weight_[0]);
132 >        hQCD_NEW[vi] -> SetName(TString("InvSel_"+histoName[vi]+"_"+ssc.str()));
133        }
134        else {
135 <        hQCD_NEW[i] = (TH1F*) mfile["InvSel"]->Get(TString(histoName[i]));
136 <        if (!realData) hQCD_NEW[i] -> Scale(weight_[0]);
137 <        hQCD_NEW[i] -> SetName((histoName[i]).c_str());
135 >        hQCD_NEW[vi] = (TH1F*) mfile["InvSel"]->Get(TString(histoName[vi]))->Clone();
136 >        if (!realData) hQCD_NEW[vi] -> Scale(weight_[0]);
137 >        hQCD_NEW[vi] -> SetName(TString("InvSel_"+histoName[vi]+"_"+ssc.str()));
138        }
139 +      if (debug_) cout << "hQCD_NEW[" << vi << "] @ " << hQCD_NEW[vi] << endl;
140  
141 <      mixh_[i] -> Sumw2();
142 <      hKSres_[i] -> Sumw2();
143 <      hKSvalues_[i] -> Sumw2();
141 >      hData_[vi] -> Sumw2();
142 >      hKSres_[vi] -> Sumw2();
143 >      hKSvalues_[vi] -> Sumw2();
144      }
145  
146 <    for (int n = 0; n < 3; ++n) {// 3 MC samples
146 >    for (int n = 0; n < 5; ++n) {// 3 MC samples
147        for (int ihisto = 0; ihisto < 3; ihisto++) {// 3 variables
148          //cout << "Variable[" << ihisto << "]" << endl;
149          string histo_name = histoName[ihisto]+sample[n];
150          ostringstream ss;
151          ss << n;
152 <        h_[n*3+ihisto] = (TH1F*) mfile[ss.str()]->Get(TString(histoName[ihisto]))->Clone();
153 <        h_[n*3+ihisto] -> Scale(weight_[n]);
154 <        h_[n*3+ihisto] -> SetName(histo_name.c_str());
152 >        hMC_[n][ihisto] = (TH1F*) mfile[ss.str()]->Get(TString(histoName[ihisto]))->Clone();
153 >        if (debug_) {
154 >          cout << "File[" << n << "] @" << mfile[ss.str()]
155 >               << "; histo[" << ihisto << "] @ " <<  mfile[ss.str()]->Get(TString(histoName[ihisto]))
156 >               <<"; hMC_[" << n << "][" << ihisto << "] raw evts = "
157 >               << setw(12) << hMC_[n][ihisto]->Integral();
158 >        }
159 >        hMC_[n][ihisto] -> Scale(weight_[n]);
160 >        hMC_[n][ihisto] -> SetName(TString("MC_"+sample[n]+"_"+histoName[ihisto]));
161 >        if (debug_) cout << "; weighted num evts = " << setw(8) << hMC_[n][ihisto]->Integral() << endl;
162        }
163      }
164  
# Line 154 | Line 173 | void ikstest() {
173      for (int i = 0; i < 3; i++) {
174        cvs[cvsName0]->cd(i+1);
175        if (!realData) {
176 <        mixh_[i] -> Add(h_[i],h_[i+3], procQCD,procWjets);
177 <        //mixh_[i] -> Add(mixh_[i],h_[i+6], 1,procttjets);
178 <        //cout << "histo_name: " << mixh_[0]->GetNbinsX() << endl;
176 >        hData_[i] -> Add(hMC_[0][i],hMC_[1][i], procQCD,procWJets);
177 >        hData_[i] -> Add(hMC_[2][i], procTTbar);
178 >        hData_[i] -> Add(hMC_[3][i], procZJets);
179 >        hData_[i] -> Add(hMC_[4][i], procSTtch);
180        }
181        else {
182          TH1F *htmp = (TH1F*) mfile["Data"]->Get(TString(histoName[i]));
183 <        mixh_[i] -> Add(htmp,1.);
183 >        hData_[i] -> Add(htmp,1.);
184        }
185 <      mixh_[i]->GetXaxis()->SetTitle(histoLabelX[i].c_str());
186 <      mixh_[i]->GetYaxis()->SetTitle("Entries");
187 <      mixh_[i]->DrawClone();
185 >      hData_[i]->GetXaxis()->SetTitle(histoLabelX[i].c_str());
186 >      hData_[i]->GetYaxis()->SetTitle("Entries");
187 >      hData_[i]->DrawClone();
188      }
189      cvs[cvsName0]->SaveAs(TString(desDir+"Data_distributions.pdf"));
190  
191 <    //define the weight corrections for each sample
192 <    double NevData                = mixh_[2]->Integral();
193 <    double corr_NevQCD            = h_[2]->Integral();
191 >    //Calculate num of events for each sample
192 >    vector<double> vNev_;
193 >
194 >    double NevData                = hData_[2]->Integral();
195 >    double corr_NevQCD            = hMC_[0][2]->Integral();
196      double corr_NevQCD_NEW        = hQCD_NEW[2]->Integral();
197 <    double corr_NevWjets          = h_[5]->Integral();
198 <    double corr_Nevttjets         = h_[8]->Integral();
199 <    double corr_Nevmix            = procQCD*corr_NevQCD+procWjets*corr_NevWjets;
200 <    //double corr_Nevmix            = procQCD*corr_NevQCD+procWjets*corr_NevWjets+procttjets*corr_Nevttjets;
201 <    if (!realData)
202 <      outprint << "Events mix sample    = " << corr_Nevmix << endl;
203 <    else
204 <      outprint << "Events in Data       = " << NevData << endl;
197 >    double corr_NevWJets          = hMC_[1][2]->Integral();
198 >    double corr_NevTTbar          = hMC_[2][2]->Integral();
199 >    double corr_NevZJets          = hMC_[3][2]->Integral();
200 >    double corr_NevSTtch          = hMC_[4][2]->Integral();
201 >    cout << "corr_NevSTtch = " << corr_NevSTtch << endl;
202 > //     double corr_Nevmix            = procQCD*corr_NevQCD + procWJets*corr_NevWJets
203 > //       + procTTbar*corr_NevTTbar+procZJets*corr_NevZJets + procSTtch*corr_NevSTtch;//should equal NevData for MC
204 >    // store nev in a vector
205 >    vNev_.push_back(NevData);
206 >    vNev_.push_back((useInv ? corr_NevQCD_NEW : corr_NevQCD));
207 >    vNev_.push_back(corr_NevWJets);
208 >
209 >    // Non WJets (use MC expected values):
210 >    if (procTTbar > 0.) vNev_.push_back(corr_NevTTbar*procTTbar);
211 >    if (procZJets > 0.) vNev_.push_back(corr_NevZJets*procZJets);
212 >    if (procSTtch > 0.) vNev_.push_back(corr_NevSTtch*procSTtch);
213 >
214 >    outprint << "Events in Data       = " << NevData << endl;
215      outprint << "Events QCD sample    = " << corr_NevQCD << endl;
184    outprint << "Events Wjets sample  = " << corr_NevWjets << endl;
216      outprint << "Events InvSel sample = " << corr_NevQCD_NEW << endl;
217 +    outprint << "---------------------------" << endl;
218 +    outprint << "Events WJets sample  = " << corr_NevWJets << endl;
219 +    outprint << "Events TTbar sample  = " << corr_NevTTbar << endl;
220 +    outprint << "Events ZJets sample  = " << corr_NevZJets << endl;
221 +    outprint << "Events STtch sample  = " << corr_NevSTtch << endl;
222  
223      //define the containers for chosen numbers (coressponding to the max KStest result)
224      testMC maxProb[3];
# Line 196 | Line 232 | void ikstest() {
232  
233      //do the KS test by varying the scale factors
234      for (int i = 0; i < 3; i++) { // 3 variables
235 <      TH1F *data = (TH1F*)mixh_[i]->Clone();
235 >      TH1F *data = (TH1F*)hData_[i]->Clone("data");
236        data -> SetName("dataClone");
237 +      map<string,TH1F*> mHisto_;
238 +      mHisto_.clear();
239 +      mHisto_["Data"]  = data;
240 +      mHisto_["QCD"]   = (useInv ? (TH1F*)hQCD_NEW[i]->Clone() : (TH1F*)hMC_[0][i]->Clone());
241 +      mHisto_["WJets"] = (TH1F*)hMC_[1][i]->Clone();//WJets
242 +      if (procTTbar > 0.) mHisto_["TTbar"] = (TH1F*)hMC_[2][i]->Clone();//TTbar
243 +      if (procZJets > 0.) mHisto_["ZJets"] = (TH1F*)hMC_[3][i]->Clone();//ZJets
244 +      if (procSTtch > 0.) mHisto_["STtch"] = (TH1F*)hMC_[4][i]->Clone();//STtch
245 +
246        //data -> Scale(1./data->Integral());
247 <      vector<testMC> resultsKS = doKStest((realData ? NevData : corr_Nevmix),
203 <                                          (useInv ? corr_NevQCD_NEW : corr_NevQCD),
204 <                                          corr_NevWjets,
205 <                                          data, hQCD_NEW[i], h_[i+3]);
247 >      vector<testMC> resultsKS = doKStest(vNev_,mHisto_);
248        testMC tksmax = getMax(resultsKS);
249        maxProb[i] = tksmax;
250        outprint << "\nFor the plot " << histoLabelX[i] << " the results are:"<< endl;
# Line 211 | Line 253 | void ikstest() {
253        outprint << "\tproc_sample     = " << maxProb[i].scaleF_sample << endl;
254  
255        outprint << "\n\tpercent_B of Data = "
256 <               << maxProb[i].scaleF_backg*corr_NevQCD_NEW*100/(realData ? NevData : corr_Nevmix) << endl;
256 >               << maxProb[i].scaleF_backg*corr_NevQCD_NEW*100/NevData << endl;
257        outprint << "\tpercent_S of Data = "
258 <               << maxProb[i].scaleF_sample*corr_NevWjets*100/(realData ? NevData : corr_Nevmix) << endl;
258 >               << maxProb[i].scaleF_sample*corr_NevWJets*100/NevData << endl;
259        outprint << "---------------------------" << endl;
260  
261        //create the mixed samples with KS test results
# Line 222 | Line 264 | void ikstest() {
264        allKS += maxProb[i].prob;
265  
266        //fill a histogram with the results from the KS test for each variable
267 <      for (int jiter = 0; jiter < resultsKS.size(); jiter++) {
267 >      for (unsigned int jiter = 0; jiter < resultsKS.size(); jiter++) {
268          if (resultsKS.at(jiter).prob == 1.)
269            cout << "variable [" << i << "]: prob[" << jiter << "]= " << resultsKS.at(jiter).prob << endl;
270          hKSvalues_[i]->SetBinContent(jiter,resultsKS.at(jiter).prob);
# Line 236 | Line 278 | void ikstest() {
278      outprint << "allKS = " << allKS << "\tbackground = " << SFbackg << "\tsample = " << SFsample << endl;
279      outprint << "==> Scale Factor for QCD MC = " << SFbackg*corr_NevQCD_NEW/corr_NevQCD << endl;
280      outprint << "\tcombined percent_B of Data = "
281 <             << SFbackg*corr_NevQCD_NEW*100/(realData ? NevData : corr_Nevmix) << endl;
281 >             << SFbackg*corr_NevQCD_NEW*100/NevData << endl;
282      outprint << "\tcombined percent_S of Data = "
283 <             << SFsample*corr_NevWjets*100/(realData ? NevData : corr_Nevmix) << endl;
283 >             << SFsample*corr_NevWJets*100/NevData << endl;
284      outprint << "\n" << endl;
285      outprint << "=================================" << endl;
286      outprint << "\n" << endl;
# Line 248 | Line 290 | void ikstest() {
290      // Plots
291      //=================================
292      for (int i = 0; i < 3; i++) {// 3 variables
293 <      hKSres_[i] -> Add(hQCD_NEW[i],h_[i+3],SFbackg,SFsample);
293 >      hKSres_[i] -> Add((TH1F*)hQCD_NEW[i]->Clone(),(TH1F*)hMC_[1][i]->Clone(),SFbackg,SFsample);
294 >      hKSres_[i] -> Add((TH1F*)hMC_[2][i]->Clone(),procTTbar);
295 >      hKSres_[i] -> Add((TH1F*)hMC_[3][i]->Clone(),procZJets);
296 >      hKSres_[i] -> Add((TH1F*)hMC_[4][i]->Clone(),procSTtch);
297 >
298        outprint << "hKSres->Integral() = " << hKSres_[i]->Integral() << endl;
299 <      outprint << "Data->Integral()   = " << mixh_[i]->Integral() << endl;
299 >      outprint << "Data->Integral()   = " << hData_[i]->Integral() << endl;
300  
301 <      mixh_[i]->Rebin(2);
301 >      hData_[i]->Rebin(2);
302        hQCD_NEW[i]->Rebin(2);
303 <      h_[i]->Rebin(2);
304 <      h_[i+3]->Rebin(2);
303 >      hMC_[0][i]->Rebin(2);
304 >      hMC_[1][i]->Rebin(2);
305        hKSres_[i]->Rebin(2);
306        //hKSvalues_[i]->Rebin(2);
307  
# Line 266 | Line 312 | void ikstest() {
312        hQCD_KS[i]->SetFillColor(style.QCDColor);
313        hQCD_KS[i]->SetFillStyle(style.QCDFill);
314  
315 <      hWJets_KS[i] = (TH1F*) h_[i+3]->Clone();
315 >      hWJets_KS[i] = (TH1F*) hMC_[1][i]->Clone();
316        hWJets_KS[i]->Scale(SFsample);
317        hWJets_KS[i]->SetLineColor(style.WJetsColor);
318        hWJets_KS[i]->SetFillColor(style.WJetsColor);
319        hWJets_KS[i]->SetFillStyle(style.WJetsFill);
320  
321 +      if (procTTbar > 0.) {
322 +        hMC_[2][i]->Rebin(2);
323 +        hMC_[2][i]->SetLineColor(style.TtbarColor);
324 +        hMC_[2][i]->SetFillColor(style.TtbarColor);
325 +        hMC_[2][i]->SetFillStyle(style.TtbarFill);
326 +      }
327 +      if (procZJets > 0.) {
328 +        hMC_[3][i]->Rebin(2);
329 +        hMC_[3][i]->SetLineColor(style.DYZJetsColor);
330 +        hMC_[3][i]->SetFillColor(style.DYZJetsColor);
331 +        hMC_[3][i]->SetFillStyle(style.DYZJetsFill);
332 +      }
333 +      if (procSTtch > 0.) {
334 +        hMC_[4][i]->Rebin(2);
335 +        hMC_[4][i]->SetLineColor(style.ST_t_sColor);
336 +        hMC_[4][i]->SetFillColor(style.ST_t_sColor);
337 +        hMC_[4][i]->SetFillStyle(style.ST_t_sFill);
338 +      }
339        THStack *hst = new THStack(invName,invName);
340 <      hst->Add(hQCD_KS[i]);
341 <      hst->Add(hWJets_KS[i]);
340 >      hst->Add((TH1F*)hQCD_KS[i]->Clone());
341 >      if (procSTtch > 0) hst->Add((TH1F*)hMC_[4][i]->Clone());
342 >      if (procZJets > 0) hst->Add((TH1F*)hMC_[3][i]->Clone());
343 >      hst->Add((TH1F*)hWJets_KS[i]->Clone());
344 >      if (procTTbar > 0) hst->Add((TH1F*)hMC_[2][i]->Clone());
345  
346        // Set plotting parameters
347 <      mixh_[i]     ->SetLineColor(1);
347 >      hData_[i]    ->SetLineColor(1);
348        hQCD_NEW[i]  ->SetLineColor(2);
349 <      h_[i]        ->SetLineColor(4);
350 <      h_[i+3]      ->SetLineColor(3);
349 >      hMC_[0][i]   ->SetLineColor(4);
350 >      hMC_[1][i]   ->SetLineColor(3);
351        hKSres_[i]   ->SetLineColor(2);
352        hKSvalues_[i]->SetLineColor(i+1);
353  
354 <      mixh_[i]     ->SetMarkerColor(1);
354 >      hData_[i]    ->SetMarkerColor(1);
355        hQCD_NEW[i]  ->SetMarkerColor(2);
356 <      h_[i]        ->SetMarkerColor(4);
357 <      h_[i+3]      ->SetMarkerColor(3);
356 >      hMC_[0][i]   ->SetMarkerColor(4);
357 >      hMC_[1][i]   ->SetMarkerColor(3);
358        hKSres_[i]   ->SetMarkerColor(2);
359        hKSvalues_[i]->SetMarkerColor(i+1);
360  
361 <      mixh_[i]     ->SetMarkerStyle(24);
361 >      hData_[i]    ->SetMarkerStyle(24);
362        hQCD_NEW[i]  ->SetMarkerStyle(20);
363 <      h_[i]        ->SetMarkerStyle(20);
364 <      h_[i+3]      ->SetMarkerStyle(20);
363 >      hMC_[0][i]   ->SetMarkerStyle(20);
364 >      hMC_[1][i]   ->SetMarkerStyle(20);
365        hKSres_[i]   ->SetMarkerStyle(20);
366        hKSvalues_[i]->SetMarkerStyle(20);
367  
368 <      mixh_[i]     ->SetMarkerSize(1.4);
368 >      hData_[i]    ->SetMarkerSize(1.4);
369        hQCD_NEW[i]  ->SetMarkerSize(1.1);
370 <      h_[i]        ->SetMarkerSize(1.1);
371 <      h_[i+3]      ->SetMarkerSize(1.1);
370 >      hMC_[0][i]   ->SetMarkerSize(1.1);
371 >      hMC_[1][i]   ->SetMarkerSize(1.1);
372        hKSres_[i]   ->SetMarkerSize(0.9);
373        hKSvalues_[i]->SetMarkerSize(1.1);
374  
375 <      mixh_[i]     ->SetStats(0);
375 >      hData_[i]    ->SetStats(0);
376        hQCD_NEW[i]  ->SetStats(0);
377 <      h_[i]        ->SetStats(0);
378 <      h_[i+3]      ->SetStats(0);
377 >      hMC_[0][i]   ->SetStats(0);
378 >      hMC_[1][i]   ->SetStats(0);
379        hKSres_[i]   ->SetStats(0);
380        hKSvalues_[i]->SetStats(0);
381        hQCD_KS[i]   ->SetStats(0);
# Line 318 | Line 385 | void ikstest() {
385        hKSres_[i]->GetYaxis()->SetTitle("Entries");
386        hKSvalues_[i]->GetXaxis()->SetTitle("iteration #");
387        hKSvalues_[i]->GetYaxis()->SetTitle("KS test values");
388 <      h_[i]->GetXaxis()->SetTitle(histoLabelX[i].c_str());
389 <      h_[i]->GetYaxis()->SetTitle("A.U.");
388 >      hMC_[0][i]->GetXaxis()->SetTitle(histoLabelX[i].c_str());
389 >      hMC_[0][i]->GetYaxis()->SetTitle("A.U.");
390 >
391  
392        TString nameCanvas1 = desDir+histoName[i]+"_QCD_"+suffix+".pdf";
393        TString cvsName1 = histoName[i]+"_QCD";
394        if(useInv) cvsName1 = cvsName1 + "_" + invName;
395        cvs[cvsName1] = new TCanvas(cvsName1,"",600,700);
396        hQCD_NEW[i] -> Scale(1./hQCD_NEW[i]->Integral());
397 <      h_[i] -> Scale(1./h_[i]->Integral());
398 <      h_[i+3] -> Scale(1./h_[i+3]->Integral());
397 >      hMC_[0][i] -> Scale(1./hMC_[0][i]->Integral());
398 >      hMC_[1][i] -> Scale(1./hMC_[1][i]->Integral());
399        outprint << "For " << histoName[i] << " , the KStest result btw MC_QCD/InvSel is = "
400 <               << h_[i] -> KolmogorovTest(hQCD_NEW[i],"") << endl;
401 <      h_[i]->Draw("P");
400 >               << hMC_[0][i] -> KolmogorovTest(hQCD_NEW[i],"") << endl;
401 >      hMC_[0][i]->DrawCopy("P");
402 >      if (useInv)
403 >        hQCD_NEW[i]->DrawCopy("sameP");
404 >      hMC_[1][i]->DrawCopy("sameP");
405 >      TLegend *legend1 = new TLegend(0.7, 0.65, 0.9, 0.85);
406 >      legend1->AddEntry(hMC_[0][i], "QCD");
407        if (useInv)
335        hQCD_NEW[i]->Draw("sameP");
336      h_[i+3]->Draw("sameP");
337      TLegend *legend1 = new TLegend(0.7, 0.70, 0.9, 0.85);
338      legend1->AddEntry(h_[i], "QCD");
339      if (useInv)
408          legend1->AddEntry(hQCD_NEW[i], "QCD - InvSel");
409 <      legend1->AddEntry(h_[i+3], "W+jets");
409 >      legend1->AddEntry(hMC_[1][i], style.WJetsText);
410        legend1->Draw();
411        legend1->SetFillColor(kWhite);
412        //latex->DrawLatex(0.22,0.91,histoName[i].c_str());
413        //cvs[cvsName1]->SetLogy();
414        cvs[cvsName1]->SaveAs(nameCanvas1);
415  
416 +
417        TString nameCanvas2 = desDir+histoName[i]+"_dataKS_"+suffix+".pdf";
418        TString cvsName2 = histoName[i]+"_dataKS";
419        if(useInv) cvsName2 = cvsName2 + "_" + invName;
420        cvs[cvsName2] = new TCanvas(cvsName2,"",600,700);
421        hst->Draw("hist");
422        hKSres_[i]->Draw("sameP");
423 <      mixh_[i]->Draw("sameP");
423 >      hData_[i]->Draw("sameP");
424  
425 <      TLegend *legend2 = new TLegend(0.7, 0.70, 0.9, 0.85);
426 <      legend2->AddEntry(mixh_[i], "Data");
425 >      TLegend *legend2 = new TLegend(0.7, 0.65, 0.9, 0.85);
426 >      legend2->AddEntry(hData_[i], "Data");
427        legend2->AddEntry(hKSres_[i], "KS result");
428 +      if (procTTbar > 0.) legend2->AddEntry(hMC_[2][i], style.TtbarText);
429        legend2->AddEntry(hWJets_KS[i], style.WJetsText);
430 +      if (procZJets > 0.) legend2->AddEntry(hMC_[3][i], style.DYZJetsText);
431 +      if (procSTtch > 0.) legend2->AddEntry(hMC_[4][i], style.ST_t_sText);
432        legend2->AddEntry(hQCD_KS[i], style.QCDText);
433        legend2->Draw();
434        legend2->SetFillColor(kWhite);
435        //latex->DrawLatex(0.22,0.91,histoName[i].c_str());
436        //cvs[cvsName2]->SetLogy();
437        cvs[cvsName2]->SaveAs(nameCanvas2);
438 +
439      }
440  
441      TString cvsName3 = "KStestValues";
442      if(useInv) cvsName3 = cvsName3 + "_" + invName;
443      cvs[cvsName3] = new TCanvas(cvsName3,"",600,700);
444 <    //hKSvalues_[0]->GetXaxis()->SetRangeUser(0.9,1.2);
444 >    if (!realData) hKSvalues_[0]->GetXaxis()->SetRangeUser(0.9,1.2);
445      hKSvalues_[0]->GetYaxis()->SetRangeUser(1e-36,1.2);
446      hKSvalues_[0]->Draw();
447      hKSvalues_[1]->Draw("same");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines