Skip to content
Snippets Groups Projects
Commit d28ff5de authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

GeoFullPhysVol: fixed clonning of full physical volumes

Removed unnecessary calls to ref() and unref()
parent 7ef39bf3
No related branches found
No related tags found
1 merge request!238GeoFullPhysVol: code cleanup
Checking pipeline status
......@@ -59,12 +59,22 @@ class GeoFullPhysVol final : public GeoVFullPhysVol
/// Returns the number of child physical volumes and Serial Transformers.
virtual unsigned int getNChildVolAndST() const override;
/// Meaning of the input parameter 'attached'
/// TRUE: all cloned volumes are meant to stay identical to their clone origin for the lifetime
/// further changes are permitted neither in the origin nor in the clone results
///
/// FALSE: use this value if you expect further changes in either clone origing or its clone results
/// which don't need to be syncronized. The clone origin and its clone are identical ONLY by
/// the time of cloning, further identity is not guaranteed
GeoFullPhysVol* clone(bool attached = true);
const GeoFullPhysVol* cloneOrigin() const;
/// The following method breaks consistency of cloned volumes!
/// Use it only in Simulation jobs and
/// don't call it until geometry has been completely translated to G4
void clear(); // drop subtree
virtual GeoTrf::Transform3D getX (const GeoVAlignmentStore* store=nullptr) const override;
virtual GeoTrf::Transform3D getDefX (const GeoVAlignmentStore* store=nullptr) const override;
virtual unsigned int getNChildNodes() const override;
......@@ -72,7 +82,7 @@ class GeoFullPhysVol final : public GeoVFullPhysVol
virtual const GeoGraphNode * const *findChildNode(const GeoGraphNode *n) const override;
protected:
virtual ~GeoFullPhysVol();
virtual ~GeoFullPhysVol() = default;
private:
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelKernel/GeoFullPhysVol.h"
......@@ -14,10 +14,6 @@
GeoFullPhysVol::GeoFullPhysVol (const GeoLogVol* LogVol)
: GeoVFullPhysVol(LogVol){ }
GeoFullPhysVol::~GeoFullPhysVol() {
if(m_cloneOrigin && m_cloneOrigin!=this) m_cloneOrigin->unref();
}
void GeoFullPhysVol::add(GeoGraphNode* graphNode)
{
if(m_cloneOrigin) throw std::runtime_error("Attempt to modify contents of a cloned FPV");
......@@ -118,27 +114,18 @@ unsigned int GeoFullPhysVol::getNChildVolAndST() const
return cv.getCount();
}
/// Meaning of the input parameter 'attached'
/// TRUE: all cloned volumes are meant to stay identical to their clone origin for the lifetime
/// further changes are permitted neither in the origin nor in the clone results
///
/// FALSE: use this value if you expect further changes in either clone origing or its clone results
/// which don't need to be syncronized. The clone origin and its clone are identical ONLY by
/// the time of cloning, further identity is not guaranteed
GeoFullPhysVol* GeoFullPhysVol::clone(bool attached)
{
GeoFullPhysVol* clone = new GeoFullPhysVol(this->getLogVol());
for(unsigned int ind = 0; ind < this->m_daughters.size(); ind++) {
GeoGraphNode* daughter =(GeoGraphNode*) m_daughters[ind];
for(auto daughter : m_daughters) {
clone->add(daughter);
}
if(attached) {
if(this->m_cloneOrigin==0) {
this->m_cloneOrigin = this;
if(!m_cloneOrigin) {
m_cloneOrigin = this;
}
clone->m_cloneOrigin = this->m_cloneOrigin;
this->m_cloneOrigin->ref();
clone->m_cloneOrigin = m_cloneOrigin;
}
return clone;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment