From fd22ec417d4317a1f47717522623e33f88a20172 Mon Sep 17 00:00:00 2001 From: johnda102 Date: Thu, 11 May 2017 17:03:56 -0400 Subject: [PATCH] Protection From Missing HLTVtx / PathResolver (#892) --- Root/HLTJetRoIBuilder.cxx | 143 ++++++++++++++++-------------- Root/JetCalibrator.cxx | 4 +- xAODAnaHelpers/HLTJetRoIBuilder.h | 6 ++ 3 files changed, 86 insertions(+), 67 deletions(-) diff --git a/Root/HLTJetRoIBuilder.cxx b/Root/HLTJetRoIBuilder.cxx index 06062d60fd..96c142f14e 100644 --- a/Root/HLTJetRoIBuilder.cxx +++ b/Root/HLTJetRoIBuilder.cxx @@ -44,12 +44,13 @@ using std::vector; ClassImp(HLTJetRoIBuilder) HLTJetRoIBuilder :: HLTJetRoIBuilder () : - Algorithm("HLTJetRoIBuilder"), +Algorithm("HLTJetRoIBuilder"), m_trigItem(""), m_trigItemVeto(""), m_doHLTBJet(true), m_doHLTJet (false), m_readHLTTracks(true), + m_readHLTVtx(true), m_outContainerName(""), m_trigDecTool(nullptr), m_jetName("EFJet"), @@ -250,20 +251,24 @@ EL::StatusCode HLTJetRoIBuilder :: buildHLTBJets () std::vector< Trig::Feature > trkCollections; if(m_readHLTTracks) trkCollections = comb->containerFeature(m_trkName); //std::vector< Trig::Feature > ftfCollections = comb->containerFeature("InDetTrigTrackingxAODCnv_Bjet_FTF"); + std::vector > vtxCollections; - std::vector > backupVtxCollections = comb->containerFeature("EFHistoPrmVtx"); + std::vector > backupVtxCollections; + if(m_readHLTTracks){ + backupVtxCollections = comb->containerFeature("EFHistoPrmVtx"); - if(m_vtxName.size()){ - vtxCollections = comb->containerFeature(m_vtxName); - }else{ - vtxCollections = comb->containerFeature(); + if(m_vtxName.size()){ + vtxCollections = comb->containerFeature(m_vtxName); + }else{ + vtxCollections = comb->containerFeature(); + } } -// cout << " Test Size " << endl; -// cout << " \tSplitJet: " << comb->containerFeature("SplitJet").size() << endl; -// cout << " \tGSCJet: " << comb->containerFeature("GSCJet") .size() << endl; -// cout << " \tEFJet: " << comb->containerFeature("EFJet") .size() << endl; -// + // cout << " Test Size " << endl; + // cout << " \tSplitJet: " << comb->containerFeature("SplitJet").size() << endl; + // cout << " \tGSCJet: " << comb->containerFeature("GSCJet") .size() << endl; + // cout << " \tEFJet: " << comb->containerFeature("EFJet") .size() << endl; + // // FTK Vertex debugging // cout << " Test Size " << endl; // cout << " \tempty: " << comb->containerFeature().size() << endl; @@ -311,17 +316,19 @@ EL::StatusCode HLTJetRoIBuilder :: buildHLTBJets () // isValid = false; //} - if(vtxCollections.size() < jetCollections.size()){ - cout << "ERROR Problem in container size: " << m_name - << " jets: "<< jetCollections.size() << " " << m_jetName - << " vtx: "<< vtxCollections.size() << " " << m_vtxName << endl; - for ( unsigned ifeat=0 ; ifeatvertexType() <vertexType() <size()){ - ATH_MSG_DEBUG("Found a hlt_tracks " << hlt_tracks->at(0)->vx() << " " << hlt_tracks->at(0)->vy() << " " << hlt_tracks->at(0)->vz()); - ATH_MSG_DEBUG("Compares to variable " << " " << var_bs_online_vx << " " << var_bs_online_vy << " " << var_bs_online_vz); + ATH_MSG_DEBUG("Found a hlt_tracks " << hlt_tracks->at(0)->vx() << " " << hlt_tracks->at(0)->vy() << " " << hlt_tracks->at(0)->vz()); + ATH_MSG_DEBUG("Compares to variable " << " " << var_bs_online_vx << " " << var_bs_online_vy << " " << var_bs_online_vz); } m_bs_online_vx (*newHLTBJet) = var_bs_online_vx; @@ -398,9 +405,9 @@ EL::StatusCode HLTJetRoIBuilder :: buildHLTBJets () } - ATH_MSG_DEBUG("Doing it for: " << m_trigItem); - ATH_MSG_DEBUG("Check for m_jetName: " << m_jetName); - ATH_MSG_DEBUG("Check for m_vtxName: " << m_vtxName); + ATH_MSG_DEBUG("Doing it for: " << m_trigItem); + ATH_MSG_DEBUG("Check for m_jetName: " << m_jetName); + ATH_MSG_DEBUG("Check for m_vtxName: " << m_vtxName); // // Check for dummy verticies @@ -409,53 +416,59 @@ EL::StatusCode HLTJetRoIBuilder :: buildHLTBJets () // 0 - IDTrig Found Vertex // 1 - EFHisto Found Vertex // 2 - No Vertex found - - if(!HelperFunctions::getPrimaryVertex(vtxCollections.at(ifeat).cptr(), msg())){ - + if(m_readHLTVtx){ + if(!HelperFunctions::getPrimaryVertex(vtxCollections.at(ifeat).cptr(), msg())){ + ATH_MSG_DEBUG("HAVE No Online Vtx!!! m_vtxName is " << m_vtxName); for( auto vtx_itr : *(vtxCollections.at(ifeat).cptr()) ) ATH_MSG_DEBUG(vtx_itr->vertexType()); - - // - // Try the HistoPrmVtx - // - if(backupVtxCollections.size()){ - ATH_MSG_DEBUG("Have EFHistoPrmVtx. "); - m_vtx_hadDummyPV (*newHLTBJet) = '1'; - const xAOD::Vertex *backup_pvx = HelperFunctions::getPrimaryVertex(backupVtxCollections.at(ifeat).cptr(), msg()); - ATH_MSG_DEBUG("backup_pvx. " << backup_pvx); - m_vtx_decoration (*newHLTBJet) = backup_pvx; - m_vtx_decoration_bkg(*newHLTBJet) = backup_pvx; + + // + // Try the HistoPrmVtx + // + if(backupVtxCollections.size()){ + ATH_MSG_DEBUG("Have EFHistoPrmVtx. "); + m_vtx_hadDummyPV (*newHLTBJet) = '1'; + const xAOD::Vertex *backup_pvx = HelperFunctions::getPrimaryVertex(backupVtxCollections.at(ifeat).cptr(), msg()); + ATH_MSG_DEBUG("backup_pvx. " << backup_pvx); + m_vtx_decoration (*newHLTBJet) = backup_pvx; + m_vtx_decoration_bkg(*newHLTBJet) = backup_pvx; + }else{ + cout << "No EFHistoPrmVtx.... " << endl; + m_vtx_hadDummyPV (*newHLTBJet) = '2'; + m_vtx_decoration (*newHLTBJet) = 0; + m_vtx_decoration_bkg(*newHLTBJet) = 0; + } + + //cout << "hadDummy and vtxType " << m_vtx_hadDummyPV (*newHLTBJet) << " " << m_vtxName << endl; + }else{ - cout << "No EFHistoPrmVtx.... " << endl; - m_vtx_hadDummyPV (*newHLTBJet) = '2'; - m_vtx_decoration (*newHLTBJet) = 0; - m_vtx_decoration_bkg(*newHLTBJet) = 0; + + m_vtx_decoration (*newHLTBJet) = HelperFunctions::getPrimaryVertex(vtxCollections.at(ifeat).cptr(), msg()); + m_vtx_hadDummyPV (*newHLTBJet) = '0'; + + if(backupVtxCollections.size()){ + m_vtx_decoration_bkg(*newHLTBJet) = HelperFunctions::getPrimaryVertex(backupVtxCollections.at(ifeat).cptr(), msg()); + }else{ + m_vtx_decoration_bkg(*newHLTBJet) = 0; + } + } - - //cout << "hadDummy and vtxType " << m_vtx_hadDummyPV (*newHLTBJet) << " " << m_vtxName << endl; - - }else{ - - m_vtx_decoration (*newHLTBJet) = HelperFunctions::getPrimaryVertex(vtxCollections.at(ifeat).cptr(), msg()); + + m_offline_vtx_decoration (*newHLTBJet) = offline_pvx; + + ATH_MSG_DEBUG("hadDummy and vtxType" << m_vtx_hadDummyPV (*newHLTBJet) << " " << m_vtxName); + //if(m_vtx_hadDummyPV (*newHLTBJet) != '0' ){ + // cout << "hadDummy and vtxType and m_outContainerName " << m_vtx_hadDummyPV (*newHLTBJet) << " " + // << m_vtxName << ' '<< m_outContainerName <push_back( newHLTBJet ); ATH_MSG_DEBUG("pushed back "); diff --git a/Root/JetCalibrator.cxx b/Root/JetCalibrator.cxx index 609cdb2c80..1673f208a9 100644 --- a/Root/JetCalibrator.cxx +++ b/Root/JetCalibrator.cxx @@ -30,6 +30,7 @@ #include "xAODAnaHelpers/HelperFunctions.h" #include "xAODAnaHelpers/JetCalibrator.h" #include +#include "PathResolver/PathResolver.h" // ROOT includes: #include "TSystem.h" @@ -321,8 +322,7 @@ EL::StatusCode JetCalibrator :: initialize () ATH_MSG_INFO("Initialize JES UNCERT with " << m_JESUncertConfig); RETURN_CHECK("JetCalibrator::initialize()", m_JetUncertaintiesTool_handle.setProperty("JetDefinition",m_jetAlgo), "Failed to set JetDefinition"); RETURN_CHECK("JetCalibrator::initialize()", m_JetUncertaintiesTool_handle.setProperty("MCType",m_JESUncertMCType), "Failed to set MCType"); - RETURN_CHECK("JetCalibrator::initialize()", m_JetUncertaintiesTool_handle.setProperty("ConfigFile", m_JESUncertConfig), "Failed to set ConfigFile"); - + RETURN_CHECK("JetCalibrator::initialize()", m_JetUncertaintiesTool_handle.setProperty("ConfigFile", PathResolverFindCalibFile(m_JESUncertConfig)), "Failed to set ConfigFile"); RETURN_CHECK("JetCalibrator::initialize()", m_JetUncertaintiesTool_handle.retrieve(), "Failed to retrieve JetUncertaintiesTool"); // m_JetUncertaintiesTool_handle->msg().setLevel( MSG::ERROR ); // VERBOSE, INFO, DEBUG diff --git a/xAODAnaHelpers/HLTJetRoIBuilder.h b/xAODAnaHelpers/HLTJetRoIBuilder.h index fd506ce56b..fd73b90083 100644 --- a/xAODAnaHelpers/HLTJetRoIBuilder.h +++ b/xAODAnaHelpers/HLTJetRoIBuilder.h @@ -48,6 +48,12 @@ class HLTJetRoIBuilder : public xAH::Algorithm bool m_readHLTTracks; + /** + @brief Do we read in the HLT vertices? + */ + bool m_readHLTVtx; + + /** @brief Name of the output container */