21 |
|
#include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEvent.h" |
22 |
|
#include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEventAuxInfo.h" |
23 |
|
|
24 |
+ |
#include "FWCore/Framework/interface/ESHandle.h" |
25 |
|
#include "DataFormats/PatCandidates/interface/PATObject.h" |
26 |
|
#include "DataFormats/PatCandidates/interface/TriggerObject.h" |
27 |
|
#include "DataFormats/PatCandidates/interface/TriggerObjectStandAlone.h" |
28 |
+ |
#include "RecoBTag/Records/interface/BTagPerformanceRecord.h" |
29 |
+ |
#include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h" |
30 |
+ |
#include "RecoBTag/PerformanceDB/interface/BtagPerformance.h" |
31 |
|
|
32 |
|
#include "DataFormats/GeometryVector/interface/VectorUtil.h" |
33 |
|
|
532 |
|
edm::Handle<CandidateView> dielectrons; |
533 |
|
iEvent.getByLabel(dielecLabel_,dielectrons); |
534 |
|
|
535 |
+ |
//BTAGGING SCALE FACTOR FROM DATABASE |
536 |
+ |
//Combined Secondary Vertex Loose |
537 |
+ |
edm::ESHandle<BtagPerformance> bTagSF_CSVL_; |
538 |
+ |
iSetup.get<BTagPerformanceRecord>().get("BTAGCSVL",bTagSF_CSVL_); |
539 |
+ |
const BtagPerformance & bTagSF_CSVL = *(bTagSF_CSVL_.product()); |
540 |
+ |
//Combined Secondary Vertex Medium |
541 |
+ |
edm::ESHandle<BtagPerformance> bTagSF_CSVM_; |
542 |
+ |
iSetup.get<BTagPerformanceRecord>().get("BTAGCSVM",bTagSF_CSVM_); |
543 |
+ |
const BtagPerformance & bTagSF_CSVM = *(bTagSF_CSVM_.product()); |
544 |
+ |
//Combined Secondary Vertex Tight |
545 |
+ |
edm::ESHandle<BtagPerformance> bTagSF_CSVT_; |
546 |
+ |
iSetup.get<BTagPerformanceRecord>().get("BTAGCSVT",bTagSF_CSVT_); |
547 |
+ |
const BtagPerformance & bTagSF_CSVT = *(bTagSF_CSVT_.product()); |
548 |
+ |
|
549 |
+ |
edm::ESHandle<BtagPerformance> mistagSF_CSVL_; |
550 |
+ |
iSetup.get<BTagPerformanceRecord>().get("MISTAGCSVL",mistagSF_CSVL_); |
551 |
+ |
const BtagPerformance & mistagSF_CSVL = *(mistagSF_CSVL_.product()); |
552 |
+ |
//Combined Secondary Vertex Medium |
553 |
+ |
edm::ESHandle<BtagPerformance> mistagSF_CSVM_; |
554 |
+ |
iSetup.get<BTagPerformanceRecord>().get("MISTAGCSVM",mistagSF_CSVM_); |
555 |
+ |
const BtagPerformance & mistagSF_CSVM = *(mistagSF_CSVM_.product()); |
556 |
+ |
//Combined Secondary Vertex Tight |
557 |
+ |
edm::ESHandle<BtagPerformance> mistagSF_CSVT_; |
558 |
+ |
iSetup.get<BTagPerformanceRecord>().get("MISTAGCSVT",mistagSF_CSVT_); |
559 |
+ |
const BtagPerformance & mistagSF_CSVT = *(mistagSF_CSVT_.product()); |
560 |
+ |
|
561 |
|
|
562 |
|
for(edm::View<pat::Jet>::const_iterator jet_iter = simplejets1.begin(); jet_iter!=simplejets1.end(); ++jet_iter){ |
563 |
|
// if(jet_iter->pt()>50) |
576 |
|
sj.ntracks=jet_iter->associatedTracks().size(); |
577 |
|
sj.p4=GENPTOLORP(jet_iter); |
578 |
|
sj.chargedTracksFourMomentum=(getChargedTracksMomentum(&*(jet_iter))); |
579 |
< |
|
579 |
> |
sj.SF_CSVL=1; |
580 |
> |
sj.SF_CSVM=1; |
581 |
> |
sj.SF_CSVT=1; |
582 |
> |
sj.SF_CSVLerr=0; |
583 |
> |
sj.SF_CSVMerr=0; |
584 |
> |
sj.SF_CSVTerr=0; |
585 |
|
// |
586 |
|
// add tVector |
587 |
|
// |
591 |
|
|
592 |
|
if(runOnMC_){ |
593 |
|
double minb1DR=9999.; |
594 |
+ |
//scale factor |
595 |
+ |
BinningPointByMap measurePoint; |
596 |
+ |
//for a USDG |
597 |
+ |
//for CB jets |
598 |
+ |
//scale factor 1 for CB jets over 240GeV/c |
599 |
+ |
if( TMath::Abs(sj.flavour) == 4 or TMath::Abs(sj.flavour) == 5 ){ |
600 |
+ |
measurePoint.insert( BinningVariables::JetEt, sj.p4.Et() ); |
601 |
+ |
measurePoint.insert( BinningVariables::JetAbsEta, fabs(sj.p4.Eta()) ); |
602 |
+ |
if( bTagSF_CSVL.isResultOk(PerformanceResult::BTAGBEFFCORR , measurePoint) ){ |
603 |
+ |
sj.SF_CSVL = bTagSF_CSVL.getResult(PerformanceResult::BTAGBEFFCORR , measurePoint); |
604 |
+ |
sj.SF_CSVLerr = bTagSF_CSVL.getResult(PerformanceResult::BTAGBERRCORR , measurePoint); |
605 |
+ |
if(verbose_){ |
606 |
+ |
std::clog << "C/B Jet flavour = " << sj.flavour << std::endl; |
607 |
+ |
std::clog << "C/B Jet Et = " << sj.p4.Et() << std::endl; |
608 |
+ |
std::clog << "C/B Jet eta = " << sj.p4.Eta() << std::endl; |
609 |
+ |
std::clog << "C/B Scale Factor = " << sj.SF_CSVL << std::endl; |
610 |
+ |
std::clog << "C/B Scale Factor error = " << sj.SF_CSVLerr << std::endl; |
611 |
+ |
} |
612 |
+ |
} |
613 |
+ |
if( bTagSF_CSVM.isResultOk(PerformanceResult::BTAGBEFFCORR , measurePoint) ){ |
614 |
+ |
sj.SF_CSVM = bTagSF_CSVM.getResult(PerformanceResult::BTAGBEFFCORR , measurePoint); |
615 |
+ |
sj.SF_CSVMerr = bTagSF_CSVM.getResult(PerformanceResult::BTAGBERRCORR , measurePoint); |
616 |
+ |
} |
617 |
+ |
if( bTagSF_CSVT.isResultOk(PerformanceResult::BTAGBEFFCORR , measurePoint) ){ |
618 |
+ |
sj.SF_CSVT = bTagSF_CSVT.getResult(PerformanceResult::BTAGBEFFCORR , measurePoint); |
619 |
+ |
sj.SF_CSVTerr = bTagSF_CSVT.getResult(PerformanceResult::BTAGBERRCORR , measurePoint); |
620 |
+ |
} |
621 |
+ |
else{ |
622 |
+ |
std::cerr << "No SF found in the database for this jet" << std::endl; |
623 |
+ |
if(verbose_){ |
624 |
+ |
std::clog << "No SF found: Jet flavour = " << sj.flavour << std::endl; |
625 |
+ |
std::clog << "No SF found: Jet Et = " << sj.p4.Et() << std::endl; |
626 |
+ |
std::clog << "No SF found: Jet eta = " << sj.p4.Eta() << std::endl; |
627 |
+ |
} |
628 |
+ |
} |
629 |
+ |
} |
630 |
+ |
else { |
631 |
+ |
measurePoint.insert( BinningVariables::JetEt, sj.p4.Et() ); |
632 |
+ |
measurePoint.insert( BinningVariables::JetAbsEta, fabs(sj.p4.Eta()) ); |
633 |
+ |
if( mistagSF_CSVL.isResultOk(PerformanceResult::BTAGLEFFCORR , measurePoint) ){ |
634 |
+ |
sj.SF_CSVL = mistagSF_CSVL.getResult(PerformanceResult::BTAGLEFFCORR , measurePoint); |
635 |
+ |
sj.SF_CSVLerr = mistagSF_CSVL.getResult(PerformanceResult::BTAGLERRCORR , measurePoint); |
636 |
+ |
if(verbose_){ |
637 |
+ |
std::clog << "Light Jet flavour = " << sj.flavour << std::endl; |
638 |
+ |
std::clog << "Light Jet Et = " << sj.p4.Et() << std::endl; |
639 |
+ |
std::clog << "Light Jet eta = " << sj.p4.Eta() << std::endl; |
640 |
+ |
std::clog << "Light Scale Factor = " << sj.SF_CSVL << std::endl; |
641 |
+ |
std::clog << "Light Scale Factor error = " << sj.SF_CSVLerr << std::endl; |
642 |
+ |
} |
643 |
+ |
} |
644 |
+ |
if( mistagSF_CSVM.isResultOk(PerformanceResult::BTAGLEFFCORR , measurePoint) ){ |
645 |
+ |
sj.SF_CSVM = mistagSF_CSVM.getResult(PerformanceResult::BTAGLEFFCORR , measurePoint); |
646 |
+ |
sj.SF_CSVMerr = mistagSF_CSVM.getResult(PerformanceResult::BTAGLERRCORR , measurePoint); |
647 |
+ |
} |
648 |
+ |
if( mistagSF_CSVT.isResultOk(PerformanceResult::BTAGLEFFCORR , measurePoint) ){ |
649 |
+ |
sj.SF_CSVT = mistagSF_CSVT.getResult(PerformanceResult::BTAGLEFFCORR , measurePoint); |
650 |
+ |
sj.SF_CSVTerr = mistagSF_CSVT.getResult(PerformanceResult::BTAGLERRCORR , measurePoint); |
651 |
+ |
} |
652 |
+ |
else{ |
653 |
+ |
std::cerr << "No SF found in the database for this jet" << std::endl; |
654 |
+ |
if(verbose_){ |
655 |
+ |
std::clog << "No SF found: Jet flavour = " << sj.flavour << std::endl; |
656 |
+ |
std::clog << "No SF found: Jet Et = " << sj.p4.Et() << std::endl; |
657 |
+ |
std::clog << "No SF found: Jet eta = " << sj.p4.Eta() << std::endl; |
658 |
+ |
} |
659 |
+ |
} |
660 |
+ |
} |
661 |
+ |
|
662 |
|
for(size_t i = 0; i < genParticles->size(); ++ i) { |
663 |
|
const GenParticle & p = (*genParticles)[i]; |
664 |
|
int id = p.pdgId(); |
665 |
|
if(abs(id)<=6 || id==21 || id==23 || abs(id)==24){ |
666 |
+ |
TLorentzVector bestMCp4_,bestMCp4mom_; |
667 |
|
double bb1DR=TMath::Sqrt((p.eta()-p4Jet.eta())*(p.eta()-p4Jet.eta())+ |
668 |
|
(p.phi()-p4Jet.phi())*(p.phi()-p4Jet.phi())); |
669 |
< |
if(bb1DR<minb1DR) {minb1DR=bb1DR; sj.bestMCid=id; if(p.mother()!=0) sj.bestMCmomid=p.mother()->pdgId();} |
669 |
> |
if(bb1DR<minb1DR){ |
670 |
> |
minb1DR=bb1DR; |
671 |
> |
sj.bestMCid=id; |
672 |
> |
bestMCp4_.SetPtEtaPhiE(p.pt(),p.eta(),p.phi(),p.energy()); |
673 |
> |
sj.bestMCp4= bestMCp4_; |
674 |
> |
if(p.mother()!=0){ |
675 |
> |
sj.bestMCmomid=p.mother()->pdgId(); |
676 |
> |
bestMCp4mom_.SetPtEtaPhiE(p.mother()->pt(),p.mother()->eta(),p.mother()->phi(),p.mother()->energy()); |
677 |
> |
sj.bestMCp4mom=bestMCp4mom_; |
678 |
> |
} |
679 |
> |
} |
680 |
|
} |
681 |
|
} |
682 |
< |
} //isMC |
682 |
> |
} //isMC |
683 |
|
hbbInfo->simpleJets.push_back(sj); |
684 |
|
|
685 |
|
} |