ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/WZStudy.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/WZStudy.C (file contents):
Revision 1.7 by buchmann, Mon Dec 3 16:06:59 2012 UTC vs.
Revision 1.10 by buchmann, Fri Apr 26 06:56:58 2013 UTC

# Line 41 | Line 41 | void WZ_kin_plot(string variable, int nb
41    pad->cd();
42  
43    THStack stack = allsamples.DrawStack("stack",variable,nbins,min,high,xlabel, "events", cut,mc, luminosity);
44 <  TH1F *hdata = allsamples.Draw("hdata",variable,nbins,min,high,xlabel, "events", cut,data, luminosity);
44 >  TH1F *hdata = SingleLeptonData.Draw("hdata",variable,nbins,min,high,xlabel, "events", cut,data, luminosity);
45  
46    float StackMax=CollapseStack(stack)->GetMaximum();
47    if(StackMax>hdata->GetMaximum()) hdata->SetMaximum(1.2*StackMax);
# Line 55 | Line 55 | void WZ_kin_plot(string variable, int nb
55    
56    float total=0;
57    float wz=0;
58 <  cout << "Numbers with variable " << variable << " and cut " << cut << ": " << endl;
58 > //  cout << "Numbers with variable " << variable << " and cut " << cut << ": " << endl;
59    TIter nextSF = TIter(stack.GetHists());
60    TH1F *h;
61    stringstream spurity;
# Line 63 | Line 63 | void WZ_kin_plot(string variable, int nb
63  
64  
65    while ( h = (TH1F*)nextSF() ) {
66 <    cout << IdentifierForUnderlinedEntry(h->GetName()) << " : " << h->Integral() << endl;
66 > //    cout << IdentifierForUnderlinedEntry(h->GetName()) << " : " << h->Integral() << endl;
67      if(IdentifierForUnderlinedEntry(h->GetName())=="WZ") {
68        wz+=h->Integral();
69        total+=h->Integral();
# Line 84 | Line 84 | void WZ_kin_plot(string variable, int nb
84    PurityPaveText->SetTextFont(42);
85    PurityPaveText->SetTextSize(0.021);
86    PurityPaveText->AddText(spurity.str().c_str());
87 <  PurityPaveText->Draw();
87 >  //PurityPaveText->Draw();
88  
89    
90   //  TText *purity = new TText(0.8,0.6,spurity.str().c_str());
91   //  purity->Draw();
92 <  cout << "DATA : " << hdata->Integral() << endl;
92 > //  cout << "DATA : " << hdata->Integral() << endl;
93 >  
94 >  Save_With_Ratio(hdata,stack,pad->cd(),"WZ_study/"+saveas);
95 >  
96 >  float sumData=0;
97 >  float sumMC=0;
98 >  TH1F *cstack = CollapseStack(stack);
99 >  
100 >  for(int i=1;i<=hdata->GetNbinsX();i++) {
101 >    if(hdata->GetBinCenter(i)>=20 && hdata->GetBinCenter(i)<=70) {
102 >      sumData+=hdata->GetBinContent(i);
103 >      sumMC+=cstack->GetBinContent(i);
104 >    }
105 >  }
106 >  delete cstack;
107 >  cout << " [20,70] for " << saveas << " : " << sumData << " (data) vs " << sumMC << " (mc) " << endl;
108    
109 <  save_with_ratio(hdata,stack,pad->cd(),"WZ_study/"+saveas);
109 >  CleanLegends();
110    delete hdata;
111    delete can;
112   }
# Line 105 | Line 120 | void SF_vs_OF_plots(string variable, int
120      if(mcordata==data) kinleg->SetHeader("Data");
121      else kinleg->SetHeader("MC");
122      
123 <    TH1F *sfdata = allsamples.Draw("sfdata",variable,nbins,min,high,xlabel, "events", cut&&sf,mcordata, luminosity);
124 <    TH1F *ofdata = allsamples.Draw("ofdata",variable,nbins,min,high,xlabel, "events", cut&&of,mcordata, luminosity);
123 >    TH1F *sfdata;
124 >    TH1F *ofdata;
125 >    
126 >    if(mcordata==data) {
127 >      ofdata = SingleLeptonData.Draw("ofdata",variable,nbins,min,high,xlabel, "events", cut&&of,mcordata, luminosity);
128 >      sfdata = SingleLeptonData.Draw("sfdata",variable,nbins,min,high,xlabel, "events", cut&&sf,mcordata, luminosity);
129 >    } else {
130 >      ofdata = allsamples.Draw("ofdata",variable,nbins,min,high,xlabel, "events", cut&&of,mcordata, luminosity);
131 >      sfdata = allsamples.Draw("sfdata",variable,nbins,min,high,xlabel, "events", cut&&sf,mcordata, luminosity);
132 >    }
133      
134      float OFmax=ofdata->GetMaximum();
135      if(OFmax>sfdata->GetMaximum()) sfdata->SetMaximum(1.2*OFmax);
# Line 121 | Line 144 | void SF_vs_OF_plots(string variable, int
144      if(mcordata==data) DrawPrelim();
145      else DrawMCPrelim();
146      
147 <    save_with_ratio(sfdata,ofdata,pad->cd(),"WZ_study/SF_vs_OF_plots/"+saveas);
147 >    Save_With_Ratio(sfdata,ofdata,pad->cd(),"WZ_study/SF_vs_OF_plots/"+saveas);
148      delete sfdata;
149      delete ofdata;
150      delete can;
# Line 210 | Line 233 | void SF_OF_comparison(TCut BasicCut, TCu
233    leg->Draw();
234    DrawMCPrelim();
235  
236 <  save_with_ratio(sfmc,ofmc,pad->cd(),"WZ_study/OFSFcomparison_MC");
236 >  Save_With_Ratio(sfmc,ofmc,pad->cd(),"WZ_study/OFSFcomparison_MC");
237    
238    // WZ only
239    TH1F *sfwz   = allsamples.Draw("sfwz"  ,"tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepSF,mc  , luminosity,allsamples.FindSample("WZJetsTo3"));
# Line 227 | Line 250 | void SF_OF_comparison(TCut BasicCut, TCu
250    leg->Draw();
251    DrawMCPrelim();
252    
253 <  save_with_ratio(sfwz,ofwz,pad2->cd(),"WZ_study/OFSFcomparison_WZ");
253 >  Save_With_Ratio(sfwz,ofwz,pad2->cd(),"WZ_study/OFSFcomparison_WZ");
254    
255    // data
256 <  TH1F *sfdata = allsamples.Draw("sfdata","tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepSF,data, luminosity);
257 <  TH1F *ofdata = allsamples.Draw("ofdata","tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepOF,data, luminosity);
256 >  TH1F *sfdata = SingleLeptonData.Draw("sfdata","tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepSF,data, luminosity);
257 >  TH1F *ofdata = SingleLeptonData.Draw("ofdata","tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepOF,data, luminosity);
258    
259    TPad *pad3 = new TPad("pad","pad",0,0,1,1);
260    pad3->cd();
# Line 244 | Line 267 | void SF_OF_comparison(TCut BasicCut, TCu
267    leg->Draw();
268    DrawPrelim();
269    
270 <  save_with_ratio(sfdata,ofdata,pad3->cd(),"WZ_study/OFSFcomparison_data");
270 >  Save_With_Ratio(sfdata,ofdata,pad3->cd(),"WZ_study/OFSFcomparison_data");
271  
272    delete can;
273    
# Line 255 | Line 278 | void SF_OF_comparison(TCut BasicCut, TCu
278      
279    TriLeptons::Rsfof_CorrectionFactor=ofwz->Integral() / sfwz->Integral();
280    TriLeptons::Rsfof_CorrectionFactor_Error=(ofwz->Integral()/sfwz->Integral()) * TMath::Sqrt(1/sfwz->GetEntries()+1/ofwz->GetEntries());
281 +  delete sfdata;
282 +  delete ofdata;
283 +  delete sfwz;
284 +  delete ofwz;
285    
286   }
287  
# Line 287 | Line 314 | void DrawMatchGenDistribution(string var
314    leg->AddEntry(noMatch,"incorrect match","l");
315    leg->Draw();
316    
317 <  save_with_ratio(goodMatch,noMatch,pad->cd(),"WZ_study/GenMatchComparison/"+SaveAs);
317 >  Save_With_Ratio(goodMatch,noMatch,pad->cd(),"WZ_study/GenMatchComparison/"+SaveAs);
318    
319    delete goodMatch;
320    delete noMatch;
# Line 324 | Line 351 | void DrawMatchRecoDistribution(string va
351    leg->Draw();
352    DrawPrelim();
353    
354 <  save_with_ratio(goodMatch,noMatch,pad->cd(),"WZ_study/RecoMatchComparison/"+SaveAs);
354 >  Save_With_Ratio(goodMatch,noMatch,pad->cd(),"WZ_study/RecoMatchComparison/"+SaveAs);
355    
356    delete goodMatch;
357    delete noMatch;
# Line 485 | Line 512 | void GetResult(TCut BasicCut, TCut Selec
512      float mll_hi=200;
513      
514      TCanvas *can = new TCanvas("can","can");
515 <    TH1F *sfwz   = allsamples.Draw("sfwz"  ,"tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepSF,data,luminosity);
516 <    TH1F *ofwz   = allsamples.Draw("ofwz"  ,"tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepOF,data,luminosity);
515 >    TH1F *sfwz   = SingleLeptonData.Draw("sfwz"  ,"tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepSF,data,luminosity);
516 >    TH1F *ofwz   = SingleLeptonData.Draw("ofwz"  ,"tri_submll",nbins,mll_low,mll_hi,"m_{l_{2}l_{3}} [GeV]", "events", BasicCut&&Selection&&TriLepOF,data,luminosity);
517      
518      delete can;
519      
# Line 539 | Line 566 | void PredictionFailurePlot(string truthv
566    leg->AddEntry(MCTruth,"MC truth (norm.)","l");
567    leg->Draw();
568    DrawMCPrelim();
569 <  save_with_ratio(MCTruth,Prediction,pad->cd(),"WZ_study/PredictionMethodFailure/"+saveas);
569 >  Save_With_Ratio(MCTruth,Prediction,pad->cd(),"WZ_study/PredictionMethodFailure/"+saveas);
570    
571    delete Prediction;
572    delete MCTruth;
# Line 571 | Line 598 | void ComputeNewMiscombinationRate(TCut o
598    TH1F *WZ_OF_OFZ = allsamples.Draw("WZ_OFZ"    ,"tri_badsubmll",1,0.0,1000.0,"m_{l_{2}l_{3}} [GeV]", "events", FlavorBlindSelection&&OFZ ,mc,luminosity,allsamples.FindSample("WZJetsTo3"));
599    TH1F *WZ_OF_any = allsamples.Draw("WZ_OF_any" ,"tri_badsubmll",1,0.0,1000.0,"m_{l_{2}l_{3}} [GeV]", "events", FlavorBlindSelection      ,mc,luminosity,allsamples.FindSample("WZJetsTo3"));
600    
601 <  TH1F *data_OF_OFZ = allsamples.Draw("data_OFZ"    ,"tri_badsubmll",1,0.0,1000.0,"m_{l_{2}l_{3}} [GeV]", "events", FlavorBlindSelection&&OFZ ,data,luminosity);
602 <  TH1F *data_OF_any = allsamples.Draw("data_OF_any" ,"tri_badsubmll",1,0.0,1000.0,"m_{l_{2}l_{3}} [GeV]", "events", FlavorBlindSelection      ,data,luminosity);
601 >  TH1F *data_OF_OFZ = SingleLeptonData.Draw("data_OFZ"    ,"tri_badsubmll",1,0.0,1000.0,"m_{l_{2}l_{3}} [GeV]", "events", FlavorBlindSelection&&OFZ ,data,luminosity);
602 >  TH1F *data_OF_any = SingleLeptonData.Draw("data_OF_any" ,"tri_badsubmll",1,0.0,1000.0,"m_{l_{2}l_{3}} [GeV]", "events", FlavorBlindSelection      ,data,luminosity);
603    
604    dout << "Miscombination rate in WZ sample with selection in place : " << 100 * WZ_OF_OFZ->Integral() / WZ_OF_any->Integral() << " +/- " << 100*(WZ_OF_OFZ->Integral() / WZ_OF_any->Integral())* sqrt( 1.0/WZ_OF_OFZ->GetEntries() + 1.0/WZ_OF_any->GetEntries())<< " %    (" << WZ_OF_OFZ->Integral() << " / " << WZ_OF_any->Integral() << ")" << endl;
605    dout << "Miscombination rate in DATA with selection in place : " << 100 * data_OF_OFZ->Integral() / data_OF_any->Integral() << " +/- " << 100*(data_OF_OFZ->Integral() / data_OF_any->Integral()) * sqrt( 1.0/data_OF_OFZ->Integral() + 1.0/data_OF_any->Integral() ) << " %    (" << data_OF_OFZ->Integral() << " / " << data_OF_any->Integral() << ")" << endl;
# Line 643 | Line 670 | void ComputeMiscombinationRate(TCut orig
670  
671  
672   void CarryOutWZStudy() {
673 <  TCut BasicCut("leptonNum>2&&tri_pt1>30&&tri_pt2>20&&tri_pt3>20");
673 >  
674 >  WZ_kin_plot("mll",40,0,200,"m_{Z} [GeV]",TCut("id1==id2 && pfJetGoodNum40>=3 && abs(mll-91.2)<20 && pt1>30 && pt2>20 && abs(eta1)<2.4 && abs(eta2)<2.4"),"Crosscheck_Lumi");
675 >  WZ_kin_plot("mll",40,0,200,"m_{Z} [GeV]",TCut("id1==id2 && id1==0 && pfJetGoodNum40>=3 && abs(mll-91.2)<20 && pt1>30 && pt2>20 && abs(eta1)<2.4 && abs(eta2)<2.4"),"Crosscheck_Lumi_ee");
676 >  WZ_kin_plot("mll",40,0,200,"m_{Z} [GeV]",TCut("id1==id2 && id1==1 && pfJetGoodNum40>=3 && abs(mll-91.2)<20 && pt1>30 && pt2>20 && abs(eta1)<2.4 && abs(eta2)<2.4"),"Crosscheck_Lumi_mm");
677 >  
678 >  TCut BasicCut("tri_MatchFound&&leptonNum>2&&tri_pt1>30&&tri_pt2>20&&tri_pt3>20");
679    TCut Selection("abs(tri_mlll-91)>30 && tri_mT>40 && met[4] > 30 && abs(tri_mll-91)<10 && tri_submll > 10 && abs(tri_submll-91)>5");
680  
681    //OptimizeSelection(BasicCut);
682    
683    //ComputeMiscombinationRate(Selection, BasicCut);
684    
685 <  ComputeNewMiscombinationRate(Selection, BasicCut);
685 > //   ComputeNewMiscombinationRate(Selection, BasicCut);
686    
687    WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut,"Inclusive/Zmass");
688    WZ_kin_plot("tri_mlll",40,0,400,"m_{ll} [GeV]",BasicCut,"Inclusive/TrileptonMass");
# Line 659 | Line 691 | void CarryOutWZStudy() {
691    WZ_kin_plot("tri_pt1",40,0,400,"p_{T}^{1} [GeV]",BasicCut,"Inclusive/Pt1");
692    WZ_kin_plot("tri_pt2",40,0,400,"p_{T}^{2} [GeV]",BasicCut,"Inclusive/Pt2");
693    WZ_kin_plot("tri_pt3",40,0,400,"p_{T}^{3} [GeV]",BasicCut,"Inclusive/Pt3");
694 <
694 > /*
695    WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&TCut("abs(tri_mlll-91)>30"),"Mlll_cut/Zmass");
696    WZ_kin_plot("tri_mlll",40,0,400,"m_{ll} [GeV]",BasicCut&&TCut("abs(tri_mlll-91)>30"),"Mlll_cut/TrileptonMass");
697    WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&TCut("abs(tri_mlll-91)>30"),"Mlll_cut/mT");
# Line 688 | Line 720 | void CarryOutWZStudy() {
720    WZ_kin_plot("met[4]",40,0,200,"MET [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30&&met[4]>30"),"CutFlow/MET__3_CutOn_MT_n_Mll_n_Met");
721    WZ_kin_plot("met[4]",40,0,200,"MET [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30&&met[4]>30&&abs(tri_mll-91)<10"),"CutFlow/MET__4_CutOn_MT_n_Mll_n_Met_MllWindow");
722  
723 <  
723 >  */
724    WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&Selection,"Zmass");
725    WZ_kin_plot("tri_mlll",40,0,400,"m_{lll} [GeV]",BasicCut&&Selection,"TrileptonMass");
726    WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&Selection,"mT");
# Line 742 | Line 774 | void ExtractDYMissingResolution() {
774    
775    TCanvas *can = new TCanvas("can","can");
776    
777 <  TH1F *histoSF = allsamples.Draw("histoSF","met[4]",50,0,100,"MET [GeV]","events",TCut("id1==id2&&mll>0&&pfJetGoodNum40>=2"),data,luminosity);
778 <  TH1F *histoOF = allsamples.Draw("histoOF","met[4]",50,0,100,"MET [GeV]","events",TCut("id1!=id2&&mll>0&&pfJetGoodNum40>=2"),data,luminosity);
777 >  TH1F *histoSF = SingleLeptonData.Draw("histoSF","met[4]",50,0,100,"MET [GeV]","events",TCut("id1==id2&&mll>0&&pfJetGoodNum40>=2"),data,luminosity);
778 >  TH1F *histoOF = SingleLeptonData.Draw("histoOF","met[4]",50,0,100,"MET [GeV]","events",TCut("id1!=id2&&mll>0&&pfJetGoodNum40>=2"),data,luminosity);
779    THStack histoMC = allsamples.DrawStack("histoMC","met[4]",50,0,100,"MET [GeV]","events",TCut("id1==id2&&mll>0&&pfJetGoodNum40>=2"),mc,luminosity);
780    TFile *f = new TFile("file.root","RECREATE");
781    
# Line 823 | Line 855 | void ExtractDYMissingResolution() {
855      stringstream savethis;
856      savethis << "WZ_study/DYResolution/Response" << 100*smearby << "Percent";
857      
858 <    save_with_ratio(histoSF,sum,pad->cd(),savethis.str());
858 >    Save_With_Ratio(histoSF,sum,pad->cd(),savethis.str());
859    }
860    
861    gr->SetTitle("Chi2Diagram");
# Line 852 | Line 884 | void ExtractDYMissingResolution() {
884    stack.Draw();
885    histoSF->Draw("e1,same");
886    DrawPrelim();
887 <  save_with_ratio(histoSF,CollapseStack(stack),pad->cd(),"WZ_study/DYResolution/Result");
887 >  Save_With_Ratio(histoSF,CollapseStack(stack),pad->cd(),"WZ_study/DYResolution/Result");
888    
889    TFile *fr = new TFile("rumba.root","RECREATE");
890    gr->Write();
# Line 867 | Line 899 | void ExtractDYMissingResolution() {
899   void WZstudy() {
900   //  ExtractDYMissingResolution();
901    
902 <  cutWeight=TCut("(weight*(weight<1000)*(is_data+(!is_data)))");
902 >  cutWeight=TCut("(weight*(weight<1000)*(is_data*tri_MatchFound+(!is_data)*(0.96*(tri_id1==1)+0.90*(tri_id1==0))))");
903    switch_overunderflow(true);
904    cout << "Essential cut is " << (const char*) essentialcut << endl;
905    cout << "Going to set essential cut to new triggers" << endl;
906    TCut essential_bkp = essentialcut;
875  write_warning(__FUNCTION__,"Need to define trigger requirement for WZ!");
907    essentialcut=TCut("mll>5||mll<6");
908    cout << "Essential cut is now " << (const char*) essentialcut << endl;
909    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines