diff --git a/Event/xAOD/xAODBase/CMakeLists.txt b/Event/xAOD/xAODBase/CMakeLists.txt index 866ebe3bf79054080bdd85fed766f956f862ee4c..19ad43af8518959680f5eb3f391fda39103e4eab 100644 --- a/Event/xAOD/xAODBase/CMakeLists.txt +++ b/Event/xAOD/xAODBase/CMakeLists.txt @@ -36,6 +36,11 @@ atlas_add_dictionary( xAODBaseDict xAODBase/selection.xml LINK_LIBRARIES xAODBase ) +atlas_add_dictionary( xAODBaseObjectTypeDict + xAODBase/xAODBaseObjectTypeDict.h + xAODBase/selection-ObjectType.xml + LINK_LIBRARIES xAODBase ) + # Test(s) in the package: atlas_add_test( ut_xAODObjectType_test SOURCES test/ut_xAODObjectType_test.cxx diff --git a/Event/xAOD/xAODBase/xAODBase/ObjectType.h b/Event/xAOD/xAODBase/xAODBase/ObjectType.h index 1c29e4b25207a365dc0168f7faabcae6b272e37d..d70435611caa36b6b12c175e9fcf303250bbae64 100644 --- a/Event/xAOD/xAODBase/xAODBase/ObjectType.h +++ b/Event/xAOD/xAODBase/xAODBase/ObjectType.h @@ -107,6 +107,8 @@ namespace xAOD { }; // enum ObjectType + struct ROOT6_NamespaceAutoloadHook{}; + } // namespace Type } // namespace xAOD diff --git a/Event/xAOD/xAODBase/xAODBase/selection-ObjectType.xml b/Event/xAOD/xAODBase/xAODBase/selection-ObjectType.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7d883b8d23a36a5e0b727ef19c635b5cedf6e70 --- /dev/null +++ b/Event/xAOD/xAODBase/xAODBase/selection-ObjectType.xml @@ -0,0 +1,7 @@ +<!-- $Id: selection.xml 618909 2014-09-29 10:16:52Z krasznaa $ --> +<lcgdict> + + <!-- An attempt to make the ObjectType enumeration visible in Python... --> + <enum name="xAOD::Type::ObjectType" /> + +</lcgdict> diff --git a/Event/xAOD/xAODBase/xAODBase/selection.xml b/Event/xAOD/xAODBase/xAODBase/selection.xml index b85d3b28a25a37140c0015e1c86d728f77871f61..45d1a41ad3ed46ab71b556062a87d1b64e9649fc 100644 --- a/Event/xAOD/xAODBase/xAODBase/selection.xml +++ b/Event/xAOD/xAODBase/xAODBase/selection.xml @@ -17,9 +17,6 @@ <class name="ElementLinkVector<xAOD::IParticleContainer>" /> <class name="std::vector<ElementLinkVector<xAOD::IParticleContainer> >" /> - <!-- An attempt to make the ObjectType enumeration visible in Python... --> - <enum name="xAOD::Type::ObjectType" /> - <!-- The helper functions: --> <function pattern="xAOD::*" /> diff --git a/Event/xAOD/xAODBase/xAODBase/xAODBaseObjectTypeDict.h b/Event/xAOD/xAODBase/xAODBase/xAODBaseObjectTypeDict.h new file mode 100644 index 0000000000000000000000000000000000000000..55fbfc49062ddcffac5aa96d4e4e6e46bbbd5355 --- /dev/null +++ b/Event/xAOD/xAODBase/xAODBase/xAODBaseObjectTypeDict.h @@ -0,0 +1,14 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: xAODBaseDict.h 618909 2014-09-29 10:16:52Z krasznaa $ +#ifndef XAODBASE_XAODBASEOBJECTTYPEDICT_H +#define XAODBASE_XAODBASEOBJECTTYPEDICT_H + +// Local include(s): +#include "xAODBase/ObjectType.h" + +#endif // XAODBASE_XAODBASEOBJECTTYPEDICT_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py index 31b8cb164dbc629e5191cbefded381bb31d05471..d3f7b00c253a087f667b52debb163469f9c7b099 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py @@ -335,8 +335,9 @@ if rec.doTruth(): # Compute the truth-particle-level energy density in the central eta region from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAlg from JetRec.JetRecStandard import jtm - tc=configEventDensityTool("EDTruthCentralTool", jtm.truthget, - 0.5, + tc=configEventDensityTool("EDTruthCentralTool", + inputlabel = jtm.truthget.Label, + radius = 0.5, AbsRapidityMax = 1.5, OutputContainer = "TruthIsoCentralEventShape", OutputLevel = 3, @@ -344,8 +345,9 @@ if rec.doTruth(): ToolSvc += tc # Compute the truth-particle-level energy density in the forward eta region - tf=configEventDensityTool("EDTruthForwardTool", jtm.truthget, - 0.5, + tf=configEventDensityTool("EDTruthForwardTool", + inputlabel = jtm.truthget.Label, + radius = 0.5, AbsRapidityMin = 1.5, AbsRapidityMax = 3.0, OutputContainer = "TruthIsoForwardEventShape", diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkJetEtMiss/python/JetCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkJetEtMiss/python/JetCommon.py index 5a71ea64e449aae1e29c76da48c164274fda8d44..24236f96619c41810dc5b7062984250b5591702b 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkJetEtMiss/python/JetCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkJetEtMiss/python/JetCommon.py @@ -33,14 +33,9 @@ def defineEDAlg(R=0.4, inputtype="LCTopo"): from JetRec.JetRecStandard import jtm - # map a getter to the input argument - inputgetter = { "LCTopo" : jtm.lcget, - "EMTopo" : jtm.emget, - "EMPFlow": jtm.empflowget, - "EMCPFlow": jtm.emcpflowget, - }[inputtype] - - t=configEventDensityTool("EDTool"+str(int(R*10))+inputtype, inputgetter, R) + t=configEventDensityTool("EDTool"+str(int(R*10))+inputtype, + inputlabel = inputtype, + radius = R) t.OutputLevel = 3 ToolSvc += t return EventDensityAlg( "EventDensityAlg"+t.name(), EventDensityTool = t , OutputLevel=3) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkSUSY/share/SUSY4.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkSUSY/share/SUSY4.py index e6a9eaa18f5a9c16d2a54645933152e7ad9bedb6..c23d45c1d495a0416da9ae4d1371f18ce457037a 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkSUSY/share/SUSY4.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkSUSY/share/SUSY4.py @@ -181,8 +181,6 @@ SUSY4SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "SUSY4Sk ToolSvc += SUSY4SkimmingTool -from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAlg - #==================================================================== # ISOLATION TOOL #==================================================================== diff --git a/Reconstruction/EventShapes/EventShapeInterface/EventShapeInterface/IEventShapeTool.h b/Reconstruction/EventShapes/EventShapeInterface/EventShapeInterface/IEventShapeTool.h index 0ed7bc388a726e82d8794e696ac7bf6d9f0befa2..30b61dc855f70b8ad6fd49b4d21487ec64b63d4f 100644 --- a/Reconstruction/EventShapes/EventShapeInterface/EventShapeInterface/IEventShapeTool.h +++ b/Reconstruction/EventShapes/EventShapeInterface/EventShapeInterface/IEventShapeTool.h @@ -43,9 +43,6 @@ class IEventShapeTool /// Fills the given EventShape object virtual StatusCode fillEventShape(xAOD::EventShape *) const =0 ; - - /// Fills the given EventShape object using the given input IParticleContainer - virtual StatusCode fillEventShape(xAOD::EventShape *, const xAOD::IParticleContainer*) const =0 ; protected: diff --git a/Reconstruction/EventShapes/EventShapeTools/CMakeLists.txt b/Reconstruction/EventShapes/EventShapeTools/CMakeLists.txt index 42e514d2f28f43b9f85e0c7a0f6f2d6ee8ede60c..bb9b3a0fc9a445b7abd38c6e9c781636f7ee6a9c 100644 --- a/Reconstruction/EventShapes/EventShapeTools/CMakeLists.txt +++ b/Reconstruction/EventShapes/EventShapeTools/CMakeLists.txt @@ -10,6 +10,8 @@ atlas_depends_on_subdirs( PUBLIC Control/AthToolSupport/AsgTools GaudiKernel Reconstruction/EventShapes/EventShapeInterface + Reconstruction/Jet/JetEDM + Reconstruction/Jet/JetRec Reconstruction/Jet/JetInterface PRIVATE Control/AthenaBaseComps @@ -26,8 +28,8 @@ atlas_add_library( EventShapeToolsLib PUBLIC_HEADERS EventShapeTools INCLUDE_DIRS ${FASTJET_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${FASTJET_LIBRARIES} AsgTools GaudiKernel EventShapeInterface JetInterface - PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps xAODEventShape ) + LINK_LIBRARIES ${FASTJET_LIBRARIES} AsgTools GaudiKernel EventShapeInterface JetRec JetInterface + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps xAODEventShape JetEDM ) atlas_add_component( EventShapeTools src/components/*.cxx diff --git a/Reconstruction/EventShapes/EventShapeTools/EventShapeTools/EventDensityTool.h b/Reconstruction/EventShapes/EventShapeTools/EventShapeTools/EventDensityTool.h index d94723bc6d26c422eff82fe7d4a881d505301fea..78d1eaf4d737e19ffbcb3c0886b6f92206c4bd35 100644 --- a/Reconstruction/EventShapes/EventShapeTools/EventShapeTools/EventDensityTool.h +++ b/Reconstruction/EventShapes/EventShapeTools/EventShapeTools/EventDensityTool.h @@ -31,12 +31,18 @@ #include "fastjet/JetDefinition.hh" #include "fastjet/AreaDefinition.hh" #include "fastjet/Selector.hh" -#include "AsgTools/ToolHandle.h" #include "AsgTools/AsgTool.h" -#include "JetInterface/IPseudoJetGetter.h" +#include "AsgTools/ToolHandle.h" +#include "JetRec/PseudoJetContainer.h" #include "EventShapeInterface/IEventShapeTool.h" #include "xAODEventShape/EventShape.h" +// Temporarily included until trigger jet-finding properly moves to DH +// Unfortunately, depending on the trigger PJG interface introduces +// a circular dependency, so we have to depend on the basic class and +// rely on the member & property names to discourage use of other PJGs +#include "JetInterface/IPseudoJetGetter.h" + class EventDensityTool : public asg::AsgTool, virtual public ::IEventShapeTool { @@ -56,21 +62,22 @@ public: /// Action. StatusCode fillEventShape() const; StatusCode fillEventShape(xAOD::EventShape* es) const; - StatusCode fillEventShape(xAOD::EventShape* es, const xAOD::IParticleContainer* input) const; protected: StatusCode fillEventShape(xAOD::EventShape *es , const PseudoJetVector& input ) const ; private: + // Temporarily included until trigger jet-finding properly moves to DH + ToolHandle<IPseudoJetGetter> m_trigPJGet{""}; + // DataHandles - SG::ReadHandleKey<xAOD::EventShape> m_outconIn; - SG::WriteHandleKey<xAOD::EventShape> m_outcon; + SG::ReadHandleKey<PseudoJetContainer> m_inPJKey{this, "InputContainer", "", "ReadHandleKey for input PseudoJetVector"}; + SG::WriteHandleKey<xAOD::EventShape> m_outEDKey{this, "OutputContainer", "GenericEventDensity", "WriteHandleKey for output EventDensity"}; // Properties std::string m_jetalg; // JetAlg float m_jetrad; // JetRadius - ToolHandle<IPseudoJetGetter> m_pjgetter; // JetInput float m_rapmin; // RapidityMax float m_rapmax; // RapidityMax std::string m_areadef; // AreaDefinition @@ -82,11 +89,6 @@ private: fastjet::Selector m_fjselector; bool m_useAreaFourMom; - // For now we use decorators, and test before to overwrite. - SG::AuxElement::Accessor< float > m_rhoDec; - SG::AuxElement::Accessor< float > m_sigmaDec; - SG::AuxElement::Accessor< float > m_areaDec; - }; #endif diff --git a/Reconstruction/EventShapes/EventShapeTools/EventShapeTools/EventShapeCopier.h b/Reconstruction/EventShapes/EventShapeTools/EventShapeTools/EventShapeCopier.h index ba71829b7a88a249131808031d77d06ed03e20ff..b03aa5380369d292d70cd075e862d0ecd63376d5 100644 --- a/Reconstruction/EventShapes/EventShapeTools/EventShapeTools/EventShapeCopier.h +++ b/Reconstruction/EventShapes/EventShapeTools/EventShapeTools/EventShapeCopier.h @@ -48,7 +48,6 @@ public: /// Action. StatusCode fillEventShape() const; StatusCode fillEventShape(xAOD::EventShape* es) const; - StatusCode fillEventShape(xAOD::EventShape* es, const xAOD::IParticleContainer* input) const; /// This function is only a convenience function for use in Standalone Analysis /// it avoids the need of configuring the tool by copying pre-determined EventShape diff --git a/Reconstruction/EventShapes/EventShapeTools/Root/EventDensityTool.cxx b/Reconstruction/EventShapes/EventShapeTools/Root/EventDensityTool.cxx index e6ba17f42f1144b2b6fcc7c6fe9831a2f9b3768d..38ec857941b78f9368715fcf49f805095604d5ed 100644 --- a/Reconstruction/EventShapes/EventShapeTools/Root/EventDensityTool.cxx +++ b/Reconstruction/EventShapes/EventShapeTools/Root/EventDensityTool.cxx @@ -10,7 +10,7 @@ #include "fastjet/ClusterSequenceArea.hh" #include "xAODEventShape/EventShape.h" #include "xAODEventShape/EventShapeAuxInfo.h" -// #include "JetRec/PseudoJetContainer.h" +#include "JetEDM/PseudoJetVector.h" using fastjet::JetAlgorithm; using fastjet::JetDefinition; @@ -23,19 +23,16 @@ using fastjet::VoronoiAreaSpec; EventDensityTool::EventDensityTool(const std::string& name) : asg::AsgTool(name), - m_useAreaFourMom(true), - m_rhoDec(""), - m_sigmaDec(""), - m_areaDec("") { + m_useAreaFourMom(true) +{ declareProperty("JetAlgorithm", m_jetalg = "Kt"); declareProperty("JetRadius", m_jetrad = 0.4); - declareProperty("JetInput", m_pjgetter); declareProperty("AbsRapidityMin", m_rapmin = 0.0); declareProperty("AbsRapidityMax", m_rapmax = 2.0); declareProperty("AreaDefinition", m_areadef = "Voronoi"); declareProperty("VoronoiRfact", m_vrfact = 1.0); - declareProperty("OutputContainer", m_outcon = "GenericEventDensity"); - declareProperty("UseFourMomArea", m_useAreaFourMom); + declareProperty("UseFourMomArea", m_useAreaFourMom); + declareProperty("TrigPseudoJetGetter", m_trigPJGet); } //********************************************************************** @@ -46,7 +43,6 @@ EventDensityTool::~EventDensityTool() {} StatusCode EventDensityTool::initialize() { ATH_MSG_INFO ("Initializing " << name() << "..."); - ATH_CHECK( m_pjgetter.retrieve() ); // Fetch the fastjet algorithm enum JetAlgorithm fjalg; @@ -85,27 +81,40 @@ StatusCode EventDensityTool::initialize() { ATH_MSG_INFO("Configured properties:"); ATH_MSG_INFO(" JetAlgorithm: " << m_jetalg); ATH_MSG_INFO(" JetRadius: " << m_jetrad); - ATH_MSG_INFO(" JetInput: " << m_pjgetter); + if(!m_inPJKey.key().empty()) { + ATH_MSG_INFO(" InputContainer: " << m_inPJKey.key()); + } else { + ATH_MSG_INFO(" TrigPJGetter: " << m_trigPJGet.name()); + } ATH_MSG_INFO(" AbsRapidityMin: " << m_rapmin); ATH_MSG_INFO(" AbsRapidityMax: " << m_rapmax); ATH_MSG_INFO(" AreaDefinition: " << m_areadef); ATH_MSG_INFO(" VoronoiRfact: " << m_vrfact); - ATH_MSG_INFO(" OutputContainer: " << m_outcon.key()); + ATH_MSG_INFO(" OutputContainer: " << m_outEDKey.key()); ATH_MSG_INFO("Derived properties:"); ATH_MSG_INFO(" Fastjet jet defn: " << m_fjjetdef.description()); ATH_MSG_INFO(" Fastjet area defn: " << m_fjareadef.description()); ATH_MSG_INFO(" Fastjet jet selector: " << m_fjselector.description()); ATH_MSG_INFO(" Use area four-momentum: " << m_useAreaFourMom); - // Fill the EventShape object - m_rhoDec = SG::AuxElement::Accessor<float>("Density"); - m_sigmaDec = SG::AuxElement::Accessor<float>("DensitySigma"); - m_areaDec = SG::AuxElement::Accessor<float>("DensityArea"); + // Input sources + if(!m_inPJKey.key().empty() && m_trigPJGet.empty()) { + ATH_CHECK( m_inPJKey.initialize() ); + } + // { FIXME: To be removed when trigger moves to DataHandles fully + else if(m_inPJKey.key().empty() && !m_trigPJGet.empty()) { + ATH_CHECK( m_trigPJGet.retrieve() ); + } + // } FIXME + else { + ATH_MSG_ERROR( "Inconsistent/ambiguous input setup." + << " InPJKey: " << m_inPJKey.key() + << " TrigPJGetter: " << m_trigPJGet.name() ); + return StatusCode::FAILURE; + } - // DataHandles - ATH_CHECK( m_outcon.initialize() ); - m_outconIn = m_outcon.key(); - ATH_CHECK( m_outconIn.initialize() ); + // Initialise output handle + ATH_CHECK( m_outEDKey.initialize() ); return StatusCode::SUCCESS; } @@ -116,13 +125,6 @@ StatusCode EventDensityTool::fillEventShape() const { ATH_MSG_DEBUG("Begin fillEventShape()"); - // check if not already existing - auto handle_inOut = SG::makeHandle (m_outconIn); - if ( handle_inOut.isValid() ) { - ATH_MSG_WARNING( "EventShape with key "<< m_outconIn.key() << " already exists. Not overwriting it." ); - return StatusCode::SUCCESS; - } - xAOD::EventShape *pevs = new xAOD::EventShape(); std::unique_ptr<const xAOD::EventShape> pevs_ptr(pevs); @@ -133,11 +135,11 @@ StatusCode EventDensityTool::fillEventShape() const { // Change the order: first fill the object and then record ATH_CHECK(fillEventShape(pevs)); - SG::WriteHandle<xAOD::EventShape> h_out(m_outcon); + auto h_out = makeHandle(m_outEDKey); if ( ! h_out.put(std::move(pevs_ptr), std::move(pevsaux_ptr) )) { - ATH_MSG_WARNING("Unable to write new Jet collection and aux store to event store: " << m_outcon.key()); + ATH_MSG_WARNING("Unable to write new Jet collection and aux store to event store: " << m_outEDKey.key()); } else { - ATH_MSG_DEBUG("Created new EventShape container: " << m_outcon.key()); + ATH_MSG_DEBUG("Created new EventShape container: " << m_outEDKey.key()); } return StatusCode::SUCCESS; @@ -146,58 +148,34 @@ StatusCode EventDensityTool::fillEventShape() const { //********************************************************************** StatusCode EventDensityTool::fillEventShape(xAOD::EventShape *pevs) const { - /* - const PseudoJetContainer* cont = m_pjgetter->getC(); - if ( cont == 0 ) { - ATH_MSG_ERROR( "Couldn't retrieve PseudoJetContainer from "<< m_pjgetter->name() ); - return StatusCode::FAILURE; - } - std::vector<PseudoJet> ppjv = const_cast<PseudoJetContainer *>(cont)->asVectorPseudoJet(); - */ - - const PseudoJetVector* ppjv = m_pjgetter->get(); - - // !!! FIXME !!! Downgraded ERROR to WARNING and no FAILURE - ATH_MSG_DEBUG("ppvj.size() = " << ppjv->size()); - if ( ppjv->size() == 0 ) { - ATH_MSG_WARNING( "ppjv.size()=0 for pseudojets from "<< m_pjgetter->name() ); - //return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG("Retrieved input pseudojets " << m_pjgetter->name() << ", count: " << ppjv->size()); + if(!m_inPJKey.key().empty() && m_trigPJGet.empty()) { + auto h_in = makeHandle(m_inPJKey); + // !!! FIXME !!! Downgraded ERROR to WARNING and no FAILURE + if ( h_in->size() == 0 ) { + ATH_MSG_WARNING( "Input PseudoJetContainer size()=0 for pseudojets from "<< m_inPJKey.key() ); + //return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG("Retrieved input pseudojets " << m_inPJKey.key() << " , count: " << h_in->size()); + } + return fillEventShape(pevs, *(h_in->casVectorPseudoJet())); } - - // call fillEventShape(PseudoJetVector, EventShape) : - return fillEventShape(pevs, *ppjv); -} - - -StatusCode EventDensityTool::fillEventShape(xAOD::EventShape *pevs, const xAOD::IParticleContainer*) const { - // Ignore IParticleContainer argument. - - /* - // Fetch inputs. - const PseudoJetContainer* cont = m_pjgetter->getC(); - if ( cont == 0 ) { - ATH_MSG_ERROR( "Couldn't retrieve PseudoJetContainer from "<< m_pjgetter->name() ); - return StatusCode::FAILURE; - } - std::vector<PseudoJet> ppjv = const_cast<PseudoJetContainer *>(cont)->asVectorPseudoJet(); - */ - - const PseudoJetVector* ppjv = m_pjgetter->get(); - - // !!! FIXME !!! Downgraded ERROR to WARNING and no FAILURE - ATH_MSG_DEBUG("ppvj.size() = " << ppjv->size()); - if ( ppjv->size() == 0 ) { - ATH_MSG_WARNING( "ppjv.size()=0 for pseudojets from "<< m_pjgetter->name() ); - //return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG("Retrieved input pseudojets " << m_pjgetter->name() << ", count: " << ppjv->size()); + // { FIXME: To be removed when trigger moves to DataHandles fully + else if(m_inPJKey.key().empty() && !m_trigPJGet.empty()) { + const PseudoJetVector& ppjv = *(m_trigPJGet->get()); + // !!! FIXME !!! Downgraded ERROR to WARNING and no FAILURE + if ( ppjv.size() == 0 ) { + ATH_MSG_WARNING( "Input PseudoJetVector size()=0 for pseudojets from "<< m_trigPJGet.name() ); + //return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG("Retrieved input pseudojets " << m_trigPJGet.name() << " , count: " << ppjv.size()); + } + return fillEventShape(pevs, ppjv); } + // } FIXME - return fillEventShape( pevs, *ppjv); + return StatusCode::FAILURE; } - + //********************************************************************** StatusCode EventDensityTool:: @@ -222,9 +200,14 @@ fillEventShape( xAOD::EventShape* pevs, const PseudoJetVector& pjv) const { ATH_MSG_DEBUG(" calculated rho="<< rho); // Record rho. - m_rhoDec(*pevs) = rho; - m_sigmaDec(*pevs) = sigma; - m_areaDec(*pevs) = area; + + // Fill the EventShape object + const static SG::AuxElement::Accessor<float> rhoDec("Density"); + const static SG::AuxElement::Accessor<float> sigmaDec("DensitySigma"); + const static SG::AuxElement::Accessor<float> areaDec("DensityArea"); + rhoDec(*pevs) = rho; + sigmaDec(*pevs) = sigma; + areaDec(*pevs) = area; ATH_MSG_DEBUG("Recorded event density: = " << 0.001*rho << " GeV"); diff --git a/Reconstruction/EventShapes/EventShapeTools/Root/EventShapeCopier.cxx b/Reconstruction/EventShapes/EventShapeTools/Root/EventShapeCopier.cxx index 74713ea27b81b284c00e15f6490ef214f1fec26f..f30f4fed53da0b620d8699f0215075853faa4049 100644 --- a/Reconstruction/EventShapes/EventShapeTools/Root/EventShapeCopier.cxx +++ b/Reconstruction/EventShapes/EventShapeTools/Root/EventShapeCopier.cxx @@ -87,13 +87,6 @@ StatusCode EventShapeCopier::fillEventShape(xAOD::EventShape *evs) const { return StatusCode::SUCCESS; } - - -StatusCode EventShapeCopier::fillEventShape(xAOD::EventShape *evs, const xAOD::IParticleContainer*) const { - // Ignore IParticleContainer argument. - - return fillEventShape( evs); -} //********************************************************************** diff --git a/Reconstruction/EventShapes/EventShapeTools/python/EventDensityConfig.py b/Reconstruction/EventShapes/EventShapeTools/python/EventDensityConfig.py index 99d15df11b581ab1929865d72a786dcaf69751a3..a0a10af87f2840c24b969a01857e7577af6c1a26 100644 --- a/Reconstruction/EventShapes/EventShapeTools/python/EventDensityConfig.py +++ b/Reconstruction/EventShapes/EventShapeTools/python/EventDensityConfig.py @@ -4,19 +4,19 @@ from EventShapeTools.EventShapeToolsConf import EventDensityTool, EventShapeCopi import logging edLogger = logging.getLogger( "EventDensityConfig" ) -def configEventDensityTool( name, pjGetter, radius, **options ): +def configEventDensityTool( name, inputlabel, radius, **options ): """ options can be used to pass any EventDensityTool properties """ # Set default and passed properties for the EventDensityTool toolProperties = dict( JetAlgorithm = "Kt", JetRadius = radius, - JetInput = pjGetter, + InputContainer = "PseudoJet"+inputlabel, AbsRapidityMin = 0.0, AbsRapidityMax = 2.0, AreaDefinition = "Voronoi", VoronoiRfact = 0.9, - OutputContainer = "Kt"+str(int(10*radius))+pjGetter.Label + "EventShape", + OutputContainer = "Kt"+str(int(10*radius))+inputlabel + "EventShape", UseFourMomArea = True, ) # Override properties with user-supplied options. @@ -48,43 +48,3 @@ def EventDensityAlg(name, EventDensityTool=None, **args): alg = EventDensityAthAlg(name,EventDensityTool=EventDensityTool, **args) return alg - -## import AthenaCommon.SystemOfUnits as Units -## import AthenaPython.PyAthena as PyAthena -## from AthenaPython.PyAthena import StatusCode -## class EventDensityAlg (PyAthena.Alg): -## 'put some documentation here' -## def __init__(self, name='EventDensityAlg', **kw): -## ## init base class -## kw['name'] = name -## super(EventDensityAlg, self).__init__(**kw) - -## self.EventDensityTool = kw.get('EventDensityTool', None) -## ## properties and data members -## #self.foo = kw.get('foo', 10) # default value -## return - -## def initialize(self): -## self.msg.info('==> initialize...') -## tools = self.EventDensityTool -## if not isinstance( tools, list): -## tools = [tools] - -## self.edTools = [PyAthena.py_tool(t.getFullName(), iface='IEventShapeTool') for t in tools ] -## self.msg.info(" using density tools : %s"%( self.edTools, ) ) - -## return StatusCode.Success - -## def execute(self): -## self.msg.debug('==> executing ...') -## for t in self.edTools: -## sc = t.fillEventShape() -## if not sc.isSuccess(): -## self.msg.error(" Error while computing density with tool %s "%(t.name(),)) -## return StatusCode.Recoverable -## return StatusCode.Success - - -## def finalize(self): -## self.msg.info('==> finalize...') -## return StatusCode.Success diff --git a/Reconstruction/Jet/JetMomentTools/python/DefaultTools.py b/Reconstruction/Jet/JetMomentTools/python/DefaultTools.py index ddda27107a9207439399f606c6a81b40109aa9a7..32d39fa8370087c25193ba7030e84e004fe8eb8d 100644 --- a/Reconstruction/Jet/JetMomentTools/python/DefaultTools.py +++ b/Reconstruction/Jet/JetMomentTools/python/DefaultTools.py @@ -329,14 +329,18 @@ def declareDefaultTools(): OnlyAssignPV = True, ) - # Load the xAODCaloEvent dictionary for cluster scale enum - import cppyy - try: cppyy.loadDictionary('xAODCaloEventDict') - except: pass - from ROOT import xAOD - # Touch an unrelated class so the dictionary is loaded - # and therefore the CaloCluster version typedef is recognised - xAOD.CaloVertexedTopoCluster + +### Not ideal, but because CaloCluster.Scale is an internal class +### it makes the dict load really slow. +### So just copy the enum to a dict... +### Defined in Event/xAOD/xAODCaloEvent/versions/CaloCluster_v1.h +CaloClusterStates = { + "UNKNOWN" : -1, + "UNCALIBRATED" : 0, + "CALIBRATED" : 1, + "ALTCALIBRATED" : 2, + "NSTATES" : 3 + } ### Workaround for inability of Gaudi to parse single-element tuple import GaudiPython.Bindings as GPB @@ -352,7 +356,7 @@ jtm += JetConstitFourMomTool( "constitfourmom_lctopo", JetScaleNames = ["DetectorEtaPhi"], AltConstitColls = ["CaloCalTopoClusters"], - AltConstitScales = [xAOD.CaloCluster.CALIBRATED], + AltConstitScales = [CaloClusterStates["CALIBRATED"]], AltJetScales = [""] ) @@ -360,7 +364,7 @@ jtm += JetConstitFourMomTool( "constitfourmom_emtopo", JetScaleNames = ["DetectorEtaPhi","JetLCScaleMomentum"], AltConstitColls = ["CaloCalTopoClusters","LCOriginTopoClusters" if jetFlags.useTracks() else "CaloCalTopoClusters"], - AltConstitScales = [xAOD.CaloCluster.UNCALIBRATED,xAOD.CaloCluster.CALIBRATED], + AltConstitScales = [CaloClusterStates["UNCALIBRATED"],CaloClusterStates["CALIBRATED"]], AltJetScales = ["",""] ) diff --git a/Reconstruction/Jet/JetRec/JetRec/PseudoJetContainer.h b/Reconstruction/Jet/JetRec/JetRec/PseudoJetContainer.h index dd7a2199c3dbdd34d8bde2b130042c75457ae206..0e66b2dec42640a79506c11f97c0db3b6e229d73 100644 --- a/Reconstruction/Jet/JetRec/JetRec/PseudoJetContainer.h +++ b/Reconstruction/Jet/JetRec/JetRec/PseudoJetContainer.h @@ -61,7 +61,6 @@ public: // returns the list of input constituents // typically to give to a fastjet::ClusterSequence - std::vector<PseudoJet> asVectorPseudoJet() const; const std::vector<PseudoJet>* casVectorPseudoJet() const; // combine the contents of a PseudoJetContainer with the current container. diff --git a/Reconstruction/Jet/JetRec/Root/PseudoJetContainer.cxx b/Reconstruction/Jet/JetRec/Root/PseudoJetContainer.cxx index be4dd957336788d1fc0d70ce24cf1e4e2626561b..fe25e4f0d77f0f664ee11dec87acc6b266bdc7bc 100644 --- a/Reconstruction/Jet/JetRec/Root/PseudoJetContainer.cxx +++ b/Reconstruction/Jet/JetRec/Root/PseudoJetContainer.cxx @@ -111,13 +111,6 @@ bool PseudoJetContainer::extractConstituents(xAOD::Jet& jet, return extractConstituents(jet, inConstituents); } -// returns the list of input constituents -// typically to give to a fastjet::ClusterSequence -// std::vector<PseudoJet> PseudoJetContainer::asVectorPseudoJet() const { -// if (m_debug){checkInvariants("asVectorPseudoJet()");} -// return m_allConstituents; -// } - const std::vector<PseudoJet>* PseudoJetContainer::casVectorPseudoJet() const { if (m_debug){checkInvariants("asVectorPseudoJet()");} return &m_allConstituents; diff --git a/Reconstruction/Jet/JetRec/Root/PseudoJetGetter.cxx b/Reconstruction/Jet/JetRec/Root/PseudoJetGetter.cxx index 433db76e4fa9bfd1e6aaa9aa76ae736dddcd5de3..a2d74a75db9546adcfc7db9f6db240674fb1934b 100644 --- a/Reconstruction/Jet/JetRec/Root/PseudoJetGetter.cxx +++ b/Reconstruction/Jet/JetRec/Root/PseudoJetGetter.cxx @@ -5,14 +5,13 @@ // PseudoJetGetter.cxx #include "JetRec/PseudoJetGetter.h" +#include "fastjet/PseudoJet.hh" +#include "JetRec/PseudoJetContainer.h" #include "JetEDM/PseudoJetVector.h" -#include "JetRec/PseudoJetContainer.h" #include "xAODBase/IParticleContainer.h" #include "JetRec/IParticleExtractor.h" #include "xAODCaloEvent/CaloClusterContainer.h" -#include "fastjet/PseudoJet.hh" -#include "JetRec/PseudoJetContainer.h" #include "xAODPFlow/PFOContainer.h" using std::string; diff --git a/Reconstruction/Jet/JetRec/python/JetAlgorithm.py b/Reconstruction/Jet/JetRec/python/JetAlgorithm.py index 40bebd7ba858c5109a718d3d0e3ace0b66682719..16d62064ccba4d865597dbe0c788f0c17fb700b2 100644 --- a/Reconstruction/Jet/JetRec/python/JetAlgorithm.py +++ b/Reconstruction/Jet/JetRec/python/JetAlgorithm.py @@ -54,7 +54,6 @@ def addJetRecoToAlgSequence(job =None, useTruth =None, eventShapeTools =None, # Event shape tools. - evstools = [] evsDict = { "emtopo" : ("EMTopoEventShape", jtm.emget), "lctopo" : ("LCTopoEventShape", jtm.lcget), @@ -76,8 +75,8 @@ def addJetRecoToAlgSequence(job =None, useTruth =None, eventShapeTools =None, else: jetlog.info( myname + "Adding event shape " + evskey ) if not IsInInputFile("xAOD::EventShape",toolname): - jtm += configEventDensityTool(toolname, getter, 0.4) - evstools += [jtm.tools[toolname]] + jtm += configEventDensityTool(toolname, getter.Label, 0.4) + jtm.allEDTools += [jtm.tools[toolname]] else: jetlog.info( myname + "Invalid event shape key: " + evskey ) raise Exception @@ -157,15 +156,12 @@ def addJetRecoToAlgSequence(job =None, useTruth =None, eventShapeTools =None, for getter in jtm.allGetters: job += PseudoJetAlgorithm("pjalg_"+getter.Label,PJGetter=getter) - if separateJetAlgs: + # Then, add all event shape tools in separate algs + for evstool in jtm.allEDTools: + from EventShapeTools.EventShapeToolsConf import EventDensityAthAlg + job += EventDensityAthAlg("edalg_"+evstool.OutputContainer,EventDensityTool=evstool) - jtm += JetToolRunner("jetevs", - EventShapeTools=evstools, - Tools=[], - Timer=jetFlags.timeJetToolRunner() - ) - job += JetAlgorithm("jetalgEventShape", - Tools = [jtm.jetevs]) + if separateJetAlgs: for t in jtm.jetrecs: jalg = JetAlgorithm("jetalg"+t.name(), @@ -175,7 +171,7 @@ def addJetRecoToAlgSequence(job =None, useTruth =None, eventShapeTools =None, else: from JetRec.JetRecConf import JetToolRunner jtm += JetToolRunner("jetrun", - EventShapeTools=evstools, + EventShapeTools=[], Tools=rtools+jtm.jetrecs, Timer=jetFlags.timeJetToolRunner() ) diff --git a/Reconstruction/Jet/JetRec/python/JetRecStandardTools.py b/Reconstruction/Jet/JetRec/python/JetRecStandardTools.py index 348ee06a649936f1b31a71cc7c57e7cae9466511..b9605faae4307ff1b19115335de4f2dc3ed59008 100644 --- a/Reconstruction/Jet/JetRec/python/JetRecStandardTools.py +++ b/Reconstruction/Jet/JetRec/python/JetRecStandardTools.py @@ -333,14 +333,14 @@ useTrackVertexTool = False if True == jetFlags.useTrackVertexTool: useTrackVertexTool = True -import cppyy -try: cppyy.loadDictionary('xAODBaseDict') -except: pass -from ROOT import xAOD - # Weight tool for charged pflow objects. jtm += WeightPFOTool("pflowweighter") +# Trigger xAOD.Type.ObjectType dict entry loading +import ROOT +from ROOT import xAOD +xAOD.Type.ObjectType + # Would go in JetRecToolsConfig but this hits a circular dependency on jtm? # this applies four-momentum corrections to PFlow objects: # - points neutral PFOs to the selected vertex @@ -702,14 +702,17 @@ jtm += JetOriginCorrectionTool( OnlyAssignPV = True, ) -# Load the xAODCaloEvent dictionary for cluster scale enum -import cppyy -try: cppyy.loadDictionary('xAODCaloEventDict') -except: pass -from ROOT import xAOD -# Touch an unrelated class so the dictionary is loaded -# and therefore the CaloCluster version typedef is recognised -xAOD.CaloVertexedTopoCluster +### Not ideal, but because CaloCluster.Scale is an internal class +### it makes the dict load really slow. +### So just copy the enum to a dict... +### Defined in Event/xAOD/xAODCaloEvent/versions/CaloCluster_v1.h +CaloClusterStates = { + "UNKNOWN" : -1, + "UNCALIBRATED" : 0, + "CALIBRATED" : 1, + "ALTCALIBRATED" : 2, + "NSTATES" : 3 + } ### Workaround for inability of Gaudi to parse single-element tuple import GaudiPython.Bindings as GPB @@ -725,7 +728,7 @@ jtm += JetConstitFourMomTool( "constitfourmom_lctopo", JetScaleNames = ["DetectorEtaPhi"], AltConstitColls = ["CaloCalTopoClusters"], - AltConstitScales = [xAOD.CaloCluster.CALIBRATED], + AltConstitScales = [CaloClusterStates["CALIBRATED"]], AltJetScales = [""] ) @@ -733,7 +736,7 @@ jtm += JetConstitFourMomTool( "constitfourmom_emtopo", JetScaleNames = ["DetectorEtaPhi","JetLCScaleMomentum"], AltConstitColls = ["CaloCalTopoClusters","LCOriginTopoClusters" if jetFlags.useTracks() else "CaloCalTopoClusters"], - AltConstitScales = [xAOD.CaloCluster.UNCALIBRATED,xAOD.CaloCluster.CALIBRATED], + AltConstitScales = [CaloClusterStates["UNCALIBRATED"],CaloClusterStates["CALIBRATED"]], AltJetScales = ["",""] ) diff --git a/Reconstruction/Jet/JetRec/python/JetToolSupport.py b/Reconstruction/Jet/JetRec/python/JetToolSupport.py index e03224fd3caa71b424e630a7999f2af9a200a37e..71037db0f24170221e24b5609efe873bc87b58f5 100644 --- a/Reconstruction/Jet/JetRec/python/JetToolSupport.py +++ b/Reconstruction/Jet/JetRec/python/JetToolSupport.py @@ -67,6 +67,8 @@ class JetToolManager: allGetters = [] # Map of modifier lists modifiersMap = {} + # List of event density tools + allEDTools = [] vertexContainer = "PrimaryVertices" trackContainer = "InDetTrackParticles" diff --git a/Reconstruction/Jet/JetRec/share/JetRec_jobOptions.py b/Reconstruction/Jet/JetRec/share/JetRec_jobOptions.py index eb0a8b1274c50a072e5ec61eb71e5bba7208f5fc..19dd6c77fce75b600c73d4dcd91b95fdcb244a88 100644 --- a/Reconstruction/Jet/JetRec/share/JetRec_jobOptions.py +++ b/Reconstruction/Jet/JetRec/share/JetRec_jobOptions.py @@ -102,8 +102,7 @@ addJetRecoToAlgSequence() #-------------------------------------------------------------- # save event shapes set with the JetAlgorithm #-------------------------------------------------------------- -estoollist = jtm.jetevs.EventShapeTools if jetFlags.separateJetAlgs() else jtm.jetrun.EventShapeTools -for esTool in estoollist: +for esTool in jtm.allEDTools: t = getattr(ToolSvc, esTool.getName() ) jetFlags.jetAODList += [ "xAOD::EventShape#"+t.OutputContainer, "xAOD::EventShapeAuxInfo#"+t.OutputContainer+'Aux.' ] diff --git a/Reconstruction/Jet/JetRec/share/PFSequenceRec.py b/Reconstruction/Jet/JetRec/share/PFSequenceRec.py index 2a6966aaff479e5e1cc159382f74b74599020546..221cf68d1db1209cc7280f7b198b3532d2244227 100644 --- a/Reconstruction/Jet/JetRec/share/PFSequenceRec.py +++ b/Reconstruction/Jet/JetRec/share/PFSequenceRec.py @@ -77,10 +77,8 @@ jtm += PseudoJetGetter( SkipNegativeEnergy = True, ) -import cppyy -try: cppyy.loadDictionary('xAODBaseDict') -except: pass from ROOT import xAOD +xAOD.Type.ObjectType #this tool does much of the PFO manipulations in PFlowPseudoJetGetter from JetRecTools.JetRecToolsConf import CorrectPFOTool diff --git a/Reconstruction/Jet/JetRecTools/JetRecTools/JetConstituentModSequence.h b/Reconstruction/Jet/JetRecTools/JetRecTools/JetConstituentModSequence.h index cd707b5a8a6424a356ecd422f5c48b32888240f5..50ded5fd4265ce7eda3aa91cbff5fa26053994ac 100644 --- a/Reconstruction/Jet/JetRecTools/JetRecTools/JetConstituentModSequence.h +++ b/Reconstruction/Jet/JetRecTools/JetRecTools/JetConstituentModSequence.h @@ -10,8 +10,8 @@ #define JETRECTOOLS_JETCONSTITUENTMODSEQUENCE_H // -// // Michael Nelson, CERN & Univesity of Oxford -// // February, 2016 +// Michael Nelson, CERN & Univesity of Oxford +// February, 2016 #include <string> #include "AsgTools/AsgTool.h" @@ -56,22 +56,16 @@ protected: bool m_saveAsShallow = true; // note: not all keys will be used for a particular instantiation - SG::WriteHandleKey<xAOD::CaloClusterContainer> m_caloClusterKey; - SG::WriteHandleKey<xAOD::TruthParticleContainer> m_truthParticleKey; - SG::WriteHandleKey<xAOD::TrackParticleContainer> m_trackParticleKey; + SG::ReadHandleKey<xAOD::CaloClusterContainer> m_inClusterKey{this, "InClusterKey", "", "ReadHandleKey for unmodified CaloClusters"}; + SG::WriteHandleKey<xAOD::CaloClusterContainer> m_outClusterKey{this, "OutClusterKey", "", "WriteHandleKey for modified CaloClusters"}; - SG::WriteHandleKey<xAOD::PFOContainer> m_outPFOChargedKey; - SG::WriteHandleKey<xAOD::PFOContainer> m_outPFONeutralKey; + SG::ReadHandleKey<xAOD::PFOContainer> m_inChargedPFOKey{this, "InChargedPFOKey", "", "ReadHandleKey for modified Charged PFlow Objects"}; + SG::WriteHandleKey<xAOD::PFOContainer> m_outChargedPFOKey{this, "OutChargedPFOKey", "", "WriteHandleKey for modified Charged PFlow Objects"}; - SG::WriteHandleKey<ConstDataVector<xAOD::PFOContainer>> m_outPFOAllKey{}; + SG::ReadHandleKey<xAOD::PFOContainer> m_inNeutralPFOKey{this, "InNeutralPFOKey", "", "ReadHandleKey for modified Neutral PFlow Objects"}; + SG::WriteHandleKey<xAOD::PFOContainer> m_outNeutralPFOKey{this, "OutNeutralPFOKey", "", "WriteHandleKey for modified Neutral PFlow Objects"}; - SG::ReadHandleKey<xAOD::PFOContainer> m_inPFOChargedKey{}; - SG::ReadHandleKey<xAOD::PFOContainer> m_inPFONeutralKey{}; - SG::ReadHandleKey<xAOD::CaloClusterContainer> m_inCaloClusterKey{}; - SG::ReadHandleKey<xAOD::TruthParticleContainer> m_inTruthParticleKey{}; - SG::ReadHandleKey<xAOD::TrackParticleContainer> m_inTrackParticleKey{}; - SG::ReadHandleKey<xAOD::PFOContainer> m_inPFOChargedCopyKey{}; - SG::ReadHandleKey<xAOD::PFOContainer> m_inPFONeutralCopyKey{}; + SG::WriteHandleKey<xAOD::PFOContainer> m_outAllPFOKey{this, "OutAllPFOKey", "", "WriteHandleKey for all modified PFlow Objects"}; StatusCode copyModRecordPFO() const; @@ -99,15 +93,15 @@ JetConstituentModSequence::copyModRecord(const SG::ReadHandleKey<T>& inKey, return StatusCode::FAILURE; } - std::pair< T*, xAOD::ShallowAuxContainer* > newclust = + std::pair< T*, xAOD::ShallowAuxContainer* > newconstit = xAOD::shallowCopyContainer(*inHandle); - newclust.second->setShallowIO(m_saveAsShallow); + newconstit.second->setShallowIO(m_saveAsShallow); - for (auto t : m_modifiers) {ATH_CHECK(t->process(newclust.first));} + for (auto t : m_modifiers) {ATH_CHECK(t->process(newconstit.first));} auto handle = makeHandle(outKey); - ATH_CHECK(handle.record(std::unique_ptr<T>(newclust.first), - std::unique_ptr<xAOD::ShallowAuxContainer>(newclust.second))); + ATH_CHECK(handle.record(std::unique_ptr<T>(newconstit.first), + std::unique_ptr<xAOD::ShallowAuxContainer>(newconstit.second))); return StatusCode::SUCCESS; } diff --git a/Reconstruction/Jet/JetRecTools/Root/JetConstituentModSequence.cxx b/Reconstruction/Jet/JetRecTools/Root/JetConstituentModSequence.cxx index 948637313eb8a933565ba3c280513f3d23c620c1..aae1eb2882c8f048c4ddabbb9ab1a942db5879e6 100644 --- a/Reconstruction/Jet/JetRecTools/Root/JetConstituentModSequence.cxx +++ b/Reconstruction/Jet/JetRecTools/Root/JetConstituentModSequence.cxx @@ -7,7 +7,6 @@ // Will later add the intermediate step #include "JetRecTools/JetConstituentModSequence.h" -#include "AthContainers/ConstDataVector.h" JetConstituentModSequence::JetConstituentModSequence(const std::string &name): asg::AsgTool(name), @@ -36,43 +35,34 @@ StatusCode JetConstituentModSequence::initialize() { return StatusCode::FAILURE; } - m_outPFOAllKey = m_outputContainer+"ParticleFlowObjects"; - m_outPFOChargedKey = m_outputContainer+"ChargedParticleFlowObjects"; - m_outPFONeutralKey = m_outputContainer+"NeutralParticleFlowObjects"; - m_caloClusterKey = m_outputContainer; - m_truthParticleKey = m_outputContainer; - m_trackParticleKey = m_outputContainer; - - m_inCaloClusterKey = m_inputContainer; - m_inTrackParticleKey = m_inputContainer; - m_inTruthParticleKey = m_inputContainer; - m_inPFOChargedKey = m_inputContainer + "ChargedParticleFlowObjects"; - m_inPFONeutralKey = m_inputContainer + "NeutralParticleFlowObjects"; - - // allow reading in of containers previously written out - m_inPFONeutralCopyKey = m_outPFONeutralKey.key(); - m_inPFOChargedCopyKey = m_outPFOChargedKey.key(); - - ATH_CHECK(m_outPFOAllKey.initialize()); - ATH_CHECK(m_caloClusterKey.initialize()); - ATH_CHECK(m_truthParticleKey.initialize()); - ATH_CHECK(m_trackParticleKey.initialize()); - ATH_CHECK(m_outPFOChargedKey.initialize()); - ATH_CHECK(m_outPFONeutralKey.initialize()); - - ATH_CHECK(m_inCaloClusterKey.initialize()); - ATH_CHECK(m_inTruthParticleKey.initialize()); - ATH_CHECK(m_inTrackParticleKey.initialize()); - ATH_CHECK(m_inPFOChargedKey.initialize()); - ATH_CHECK(m_inPFONeutralKey.initialize()); - ATH_CHECK(m_inPFOChargedCopyKey.initialize()); - ATH_CHECK(m_inPFONeutralCopyKey.initialize()); - + // Set and initialise DataHandleKeys only for the correct input type + // Die if the input type is unsupported switch(m_inputType) { case xAOD::Type::CaloCluster: - break; + { + m_inClusterKey = m_inputContainer; + m_outClusterKey = m_outputContainer; + + ATH_CHECK(m_inClusterKey.initialize()); + ATH_CHECK(m_outClusterKey.initialize()); + break; + } case xAOD::Type::ParticleFlow: - break; + { + m_inChargedPFOKey = m_inputContainer + "ChargedParticleFlowObjects"; + m_inNeutralPFOKey = m_inputContainer + "NeutralParticleFlowObjects"; + + m_outChargedPFOKey = m_outputContainer+"ChargedParticleFlowObjects"; + m_outNeutralPFOKey = m_outputContainer+"NeutralParticleFlowObjects"; + m_outAllPFOKey = m_outputContainer+"ParticleFlowObjects"; + + ATH_CHECK(m_inChargedPFOKey.initialize()); + ATH_CHECK(m_inNeutralPFOKey.initialize()); + ATH_CHECK(m_outChargedPFOKey.initialize()); + ATH_CHECK(m_outNeutralPFOKey.initialize()); + ATH_CHECK(m_outAllPFOKey.initialize()); + break; + } default: ATH_MSG_ERROR(" Unsupported input type "<< m_inputType ); return StatusCode::FAILURE; @@ -88,26 +78,12 @@ int JetConstituentModSequence::execute() const { switch(m_inputType){ case xAOD::Type::CaloCluster: { - auto sc = copyModRecord(m_inCaloClusterKey, - m_caloClusterKey); + auto sc = copyModRecord(m_inClusterKey, + m_outClusterKey); if(!sc.isSuccess()){return 1;} break; } - case xAOD::Type::TruthParticle: { - auto sc = copyModRecord(m_inTruthParticleKey, - m_truthParticleKey); - if(!sc.isSuccess()){return 1;} - break; - } - - case xAOD::Type::TrackParticle: { - auto sc = copyModRecord(m_inTrackParticleKey, - m_trackParticleKey); - if(!sc.isSuccess()){return 1;} - break; - } - case xAOD::Type::ParticleFlow: { auto sc = copyModRecordPFO(); if(!sc.isSuccess()){return 1;} @@ -127,46 +103,55 @@ int JetConstituentModSequence::execute() const { StatusCode JetConstituentModSequence::copyModRecordPFO() const { - // write in charged and neutral PFO object, - // pass them to copyModRecord so that copies are - // written to store gate. Request that the copies not be modified. - - using PFOCont = xAOD::PFOContainer; - ATH_CHECK(copyModRecord<PFOCont>(m_inPFOChargedKey, - m_outPFOChargedKey)); - - ATH_CHECK(copyModRecord<PFOCont>(m_inPFONeutralKey, - m_outPFONeutralKey)); - - - /* read in copies of neutral and chargeed PFO objects just written out, - place into a single data vector, modify them, and write them out */ - - auto outHandle = makeHandle(m_outPFOAllKey); - - ATH_CHECK(outHandle.record(std::make_unique<ConstDataVector<xAOD::PFOContainer>>(SG::VIEW_ELEMENTS))); - - - auto neutralHandle = makeHandle(m_inPFONeutralCopyKey); - if(!neutralHandle.isValid()){ - ATH_MSG_WARNING("Unable to retrieve copy of neutral PFOs from " - << m_inPFONeutralCopyKey.key()); + // Cannot be handled the same way as other objects (e.g. clusters), + // because the data is split between two containers, but we need + // information from both to do the modifications. + // + // The logic is: + // 1. Copy the charged & neutral containers independently + // 2. Merge into a combined view container + // 3. Modify the combined container + + // 1. Retrieve the input containers + auto inNeutralPFOHandle = makeHandle(m_inNeutralPFOKey); + auto inChargedPFOHandle = makeHandle(m_inChargedPFOKey); + if(!inNeutralPFOHandle.isValid()){ + ATH_MSG_WARNING("Unable to retrieve input PFO containers \"" + << m_inNeutralPFOKey.key() << "\" and \"" + << m_inChargedPFOKey.key() << "\""); return StatusCode::FAILURE; } + // Copy the input containers individually, set I/O option and record + // Neutral PFOs + std::pair<xAOD::PFOContainer*, xAOD::ShallowAuxContainer* > neutralCopy = + xAOD::shallowCopyContainer(*inNeutralPFOHandle); + neutralCopy.second->setShallowIO(m_saveAsShallow); + // + auto outNeutralPFOHandle = makeHandle(m_outNeutralPFOKey); + ATH_CHECK(outNeutralPFOHandle.record(std::unique_ptr<xAOD::PFOContainer>(neutralCopy.first), + std::unique_ptr<xAOD::ShallowAuxContainer>(neutralCopy.second))); + // Charged PFOs + std::pair<xAOD::PFOContainer*, xAOD::ShallowAuxContainer* > chargedCopy = + xAOD::shallowCopyContainer(*inChargedPFOHandle); + chargedCopy.second->setShallowIO(m_saveAsShallow); + // + auto outChargedPFOHandle = makeHandle(m_outChargedPFOKey); + ATH_CHECK(outChargedPFOHandle.record(std::unique_ptr<xAOD::PFOContainer>(chargedCopy.first), + std::unique_ptr<xAOD::ShallowAuxContainer>(chargedCopy.second))); + + // 2. Set up output handle for merged (view) container and record + auto outAllPFOHandle = makeHandle(m_outAllPFOKey); + ATH_CHECK(outAllPFOHandle.record(std::make_unique<xAOD::PFOContainer>(SG::VIEW_ELEMENTS))); + // Merge charged & neutral PFOs into the viw container + outAllPFOHandle->assign(outNeutralPFOHandle->begin(), outNeutralPFOHandle->end()); + outAllPFOHandle->insert(outAllPFOHandle->end(), + outChargedPFOHandle->begin(), + outChargedPFOHandle->end()); + + // 3. Now process modifications on all PFOs + for (auto t : m_modifiers) {ATH_CHECK(t->process(outAllPFOHandle.ptr()));} - auto chargedHandle = makeHandle(m_inPFOChargedCopyKey); - if(!chargedHandle.isValid()){ - ATH_MSG_WARNING("Unable to retrieve copy of charged PFOs from " - << m_inPFOChargedCopyKey.key()); - return StatusCode::FAILURE; - } - - outHandle->assign(neutralHandle->begin(), neutralHandle->end()); - outHandle->insert(outHandle->end(), - chargedHandle->begin(), - chargedHandle->end()); - return StatusCode::SUCCESS; } diff --git a/Reconstruction/Jet/JetRecTools/python/JetRecToolsConfig.py b/Reconstruction/Jet/JetRecTools/python/JetRecToolsConfig.py index ec0bf14e2d2f32c70179952adf6f88e9680301a9..cea87de38aaf799061236ad390a53e12aabd9f43 100644 --- a/Reconstruction/Jet/JetRecTools/python/JetRecToolsConfig.py +++ b/Reconstruction/Jet/JetRecTools/python/JetRecToolsConfig.py @@ -61,16 +61,13 @@ class ConstituentToolManager(object): # map of named standard list of modifiers standardModifierLists = dict() - import cppyy - try: cppyy.loadDictionary('xAODBaseDict') - except: pass + import ROOT from ROOT import xAOD - - # map of known input collection to their type + xAOD.Type.ObjectType # Trigger dict load + # map of known input collections to their type inputContainerMap = dict( CaloCalTopoClusters = xAOD.Type.CaloCluster, CaloTopoClusters = xAOD.Type.CaloCluster, EMOriginTopoClusters = xAOD.Type.CaloCluster, LCOriginTopoClusters = xAOD.Type.CaloCluster, InDetTrackParticles = xAOD.Type.TrackParticle, JetETMiss = xAOD.Type.ParticleFlow ) - log = Logging.logging.getLogger("ConstituentToolManager") diff --git a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoAODFixGetter.py b/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoAODFixGetter.py index 2fbb1563e9501736aa34282352190eb4ddbcbef4..9baab1e9fad5fd68b578ec3cb71337499dc53211 100644 --- a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoAODFixGetter.py +++ b/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoAODFixGetter.py @@ -30,7 +30,8 @@ def configureEDCorrection(tool): from JetRec.JetRecStandard import jtm topSequence = AlgSequence() if not hasattr(topSequence,'EDtpIsoVeryForwardAlg'): - tfcc = configEventDensityTool("EDtpIsoVeryForwardTool", jtm.emget, + tfcc = configEventDensityTool("EDtpIsoVeryForwardTool", + inputlabel = jtm.emget.Label, radius = 0.5, AbsRapidityMin = 2.5, AbsRapidityMax = 4.5, diff --git a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.py b/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.py index 1c8cdf0dc77d3b657839b146b2e8f042b616689d..f89b0ebaef6cd56455328f1c7ca8fde79bae94c0 100644 --- a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.py +++ b/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.py @@ -18,6 +18,9 @@ from IsolationCorrections.IsolationCorrectionsConf import CP__IsolationCorrectio IsoCorrectionTool = ToolFactory(ICT, name = "NewLeakageCorrTool") +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + doPFlow = False PFlowObjectsInConeTool = None from RecExConfig.RecAlgsFlags import recAlgs @@ -37,13 +40,20 @@ if recAlgs.doEFlow() : from JetRec.JetRecStandard import jtm from JetRec.JetRecConf import PseudoJetGetter - jtm += PseudoJetGetter( + emnpflowget = PseudoJetGetter( name = "emnpflowget", Label = "EMNPFlow", InputContainer = "CHSNeutralParticleFlowObjects", OutputContainer = "PseudoJetEMNPFlow", SkipNegativeEnergy = True, ) + jtm += emnpflowget + # PseudoJetGetters are now run in their own dedicated algs + from JetRec.JetRecConf import PseudoJetAlgorithm + # EMTopo (non-origin corrected) clusters + topSequence += PseudoJetAlgorithm("pjalg_"+jtm.emget.Label,PJGetter=jtm.emget) + # EM Neutral PFOs + topSequence += PseudoJetAlgorithm("pjalg_"+emnpflowget.Label,PJGetter=emnpflowget) # tool to collect topo clusters in cone from ParticlesInConeTools.ParticlesInConeToolsConf import xAOD__CaloClustersInConeTool @@ -62,12 +72,12 @@ def configureEDCorrection(tool): OutputLevel = min(getPropertyValue(tool, 'OutputLevel'), INFO) try: from AthenaCommon.AppMgr import ToolSvc - from AthenaCommon.AlgSequence import AlgSequence from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAthAlg - from JetRec.JetRecStandard import jtm + from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() if not hasattr(topSequence,'EDtpIsoCentralAlg'): - tccc = configEventDensityTool("EDtpIsoCentralTool", jtm.emget, + tccc = configEventDensityTool("EDtpIsoCentralTool", + inputlabel = jtm.emget.Label, radius = 0.5, AbsRapidityMin = 0.0, AbsRapidityMax = 1.5, @@ -78,7 +88,8 @@ def configureEDCorrection(tool): topSequence += EventDensityAthAlg("EDtpIsoCentralAlg", EventDensityTool = tccc) if not hasattr(topSequence,'EDtpIsoForwardAlg'): - tfcc = configEventDensityTool("EDtpIsoForwardTool", jtm.emget, + tfcc = configEventDensityTool("EDtpIsoForwardTool", + inputlabel = jtm.emget.Label, radius = 0.5, AbsRapidityMin = 1.5, AbsRapidityMax = 3.0, @@ -89,7 +100,8 @@ def configureEDCorrection(tool): topSequence += EventDensityAthAlg("EDtpIsoForwardAlg", EventDensityTool = tfcc) if not hasattr(topSequence,'EDtpIsoVeryForwardAlg'): - tvfcc = configEventDensityTool("EDtpIsoVeryForwardTool", jtm.emget, + tvfcc = configEventDensityTool("EDtpIsoVeryForwardTool", + inputlabel = jtm.emget.Label, radius = 0.5, AbsRapidityMin = 2.5, AbsRapidityMax = 4.5, @@ -101,7 +113,8 @@ def configureEDCorrection(tool): if doPFlow: if not hasattr(topSequence,'EDpfIsoCentralAlg'): - tcpf = configEventDensityTool("EDpfIsoCentralTool", jtm.empflowget, + tcpf = configEventDensityTool("EDpfIsoCentralTool", + inputlabel = jtm.empflowget.Label, radius = 0.5, AbsRapidityMin = 0.0, AbsRapidityMax = 1.5, @@ -112,7 +125,8 @@ def configureEDCorrection(tool): topSequence += EventDensityAthAlg("EDpfIsoCentralAlg", EventDensityTool = tcpf) if not hasattr(topSequence,'EDpfIsoForwardAlg'): - tfpf = configEventDensityTool("EDpfIsoForwardTool", jtm.empflowget, + tfpf = configEventDensityTool("EDpfIsoForwardTool", + inputlabel = jtm.empflowget.Label, radius = 0.5, AbsRapidityMin = 1.5, AbsRapidityMax = 3.0, @@ -124,7 +138,8 @@ def configureEDCorrection(tool): ## Try a neutral density if not hasattr(topSequence,'EDnpfIsoCentralAlg'): - tcnpf = configEventDensityTool("EDnpfIsoCentralTool", jtm.emnpflowget, + tcnpf = configEventDensityTool("EDnpfIsoCentralTool", + inputlabel = jtm.emnpflowget.Label, radius = 0.5, AbsRapidityMin = 0.0, AbsRapidityMax = 1.5, @@ -135,7 +150,8 @@ def configureEDCorrection(tool): topSequence += EventDensityAthAlg("EDnpfIsoCentralAlg", EventDensityTool = tcnpf) if not hasattr(topSequence,'EDnpfIsoForwardAlg'): - tfnpf = configEventDensityTool("EDnpfIsoForwardTool", jtm.emnpflowget, + tfnpf = configEventDensityTool("EDnpfIsoForwardTool", + inputlabel = jtm.emnpflowget.Label, radius = 0.5, AbsRapidityMin = 1.5, AbsRapidityMax = 3.0, diff --git a/Trigger/TrigAlgorithms/TrigHLTJetRec/python/TrigHLTJetRecConfig.py b/Trigger/TrigAlgorithms/TrigHLTJetRec/python/TrigHLTJetRecConfig.py index 251ac4f19e40b96dcaff58b47a8489c16cee63f8..c7c6a1623160b68cc722c7be7d0b016d7e75e3c0 100644 --- a/Trigger/TrigAlgorithms/TrigHLTJetRec/python/TrigHLTJetRecConfig.py +++ b/Trigger/TrigAlgorithms/TrigHLTJetRec/python/TrigHLTJetRecConfig.py @@ -74,7 +74,7 @@ def configHLTEventDensityTool(name, toolProperties = dict( JetAlgorithm = JetAlgorithm, JetRadius = radius, - JetInput = pjGetter, + TrigPseudoJetGetter = pjGetter, AbsRapidityMin = AbsRapidityMin, AbsRapidityMax = AbsRapidityMax, AreaDefinition = AreaDefinition,