Skip to content

Commit

Permalink
R22 Jet Pile-up tagging and MET pre-recommendations (#1580)
Browse files Browse the repository at this point in the history
* change to new JetJvtEfficiency interface

* change to new JetJvtEfficiencyInterface

* adjust settings of Jvt selection tools to use enums

* adding functionality to add fJvt scores to output

* removing EMPFlow flag from analysis OR

* bumping release up to 22.2.97

* removing Jvt functionalities from JetCalibrator

* making Jvt tagging algorithm and the re-evluation configurable
  • Loading branch information
miholzbo authored Nov 21, 2022
1 parent 0e0c548 commit 045bdaa
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
release_type:
- analysisbase
release_version:
- 22.2.88
- 22.2.97

steps:
- uses: actions/checkout@master
Expand Down
1 change: 1 addition & 0 deletions Root/HelperClasses.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ namespace HelperClasses{
m_trackAll = has_exact("trackAll");
m_chargedPFOPV = has_exact("chargedPFOPV");
m_jvt = has_exact("JVT");
m_fJvt = has_exact("fJvt");
m_NNJvt = has_exact("NNJvt");
m_allTrack = has_exact("allTrack");
m_allTrackPVSel = has_exact("allTrackPVSel");
Expand Down
44 changes: 3 additions & 41 deletions Root/JetCalibrator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "JetCalibTools/JetCalibrationTool.h"
#include "JetUncertainties/JetUncertaintiesTool.h"
#include "JetSelectorTools/JetCleaningTool.h"
#include "JetMomentTools/JetVertexTaggerTool.h"
// #include "JetTileCorrection/JetTileCorrectionTool.h"
#include "METUtilities/METHelpers.h"

Expand Down Expand Up @@ -338,31 +337,6 @@ EL::StatusCode JetCalibrator :: initialize ()
ANA_MSG_INFO( "No Jet Uncertainities considered");
}

// initialize and configure the JVT correction tool

if( m_redoJVT ){
ANA_CHECK( m_JVTUpdateTool_handle.setProperty("JetContainer", m_inContainerName));
ANA_CHECK( m_JVTUpdateTool_handle.setProperty("JVTFileName", PathResolverFindCalibFile("JetMomentTools/JVTlikelihood_20140805.root")));

if( ! m_JvtAuxName.empty() ){
ANA_CHECK( m_JVTUpdateTool_handle.setProperty("JVFCorrName", m_JvtAuxName) )
}
ANA_CHECK( m_JVTUpdateTool_handle.setProperty("OutputLevel", msg().level()));
ANA_CHECK( m_JVTUpdateTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_JVTUpdateTool_handle);
}

if ( m_calculatefJVT ) {
ANA_CHECK(m_fJVTTool_handle.setProperty("CentralMaxPt", m_fJVTCentralMaxPt));
if ( m_fJVTWorkingPoint == "Tight" ) {
ANA_CHECK(m_fJVTTool_handle.setProperty("UseTightOP", true));
}
ANA_CHECK(m_fJVTTool_handle.setProperty("OutputLevel", msg().level()));
ANA_CHECK(m_fJVTTool_handle.setProperty("JetContainer", m_inContainerName));
ANA_CHECK(m_fJVTTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_fJVTTool_handle);
}

auto SystJetsNames = std::make_unique< std::vector< std::string > >();
for ( const auto& syst_it : m_systList ) {
if ( m_systName.empty() && m_systName.empty() ) {
Expand Down Expand Up @@ -424,7 +398,7 @@ EL::StatusCode JetCalibrator :: execute ()
//
// truth labelling for systematics
if(isMC()){

if(m_runSysts){

// b-jet truth labelling
Expand Down Expand Up @@ -456,7 +430,7 @@ EL::StatusCode JetCalibrator :: execute ()
// m_JetTruthLabelingTool_handle->modifyJet(*jet_itr);
// }
}

}

}//for jets
Expand Down Expand Up @@ -632,18 +606,6 @@ EL::StatusCode JetCalibrator::executeSystematic(const CP::SystematicSet& thisSys
ANA_MSG_ERROR( "Failed to set original object links -- MET rebuilding cannot proceed.");
}

// Recalculate JVT using calibrated Jets
if(m_redoJVT){
for ( auto jet_itr : *(uncertCalibJetsSC.first) ) {
jet_itr->auxdata< float >("Jvt") = m_JVTUpdateTool_handle->updateJvt(*jet_itr);
}
}

// Calculate fJVT using calibrated Jets
if ( m_calculatefJVT ) {
m_fJVTTool_handle->modify(*(uncertCalibJetsSC.first));
}

// save pointers in ConstDataVector with same order
for ( auto jet_itr : *(uncertCalibJetsSC.first) ) {
uncertCalibJetsCDV->push_back( jet_itr );
Expand All @@ -661,7 +623,7 @@ EL::StatusCode JetCalibrator::executeSystematic(const CP::SystematicSet& thisSys
}
// add ConstDataVector to TStore
ANA_CHECK( m_store->record( uncertCalibJetsCDV, outContainerName));

return EL::StatusCode::SUCCESS;
}

Expand Down
106 changes: 100 additions & 6 deletions Root/JetContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ JetContainer::JetContainer(const std::string& name, const std::string& detailStr
m_JvtEff_SF_Tight = new std::vector< std::vector<float> > ();
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "FixedEffPt" ) {
m_JvtPass_FixedEffPt = new std::vector<int>();
if ( m_mc ) {
m_JvtEff_SF_FixedEffPt = new std::vector< std::vector<float> > ();
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "TightFwd" ) {
m_JvtPass_TightFwd = new std::vector<int>();
if ( m_mc ) {
m_JvtEff_SF_TightFwd = new std::vector< std::vector<float> > ();
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sffJVTName == "Loose" ) {
m_fJvtPass_Loose = new std::vector<int>();
if ( m_mc ) {
Expand All @@ -183,6 +195,10 @@ JetContainer::JetContainer(const std::string& name, const std::string& detailStr
}
}

if (m_infoSwitch.m_fJvt) {
m_fJvt = new std::vector<float>();
}

if (m_infoSwitch.m_NNJvt) {
m_NNJvt = new std::vector<float>();
m_NNJvtPass = new std::vector<bool>();
Expand Down Expand Up @@ -590,6 +606,10 @@ JetContainer::~JetContainer()
delete m_Jvt;
}

if (m_infoSwitch.m_fJvt){
delete m_fJvt;
}

if (m_infoSwitch.m_NNJvt){
delete m_NNJvt;
delete m_NNJvtPass;
Expand All @@ -613,6 +633,18 @@ JetContainer::~JetContainer()
delete m_JvtEff_SF_Tight;
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "FixedEffPt" ) {
delete m_JvtPass_FixedEffPt;
if ( m_mc ) {
delete m_JvtEff_SF_FixedEffPt;
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "TightFwd" ) {
delete m_JvtPass_TightFwd;
if ( m_mc ) {
delete m_JvtEff_SF_TightFwd;
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sffJVTName == "Loose" ) {
delete m_fJvtPass_Loose;
if ( m_mc ) {
Expand Down Expand Up @@ -1238,7 +1270,6 @@ void JetContainer::updateParticle(uint idx, Jet& jet)
jet.Jvt =m_Jvt ->at(idx);
}


if ( m_infoSwitch.m_chargedPFOPV ) {
jet.SumPtChargedPFOPt500PV=m_SumPtChargedPFOPt500PV->at(idx);
jet.fCharged=m_fCharged->at(idx);
Expand Down Expand Up @@ -1401,7 +1432,7 @@ void JetContainer::updateParticle(uint idx, Jet& jet)
jet.is_DL1r_Continuous= btag->m_isTag->at(idx);
jet.SF_DL1r_Continuous=(m_mc)?btag->m_sf ->at(idx):dummy1;
break;
//DL1dv01 has preliminary rel22 pre-rec SF uncertainties
//DL1dv01 has preliminary rel22 pre-rec SF uncertainties
case Jet::BTaggerOP::DL1dv01_FixedCutBEff_60:
jet.is_DL1dv01_FixedCutBEff_60= btag->m_isTag->at(idx);
jet.SF_DL1dv01_FixedCutBEff_60=(m_mc)?btag->m_sf ->at(idx):dummy1;
Expand Down Expand Up @@ -1634,6 +1665,10 @@ void JetContainer::setBranches(TTree *tree)
//setBranch<float>(tree,"GhostTrackAssociationFraction", m_ghostTrackAssFrac);
}

if (m_infoSwitch.m_fJvt) {
setBranch<float>(tree, "fJvt", m_fJvt);
}

if (m_infoSwitch.m_NNJvt) {
setBranch<float>(tree, "NNJvt", m_NNJvt);
setBranch<bool>(tree, "NNJvtPass", m_NNJvtPass);
Expand All @@ -1657,6 +1692,18 @@ void JetContainer::setBranches(TTree *tree)
setBranch<std::vector<float> >(tree,"JvtEff_SF_Tight", m_JvtEff_SF_Tight );
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "FixedEffPt" ) {
setBranch<int>(tree,"JvtPass_FixedEffPt", m_JvtPass_FixedEffPt );
if ( m_mc ) {
setBranch<std::vector<float> >(tree,"JvtEff_SF_FixedEffPt", m_JvtEff_SF_FixedEffPt );
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "TightFwd" ) {
setBranch<int>(tree,"JvtPass_TightFwd", m_JvtPass_TightFwd );
if ( m_mc ) {
setBranch<std::vector<float> >(tree,"JvtEff_SF_TightFwd", m_JvtEff_SF_TightFwd );
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sffJVTName == "Loose" ) {
setBranch<int>(tree,"fJvtPass_Loose", m_fJvtPass_Loose );
if ( m_mc ) {
Expand Down Expand Up @@ -2066,6 +2113,10 @@ void JetContainer::clear()
m_Jvt ->clear();
}

if (m_infoSwitch.m_fJvt){
m_fJvt->clear();
}

if (m_infoSwitch.m_NNJvt){
m_NNJvt->clear();
m_NNJvtPass->clear();
Expand All @@ -2089,6 +2140,18 @@ void JetContainer::clear()
m_JvtEff_SF_Tight ->clear();
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "FixedEffPt" ) {
m_JvtPass_FixedEffPt ->clear();
if ( m_mc ) {
m_JvtEff_SF_FixedEffPt->clear();
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "TightFwd" ) {
m_JvtPass_TightFwd ->clear();
if ( m_mc ) {
m_JvtEff_SF_TightFwd ->clear();
}
}
if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sffJVTName == "Loose" ) {
m_fJvtPass_Loose ->clear();
if ( m_mc ) {
Expand Down Expand Up @@ -2760,6 +2823,11 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*

} // trackPV || chargedPFOPV || JVT

if (m_infoSwitch.m_fJvt) {
static SG::AuxElement::ConstAccessor< float > fJvt ("DFCommonJets_fJvt");
safeFill<float, float, xAOD::Jet>(jet, fJvt, m_fJvt, -999);
}

if (m_infoSwitch.m_NNJvt) {
static SG::AuxElement::ConstAccessor< float > NNJvt ("NNJvt");
static SG::AuxElement::ConstAccessor< char > NNJvtPass ("NNJvtPass");
Expand Down Expand Up @@ -2790,12 +2858,16 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
static SG::AuxElement::ConstAccessor< char > jvtPass_Loose("JetJVT_Passed_Loose");
static SG::AuxElement::ConstAccessor< char > jvtPass_Medium("JetJVT_Passed_Medium");
static SG::AuxElement::ConstAccessor< char > jvtPass_Tight("JetJVT_Passed_Tight");
static SG::AuxElement::ConstAccessor< char > jvtPass_FixedEffPt("JetJVT_Passed_FixedEffPt");
static SG::AuxElement::ConstAccessor< char > jvtPass_TightFwd("JetJVT_Passed_TightFwd");
static SG::AuxElement::ConstAccessor< char > fjvtPass_Loose("JetfJVT_Passed_Loose");
static SG::AuxElement::ConstAccessor< char > fjvtPass_Medium("JetfJVT_Passed_Medium");
static SG::AuxElement::ConstAccessor< char > fjvtPass_Tight("JetfJVT_Passed_Tight");
static SG::AuxElement::ConstAccessor< std::vector< float > > jvtSF_Loose("JetJvtEfficiency_JVTSyst_JVT_Loose");
static SG::AuxElement::ConstAccessor< std::vector< float > > jvtSF_Medium("JetJvtEfficiency_JVTSyst_JVT_Medium");
static SG::AuxElement::ConstAccessor< std::vector< float > > jvtSF_Tight("JetJvtEfficiency_JVTSyst_JVT_Tight");
static SG::AuxElement::ConstAccessor< std::vector< float > > jvtSF_FixedEffPt("JetJvtEfficiency_JVTSyst_JVT_FixedEffPt");
static SG::AuxElement::ConstAccessor< std::vector< float > > jvtSF_TightFwd("JetJvtEfficiency_JVTSyst_JVT_TightFwd");
static SG::AuxElement::ConstAccessor< std::vector< float > > fjvtSF_Loose("JetJvtEfficiency_fJVTSyst_fJVT_Loose");
static SG::AuxElement::ConstAccessor< std::vector< float > > fjvtSF_Medium("JetJvtEfficiency_fJVTSyst_fJVT_Medium");
static SG::AuxElement::ConstAccessor< std::vector< float > > fjvtSF_Tight("JetJvtEfficiency_fJVTSyst_fJVT_Tight");
Expand Down Expand Up @@ -2835,6 +2907,28 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
}
}

if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "FixedEffPt" ) {
safeFill<char, int, xAOD::Jet>(jet, jvtPass_FixedEffPt, m_JvtPass_FixedEffPt, -1);
if ( m_mc ) {
if ( jvtSF_FixedEffPt.isAvailable( *jet ) ) {
m_JvtEff_SF_FixedEffPt->push_back( jvtSF_FixedEffPt( *jet ) );
} else {
m_JvtEff_SF_FixedEffPt->push_back( junkSF );
}
}
}

if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sfJVTName == "TightFwd" ) {
safeFill<char, int, xAOD::Jet>(jet, jvtPass_TightFwd, m_JvtPass_TightFwd, -1);
if ( m_mc ) {
if ( jvtSF_TightFwd.isAvailable( *jet ) ) {
m_JvtEff_SF_TightFwd->push_back( jvtSF_TightFwd( *jet ) );
} else {
m_JvtEff_SF_TightFwd->push_back( junkSF );
}
}
}

if ( m_infoSwitch.m_trackPV || m_infoSwitch.m_sffJVTName == "Loose" ) {
safeFill<char, int, xAOD::Jet>(jet, fjvtPass_Loose, m_fJvtPass_Loose, -1);
if ( m_mc ) {
Expand Down Expand Up @@ -3015,7 +3109,7 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
static SG::AuxElement::ConstAccessor<double> JetVertexCharge_discriminant("JetVertexCharge_discriminant");
safeFill<double, double, xAOD::BTagging>(myBTag, JetVertexCharge_discriminant, m_JetVertexCharge_discriminant, -999);
}

float pu, pb, pc, score;

pu=0; pb=0; pc=0;
Expand All @@ -3028,7 +3122,7 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
m_DL1r_pc->push_back(pc);
m_DL1r_pb->push_back(pb);
m_DL1r->push_back( score );

pu=0; pb=0; pc=0;
myBTag->variable<float>("DL1dv00" , "pu", pu);
myBTag->variable<float>("DL1dv00" , "pc", pc);
Expand All @@ -3049,7 +3143,7 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
m_DL1dv01_pc->push_back(pc);
m_DL1dv01_pb->push_back(pb);
m_DL1dv01->push_back( score );

pu=0; pb=0; pc=0;
myBTag->variable<float>("GN120220509" , "pu", pu);
myBTag->variable<float>("GN120220509" , "pc", pc);
Expand All @@ -3060,7 +3154,7 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
m_GN1_pc->push_back(pc);
m_GN1_pb->push_back(pb);
m_GN1->push_back( score );


// flavor groups truth definition
static SG::AuxElement::ConstAccessor<int> hadConeExclTruthLabel("HadronConeExclTruthLabelID");
Expand Down
Loading

0 comments on commit 045bdaa

Please sign in to comment.