79 |
|
float FixedMEdge=-1; |
80 |
|
float FixedMEdgeChi2=-1; |
81 |
|
|
82 |
+ |
bool RejectPointIfNoConvergence=false; |
83 |
+ |
|
84 |
+ |
string Mode="UndefinedMode"; |
85 |
+ |
|
86 |
|
} |
87 |
|
|
88 |
|
TGraph* EdgeFitter::prepareLM(float mass, float nEv) { |
361 |
|
RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}"); |
362 |
|
RooRealVar id1("id1","id1",0,1,"GeV/c^{2}"); |
363 |
|
RooRealVar id2("id2","id2",0,1,"GeV/c^{2}"); |
360 |
– |
//RooRealVar jzb("jzb","jzb",-jzbmax,jzbmax,"GeV/c"); |
364 |
|
RooRealVar edgeWeight("edgeWeight","edgeWeight",0,1000,""); |
365 |
|
RooArgSet observables(mll,id1,id2,edgeWeight); |
366 |
|
|
445 |
|
RooAddPdf model_OF("model_OF","model_OF", ttbarOF, fttbarOF); |
446 |
|
RooSimultaneous simPdfOF("simPdfOF","simultaneous pdf", sample) ; |
447 |
|
simPdfOF.addPdf(model_OF,"OF"); |
448 |
< |
RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save(),RooFit::Extended()); |
449 |
< |
resultOF->Print(); |
448 |
> |
RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save(),RooFit::Extended(),RooFit::Minos(true)); |
449 |
> |
//resultOF->Print(); |
450 |
> |
|
451 |
> |
if(resultOF->covQual()!=3) { |
452 |
> |
write_error(__FUNCTION__,"OF fit did not converge!!! Cannot continue!"); |
453 |
> |
cout << "covQual is " << resultOF->covQual() << endl; |
454 |
> |
EdgeFitter::FixedMEdgeChi2=-1; |
455 |
> |
if(EdgeFitter::RejectPointIfNoConvergence) return; |
456 |
> |
} else { |
457 |
> |
write_info(__FUNCTION__,"OF fit converged"); |
458 |
> |
} |
459 |
|
|
460 |
|
RooRealVar* resultOFpar1_ = (RooRealVar*) resultOF->floatParsFinal().find("par1ttbarOF"); |
461 |
|
float resultOFpar1 = resultOFpar1_->getVal(); |
482 |
|
RooRealVar widthzSF("widthzSF", "widthzSF", 2.94); |
483 |
|
|
484 |
|
RooRealVar fttbarSF("fttbarSF", "fttbarSF", 100, 0, 100000); |
485 |
< |
RooRealVar par1ttbarSF("par1ttbarSF", "par1ttbarSF", resultOFpar1, 0, 100); |
485 |
> |
RooRealVar par1ttbarSF("par1ttbarSF", "par1ttbarSF", 1.02*resultOFpar1, 0, 100); |
486 |
|
RooRealVar par2ttbarSF("par2ttbarSF", "par2ttbarSF", 1.0); |
487 |
|
RooRealVar par3ttbarSF("par3ttbarSF", "par3ttbarSF", resultOFpar3, 0, 100); |
488 |
|
RooRealVar par4ttbarSF("par4ttbarSF", "par4ttbarSF", 2.0); |
496 |
|
|
497 |
|
if(EdgeFitter::FixedMEdge>0) par3signalSF.setConstant(); |
498 |
|
|
499 |
+ |
/* par1ttbarOF.setConstant(1); |
500 |
+ |
par2ttbarOF.setConstant(1); |
501 |
+ |
par3ttbarOF.setConstant(1); |
502 |
+ |
par4ttbarOF.setConstant(1); |
503 |
+ |
fttbarOF.setConstant(1);*/ |
504 |
+ |
|
505 |
|
RooSUSYBkgPdf ttbarSF("ttbarSF","ttbarSF", mll , par1ttbarSF, par2ttbarSF, par3ttbarSF, par4ttbarSF); |
506 |
|
//RooSUSYTPdf signalSF("signalSF","signalSF", mll , par1signalSF, par2signalSF, par3signalSF); |
507 |
|
RooSUSYTPdf signalSF("signalSF","signalSF", mll , par1signalSF, sigmazSF, par3signalSF); |
514 |
|
|
515 |
|
//RooAddPdf model_SF("model_SF","model_SF", RooArgList(zSF, ttbarSF, signalSF), RooArgList(fzSF, fttbarSF, fsignalSF)); |
516 |
|
RooAddPdf model_SF("model_SF","model_SF", RooArgList(zSF, ttbarSF, signalSF), RooArgList(fzSF, fttbarSF, fsignalSF)); |
517 |
< |
RooAddPdf model_em("model_em","model_em", RooArgList(ttbarSF), RooArgList(fttbarSF)); |
517 |
> |
RooAddPdf model_OF("model_OF","model_OF", RooArgList(ttbarSF), RooArgList(fttbarSF)); |
518 |
|
|
519 |
|
|
520 |
|
RooSimultaneous simPdf("simPdf","simultaneous pdf",sample) ; |
521 |
|
simPdf.addPdf(model_SF,"SF") ; |
522 |
< |
simPdf.addPdf(model_em,"em") ; |
522 |
> |
simPdf.addPdf(model_OF,"OF") ; |
523 |
> |
|
524 |
> |
RooFitResult *result = simPdf.fitTo(combData, RooFit::Save(), RooFit::Extended(),RooFit::Minos(true)); |
525 |
> |
|
526 |
> |
if(result->covQual()!=3) { |
527 |
> |
write_error(__FUNCTION__,"Full fit did not converge!!! Cannot continue!"); |
528 |
> |
cout << "covQual is " << result->covQual() << endl; |
529 |
> |
EdgeFitter::FixedMEdgeChi2=-1; |
530 |
> |
if(EdgeFitter::RejectPointIfNoConvergence) return; |
531 |
> |
} else { |
532 |
> |
write_info(__FUNCTION__,"Full fit converged"); |
533 |
> |
} |
534 |
|
|
535 |
< |
RooFitResult *result = simPdf.fitTo(combData, RooFit::Save(), RooFit::Extended()); |
507 |
< |
result->Print(); |
535 |
> |
// result->Print(); |
536 |
|
|
537 |
|
RooPlot* frame1 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("EE sample")) ; |
538 |
|
frame1->GetXaxis()->CenterTitle(1); |
539 |
+ |
frame1->GetYaxis()->CenterTitle(1); |
540 |
|
combData.plotOn(frame1,RooFit::Name("SFdata"),RooFit::Cut("sample==sample::SF")) ; |
541 |
|
simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("FullFit"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ; |
542 |
|
simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("TTbarSFonly"),RooFit::Components("ttbarSF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ; |
556 |
|
// The same plot for the cointrol sample slice |
557 |
|
RooPlot* frame3 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample")) ; |
558 |
|
frame3->GetXaxis()->CenterTitle(1); |
559 |
+ |
frame3->GetYaxis()->CenterTitle(1); |
560 |
|
frame3->SetMaximum(frame1->GetMaximum()); |
561 |
|
combData.plotOn(frame3,RooFit::Cut("sample==sample::OF")) ; |
562 |
|
simPdfOF.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ; |
568 |
|
if(is_data==mc) prefix << "mc_"; |
569 |
|
if(is_data==mcwithsignal) prefix << "mcwithS_"; |
570 |
|
|
571 |
< |
prefix << "JZB_" << jzb_cut; |
571 |
> |
prefix << EdgeFitter::Mode << "_" << jzb_cut; |
572 |
|
|
573 |
|
|
574 |
|
|
580 |
|
if(is_data==data) DrawPrelim(); |
581 |
|
else DrawPrelim(PlottingSetup::luminosity,true); |
582 |
|
stringstream infotext; |
583 |
< |
infotext << "#splitline{Fit results (JZB>" << jzb_cut << "): }{#splitline{"; |
583 |
> |
infotext << "#splitline{Fit results (" << EdgeFitter::Mode << ">" << jzb_cut << "): }{#splitline{"; |
584 |
|
infotext << "N(Data) = " << EdgeFitter::SFSample->numEntries() << "}{#splitline{"; |
585 |
|
infotext << "N(Z+Jets) = " << WriteWithError(fzSF.getVal(),fzSF.getError(),3) << "}{#splitline{"; |
586 |
|
infotext << "N(t#bar{t}) = " << WriteWithError(fttbarSF.getVal(),fttbarSF.getError(),3) << "}{#splitline{"; |
591 |
|
infobox->SetNDC(); |
592 |
|
infobox->SetTextSize(0.03); |
593 |
|
infobox->Draw(); |
594 |
< |
CompleteSave(c,"Edge/"+prefix.str()+"_SF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false); |
594 |
> |
if(EdgeFitter::FixedMEdge>=0) CompleteSave(c,"Edge/"+prefix.str()+"_SF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false); |
595 |
> |
else CompleteSave(c,"Edge/"+prefix.str()+"_SF",false,false); |
596 |
|
delete c; |
597 |
|
|
598 |
|
TCanvas* e = new TCanvas("rf501_simultaneouspdfem","rf403_simultaneouspdfem") ; |
602 |
|
frame3->Draw(); |
603 |
|
if(is_data==data) DrawPrelim(); |
604 |
|
else DrawPrelim(PlottingSetup::luminosity,true); |
605 |
< |
CompleteSave(e,"Edge/"+prefix.str()+"_OF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false); |
605 |
> |
if(EdgeFitter::FixedMEdge>=0) CompleteSave(e,"Edge/"+prefix.str()+"_OF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false); |
606 |
> |
else CompleteSave(e,"Edge/"+prefix.str()+"_OF",false,false); |
607 |
|
delete e; |
608 |
|
|
609 |
|
|
650 |
|
|
651 |
|
RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow(); |
652 |
|
RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL); |
621 |
– |
write_warning(__FUNCTION__,"Deactivated actual fitting procedure ATM"); |
653 |
|
|
654 |
|
|
655 |
< |
bool ScanMassRange=true; |
655 |
> |
bool ScanMassRange=false; |
656 |
|
|
657 |
|
|
658 |
|
|
660 |
|
TFile *fscan = new TFile("fscan.root","UPDATE"); |
661 |
|
TGraph *gr = new TGraph(); |
662 |
|
stringstream GrName; |
663 |
< |
GrName << "ScanGraphFor_JZB_" << jzb_cut; |
663 |
> |
GrName << "ScanGraphFor_" << EdgeFitter::Mode << "_" << jzb_cut; |
664 |
|
gr->SetName(GrName.str().c_str()); |
634 |
– |
gr->SetTitle(GrName.str().c_str()); |
665 |
|
|
666 |
|
int i=0; |
667 |
< |
for(float tempMedge=10;tempMedge<=300;tempMedge+=10.0) { |
668 |
< |
write_info(__FUNCTION__,"Now testing Medge="+any2string(tempMedge)+" for JZB>"+any2string(jzb_cut)); |
667 |
> |
for(float tempMedge=10;tempMedge<=300;tempMedge+=5.0) { |
668 |
> |
write_info(__FUNCTION__,"Now testing Medge="+any2string(tempMedge)+" for "+EdgeFitter::Mode+">"+any2string(jzb_cut)); |
669 |
|
EdgeFitter::FixedMEdge=tempMedge; |
670 |
|
EdgeFitter::DoFit(is_data, jzb_cut); |
671 |
+ |
if(EdgeFitter::FixedMEdgeChi2<0) continue; |
672 |
|
gr->SetPoint(i,tempMedge,EdgeFitter::FixedMEdgeChi2); |
673 |
|
i++; |
674 |
|
} |
678 |
|
gr->GetXaxis()->CenterTitle(); |
679 |
|
gr->GetYaxis()->SetTitle("#Chi^{2} / NDF"); |
680 |
|
gr->GetYaxis()->CenterTitle(); |
681 |
< |
gr->Draw("AP*"); |
682 |
< |
fscan->cd(); |
683 |
< |
gr->Write(); |
681 |
> |
gr->GetYaxis()->SetTitleOffset(0.95); |
682 |
> |
gr->GetXaxis()->SetTitleOffset(0.9); |
683 |
> |
gr->SetLineColor(kBlue); |
684 |
> |
gr->SetTitle(""); |
685 |
> |
gr->Draw("AL"); |
686 |
|
stringstream ScanCanSave; |
687 |
< |
ScanCanSave << "Edge/MEdgeScan_JZB_" << jzb_cut; |
687 |
> |
ScanCanSave << "Edge/MEdgeScan_"+EdgeFitter::Mode+"_" << jzb_cut; |
688 |
|
if(is_data) DrawPrelim(); |
689 |
|
else DrawMCPrelim(); |
690 |
< |
ScanCan->SaveAs(ScanCanSave.str().c_str()); |
690 |
> |
CompleteSave(ScanCan,ScanCanSave.str()); |
691 |
> |
fscan->cd(); |
692 |
> |
gr->Write(); |
693 |
|
delete ScanCan; |
694 |
|
fscan->Close(); |
695 |
|
} else { |
708 |
|
} |
709 |
|
|
710 |
|
void DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, vector<float> jzb_cut, int is_data, TCut cut, TTree *signalevents=0) { |
711 |
+ |
|
712 |
+ |
EdgeFitter::Mode="JZB"; |
713 |
+ |
if(mcjzb=="met[4]") EdgeFitter::Mode="MET"; |
714 |
+ |
|
715 |
|
for(int icut=0;icut<(int)jzb_cut.size();icut++) { |
716 |
|
stringstream addcut; |
717 |
|
if(is_data==1) addcut << "(" << datajzb << ">" << jzb_cut[icut] << ")"; |