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.20 by buchmann, Thu Jan 17 16:25:46 2013 UTC vs.
Revision 1.23 by buchmann, Thu Jan 24 08:17:53 2013 UTC

# Line 1 | Line 1
1   #include <iostream>
2   #include <vector>
3   #include <sys/stat.h>
4 + #include <math.h>
5  
6   #include <TCut.h>
7   #include <TROOT.h>
# Line 138 | Line 139 | std::ostream &operator<<(std::ostream &o
139   CutYields print_yield(TCut cut) {
140    
141    CutYields Yield;
141  //cout << __LINE__ << endl;
142    TH1F *data  = allsamples.Draw("data",    "mll",1,0,10000000, "m_{ll} [GeV]", "events", cut,data,luminosity);
143  //cout << __LINE__ << endl;
143    dout << "  Yields for " << (const char*) cut << endl;
145  //cout << __LINE__ << endl;
144   //  dout << "     data: " << data->Integral() << endl;
147  //cout << __LINE__ << endl;
145    
149  //cout << __LINE__ << endl;
146    Yield.data=data->Integral();
151  //cout << __LINE__ << endl;
147    THStack mcm = allsamples.DrawStack("mc", "mll",1,0,10000000, "m_{ll} [GeV]", "events", cut,mc,luminosity);
153  //cout << __LINE__ << endl;
148    int nhists = mcm.GetHists()->GetEntries();
155  //cout << __LINE__ << endl;
156 //  dout << "Going to loop over " << nhists << " histograms " << endl;
157  //cout << __LINE__ << endl;
149    TFile *test = new TFile("test.root","RECREATE");
159  //cout << __LINE__ << endl;
150    mcm.Write();
161  //cout << __LINE__ << endl;
151    test->Close();
163  //cout << __LINE__ << endl;
152    for (int i = 0; i < nhists; i++) {
165  //cout << __LINE__ << endl;
153      TH1* hist = static_cast<TH1*>(mcm.GetHists()->At(i));
167  //cout << __LINE__ << endl;
168 //    cout << "     " << hist->GetName() << ": " << hist->Integral() << endl;
169  //cout << __LINE__ << endl;
154      string name=hist->GetName();
171  //cout << __LINE__ << endl;
155      if(Contains(name,"t_bar_t")) Yield.tt+=hist->Integral();
173  //cout << __LINE__ << endl;
156      if(Contains(name,"W_Jets")) Yield.WJets+=hist->Integral();
175  //cout << __LINE__ << endl;
157      if(Contains(name,"Single_top")) Yield.SiTo+=hist->Integral();
177  //cout << __LINE__ << endl;
158      if(Contains(name,"Dibosons")) Yield.Dibosons+=hist->Integral();
179  //cout << __LINE__ << endl;
159      if(Contains(name,"Z_l_")) Yield.Zl+=hist->Integral();
181  //cout << __LINE__ << endl;
160      if(Contains(name,"Z_c_")) Yield.Zc+=hist->Integral();
183  //cout << __LINE__ << endl;
161      if(Contains(name,"Z_b_")) Yield.Zb+=hist->Integral();
185  //cout << __LINE__ << endl;
162    }
187  //cout << __LINE__ << endl;
163    
189  //cout << __LINE__ << endl;
164    cout << Yield << endl;
191  //cout << __LINE__ << endl;
165    cout << endl << endl;
193  //cout << __LINE__ << endl;
166    
195  //cout << __LINE__ << endl;
167    delete data;
168    CleanLegends();
169    DeleteStack(mcm);
170  
200  //cout << __LINE__ << endl;
171    return Yield;
202  //cout << __LINE__ << endl;
172   }
173  
174   void draw_kin_variable(string variable, TCut cut, int nbins, float min, float max, string xlabel, string saveas, bool dologscale, string speciallabel="") {
# Line 213 | Line 182 | void draw_kin_variable(string variable,
182    
183    float SumMC=0.0;
184    TIter nextH(mcstack.GetHists());
216  cout << __LINE__ << endl;
185    TH1F* h;
218  cout << __LINE__ << endl;
186    while ( h = (TH1F*)nextH() ) {
220  cout << __LINE__ << endl;
187      SumMC += h->Integral();
222  cout << __LINE__ << endl;
188    }
224  cout << __LINE__ << endl;
189    float scale = datahisto->Integral()/SumMC;
226  cout << __LINE__ << endl;
190  
228  cout << __LINE__ << endl;
191    // Re-scale stack to data integral
230  cout << __LINE__ << endl;
192    nextH = TIter(mcstack.GetHists());
232  cout << __LINE__ << endl;
193    
234  cout << __LINE__ << endl;
194    while ( h = (TH1F*)nextH() ) {
236  cout << __LINE__ << endl;
195      h->Scale(scale);
238  cout << __LINE__ << endl;
196    }
240  cout << __LINE__ << endl;
197    
242  cout << __LINE__ << endl;
198    TText *speciall;
244  cout << __LINE__ << endl;
199    datahisto->Draw("e1");
246  cout << __LINE__ << endl;
200    ckin->Update();
248  cout << __LINE__ << endl;
201    mcstack.Draw("histo,same");
250  cout << __LINE__ << endl;
202    datahisto->Draw("same,e1");
252  cout << __LINE__ << endl;
203    TLegend *kinleg = allsamples.allbglegend();
254  cout << __LINE__ << endl;
204  
256  cout << __LINE__ << endl;
205    kinleg->Draw();
258  cout << __LINE__ << endl;
206  
260  cout << __LINE__ << endl;
207    TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
262  cout << __LINE__ << endl;
208    kinpad->cd();
264  cout << __LINE__ << endl;
209    if(dologscale) kinpad->SetLogy(1);
266  cout << __LINE__ << endl;
210    datahisto->Draw("e1");
268  cout << __LINE__ << endl;
211    mcstack.Draw("histo,same");
270  cout << __LINE__ << endl;
212    datahisto->Draw("same,e1");
272  cout << __LINE__ << endl;
213    datahisto->Draw("same,axis");
274  cout << __LINE__ << endl;
214    kinleg->Draw();
276  cout << __LINE__ << endl;
215    DrawPrelim();
278  cout << __LINE__ << endl;
216    saveas="kin/"+saveas;
280  cout << __LINE__ << endl;
217    kinpad->cd();
282  cout << __LINE__ << endl;
218    
284  cout << __LINE__ << endl;
219    if(speciallabel!="") {
286  cout << __LINE__ << endl;
220      speciall = write_title(speciallabel);
288  cout << __LINE__ << endl;
221      speciall->SetX(0.18);
290  cout << __LINE__ << endl;
222      speciall->SetTextAlign(11);
292  cout << __LINE__ << endl;
223      speciall->SetTextSize(0.03);
294  cout << __LINE__ << endl;
224      speciall->SetY(0.85);
296  cout << __LINE__ << endl;
225      speciall->Draw();
298  cout << __LINE__ << endl;
226    }
300  cout << __LINE__ << endl;
227    
302  cout << __LINE__ << endl;
228    save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
304  cout << __LINE__ << endl;
229    
306  cout << __LINE__ << endl;
230    datahisto->Delete();
308  cout << __LINE__ << endl;
231    delete kinleg;
232    delete ckin;
233    CleanLegends();
# Line 328 | Line 250 | void print_all_b_yields() {
250    yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.35"));
251    cout << "#alpha < 0.3" << endl;
252    yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.3"));
331  //cout << __LINE__ << endl;
253   /*  cout << "#alpha < 0.2" << endl;
254    yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.2"));
255    cout << "#alpha < 0.15" << endl;
# Line 336 | Line 257 | void print_all_b_yields() {
257    cout << "#alpha < 0.1" << endl;
258    yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.1"));*/
259  
339  //cout << __LINE__ << endl;
260    for(int iy=0;iy<yields.size();iy++) {
341  //cout << __LINE__ << endl;
261      cout << yields[iy] << endl;
343  //cout << __LINE__ << endl;
262    }
345  //cout << __LINE__ << endl;
346
347  //cout << __LINE__ << endl;
263   }  
264  
265   void DrawEvilCutFlow() {
# Line 494 | Line 409 | Value get_Zb_data_over_mc(string Contain
409    }
410    
411    cn->cd();
412 <  hdata->GetYaxis()->SetTitle("events / 0.1");
412 >  hdata->Rebin(0.05*1200/(1.5-0.5));
413 >  hmc->Rebin(0.05*1200/(1.5-0.5));
414 >  hdata->GetYaxis()->SetTitle("events / 0.05");
415    hdata->SetMarkerColor(kRed);
416    if(DoFit) {
417      gaus_mc->SetLineColor(kBlue);
# Line 504 | Line 421 | Value get_Zb_data_over_mc(string Contain
421    hdata->GetXaxis()->SetRangeUser(0,2);
422    hdata->GetYaxis()->SetTitleOffset(1.3);
423    hdata->Draw("e1");
424 +  
425 +  hmc->Scale(hdata->Integral()/hmc->Integral());
426 +  if(hmc->GetMaximum()>hdata->GetMaximum()) hdata->SetMaximum((hmc->GetMaximum()+sqrt((double)hmc->GetMaximum()))*1.2);
427 +  
428    hmc->Draw("histo,same");
429    hdata->Draw("e1,same");
430    if(DoFit) {
# Line 604 | Line 525 | void DeterminePurity(TCut basecut, int n
525    DeleteStack(mcm);
526   }
527  
528 + string NiceAlphaPrint(float alpha) {
529 +  //get in : 0.3, return 0p3 ...
530 +  stringstream res;
531 +  res << int(alpha) << "p" << int(100*alpha);
532 +  return res.str();
533 + }
534  
535   ZbResultContainer new_data_mc_agreement_2d(bool gofast, string AlphaVariable, string ContainerName, TCut BTagCut, TCut BTagWgt, float FaceValueToBeTakenAt) {
536    
# Line 646 | Line 573 | ZbResultContainer new_data_mc_agreement_
573          ahigh=alphacuts[ia];
574        }
575        cout << specialcut.str() << endl;
576 <      Value MPF_data_over_mc = get_Zb_data_over_mc(ContainerName,results,"mpf","",TCut(basecut && specialcut.str().c_str()),"MPF___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__alpha_"+any2string(alphacuts[ia]), ptcuts[ipt], ptcuts[ipt+1],alow,ahigh);
577 <      Value RABS_data_over_mc = get_Zb_data_over_mc(ContainerName,results,"ZbCHS3010_pfJetGoodPt[0]/pt","",TCut(basecut && specialcut.str().c_str()),"Rabs___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__alpha_"+any2string(alphacuts[ia]), ptcuts[ipt], ptcuts[ipt+1],alow,ahigh);
576 >      Value MPF_data_over_mc = get_Zb_data_over_mc(ContainerName,results,"mpf","",TCut(basecut && specialcut.str().c_str()),"MPF___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__alpha_"+any2string(NiceAlphaPrint(alphacuts[ia])), ptcuts[ipt], ptcuts[ipt+1],alow,ahigh);
577 >      Value RABS_data_over_mc = get_Zb_data_over_mc(ContainerName,results,"ZbCHS3010_pfJetGoodPt[0]/pt","",TCut(basecut && specialcut.str().c_str()),"Rabs___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__alpha_"+any2string(NiceAlphaPrint(alphacuts[ia])), ptcuts[ipt], ptcuts[ipt+1],alow,ahigh);
578        
579        MPF_Results[ia][ipt]=MPF_data_over_mc.getValue();
580        MPF_Errors[ia][ipt]=MPF_data_over_mc.getError();
# Line 715 | Line 642 | ZbResultContainer new_data_mc_agreement_
642      
643      
644      
718 //cout << __LINE__ << endl;
719    
645      if(!gofast) {
646        can->cd();
722 //cout << __LINE__ << endl;
647        mpf_gr->SetMarkerStyle(21);
724 //cout << __LINE__ << endl;
725 //cout << __LINE__ << endl;
648        mpf_gr->SetMarkerColor(kBlue);
727 //cout << __LINE__ << endl;
649        mpf_gr->Draw("AP");
729 //cout << __LINE__ << endl;
650        mpf_gr->Fit("pol1","");
731 //cout << __LINE__ << endl;
651        mpf_gr->GetXaxis()->SetTitle("#alpha");
733 //cout << __LINE__ << endl;
652        mpf_gr->GetXaxis()->CenterTitle();
735 //cout << __LINE__ << endl;
653        mpf_gr->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
737 //cout << __LINE__ << endl;
654        mpf_gr->GetYaxis()->CenterTitle();
739 //cout << __LINE__ << endl;
740 //cout << __LINE__ << endl;
741 //cout << __LINE__ << endl;
655        TF1 *mpf_pol=(TF1*)mpf_gr->GetFunction("pol1");
743 //cout << __LINE__ << endl;
656        mpf_pol->SetLineWidth(0);
745 //cout << __LINE__ << endl;
657        TF1 *mpf_pol_complete = new TF1("mpf_pol_complete","[0]+[1]*x");
747 //cout << __LINE__ << endl;
658        mpf_pol_complete->SetParameters(mpf_pol->GetParameters());
749 //cout << __LINE__ << endl;
659        mpf_pol_complete->SetLineWidth(1);
751 //cout << __LINE__ << endl;
660        mpf_pol_complete->SetLineColor(kBlue);
753 //cout << __LINE__ << endl;
661        
755 //cout << __LINE__ << endl;
662        float min,max;
757 //cout << __LINE__ << endl;
663        FindMinMax(mpf_gr,min,max);
759 //cout << __LINE__ << endl;
664        TH1F *histo = new TH1F("histo","histo",1,0,0.4);
761 //cout << __LINE__ << endl;
665        histo->GetXaxis()->SetTitle("#alpha");
763 //cout << __LINE__ << endl;
666        histo->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
765 //cout << __LINE__ << endl;
766 //cout << __LINE__ << endl;
667        histo->GetXaxis()->CenterTitle();
768 //cout << __LINE__ << endl;
668        histo->GetYaxis()->CenterTitle();
770 //cout << __LINE__ << endl;
669        histo->GetYaxis()->SetTitleOffset(1.3);
772 //cout << __LINE__ << endl;
670        histo->SetStats(0);
774 //cout << __LINE__ << endl;
775 //cout << __LINE__ << endl;
671        histo->GetXaxis()->SetRangeUser(0,0.4);
777 //cout << __LINE__ << endl;
672        histo->GetYaxis()->SetRangeUser(min,max);
779 //cout << __LINE__ << endl;
673        mpf_gr->GetYaxis()->SetRangeUser(min,max);
781 //cout << __LINE__ << endl;
674        
783 //cout << __LINE__ << endl;
675        TPolyLine *mpf_fit_uncert = GetFitUncertaintyShape(mpf_gr, "pol1", min, max,0.0,0.4);
785 //cout << __LINE__ << endl;
676        mpf_pol->SetLineColor(TColor::GetColor("#0101DF"));
787 //cout << __LINE__ << endl;
677        mpf_fit_uncert->SetFillColor(TColor::GetColor("#5353FC"));
789 //cout << __LINE__ << endl;
678        histo->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
791 //cout << __LINE__ << endl;
679        histo->Draw();
793 //cout << __LINE__ << endl;
680        mpf_fit_uncert->Draw("F");
795 //cout << __LINE__ << endl;
796 //cout << __LINE__ << endl;
681        mpf_fit_uncert->Draw("");
798 //cout << __LINE__ << endl;
799 //cout << __LINE__ << endl;
682        mpf_gr->Draw("P");
801 //cout << __LINE__ << endl;
802 //cout << __LINE__ << endl;
683        mpf_pol_complete->Draw("same");
804 //cout << __LINE__ << endl;
684        
806 //cout << __LINE__ << endl;
685        float mpf_a=mpf_pol->GetParameter(0);
808 //cout << __LINE__ << endl;
686        float mpf_b=mpf_pol->GetParameter(1);
810 //cout << __LINE__ << endl;
687        MPF_FinalGraph->SetPoint(ipt,0.5*(ptcuts[ipt]+ptcuts[ipt+1]),mpf_a);
812 //cout << __LINE__ << endl;
813 //cout << __LINE__ << endl;
688        MPF_FinalGraph->SetPointError(ipt,0,mpf_pol->GetParError(0));
815 //cout << __LINE__ << endl;
689        
817 //cout << __LINE__ << endl;
818 //cout << __LINE__ << endl;
690        MPF_ExtraPolatedResults[ipt]=mpf_a;
820 //cout << __LINE__ << endl;
821 //cout << __LINE__ << endl;
691        
823 //cout << __LINE__ << endl;
824 //cout << __LINE__ << endl;
692        stringstream mpf_info;
826 //cout << __LINE__ << endl;
693        mpf_info <<  "#splitline{#splitline{#splitline{" << ptcuts[ipt] << " GeV < p_{T}^{Z} < " << ptcuts[ipt+1] << " GeV }{ (MPF) }}{Extrapolated value: " << std::setprecision(4) << mpf_a << "}}{#chi^{2}/NDF : " << mpf_pol->GetChisquare() << " / " << mpf_pol->GetNDF() << "}";
828 //cout << __LINE__ << endl;
694        
830 //cout << __LINE__ << endl;
831 //cout << __LINE__ << endl;
695        TText *mpf_mark = write_title(mpf_info.str());
833 //cout << __LINE__ << endl;
696        mpf_mark->SetX(0.75);
835 //cout << __LINE__ << endl;
836 //cout << __LINE__ << endl;
697        mpf_mark->SetTextSize(0.03);
838 //cout << __LINE__ << endl;
698        mpf_mark->SetY(0.75);
840 //cout << __LINE__ << endl;
699        mpf_mark->Draw();
842 //cout << __LINE__ << endl;
843 //cout << __LINE__ << endl;
844 //cout << __LINE__ << endl;
700        
846 //cout << __LINE__ << endl;
701        string filenamebkp=filename.str();
848 //cout << __LINE__ << endl;
702        filename << "__MPF";
850 //cout << __LINE__ << endl;
703        DrawPrelim();
852 //cout << __LINE__ << endl;
704        CompleteSave(can,ContainerName+"/"+filename.str());
854 //cout << __LINE__ << endl;
705        cout << "MPF : " << mpf_a << " + " << mpf_b << " * alpha " << endl;
856 //cout << __LINE__ << endl;
706        
858 //cout << __LINE__ << endl;
707        filename.str("");
860 //cout << __LINE__ << endl;
708        
862 //cout << __LINE__ << endl;
863 //cout << __LINE__ << endl;
709        rabs_gr->SetMarkerStyle(21);
865 //cout << __LINE__ << endl;
866 //cout << __LINE__ << endl;
867 //cout << __LINE__ << endl;
710        rabs_gr->SetMarkerColor(kRed);
869 //cout << __LINE__ << endl;
711        rabs_gr->Draw("AP");
871 //cout << __LINE__ << endl;
712        rabs_gr->Fit("pol1","");
873 //cout << __LINE__ << endl;
874 //cout << __LINE__ << endl;
713        rabs_gr->GetXaxis()->SetTitle("#alpha");
876 //cout << __LINE__ << endl;
714        rabs_gr->GetXaxis()->CenterTitle();
878 //cout << __LINE__ << endl;
715        rabs_gr->GetYaxis()->SetTitle("<R_{abs}>_{data}/<R_{abs}>_{mc}");
880 //cout << __LINE__ << endl;
881 //cout << __LINE__ << endl;
882 //cout << __LINE__ << endl;
716        rabs_gr->GetYaxis()->CenterTitle();
884 //cout << __LINE__ << endl;
717        TF1 *rabs_pol=(TF1*)rabs_gr->GetFunction("pol1");
886 //cout << __LINE__ << endl;
718        rabs_pol->SetLineWidth(0);
888 //cout << __LINE__ << endl;
889 //cout << __LINE__ << endl;
719        TF1 *rabs_pol_complete = new TF1("rabs_pol_complete","[0]+[1]*x");
891 //cout << __LINE__ << endl;
720        rabs_pol_complete->SetParameters(rabs_pol->GetParameters());
893 //cout << __LINE__ << endl;
721        rabs_pol_complete->SetLineColor(kRed);
895 //cout << __LINE__ << endl;
722        rabs_pol_complete->SetLineWidth(1);
897 //cout << __LINE__ << endl;
898 //cout << __LINE__ << endl;
899 //cout << __LINE__ << endl;
723        FindMinMax(rabs_gr,min,max);
901 //cout << __LINE__ << endl;
724        rabs_gr->GetYaxis()->SetRangeUser(min,max);
903 //cout << __LINE__ << endl;
904 //cout << __LINE__ << endl;
905 //cout << __LINE__ << endl;
906 //cout << __LINE__ << endl;
725        histo->GetYaxis()->SetRangeUser(min,max);
908 //cout << __LINE__ << endl;
726        TPolyLine *rabs_fit_uncert = GetFitUncertaintyShape(rabs_gr, "pol1", min, max,0.0,0.4);
910 //cout << __LINE__ << endl;
727        rabs_pol->SetLineColor(TColor::GetColor("#FA5858"));
912 //cout << __LINE__ << endl;
728        rabs_pol->SetFillColor(TColor::GetColor("#FA5858"));
914 //cout << __LINE__ << endl;
729        rabs_fit_uncert->SetLineColor(TColor::GetColor("#FA5858"));
916 //cout << __LINE__ << endl;
730        rabs_fit_uncert->SetFillColor(TColor::GetColor("#FA5858"));
918 //cout << __LINE__ << endl;
919 //cout << __LINE__ << endl;
731        histo->GetYaxis()->SetTitle("<R_{abs}>_{data}/<R_{abs}>_{mc}");
921 //cout << __LINE__ << endl;
732        histo->Draw();
923 //cout << __LINE__ << endl;
733        rabs_fit_uncert->Draw("F");
925 //cout << __LINE__ << endl;
734        rabs_fit_uncert->Draw("");
927 //cout << __LINE__ << endl;
735        rabs_gr->Draw("P");
929 //cout << __LINE__ << endl;
736        rabs_pol_complete->Draw("same");
931 //cout << __LINE__ << endl;
932 //cout << __LINE__ << endl;
737        
934 //cout << __LINE__ << endl;
935 //cout << __LINE__ << endl;
936      
937 //cout << __LINE__ << endl;
938 //cout << __LINE__ << endl;
738        float rabs_a=rabs_pol->GetParameter(0);
940 //cout << __LINE__ << endl;
941 //cout << __LINE__ << endl;
739        float rabs_b=rabs_pol->GetParameter(1);
943 //cout << __LINE__ << endl;
740        RABS_FinalGraph->SetPoint(ipt,0.5*(ptcuts[ipt]+ptcuts[ipt+1]),rabs_a);
945 //cout << __LINE__ << endl;
741        RABS_FinalGraph->SetPointError(ipt,0,rabs_pol->GetParError(0));
947 //cout << __LINE__ << endl;
742        
949 //cout << __LINE__ << endl;
743        cout << "!+!+!+!+!+!+!+!+!+ Just added a point to the final plot : " << rabs_a << " +/- " << rabs_pol->GetParError(0) << endl;
951 //cout << __LINE__ << endl;
744        
953 //cout << __LINE__ << endl;
745        stringstream rabs_info;
955 //cout << __LINE__ << endl;
746        rabs_info << "#splitline{#splitline{#splitline{" << ptcuts[ipt] << " GeV < p_{T}^{Z} < " << ptcuts[ipt+1] << " GeV }{ (R_{abs}) }}{Extrapolated value: " << std::setprecision(4) << rabs_a << "}}{#chi^{2}/NDF : " << rabs_pol->GetChisquare() << " / " << rabs_pol->GetNDF() << "}";
957 //cout << __LINE__ << endl;
747        TText *rabs_mark = write_title(rabs_info.str());
959 //cout << __LINE__ << endl;
748        rabs_mark->SetX(0.75);
961 //cout << __LINE__ << endl;
749        rabs_mark->SetTextSize(0.03);
963 //cout << __LINE__ << endl;
750        rabs_mark->SetY(0.75);
965 //cout << __LINE__ << endl;
751        rabs_mark->Draw();
967 //cout << __LINE__ << endl;
752        
969 //cout << __LINE__ << endl;
753        RABS_ExtraPolatedResults[ipt]=rabs_a;
971 //cout << __LINE__ << endl;
754        filename << filenamebkp << "__RABS";
973 //cout << __LINE__ << endl;
755        DrawPrelim();
975 //cout << __LINE__ << endl;
756        CompleteSave(can,ContainerName+"/"+filename.str());
977 //cout << __LINE__ << endl;
978 //cout << __LINE__ << endl;
757        cout << "RABS : " << rabs_a << " + " << rabs_b << " * alpha " << endl;
980 //cout << __LINE__ << endl;
981 //cout << __LINE__ << endl;
758      }
983 //cout << __LINE__ << endl;
759    }
985 //cout << __LINE__ << endl;
760    
987 //cout << __LINE__ << endl;
761    float MPFResult;
989 //cout << __LINE__ << endl;
762    float MPFResultError;
991 //cout << __LINE__ << endl;
992 //cout << __LINE__ << endl;
763    
994 //cout << __LINE__ << endl;
995 //cout << __LINE__ << endl;
764    float RabsResult;
997 //cout << __LINE__ << endl;
765    float RabsResultError;
999 //cout << __LINE__ << endl;
766  
1001 //cout << __LINE__ << endl;
767    if(!gofast) {
1003 //cout << __LINE__ << endl;
768      MPF_FinalGraph->SetMarkerStyle(21);
1005 //cout << __LINE__ << endl;
769      MPF_FinalGraph->SetMarkerColor(kBlue);
1007 //cout << __LINE__ << endl;
770      MPF_FinalGraph->Fit("pol0",""); // quiet, use minos
1009 //cout << __LINE__ << endl;
1010 //cout << __LINE__ << endl;
771      
1012 //cout << __LINE__ << endl;
772      TF1 *mpf_pol0=(TF1*)MPF_FinalGraph->GetFunction("pol0");
1014 //cout << __LINE__ << endl;
1015 //cout << __LINE__ << endl;
773      TF1 *mpf_pol0_complete = new TF1("mpf_pol0_complete","[0]+[1]*x");
1017 //cout << __LINE__ << endl;
1018 //cout << __LINE__ << endl;
774      mpf_pol0_complete->SetLineWidth(1);
1020 //cout << __LINE__ << endl;
775      mpf_pol0_complete->SetLineColor(kBlue);
1022 //cout << __LINE__ << endl;
1023 //cout << __LINE__ << endl;
1024 //cout << __LINE__ << endl;
776      mpf_pol0->SetLineColor(kBlue);
1026 //cout << __LINE__ << endl;
777      MPF_FinalGraph->Draw("AP");
1028 //cout << __LINE__ << endl;
778      MPF_FinalGraph->GetXaxis()->SetTitle("p_{T}^{Z}");
1030 //cout << __LINE__ << endl;
779      MPF_FinalGraph->GetXaxis()->CenterTitle();
1032 //cout << __LINE__ << endl;
780      MPF_FinalGraph->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
1034 //cout << __LINE__ << endl;
781      MPF_FinalGraph->GetYaxis()->CenterTitle();
1036 //cout << __LINE__ << endl;
782      MPF_FinalGraph->Draw("AP");
1038 //cout << __LINE__ << endl;
783      mpf_pol0_complete->Draw("same");
1040 //cout << __LINE__ << endl;
784      
1042 //cout << __LINE__ << endl;
785      stringstream mpf_result;
1044 //cout << __LINE__ << endl;
786      mpf_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/mpf_pol0->GetParameter(0) << " #pm " << std::setprecision(2) << mpf_pol0->GetParError(0)/(mpf_pol0->GetParameter(0)*mpf_pol0->GetParameter(0)) << "}{ (MPF)}";
787      TText *rmpf_final_mark = write_title(mpf_result.str());
788      rmpf_final_mark->SetX(0.75);
# Line 1052 | Line 793 | ZbResultContainer new_data_mc_agreement_
793      MPFResult=1/mpf_pol0->GetParameter(0);
794      MPFResultError=mpf_pol0->GetParError(0)/(mpf_pol0->GetParameter(0)*mpf_pol0->GetParameter(0));
795      
1055 //cout << __LINE__ << endl;
796      stringstream filename2;
797      filename2 << "Extrapolation/FINAL_RESULT_MPF";
798      CompleteSave(can,ContainerName+"/"+filename2.str());
799      
1060 //cout << __LINE__ << endl;
800      RABS_FinalGraph->SetMarkerStyle(21);
801      RABS_FinalGraph->SetMarkerStyle(21);
802      RABS_FinalGraph->SetMarkerColor(kRed);
803      RABS_FinalGraph->Fit("pol0","QE"); // quiet, use minos
804      RABS_FinalGraph->Draw("AP");
1066 //cout << __LINE__ << endl;
805      RABS_FinalGraph->GetXaxis()->SetTitle("p_{T}^{Z}");
806      RABS_FinalGraph->GetXaxis()->CenterTitle();
807      RABS_FinalGraph->GetYaxis()->SetTitle("<R_{abs}>_{data}/<R_{abs}>_{mc}");
808      RABS_FinalGraph->GetYaxis()->CenterTitle();
1071 //cout << __LINE__ << endl;
809      RABS_FinalGraph->Draw("AP");
810      TF1 *rabs_pol0=(TF1*)RABS_FinalGraph->GetFunction("pol0");
811      stringstream rabs_result;
812      rabs_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/rabs_pol0->GetParameter(0) << " #pm " << std::setprecision(2) << rabs_pol0->GetParError(0)/(rabs_pol0->GetParameter(0)*rabs_pol0->GetParameter(0)) << "}{ (R_{abs})}";;
813      TText *rabs_final_mark = write_title(rabs_result.str());
1077 //cout << __LINE__ << endl;
814      rabs_final_mark->SetX(0.75);
815      rabs_final_mark->SetY(0.75);
816      rabs_final_mark->SetTextSize(0.03);
817      rabs_final_mark->Draw();
1082 //cout << __LINE__ << endl;
818      DrawPrelim();
819      
820      RabsResult=1/rabs_pol0->GetParameter(0);
1086 //cout << __LINE__ << endl;
821      RabsResultError=rabs_pol0->GetParError(0)/(rabs_pol0->GetParameter(0)*rabs_pol0->GetParameter(0));
822      
823      filename2.str("");
1090 //cout << __LINE__ << endl;
824      filename2 << "Extrapolation/FINAL_RESULT_RABS";
825      CompleteSave(can,ContainerName+"/"+filename2.str());
826    }
1094 //cout << __LINE__ << endl;
827  
828    can->cd();
829    MPF_FaceValueAtPoint3->SetMarkerStyle(21);
1098 //cout << __LINE__ << endl;
830    MPF_FaceValueAtPoint3->SetMarkerColor(kBlue);
831    MPF_FaceValueAtPoint3->Fit("pol0","QE"); // quiet, use minos
832    MPF_FaceValueAtPoint3->Draw("AP");
833    MPF_FaceValueAtPoint3->GetXaxis()->SetTitle("p_{T}^{Z}");
1103 //cout << __LINE__ << endl;
834    MPF_FaceValueAtPoint3->GetXaxis()->CenterTitle();
835    MPF_FaceValueAtPoint3->GetYaxis()->SetTitle(((string)"<MPF>__{data}/<MPF>_{mc} for #alpha<"+any2string(FaceValueToBeTakenAt)).c_str());
836    MPF_FaceValueAtPoint3->GetYaxis()->CenterTitle();
1107 //cout << __LINE__ << endl;
837    MPF_FaceValueAtPoint3->Draw("AP");
838    TF1 *faceval_pol0=(TF1*)MPF_FaceValueAtPoint3->GetFunction("pol0");
839    faceval_pol0->SetLineColor(kBlue);
840    faceval_pol0->SetLineWidth(1);
1112 //cout << __LINE__ << endl;
841    faceval_pol0->Draw("same");
842    TF1 *faceval_pol0_complete = new TF1("faceval_pol0_complete","[0]+[1]*x");
843    faceval_pol0_complete->SetParameters(faceval_pol0->GetParameters());
844    stringstream faceval_result;
845    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<" << FaceValueToBeTakenAt << ")}";;
1118 //cout << __LINE__ << endl;
846    TText *faceval_final_mark = write_title(faceval_result.str());
847    faceval_final_mark->SetX(0.75);
848    faceval_final_mark->SetY(0.75);
1122 //cout << __LINE__ << endl;
849    faceval_final_mark->SetTextSize(0.03);
850    faceval_final_mark->Draw();
851    DrawPrelim();
1126 //cout << __LINE__ << endl;
852    
853    float FaceValResult=1/faceval_pol0->GetParameter(0);
854    float FaceValResultError=faceval_pol0->GetParError(0)/(faceval_pol0->GetParameter(0)*faceval_pol0->GetParameter(0));
1130 //cout << __LINE__ << endl;
855    
856    stringstream filename2;
857    filename2.str("");
1134 //cout << __LINE__ << endl;
858    filename2 << "Extrapolation/FINAL_RESULT_MPF_FaceValp3";
859    CompleteSave(can,ContainerName+"/"+filename2.str());
860    
1138 //cout << __LINE__ << endl;
861    can->cd();
862    RABS_FaceValueAtPoint3->SetMarkerStyle(21);
863    RABS_FaceValueAtPoint3->SetMarkerColor(kRed);
1142 //cout << __LINE__ << endl;
864    RABS_FaceValueAtPoint3->Fit("pol0","QE"); // quiet, use minos
865    RABS_FaceValueAtPoint3->Draw("AP");
866    RABS_FaceValueAtPoint3->GetXaxis()->SetTitle("p_{T}^{Z}");
867    RABS_FaceValueAtPoint3->GetXaxis()->CenterTitle();
1147 //cout << __LINE__ << endl;
868    RABS_FaceValueAtPoint3->GetYaxis()->SetTitle(((string)"<R_{abs}>_{data}/<R_{abs}>_{mc} for #alpha<"+any2string(FaceValueToBeTakenAt)).c_str());
869    RABS_FaceValueAtPoint3->GetYaxis()->CenterTitle();
870    RABS_FaceValueAtPoint3->Draw("AP");
1151 //cout << __LINE__ << endl;
871    TF1 *faceval_pol0RABS=(TF1*)RABS_FaceValueAtPoint3->GetFunction("pol0");
872    TF1 *faceval_pol0RABS_complete = new TF1("faceval_pol0_complete","[0]+[1]*x");
873    faceval_pol0RABS_complete->SetParameters(faceval_pol0RABS->GetParameters());
1155 //cout << __LINE__ << endl;
874    faceval_pol0RABS->SetLineWidth(1);
875    faceval_pol0RABS->SetLineColor(kRed);
876    faceval_pol0RABS_complete->Draw("same");
1159 //cout << __LINE__ << endl;
877    stringstream RABSfaceval_result;
878    RABSfaceval_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/faceval_pol0RABS->GetParameter(0) << " #pm " << std::setprecision(2) << faceval_pol0RABS->GetParError(0)/(faceval_pol0RABS->GetParameter(0)*faceval_pol0RABS->GetParameter(0)) << "}{ (R_{abs} at #alpha<" << FaceValueToBeTakenAt << ")}";;
879    TText *RABSfaceval_final_mark = write_title(RABSfaceval_result.str());
1163 //cout << __LINE__ << endl;
880    RABSfaceval_final_mark->SetX(0.75);
881    RABSfaceval_final_mark->SetY(0.75);
882    RABSfaceval_final_mark->SetTextSize(0.03);
1167 //cout << __LINE__ << endl;
883    RABSfaceval_final_mark->Draw();
884    DrawPrelim();
885    
1171 //cout << __LINE__ << endl;
886    float RABSFaceValResult=1/faceval_pol0RABS->GetParameter(0);
887    float RABSFaceValResultError=faceval_pol0RABS->GetParError(0)/(faceval_pol0RABS->GetParameter(0)*faceval_pol0RABS->GetParameter(0));
888    
889    filename2.str("");
1176 //cout << __LINE__ << endl;
890    filename2 << "Extrapolation/FINAL_RESULT_RABS_FaceValp3";
891    CompleteSave(can,ContainerName+"/"+filename2.str());
892    
893    cout << "FINAL RESULTS: " << endl;
1181 //cout << __LINE__ << endl;
894    if(!gofast) cout << "MPF : " << MPFResult  << " +/- " << MPFResultError  << endl;
895    if(!gofast) cout << "Rabs: " << RabsResult << " +/- " << RabsResultError << endl;
896    cout << "Face value at " << FaceValueToBeTakenAt << " :" << FaceValResult << " +/- " << FaceValResultError << "  (MPF) " << endl;
897    cout << "Face value at " << FaceValueToBeTakenAt << " :" << RABSFaceValResult << " +/- " << RABSFaceValResultError << "  (RABS) " << endl;
1186 //cout << __LINE__ << endl;
898    
899    delete can;
900    
901    results.MPF_Result_FaceValue=Value(FaceValResult,FaceValResultError);
902    results.Rabs_Result_FaceValue=Value(RABSFaceValResult,RABSFaceValResultError);
1192 //cout << __LINE__ << endl;
903    if(!gofast) results.MPF_Result_Extrapolated=Value(MPFResult,MPFResultError);
904    if(!gofast) results.Rabs_Result_Extrapolated=Value(RabsResult,RabsResultError);
905    cout << results << endl;
906    return results;
1197 //cout << __LINE__ << endl;
907   }
908  
909  
# Line 1313 | Line 1022 | void ScenarioComparison() {
1022      }
1023      
1024      
1025 +    gStyle->SetOptFit(0);
1026      gr[i]->SetTitle();
1027      gr[i]->GetXaxis()->SetTitle("N(Vtx)");
1028      gr[i]->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
# Line 1648 | Line 1358 | void TEST_GetNumberEventsInsideOutsideAl
1358   }
1359    
1360  
1361 <
1361 > void MetSpectrumDepletionIllustration(int isdata) {
1362 >  
1363 >  TCanvas *can = new TCanvas("can","can");
1364 >  TCut basecut(ZplusBsel&&LeadingB&&EtaB&&PhiZcut);
1365 >  
1366 >  cutWeight=STDWEIGHT*TCut("ZbCHS3010_BTagWgtTUp*(1.0)*(ZbCHS3010_bTagProbCSVBP[0]>0.898)");
1367 >  TH1F *standard  = allsamples.Draw("standard","met[1]",80,0,400, "MET [GeV]", "events", basecut,isdata,luminosity);
1368 >  
1369 >  cutWeight=STDWEIGHT*TCut("ZbCHS3010_BTagWgtTUp*(1.0*softMuon)*(ZbCHS3010_bTagProbCSVBP[0]>0.898)");
1370 >  TH1F *Neutrinos  = allsamples.Draw("Neutrinos","met[1]",80,0,400, "MET [GeV]", "events", basecut,isdata,luminosity);
1371 >  
1372 >  cutWeight=STDWEIGHT*TCut("ZbCHS3010_BTagWgtTUp*(1.0*(1.0-softMuon))*(ZbCHS3010_bTagProbCSVBP[0]>0.898)");
1373 >  TH1F *NoNeutrinos  = allsamples.Draw("NoNeutrinos","met[1]",80,0,400, "MET [GeV]", "events", basecut,isdata,luminosity);
1374 >  
1375 >  standard->Scale(1.0/standard->Integral());
1376 >  Neutrinos->Scale(1.0/Neutrinos->Integral());
1377 >  NoNeutrinos->Scale(1.0/NoNeutrinos->Integral());
1378 >  
1379 >  Neutrinos->SetLineColor(kGreen);
1380 >  NoNeutrinos->SetLineColor(kRed);
1381 >  
1382 >  can->SetLogy(1);
1383 >  TLegend *leg = make_legend();
1384 >  leg->AddEntry(standard,"Standard sample","ep");
1385 >  leg->AddEntry(Neutrinos,"#nu enriched sample","l");
1386 >  leg->AddEntry(NoNeutrinos,"#nu depleted sample","l");
1387 >  leg->SetX1(0.9*leg->GetX1());
1388 >  standard->Draw("e1");
1389 >  Neutrinos->Draw("histo,same");
1390 >  NoNeutrinos->Draw("histo,same");
1391 >  if(isdata==data) leg->SetHeader("Data:");
1392 >  else leg->SetHeader("MC:");
1393 >  leg->Draw();
1394 >  DrawPrelim();
1395 >  
1396 >  if(isdata==data) CompleteSave(can,"NeutrinoMetSpectrum__Data");
1397 >  else CompleteSave(can,"NeutrinoMetSpectrum__MC");
1398 >  delete standard;
1399 >  delete Neutrinos;
1400 >  delete NoNeutrinos;
1401 >  delete can;
1402 >  CleanLegends();
1403 > }
1404 >  
1405 >  
1406 >  
1407 >  
1408 >  
1409 >  
1410      
1411   void do_basic_ZB_analysis(bool DoCompleteAnalysis) {
1412    STDWEIGHT=TCut(cutWeight);
# Line 1658 | Line 1416 | void do_basic_ZB_analysis(bool DoComplet
1416    
1417     TCanvas *zbcanvas = new TCanvas("zbcanvas","zbcanvas");
1418    
1419 < //   ScenarioComparison();
1420 < //   ScenarioComparisonInclusive();
1421 <
1419 >  
1420 >   MetSpectrumDepletionIllustration(data);
1421 >   MetSpectrumDepletionIllustration(mc);
1422 >   assert(0);
1423 >  
1424   //   compare_selection("ZbCHS3010_p5Clean");
1425   //   compare_selection("ZbCHS3010");
1426   //   compare_selection("Zb30");
# Line 1679 | Line 1439 | void do_basic_ZB_analysis(bool DoComplet
1439   //   compare_selection("Zb40");
1440  
1441    if(!doquick) {
1442 <    //draw_kin_variable("mll","",28,60.0,200.0,"m_{ll}","mll",1,"");//nice and quick test to see if the normalization is ok (i.e. all data is processed etc.)
1442 >    draw_kin_variable("mll","",28,60.0,200.0,"m_{ll}","mll",1,"");//nice and quick test to see if the normalization is ok (i.e. all data is processed etc.)
1443      //print_all_b_yields();
1444 <    draw_mpf_vars();
1444 > //     draw_mpf_vars();
1445      //DrawEvilCutFlow();
1446          
1447 <    draw_Zb_kin_vars();
1447 > //     draw_Zb_kin_vars();
1448          
1449     }
1450    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines