diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/CMakeLists.txt b/Trigger/TrigHypothesis/TrigBjetHypo/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b280b7312dce66bbc8dd0bc6efeeb1326e176fec --- /dev/null +++ b/Trigger/TrigHypothesis/TrigBjetHypo/CMakeLists.txt @@ -0,0 +1,52 @@ +################################################################################ +# Package: TrigBjetHypo +################################################################################ + +# Declare the package name: +atlas_subdir( TrigBjetHypo ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Event/xAOD/xAODBase + Event/xAOD/xAODTracking + GaudiKernel + Reconstruction/Particle + Tracking/TrkEvent/VxSecVertex + Trigger/TrigEvent/TrigInDetEvent + Trigger/TrigSteer/TrigInterfaces + Trigger/TrigTools/TrigTrackJetFinderTool + PRIVATE + Control/AthContainers + DetectorDescription/GeoPrimitives + Event/EventInfo + Event/EventPrimitives + Event/FourMomUtils + Event/xAOD/xAODBTagging + Event/xAOD/xAODCore + Event/xAOD/xAODJet + Event/xAOD/xAODMuon + InnerDetector/InDetConditions/InDetBeamSpotService + PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging + Reconstruction/Jet/JetEvent + Tracking/TrkEvent/VxVertex + Trigger/TrigEvent/TrigCaloEvent + Trigger/TrigEvent/TrigMuonEvent + Trigger/TrigEvent/TrigNavigation + Trigger/TrigEvent/TrigParticle + Trigger/TrigEvent/TrigSteeringEvent ) + +# External dependencies: +find_package( Eigen ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_component( TrigBjetHypo + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} xAODBase xAODTracking GaudiKernel Particle VxSecVertex TrigInDetEvent TrigInterfacesLib AthContainers GeoPrimitives EventInfo EventPrimitives FourMomUtils xAODBTagging xAODCore xAODJet xAODMuon BTaggingLib JetEvent VxVertex TrigCaloEvent TrigMuonEvent TrigNavigationLib TrigParticle TrigSteeringEvent ) + +# Install files from the package: +atlas_install_headers( TrigBjetHypo ) +atlas_install_python_modules( python/*.py ) + diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/TrigBjetHypo/TrigBtagFex.h b/Trigger/TrigHypothesis/TrigBjetHypo/TrigBjetHypo/TrigBtagFex.h index 4e29960d332da6ddb281f61b6ab88dac96889b31..42f7509f1e3bbe324f0b3b285f59aa319fe52aeb 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/TrigBjetHypo/TrigBtagFex.h +++ b/Trigger/TrigHypothesis/TrigBjetHypo/TrigBjetHypo/TrigBtagFex.h @@ -298,6 +298,8 @@ class TrigBtagFex: public HLT::FexAlgo { std::string m_trackKey; std::string m_jetKey; std::string m_priVtxKey; + bool m_usePriVtxKeyBackup; + std::string m_priVtxKeyBackup; }; #endif diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/TrigBjetHypo/TrigJetSplitterAllTE.h b/Trigger/TrigHypothesis/TrigBjetHypo/TrigBjetHypo/TrigJetSplitterAllTE.h index 42e7f5659d75a405ef50c5ee6020abb150cf5db2..1032a2e1dd050d4bcb993dd690fd3ddd40f5bc6b 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/TrigBjetHypo/TrigJetSplitterAllTE.h +++ b/Trigger/TrigHypothesis/TrigBjetHypo/TrigBjetHypo/TrigJetSplitterAllTE.h @@ -29,9 +29,14 @@ class TrigJetSplitterAllTE : public HLT::AllTEAlgo { private: + HLT::ErrorCode getAndCheckHistoPrmVtx(HLT::TriggerElement* vtxTriggerElement , const xAOD::VertexContainer* vertices); + const xAOD::Vertex* getPrimaryVertex(const xAOD::VertexContainer* vertexContainer); + std::string m_jetInputKey; std::string m_jetOutputKey; std::string m_priVtxKey; + bool m_usePriVtxKeyBackup; + std::string m_priVtxKeyBackup; double m_etaHalfWidth; double m_phiHalfWidth; diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigBtagFexConfig.py b/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigBtagFexConfig.py index 42a743bc117dc3f877494d015ffb45fb061d55cd..8d034974fa08f99c1c7fe28cad29a745a236a657 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigBtagFexConfig.py +++ b/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigBtagFexConfig.py @@ -108,6 +108,8 @@ class BtagFexSplit (TrigBtagFex): instance = "EF" self.PriVtxKey = "xPrimVx" #"EFHistoPrmVtx" + self.UsePriVtxKeyBackup = True + self.PriVtxKeyBackup = "EFHistoPrmVtx" self.TrackKey = "InDetTrigTrackingxAODCnv_Bjet_IDTrig" # IMPORT OFFLINE TOOLS diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBtagFex.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBtagFex.cxx index d66c49a8aa9074ce2bf086474dc4c2de7b0533fa..2a39266d64f1d3da2e1394bf66e17748d429ec55 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBtagFex.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBtagFex.cxx @@ -57,7 +57,9 @@ TrigBtagFex::TrigBtagFex(const std::string& name, ISvcLocator* pSvcLocator) : declareProperty("TaggerBaseNames", m_TaggerBaseNames); declareProperty("TrackKey", m_trackKey = ""); declareProperty("JetKey", m_jetKey = ""); - declareProperty("PriVtxKey", m_priVtxKey = ""); + declareProperty("PriVtxKey", m_priVtxKey = "xPrimVx"); + declareProperty("UsePriVtxKeyBackup", m_usePriVtxKeyBackup = true); + declareProperty("PriVtxKeyBackup", m_priVtxKeyBackup = "EFHistoPrmVtx"); declareProperty("BTagTool", m_bTagTool); declareProperty("BTagTrackAssocTool", m_bTagTrackAssocTool); @@ -222,10 +224,29 @@ HLT::ErrorCode TrigBtagFex::hltExecute(const HLT::TriggerElement* inputTE, HLT:: // Get primary vertex const xAOD::VertexContainer* vertexes = nullptr; + bool usePVBackup=true; if (getFeature(outputTE, vertexes, m_priVtxKey) == HLT::OK && vertexes != nullptr) { - if(msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "INPUT - xAOD::VertexContainer: " << "nVertexes = " << vertexes->size() << endreq; - } else { - if(msgLvl() <= MSG::ERROR) msg() << MSG::ERROR << "INPUT - No xAOD::VertexContainer" << endreq; + if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "INPUT - xAOD::VertexContainer: " << m_priVtxKey << " has nVertexes = " << vertexes->size() << endreq; + if (!(vertexes->empty())) + if ((*(vertexes->begin()))->vertexType()==xAOD::VxType::PriVtx) { + usePVBackup=false; + if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "INPUT - xAOD::VertexContainer: valid vertex found in " << m_priVtxKey << endreq; + } + } + if(m_usePriVtxKeyBackup && usePVBackup) { + vertexes = nullptr; + if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "INPUT - xAOD::VertexContainer: NO valid vertex found in " << m_priVtxKey << " - proceeding with backup option" << endreq; + if (getFeature(outputTE, vertexes, m_priVtxKeyBackup) == HLT::OK && vertexes != nullptr) { + if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "INPUT - xAOD::VertexContainer: " << m_priVtxKeyBackup << " has nVertexes = " << vertexes->size() << endreq; + if (!(vertexes->empty())) + if ((*(vertexes->begin()))->vertexType()==xAOD::VxType::PriVtx) { + usePVBackup=false; + if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "INPUT - xAOD::VertexContainer: valid vertex found in " << m_priVtxKeyBackup << endreq; + } + } + } + if(usePVBackup) { + if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "INPUT - xAOD::VertexContainer: NO valid vertex found in " << m_priVtxKeyBackup << " - aborting..." << endreq; return HLT::MISSING_FEATURE; } diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigFarawayJetFinderAllTE.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigFarawayJetFinderAllTE.cxx index aec13fa51900b93ddc8c5854c0d327ffc7939a57..4546a8bb59fc902224598b7a05419b16675535b1 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigFarawayJetFinderAllTE.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigFarawayJetFinderAllTE.cxx @@ -157,7 +157,7 @@ HLT::ErrorCode TrigFarawayJetFinderAllTE::hltExecute(std::vector<std::vector<HLT std::vector<const xAOD::Jet*>::const_iterator Jet = theJets.begin(); - std::cout << "=====================> Jet" << iJet << std::endl; + //std::cout << "=====================> Jet" << iJet << std::endl; float minimumDeltaR = 9e9; diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterAllTE.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterAllTE.cxx index 801680eba584217d6bf16d7ee146aa255d9103d1..474233be4c1b1fad4c8b7a9a57d5c9a03716c41c 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterAllTE.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterAllTE.cxx @@ -31,14 +31,16 @@ TrigJetSplitterAllTE::TrigJetSplitterAllTE(const std::string & name, ISvcLocator* pSvcLocator) : HLT::AllTEAlgo(name, pSvcLocator) { - declareProperty ("JetInputKey", m_jetInputKey = "TrigJetRec"); - declareProperty ("JetOutputKey", m_jetOutputKey = "SplitJet"); - declareProperty ("PriVtxKey", m_priVtxKey = "xPrimVx"); //"EFHistoPrmVtx" - declareProperty ("EtaHalfWidth", m_etaHalfWidth = 0.4); - declareProperty ("PhiHalfWidth", m_phiHalfWidth = 0.4); - declareProperty ("ZHalfWidth", m_zHalfWidth = 20.0);// in mm? - declareProperty ("JetMinEt", m_minJetEt = 15.0); // in GeV ==> Can't be any higher than the lowest pT chain that will run - declareProperty ("JetMaxEta", m_maxJetEta = 2.5+m_etaHalfWidth); // tracker acceptance + jet half-width + declareProperty ("JetInputKey", m_jetInputKey = "TrigJetRec"); + declareProperty ("JetOutputKey", m_jetOutputKey = "SplitJet"); + declareProperty ("PriVtxKey", m_priVtxKey = "xPrimVx"); //"EFHistoPrmVtx" + declareProperty ("UsePriVtxKeyBackup", m_usePriVtxKeyBackup = true); + declareProperty ("PriVtxKeyBackup", m_priVtxKeyBackup = "EFHistoPrmVtx"); + declareProperty ("EtaHalfWidth", m_etaHalfWidth = 0.4); + declareProperty ("PhiHalfWidth", m_phiHalfWidth = 0.4); + declareProperty ("ZHalfWidth", m_zHalfWidth = 20.0);// in mm? + declareProperty ("JetMinEt", m_minJetEt = 15.0); // in GeV ==> Can't be any higher than the lowest pT chain that will run + declareProperty ("JetMaxEta", m_maxJetEta = 2.5+m_etaHalfWidth); // tracker acceptance + jet half-width } @@ -154,26 +156,119 @@ HLT::ErrorCode TrigJetSplitterAllTE::hltExecute(std::vector<std::vector<HLT::Tri const xAOD::VertexContainer* vertices = 0; HLT::ErrorCode statusVertices = getFeature(vtxTE.front(), vertices, m_priVtxKey); + // + // Retrieve the vertiecies (Fallback to HistoPrmVtx if failure) + // if (statusVertices != HLT::OK) { - if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Failed to retrieve features (PV)" << endreq; - return HLT::NAV_ERROR; + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Failed to retrieve features (PV) " << m_priVtxKey << endreq; + + // + // Try for HistoPrmVtx instead + // + if(m_usePriVtxKeyBackup){ + statusVertices = getAndCheckHistoPrmVtx(vtxTE.front(), vertices); + + if(statusVertices != HLT::OK){ + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Failed to retrieve features (PV) " << m_priVtxKeyBackup << endreq; + return statusVertices; + } + + }else{ + return HLT::NAV_ERROR; + } + } + // + // Check pointer (Fallback to HistoPrmVtx if failure) + // if(vertices==0) { - if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Missing feature (vertices)." << endreq; - return HLT::MISSING_FEATURE; + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Missing feature (vertices): " << m_priVtxKey << endreq; + + // + // Try for HistoPrmVtx instead + // + if(m_usePriVtxKeyBackup){ + statusVertices = getAndCheckHistoPrmVtx(vtxTE.front(), vertices); + + if(statusVertices != HLT::OK){ + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Failed to retrieve features (PV) " << m_priVtxKeyBackup << endreq; + return statusVertices; + } + if(vertices==0) { + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Missing feature (vertices): " << m_priVtxKeyBackup << endreq; + return HLT::MISSING_FEATURE; + } + } else { + return HLT::MISSING_FEATURE; + } + + } - - - - if(vertices->size() == 0) { - if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << " No primary vertices: returning HLT:OK" << endreq; - return HLT::OK; - } else if(vertices->size() > 1) { - if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "Retrieved " << vertices->size() << " primary vertices. Using the first." << endreq; + + // + // Check size (Fallback to HistoPrmVtx if failure) + // + if(vertices->empty()) { + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Missing feature (vertices): " << m_priVtxKey << endreq; + + // + // Try for HistoPrmVtx instead + // + if(m_usePriVtxKeyBackup){ + statusVertices = getAndCheckHistoPrmVtx(vtxTE.front(), vertices); + + if(statusVertices != HLT::OK){ + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Failed to retrieve features (PV) " << m_priVtxKeyBackup << endreq; + return statusVertices; + } + if(vertices==0) { + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Missing feature (vertices): " << m_priVtxKeyBackup << endreq; + return HLT::MISSING_FEATURE; + } + if(vertices->empty()) { + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Missing feature (vertices): " << m_priVtxKeyBackup << endreq; + return HLT::MISSING_FEATURE; + } + } else { + return HLT::MISSING_FEATURE; + } + + } - - const xAOD::Vertex* prmVtx = vertices->at(0); + + // + // Get the first primary vertex + // + const xAOD::Vertex* prmVtx = getPrimaryVertex(vertices); + + // + // If no PV revert to the HistoPV + // + if(!prmVtx){ + if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << " No primary vertices in " << m_priVtxKey << " checking HistoPV" << endreq; + + // + // Try for HistoPrmVtx instead + // + if(m_usePriVtxKeyBackup){ + statusVertices = getAndCheckHistoPrmVtx(vtxTE.front(), vertices); + if(statusVertices != HLT::OK){ + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Failed to retrieve features (PV) " << m_priVtxKeyBackup << endreq; + return statusVertices; + } + + const xAOD::Vertex* prmVtx = getPrimaryVertex(vertices); + if(!prmVtx){ + if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << " No primary vertices in " << m_priVtxKeyBackup << " return HLT::OL" << endreq; + return HLT::OK; + } + } else{ + return HLT::OK; + } + + } + prmVtx_z = prmVtx->z(); if (msgLvl() <= MSG::DEBUG) msg() << MSG::DEBUG << "Primary vertex z-position = " << prmVtx_z << endreq; @@ -300,3 +395,35 @@ HLT::ErrorCode TrigJetSplitterAllTE::hltFinalize() { +HLT::ErrorCode TrigJetSplitterAllTE::getAndCheckHistoPrmVtx(HLT::TriggerElement* vtxTriggerElement , const xAOD::VertexContainer* vertices) { + //std::cout << "checking histoprmvtx " << std::endl; + HLT::ErrorCode statusHistoPrmVtx = getFeature(vtxTriggerElement, vertices, m_priVtxKeyBackup); + + if(statusHistoPrmVtx != HLT::OK){ + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Failed to retrieve features (PV) " << m_priVtxKeyBackup << endreq; + return HLT::NAV_ERROR; + } + + if(vertices == 0){ + if (msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "Missing feature (vertices): " << m_priVtxKeyBackup << endreq; + return HLT::MISSING_FEATURE; + } + + return HLT::OK; +} + + +const xAOD::Vertex* TrigJetSplitterAllTE::getPrimaryVertex(const xAOD::VertexContainer* vertexContainer) +{ + // vertex types are listed on L328 of + // https://svnweb.cern.ch/trac/atlasoff/browser/Event/xAOD/xAODTracking/trunk/xAODTracking/TrackingPrimitives.h + for( auto vtx_itr : *vertexContainer ) + { + if(vtx_itr->vertexType() != xAOD::VxType::VertexType::PriVtx) { continue; } + return vtx_itr; + } + Warning("HelperFunctions::getPrimaryVertex()","No primary vertex was found! Returning nullptr"); + + return 0; +} +