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.4 by buchmann, Fri Aug 10 11:47:53 2012 UTC vs.
Revision 1.8 by buchmann, Wed Nov 7 10:49:57 2012 UTC

# Line 26 | Line 26 | namespace ZbData {
26   TCut ZplusBsel("pt1>20&&pt2>20&&mll>60&&mll<120");
27   TCut LeadingB("Zb30_bTagProbCSVBP[0]>0.679");
28   TCut EtaB("abs(Zb30_pfJetGoodEta[0])<1.3");
29 < TCut PhiZcut("Zb30_pfJetDphiZ[0]>2.7");
29 > TCut PhiZcut("abs(pfJetDphiZ[0])>2.7");
30    
31   }
32  
33   using namespace ZbData;
34  
35 +
36 + //*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*  DELETE EVERYTHING BETWEEN THIS LINE /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*//
37 + void SpecialCutFlow(string identifier);
38 +  
39 + //*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*            AND THIS LINE             /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*//
40 +
41 +
42   void print_yield(TCut cut) {
43    TH1F *data  = allsamples.Draw("data",    "mll",1,0,10000000, "m_{ll} [GeV]", "events", cut,data,luminosity);
44 <  cout << "  Yields for " << (const char*) cut << endl;
45 <  cout << "     data: " << data->Integral() << endl;
46 <  THStack mcm = allsamples.DrawStack("mc", "mll",1,0,10000000, "m_{ll} [GeV]", "events", cut,mc,luminosity);
44 >  dout << "  Yields for " << (const char*) cut << endl;
45 >  dout << "     data: " << data->Integral() << endl;
46 > /*  THStack mcm = allsamples.DrawStack("mc", "mll",1,0,10000000, "m_{ll} [GeV]", "events", cut,mc,luminosity);
47    int nhists = mcm.GetHists()->GetEntries();
48 <  cout << "Going to loop over " << nhists << " histograms " << endl;
48 >  dout << "Going to loop over " << nhists << " histograms " << endl;
49    TFile *test = new TFile("test.root","RECREATE");
50    mcm.Write();
51    test->Close();
# Line 47 | Line 54 | void print_yield(TCut cut) {
54      cout << "     " << hist->GetName() << ": " << hist->Integral() << endl;
55    }
56    cout << endl << endl;
57 +  */
58    delete data;
59   }
60  
# Line 100 | Line 108 | Value getfrom2Dmap(TH2F *map, int ixbin,
108    return sum;
109   }
110    
103  
104 void data_mc_agreement_2d() {
105  
106  vector<int> emptyvector;
107  float binX[5]={10,50,100,200,1000};
108  float binY[5]={0.0,0.1,0.15,0.2,0.3};
109  vector<float>binningx;
110  vector<float>binningy;
111  binningx.assign(binX,binX+5);
112  binningy.assign(binY,binY+5);
113  
114  TCut cut(ZplusBsel&&LeadingB&&EtaB&&PhiZcut);
115  
116  TCanvas *agrcan = new TCanvas("agrcan","agrcan");
117  
118  cout << "Drawing 2d for data " << endl;
119  TH2F *alphazptplane_data = allsamples.Draw("alphazptplane_data","alpha:pt",binningx,binningy,"Z p_{T}","#alpha",cut,data,luminosity,emptyvector,false);
120  cout << "Drawing 2d for MC " << endl;
121  TH2F *alphazptplane_mc   = allsamples.Draw("alphazptplane_mc",  "alpha:pt",binningx,binningy,"Z p_{T}","#alpha",cut,mc,  luminosity,emptyvector,false);
122  
123  
124  TFile *f = new TFile("test.root","RECREATE");
125  alphazptplane_data->Write();
126  f->Close();
127  
128  for(int ix=1;ix<binningx.size();ix++) {
129    cout << "pt in " << binningx[ix-1] << " , " << binningx[ix] << endl;
130    TGraphErrors gr;
131    for(int iy=1;iy<binningy.size();iy++) {
132      Value mc   = Value((getfrom2Dmap(alphazptplane_mc,ix,iy)).getValue(),0.0);// not taking MC statistics into account
133      Value data = getfrom2Dmap(alphazptplane_data,ix,iy);
134      cout << " For an alpha cut at " << binningy[iy] << " we get : mc (" << mc << ") , data (" << data << ") --> data/mc = " << data/mc << endl;
135      gr.SetPoint(iy-1,binningy[iy],(data/mc).getValue());
136      gr.SetPointError(iy-1,0,(data/mc).getError());
137    }
138
139    gr.Draw("AP*");
140    gr.GetYaxis()->SetTitle("data / mc");
141    gr.GetYaxis()->CenterTitle();
142    gr.GetXaxis()->SetTitle("#alpha");
143    gr.GetXaxis()->CenterTitle();
144    gr.GetXaxis()->SetRangeUser(0,0.4);
145    gr.GetYaxis()->SetRangeUser(0.5,1.5);
146    gr.Draw("AP*");
147    DrawPrelim();
148    stringstream ptbin;
149    ptbin << binningx[ix-1] << " < p_{T}^{Z} < " << binningx[ix] << " GeV";
150    TText *ptt = write_title(ptbin.str());
151    ptt->SetX(0.7);
152    ptt->SetY(0.7);
153    ptt->SetTextSize(0.03);
154    ptt->Draw();
155    TLine *l = new TLine(0.0,1.0,0.4,1.0);
156    l->SetLineStyle(2);
157    l->SetLineColor(kBlue);
158    l->Draw();
159    
160    stringstream saveas;
161    saveas << "Zplusb_data_over_mc___" << binningx[ix-1] << "to" << binningx[ix];
162    DrawPrelim();
163    CompleteSave(agrcan,saveas.str());
164 //    agrcan->SaveAs("tester.png");
165  }
166  
167  delete agrcan;
168  
169 }
170
111   void print_all_b_yields() {
112    cout << "Basic selection with a b jet" << endl;
113    print_yield(ZplusBsel&&"Zb30_pfJetGoodNumBtag>0");
# Line 180 | Line 120 | void print_all_b_yields() {
120    cout << "10<ptZ<1000 GeV" << endl;
121    print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000");
122    cout << "#alpha < 0.3" << endl;
123 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"Zb30_alpha<0.3");
123 >  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"(Zb30_pfJetGoodPt[1]/pt)<0.3");
124    cout << "#alpha < 0.2" << endl;
125 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"Zb30_alpha<0.2");
125 >  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"(Zb30_pfJetGoodPt[1]/pt)<0.2");
126    cout << "#alpha < 0.15" << endl;
127 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"Zb30_alpha<0.15");
127 >  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"(Zb30_pfJetGoodPt[1]/pt)<0.15");
128    cout << "#alpha < 0.1" << endl;
129 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"Zb30_alpha<0.1");
129 >  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"(Zb30_pfJetGoodPt[1]/pt)<0.1");
130    cout << "#alpha < 0.05" << endl;
131 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"Zb30_alpha<0.05");
131 >  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"(Zb30_pfJetGoodPt[1]/pt)<0.05");
132   }  
133  
134 + void DrawEvilCutFlow() {
135 +  stringstream MegaCut;
136 +  
137 +  MegaCut << "   1*(" << (const char*) (ZplusBsel&&TCut("Zb30_pfJetGoodNumBtag>0")) << ")";
138 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB) << ")";
139 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB) << ")";
140 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut) << ")";
141 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000")) << ")";
142 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.3")) << ")";
143 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.2")) << ")";
144 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.15")) << ")";
145 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.1")) << ")";
146 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.05")) << ")";
147 +  MegaCut << " ";
148 +  
149 +  TCanvas *can = new TCanvas("can","can");
150 +  can->SetLogy(1);
151 +  TCut basecut("mll>6||mll<10");
152 +  
153 +  
154 +  
155 +  TLegend *leg = allsamples.allbglegend();
156 +  
157 +  
158 +  TH1F *data  = allsamples.Draw("data",    MegaCut.str(),11,-0.5,10.5, "", "events", basecut,data,luminosity);
159 +   THStack mcm = allsamples.DrawStack("mc", MegaCut.str(),11,-0.5,10.5, "", "events", basecut,mc,luminosity);
160 +
161 +  float runningsum=0;
162 +  for(int i=data->GetNbinsX();i>0;i--) {
163 +    runningsum+=data->GetBinContent(i);
164 +    data->SetBinContent(i,runningsum);
165 +  }
166 +  
167 +  float minimum=data->GetMaximum();
168 +  
169 +  TH1F* h;
170 +  TIter nextOF(mcm.GetHists());
171 +  while ( h = (TH1F*)nextOF() ) {
172 +    float runningsum=0;
173 +    minimum=data->GetMaximum();//done deliberately at each step so get the minimum of the last (!) contribution
174 +    for(int i=h->GetNbinsX();i>0;i--) {
175 +      runningsum+=h->GetBinContent(i);
176 +      h->SetBinContent(i,runningsum);
177 +      if(runningsum<minimum&&runningsum>0) minimum=runningsum;
178 +    }
179 +  }
180 +  
181 +  
182 +
183 +  data->SetMinimum(0.05*minimum);
184 +  can->cd(1)->SetBottomMargin(0.25);
185 +  data->GetXaxis()->SetBinLabel(1,"Pre-selection");
186 +  data->GetXaxis()->SetBinLabel(2,"Contains b jet");
187 +  data->GetXaxis()->SetBinLabel(3,"Leading jet is b-jet");
188 +  data->GetXaxis()->SetBinLabel(4,"|#eta_{b}|<1.3 ");
189 +  data->GetXaxis()->SetBinLabel(5,"|#delta#phi(b,Z)|>2.7");
190 +  data->GetXaxis()->SetBinLabel(6,"10<p_{T}^{Z}<1000 GeV");
191 +  data->GetXaxis()->SetBinLabel(7,"#alpha < 0.3");
192 +  data->GetXaxis()->SetBinLabel(8,"#alpha < 0.2");
193 +  data->GetXaxis()->SetBinLabel(9,"#alpha < 0.15");
194 +  data->GetXaxis()->SetBinLabel(10,"#alpha < 0.1");
195 +  data->GetXaxis()->SetBinLabel(11,"#alpha < 0.05");
196 +  data->GetXaxis()->LabelsOption("v");
197 +  
198 +  data->Draw("e1");
199 +  mcm.Draw("same");
200 +  data->Draw("same,e1,axis");
201 +  data->Draw("same,e1");
202 + //  data->Draw("same,TEXT");
203 +  
204 +  leg->Draw();
205 +  
206 +  DrawPrelim();
207 +  
208 +  CompleteSave(can,"CutFlow");
209 + }
210 +
211   void draw_Zb_kin_vars() {
212 <  draw_kin_variable("Zb30_pfBJetDphiZ",ZplusBsel&&LeadingB,100,0,3.2,"#delta#phi (Z,b lead)","DeltaPhiZBlead",1);
213 <  draw_kin_variable("pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",50,0,200,"Z p_{T}","Zpt",1);
214 <  draw_kin_variable("Zb30_pfJetGoodPt[1]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",50,0,200,"Sub-Leading Jet Pt","Jet2Pt",1);
215 <  draw_kin_variable("Zb30_pfJetGoodPtlBtag[0]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",50,0,200,"Leading Jet Pt (B)","LeadingJetPt",1);
216 <  draw_kin_variable("Zb30_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,0,2,"#alpha","alpha",1);
212 >   draw_kin_variable("pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",25,0,200,"Z p_{T}","Official/Zpt",1);
213 >   draw_kin_variable("Zb30_pfJetGoodPt[1]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",25,0,200,"Sub-Leading Jet Pt","Official/Jet2Pt",1);
214 >   draw_kin_variable("Zb30_pfJetGoodPt[0]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",25,0,200,"Leading Jet Pt (B)","Official/LeadingJetPt",1);
215 >   draw_kin_variable("Zb30_pfJetGoodPt[1]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,0,2,"p_{T}^{J2} / p_{T}^{Z}","Official/SubLeadingJetPt_Over_ZPt",1);
216 >   draw_kin_variable("Zb30_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<50",   20,0,2,"#alpha","Official/alpha_pt_10_to_50",1);
217 >   draw_kin_variable("Zb30_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>50&&pt<100",  20,0,2,"#alpha","Official/alpha_50_to_100",1);
218 >   draw_kin_variable("Zb30_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>100&&pt<200", 20,0,2,"#alpha","Official/alpha_pt_100_to_200",1);
219 >   draw_kin_variable("Zb30_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>200&&pt<1000",20,0,2,"#alpha","Official/alpha_pt_200_to_1000",1);
220 >  
221 >  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);
222 >  
223 > /*
224 >  draw_kin_variable("pt1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,0,200,"p_{T}^{l1}","Lep/pt1",1);
225 >  draw_kin_variable("pt1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id1==0",20,0,200,"p_{T}^{e1}","Lep/pt1_e",1);
226 >  draw_kin_variable("pt1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id1==1",20,0,200,"p_{T}^{#mu1}","Lep/pt1_m",1);
227 >  draw_kin_variable("pt2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,0,200,"p_{T}^{l2}","Lep/pt2",1);
228 >  draw_kin_variable("pt2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id2==0",20,0,200,"p_{T}^{e2}","Lep/pt2_e",1);
229 >  draw_kin_variable("pt2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id2==1",20,0,200,"p_{T}^{#mu2}","Lep/pt2_m",1);
230 >  draw_kin_variable("eta1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,-3.1,3.1,"#eta^{l1}","Lep/eta1",1);
231 >  draw_kin_variable("eta1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id1==0",20,-3.1,3.1,"#eta^{e1}","Lep/eta1_e",1);
232 >  draw_kin_variable("eta1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id1==1",20,-3.1,3.1,"#eta^{m1}","Lep/eta1_m",1);
233 >  draw_kin_variable("eta2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,-3.1,3.1,"#eta^{l1}","Lep/eta2",1);
234 >  draw_kin_variable("eta2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id2==0",20,-3.1,3.1,"#eta^{e2}","Lep/eta2_e",1);
235 >  draw_kin_variable("eta2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id2==1",20,-3.1,3.1,"#eta^{#mu2}","Lep/eta2_m",1);
236 >  draw_kin_variable("numVtx",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",30,0,30,"N(Vtx)","Lep/nVtx",1);
237 >  */
238   }
239  
240   void draw_mpf_vars() {
# Line 235 | Line 273 | Value get_Zb_data_over_mc(string variabl
273   void new_data_mc_agreement_2d() {
274    gStyle->SetOptFit(0);
275    TCut basecut(ZplusBsel&&LeadingB&&EtaB&&PhiZcut);
276 +  const int nalphacuts=6;
277 +  float alphacuts[nalphacuts] = {0.0,0.1,0.15,0.2,0.25,0.3};
278 +  int PointThree=-1;
279 +  for(int i=0;i<nalphacuts;i++) {
280 +    if((alphacuts[i]-0.3)<0.01) PointThree=i;
281 +  }
282 +  if(PointThree<0) {
283 +    write_warning(__FUNCTION__,"alpha=0.3 MUST BE ONE OF THE ALPHA VALUES!");
284 +    assert(PointThree<0);
285 +  }
286    
239  const int nalphacuts=5;
240  float alphacuts[nalphacuts] = {0.1,0.15,0.2,0.25,0.3};
287    const int nptcuts=5;
288    float ptcuts[nptcuts]={10,50,100,200,1000};
289    
# Line 247 | Line 293 | void new_data_mc_agreement_2d() {
293    float RABS_Errors[nalphacuts][nptcuts];
294    
295    
296 <  for(int ia=0;ia<nalphacuts;ia++) {
296 >  for(int ia=0;ia<nalphacuts-1;ia++) {
297      for(int ipt=0;ipt<nptcuts-1;ipt++) {
298        stringstream specialcut;
299 <      specialcut << "((pt>" << ptcuts[ipt] << " && pt< " << ptcuts[ipt+1] << ") && (alpha<" << alphacuts[ia] << "))";
299 >      specialcut << "((pt>" << ptcuts[ipt] << " && pt< " << ptcuts[ipt+1] << ") && (Zb30_alpha<" << alphacuts[ia+1] << "&&Zb30_alpha>" << alphacuts[ia] << "))";
300        Value MPF_data_over_mc = get_Zb_data_over_mc("mpf",TCut(basecut && specialcut.str().c_str()));
301        Value RABS_data_over_mc = get_Zb_data_over_mc("Zb30_pfJetGoodPt[0]/pt",TCut(basecut && specialcut.str().c_str()));
302        
# Line 271 | Line 317 | void new_data_mc_agreement_2d() {
317    
318    TGraphErrors *MPF_FinalGraph = new TGraphErrors();
319    TGraphErrors *RABS_FinalGraph = new TGraphErrors();
320 +  TGraphErrors *FaceValueAtPoint3 = new TGraphErrors();
321    
322    for(int ipt=0;ipt<nptcuts-1;ipt++) {
323      
# Line 285 | Line 332 | void new_data_mc_agreement_2d() {
332        rabs_gr->SetPoint(ia,alphacuts[ia],RABS_Results[ia][ipt]);
333        rabs_gr->SetPointError(ia,0,RABS_Errors[ia][ipt]);
334      }
335 +    FaceValueAtPoint3->SetPoint(ipt,(ptcuts[ipt]+ptcuts[ipt+1]),MPF_Results[PointThree][ipt]);
336 +    FaceValueAtPoint3->SetPointError(ipt,0,MPF_Errors[PointThree][ipt]);
337      
338      mpf_gr->SetMarkerStyle(21);
339      mpf_gr->SetMarkerColor(kBlue);
# Line 374 | Line 423 | void new_data_mc_agreement_2d() {
423    rmpf_final_mark->SetTextSize(0.03);
424    rmpf_final_mark->Draw();
425    DrawPrelim();
426 +  float MPFResult=1/mpf_pol0->GetParameter(0);
427 +  float MPFResultError=mpf_pol0->GetParError(0)/(mpf_pol0->GetParameter(0)*mpf_pol0->GetParameter(0));
428    
429    stringstream filename2;
430    filename2 << "Extrapolation/FINAL_RESULT_MPF";
# Line 400 | Line 451 | void new_data_mc_agreement_2d() {
451    rabs_final_mark->Draw();
452    DrawPrelim();
453    
454 +  float RabsResult=1/rabs_pol0->GetParameter(0);
455 +  float RabsResultError=rabs_pol0->GetParError(0)/(rabs_pol0->GetParameter(0)*rabs_pol0->GetParameter(0));
456 +  
457    filename2.str("");
458    filename2 << "Extrapolation/FINAL_RESULT_RABS";
459    CompleteSave(can,filename2.str());
460    
461    
462 +  TCanvas *FaceValueCanvas = new TCanvas("FaceValueCanvas","FaceValueCanvas");
463 +  FaceValueAtPoint3->SetMarkerStyle(21);
464 +  FaceValueAtPoint3->SetMarkerStyle(21);
465 +  FaceValueAtPoint3->Fit("pol0","QE"); // quiet, use minos
466 +  FaceValueAtPoint3->Draw("AP");
467 +  FaceValueAtPoint3->GetXaxis()->SetTitle("p_{T}^{Z}");
468 +  FaceValueAtPoint3->GetXaxis()->CenterTitle();
469 +  FaceValueAtPoint3->GetYaxis()->SetTitle("data/mc for #alpha<0.3");
470 +  FaceValueAtPoint3->GetYaxis()->CenterTitle();
471 +  FaceValueAtPoint3->Draw("AP");
472 +  TF1 *faceval_pol0=(TF1*)FaceValueAtPoint3->GetFunction("pol0");
473 +  stringstream faceval_result;
474 +  faceval_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/faceval_pol0->GetParameter(0) << " #pm " << std::setprecision(2) << faceval_pol0->GetParError(0)/(faceval_pol0->GetParameter(0)*faceval_pol0->GetParameter(0)) << "}{ (MPF at #alpha<0.3)}";;
475 +  TText *faceval_final_mark = write_title(faceval_result.str());
476 +  faceval_final_mark->SetX(0.75);
477 +  faceval_final_mark->SetY(0.75);
478 +  faceval_final_mark->SetTextSize(0.03);
479 +  faceval_final_mark->Draw();
480 +  DrawPrelim();
481 +  
482 +  float FaceValResult=1/faceval_pol0->GetParameter(0);
483 +  float FaceValResultError=faceval_pol0->GetParError(0)/(faceval_pol0->GetParameter(0)*faceval_pol0->GetParameter(0));
484 +  
485 +  filename2.str("");
486 +  filename2 << "Extrapolation/FINAL_RESULT_RABS";
487 +  CompleteSave(can,filename2.str());
488 +  
489 +  cout << "FINAL RESULTS: " << endl;
490 +  cout << "MPF : " << MPFResult  << " +/- " << MPFResultError  << endl;
491 +  cout << "Rabs: " << RabsResult << " +/- " << RabsResultError << endl;
492 +  cout << "Face value at 0.3 :" << FaceValResult << " +/- " << FaceValResultError << endl;
493 +  
494    delete can;
495    
496    
# Line 412 | Line 498 | void new_data_mc_agreement_2d() {
498  
499  
500  
501 + void compare_selection(string identifier) {
502 +  bool recognized_scenario=false;
503 +  
504 +  cout << "Running with identifier " << identifier << endl;
505 +  if(identifier=="Zb30") {
506 +      LeadingB=TCut ("Zb30_bTagProbCSVBP[0]>0.679");
507 +      EtaB=TCut("abs(Zb30_pfJetGoodEta[0])<1.3");
508 +      PhiZcut=TCut("abs(Zb30_pfJetDphiZ[0])>2.7");
509 +      recognized_scenario=true;
510 +  }
511 +  
512 +  if(identifier=="Zb2030") {
513 +      LeadingB=TCut ("Zb2030_bTagProbCSVBP[0]>0.679");
514 +      EtaB=TCut("abs(Zb2030_pfJetGoodEta[0])<1.3");
515 +      PhiZcut=TCut("abs(Zb2030_pfJetDphiZ[0])>2.7");
516 +      recognized_scenario=true;
517 +  }
518 +  
519 +  if(identifier=="Zb1530") {
520 +      LeadingB=TCut ("Zb1530_bTagProbCSVBP[0]>0.679");
521 +      EtaB=TCut("abs(Zb1530_pfJetGoodEta[0])<1.3");
522 +      PhiZcut=TCut("abs(Zb1530_pfJetDphiZ[0])>2.7");
523 +      recognized_scenario=true;
524 +  }
525 +  
526 +  if(identifier=="Zb3010") {
527 +      LeadingB=TCut ("Zb3010_bTagProbCSVBP[0]>0.679");
528 +      EtaB=TCut("abs(Zb3010_pfJetGoodEta[0])<1.3");
529 +      PhiZcut=TCut("abs(Zb3010_pfJetDphiZ[0])>2.7");
530 +      recognized_scenario=true;
531 +  }
532 +  
533 +  if(identifier=="Zb30_SecEta3") {
534 +      LeadingB=TCut ("Zb30_SecEta3_bTagProbCSVBP[0]>0.679");
535 +      EtaB=TCut("abs(Zb30_SecEta3_pfJetGoodEta[0])<1.3");
536 +      PhiZcut=TCut("abs(Zb30_SecEta3_pfJetDphiZ[0])>2.7");
537 +      recognized_scenario=true;
538 +  }
539 +  
540 +  if(identifier=="Zb30_SecEta5") {
541 +      LeadingB=TCut ("Zb30_SecEta5_bTagProbCSVBP[0]>0.679");
542 +      EtaB=TCut("abs(Zb30_SecEta5_pfJetGoodEta[0])<1.3");
543 +      PhiZcut=TCut("abs(Zb30_SecEta5_pfJetDphiZ[0])>2.7");
544 +      recognized_scenario=true;
545 +  }
546 +  
547 +  if(identifier=="Zb30_p5Clean") {
548 +      LeadingB=TCut ("Zb30_p5Clean_bTagProbCSVBP[0]>0.679");
549 +      EtaB=TCut("abs(Zb30_p5Clean_pfJetGoodEta[0])<1.3");
550 +      PhiZcut=TCut("abs(Zb30_p5Clean_pfJetDphiZ[0])>2.7");
551 +      recognized_scenario=true;
552 +  }
553 +  
554 +  if(identifier=="Zb30CHS") {
555 +      LeadingB=TCut ("Zb30CHS_bTagProbCSVBP[0]>0.679");
556 +      EtaB=TCut("abs(Zb30CHS_pfJetGoodEta[0])<1.3");
557 +      PhiZcut=TCut("abs(Zb30CHS_pfJetDphiZ[0])>2.7");
558 +      recognized_scenario=true;
559 +  }
560 +  
561 +  assert(recognized_scenario);
562 +  
563 +  cout << "Cuts: " << endl;
564 +  cout << "   " << (const char*) LeadingB << endl;
565 +  cout << "   " << (const char*) EtaB << endl;
566 +  cout << "   " << (const char*) PhiZcut << endl;
567 +  
568 +  cout << endl << endl;
569 +  
570 +  SpecialCutFlow(identifier);
571 +  draw_kin_variable("pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",25,0,200,"Z p_{T}","Official/"+identifier+"/Zpt__"+identifier,1);
572 +  draw_kin_variable(identifier+"_pfJetGoodPt[0]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",40,0,200,"Leading Jet Pt (B)","Official/"+identifier+"/LeadingJetPt__"+identifier,1);
573 +  draw_kin_variable(identifier+"_pfJetGoodPt[1]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",40,0,200,"Sub-Leading Jet Pt [GeV]","Official/"+identifier+"/Jet2Pt__"+identifier,1);
574 +  draw_kin_variable(identifier+"_pfJetGoodPt[1]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,0,2,"p_{T}^{J2} / p_{T}^{Z}","Official/"+identifier+"/SubLeadingJetPt_Over_ZPt__"+identifier,1);
575 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<50",20,0,2,"#alpha","Official/"+identifier+"/alpha_pt_10_to_50__"+identifier,1);
576 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>50&&pt<100",20,0,2,"#alpha","Official/"+identifier+"/alpha_50_to_100__"+identifier,1);
577 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>100&&pt<200",20,0,2,"#alpha","Official/"+identifier+"/alpha_pt_100_to_200__"+identifier,1);
578 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>200&&pt<1000",20,0,2,"#alpha","Official/"+identifier+"/alpha_pt_200_to_1000__"+identifier,1);
579 +  draw_kin_variable(identifier+"_pfBJetDphiZ[0]",ZplusBsel&&LeadingB&&"pt>10&&pt<1000&&pfBJetDphiZ[0]>0",30,0,3.2,"#delta#phi (Z,b lead)","Official/"+identifier+"/DeltaPhiZBlead__"+identifier,0);
580 +  
581 +  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>10&&pt<1000&&"+identifier+"_alpha<0.3").c_str()),20,0,2,"Z+b MPF","Official/"+identifier+"/mpf_alpha_smaller_0p3___"+identifier,0,"#alpha<0.3, 10 GeV < p_{T}^{Z} < 1000 GeV");
582 +  draw_kin_variable(identifier+"_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>10&&pt<1000&&"+identifier+"_alpha<0.3").c_str()),20,0,2,"p_{T} b-jet / p_{T} Z","Official/"+identifier+"/ptb_over_ptz___alpha_smaller_0p3______"+identifier,0,"#alpha<0.3, 10 GeV < p_{T}^{Z} < 1000 GeV");
583 +
584 +  
585 +  
586 +  
587 + }
588 +
589   void do_basic_ZB_analysis() {
590    TCanvas *zbcanvas = new TCanvas("zbcanvas","zbcanvas");
417  write_warning(__FUNCTION__,"TESTING NEW DATA MC AGREEMENT");
591    
592 <  /*
593 < //  print_all_b_yields();
592 >  compare_selection("Zb30_p5Clean");
593 >  compare_selection("Zb30CHS");
594 >  compare_selection("Zb30");
595 >  compare_selection("Zb2030");
596 >  compare_selection("Zb1530");
597 >  compare_selection("Zb3010");
598 >  compare_selection("Zb30_SecEta3");
599 >  compare_selection("Zb30_SecEta5"); // buggy, ntuples need to be updated
600 >  compare_selection("Zb1510");
601 >  compare_selection("Zb2010");
602 >  compare_selection("ZbMikko");
603 >  compare_selection("Zb20");
604 >  compare_selection("Zb40");
605 >
606 >  
607 > //    print_all_b_yields();
608   //  draw_mpf_vars();
609 <  draw_Zb_kin_vars();
609 > //  DrawEvilCutFlow();
610 >  
611 > //  draw_Zb_kin_vars();
612 >  
613 > //  new_data_mc_agreement_2d();
614    
424  data_mc_agreement_2d();
425  */
426  new_data_mc_agreement_2d();
615    
616    delete zbcanvas;
617   }
618 +
619 +
620 +
621 +
622 + //*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*  DELETE EVERYTHING BELOW THIS LINE /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*//
623 +
624 +
625 + const char* concatenate(string bla1, string bla2) {
626 +  stringstream bla;
627 +  bla << bla1 << bla2;
628 +  return bla.str().c_str();
629 + }
630 +
631 + void SpecialCutFlow(string identifier) {
632 +  stringstream MegaCut;
633 +  
634 +  
635 +  
636 +  MegaCut << "   1*(" << (const char*) (ZplusBsel&&TCut(concatenate(identifier,"_pfJetGoodNumBtag>0"))) << ")";
637 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB) << ")";
638 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB) << ")";
639 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut) << ")";
640 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000")) << ")";
641 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.3")) << ")";
642 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.2")) << ")";
643 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.15")) << ")";
644 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.1")) << ")";
645 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb30_alpha<0.05")) << ")";
646 +  MegaCut << " ";
647 +  
648 +  TCanvas *can = new TCanvas("can","can");
649 +  can->SetLogy(1);
650 +  TCut basecut("mll>6||mll<10");
651 +  
652 +  
653 +  
654 +  TLegend *leg = allsamples.allbglegend();
655 +  
656 +  
657 +  TH1F *data  = allsamples.Draw("data",    MegaCut.str(),11,-0.5,10.5, "", "events", basecut,data,luminosity);
658 +   THStack mcm = allsamples.DrawStack("mc", MegaCut.str(),11,-0.5,10.5, "", "events", basecut,mc,luminosity);
659 +
660 +  float runningsum=0;
661 +  for(int i=data->GetNbinsX();i>0;i--) {
662 +    runningsum+=data->GetBinContent(i);
663 +    data->SetBinContent(i,runningsum);
664 +  }
665 +  
666 +  float minimum=data->GetMaximum();
667 +  
668 +  TH1F* h;
669 +  TIter nextOF(mcm.GetHists());
670 +  
671 +  float mcsum=0;
672 +  float zb=0;
673 +  while ( h = (TH1F*)nextOF() ) {
674 +    float runningsum=0;
675 +    minimum=data->GetMaximum();//done deliberately at each step so get the minimum of the last (!) contribution
676 +    for(int i=h->GetNbinsX();i>0;i--) {
677 +      runningsum+=h->GetBinContent(i);
678 +      h->SetBinContent(i,runningsum);
679 +      if(runningsum<minimum&&runningsum>0) minimum=runningsum;
680 +    }
681 +    if(Contains(h->GetName(),"Z_b_")) {
682 +      zb=h->GetBinContent(h->GetNbinsX());
683 +    }
684 +    mcsum+=h->GetBinContent(h->GetNbinsX());
685 +  }
686 +  
687 +  
688 +
689 +  data->SetMinimum(0.05*minimum);
690 +  can->cd(1)->SetBottomMargin(0.25);
691 +  data->GetXaxis()->SetBinLabel(1,"Pre-selection");
692 +  data->GetXaxis()->SetBinLabel(2,"Contains b jet");
693 +  data->GetXaxis()->SetBinLabel(3,"Leading jet is b-jet");
694 +  data->GetXaxis()->SetBinLabel(4,"|#eta_{b}|<1.3 ");
695 +  data->GetXaxis()->SetBinLabel(5,"|#delta#phi(b,Z)|>2.7");
696 +  data->GetXaxis()->SetBinLabel(6,"10<p_{T}^{Z}<1000 GeV");
697 +  data->GetXaxis()->SetBinLabel(7,"#alpha < 0.3");
698 +  data->GetXaxis()->SetBinLabel(8,"#alpha < 0.2");
699 +  data->GetXaxis()->SetBinLabel(9,"#alpha < 0.15");
700 +  data->GetXaxis()->SetBinLabel(10,"#alpha < 0.1");
701 +  data->GetXaxis()->SetBinLabel(11,"#alpha < 0.05");
702 +  data->GetXaxis()->LabelsOption("v");
703 +  
704 +  stringstream purityinfo;
705 +  purityinfo << "Purity: " << std::setprecision(3) << 100*zb/mcsum << " %";
706 +  stringstream neventsinfo;
707 +  neventsinfo << "Nevents: " << data->GetBinContent(data->GetNbinsX());
708 +  TH1F *crap = new TH1F("crap","",1,0,1);
709 +  crap->SetLineColor(kWhite);
710 +  leg->AddEntry(crap,purityinfo.str().c_str(),"l");
711 +  leg->AddEntry(crap,neventsinfo.str().c_str(),"l");
712 +  
713 +  data->Draw("e1");
714 +  mcm.Draw("same");
715 +  data->Draw("same,e1,axis");
716 +  data->Draw("same,e1");
717 + //  data->Draw("same,TEXT");
718 +  
719 +  leg->Draw();
720 +  
721 +  DrawPrelim();
722 +  
723 +  CompleteSave(can,"CutFlow___"+identifier);
724 +  
725 +  delete crap;
726 +  delete data;
727 +  
728 +  
729 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines