From 8bf5c11ec701deed769876efe8b1347a64b10153 Mon Sep 17 00:00:00 2001 From: abarton <Adam.Edward.Barton@cern.ch> Date: Fri, 12 Aug 2022 16:51:55 +0100 Subject: [PATCH] Rework V0Finder to work with AthenaMT, fix BPHY10 crash Reworks/refactors V0Finder to reuse decorator code Fix a bug in BPHY10 (ATLBPHYS-235) - The change to JpsiPlusV0Cascade.cxx Fixes V0Finder erroneously decorating the primary vertices (ATLASRECTS-7186) Clean up old dependencies Use xAOD::EventInfo instead of BeamSpotConditions --- .../share/InDetRecPostProcessing.py | 9 +- .../InDetRecAlgs/InDetV0Finder/CMakeLists.txt | 10 +- .../InDetV0Finder/InDetV0FinderTool.h | 31 +- .../InDetV0Finder/V0MainDecorator.h | 139 +++++++ .../InDetV0Finder/src/InDetV0Finder.cxx | 366 ++---------------- .../InDetV0Finder/src/InDetV0Finder.h | 119 +----- .../InDetV0Finder/src/InDetV0FinderTool.cxx | 130 +++---- .../InDetV0Finder/src/V0MainDecorator.cxx | 264 +++++++++++++ .../src/components/InDetV0Finder_entries.cxx | 3 +- .../JpsiPlusV0Cascade.h | 2 +- .../DerivationFrameworkBPhys/Reco_V0Finder.h | 37 +- .../DerivationFrameworkBPhys/share/BPHY10.py | 32 +- .../src/JpsiPlusV0Cascade.cxx | 5 +- .../src/Reco_V0Finder.cxx | 299 +++----------- 14 files changed, 641 insertions(+), 805 deletions(-) create mode 100644 InnerDetector/InDetRecAlgs/InDetV0Finder/InDetV0Finder/V0MainDecorator.h create mode 100644 InnerDetector/InDetRecAlgs/InDetV0Finder/src/V0MainDecorator.cxx diff --git a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecPostProcessing.py b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecPostProcessing.py index 6bb10c0b0265..842ce206dfba 100755 --- a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecPostProcessing.py +++ b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecPostProcessing.py @@ -353,11 +353,18 @@ if InDetFlags.doV0Finder(): # --- now configure the algorithm # if InDetFlags.doV0Finder() : + from InDetV0Finder.InDetV0FinderConf import InDet__V0MainDecorator + V0Decorator = InDet__V0MainDecorator(name = "V0Decorator", + V0Tools = v0_tools, + V0ContainerName = InDetKeys.xAODV0VertexContainer(), + KshortContainerName = InDetKeys.xAODKshortVertexContainer(), + LambdaContainerName = InDetKeys.xAODLambdaVertexContainer(), + LambdabarContainerName = InDetKeys.xAODLambdabarVertexContainer()) from InDetV0Finder.InDetV0FinderConf import InDet__InDetV0Finder InDetV0Finder = InDet__InDetV0Finder(name = 'InDetV0Finder', #decorateV0 = False, InDetV0FinderToolName = V0FinderTool, - V0Tools = v0_tools, + Decorator = V0Decorator, V0ContainerName = InDetKeys.xAODV0VertexContainer(), KshortContainerName = InDetKeys.xAODKshortVertexContainer(), LambdaContainerName = InDetKeys.xAODLambdaVertexContainer(), diff --git a/InnerDetector/InDetRecAlgs/InDetV0Finder/CMakeLists.txt b/InnerDetector/InDetRecAlgs/InDetV0Finder/CMakeLists.txt index 0ebf119d8a56..076c01d7c08c 100644 --- a/InnerDetector/InDetRecAlgs/InDetV0Finder/CMakeLists.txt +++ b/InnerDetector/InDetRecAlgs/InDetV0Finder/CMakeLists.txt @@ -1,19 +1,17 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration # Declare the package name: atlas_subdir( InDetV0Finder ) # External dependencies: -find_package( CLHEP ) find_package( HepPDT ) -find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) atlas_add_library( InDetV0FinderLib src/*.cxx PUBLIC_HEADERS InDetV0Finder - PRIVATE_INCLUDE_DIRS ${HEPPDT_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES AthContainers AthenaBaseComps BeamSpotConditionsData GaudiKernel StoreGateLib xAODTracking - PRIVATE_LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPPDT_LIBRARIES} ${ROOT_LIBRARIES} ITrackToVertex InDetConversionFinderToolsLib TrkExInterfaces TrkToolInterfaces TrkV0FitterLib TrkVKalVrtFitterLib TrkVertexAnalysisUtilsLib TrkVertexFitterInterfaces ) + PRIVATE_INCLUDE_DIRS ${HEPPDT_INCLUDE_DIRS} } + LINK_LIBRARIES AthContainers AthenaBaseComps GaudiKernel StoreGateLib xAODTracking TrkVertexAnalysisUtilsLib + PRIVATE_LINK_LIBRARIES ${HEPPDT_LIBRARIES} ITrackToVertex InDetConversionFinderToolsLib TrkExInterfaces TrkToolInterfaces TrkV0FitterLib TrkVKalVrtFitterLib TrkVertexFitterInterfaces xAODEventInfo ) atlas_add_component( InDetV0Finder src/components/*.cxx diff --git a/InnerDetector/InDetRecAlgs/InDetV0Finder/InDetV0Finder/InDetV0FinderTool.h b/InnerDetector/InDetRecAlgs/InDetV0Finder/InDetV0Finder/InDetV0FinderTool.h index a9a905de4280..3928373f1fac 100755 --- a/InnerDetector/InDetRecAlgs/InDetV0Finder/InDetV0Finder/InDetV0FinderTool.h +++ b/InnerDetector/InDetRecAlgs/InDetV0Finder/InDetV0Finder/InDetV0FinderTool.h @@ -17,12 +17,10 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ToolHandle.h" -#include "AthContainers/DataVector.h" #include "xAODTracking/VertexContainer.h" -#include "xAODTracking/VertexAuxContainer.h" #include "xAODTracking/TrackParticleContainer.h" #include "StoreGate/WriteDecorHandleKey.h" -#include "BeamSpotConditionsData/BeamSpotData.h" +#include "xAODEventInfo/EventInfo.h" #include <atomic> /** The InDetV0FinderTool reads in the TrackParticle container from StoreGate, @@ -90,7 +88,6 @@ namespace Reco{ namespace InDet { class VertexPointEstimator; - class ConversionFinderUtils; static const InterfaceID IID_InDetV0FinderTool("InDetV0FinderTool", 1, 0); @@ -104,12 +101,12 @@ namespace InDet static const InterfaceID& interfaceID() { return IID_InDetV0FinderTool;} - StatusCode performSearch(xAOD::VertexContainer*& v0Container, xAOD::VertexAuxContainer*& v0AuxContainer, - xAOD::VertexContainer*& ksContainer, xAOD::VertexAuxContainer*& ksAuxContainer, - xAOD::VertexContainer*& laContainer, xAOD::VertexAuxContainer*& laAuxContainer, - xAOD::VertexContainer*& lbContainer, xAOD::VertexAuxContainer*& lbAuxContainer, + StatusCode performSearch(xAOD::VertexContainer* v0Container, + xAOD::VertexContainer* ksContainer, + xAOD::VertexContainer* laContainer, + xAOD::VertexContainer* lbContainer, const xAOD::Vertex* vertex, - const xAOD::VertexContainer* vertColl + const xAOD::VertexContainer* vertColl, const EventContext& ctx ) const; //protected: @@ -125,7 +122,6 @@ namespace InDet ToolHandle < Trk::IVertexFitter > m_iGammaFitter; ToolHandle < Trk::V0Tools > m_V0Tools; ToolHandle < Reco::ITrackToVertex > m_trackToVertexTool; - ToolHandle < InDet::ConversionFinderUtils > m_helpertool; ToolHandle < Trk::ITrackSelectorTool > m_trkSelector; ToolHandle < InDet::VertexPointEstimator > m_vertexEstimator; ToolHandle < Trk::IExtrapolator > m_extrapolator; @@ -177,7 +173,7 @@ namespace InDet static double invariantMass(const Trk::TrackParameters* per1, const Trk::TrackParameters* per2, double m1, double m2) ; - bool doFit(const xAOD::TrackParticle* track1, const xAOD::TrackParticle* track2, Amg::Vector3D &startingPoint) const; + bool doFit(const xAOD::TrackParticle* track1, const xAOD::TrackParticle* track2, Amg::Vector3D &startingPoint, const EventContext& ctx) const; bool d0Pass(const xAOD::TrackParticle* track1, const xAOD::TrackParticle* track2, const xAOD::VertexContainer * vertColl) const; bool d0Pass(const xAOD::TrackParticle* track1, const xAOD::TrackParticle* track2, const xAOD::Vertex * vertex) const; @@ -194,7 +190,9 @@ namespace InDet SG::ReadHandleKey<xAOD::VertexContainer> m_vertexKey { this, "VertexContainer", "PrimaryVertices", "primary vertex container" }; - SG::WriteDecorHandleKey<xAOD::VertexContainer> m_v0LinksDecorkey; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_v0LinksDecorkeyks; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_v0LinksDecorkeylb; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_v0LinksDecorkeylbb; SG::WriteDecorHandleKey<xAOD::VertexContainer> m_v0_ksLinksDecorkey; SG::WriteDecorHandleKey<xAOD::VertexContainer> m_v0_laLinksDecorkey; SG::WriteDecorHandleKey<xAOD::VertexContainer> m_v0_lbLinksDecorkey; @@ -204,8 +202,15 @@ namespace InDet SG::WriteDecorHandleKey<xAOD::VertexContainer> m_mDecor_gmasserr; SG::WriteDecorHandleKey<xAOD::VertexContainer> m_mDecor_gprob; - SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; + SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo_key{this, "EventInfo", "EventInfo", "Input event information"}; + // V0 candidate output container name (same calling alg) + Gaudi::Property<std::string> m_v0Key { this, "V0ContainerName", "V0Candidates", "V0 container name (same calling alg)" }; + Gaudi::Property<std::string> m_ksKey { this, "KshortContainerName", "KshortCandidates", "Ks container name (same calling alg)" }; + Gaudi::Property<std::string> m_laKey { this, "LambdaContainerName", "LambdaCandidates", + "Lambda container name (same calling alg)" }; + Gaudi::Property<std::string> m_lbKey { this, "LambdabarContainerName", "LambdabarCandidates", + "Lambdabar container name (same calling alg)" }; }; diff --git a/InnerDetector/InDetRecAlgs/InDetV0Finder/InDetV0Finder/V0MainDecorator.h b/InnerDetector/InDetRecAlgs/InDetV0Finder/InDetV0Finder/V0MainDecorator.h new file mode 100644 index 000000000000..ab9910e67501 --- /dev/null +++ b/InnerDetector/InDetRecAlgs/InDetV0Finder/InDetV0Finder/V0MainDecorator.h @@ -0,0 +1,139 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef INDETV0FINDER_V0MAINDECORATOR_H +#define INDETV0FINDER_V0MAINDECORATOR_H + +#include "AthenaBaseComps/AthAlgTool.h" +#include "GaudiKernel/ToolHandle.h" +#include "xAODTracking/VertexContainer.h" +#include "TrkVertexAnalysisUtils/V0Tools.h" + + +namespace InDet +{ + + class V0MainDecorator: public AthAlgTool + { + public: + V0MainDecorator(const std::string& t, const std::string& n, const IInterface* p); + ~V0MainDecorator(); + StatusCode initialize(); + StatusCode decorateV0(xAOD::VertexContainer *container, const EventContext& ctx) const; + StatusCode decorateks(xAOD::VertexContainer *container, const EventContext& ctx) const; + StatusCode decoratela(xAOD::VertexContainer *container, const EventContext& ctx) const; + StatusCode decoratelb(xAOD::VertexContainer *container, const EventContext& ctx) const; + private: + + int m_masses; //!< = 1 if using PDG values, = 2 if user set (1) + double m_masspi; //!< pion mass (139.57 MeV) + double m_massp; //!< proton mass (938.272 MeV) + double m_masse; //!< electron mass (0.510999 MeV) + double m_massK0S; //!< Kshort mass (497.672 MeV) + double m_massLambda; //!< Lambda mass (1115.68 MeV) + ToolHandle<Trk::V0Tools> m_V0Tools {this, "V0Tools", "Trk::V0Tools", "V0 tools to calculate things like Lxy"}; + StatusCode initKey(const std::string&, SG::WriteDecorHandleKey<xAOD::VertexContainer> &decokey) const; + + Gaudi::Property<std::string> m_v0Key + { this, "V0ContainerName", "V0Candidates", "V0 container name (same calling alg)" }; + Gaudi::Property<std::string> m_ksKey { this, "KshortContainerName", "KshortCandidates", "Ks container" }; + Gaudi::Property<std::string> m_laKey { this, "LambdaContainerName", "LambdaCandidates", + "Lambda container" }; + Gaudi::Property<std::string> m_lbKey { this, "LambdabarContainerName", "LambdabarCandidates", + "Lambdabar container" }; + + + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorKsMass + { this, "KsMass_v0", ".Kshort_mass", "Ks mass for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorKsMassErr + { this, "KsMassErr_v0", ".Kshort_massError", "Ks mass error for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorLaMass + { this, "LaMass_v0", ".Lambda_mass", "Lambda mass for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorLaMassErr + { this, "LaMassErr_v0", ".Lambda_massError", "Lambda mass error for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorLbMass + { this, "LbMass_v0", ".Lambdabar_mass", "Lambdabar mass for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorLbMassErr + { this, "LbMassErr_v0", ".Lambdabar_massError", "Lambdabar mass error for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPt_v0 + { this, "Pt_v0", ".pT", "Transverse momentum for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPtErr_v0 + { this, "PtErr_v0", ".pTError", "Transverse momentum error for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorRxy_v0 + { this, "Rxy_v0", ".Rxy", "Rxy for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorRxyErr_v0 + { this, "RxyErr_v0", ".RxyError", "Rxy error for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPx_v0 + { this, "Px_v0", ".px", "Px for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPy_v0 + { this, "Py_v0", ".py", "Py for v0" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPz_v0 + { this, "Pz_v0", ".pz", "Pz for v0" }; + + // Ks decorators + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorMass_ks + { this, "Mass_ks", ".mass", "mass for Ks" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorMassErr_ks + { this, "MassErr_ks", ".massError", "mass error for Ks" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPt_ks + { this, "Pt_ks", ".pT", "Transverse momentum for Ks" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPtErr_ks + { this, "PtErr_ks", ".pTError", "Transverse momentum error for Ks" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorRxy_ks + { this, "Rxy_ks", ".Rxy", "Rxy for Ks" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorRxyErr_ks + { this, "RxyErr_ks", ".RxyError", "Rxy error for Ks" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPx_ks + { this, "Px_ks", ".px", "Px for Ks" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPy_ks + { this, "Py_ks", ".py", "Py for Ks" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPz_ks + { this, "Pz_ks", ".pz", "Pz for Ks" }; + + // Lambda decorators + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorMass_la + { this, "Mass_la", ".mass", "mass for Lambda" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorMassErr_la + { this, "MassErr_la", ".massError", "mass error for Lambda" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPt_la + { this, "Pt_la", ".pT", "Transverse momentum for Lambda" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPtErr_la + { this, "PtErr_la", ".pTError", "Transverse momentum error for Lambda" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorRxy_la + { this, "Rxy_la", ".Rxy", "Rxy for la" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorRxyErr_la + { this, "RxyErr_la", ".RxyError", "Rxy error for Lambda" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPx_la + { this, "Px_la", ".px", "Px for Lambda" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPy_la + { this, "Py_la", ".py", "Py for Lambda" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPz_la + { this, "Pz_la", ".pz", "Pz for Lambda" }; + + // Lambdabar decorators + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorMass_lb + { this, "Mass_lb", ".mass", "mass for Lambdabar" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorMassErr_lb + { this, "MassErr_lb", ".massError", "mass error for Lambdabar" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPt_lb + { this, "Pt_lb", ".pT", "Transverse momentum for Lambdabar" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPtErr_lb + { this, "PtErr_lb", ".pTError", "Transverse momentum error for Lambdabar" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorRxy_lb + { this, "Rxy_lb", ".Rxy", "Rxy for Lambdabar" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorRxyErr_lb + { this, "RxyErr_lb", ".RxyError", "Rxy error for Lambdabar" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPx_lb + { this, "Px_lb", ".px", "Px for Lambdabar" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPy_lb + { this, "Py_lb", ".py", "Py for Lambdabar" }; + SG::WriteDecorHandleKey<xAOD::VertexContainer> m_decorPz_lb + { this, "Pz_lb", ".pz", "Pz for Lambdabar" }; + + }; + +} + + +#endif \ No newline at end of file diff --git a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0Finder.cxx b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0Finder.cxx index ea9547d12cfd..7908e97a0800 100755 --- a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0Finder.cxx +++ b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0Finder.cxx @@ -16,20 +16,11 @@ #include "InDetV0Finder.h" -#include "GaudiKernel/IToolSvc.h" -#include "GaudiKernel/ISvcLocator.h" - #include "xAODTracking/VertexContainer.h" #include "xAODTracking/VertexAuxContainer.h" -#include "TrkVertexAnalysisUtils/V0Tools.h" #include "InDetV0Finder/InDetV0FinderTool.h" -#include "GaudiKernel/IPartPropSvc.h" #include "StoreGate/WriteDecorHandle.h" -#include "HepPDT/ParticleDataTable.hh" -#include "EventKernel/PdtPdg.h" - #include <vector> -#include <cmath> #include <string> @@ -39,16 +30,8 @@ namespace InDet InDetV0Finder::InDetV0Finder(const std::string &n, ISvcLocator *pSvcLoc) : AthAlgorithm(n, pSvcLoc), - m_v0FinderTool("InDet::InDetV0FinderTool"), - m_V0Tools("Trk::V0Tools"), - m_particleDataTable(nullptr), + m_v0FinderTool("InDet::InDetV0FinderTool",this), m_decorate(true), - m_masses(1), - m_masspi(139.57), - m_massp(938.272), - m_masse(0.510999), - m_massK0S(497.672), - m_massLambda(1115.68), m_events_processed(0), m_V0s_stored(0), m_Kshort_stored(0), @@ -56,14 +39,7 @@ InDetV0Finder::InDetV0Finder(const std::string &n, ISvcLocator *pSvcLoc) m_Lambdabar_stored(0) { declareProperty("InDetV0FinderToolName" , m_v0FinderTool); - declareProperty("V0Tools",m_V0Tools); declareProperty("decorateV0", m_decorate); - declareProperty("masses", m_masses); - declareProperty("masspi", m_masspi); - declareProperty("massp", m_massp); - declareProperty("masse", m_masse); - declareProperty("massK0S", m_massK0S); - declareProperty("massLambda", m_massLambda); } InDetV0Finder::~InDetV0Finder() = default; @@ -78,121 +54,12 @@ StatusCode InDetV0Finder::initialize() ATH_CHECK( m_laKey.initialize() ); ATH_CHECK( m_lbKey.initialize() ); - // Make sure decoration keys match the VertexContainer name (which is configured at run-time by python for production jobs) - m_decorKsMass = m_v0Key.key() + m_decorKsMass.key(); - m_decorLaMass = m_v0Key.key() + m_decorLaMass.key(); - m_decorLbMass = m_v0Key.key() + m_decorLaMass.key(); - m_decorKsMassErr = m_v0Key.key() + m_decorKsMassErr.key(); - m_decorLaMassErr = m_v0Key.key() + m_decorLaMassErr.key(); - m_decorLbMassErr = m_v0Key.key() + m_decorLbMassErr.key(); - - ATH_CHECK( m_decorKsMass.initialize() ); - ATH_CHECK( m_decorLaMass.initialize() ); - ATH_CHECK( m_decorLbMass.initialize() ); - ATH_CHECK( m_decorKsMassErr.initialize() ); - ATH_CHECK( m_decorLaMassErr.initialize() ); - ATH_CHECK( m_decorLbMassErr.initialize() ); - - m_decorMass_ks = m_ksKey.key() + m_decorMass_ks.key(); - m_decorMass_la = m_laKey.key() + m_decorMass_la.key(); - m_decorMass_lb = m_lbKey.key() + m_decorMass_lb.key(); - - m_decorMassErr_ks = m_ksKey.key() + m_decorMassErr_ks.key(); - m_decorMassErr_la = m_laKey.key() + m_decorMassErr_la.key(); - m_decorMassErr_lb = m_lbKey.key() + m_decorMassErr_lb.key(); - - ATH_CHECK( m_decorMass_ks.initialize() ); - ATH_CHECK( m_decorMass_la.initialize() ); - ATH_CHECK( m_decorMass_lb.initialize() ); - ATH_CHECK( m_decorMassErr_ks.initialize() ); - ATH_CHECK( m_decorMassErr_la.initialize() ); - ATH_CHECK( m_decorMassErr_lb.initialize() ); - - m_decorPt_v0 = m_v0Key.key() + m_decorPt_v0.key(); - m_decorPt_ks = m_ksKey.key() + m_decorPt_ks.key(); - m_decorPt_la = m_laKey.key() + m_decorPt_la.key(); - m_decorPt_lb = m_lbKey.key() + m_decorPt_lb.key(); - m_decorPtErr_v0 = m_v0Key.key() + m_decorPtErr_v0.key(); - m_decorPtErr_ks = m_ksKey.key() + m_decorPtErr_ks.key(); - m_decorPtErr_la = m_laKey.key() + m_decorPtErr_la.key(); - m_decorPtErr_lb = m_lbKey.key() + m_decorPtErr_lb.key(); - m_decorRxy_v0 = m_v0Key.key() + m_decorRxy_v0.key(); - m_decorRxy_ks = m_ksKey.key() + m_decorRxy_ks.key(); - m_decorRxy_la = m_laKey.key() + m_decorRxy_la.key(); - m_decorRxy_lb = m_lbKey.key() + m_decorRxy_lb.key(); - m_decorRxyErr_v0 = m_v0Key.key() + m_decorRxyErr_v0.key(); - m_decorRxyErr_ks = m_ksKey.key() + m_decorRxyErr_ks.key(); - m_decorRxyErr_la = m_laKey.key() + m_decorRxyErr_la.key(); - m_decorRxyErr_lb = m_lbKey.key() + m_decorRxyErr_lb.key(); - m_decorPx_v0 = m_v0Key.key() + m_decorPx_v0.key(); - m_decorPx_ks = m_ksKey.key() + m_decorPx_ks.key(); - m_decorPx_la = m_laKey.key() + m_decorPx_la.key(); - m_decorPx_lb = m_lbKey.key() + m_decorPx_lb.key(); - m_decorPy_v0 = m_v0Key.key() + m_decorPy_v0.key(); - m_decorPy_ks = m_ksKey.key() + m_decorPy_ks.key(); - m_decorPy_la = m_laKey.key() + m_decorPy_la.key(); - m_decorPy_lb = m_lbKey.key() + m_decorPy_lb.key(); - m_decorPz_v0 = m_v0Key.key() + m_decorPz_v0.key(); - m_decorPz_ks = m_ksKey.key() + m_decorPz_ks.key(); - m_decorPz_la = m_laKey.key() + m_decorPz_la.key(); - m_decorPz_lb = m_lbKey.key() + m_decorPz_lb.key(); - - ATH_CHECK( m_decorPt_v0.initialize() ); - ATH_CHECK( m_decorPt_ks.initialize() ); - ATH_CHECK( m_decorPt_la.initialize() ); - ATH_CHECK( m_decorPt_lb.initialize() ); - ATH_CHECK( m_decorPtErr_v0.initialize() ); - ATH_CHECK( m_decorPtErr_ks.initialize() ); - ATH_CHECK( m_decorPtErr_la.initialize() ); - ATH_CHECK( m_decorPtErr_lb.initialize() ); - ATH_CHECK( m_decorRxy_v0.initialize() ); - ATH_CHECK( m_decorRxy_ks.initialize() ); - ATH_CHECK( m_decorRxy_la.initialize() ); - ATH_CHECK( m_decorRxy_lb.initialize() ); - ATH_CHECK( m_decorRxyErr_v0.initialize() ); - ATH_CHECK( m_decorRxyErr_ks.initialize() ); - ATH_CHECK( m_decorRxyErr_la.initialize() ); - ATH_CHECK( m_decorRxyErr_lb.initialize() ); - ATH_CHECK( m_decorPx_v0.initialize() ); - ATH_CHECK( m_decorPx_ks.initialize() ); - ATH_CHECK( m_decorPx_la.initialize() ); - ATH_CHECK( m_decorPx_lb.initialize() ); - ATH_CHECK( m_decorPy_v0.initialize() ); - ATH_CHECK( m_decorPy_ks.initialize() ); - ATH_CHECK( m_decorPy_la.initialize() ); - ATH_CHECK( m_decorPy_lb.initialize() ); - ATH_CHECK( m_decorPz_v0.initialize() ); - ATH_CHECK( m_decorPz_ks.initialize() ); - ATH_CHECK( m_decorPz_la.initialize() ); - ATH_CHECK( m_decorPz_lb.initialize() ); - // uploading the V0Finding tools ATH_CHECK( m_v0FinderTool.retrieve() ); - msg(MSG::INFO) << "Retrieved tool " << m_v0FinderTool << endmsg; + ATH_MSG_DEBUG("Retrieved tool " << m_v0FinderTool); + ATH_CHECK(m_v0DecoTool.retrieve(DisableTool{!m_decorate})); -// uploading the V0 tools - ATH_CHECK( m_V0Tools.retrieve() ); - msg(MSG::INFO) << "Retrieved tool " << m_V0Tools << endmsg; - -// get the Particle Properties Service - IPartPropSvc* partPropSvc = nullptr; - ATH_CHECK( service("PartPropSvc", partPropSvc, true) ); - m_particleDataTable = partPropSvc->PDT(); - - const HepPDT::ParticleData* pd_pi = m_particleDataTable->particle(PDG::pi_plus); - const HepPDT::ParticleData* pd_p = m_particleDataTable->particle(PDG::p_plus); - const HepPDT::ParticleData* pd_e = m_particleDataTable->particle(PDG::e_minus); - const HepPDT::ParticleData* pd_K = m_particleDataTable->particle(PDG::K_S0); - const HepPDT::ParticleData* pd_L = m_particleDataTable->particle(PDG::Lambda0); - if (m_masses == 1) { - m_masspi = pd_pi->mass(); - m_massp = pd_p->mass(); - m_masse = pd_e->mass(); - m_massK0S = pd_K->mass(); - m_massLambda = pd_L->mass(); - } - - msg(MSG::INFO) << "Initialization successful" << endmsg; + ATH_MSG_DEBUG("Initialization successful"); return StatusCode::SUCCESS; } @@ -202,10 +69,10 @@ StatusCode InDetV0Finder::execute() { m_events_processed++; - + const EventContext& ctx = Gaudi::Hive::currentContext(); // Get primary vertex from StoreGate const xAOD::Vertex* primaryVertex = nullptr; - SG::ReadHandle<xAOD::VertexContainer> importedVxContainer( m_vertexKey ); + SG::ReadHandle<xAOD::VertexContainer> importedVxContainer( m_vertexKey, ctx ); if ( !importedVxContainer.isValid() ) { ATH_MSG_WARNING("No xAOD::VertexContainer named " << m_vertexKey.key() << " found in StoreGate"); @@ -219,205 +86,48 @@ StatusCode InDetV0Finder::execute() primaryVertex = importedVxContainer->front(); } -// InDetV0 container and its auxilliary store - xAOD::VertexContainer* v0Container{}; - xAOD::VertexAuxContainer* v0AuxContainer{}; - xAOD::VertexContainer* ksContainer{}; - xAOD::VertexAuxContainer* ksAuxContainer{}; - xAOD::VertexContainer* laContainer{}; - xAOD::VertexAuxContainer* laAuxContainer{}; - xAOD::VertexContainer* lbContainer{}; - xAOD::VertexAuxContainer* lbAuxContainer{}; - - - // - const auto statusOfSearch = m_v0FinderTool->performSearch(v0Container, v0AuxContainer, - ksContainer, ksAuxContainer, - laContainer, laAuxContainer, - lbContainer, lbAuxContainer, - primaryVertex, importedVxContainer.cptr()); - // - using Container_p = std::unique_ptr<xAOD::VertexContainer>; - using Aux_p = std::unique_ptr<xAOD::VertexAuxContainer>; - //create unique pointers for all containers and aux containers - Container_p pV = Container_p(v0Container); - Aux_p pVaux = Aux_p(v0AuxContainer); - // - Container_p pK = Container_p(ksContainer); - Aux_p pKaux = Aux_p(ksAuxContainer); - // - Container_p pLa = Container_p(laContainer); - Aux_p pLaaux = Aux_p(laAuxContainer); - // - Container_p pLb = Container_p(lbContainer); - Aux_p pLbaux = Aux_p(lbAuxContainer); - // - if (statusOfSearch != StatusCode::SUCCESS){ - ATH_MSG_ERROR("Vertex search of v0Container failed."); - return StatusCode::FAILURE; - } - // //---- Recording section: write the results to StoreGate ---// - SG::WriteHandle<xAOD::VertexContainer> h_V0( m_v0Key ); - if ( h_V0.record(std::move(pV),std::move(pVaux)) !=StatusCode::SUCCESS){ - ATH_MSG_ERROR("Storegate record of v0Container failed."); - return StatusCode::FAILURE; - } + SG::WriteHandle<xAOD::VertexContainer> h_V0( m_v0Key, ctx ); + if ( h_V0.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){ + ATH_MSG_ERROR("Storegate record of v0Container failed."); + return StatusCode::FAILURE; + } - SG::WriteHandle<xAOD::VertexContainer> h_Ks( m_ksKey ); - if ( h_Ks.record(std::move(pK), std::move(pKaux)) != StatusCode::SUCCESS){ - ATH_MSG_ERROR("Storegate record of ksContainer failed."); - return StatusCode::FAILURE; - } + SG::WriteHandle<xAOD::VertexContainer> h_Ks( m_ksKey, ctx ); + if ( h_Ks.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){ + ATH_MSG_ERROR("Storegate record of ksContainer failed."); + return StatusCode::FAILURE; + } - SG::WriteHandle<xAOD::VertexContainer> h_La( m_laKey ); - if( h_La.record(std::move(pLa),std::move(pLaaux)) != StatusCode::SUCCESS){ + SG::WriteHandle<xAOD::VertexContainer> h_La( m_laKey, ctx ); + if( h_La.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){ ATH_MSG_ERROR("Storegate record of laContainer failed."); - return StatusCode::FAILURE; + return StatusCode::FAILURE; } - SG::WriteHandle<xAOD::VertexContainer> h_Lb( m_lbKey ); - if(h_Lb.record(std::move(pLb), std::move(pLbaux)) != StatusCode::SUCCESS){ - ATH_MSG_ERROR("Storegate record of lbContainer failed."); - return StatusCode::FAILURE; - } - - if (m_decorate) { - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorKsMass(m_decorKsMass); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorLaMass(m_decorLaMass); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorLbMass(m_decorLbMass); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorKsMassErr(m_decorKsMassErr); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorLaMassErr(m_decorLaMassErr); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorLbMassErr(m_decorLbMassErr); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPt_v0(m_decorPt_v0); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPtErr_v0(m_decorPtErr_v0); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxy_v0(m_decorRxy_v0); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxyErr_v0(m_decorRxyErr_v0); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPx_v0(m_decorPx_v0); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPy_v0(m_decorPy_v0); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPz_v0(m_decorPz_v0); - - for ( auto unconstrV0 : *h_V0 ) - { - double mass_ks = m_V0Tools->invariantMass(unconstrV0,m_masspi,m_masspi); - double mass_error_ks = m_V0Tools->invariantMassError(unconstrV0,m_masspi,m_masspi); - double mass_la = m_V0Tools->invariantMass(unconstrV0,m_massp,m_masspi); - double mass_error_la = m_V0Tools->invariantMassError(unconstrV0,m_massp,m_masspi); - double mass_lb = m_V0Tools->invariantMass(unconstrV0,m_masspi,m_massp); - double mass_error_lb = m_V0Tools->invariantMassError(unconstrV0,m_masspi,m_massp); - double pt = m_V0Tools->pT(unconstrV0); - double ptError = m_V0Tools->pTError(unconstrV0); - double rxy = m_V0Tools->rxy(unconstrV0); - double rxyError = m_V0Tools->rxyError(unconstrV0); - Amg::Vector3D momentum = m_V0Tools->V0Momentum(unconstrV0); - - decorKsMass( *unconstrV0 ) = mass_ks; - decorLaMass( *unconstrV0 ) = mass_la; - decorLbMass( *unconstrV0 ) = mass_lb; - decorKsMassErr( *unconstrV0 ) = mass_error_ks; - decorLaMassErr( *unconstrV0 ) = mass_error_la; - decorLbMassErr( *unconstrV0 ) = mass_error_lb; - decorPt_v0( *unconstrV0 ) = pt; - decorPtErr_v0( *unconstrV0 ) =ptError; - decorRxy_v0( *unconstrV0 ) = rxy; - decorRxyErr_v0( *unconstrV0 ) =rxyError; - decorPx_v0( *unconstrV0 ) = momentum.x(); - decorPy_v0( *unconstrV0 ) = momentum.y(); - decorPz_v0( *unconstrV0 ) = momentum.z(); - } - - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMass_ks(m_decorMass_ks); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMassErr_ks(m_decorMassErr_ks); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPt_ks(m_decorPt_ks); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPtErr_ks(m_decorPtErr_ks); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxy_ks(m_decorRxy_ks); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxyErr_ks(m_decorRxyErr_ks); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPx_ks(m_decorPx_ks); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPy_ks(m_decorPy_ks); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPz_ks(m_decorPz_ks); - - for ( auto ksV0 : *h_Ks ) - { - double mass_ks = m_V0Tools->invariantMass(ksV0,m_masspi,m_masspi); - double mass_error_ks = m_V0Tools->invariantMassError(ksV0,m_masspi,m_masspi); - double pt = m_V0Tools->pT(ksV0); - double ptError = m_V0Tools->pTError(ksV0); - double rxy = m_V0Tools->rxy(ksV0); - double rxyError = m_V0Tools->rxyError(ksV0); - Amg::Vector3D momentum = m_V0Tools->V0Momentum(ksV0); - - decorMass_ks( *ksV0 ) = mass_ks; - decorMassErr_ks( *ksV0 ) = mass_error_ks; - decorPt_ks( *ksV0 ) = pt; - decorPtErr_ks( *ksV0 ) = ptError; - decorRxy_ks( *ksV0 ) = rxy; - decorRxyErr_ks( *ksV0 ) = rxyError; - decorPx_ks( *ksV0 ) = momentum.x(); - decorPy_ks( *ksV0 ) = momentum.y(); - decorPz_ks( *ksV0 ) = momentum.z(); - } - - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMass_la(m_decorMass_la); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMassErr_la(m_decorMassErr_la); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPt_la(m_decorPt_la); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPtErr_la(m_decorPtErr_la); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxy_la(m_decorRxy_la); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxyErr_la(m_decorRxyErr_la); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPx_la(m_decorPx_la); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPy_la(m_decorPy_la); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPz_la(m_decorPz_la); - - for ( auto laV0 : *h_La ) - { - double mass_la = m_V0Tools->invariantMass(laV0,m_massp,m_masspi); - double mass_error_la = m_V0Tools->invariantMassError(laV0,m_massp,m_masspi); - double pt = m_V0Tools->pT(laV0); - double ptError = m_V0Tools->pTError(laV0); - double rxy = m_V0Tools->rxy(laV0); - double rxyError = m_V0Tools->rxyError(laV0); - Amg::Vector3D momentum = m_V0Tools->V0Momentum(laV0); + SG::WriteHandle<xAOD::VertexContainer> h_Lb( m_lbKey, ctx ); + if(h_Lb.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){ + ATH_MSG_ERROR("Storegate record of lbContainer failed."); + return StatusCode::FAILURE; + } - decorMass_la( *laV0 ) = mass_la; - decorMassErr_la( *laV0 ) = mass_error_la; - decorPt_la( *laV0 ) = pt; - decorPtErr_la( *laV0 ) = ptError; - decorRxy_la( *laV0 ) = rxy; - decorRxyErr_la( *laV0 ) = rxyError; - decorPx_la( *laV0 ) = momentum.x(); - decorPy_la( *laV0 ) = momentum.y(); - decorPz_la( *laV0 ) = momentum.z(); - } - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMass_lb(m_decorMass_lb); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMassErr_lb(m_decorMassErr_lb); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPt_lb(m_decorPt_lb); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPtErr_lb(m_decorPtErr_lb); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxy_lb(m_decorRxy_lb); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxyErr_lb(m_decorRxyErr_lb); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPx_lb(m_decorPx_lb); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPy_lb(m_decorPy_lb); - SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPz_lb(m_decorPz_lb); + const auto statusOfSearch = m_v0FinderTool->performSearch(h_V0.ptr(), + h_Ks.ptr(), + h_La.ptr(), + h_Lb.ptr(), + primaryVertex, importedVxContainer.cptr(), ctx); - for ( auto lbV0 : *h_Lb ) - { - double mass_lb = m_V0Tools->invariantMass(lbV0,m_masspi,m_massp); - double mass_error_lb = m_V0Tools->invariantMassError(lbV0,m_masspi,m_massp); - double pt = m_V0Tools->pT(lbV0); - double ptError = m_V0Tools->pTError(lbV0); - double rxy = m_V0Tools->rxy(lbV0); - double rxyError = m_V0Tools->rxyError(lbV0); - Amg::Vector3D momentum = m_V0Tools->V0Momentum(lbV0); + if (statusOfSearch != StatusCode::SUCCESS){ + ATH_MSG_ERROR("Vertex search of v0Container failed."); + return StatusCode::FAILURE; + } - decorMass_lb( *lbV0 ) = mass_lb; - decorMassErr_lb( *lbV0 ) = mass_error_lb; - decorPt_lb( *lbV0 ) = pt; - decorPtErr_lb( *lbV0 ) = ptError; - decorRxy_lb( *lbV0 ) = rxy; - decorRxyErr_lb( *lbV0 ) = rxyError; - decorPx_lb( *lbV0 ) = momentum.x(); - decorPy_lb( *lbV0 ) = momentum.y(); - decorPz_lb( *lbV0 ) = momentum.z(); - } + if (m_decorate) { + ATH_CHECK(m_v0DecoTool->decorateV0(h_V0.ptr(), ctx)); + ATH_CHECK(m_v0DecoTool->decorateks(h_Ks.ptr() ,ctx)); + ATH_CHECK(m_v0DecoTool->decoratela(h_La.ptr(), ctx)); + ATH_CHECK(m_v0DecoTool->decoratelb(h_Lb.ptr(), ctx)); } m_V0s_stored += h_V0->size(); diff --git a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0Finder.h b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0Finder.h index add05480cb28..e82c90373209 100755 --- a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0Finder.h +++ b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0Finder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /*************************************************************************** @@ -15,12 +15,12 @@ #ifndef INDETV0FINDER_INDETV0FINDER_H #define INDETV0FINDER_INDETV0FINDER_H +#include "InDetV0Finder/V0MainDecorator.h" #include "AthenaBaseComps/AthAlgorithm.h" #include "GaudiKernel/ToolHandle.h" #include "xAODTracking/VertexContainerFwd.h" - /** @class InDetV0Finder Execute method for the main V0 finding module. @@ -31,17 +31,8 @@ /* Forward declarations */ -namespace Trk{ - class V0Tools; -} - -namespace HepPDT{ - class ParticleDataTable; -} - namespace InDet { - class VertexPointEstimator; class InDetV0FinderTool; class InDetV0Finder : public AthAlgorithm @@ -67,112 +58,15 @@ namespace InDet SG::WriteHandleKey<xAOD::VertexContainer> m_lbKey { this, "LambdabarContainerName", "LambdabarCandidates", "Lambdabar container" }; - // Decorator keys will be modified at run-time to conform to the correct container name - // For the run-time update to work, the decoration key name properties must start with a period (".") - // V0 decorators - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorKsMass - { this, "KsMass_v0", ".Kshort_mass", "Ks mass for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorKsMassErr - { this, "KsMassErr_v0", ".Kshort_massError", "Ks mass error for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorLaMass - { this, "LaMass_v0", ".Lambda_mass", "Lambda mass for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorLaMassErr - { this, "LaMassErr_v0", ".Lambda_massError", "Lambda mass error for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorLbMass - { this, "LbMass_v0", ".Lambdabar_mass", "Lambdabar mass for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorLbMassErr - { this, "LbMassErr_v0", ".Lambdabar_massError", "Lambdabar mass error for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPt_v0 - { this, "Pt_v0", ".pT", "Transverse momentum for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPtErr_v0 - { this, "PtErr_v0", ".pTError", "Transverse momentum error for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorRxy_v0 - { this, "Rxy_v0", ".Rxy", "Rxy for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorRxyErr_v0 - { this, "RxyErr_v0", ".RxyError", "Rxy error for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPx_v0 - { this, "Px_v0", ".px", "Px for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPy_v0 - { this, "Py_v0", ".py", "Py for v0" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPz_v0 - { this, "Pz_v0", ".pz", "Pz for v0" }; - - // Ks decorators - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorMass_ks - { this, "Mass_ks", ".mass", "mass for Ks" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorMassErr_ks - { this, "MassErr_ks", ".massError", "mass error for Ks" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPt_ks - { this, "Pt_ks", ".pT", "Transverse momentum for Ks" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPtErr_ks - { this, "PtErr_ks", ".pTError", "Transverse momentum error for Ks" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorRxy_ks - { this, "Rxy_ks", ".Rxy", "Rxy for Ks" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorRxyErr_ks - { this, "RxyErr_ks", ".RxyError", "Rxy error for Ks" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPx_ks - { this, "Px_ks", ".px", "Px for Ks" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPy_ks - { this, "Py_ks", ".py", "Py for Ks" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPz_ks - { this, "Pz_ks", ".pz", "Pz for Ks" }; - - // Lambda decorators - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorMass_la - { this, "Mass_la", ".mass", "mass for Lambda" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorMassErr_la - { this, "MassErr_la", ".massError", "mass error for Lambda" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPt_la - { this, "Pt_la", ".pT", "Transverse momentum for Lambda" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPtErr_la - { this, "PtErr_la", ".pTError", "Transverse momentum error for Lambda" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorRxy_la - { this, "Rxy_la", ".Rxy", "Rxy for la" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorRxyErr_la - { this, "RxyErr_la", ".RxyError", "Rxy error for Lambda" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPx_la - { this, "Px_la", ".px", "Px for Lambda" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPy_la - { this, "Py_la", ".py", "Py for Lambda" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPz_la - { this, "Pz_la", ".pz", "Pz for Lambda" }; - - // Lambdabar decorators - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorMass_lb - { this, "Mass_lb", ".mass", "mass for Lambdabar" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorMassErr_lb - { this, "MassErr_lb", ".massError", "mass error for Lambdabar" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPt_lb - { this, "Pt_lb", ".pT", "Transverse momentum for Lambdabar" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPtErr_lb - { this, "PtErr_lb", ".pTError", "Transverse momentum error for Lambdabar" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorRxy_lb - { this, "Rxy_lb", ".Rxy", "Rxy for Lambdabar" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorRxyErr_lb - { this, "RxyErr_lb", ".RxyError", "Rxy error for Lambdabar" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPx_lb - { this, "Px_lb", ".px", "Px for Lambdabar" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPy_lb - { this, "Py_lb", ".py", "Py for Lambdabar" }; - Gaudi::Property<SG::WriteDecorHandleKey<xAOD::VertexContainer> > m_decorPz_lb - { this, "Pz_lb", ".pz", "Pz for Lambdabar" }; - // Tools ToolHandle<InDet::InDetV0FinderTool> m_v0FinderTool; - ToolHandle < Trk::V0Tools > m_V0Tools; + ToolHandle<InDet::V0MainDecorator> m_v0DecoTool{this, "Decorator", "InDet::V0MainDecorator"}; // Other members - const HepPDT::ParticleDataTable *m_particleDataTable; - bool m_decorate; //!< decorate V0 containers - int m_masses; //!< = 1 if using PDG values, = 2 if user set (1) - double m_masspi; //!< pion mass (139.57 MeV) - double m_massp; //!< proton mass (938.272 MeV) - double m_masse; //!< electron mass (0.510999 MeV) - double m_massK0S; //!< Kshort mass (497.672 MeV) - double m_massLambda; //!< Lambda mass (1115.68 MeV) + long m_events_processed; long m_V0s_stored; @@ -180,11 +74,6 @@ namespace InDet long m_Lambda_stored; long m_Lambdabar_stored; - std::string m_v0ContainerName; - std::string m_ksContainerName; - std::string m_laContainerName; - std::string m_lbContainerName; - }; }//end of namespace InDet diff --git a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0FinderTool.cxx b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0FinderTool.cxx index 8261735ef13f..e95941ca2b39 100755 --- a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0FinderTool.cxx +++ b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/InDetV0FinderTool.cxx @@ -15,9 +15,6 @@ ***************************************************************************/ -#include "GaudiKernel/IToolSvc.h" -#include "GaudiKernel/ISvcLocator.h" - #include "InDetV0Finder/InDetV0FinderTool.h" #include "TrkVertexFitterInterfaces/IVertexFitter.h" #include "TrkV0Fitter/TrkV0VertexFitter.h" @@ -27,13 +24,11 @@ #include "TrkToolInterfaces/ITrackSelectorTool.h" #include "InDetConversionFinderTools/VertexPointEstimator.h" -#include "InDetConversionFinderTools/ConversionFinderUtils.h" #include "ITrackToVertex/ITrackToVertex.h" #include "GaudiKernel/IPartPropSvc.h" -#include "CLHEP/GenericFunctions/CumulativeChiSquare.hh" // for chi2prob calculation #include "xAODTracking/TrackingPrimitives.h" @@ -59,7 +54,6 @@ InDetV0FinderTool::InDetV0FinderTool(const std::string& t, const std::string& n, m_iGammaFitter("Trk::TrkVKalVrtFitter"), m_V0Tools("Trk::V0Tools"), m_trackToVertexTool("Reco::TrackToVertex"), - m_helpertool("InDet::ConversionFinderUtils"), m_trkSelector("InDet::TrackSelectorTool"), m_vertexEstimator("InDet::VertexPointEstimator"), m_extrapolator("Trk::Extrapolator"), @@ -106,7 +100,6 @@ InDetV0FinderTool::InDetV0FinderTool(const std::string& t, const std::string& n, declareProperty("GammaFitterTool", m_iGammaFitter); declareProperty("V0Tools",m_V0Tools); declareProperty("TrackToVertexTool",m_trackToVertexTool); - declareProperty("ConversionFinderHelperTool", m_helpertool); declareProperty("TrackSelectorTool", m_trkSelector); declareProperty("VertexPointEstimator", m_vertexEstimator); declareProperty("Extrapolator", m_extrapolator); @@ -143,7 +136,9 @@ InDetV0FinderTool::InDetV0FinderTool(const std::string& t, const std::string& n, declareProperty("vert_a0xy_cut", m_vert_a0xy_cut ); declareProperty("vert_a0z_cut", m_vert_a0z_cut ); - declareProperty("V0Link", m_v0LinksDecorkey); + declareProperty("V0Linkks", m_v0LinksDecorkeyks); + declareProperty("V0Linklb", m_v0LinksDecorkeylb); + declareProperty("V0Linklbb", m_v0LinksDecorkeylbb); declareProperty("KshortLink", m_v0_ksLinksDecorkey); declareProperty("LambdaLink", m_v0_laLinksDecorkey); declareProperty("LambdabarLink", m_v0_lbLinksDecorkey); @@ -163,30 +158,30 @@ StatusCode InDetV0FinderTool::initialize() // Get the right vertex fitting tool from ToolSvc if (m_useV0Fitter) { ATH_CHECK( m_iVertexFitter.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_iVertexFitter << endmsg; + ATH_MSG_DEBUG( "Retrieved tool " << m_iVertexFitter); ATH_CHECK( m_iGammaFitter.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_iGammaFitter << endmsg; + ATH_MSG_DEBUG("Retrieved tool " << m_iGammaFitter); } else { ATH_CHECK( m_iVKVertexFitter.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_iVKVertexFitter << endmsg; + ATH_MSG_DEBUG("Retrieved tool " << m_iVKVertexFitter); // Get the VKalVrt Ks vertex fitting tool from ToolSvc ATH_CHECK( m_iKshortFitter.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_iKshortFitter << endmsg; + ATH_MSG_DEBUG("Retrieved tool " << m_iKshortFitter); // Get the VKalVrt Lambda vertex fitting tool from ToolSvc ATH_CHECK( m_iLambdaFitter.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_iLambdaFitter << endmsg; + ATH_MSG_DEBUG( "Retrieved tool " << m_iLambdaFitter); // Get the VKalVrt Lambdabar vertex fitting tool from ToolSvc ATH_CHECK( m_iLambdabarFitter.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_iLambdabarFitter << endmsg; + ATH_MSG_DEBUG("Retrieved tool " << m_iLambdabarFitter); // Get the VKalVrt Gamma vertex fitting tool from ToolSvc ATH_CHECK( m_iGammaFitter.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_iGammaFitter << endmsg; + ATH_MSG_DEBUG( "Retrieved tool " << m_iGammaFitter ); } // get the Particle Properties Service @@ -196,50 +191,54 @@ StatusCode InDetV0FinderTool::initialize() // uploading the V0 tools ATH_CHECK( m_V0Tools.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_V0Tools << endmsg; + ATH_MSG_DEBUG("Retrieved tool " << m_V0Tools); // Get the TrackToVertex extrapolator tool ATH_CHECK( m_trackToVertexTool.retrieve() ); // Get the extrapolator ATH_CHECK( m_extrapolator.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_extrapolator << endmsg; + ATH_MSG_DEBUG("Retrieved tool "); // Initialize vertex container key ATH_CHECK( m_vertexKey.initialize() ); - m_v0LinksDecorkey = m_vertexKey.key() + ".V0Link"; - m_v0_ksLinksDecorkey = m_vertexKey.key() + ".KshortLink"; - m_v0_laLinksDecorkey = m_vertexKey.key() + ".LambdaLink"; - m_v0_lbLinksDecorkey = m_vertexKey.key() + ".LambdabarLink"; - ATH_CHECK( m_v0LinksDecorkey.initialize()); + m_v0LinksDecorkeyks = m_ksKey + ".V0Link"; + m_v0LinksDecorkeylb = m_laKey + ".V0Link"; + m_v0LinksDecorkeylbb = m_lbKey + ".V0Link"; + m_v0_ksLinksDecorkey = m_v0Key + ".KshortLink"; + m_v0_laLinksDecorkey = m_v0Key + ".LambdaLink"; + m_v0_lbLinksDecorkey = m_v0Key + ".LambdabarLink"; + ATH_MSG_DEBUG("m_v0_lbLinksDecorkey = " << m_v0_lbLinksDecorkey.key()); + ATH_MSG_DEBUG("m_v0_laLinksDecorkey = " << m_v0_laLinksDecorkey.key()); + ATH_MSG_DEBUG("m_v0_ksLinksDecorkey = " << m_v0_ksLinksDecorkey.key()); + ATH_MSG_DEBUG("m_v0LinksDecorkeyks = " << m_v0LinksDecorkeyks.key()); + ATH_CHECK( m_v0LinksDecorkeyks.initialize()); + ATH_CHECK( m_v0LinksDecorkeylb.initialize()); + ATH_CHECK( m_v0LinksDecorkeylbb.initialize()); ATH_CHECK( m_v0_ksLinksDecorkey.initialize()); ATH_CHECK( m_v0_laLinksDecorkey.initialize()); ATH_CHECK( m_v0_lbLinksDecorkey.initialize()); - m_mDecor_gfit = m_vertexKey.key() + ".gamma_fit"; - m_mDecor_gmass = m_vertexKey.key() + ".gamma_mass"; - m_mDecor_gmasserr = m_vertexKey.key() + ".gamma_massError"; - m_mDecor_gprob = m_vertexKey.key() + ".gamma_probability"; + m_mDecor_gfit = m_v0Key + ".gamma_fit"; + m_mDecor_gmass = m_v0Key + ".gamma_mass"; + m_mDecor_gmasserr = m_v0Key + ".gamma_massError"; + m_mDecor_gprob = m_v0Key + ".gamma_probability"; ATH_CHECK( m_mDecor_gfit.initialize()); ATH_CHECK( m_mDecor_gmass.initialize()); ATH_CHECK( m_mDecor_gmasserr.initialize()); ATH_CHECK( m_mDecor_gprob.initialize()); - ATH_CHECK( m_beamSpotKey.initialize()); - + ATH_CHECK( m_eventInfo_key.initialize()); -// Get the helpertool from ToolSvc - ATH_CHECK( m_helpertool.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_helpertool << endmsg; // Get the track selector tool from ToolSvc ATH_CHECK( m_trkSelector.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_trkSelector << endmsg; + ATH_MSG_DEBUG("Retrieved tool " << m_trkSelector); // Get the vertex point estimator tool from ToolSvc ATH_CHECK( m_vertexEstimator.retrieve() ); - msg(MSG::DEBUG) << "Retrieved tool " << m_vertexEstimator << endmsg; + ATH_MSG_DEBUG("Retrieved tool " << m_vertexEstimator); const HepPDT::ParticleData* pd_pi = m_particleDataTable->particle(PDG::pi_plus); const HepPDT::ParticleData* pd_p = m_particleDataTable->particle(PDG::p_plus); @@ -273,38 +272,27 @@ StatusCode InDetV0FinderTool::initialize() - msg(MSG::DEBUG) << "Initialization successful" << endmsg; + ATH_MSG_DEBUG( "Initialization successful" ); return StatusCode::SUCCESS; } -StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer*& v0Container, xAOD::VertexAuxContainer*& v0AuxContainer, - xAOD::VertexContainer*& ksContainer, xAOD::VertexAuxContainer*& ksAuxContainer, - xAOD::VertexContainer*& laContainer, xAOD::VertexAuxContainer*& laAuxContainer, - xAOD::VertexContainer*& lbContainer, xAOD::VertexAuxContainer*& lbAuxContainer, +StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer* v0Container, + xAOD::VertexContainer* ksContainer, + xAOD::VertexContainer* laContainer, + xAOD::VertexContainer* lbContainer, const xAOD::Vertex* primaryVertex, - const xAOD::VertexContainer* vertColl + const xAOD::VertexContainer* vertColl, + const EventContext& ctx ) const { ATH_MSG_DEBUG( "InDetV0FinderTool::performSearch" ); - v0Container = new xAOD::VertexContainer; - v0AuxContainer = new xAOD::VertexAuxContainer; - v0Container->setStore(v0AuxContainer); - ksContainer = new xAOD::VertexContainer; - ksAuxContainer = new xAOD::VertexAuxContainer; - ksContainer->setStore(ksAuxContainer); - laContainer = new xAOD::VertexContainer; - laAuxContainer = new xAOD::VertexAuxContainer; - laContainer->setStore(laAuxContainer); - lbContainer = new xAOD::VertexContainer; - lbAuxContainer = new xAOD::VertexAuxContainer; - lbContainer->setStore(lbAuxContainer); m_events_processed ++; // Retrieve track particles from StoreGate - SG::ReadHandle<xAOD::TrackParticleContainer> TPC( m_trackParticleKey ); + SG::ReadHandle<xAOD::TrackParticleContainer> TPC( m_trackParticleKey, ctx ); if ( !TPC.isValid() ) { ATH_MSG_ERROR("Input TrackParticle collection is invalid!"); @@ -316,8 +304,8 @@ StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer*& v0Container, ATH_MSG_DEBUG("Vertex container size " << vertColl->size()); } - SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; - Amg::Vector3D beamspot = Amg::Vector3D(beamSpotHandle->beamVtx().position()); + SG::ReadHandle<xAOD::EventInfo> evt { m_eventInfo_key, ctx }; + Amg::Vector3D beamspot = Amg::Vector3D(evt->beamPosX(), evt->beamPosY(), evt->beamPosZ()); // track preselection std::vector<const xAOD::TrackParticle*> posTracks; posTracks.clear(); @@ -351,7 +339,7 @@ StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer*& v0Container, if (!posTracks.empty() && !negTracks.empty()) { - SG::ReadHandle<xAOD::VertexContainer> vertices { m_vertexKey }; + SG::ReadHandle<xAOD::VertexContainer> vertices { m_vertexKey, ctx }; if (!vertices.isValid()) { ATH_MSG_WARNING("Primary vertex container with key " << m_vertexKey.key() << " not found"); @@ -387,14 +375,16 @@ StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer*& v0Container, } } - SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0LinksDecor(m_v0LinksDecorkey); - SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0_ksLinksDecor(m_v0_ksLinksDecorkey); - SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0_laLinksDecor(m_v0_laLinksDecorkey); - SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0_lbLinksDecor(m_v0_lbLinksDecorkey); - SG::WriteDecorHandle<xAOD::VertexContainer, int> mDecor_gfit(m_mDecor_gfit); - SG::WriteDecorHandle<xAOD::VertexContainer, float> mDecor_gmass(m_mDecor_gmass); - SG::WriteDecorHandle<xAOD::VertexContainer, float> mDecor_gmasserr(m_mDecor_gmasserr); - SG::WriteDecorHandle<xAOD::VertexContainer, float> mDecor_gprob(m_mDecor_gprob); + SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0LinksDecorks(m_v0LinksDecorkeyks, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0LinksDecorlb(m_v0LinksDecorkeylb, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0LinksDecorlbb(m_v0LinksDecorkeylbb, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0_ksLinksDecor(m_v0_ksLinksDecorkey, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0_laLinksDecor(m_v0_laLinksDecorkey, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, ElementLink<xAOD::VertexContainer>> v0_lbLinksDecor(m_v0_lbLinksDecorkey, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, int> mDecor_gfit(m_mDecor_gfit, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, float> mDecor_gmass(m_mDecor_gmass, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, float> mDecor_gmasserr(m_mDecor_gmasserr, ctx); + SG::WriteDecorHandle<xAOD::VertexContainer, float> mDecor_gprob(m_mDecor_gprob, ctx); unsigned int i2 = 0; for (tpIt2 = negTracks.begin(); tpIt2 != negTracks.end(); ++tpIt2) { @@ -470,7 +460,7 @@ StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer*& v0Container, { // pair pre-selection cuts - if ( doFit(TP1,TP2,startingPoint) ) + if ( doFit(TP1,TP2,startingPoint, ctx) ) { std::vector<const xAOD::TrackParticle*> pairV0; pairV0.clear(); @@ -589,7 +579,7 @@ StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer*& v0Container, v0Link.setElement(v0Container->back()); v0Link.setStorableObject(*v0Container); - v0LinksDecor(*(ksContainer->back())) = v0Link; + v0LinksDecorks(*(ksContainer->back())) = v0Link; ksLink.setElement(ksContainer->back()); ksLink.setStorableObject(*ksContainer); @@ -612,7 +602,7 @@ StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer*& v0Container, v0Link.setElement(v0Container->back()); v0Link.setStorableObject(*v0Container); - v0LinksDecor(*(laContainer->back())) = v0Link; + v0LinksDecorlb(*(laContainer->back())) = v0Link; laLink.setElement(laContainer->back()); laLink.setStorableObject(*laContainer); @@ -635,7 +625,7 @@ StatusCode InDetV0FinderTool::performSearch(xAOD::VertexContainer*& v0Container, v0Link.setElement(v0Container->back()); v0Link.setStorableObject(*v0Container); - v0LinksDecor(*(lbContainer->back())) = v0Link; + v0LinksDecorlbb(*(lbContainer->back())) = v0Link; lbLink.setElement(lbContainer->back()); lbLink.setStorableObject(*lbContainer); @@ -704,15 +694,15 @@ StatusCode InDetV0FinderTool::finalize() void InDetV0FinderTool::SGError(const std::string& errService) const { - msg(MSG::FATAL) << errService << " not found. Exiting !" << endmsg; + ATH_MSG_FATAL(errService << " not found. Exiting !"); } -bool InDetV0FinderTool::doFit(const xAOD::TrackParticle* track1, const xAOD::TrackParticle* track2, Amg::Vector3D &startingPoint) const +bool InDetV0FinderTool::doFit(const xAOD::TrackParticle* track1, const xAOD::TrackParticle* track2, + Amg::Vector3D &startingPoint, const EventContext& ctx) const { bool pass = false; double srxy = startingPoint.perp(); - const EventContext& ctx = Gaudi::Hive::currentContext(); if (srxy <= m_maxsxy) { double massKshort_i=2000001., massLambda_i=2000001., massLambdabar_i=2000001.; diff --git a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/V0MainDecorator.cxx b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/V0MainDecorator.cxx new file mode 100644 index 000000000000..29c06bda3b53 --- /dev/null +++ b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/V0MainDecorator.cxx @@ -0,0 +1,264 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ +#include "InDetV0Finder/V0MainDecorator.h" +#include "TrkVertexAnalysisUtils/V0Tools.h" +#include "StoreGate/WriteDecorHandle.h" +#include "HepPDT/ParticleDataTable.hh" +#include "EventKernel/PdtPdg.h" +#include "GaudiKernel/IPartPropSvc.h" + + +namespace InDet +{ +V0MainDecorator::V0MainDecorator(const std::string& t, const std::string& n, const IInterface* p) + : + AthAlgTool(t,n,p), m_masses(1), + m_masspi(139.57), + m_massp(938.272), + m_masse(0.510999), + m_massK0S(497.672), + m_massLambda(1115.68) + { + declareProperty("masses", m_masses); + declareProperty("masspi", m_masspi); + declareProperty("massp", m_massp); + declareProperty("masse", m_masse); + declareProperty("massK0S", m_massK0S); + declareProperty("massLambda", m_massLambda); + } + +V0MainDecorator::~V0MainDecorator() = default; + +StatusCode V0MainDecorator::initKey(const std::string &containerKey, + SG::WriteDecorHandleKey<xAOD::VertexContainer> &decokey) const { + decokey = containerKey + decokey.key(); + ATH_MSG_DEBUG(" : " << decokey.key()); + ATH_CHECK(decokey.initialize(!containerKey.empty())); + return StatusCode::SUCCESS; +} + +StatusCode V0MainDecorator::initialize(){ + + ATH_CHECK( m_V0Tools.retrieve() ); + ATH_CHECK(initKey(m_v0Key, m_decorKsMass)); + ATH_CHECK(initKey(m_v0Key, m_decorKsMassErr)); + ATH_CHECK(initKey(m_v0Key, m_decorLaMass)); + ATH_CHECK(initKey(m_v0Key, m_decorLaMassErr)); + ATH_CHECK(initKey(m_v0Key, m_decorLbMass)); + ATH_CHECK(initKey(m_v0Key, m_decorLbMassErr)); + + ATH_CHECK(initKey( m_ksKey, m_decorMass_ks) ); + ATH_CHECK(initKey( m_laKey, m_decorMass_la) ); + ATH_CHECK(initKey( m_lbKey, m_decorMass_lb) ); + ATH_CHECK(initKey( m_ksKey, m_decorMassErr_ks) ); + ATH_CHECK(initKey( m_laKey, m_decorMassErr_la) ); + ATH_CHECK(initKey( m_lbKey, m_decorMassErr_lb) ); + + ATH_CHECK(initKey( m_v0Key, m_decorPt_v0)); + ATH_CHECK(initKey( m_ksKey, m_decorPt_ks)); + ATH_CHECK(initKey( m_laKey, m_decorPt_la)); + ATH_CHECK(initKey( m_lbKey, m_decorPt_lb)); + ATH_CHECK(initKey( m_v0Key, m_decorPtErr_v0 )); + ATH_CHECK(initKey( m_ksKey, m_decorPtErr_ks )); + ATH_CHECK(initKey( m_laKey, m_decorPtErr_la )); + ATH_CHECK(initKey( m_lbKey, m_decorPtErr_lb )); + ATH_CHECK(initKey( m_v0Key, m_decorRxy_v0) ); + ATH_CHECK(initKey( m_ksKey, m_decorRxy_ks) ); + ATH_CHECK(initKey( m_laKey, m_decorRxy_la) ); + ATH_CHECK(initKey( m_lbKey, m_decorRxy_lb) ); + ATH_CHECK(initKey( m_v0Key, m_decorRxyErr_v0 )); + ATH_CHECK(initKey( m_ksKey, m_decorRxyErr_ks )); + ATH_CHECK(initKey( m_laKey, m_decorRxyErr_la )); + ATH_CHECK(initKey( m_lbKey, m_decorRxyErr_lb )); + ATH_CHECK(initKey( m_v0Key, m_decorPx_v0)); + ATH_CHECK(initKey( m_ksKey, m_decorPx_ks)); + ATH_CHECK(initKey( m_laKey, m_decorPx_la)); + ATH_CHECK(initKey( m_lbKey, m_decorPx_lb)); + ATH_CHECK(initKey( m_v0Key, m_decorPy_v0)); + ATH_CHECK(initKey( m_ksKey, m_decorPy_ks)); + ATH_CHECK(initKey( m_laKey, m_decorPy_la)); + ATH_CHECK(initKey( m_lbKey, m_decorPy_lb)); + ATH_CHECK(initKey( m_v0Key, m_decorPz_v0)); + ATH_CHECK(initKey( m_ksKey, m_decorPz_ks)); + ATH_CHECK(initKey( m_laKey, m_decorPz_la)); + ATH_CHECK(initKey( m_lbKey, m_decorPz_lb)); + + + + if (m_masses == 1) { + // get the Particle Properties Service + IPartPropSvc* partPropSvc = nullptr; + ATH_CHECK( service("PartPropSvc", partPropSvc, true) ); + auto particleDataTable = partPropSvc->PDT(); + + const HepPDT::ParticleData* pd_pi = particleDataTable->particle(PDG::pi_plus); + const HepPDT::ParticleData* pd_p = particleDataTable->particle(PDG::p_plus); + const HepPDT::ParticleData* pd_e = particleDataTable->particle(PDG::e_minus); + const HepPDT::ParticleData* pd_K = particleDataTable->particle(PDG::K_S0); + const HepPDT::ParticleData* pd_L = particleDataTable->particle(PDG::Lambda0); + + m_masspi = pd_pi->mass(); + m_massp = pd_p->mass(); + m_masse = pd_e->mass(); + m_massK0S = pd_K->mass(); + m_massLambda = pd_L->mass(); + } + return StatusCode::SUCCESS; +} + +StatusCode V0MainDecorator::decorateV0(xAOD::VertexContainer *container, const EventContext& ctx) const +{ + + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorKsMass(m_decorKsMass, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorLaMass(m_decorLaMass, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorLbMass(m_decorLbMass, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorKsMassErr(m_decorKsMassErr, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorLaMassErr(m_decorLaMassErr, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorLbMassErr(m_decorLbMassErr, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPt_v0(m_decorPt_v0, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPtErr_v0(m_decorPtErr_v0, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxy_v0(m_decorRxy_v0, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxyErr_v0(m_decorRxyErr_v0, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPx_v0(m_decorPx_v0, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPy_v0(m_decorPy_v0, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPz_v0(m_decorPz_v0, ctx ); + + for ( auto unconstrV0 : *container ) + { + double mass_ks = m_V0Tools->invariantMass(unconstrV0,m_masspi,m_masspi); + double mass_error_ks = m_V0Tools->invariantMassError(unconstrV0,m_masspi,m_masspi); + double mass_la = m_V0Tools->invariantMass(unconstrV0,m_massp,m_masspi); + double mass_error_la = m_V0Tools->invariantMassError(unconstrV0,m_massp,m_masspi); + double mass_lb = m_V0Tools->invariantMass(unconstrV0,m_masspi,m_massp); + double mass_error_lb = m_V0Tools->invariantMassError(unconstrV0,m_masspi,m_massp); + double pt = m_V0Tools->pT(unconstrV0); + double ptError = m_V0Tools->pTError(unconstrV0); + double rxy = m_V0Tools->rxy(unconstrV0); + double rxyError = m_V0Tools->rxyError(unconstrV0); + Amg::Vector3D momentum = m_V0Tools->V0Momentum(unconstrV0); + + decorKsMass( *unconstrV0 ) = mass_ks; + decorLaMass( *unconstrV0 ) = mass_la; + decorLbMass( *unconstrV0 ) = mass_lb; + decorKsMassErr( *unconstrV0 ) = mass_error_ks; + decorLaMassErr( *unconstrV0 ) = mass_error_la; + decorLbMassErr( *unconstrV0 ) = mass_error_lb; + decorPt_v0( *unconstrV0 ) = pt; + decorPtErr_v0( *unconstrV0 ) =ptError; + decorRxy_v0( *unconstrV0 ) = rxy; + decorRxyErr_v0( *unconstrV0 ) =rxyError; + decorPx_v0( *unconstrV0 ) = momentum.x(); + decorPy_v0( *unconstrV0 ) = momentum.y(); + decorPz_v0( *unconstrV0 ) = momentum.z(); + } + return StatusCode::SUCCESS; +} + +StatusCode V0MainDecorator::decorateks(xAOD::VertexContainer *container, const EventContext& ctx) const +{ + + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMass_ks(m_decorMass_ks, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMassErr_ks(m_decorMassErr_ks, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPt_ks(m_decorPt_ks, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPtErr_ks(m_decorPtErr_ks, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxy_ks(m_decorRxy_ks, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxyErr_ks(m_decorRxyErr_ks, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPx_ks(m_decorPx_ks, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPy_ks(m_decorPy_ks, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPz_ks(m_decorPz_ks, ctx ); + + for ( auto ksV0 : *container ) + { + double mass_ks = m_V0Tools->invariantMass(ksV0,m_masspi,m_masspi); + double mass_error_ks = m_V0Tools->invariantMassError(ksV0,m_masspi,m_masspi); + double pt = m_V0Tools->pT(ksV0); + double ptError = m_V0Tools->pTError(ksV0); + double rxy = m_V0Tools->rxy(ksV0); + double rxyError = m_V0Tools->rxyError(ksV0); + Amg::Vector3D momentum = m_V0Tools->V0Momentum(ksV0); + + decorMass_ks( *ksV0 ) = mass_ks; + decorMassErr_ks( *ksV0 ) = mass_error_ks; + decorPt_ks( *ksV0 ) = pt; + decorPtErr_ks( *ksV0 ) = ptError; + decorRxy_ks( *ksV0 ) = rxy; + decorRxyErr_ks( *ksV0 ) = rxyError; + decorPx_ks( *ksV0 ) = momentum.x(); + decorPy_ks( *ksV0 ) = momentum.y(); + decorPz_ks( *ksV0 ) = momentum.z(); + } + return StatusCode::SUCCESS; +} + +StatusCode V0MainDecorator::decoratela(xAOD::VertexContainer *container, const EventContext& ctx) const +{ + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMass_la(m_decorMass_la, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMassErr_la(m_decorMassErr_la, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPt_la(m_decorPt_la, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPtErr_la(m_decorPtErr_la, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxy_la(m_decorRxy_la, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxyErr_la(m_decorRxyErr_la, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPx_la(m_decorPx_la, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPy_la(m_decorPy_la, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPz_la(m_decorPz_la, ctx ); + + for ( auto laV0 : *container ) + { + double mass_la = m_V0Tools->invariantMass(laV0,m_massp,m_masspi); + double mass_error_la = m_V0Tools->invariantMassError(laV0,m_massp,m_masspi); + double pt = m_V0Tools->pT(laV0); + double ptError = m_V0Tools->pTError(laV0); + double rxy = m_V0Tools->rxy(laV0); + double rxyError = m_V0Tools->rxyError(laV0); + Amg::Vector3D momentum = m_V0Tools->V0Momentum(laV0); + + decorMass_la( *laV0 ) = mass_la; + decorMassErr_la( *laV0 ) = mass_error_la; + decorPt_la( *laV0 ) = pt; + decorPtErr_la( *laV0 ) = ptError; + decorRxy_la( *laV0 ) = rxy; + decorRxyErr_la( *laV0 ) = rxyError; + decorPx_la( *laV0 ) = momentum.x(); + decorPy_la( *laV0 ) = momentum.y(); + decorPz_la( *laV0 ) = momentum.z(); + } + return StatusCode::SUCCESS; +} + +StatusCode V0MainDecorator::decoratelb(xAOD::VertexContainer *container, const EventContext& ctx) const +{ + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMass_lb(m_decorMass_lb, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorMassErr_lb(m_decorMassErr_lb, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPt_lb(m_decorPt_lb, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPtErr_lb(m_decorPtErr_lb, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxy_lb(m_decorRxy_lb, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorRxyErr_lb(m_decorRxyErr_lb, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPx_lb(m_decorPx_lb, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPy_lb(m_decorPy_lb, ctx ); + SG::WriteDecorHandle<xAOD::VertexContainer, float> decorPz_lb(m_decorPz_lb, ctx ); + + for ( auto lbV0 : *container ) + { + double mass_lb = m_V0Tools->invariantMass(lbV0,m_masspi,m_massp); + double mass_error_lb = m_V0Tools->invariantMassError(lbV0,m_masspi,m_massp); + double pt = m_V0Tools->pT(lbV0); + double ptError = m_V0Tools->pTError(lbV0); + double rxy = m_V0Tools->rxy(lbV0); + double rxyError = m_V0Tools->rxyError(lbV0); + Amg::Vector3D momentum = m_V0Tools->V0Momentum(lbV0); + + decorMass_lb( *lbV0 ) = mass_lb; + decorMassErr_lb( *lbV0 ) = mass_error_lb; + decorPt_lb( *lbV0 ) = pt; + decorPtErr_lb( *lbV0 ) = ptError; + decorRxy_lb( *lbV0 ) = rxy; + decorRxyErr_lb( *lbV0 ) = rxyError; + decorPx_lb( *lbV0 ) = momentum.x(); + decorPy_lb( *lbV0 ) = momentum.y(); + decorPz_lb( *lbV0 ) = momentum.z(); + } + return StatusCode::SUCCESS; +} + +} \ No newline at end of file diff --git a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/components/InDetV0Finder_entries.cxx b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/components/InDetV0Finder_entries.cxx index 6e7b6d949bca..fad2ac786434 100644 --- a/InnerDetector/InDetRecAlgs/InDetV0Finder/src/components/InDetV0Finder_entries.cxx +++ b/InnerDetector/InDetRecAlgs/InDetV0Finder/src/components/InDetV0Finder_entries.cxx @@ -1,11 +1,12 @@ #include "InDetV0Finder/InDetV0FinderTool.h" +#include "InDetV0Finder/V0MainDecorator.h" #include "../InDetV0Finder.h" //#include "InDetV0Finder/InDetSimpleV0Finder.h" using namespace InDet; DECLARE_COMPONENT( InDetV0FinderTool ) - +DECLARE_COMPONENT( V0MainDecorator ) DECLARE_COMPONENT( InDetV0Finder ) //DECLARE_COMPONENT( InDetSimpleV0Finder ) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/DerivationFrameworkBPhys/JpsiPlusV0Cascade.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/DerivationFrameworkBPhys/JpsiPlusV0Cascade.h index 595a39c4f3c4..64e4418591d3 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/DerivationFrameworkBPhys/JpsiPlusV0Cascade.h +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/DerivationFrameworkBPhys/JpsiPlusV0Cascade.h @@ -71,7 +71,7 @@ namespace DerivationFramework { ToolHandle < DerivationFramework::CascadeTools > m_CascadeTools; bool m_refitPV; - SG::WriteHandleKey<xAOD::VertexContainer> m_refPVContainerName; + Gaudi::Property<std::string> m_refPVContainerName; std::string m_hypoName; //!< name of the mass hypothesis. E.g. Jpis, Upsi, etc. Will be used as a prefix for decorations //This parameter will allow us to optimize the number of PVs under consideration as the probability //of a useful primary vertex drops significantly the higher you go diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/DerivationFrameworkBPhys/Reco_V0Finder.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/DerivationFrameworkBPhys/Reco_V0Finder.h index ceb666c23931..d7c769b4eb21 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/DerivationFrameworkBPhys/Reco_V0Finder.h +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/DerivationFrameworkBPhys/Reco_V0Finder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// // Reco_V0Finder.h, (c) ATLAS Detector software @@ -14,15 +14,8 @@ #include "GaudiKernel/ToolHandle.h" #include "DerivationFrameworkInterfaces/IAugmentationTool.h" #include "InDetV0Finder/InDetV0FinderTool.h" -#include "HepPDT/ParticleDataTable.hh" - -/** forward declarations - */ -namespace Trk -{ - class V0Tools; - class ParticleDataTable; -} +#include "InDetV0Finder/V0MainDecorator.h" + namespace DerivationFramework { @@ -31,7 +24,6 @@ namespace DerivationFramework { Reco_V0Finder(const std::string& t, const std::string& n, const IInterface* p); StatusCode initialize() override; - StatusCode finalize() override; virtual StatusCode addBranches() const override; @@ -39,23 +31,18 @@ namespace DerivationFramework { std::vector<std::string> m_CollectionsToCheck; ToolHandle <InDet::InDetV0FinderTool> m_v0FinderTool; - ToolHandle <Trk::V0Tools> m_V0Tools; - const HepPDT::ParticleDataTable *m_particleDataTable; - - int m_masses; //!< = 1 if using PDG values, = 2 if user set (1) - double m_masspi; //!< pion mass (139.57 MeV) - double m_massp; //!< proton mass (938.272 MeV) - double m_masse; //!< electron mass (0.510999 MeV) - double m_massK0S; //!< Kshort mass (497.672 MeV) - double m_massLambda; //!< Lambda mass (1115.68 MeV) - std::string m_VxPrimaryCandidateName; //!< Name of primary vertex container + SG::ReadHandleKey<xAOD::VertexContainer> m_vertexKey { this, "VxPrimaryCandidateName", "PrimaryVertices", + "key for retrieving vertices" }; - std::string m_v0ContainerName; - std::string m_ksContainerName; - std::string m_laContainerName; - std::string m_lbContainerName; + SG::WriteHandleKey<xAOD::VertexContainer> m_v0Key { this, "V0ContainerName", "V0Candidates", "V0 container" }; + SG::WriteHandleKey<xAOD::VertexContainer> m_ksKey { this, "KshortContainerName", "KshortCandidates", "Ks container" }; + SG::WriteHandleKey<xAOD::VertexContainer> m_laKey { this, "LambdaContainerName", "LambdaCandidates", + "Lambda container" }; + SG::WriteHandleKey<xAOD::VertexContainer> m_lbKey { this, "LambdabarContainerName", "LambdabarCandidates", + "Lambdabar container" }; + ToolHandle<InDet::V0MainDecorator> m_v0DecoTool{this, "Decorator", "InDet::V0MainDecorator"}; }; } diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/share/BPHY10.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/share/BPHY10.py index fb51c2ddae9b..e3315b7051ab 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/share/BPHY10.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/share/BPHY10.py @@ -154,9 +154,34 @@ BPHY10BdJpsiKst = Analysis__JpsiPlus2Tracks( ToolSvc += BPHY10BdJpsiKst print(BPHY10BdJpsiKst) +## 7/ call the V0Finder if a Jpsi has been found +doSimpleV0Finder = False +if doSimpleV0Finder: + include("DerivationFrameworkBPhys/configureSimpleV0Finder.py") +else: + include("DerivationFrameworkBPhys/configureV0Finder.py") + + +BPHY10_V0FinderTools = BPHYV0FinderTools("BPHY10") +print(BPHY10_V0FinderTools) + +BPHY10_V0FinderTools.V0FinderTool.V0ContainerName = "BPHY10RecoV0Candidates" +BPHY10_V0FinderTools.V0FinderTool.KshortContainerName = "BPHY10RecoKshortCandidates" +BPHY10_V0FinderTools.V0FinderTool.LambdaContainerName = "BPHY10RecoLambdaCandidates" +BPHY10_V0FinderTools.V0FinderTool.LambdabarContainerName = "BPHY10RecoLambdabarCandidates" + +from InDetV0Finder.InDetV0FinderConf import InDet__V0MainDecorator +V0Decorator = InDet__V0MainDecorator(name = "BPHY10V0Decorator", + V0Tools = TrackingCommon.getV0Tools(), + V0ContainerName = "BPHY10RecoV0Candidates", + KshortContainerName = "BPHY10RecoKshortCandidates", + LambdaContainerName = "BPHY10RecoLambdaCandidates", + LambdabarContainerName = "BPHY10RecoLambdabarCandidates") +ToolSvc += V0Decorator ## 6/ setup the combined augmentation/skimming tool for the BdKst -from DerivationFrameworkBPhys.DerivationFrameworkBPhysConf import DerivationFramework__Reco_Vertex +from DerivationFrameworkBPhys.DerivationFrameworkBPhysConf import DerivationFramework__Reco_Vertex + BPHY10BdKstSelectAndWrite = DerivationFramework__Reco_Vertex( name = "BPHY10BdKstSelectAndWrite", VertexSearchTool = BPHY10BdJpsiKst, @@ -212,14 +237,11 @@ if doSimpleV0Finder: else: include("DerivationFrameworkBPhys/configureV0Finder.py") -BPHY10_V0FinderTools = BPHYV0FinderTools("BPHY10") -print(BPHY10_V0FinderTools) - from DerivationFrameworkBPhys.DerivationFrameworkBPhysConf import DerivationFramework__Reco_V0Finder BPHY10_Reco_V0Finder = DerivationFramework__Reco_V0Finder( name = "BPHY10_Reco_V0Finder", V0FinderTool = BPHY10_V0FinderTools.V0FinderTool, - V0Tools = TrackingCommon.getV0Tools(), + Decorator = V0Decorator, #OutputLevel = DEBUG, V0ContainerName = "BPHY10RecoV0Candidates", KshortContainerName = "BPHY10RecoKshortCandidates", diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/src/JpsiPlusV0Cascade.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/src/JpsiPlusV0Cascade.cxx index cce3b8e14bbf..21598216bcf4 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/src/JpsiPlusV0Cascade.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/src/JpsiPlusV0Cascade.cxx @@ -53,7 +53,6 @@ namespace DerivationFramework { } ATH_CHECK(m_eventInfo_key.initialize()); - ATH_CHECK(m_refPVContainerName.initialize(m_refitPV)); IPartPropSvc* partPropSvc = 0; StatusCode sc = service("PartPropSvc", partPropSvc, true); if (sc.isFailure()) { @@ -117,8 +116,8 @@ namespace DerivationFramework { refPvContainer = new xAOD::VertexContainer; refPvAuxContainer = new xAOD::VertexAuxContainer; refPvContainer->setStore(refPvAuxContainer); - SG::WriteHandle<xAOD::VertexContainer> refPV(m_refPVContainerName); - ATH_CHECK(refPV.record(std::unique_ptr<xAOD::VertexContainer>(refPvContainer))); + CHECK(evtStore()->record(refPvContainer , m_refPVContainerName )); + CHECK(evtStore()->record(refPvAuxContainer, m_refPVContainerName + "Aux.")); } ATH_CHECK(performSearch(&cascadeinfoContainer)); diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/src/Reco_V0Finder.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/src/Reco_V0Finder.cxx index 0b19d017b136..20b1b10b2ea2 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/src/Reco_V0Finder.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/src/Reco_V0Finder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ ///////////////////////////////////////////////////////////////// // Reco_V0Finder.cxx, (c) ATLAS Detector software @@ -8,9 +8,6 @@ #include "DerivationFrameworkBPhys/Reco_V0Finder.h" #include "xAODTracking/VertexContainer.h" #include "xAODTracking/VertexAuxContainer.h" -#include "TrkVertexAnalysisUtils/V0Tools.h" -#include "GaudiKernel/IPartPropSvc.h" -#include "EventKernel/PdtPdg.h" namespace DerivationFramework { @@ -18,38 +15,13 @@ namespace DerivationFramework { const std::string& n, const IInterface* p) : AthAlgTool(t,n,p), - m_v0FinderTool("InDet::V0FinderTool"), - m_V0Tools("Trk::V0Tools"), - m_particleDataTable(nullptr), - m_masses(1), - m_masspi(139.57), - m_massp(938.272), - m_masse(0.510999), - m_massK0S(497.672), - m_massLambda(1115.68), - m_VxPrimaryCandidateName("PrimaryVertices"), - m_v0ContainerName("RecoV0Candidates"), - m_ksContainerName("RecoKshortCandidates"), - m_laContainerName("RecoLambdaCandidates"), - m_lbContainerName("RecoLambdabarCandidates") + m_v0FinderTool("InDet::V0FinderTool", this) { declareInterface<DerivationFramework::IAugmentationTool>(this); // Declare user-defined properties declareProperty("CheckVertexContainers", m_CollectionsToCheck); declareProperty("V0FinderTool", m_v0FinderTool); - declareProperty("V0Tools", m_V0Tools); - declareProperty("masses", m_masses); - declareProperty("masspi", m_masspi); - declareProperty("massp", m_massp); - declareProperty("masse", m_masse); - declareProperty("massK0S", m_massK0S); - declareProperty("massLambda", m_massLambda); - declareProperty("VxPrimaryCandidateName", m_VxPrimaryCandidateName); - declareProperty("V0ContainerName", m_v0ContainerName); - declareProperty("KshortContainerName", m_ksContainerName); - declareProperty("LambdaContainerName", m_laContainerName); - declareProperty("LambdabarContainerName", m_lbContainerName); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -58,52 +30,25 @@ namespace DerivationFramework { { ATH_MSG_DEBUG("in initialize()"); - // get the V0Finder tool ATH_CHECK( m_v0FinderTool.retrieve()); - // uploading the V0 tools - ATH_CHECK( m_V0Tools.retrieve()); - - // get the Particle Properties Service - IPartPropSvc* partPropSvc = nullptr; - StatusCode sc = service("PartPropSvc", partPropSvc, true); - if (sc.isFailure()) { - msg(MSG::ERROR) << "Could not initialize Particle Properties Service" << endmsg; - return StatusCode::FAILURE; - } - m_particleDataTable = partPropSvc->PDT(); - - const HepPDT::ParticleData* pd_pi = m_particleDataTable->particle(PDG::pi_plus); - const HepPDT::ParticleData* pd_p = m_particleDataTable->particle(PDG::p_plus); - const HepPDT::ParticleData* pd_e = m_particleDataTable->particle(PDG::e_minus); - const HepPDT::ParticleData* pd_K = m_particleDataTable->particle(PDG::K_S0); - const HepPDT::ParticleData* pd_L = m_particleDataTable->particle(PDG::Lambda0); - if (m_masses == 1) { - m_masspi = pd_pi->mass(); - m_massp = pd_p->mass(); - m_masse = pd_e->mass(); - m_massK0S = pd_K->mass(); - m_massLambda = pd_L->mass(); - } - + ATH_CHECK(m_vertexKey.initialize()); + ATH_CHECK(m_v0Key.initialize()); + ATH_CHECK(m_ksKey.initialize()); + ATH_CHECK(m_laKey.initialize()); + ATH_CHECK(m_lbKey.initialize()); return StatusCode::SUCCESS; } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - - StatusCode Reco_V0Finder::finalize() - { - // everything all right - return StatusCode::SUCCESS; - } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * StatusCode Reco_V0Finder::addBranches() const { + bool callV0Finder = false; // Jpsi container and its auxilliary store for(const auto &str : m_CollectionsToCheck){ @@ -118,187 +63,67 @@ namespace DerivationFramework { } } - // Call V0Finder - - -// InDetV0 container and its auxilliary store - xAOD::VertexContainer* v0Container(nullptr); - xAOD::VertexAuxContainer* v0AuxContainer(nullptr); - xAOD::VertexContainer* ksContainer(nullptr); - xAOD::VertexAuxContainer* ksAuxContainer(nullptr); - xAOD::VertexContainer* laContainer(nullptr); - xAOD::VertexAuxContainer* laAuxContainer(nullptr); - xAOD::VertexContainer* lbContainer(nullptr); - xAOD::VertexAuxContainer* lbAuxContainer(nullptr); - - if (callV0Finder) { - - // Get primary vertex from StoreGate - const xAOD::Vertex * primaryVertex(0); - const xAOD::VertexContainer * importedVxContainer(0); - ATH_CHECK( evtStore()->retrieve(importedVxContainer, m_VxPrimaryCandidateName) ); - ATH_MSG_DEBUG("Found " << m_VxPrimaryCandidateName << " in StoreGate!"); - if (importedVxContainer->size()==0){ - ATH_MSG_WARNING("You have no primary vertices: " << importedVxContainer->size()); - } else { - primaryVertex = (*importedVxContainer)[0]; - } - - ATH_CHECK(m_v0FinderTool->performSearch(v0Container, v0AuxContainer, ksContainer, ksAuxContainer, laContainer, laAuxContainer, lbContainer, lbAuxContainer, primaryVertex, importedVxContainer)); - - ATH_MSG_DEBUG("Reco_V0Finder v0Container->size() " << v0Container->size()); - ATH_MSG_DEBUG("Reco_V0Finder ksContainer->size() " << ksContainer->size()); - ATH_MSG_DEBUG("Reco_V0Finder laContainer->size() " << laContainer->size()); - ATH_MSG_DEBUG("Reco_V0Finder lbContainer->size() " << lbContainer->size()); - - SG::AuxElement::Decorator<float> mDecor_Ksmass("Kshort_mass"); - SG::AuxElement::Decorator<float> mDecor_Ksmasse("Kshort_massError"); - SG::AuxElement::Decorator<float> mDecor_Lamass("Lambda_mass"); - SG::AuxElement::Decorator<float> mDecor_Lamasse("Lambda_massError"); - SG::AuxElement::Decorator<float> mDecor_Lbmass("Lambdabar_mass"); - SG::AuxElement::Decorator<float> mDecor_Lbmasse("Lambdabar_massError"); - SG::AuxElement::Decorator<float> mDecor_mass("mass"); - SG::AuxElement::Decorator<float> mDecor_massError("massError"); - SG::AuxElement::Decorator<float> mDecor_pt("pT"); - SG::AuxElement::Decorator<float> mDecor_ptError("pTError"); - SG::AuxElement::Decorator<float> mDecor_rxy("Rxy"); - SG::AuxElement::Decorator<float> mDecor_rxyError("RxyError"); - SG::AuxElement::Decorator<float> mDecor_px("px"); - SG::AuxElement::Decorator<float> mDecor_py("py"); - SG::AuxElement::Decorator<float> mDecor_pz("pz"); - - xAOD::VertexContainer::const_iterator v0Itr = v0Container->begin(); - for ( v0Itr=v0Container->begin(); v0Itr!=v0Container->end(); ++v0Itr ) - { - const xAOD::Vertex * unconstrV0 = (*v0Itr); - double mass_ks = m_V0Tools->invariantMass(unconstrV0,m_masspi,m_masspi); - double mass_error_ks = m_V0Tools->invariantMassError(unconstrV0,m_masspi,m_masspi); - double mass_la = m_V0Tools->invariantMass(unconstrV0,m_massp,m_masspi); - double mass_error_la = m_V0Tools->invariantMassError(unconstrV0,m_massp,m_masspi); - double mass_lb = m_V0Tools->invariantMass(unconstrV0,m_masspi,m_massp); - double mass_error_lb = m_V0Tools->invariantMassError(unconstrV0,m_masspi,m_massp); - double pt = m_V0Tools->pT(unconstrV0); - double ptError = m_V0Tools->pTError(unconstrV0); - double rxy = m_V0Tools->rxy(unconstrV0); - double rxyError = m_V0Tools->rxyError(unconstrV0); - Amg::Vector3D momentum = m_V0Tools->V0Momentum(unconstrV0); - mDecor_Ksmass( *unconstrV0 ) = mass_ks; - mDecor_Ksmasse( *unconstrV0 ) = mass_error_ks; - mDecor_Lamass( *unconstrV0 ) = mass_la; - mDecor_Lamasse( *unconstrV0 ) = mass_error_la; - mDecor_Lbmass( *unconstrV0 ) = mass_lb; - mDecor_Lbmasse( *unconstrV0 ) = mass_error_lb; - mDecor_pt( *unconstrV0 ) = pt; - mDecor_ptError( *unconstrV0 ) = ptError; - mDecor_rxy( *unconstrV0 ) = rxy; - mDecor_rxyError( *unconstrV0 ) = rxyError; - mDecor_px( *unconstrV0 ) = momentum.x(); - mDecor_py( *unconstrV0 ) = momentum.y(); - mDecor_pz( *unconstrV0 ) = momentum.z(); - ATH_MSG_DEBUG("Reco_V0Finder mass_ks " << mass_ks << " mass_la " << mass_la << " mass_lb " << mass_lb); - } - xAOD::VertexContainer::const_iterator ksItr = ksContainer->begin(); - for ( ksItr=ksContainer->begin(); ksItr!=ksContainer->end(); ++ksItr ) - { - const xAOD::Vertex * ksV0 = (*ksItr); - double mass_ks = m_V0Tools->invariantMass(ksV0,m_masspi,m_masspi); - double mass_error_ks = m_V0Tools->invariantMassError(ksV0,m_masspi,m_masspi); - double pt = m_V0Tools->pT(ksV0); - double ptError = m_V0Tools->pTError(ksV0); - double rxy = m_V0Tools->rxy(ksV0); - double rxyError = m_V0Tools->rxyError(ksV0); - Amg::Vector3D momentum = m_V0Tools->V0Momentum(ksV0); - mDecor_mass( *ksV0 ) = mass_ks; - mDecor_massError( *ksV0 ) = mass_error_ks; - mDecor_pt( *ksV0 ) = pt; - mDecor_ptError( *ksV0 ) = ptError; - mDecor_rxy( *ksV0 ) = rxy; - mDecor_rxyError( *ksV0 ) = rxyError; - mDecor_px( *ksV0 ) = momentum.x(); - mDecor_py( *ksV0 ) = momentum.y(); - mDecor_pz( *ksV0 ) = momentum.z(); - ATH_MSG_DEBUG("Reco_V0Finder mass_ks " << mass_ks << " mass_error_ks " << mass_error_ks << " pt " << pt << " rxy " << rxy); + const EventContext& ctx = Gaudi::Hive::currentContext(); + // InDetV0 container and its auxilliary store + //---- Recording section: write the results to StoreGate ---// + SG::WriteHandle<xAOD::VertexContainer> h_V0( m_v0Key, ctx ); + if ( h_V0.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){ + ATH_MSG_ERROR("Storegate record of v0Container failed."); + return StatusCode::FAILURE; } - xAOD::VertexContainer::const_iterator laItr = laContainer->begin(); - for ( laItr=laContainer->begin(); laItr!=laContainer->end(); ++laItr ) - { - const xAOD::Vertex * laV0 = (*laItr); - double mass_la = m_V0Tools->invariantMass(laV0,m_massp,m_masspi); - double mass_error_la = m_V0Tools->invariantMassError(laV0,m_massp,m_masspi); - double pt = m_V0Tools->pT(laV0); - double ptError = m_V0Tools->pTError(laV0); - double rxy = m_V0Tools->rxy(laV0); - double rxyError = m_V0Tools->rxyError(laV0); - Amg::Vector3D momentum = m_V0Tools->V0Momentum(laV0); - mDecor_mass( *laV0 ) = mass_la; - mDecor_massError( *laV0 ) = mass_error_la; - mDecor_pt( *laV0 ) = pt; - mDecor_ptError( *laV0 ) = ptError; - mDecor_rxy( *laV0 ) = rxy; - mDecor_rxyError( *laV0 ) = rxyError; - mDecor_px( *laV0 ) = momentum.x(); - mDecor_py( *laV0 ) = momentum.y(); - mDecor_pz( *laV0 ) = momentum.z(); - ATH_MSG_DEBUG("Reco_V0Finder mass_la " << mass_la << " mass_error_la " << mass_error_la << " pt " << pt << " rxy " << rxy); + + SG::WriteHandle<xAOD::VertexContainer> h_Ks( m_ksKey, ctx ); + if ( h_Ks.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){ + ATH_MSG_ERROR("Storegate record of ksContainer failed."); + return StatusCode::FAILURE; } - xAOD::VertexContainer::const_iterator lbItr = lbContainer->begin(); - for ( lbItr=lbContainer->begin(); lbItr!=lbContainer->end(); ++lbItr ) - { - const xAOD::Vertex * lbV0 = (*lbItr); - double mass_lb = m_V0Tools->invariantMass(lbV0,m_masspi,m_massp); - double mass_error_lb = m_V0Tools->invariantMassError(lbV0,m_masspi,m_massp); - double pt = m_V0Tools->pT(lbV0); - double ptError = m_V0Tools->pTError(lbV0); - double rxy = m_V0Tools->rxy(lbV0); - double rxyError = m_V0Tools->rxyError(lbV0); - Amg::Vector3D momentum = m_V0Tools->V0Momentum(lbV0); - mDecor_mass( *lbV0 ) = mass_lb; - mDecor_massError( *lbV0 ) = mass_error_lb; - mDecor_pt( *lbV0 ) = pt; - mDecor_ptError( *lbV0 ) = ptError; - mDecor_rxy( *lbV0 ) = rxy; - mDecor_rxyError( *lbV0 ) = rxyError; - mDecor_px( *lbV0 ) = momentum.x(); - mDecor_py( *lbV0 ) = momentum.y(); - mDecor_pz( *lbV0 ) = momentum.z(); - ATH_MSG_DEBUG("Reco_V0Finder mass_lb " << mass_lb << " mass_error_lb " << mass_error_lb << " pt " << pt << " rxy " << rxy); + + SG::WriteHandle<xAOD::VertexContainer> h_La( m_laKey, ctx ); + if( h_La.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){ + ATH_MSG_ERROR("Storegate record of laContainer failed."); + return StatusCode::FAILURE; + } + SG::WriteHandle<xAOD::VertexContainer> h_Lb( m_lbKey, ctx ); + if(h_Lb.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){ + ATH_MSG_ERROR("Storegate record of lbContainer failed."); + return StatusCode::FAILURE; } - - if(!callV0Finder){ //Fill with empty containers - v0Container = new xAOD::VertexContainer; - v0AuxContainer = new xAOD::VertexAuxContainer; - v0Container->setStore(v0AuxContainer); - ksContainer = new xAOD::VertexContainer; - ksAuxContainer = new xAOD::VertexAuxContainer; - ksContainer->setStore(ksAuxContainer); - laContainer = new xAOD::VertexContainer; - laAuxContainer = new xAOD::VertexAuxContainer; - laContainer->setStore(laAuxContainer); - lbContainer = new xAOD::VertexContainer; - lbAuxContainer = new xAOD::VertexAuxContainer; - lbContainer->setStore(lbAuxContainer); + xAOD::VertexContainer* v0Container(h_V0.ptr()); + xAOD::VertexContainer* ksContainer(h_Ks.ptr()); + xAOD::VertexContainer* laContainer(h_La.ptr()); + xAOD::VertexContainer* lbContainer(h_Lb.ptr()); + // Call V0Finder + if (callV0Finder) { + const xAOD::Vertex * primaryVertex(0); + SG::ReadHandle<xAOD::VertexContainer> importedVxContainer( m_vertexKey, ctx ); + ATH_CHECK(importedVxContainer.isValid()); + + if (importedVxContainer->size()==0){ + ATH_MSG_WARNING("You have no primary vertices: " << importedVxContainer->size()); + } else { + primaryVertex = (*importedVxContainer)[0]; + } + ATH_CHECK( m_v0FinderTool->performSearch(h_V0.ptr(), + h_Ks.ptr(), + h_La.ptr(), + h_Lb.ptr(), + primaryVertex, importedVxContainer.cptr(), ctx)); + + ATH_MSG_DEBUG("Reco_V0Finder v0Container->size() " << v0Container->size()); + ATH_MSG_DEBUG("Reco_V0Finder ksContainer->size() " << ksContainer->size()); + ATH_MSG_DEBUG("Reco_V0Finder laContainer->size() " << laContainer->size()); + ATH_MSG_DEBUG("Reco_V0Finder lbContainer->size() " << lbContainer->size()); + + + ATH_CHECK(m_v0DecoTool->decorateV0(h_V0.ptr(), ctx)); + ATH_CHECK(m_v0DecoTool->decorateks(h_Ks.ptr() ,ctx)); + ATH_CHECK(m_v0DecoTool->decoratela(h_La.ptr(), ctx)); + ATH_CHECK(m_v0DecoTool->decoratelb(h_Lb.ptr(), ctx)); } - //---- Recording section: write the results to StoreGate ---// - CHECK(evtStore()->record(v0Container, m_v0ContainerName)); - - CHECK(evtStore()->record(v0AuxContainer, m_v0ContainerName+"Aux.")); - - CHECK(evtStore()->record(ksContainer, m_ksContainerName)); - - CHECK(evtStore()->record(ksAuxContainer, m_ksContainerName+"Aux.")); - - CHECK(evtStore()->record(laContainer, m_laContainerName)); - - CHECK(evtStore()->record(laAuxContainer, m_laContainerName+"Aux.")); - - CHECK(evtStore()->record(lbContainer, m_lbContainerName)); - - CHECK(evtStore()->record(lbAuxContainer, m_lbContainerName+"Aux.")); - - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } } -- GitLab