556 |
|
|
557 |
|
|
558 |
|
*/ |
559 |
+ |
|
560 |
+ |
|
561 |
+ |
void DoNewExperimentalMetPrediction() { |
562 |
+ |
// Do it without Pt correction |
563 |
+ |
float MCPeakNoPtCorr=0,MCPeakErrorNoPtCorr=0,DataPeakNoPtCorr=0,DataPeakErrorNoPtCorr=0,MCSigma=0,DataSigma=0; |
564 |
+ |
stringstream resultsNoPtCorr; |
565 |
+ |
stringstream NoPtCorrdatajzb; |
566 |
+ |
stringstream NoPtCorrmcjzb; |
567 |
+ |
|
568 |
+ |
string originalJZBvariableDATA = PlottingSetup::jzbvariabledata; |
569 |
+ |
string originalJZBvariableMC = PlottingSetup::jzbvariablemc; |
570 |
+ |
|
571 |
+ |
PlottingSetup::jzbvariabledata="jzb[1]"; |
572 |
+ |
PlottingSetup::jzbvariablemc="jzb[1]"; |
573 |
+ |
|
574 |
+ |
stringstream mcjzbNoPtCorr; |
575 |
+ |
find_peaks(MCPeakNoPtCorr,MCPeakErrorNoPtCorr, DataPeakNoPtCorr, DataPeakErrorNoPtCorr,resultsNoPtCorr,true,NoPtCorrdatajzb,NoPtCorrmcjzb); |
576 |
+ |
string mcjzb = NoPtCorrmcjzb.str(); |
577 |
+ |
|
578 |
+ |
PlottingSetup::jzbvariabledata=originalJZBvariableDATA; |
579 |
+ |
PlottingSetup::jzbvariablemc=originalJZBvariableMC; |
580 |
+ |
|
581 |
+ |
cout << "Have found a peak in mc at " << MCPeakNoPtCorr << " +/- " << MCPeakErrorNoPtCorr << " ; will use this result." << endl; |
582 |
+ |
|
583 |
+ |
string CorrectedMet="met[4]+"+any2string(abs(2*(MCPeakNoPtCorr))); |
584 |
+ |
if(2*(MCPeakNoPtCorr)<0) CorrectedMet="met[4]-"+any2string(2*(MCPeakNoPtCorr)); |
585 |
+ |
string CorrectedMetUp="met[4]+"+any2string(abs(2*(MCPeakNoPtCorr+MCPeakErrorNoPtCorr))); |
586 |
+ |
if(2*(MCPeakNoPtCorr+MCPeakErrorNoPtCorr)<0) "met[4]-"+any2string(abs(2*(MCPeakNoPtCorr+MCPeakErrorNoPtCorr))); |
587 |
+ |
string CorrectedMetDown="met[4]+"+any2string(abs(2*(MCPeakNoPtCorr-MCPeakErrorNoPtCorr))); |
588 |
+ |
if(2*(MCPeakNoPtCorr-MCPeakErrorNoPtCorr)<0) "met[4]-"+any2string(abs(2*(MCPeakNoPtCorr+MCPeakErrorNoPtCorr))); |
589 |
+ |
|
590 |
+ |
do_experimental_zjets_prediction("met[4]",CorrectedMet,"jzb[1]",MCPeakNoPtCorr,"CovertMapping"); |
591 |
+ |
do_experimental_zjets_prediction("met[4]",CorrectedMetDown,"jzb[1]",(MCPeakNoPtCorr-MCPeakErrorNoPtCorr),"CovertMapping_SysDown"); |
592 |
+ |
do_experimental_zjets_prediction("met[4]",CorrectedMetUp,"jzb[1]",(MCPeakNoPtCorr+MCPeakErrorNoPtCorr),"CovertMapping_SysUp"); |
593 |
+ |
|
594 |
+ |
|
595 |
+ |
} |
596 |
+ |
|
597 |
+ |
void DoNewExperimentalMetPrediction_WithPtCorrection() { |
598 |
+ |
// Do it with Pt correction |
599 |
+ |
float MCPeakWithPtCorr=0,MCPeakErrorWithPtCorr=0,DataPeakWithPtCorr=0,DataPeakErrorWithPtCorr=0,MCSigma=0,DataSigma=0; |
600 |
+ |
stringstream resultsWithPtCorr; |
601 |
+ |
stringstream WithPtCorrdatajzb; |
602 |
+ |
stringstream WithPtCorrmcjzb; |
603 |
+ |
|
604 |
+ |
string originalJZBvariableDATA = PlottingSetup::jzbvariabledata; |
605 |
+ |
string originalJZBvariableMC = PlottingSetup::jzbvariablemc; |
606 |
+ |
|
607 |
+ |
stringstream mcjzbWithPtCorr; |
608 |
+ |
// find_peaks(MCPeakWithPtCorr,MCPeakErrorWithPtCorr, DataPeakWithPtCorr, DataPeakErrorWithPtCorr,resultsWithPtCorr,true,WithPtCorrdatajzb,WithPtCorrmcjzb); |
609 |
+ |
write_warning(__FUNCTION__,"Hardcoded peak position");MCPeakWithPtCorr=3.58273,MCPeakErrorWithPtCorr=0.208997; |
610 |
+ |
|
611 |
+ |
string mcjzb = WithPtCorrmcjzb.str(); |
612 |
+ |
|
613 |
+ |
cout << "Have found a peak in mc at " << MCPeakWithPtCorr << " +/- " << MCPeakErrorWithPtCorr << " ; will use this result." << endl; |
614 |
+ |
|
615 |
+ |
string CorrectedMet="met[4]+"+any2string(abs(2*(MCPeakWithPtCorr))); |
616 |
+ |
if(2*(MCPeakWithPtCorr)<0) CorrectedMet="met[4]-"+any2string(2*(MCPeakWithPtCorr)); |
617 |
+ |
string CorrectedMetUp="met[4]+"+any2string(abs(2*(MCPeakWithPtCorr+MCPeakErrorWithPtCorr))); |
618 |
+ |
if(2*(MCPeakWithPtCorr+MCPeakErrorWithPtCorr)<0) "met[4]-"+any2string(abs(2*(MCPeakWithPtCorr+MCPeakErrorWithPtCorr))); |
619 |
+ |
string CorrectedMetDown="met[4]+"+any2string(abs(2*(MCPeakWithPtCorr-MCPeakErrorWithPtCorr))); |
620 |
+ |
if(2*(MCPeakWithPtCorr-MCPeakErrorWithPtCorr)<0) "met[4]-"+any2string(abs(2*(MCPeakWithPtCorr+MCPeakErrorWithPtCorr))); |
621 |
+ |
|
622 |
+ |
do_experimental_zjets_prediction("met[4]",CorrectedMet,originalJZBvariableMC,MCPeakWithPtCorr,"CovertMapping_WithPtCorr_AdaptedPredMet"); |
623 |
+ |
// do_experimental_zjets_prediction("met[4]",CorrectedMetDown,originalJZBvariableMC,(MCPeakWithPtCorr-MCPeakErrorWithPtCorr),"CovertMapping_WithPtCorr_AdaptedPredMet_SysDown"); |
624 |
+ |
// do_experimental_zjets_prediction("met[4]",CorrectedMetUp,originalJZBvariableMC,(MCPeakWithPtCorr+MCPeakErrorWithPtCorr),"CovertMapping_WithPtCorr_AdaptedPredMet_SysUp"); |
625 |
+ |
|
626 |
+ |
do_experimental_zjets_prediction("met[4]",CorrectedMet+"+0.036*pt",originalJZBvariableMC,MCPeakWithPtCorr,"CovertMapping_WithPtCorr_AdaptedPredMetWithPtDep"); |
627 |
+ |
|
628 |
+ |
// do_experimental_zjets_prediction("met[4]","met[4]",originalJZBvariableMC,MCPeakWithPtCorr,"CovertMapping_WithPtCorr"); |
629 |
+ |
|
630 |
+ |
|
631 |
+ |
} |
632 |
+ |
|
633 |
+ |
|
634 |
+ |
void OUTDATED_ExperimentalMetPrediction() { |
635 |
+ |
|
636 |
+ |
// compute_r_in_out(); |
637 |
+ |
|
638 |
+ |
// DoNewExperimentalMetPrediction(); |
639 |
+ |
DoNewExperimentalMetPrediction_WithPtCorrection(); |
640 |
+ |
|
641 |
+ |
cout << "About to switch off the weight : " << (const char*) cutWeight << endl; |
642 |
+ |
TCut weightbackup=cutWeight; |
643 |
+ |
cutWeight="1.0"; |
644 |
+ |
cout << "Have set cut weight to 1.0 (no PURW)" << endl; |
645 |
+ |
|
646 |
+ |
// do_experimental_zjets_prediction("met[4]",PlottingSetup::jzbvariablemc,0,"PtCorrectedJZB"); |
647 |
+ |
/* |
648 |
+ |
// Do it without PU re-weighting |
649 |
+ |
float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0; |
650 |
+ |
stringstream resultsNoPU; |
651 |
+ |
stringstream noPUdatajzb; |
652 |
+ |
stringstream noPUmcjzb; |
653 |
+ |
|
654 |
+ |
stringstream mcjzbnoPU; |
655 |
+ |
find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb); |
656 |
+ |
string mcjzb = noPUmcjzb.str(); |
657 |
+ |
*/ |
658 |
+ |
// do_experimental_zjets_prediction("met[4]","jzb[1]",0,"RAWJZB"); |
659 |
+ |
|
660 |
+ |
// do_experimental_zjets_prediction("met[4]","((jzb[1]))",-0.614166,"PeakCorrectedJZB");/* |
661 |
+ |
// do_experimental_zjets_prediction("met[4]",mcjzb,"FullyCorrectedJZB"); |
662 |
+ |
/* |
663 |
+ |
do_experimental_zjets_prediction(tauevents.GetTree(),"met[4]","jzb[1]","tau_RAWJZB"); |
664 |
+ |
do_experimental_zjets_prediction(tauevents.GetTree(),"met[4]","((jzb[1])- 3.53399 )","tau_PeakCorrectedJZB"); |
665 |
+ |
do_experimental_zjets_prediction(tauevents.GetTree(),"met[4]","((jzb[1]+0.059979*pt))","tau_PtCorrectedJZB"); |
666 |
+ |
do_experimental_zjets_prediction(tauevents.GetTree(),"met[4]","((jzb[1]+0.059979*pt)- 3.53399 )","tau_FullyCorrectedJZB"); |
667 |
+ |
*/ |
668 |
+ |
/**/ |
669 |
+ |
|
670 |
+ |
cutWeight=weightbackup; |
671 |
+ |
cout << "Have reset cut weight (PURW reactivated)" << endl; |
672 |
+ |
} |
673 |
+ |
|
674 |
+ |
oid do_experimental_zjets_prediction(string metvariable, string predvariable, string jzbvariable, float epsilonZero, string SaveAsName) { |
675 |
+ |
TCanvas *can = new TCanvas("can","can"); |
676 |
+ |
|
677 |
+ |
cout << "Going to use the variable " << metvariable << " to draw met " << endl; |
678 |
+ |
cout << "Going to use the variable " << predvariable<< " to draw the met PREDICTION" << endl; |
679 |
+ |
cout << "Going to use the variable " << jzbvariable << " to cut on JZB" << endl; |
680 |
+ |
int nbins=50; |
681 |
+ |
float xmin=0; |
682 |
+ |
float xmax=100; |
683 |
+ |
|
684 |
+ |
string basiccut="pfJetGoodNum40>=3&&abs(mll-91.2)<20&&pt1>20&&pt2>20&&(abs(jzb[1]-"+any2string(epsilonZero)+")>abs("+any2string(epsilonZero)+"))&&(("; |
685 |
+ |
|
686 |
+ |
cout << "The basic cut is " << basiccut << endl; |
687 |
+ |
stringstream ObsCommand; |
688 |
+ |
ObsCommand << basiccut << jzbvariable << ")>0)&&(id1==id2)&&abs("+metvariable+"-75)>5"; |
689 |
+ |
stringstream PredCommand; |
690 |
+ |
PredCommand << basiccut << jzbvariable << ")<0)&&(id1==id2)&&abs("+predvariable+"-75)>5"; |
691 |
+ |
stringstream PredCommand3; |
692 |
+ |
PredCommand3 << basiccut << jzbvariable << ")>0)&&(id1!=id2)&&abs("+predvariable+"-75)>5"; |
693 |
+ |
stringstream PredCommand4; |
694 |
+ |
PredCommand4 << basiccut << jzbvariable << ")<0)&&(id1!=id2)&&abs("+predvariable+"-75)>5"; |
695 |
+ |
|
696 |
+ |
TH1F *obs = allsamples.Draw("obs",metvariable,nbins,xmin,xmax,"MET [GeV]","events",TCut(ObsCommand.str().c_str()),mc,PlottingSetup::luminosity,allsamples.FindSample("Z_em_DYJetsToLL")); |
697 |
+ |
TH1F *pred = allsamples.Draw("pred", predvariable,nbins,xmin,xmax,"MET [GeV]","events",TCut(PredCommand.str().c_str()),mc,PlottingSetup::luminosity,allsamples.FindSample("Z_em_DYJetsToLL")); |
698 |
+ |
TH1F *pre3 = allsamples.Draw("pre3",predvariable,nbins,xmin,xmax,"MET [GeV]","events",TCut(PredCommand3.str().c_str()),mc,PlottingSetup::luminosity,allsamples.FindSample("Z_em_DYJetsToLL")); |
699 |
+ |
TH1F *pre4 = allsamples.Draw("pre4",predvariable,nbins,xmin,xmax,"MET [GeV]","events",TCut(PredCommand4.str().c_str()),mc,PlottingSetup::luminosity,allsamples.FindSample("Z_em_DYJetsToLL")); |
700 |
+ |
|
701 |
+ |
obs->SetLineColor(kBlue); |
702 |
+ |
obs->SetMarkerSize(0.3); |
703 |
+ |
obs->SetMarkerColor(kBlue); |
704 |
+ |
|
705 |
+ |
pred->Add(pre3); |
706 |
+ |
pred->Add(pre4,-1); |
707 |
+ |
|
708 |
+ |
pred->SetMarkerColor(kRed); |
709 |
+ |
pred->SetLineColor(kRed); |
710 |
+ |
|
711 |
+ |
can->SetLogy(0); |
712 |
+ |
obs->Draw("e1"); |
713 |
+ |
pred->Draw("histo,same"); |
714 |
+ |
obs->Draw("same,e1"); |
715 |
+ |
|
716 |
+ |
TLegend *leg = new TLegend(0.7,0.7,0.89,0.89); |
717 |
+ |
leg->SetFillColor(kWhite); |
718 |
+ |
leg->AddEntry(obs,"Observed","lp"); |
719 |
+ |
leg->AddEntry(pred,"Predicted","lp"); |
720 |
+ |
leg->Draw("same"); |
721 |
+ |
|
722 |
+ |
stringstream SaveAsName1; |
723 |
+ |
SaveAsName1 << "MetPredPlots/" << SaveAsName; |
724 |
+ |
CompleteSave(can,SaveAsName1.str()); |
725 |
+ |
|
726 |
+ |
can->SetLogy(0); |
727 |
+ |
TH1F *ratio = (TH1F*)obs->Clone("ratio"); |
728 |
+ |
ratio->SetTitle("obs/pred"); |
729 |
+ |
ratio->SetName("ratio"); |
730 |
+ |
ratio->Divide(pred); |
731 |
+ |
ratio->GetYaxis()->SetTitle("obs/pred"); |
732 |
+ |
ratio->GetYaxis()->CenterTitle(); |
733 |
+ |
ratio->GetYaxis()->SetRangeUser(0,5); |
734 |
+ |
TF1 *func = new TF1("func","[0]+[1]*x",10,100); |
735 |
+ |
ratio->Fit("func","R"); |
736 |
+ |
ratio->Draw(); |
737 |
+ |
TLine *line = new TLine(0.0,1.0,100,1.0); |
738 |
+ |
line->SetLineColor(kBlue); |
739 |
+ |
line->SetLineWidth(2); |
740 |
+ |
line->Draw("same"); |
741 |
+ |
|
742 |
+ |
stringstream SaveAsName2; |
743 |
+ |
SaveAsName2 << "MetPredPlots/" << SaveAsName << "_ratio"; |
744 |
+ |
CompleteSave(can,SaveAsName2.str()); |
745 |
+ |
|
746 |
+ |
delete line; |
747 |
+ |
delete ratio; |
748 |
+ |
delete pred; |
749 |
+ |
delete pre3; |
750 |
+ |
delete pre4; |
751 |
+ |
delete obs; |
752 |
+ |
delete can; |
753 |
+ |
} |