48 return StatusCode::FAILURE;
70 return StatusCode::SUCCESS;
86 return StatusCode::SUCCESS;
103 ATH_MSG_FATAL(
"execute - failed to find the InDetTrackParticles");
104 return StatusCode::FAILURE;
113 std::unique_ptr<xAOD::VertexContainer> refitVtxContainer = std::make_unique< xAOD::VertexContainer>();
114 std::unique_ptr<xAOD::VertexAuxContainer> refitVtxContainerAux = std::make_unique< xAOD::VertexAuxContainer>();
116 refitVtxContainer->setStore(refitVtxContainerAux.get());
120 std::move(refitVtxContainer), std::move(refitVtxContainerAux)
128 if (!h_leptonContainer.
isValid()){
129 ATH_MSG_FATAL(
"execute - failed to find the lepton container");
130 return StatusCode::FAILURE;
136 return StatusCode::FAILURE;
145 if(vertex->vertexType() == 1) {
151 if(!fittingInput.
priVtx) {
152 ATH_MSG_INFO(
"Failed to find primary vertices - save empty containers");
153 return StatusCode::SUCCESS;
159 std::vector<const xAOD::TrackParticle *> priVtx_tracks;
166 priVtx_tracks.push_back(track);
172 ctx, fittingInput, priVtx_tracks,
177 if(!refittedPriVtx) {
178 ATH_MSG_WARNING(
"Failed to refit primary vertex - save empty containers");
179 return StatusCode::SUCCESS;
194 <<
"\n\t\t\t Size of lepton container: " << leptonContainer.
size()
195 <<
"\n-----------------------------------------------------------------");
218 tracklep = muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
222 ATH_MSG_WARNING(
"PrimaryVertexReFitter::execute - cannot find muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) nor electron->trackParticle()");
232 h_refitVtxContainer->push_back(std::move(refittedPriVtx));
239 return StatusCode::SUCCESS;
244 const EventContext& ctx,
247 const std::vector<const xAOD::TrackParticle*> &tracks,
256 ATH_MSG_WARNING(
"decorateLepWithReFitPrimaryVertex - invalid input primary vertex pointer");
264 std::vector<const xAOD::TrackParticle*> priVtx_tracks_pass;
265 bool isRefit =
false;
268 if(track == tracklep) {
270 ATH_MSG_DEBUG(
"decorateLepWithReFitPrimaryVertex -- lepton has been used, lepton pT =" << tracklep->
pt() <<
", track pT =" << track->pt());
274 priVtx_tracks_pass.push_back(track);
278 ATH_MSG_DEBUG(
"decorateLepWithReFitPrimaryVertex -- Skip the primary vertex without lepton track");
283 if(priVtx_tracks_pass.size() < 2) {
284 ATH_MSG_DEBUG(
"decorateLepWithReFitPrimaryVertex -- Skip the primary vertex refitting: N tracks =" << priVtx_tracks_pass.size());
289 std::unique_ptr<xAOD::Vertex> refittedVtxRMLep =
m_vertexFitterTool->fitVertexWithSeed(
290 ctx, input, priVtx_tracks_pass, input.priVtx->position(),
293 if(refittedVtxRMLep) {
294 ATH_MSG_DEBUG(
"decorateLepWithReFitPrimaryVertex -- save refitted non-prompt primary vertex with NTrack = " << refittedVtxRMLep->nTrackParticles());
296 if(input.refittedPriVtx) {
297 (*m_distToRefittedPriVtx) (*refittedVtxRMLep) =
Prompt::getDistance(input.refittedPriVtx->position(), refittedVtxRMLep->position());
299 input.refittedPriVtx->position(),
300 refittedVtxRMLep->position(),
301 refittedVtxRMLep->covariance(),
308 refitVtxContainer.
push_back(std::move(refittedVtxRMLep));
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Handle class for adding a decoration to an object.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Object reference supporting deferred reading from StoreGate.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
ElementLink implementation for ROOT usage.
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_lepRefittedVtxWithoutLeptonLinkName
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVertexContainerKey
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
SG::ReadHandleKey< xAOD::IParticleContainer > m_leptonContainerKey
std::optional< accessorFloat_t > m_normdistToRefittedPriVtx
SG::WriteHandleKey< xAOD::VertexContainer > m_reFitPrimaryVertexKey
std::optional< accessorFloat_t > m_distToRefittedPriVtx
virtual StatusCode finalize() override
PrimaryVertexReFitter(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::string > m_distToRefittedPriVtxName
Gaudi::Property< bool > m_printTime
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_normDistToRefittedPriVtxName
bool decorateLepWithReFitPrimaryVertex(const EventContext &ctx, const FittingInput &input, const xAOD::TrackParticle *tracklep, const std::vector< const xAOD::TrackParticle * > &tracks, xAOD::VertexContainer &refitVtxContainer)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inDetTracksKey
ToolHandle< Prompt::VertexFittingTool > m_vertexFitterTool
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
Class providing the definition of the 4-vector interface.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
const Amg::Vector3D & position() const
Returns the 3-pos.
std::string PrintResetStopWatch(TStopwatch &watch)
@ kRefittedPriVtxWithoutLep
double getNormDist(const Amg::Vector3D &PrimVtx, const Amg::Vector3D &SecVtx, const std::vector< float > &ErrorMatrix, MsgStream &msg)
double getDistance(const xAOD::Vertex *vtx1, const xAOD::Vertex *vtx2)
const xAOD::TrackParticle * getOriginalTrackParticleFromGSF(const xAOD::TrackParticle *trkPar)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle...
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Muon_v1 Muon
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.