Commit fb331214 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'hepmclink' into 'master'

Simplify dummy HepMcEventLinks

See merge request atlas/athena!41011
parents 95ab9250 e91a631d
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
* Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file GeneratorObjects/CachedParticlePtr.h
......@@ -106,6 +106,12 @@ public:
void set (const IProxyDict* sg, const HepMC::GenParticle* part) const;
/**
* @brief Check if the cached pointer is valid
*/
bool isValid () const;
private:
/**
* @brief Convert a store pointer to a void* stored value.
......
/*
* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
* Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file GeneratorObjects/CachedParticlePtr.icc
......@@ -125,6 +125,16 @@ void CachedParticlePtr::set (const IProxyDict* sg,
}
/**
* @brief Check if the cached pointer is valid
*/
inline
bool CachedParticlePtr::isValid () const
{
return m_ptr != nullptr;
}
/**
* @brief Convert a store pointer to a void* to store.
* @param sg IProxyDict* to reference.
......
......@@ -305,7 +305,7 @@ public:
* @brief Default constructor. Makes a null link.
* @param sg Optional specification of a specific store to reference.
*/
HepMcParticleLink (IProxyDict* sg = SG::CurrentEventStore::store());
HepMcParticleLink (IProxyDict* sg = nullptr);
/**
......
......@@ -306,7 +306,7 @@ HepMcParticleLink::ExtendedBarCode::setIndex (index_type idx,
* @param sg Optional specification of a specific store to reference.
*/
inline
HepMcParticleLink::HepMcParticleLink (IProxyDict* sg /*= SG::CurrentEventStore::store()*/)
HepMcParticleLink::HepMcParticleLink (IProxyDict* sg /*= nullptr*/)
: m_ptrs (sg)
{
}
......
......@@ -166,6 +166,11 @@ HepMcParticleLink::HepMcParticleLink (const HepMC::GenParticle* part,
*/
const HepMC::GenParticle* HepMcParticleLink::cptr() const
{
// dummy link
if (!m_ptrs.isValid()) {
return nullptr;
}
const IProxyDict* sg = nullptr;
auto p = m_ptrs.get (sg);
if (!p) {
......@@ -243,6 +248,11 @@ const HepMC::GenParticle* HepMcParticleLink::cptr() const
*/
HepMC3::ConstGenParticlePtr HepMcParticleLink::scptr() const
{
// dummy link
if (!m_ptrs.isValid()) {
return nullptr;
}
HepMC3::ConstGenParticlePtr pp{nullptr};
const IProxyDict* sg = nullptr;
auto p = m_ptrs.get (sg);
......@@ -315,6 +325,11 @@ HepMC3::ConstGenParticlePtr HepMcParticleLink::scptr() const
*/
HepMcParticleLink::index_type HepMcParticleLink::eventIndex() const
{
// dummy link
if (!m_ptrs.isValid()) {
return ExtendedBarCode::UNDEFINED;
}
index_type index, position;
m_extBarcode.eventIndex (index, position);
if (index == ExtendedBarCode::UNDEFINED) {
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -35,7 +35,7 @@ SiCharge::SiCharge(const double& charge,const double& time,
m_charge(charge),
m_time(time),
m_processType(processType),
m_partLink(HepMcParticleLink((unsigned int) 0, 0))
m_partLink(HepMcParticleLink())
{}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -18,14 +18,14 @@
SiTotalCharge::SiTotalCharge(const alloc_t& alloc) :
m_charge(0),
m_chargeComposition(alloc),
m_emptyLink((unsigned int) 0, 0)
m_emptyLink()
{}
// Copy constructor:
SiTotalCharge::SiTotalCharge(const SiTotalCharge &totalCharge) :
m_charge(totalCharge.m_charge),
m_chargeComposition(totalCharge.m_chargeComposition),
m_emptyLink((unsigned int) 0, 0)
m_emptyLink()
{}
// Assignment operator:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment