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

Comparing UserCode/cbrown/Development/Plotting/Modules/ZbTools.C (file contents):
Revision 1.9 by buchmann, Wed Nov 14 10:46:45 2012 UTC vs.
Revision 1.12 by buchmann, Mon Nov 19 16:21:52 2012 UTC

# Line 23 | Line 23 | using namespace PlottingSetup;
23   namespace ZbData {
24   vector<float> data_over_mc;
25  
26 < TCut ZplusBsel("pt1>20&&pt2>20&&mll>60&&mll<120");
26 > TCut ZplusBsel("pt1>20&&pt2>20&&mll>60&&mll<120&&id1==id2");
27   TCut LeadingB("Zb3010_bTagProbCSVBP[0]>0.898");
28   TCut EtaB("abs(Zb3010_pfJetGoodEta[0])<1.3");
29 < TCut PhiZcut("abs(pfJetDphiZ[0])>2.7");
29 > TCut PhiZcut("abs(Zb3010_pfJetDphiZ[0])>2.7");
30    
31   }
32  
# Line 220 | Line 220 | void draw_Zb_kin_vars() {
220     draw_kin_variable("Zb3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>125&&pt<1000",40,0,2,"#alpha","Official/alpha_pt_125_to_1000",1);
221      draw_kin_variable("Zb3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000",40,0,2,"#alpha","Official/alpha_pt_30_to_1000",1);
222    
223 <  draw_kin_variable("pfBJetDphiZ[0]",ZplusBsel&&LeadingB&&"pt>10&&pt<1000&&pfBJetDphiZ[0]>0",30,0,3.2,"#delta#phi (Z,b lead)","DeltaPhiZBlead",0);
223 >  draw_kin_variable("Zb3010_pfBJetDphiZ[0]",ZplusBsel&&LeadingB&&"pt>10&&pt<1000&&pfBJetDphiZ[0]>0",30,0,3.2,"#delta#phi (Z,b lead)","DeltaPhiZBlead",0);
224    
225   /*
226    draw_kin_variable("pt1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,0,200,"p_{T}^{l1}","Lep/pt1",1);
# Line 254 | Line 254 | void draw_mpf_vars() {
254    draw_kin_variable("Zb3010_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"Zb3010_alpha<0.05",20,0,2,"p_{T} b-jet / p_{T} Z","ptb_over_ptz__mpf_alpha_smaller_0p05",0,"#alpha<0.05, 10 GeV < p_{T}^{Z} < 1000 GeV");
255   }  
256  
257 < Value get_Zb_data_over_mc(string variable, TCut cut) {
257 > /*double GetMedian(TH1F *histo) {
258 >    int numBins = histo->GetXaxis()->GetNbins();
259 >    Double_t x[numBins];
260 >    Double_t y[numBins];
261 >    for (int i = 1; i <= numBins; i++) {
262 >        x[i] = histo->GetBinCenter(i);
263 >        y[i] = histo->GetBinContent(i);
264 >    }
265 >    return TMath::Median(numBins, &x, &y);
266 > }*/
267 >
268 > Value get_Zb_data_over_mc(string variable, string variable2, TCut cut, string saveas) {
269   //  write_warning(__FUNCTION__,"Debugging this function, therefore always returning 3.1415+/-1.010101"); return Value(3.1415,1.010101);
270 <  TH1F *hdata  = allsamples.Draw("hdata",variable,1000,0,30, "#alpha [GeV]", "events", cut,data,luminosity);
271 <  TH1F *hmc    = allsamples.Draw("hmc" , variable,1000,0,30, "#alpha [GeV]", "events", cut,mc,  luminosity);
270 >  TCanvas *cn = new TCanvas("cn","cn");
271 >  string varname="MPF";
272 >  if(Contains(variable,"pfJetGood")) varname="R_{abs}";
273 >  TH1F *hdata  = allsamples.Draw("hdata",variable,1200,0,30, varname, "events",  cut,data,luminosity);
274 >  TH1F *hmc    = allsamples.Draw("hmc" , variable,1200,0,30, varname, "events", cut, mc,  luminosity);
275    
276 <  hdata->Fit("gaus","QE");
263 <  hmc->Fit("gaus","QE");
264 <  TF1 *fdata = (TF1*) hdata->GetFunction("gaus");
265 <  TF1 *fmc   = (TF1*) hmc->GetFunction("gaus");
266 <    
267 < /*  float a=hdata->GetMean();
276 >  float a=hdata->GetMean();
277    float b=hmc->GetMean();
278    float da=hdata->GetMeanError();
279 <  float db=hmc->GetMeanError();*/
271 <  float a = fdata->GetParameter(1);
272 <  float da = fdata->GetParError(1);
273 <  float b = fmc->GetParameter(1);
274 <  float db = fmc->GetParError(1);
279 >  float db=hmc->GetMeanError();
280    float factor = a / b;
281    float error = TMath::Sqrt(  (1/(b*b)) * (da*da) + ((a*a)/(b*b))*db*db);
282 +  
283 +  cn->cd();
284 +  hdata->GetYaxis()->SetTitle("events / 0.1");
285 +  hdata->Rebin(4);
286 +  hmc->Rebin(4);
287 +  hdata->GetXaxis()->SetRangeUser(0,2);
288 +  hdata->Draw("e1");
289 +  hmc->Draw("histo,same");
290 +  hdata->Draw("e1,same");
291 +  stringstream summary;
292 +  summary << "#splitline{" << varname << "}{#splitline{data: " << std::setprecision(4) << a << " #pm " << std::setprecision(4) << da << "}{#splitline{mc:   " << std::setprecision(4) << b << " #pm " << std::setprecision(4) << db << "}{ratio: " << factor;
293 +  summary << " #pm " << error << "}}}";
294 +  TText *infobox = write_title(summary.str());
295 +  infobox->SetX(0.75);
296 +  infobox->SetTextSize(0.03);
297 +  infobox->SetY(0.75);
298 +  infobox->Draw();
299 +    
300 +    
301 +  DrawPrelim();
302 +  CompleteSave(cn,"ResponsePlots/"+saveas);
303 +  
304 +  cout << "Data;" << a << ";"<<da<<";MC"<<b<<";"<<db<<endl;
305 +  delete cn;
306    delete hdata;
307    delete hmc;
308  
# Line 312 | Line 341 | void new_data_mc_agreement_2d() {
341        stringstream specialcut;
342        specialcut << "((pt>" << ptcuts[ipt] << " && pt< " << ptcuts[ipt+1] << ") && (Zb3010_alpha<" << alphacuts[ia] << "))";
343        cout << specialcut.str() << endl;
344 <      Value MPF_data_over_mc = get_Zb_data_over_mc("mpf",TCut(basecut && specialcut.str().c_str()));
345 <      Value RABS_data_over_mc = get_Zb_data_over_mc("Zb3010_pfJetGoodPt[0]/pt",TCut(basecut && specialcut.str().c_str()));
344 >      Value MPF_data_over_mc = get_Zb_data_over_mc("mpf","",TCut(basecut && specialcut.str().c_str()),"MPF___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__alpha_"+any2string(alphacuts[ia]));
345 >      Value RABS_data_over_mc = get_Zb_data_over_mc("Zb3010_pfJetGoodPt[0]/pt","",TCut(basecut && specialcut.str().c_str()),"Rabs___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__alpha_"+any2string(alphacuts[ia]));
346        
347        MPF_Results[ia][ipt]=MPF_data_over_mc.getValue();
348        MPF_Errors[ia][ipt]=MPF_data_over_mc.getError();
# Line 874 | Line 903 | void compare_selection(string identifier
903    
904   }
905  
906 < void do_basic_ZB_analysis() {
906 > void do_basic_ZB_analysis(int do_inclusive) {
907 >  
908 >  //https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagPOG#2011_Data_and_MC
909 >  //https://twiki.cern.ch/twiki/pub/CMS/BtagPOG/SFb-ttbar_payload.txt
910 >  
911 >  if(do_inclusive) {
912 >    LeadingB=TCut("Zb3010_bTagProbCSVBP[0]>=-10000");
913 >    cutWeight=TCut("(weight*(weight<1000)*(is_data+(!is_data)*((id1==id2&&id1==0)*0.95+(id1==id2&&id1==1)*0.88+(id1!=id2)*0.92)))");
914 >    write_info(__FUNCTION__,"Inclusive selection - no btag requirement, no btag efficiency/mistag correction (weight)");
915 >  } else {
916 >    LeadingB=TCut("Zb3010_bTagProbCSVBP[0]>0.898");
917 >    cutWeight=TCut("(weight*(weight<1000)*(is_data+(!is_data)*((id1==id2&&id1==0)*0.95+(id1==id2&&id1==1)*0.88+(id1!=id2)*0.92)*Zb3010_BTagWgt))");
918 >    write_info(__FUNCTION__,"Exclusive selection - switched on btag requirement and btag efficiency/mistag correction (weight)");
919 >  }
920    
921 +  bool doquick=true;
922    
923    TCanvas *zbcanvas = new TCanvas("zbcanvas","zbcanvas");
924    
# Line 893 | Line 936 | void do_basic_ZB_analysis() {
936   //     compare_selection("Zb3010");
937   //     compare_selection("Zb40");
938  
939 <  
940 < //  print_all_b_yields();
941 < //  draw_mpf_vars();
942 < //  DrawEvilCutFlow();
943 <  
944 < //  draw_Zb_kin_vars();
939 >  if(!doquick) {
940 >    print_all_b_yields();
941 >    draw_mpf_vars();
942 >    //  DrawEvilCutFlow();
943 >        
944 >    draw_Zb_kin_vars();
945 >        
946 >   }
947    
948    new_data_mc_agreement_2d();
949    
950 <  
950 >  write_error(__FUNCTION__,"Need to implement switch for inclusive result; inclusive result needs to have btag efficiency reweighting deactivated!");
951    delete zbcanvas;
952   }
953  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines