Import Geant4 11.2.0 source tree
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4NavigationHistory
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Responsible for maintenance of the history of the path taken through
|
||||
// the geometrical hierarchy. Principally a utility class for use by the
|
||||
// G4Navigator.
|
||||
|
||||
// 25.07.96 - P.Kent Initial version. Services derived from
|
||||
// requirements of G4Navigator.
|
||||
// ----------------------------------------------------------------------
|
||||
#ifndef G4NAVIGATIONHISTORY_HH
|
||||
#define G4NAVIGATIONHISTORY_HH
|
||||
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include "geomdefs.hh"
|
||||
#include "geomwdefs.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4NavigationLevel.hh"
|
||||
#include "G4NavigationHistoryPool.hh"
|
||||
#include "G4Allocator.hh"
|
||||
|
||||
class G4NavigationHistory
|
||||
{
|
||||
|
||||
public: // with description
|
||||
|
||||
friend std::ostream&
|
||||
operator << (std::ostream& os, const G4NavigationHistory& h);
|
||||
|
||||
G4NavigationHistory();
|
||||
// Constructor: sizes history lists & resets histories.
|
||||
|
||||
~G4NavigationHistory();
|
||||
// Destructor.
|
||||
|
||||
G4NavigationHistory(const G4NavigationHistory& h);
|
||||
// Copy constructor.
|
||||
|
||||
inline G4NavigationHistory& operator=(const G4NavigationHistory& h);
|
||||
// Assignment operator.
|
||||
|
||||
inline void Reset();
|
||||
// Resets history. It now does clear most entries.
|
||||
// Level 0 is preserved.
|
||||
|
||||
inline void Clear();
|
||||
// Clears entries, zeroing transforms, matrices & negating
|
||||
// replica history.
|
||||
|
||||
inline void SetFirstEntry(G4VPhysicalVolume* pVol);
|
||||
// Setup initial entry in stack: copies through volume transform & matrix.
|
||||
// The volume is assumed to be unrotated.
|
||||
|
||||
inline const G4AffineTransform& GetTopTransform() const;
|
||||
// Returns topmost transform.
|
||||
|
||||
inline const G4AffineTransform* GetPtrTopTransform() const;
|
||||
// Returns pointer to topmost transform.
|
||||
|
||||
inline G4int GetTopReplicaNo() const;
|
||||
// Returns topmost replica no record.
|
||||
|
||||
inline EVolume GetTopVolumeType() const;
|
||||
// Returns topmost volume type.
|
||||
|
||||
inline G4VPhysicalVolume* GetTopVolume() const;
|
||||
// Returns topmost physical volume pointer.
|
||||
|
||||
inline std::size_t GetDepth() const;
|
||||
// Returns current history depth.
|
||||
|
||||
inline std::size_t GetMaxDepth() const;
|
||||
// Returns current maximum size of history.
|
||||
// Note: MaxDepth of 16 mean history entries [0..15] inclusive.
|
||||
|
||||
inline const G4AffineTransform& GetTransform(G4int n) const;
|
||||
// Returns specified transformation.
|
||||
|
||||
inline G4int GetReplicaNo(G4int n) const;
|
||||
// Returns specified replica no record.
|
||||
|
||||
inline EVolume GetVolumeType(G4int n) const;
|
||||
// Returns specified volume type.
|
||||
|
||||
inline G4VPhysicalVolume* GetVolume(G4int n) const;
|
||||
// Returns specified physical volume pointer.
|
||||
|
||||
inline void NewLevel(G4VPhysicalVolume* pNewMother,
|
||||
EVolume vType = kNormal,
|
||||
G4int nReplica = -1);
|
||||
// Changes navigation level to that of the new mother.
|
||||
|
||||
inline void BackLevel();
|
||||
// Back up one level in history: from mother to grandmother.
|
||||
// It does not erase history record of current mother.
|
||||
|
||||
inline void BackLevel(G4int n);
|
||||
// Back up specified number of levels in history.
|
||||
|
||||
inline void *operator new(std::size_t);
|
||||
// Override "new" for "G4Allocator".
|
||||
inline void operator delete(void *aHistory);
|
||||
// Override "delete" for "G4Allocator".
|
||||
|
||||
private:
|
||||
|
||||
inline void EnlargeHistory();
|
||||
// Enlarge history if required: increase size by kHistoryStride.
|
||||
// Note that additional history entries are `dirty' (non zero) apart
|
||||
// from the volume history.
|
||||
|
||||
private:
|
||||
|
||||
std::vector<G4NavigationLevel>* fNavHistory;
|
||||
// Pointer to the vector of navigation levels.
|
||||
|
||||
std::size_t fStackDepth{0};
|
||||
// Depth of stack: effectively depth in geometrical tree.
|
||||
};
|
||||
|
||||
#include "G4NavigationHistory.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,225 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// class G4NavigationHistory Inline implementation
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
extern G4GEOM_DLL G4Allocator<G4NavigationHistory>*& aNavigHistoryAllocator();
|
||||
|
||||
// There is no provision that this class is subclassed.
|
||||
// If it is subclassed & new data members are added then the
|
||||
// following "new" & "delete" will fail and give errors.
|
||||
//
|
||||
inline
|
||||
void* G4NavigationHistory::operator new(std::size_t)
|
||||
{
|
||||
if (aNavigHistoryAllocator() == nullptr)
|
||||
{
|
||||
aNavigHistoryAllocator() = new G4Allocator<G4NavigationHistory>;
|
||||
}
|
||||
return (void *) aNavigHistoryAllocator()->MallocSingle();
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationHistory::operator delete(void *aHistory)
|
||||
{
|
||||
aNavigHistoryAllocator()->FreeSingle((G4NavigationHistory *) aHistory);
|
||||
}
|
||||
|
||||
inline
|
||||
G4NavigationHistory&
|
||||
G4NavigationHistory::operator=(const G4NavigationHistory &h)
|
||||
{
|
||||
if (&h == this) { return *this; }
|
||||
|
||||
// *fNavHistory=*(h.fNavHistory); // This works, but is very slow.
|
||||
|
||||
if( GetMaxDepth() != h.GetMaxDepth() )
|
||||
{
|
||||
fNavHistory->resize( h.GetMaxDepth() );
|
||||
}
|
||||
|
||||
for ( auto ilev=G4int(h.fStackDepth); ilev>=0; --ilev )
|
||||
{
|
||||
(*fNavHistory)[ilev] = (*h.fNavHistory)[ilev];
|
||||
}
|
||||
fStackDepth = h.fStackDepth;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationHistory::Reset()
|
||||
{
|
||||
fStackDepth=0;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationHistory::Clear()
|
||||
{
|
||||
G4AffineTransform origin(G4ThreeVector(0.,0.,0.));
|
||||
G4NavigationLevel tmpNavLevel = G4NavigationLevel(nullptr, origin, kNormal, -1) ;
|
||||
|
||||
Reset();
|
||||
for (auto ilev=G4long(fNavHistory->size()-1); ilev>=0; --ilev)
|
||||
{
|
||||
(*fNavHistory)[ilev] = tmpNavLevel;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationHistory::SetFirstEntry(G4VPhysicalVolume* pVol)
|
||||
{
|
||||
G4ThreeVector translation(0.,0.,0.);
|
||||
G4int copyNo = -1;
|
||||
|
||||
// Protection needed in case pVol=null
|
||||
// so that a touchable-history can signal OutOfWorld
|
||||
//
|
||||
if( pVol != nullptr )
|
||||
{
|
||||
translation = pVol->GetTranslation();
|
||||
copyNo = pVol->GetCopyNo();
|
||||
}
|
||||
(*fNavHistory)[0] =
|
||||
G4NavigationLevel( pVol, G4AffineTransform(translation), kNormal, copyNo );
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform* G4NavigationHistory::GetPtrTopTransform() const
|
||||
{
|
||||
return (*fNavHistory)[fStackDepth].GetPtrTransform();
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform& G4NavigationHistory::GetTopTransform() const
|
||||
{
|
||||
return (*fNavHistory)[fStackDepth].GetTransform();
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4NavigationHistory::GetTopReplicaNo() const
|
||||
{
|
||||
return (*fNavHistory)[fStackDepth].GetReplicaNo();
|
||||
}
|
||||
|
||||
inline
|
||||
EVolume G4NavigationHistory::GetTopVolumeType() const
|
||||
{
|
||||
return (*fNavHistory)[fStackDepth].GetVolumeType();
|
||||
}
|
||||
|
||||
inline
|
||||
G4VPhysicalVolume* G4NavigationHistory::GetTopVolume() const
|
||||
{
|
||||
return (*fNavHistory)[fStackDepth].GetPhysicalVolume();
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t G4NavigationHistory::GetDepth() const
|
||||
{
|
||||
return fStackDepth;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform&
|
||||
G4NavigationHistory::GetTransform(G4int n) const
|
||||
{
|
||||
return (*fNavHistory)[n].GetTransform();
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4NavigationHistory::GetReplicaNo(G4int n) const
|
||||
{
|
||||
return (*fNavHistory)[n].GetReplicaNo();
|
||||
}
|
||||
|
||||
inline
|
||||
EVolume G4NavigationHistory::GetVolumeType(G4int n) const
|
||||
{
|
||||
return (*fNavHistory)[n].GetVolumeType();
|
||||
}
|
||||
|
||||
inline
|
||||
G4VPhysicalVolume* G4NavigationHistory::GetVolume(G4int n) const
|
||||
{
|
||||
return (*fNavHistory)[n].GetPhysicalVolume();
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t G4NavigationHistory::GetMaxDepth() const
|
||||
{
|
||||
return fNavHistory->size();
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationHistory::BackLevel()
|
||||
{
|
||||
assert( fStackDepth>0 );
|
||||
|
||||
// Tell the level that I am forgetting it
|
||||
// delete (*fNavHistory)[fStackDepth];
|
||||
//
|
||||
--fStackDepth;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationHistory::BackLevel(G4int n)
|
||||
{
|
||||
assert( n<=G4int(fStackDepth) );
|
||||
fStackDepth-=n;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationHistory::EnlargeHistory()
|
||||
{
|
||||
std::size_t len = fNavHistory->size();
|
||||
if ( len == fStackDepth )
|
||||
{
|
||||
// Note: Resize operation clears additional entries
|
||||
//
|
||||
std::size_t nlen = len+kHistoryStride;
|
||||
fNavHistory->resize(nlen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void G4NavigationHistory::NewLevel( G4VPhysicalVolume* pNewMother,
|
||||
EVolume vType,
|
||||
G4int nReplica )
|
||||
{
|
||||
++fStackDepth;
|
||||
EnlargeHistory(); // Enlarge if required
|
||||
(*fNavHistory)[fStackDepth] =
|
||||
G4NavigationLevel( pNewMother,
|
||||
(*fNavHistory)[fStackDepth-1].GetTransform(),
|
||||
G4AffineTransform(pNewMother->GetRotation(),
|
||||
pNewMother->GetTranslation()),
|
||||
vType,
|
||||
nReplica );
|
||||
// The constructor computes the new global->local transform
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4NavigationHistoryPool
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Thread-local pool for navigation history levels collections being
|
||||
// allocated by G4NavigationHistory. Allows for reuse of the vectors
|
||||
// allocated according to lifetime of G4NavigationHistory objects.
|
||||
|
||||
// 07.05.14 G.Cosmo Initial version
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4NAVIGATIONHISTORYPOOL_HH
|
||||
#define G4NAVIGATIONHISTORYPOOL_HH
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "G4NavigationLevel.hh"
|
||||
|
||||
class G4NavigationHistoryPool
|
||||
{
|
||||
public:
|
||||
|
||||
static G4NavigationHistoryPool* GetInstance();
|
||||
// Return unique instance of G4NavigationHistoryPool.
|
||||
|
||||
inline std::vector<G4NavigationLevel> * GetNewLevels();
|
||||
// Return the pointer to a new collection of levels being allocated.
|
||||
|
||||
inline std::vector<G4NavigationLevel> * GetLevels();
|
||||
// Return the pointer of the first available collection of levels
|
||||
// If none are available (i.e. empty Free vector) allocate collection.
|
||||
|
||||
inline void DeRegister(std::vector<G4NavigationLevel> * pLevels);
|
||||
// Deactivate levels collection in pool.
|
||||
|
||||
void Clean();
|
||||
// Delete all levels stored in the pool.
|
||||
|
||||
void Print() const;
|
||||
// Print number of entries.
|
||||
|
||||
~G4NavigationHistoryPool();
|
||||
// Destructor: takes care to delete allocated levels.
|
||||
|
||||
private:
|
||||
|
||||
G4NavigationHistoryPool();
|
||||
// Default constructor.
|
||||
|
||||
inline void Register(std::vector<G4NavigationLevel> * pLevels);
|
||||
// Register levels collection to pool and activate it.
|
||||
|
||||
void Reset();
|
||||
// Set internal vectors content to zero.
|
||||
|
||||
private:
|
||||
|
||||
static G4ThreadLocal G4NavigationHistoryPool* fgInstance;
|
||||
|
||||
std::vector<std::vector<G4NavigationLevel> *> fPool;
|
||||
std::vector<std::vector<G4NavigationLevel> *> fFree;
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
// Register levels collection to pool (add and/or activate)
|
||||
// ***************************************************************************
|
||||
//
|
||||
inline void G4NavigationHistoryPool::
|
||||
Register(std::vector<G4NavigationLevel> * pLevels)
|
||||
{
|
||||
fPool.push_back(pLevels);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Deactivate levels collection in pool
|
||||
// ***************************************************************************
|
||||
//
|
||||
inline void G4NavigationHistoryPool::
|
||||
DeRegister(std::vector<G4NavigationLevel> * pLevels)
|
||||
{
|
||||
fFree.push_back(pLevels);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Return the pointer of a new collection of levels allocated
|
||||
// ***************************************************************************
|
||||
//
|
||||
inline std::vector<G4NavigationLevel> * G4NavigationHistoryPool::GetNewLevels()
|
||||
{
|
||||
auto aLevelVec = new std::vector<G4NavigationLevel>(kHistoryMax);
|
||||
Register(aLevelVec);
|
||||
|
||||
return aLevelVec;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Return the pointer of the first available collection of levels
|
||||
// If none are available (i.e. non active) allocate collection
|
||||
// ***************************************************************************
|
||||
//
|
||||
inline std::vector<G4NavigationLevel> * G4NavigationHistoryPool::GetLevels()
|
||||
{
|
||||
std::vector<G4NavigationLevel> * levels = nullptr;
|
||||
|
||||
if (!fFree.empty())
|
||||
{
|
||||
levels = fFree.back();
|
||||
fFree.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
levels = GetNewLevels();
|
||||
}
|
||||
|
||||
return levels;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4NavigationLevel
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Maintains one level of the geometrical hierarchy.
|
||||
// A utility class for use by G4NavigationHistory.
|
||||
|
||||
// 30.09.97 J.Apostolakis Initial version. Services derived from
|
||||
// requirements of touchables & G4NavigatorHistory
|
||||
// ----------------------------------------------------------------------
|
||||
#ifndef G4NAVIGATIONLEVEL_HH
|
||||
#define G4NAVIGATIONLEVEL_HH
|
||||
|
||||
#include "G4Types.hh"
|
||||
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
#include "G4NavigationLevelRep.hh"
|
||||
#include "G4Allocator.hh"
|
||||
|
||||
#include "geomwdefs.hh"
|
||||
|
||||
class G4NavigationLevel
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
G4NavigationLevel(G4VPhysicalVolume* newPtrPhysVol,
|
||||
const G4AffineTransform& newT,
|
||||
EVolume newVolTp,
|
||||
G4int newRepNo = -1);
|
||||
|
||||
G4NavigationLevel(G4VPhysicalVolume* newPtrPhysVol,
|
||||
const G4AffineTransform& levelAbove,
|
||||
const G4AffineTransform& relativeCurrent,
|
||||
EVolume newVolTp,
|
||||
G4int newRepNo = -1);
|
||||
// As the previous constructor, but instead of giving Transform, give
|
||||
// the AffineTransform to the level above and the current level's
|
||||
// Transform relative to that.
|
||||
|
||||
G4NavigationLevel();
|
||||
G4NavigationLevel( const G4NavigationLevel& );
|
||||
|
||||
~G4NavigationLevel();
|
||||
|
||||
G4NavigationLevel& operator=(const G4NavigationLevel& right);
|
||||
|
||||
inline G4VPhysicalVolume* GetPhysicalVolume() const;
|
||||
inline const G4AffineTransform* GetTransformPtr() const ; // New
|
||||
inline const G4AffineTransform& GetTransform() const ; // Old
|
||||
|
||||
inline EVolume GetVolumeType() const ;
|
||||
inline G4int GetReplicaNo() const ;
|
||||
|
||||
inline const G4AffineTransform* GetPtrTransform() const;
|
||||
// To try to resolve the possible problem with returning a reference.
|
||||
|
||||
inline void* operator new(size_t);
|
||||
inline void operator delete(void* aLevel);
|
||||
// Override "new" and "delete" to use "G4Allocator".
|
||||
|
||||
inline void* operator new(size_t, void*);
|
||||
#ifndef G4NOT_ISO_DELETES
|
||||
inline void operator delete(void* ptr, void*); // Not accepted Sun/HP
|
||||
#endif
|
||||
// Pre-allocated 'new' and 'delete' for use with STL
|
||||
// Do not (directly) use Allocator
|
||||
|
||||
private:
|
||||
|
||||
G4NavigationLevelRep* fLevelRep;
|
||||
};
|
||||
|
||||
#include "G4NavigationLevel.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4NavigationLevel inline implementation
|
||||
//
|
||||
// 30.09.97 J.Apostolakis Initial version
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
extern G4GEOM_DLL G4Allocator<G4NavigationLevel>*& aNavigationLevelAllocator();
|
||||
|
||||
inline
|
||||
G4VPhysicalVolume* G4NavigationLevel::GetPhysicalVolume() const
|
||||
{
|
||||
return fLevelRep->GetPhysicalVolume();
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform& G4NavigationLevel::GetTransform() const
|
||||
{
|
||||
return fLevelRep->GetTransform() ;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform* G4NavigationLevel::GetPtrTransform() const
|
||||
{
|
||||
return fLevelRep->GetTransformPtr() ;
|
||||
}
|
||||
|
||||
inline
|
||||
EVolume G4NavigationLevel::GetVolumeType() const
|
||||
{
|
||||
return fLevelRep->GetVolumeType() ;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4NavigationLevel::GetReplicaNo() const
|
||||
{
|
||||
return fLevelRep->GetReplicaNo() ;
|
||||
}
|
||||
|
||||
// There is no provision in case this class is subclassed.
|
||||
// If it is subclassed, this will fail and may not give errors!
|
||||
//
|
||||
inline
|
||||
void* G4NavigationLevel::operator new(size_t)
|
||||
{
|
||||
if (aNavigationLevelAllocator() == nullptr)
|
||||
{
|
||||
aNavigationLevelAllocator() = new G4Allocator<G4NavigationLevel>;
|
||||
}
|
||||
return (void *) aNavigationLevelAllocator()->MallocSingle();
|
||||
}
|
||||
|
||||
// Added for use by STL (used for pre-allocation).
|
||||
//
|
||||
inline
|
||||
void* G4NavigationLevel::operator new(size_t, void* a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationLevel::operator delete(void* aLevel)
|
||||
{
|
||||
aNavigationLevelAllocator()->FreeSingle((G4NavigationLevel *) aLevel);
|
||||
}
|
||||
|
||||
// Added for use by STL (used for free-ing pre-allocated?).
|
||||
//
|
||||
#ifndef G4NOT_ISO_DELETES
|
||||
inline
|
||||
void G4NavigationLevel::operator delete(void *, void *)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4NavigationLevelRep
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// A data representation class, used to hold the data for a single level
|
||||
// of the Navigation history tree.
|
||||
//
|
||||
// This is the body of a handle/body pair of classes, that implement
|
||||
// reference counting for NavigationLevels.
|
||||
// The corresponding handle class is G4NavigationLevel
|
||||
|
||||
// 1 October 1997, J.Apostolakis: initial version
|
||||
// ----------------------------------------------------------------------
|
||||
#ifndef G4NAVIGATIONLEVELREP_HH
|
||||
#define G4NAVIGATIONLEVELREP_HH
|
||||
|
||||
#include "G4Types.hh"
|
||||
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Allocator.hh"
|
||||
|
||||
#include "geomwdefs.hh"
|
||||
|
||||
class G4NavigationLevelRep
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
inline G4NavigationLevelRep( G4VPhysicalVolume* newPtrPhysVol,
|
||||
const G4AffineTransform& newT,
|
||||
EVolume newVolTp,
|
||||
G4int newRepNo = -1 );
|
||||
|
||||
inline G4NavigationLevelRep( G4VPhysicalVolume* newPtrPhysVol,
|
||||
const G4AffineTransform& levelAbove,
|
||||
const G4AffineTransform& relativeCurrent,
|
||||
EVolume newVolTp,
|
||||
G4int newRepNo = -1 );
|
||||
// As the previous constructor, but instead of giving Transform, give
|
||||
// the AffineTransform to the level above and the current level's
|
||||
// Transform relative to that.
|
||||
|
||||
inline G4NavigationLevelRep();
|
||||
inline G4NavigationLevelRep( G4NavigationLevelRep& );
|
||||
|
||||
inline ~G4NavigationLevelRep();
|
||||
|
||||
inline G4NavigationLevelRep& operator=(const G4NavigationLevelRep& right);
|
||||
|
||||
inline G4VPhysicalVolume* GetPhysicalVolume();
|
||||
|
||||
inline const G4AffineTransform* GetTransformPtr() const ; // New
|
||||
inline const G4AffineTransform& GetTransform() const ; // Old
|
||||
|
||||
inline EVolume GetVolumeType() const ;
|
||||
inline G4int GetReplicaNo() const ;
|
||||
|
||||
inline void AddAReference();
|
||||
inline G4bool RemoveAReference();
|
||||
// Take care of the reference counts.
|
||||
|
||||
inline void* operator new(size_t);
|
||||
// Override "new" to use "G4Allocator".
|
||||
inline void operator delete(void* aTrack);
|
||||
// Override "delete" to use "G4Allocator".
|
||||
|
||||
private:
|
||||
|
||||
G4AffineTransform sTransform;
|
||||
// Compounded global->local transformation (takes a point in the
|
||||
// global reference system to the system of the volume at this level)
|
||||
|
||||
G4VPhysicalVolume* sPhysicalVolumePtr = nullptr;
|
||||
// Physical volume ptrs, for this level's volume
|
||||
|
||||
G4int sReplicaNo = -1;
|
||||
EVolume sVolumeType;
|
||||
// Volume `type'
|
||||
|
||||
G4int fCountRef = 1;
|
||||
|
||||
};
|
||||
|
||||
#include "G4NavigationLevelRep.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,176 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4NavigationLevelRep inline implementation
|
||||
//
|
||||
// 1 October 1997, J.Apostolakis Initial version
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
extern G4GEOM_DLL G4Allocator<G4NavigationLevelRep>*& aNavigLevelRepAllocator();
|
||||
|
||||
// Constructors
|
||||
//--------------
|
||||
|
||||
inline
|
||||
G4NavigationLevelRep::G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
|
||||
const G4AffineTransform& afTransform,
|
||||
EVolume volTp,
|
||||
G4int repNo )
|
||||
: sTransform(afTransform),
|
||||
sPhysicalVolumePtr(pPhysVol),
|
||||
sReplicaNo(repNo),
|
||||
sVolumeType(volTp)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
G4NavigationLevelRep::G4NavigationLevelRep()
|
||||
: sVolumeType(kReplica)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
G4NavigationLevelRep::G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
|
||||
const G4AffineTransform& levelAbove,
|
||||
const G4AffineTransform& relativeCurrent,
|
||||
EVolume volTp,
|
||||
G4int repNo )
|
||||
: sPhysicalVolumePtr(pPhysVol),
|
||||
sReplicaNo(repNo),
|
||||
sVolumeType(volTp)
|
||||
{
|
||||
sTransform.InverseProduct( levelAbove, relativeCurrent );
|
||||
}
|
||||
|
||||
inline
|
||||
G4NavigationLevelRep::G4NavigationLevelRep( G4NavigationLevelRep& right )
|
||||
: sTransform(right.sTransform),
|
||||
sPhysicalVolumePtr(right.sPhysicalVolumePtr),
|
||||
sReplicaNo(right.sReplicaNo),
|
||||
sVolumeType(right.sVolumeType)
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor
|
||||
//--------------
|
||||
|
||||
inline
|
||||
G4NavigationLevelRep::~G4NavigationLevelRep()
|
||||
{
|
||||
#ifdef DEBUG_NAVIG_LEVEL
|
||||
if(fCountRef>0)
|
||||
{
|
||||
G4Exception("G4NavigationLevelRep::~G4NavigationLevelRep()",
|
||||
"GeomVol0003", FatalException,
|
||||
"Deletion of data-level object with positive reference count.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Operators
|
||||
// --------------
|
||||
|
||||
inline
|
||||
G4NavigationLevelRep&
|
||||
G4NavigationLevelRep::operator=( const G4NavigationLevelRep& right )
|
||||
{
|
||||
if ( &right != this )
|
||||
{
|
||||
sTransform = right.sTransform;
|
||||
sPhysicalVolumePtr = right.sPhysicalVolumePtr;
|
||||
sVolumeType = right.sVolumeType;
|
||||
sReplicaNo = right.sReplicaNo;
|
||||
fCountRef = right.fCountRef;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Accessors
|
||||
// --------------
|
||||
|
||||
inline
|
||||
G4VPhysicalVolume*
|
||||
G4NavigationLevelRep::GetPhysicalVolume()
|
||||
{
|
||||
return sPhysicalVolumePtr;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform&
|
||||
G4NavigationLevelRep::GetTransform() const
|
||||
{
|
||||
return sTransform;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform*
|
||||
G4NavigationLevelRep::GetTransformPtr() const
|
||||
{
|
||||
return &sTransform;
|
||||
}
|
||||
|
||||
inline
|
||||
EVolume G4NavigationLevelRep::GetVolumeType() const
|
||||
{
|
||||
return sVolumeType;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4NavigationLevelRep::GetReplicaNo() const
|
||||
{
|
||||
return sReplicaNo;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationLevelRep::AddAReference()
|
||||
{
|
||||
++fCountRef;
|
||||
}
|
||||
|
||||
inline
|
||||
G4bool G4NavigationLevelRep::RemoveAReference()
|
||||
{
|
||||
return( --fCountRef <= 0 );
|
||||
}
|
||||
|
||||
// There is no provision that this class is subclassed.
|
||||
// If it is subclassed & new data members are added then the
|
||||
// following "new" & "delete" will fail and give errors.
|
||||
//
|
||||
inline
|
||||
void* G4NavigationLevelRep::operator new(size_t)
|
||||
{
|
||||
if (aNavigLevelRepAllocator() == nullptr)
|
||||
{
|
||||
aNavigLevelRepAllocator() = new G4Allocator<G4NavigationLevelRep>;
|
||||
}
|
||||
return (void *) aNavigLevelRepAllocator()->MallocSingle();
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationLevelRep::operator delete(void* aLevelRep)
|
||||
{
|
||||
aNavigLevelRepAllocator()->FreeSingle((G4NavigationLevelRep *) aLevelRep);
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4TouchableHistory
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Object representing a touchable detector element, and its history in the
|
||||
// geometrical hierarchy, including its net resultant local->global transform.
|
||||
//
|
||||
// Touchables are objects capable of maintaining an
|
||||
// association between parts of the geometrical hierarchy (volumes
|
||||
// &/or solids) and their resultant transformation.
|
||||
//
|
||||
// Utilisation:
|
||||
// -----------
|
||||
// A touchable is a geometrical volume (solid) which has a unique
|
||||
// placement in a detector description. It is an abstract base class which
|
||||
// can be implemented in a variety of ways. Each way must provide the
|
||||
// capabilities of obtaining the transformation and solid that is described
|
||||
// by the touchable.
|
||||
//
|
||||
// All touchable implementations must respond to the two following "requests":
|
||||
//
|
||||
// 1) GetTranslation and GetRotation that return the components of the
|
||||
// volume's transformation.
|
||||
//
|
||||
// 2) GetSolid that gives the solid of this touchable.
|
||||
//
|
||||
//
|
||||
// Additional capabilities are available from implementations with more
|
||||
// information. These have a default implementation that causes an exception.
|
||||
//
|
||||
// Several capabilities are available from touchables with physical volumes:
|
||||
//
|
||||
// 3) GetVolume gives the physical volume.
|
||||
//
|
||||
// 4) GetReplicaNumber or GetCopyNumber gives the copy number of the
|
||||
// physical volume, either if it is replicated or not.
|
||||
//
|
||||
// Touchables that store volume hierarchy (history) have the whole stack of
|
||||
// parent volumes available. Thus it is possible to add a little more state
|
||||
// in order to extend its functionality. We add a "pointer" to a level and a
|
||||
// member function to move the level in this stack. Then calling the above
|
||||
// member functions for another level, the information for that level can be
|
||||
// retrieved.
|
||||
//
|
||||
// The top of the history tree is, by convention, the world volume.
|
||||
//
|
||||
// 5) GetHistoryDepth gives the depth of the history tree.
|
||||
//
|
||||
// 6) GetReplicaNumber/GetCopyNumber, GetVolume, GetTranslation and
|
||||
// GetRotation each can be called with a depth argument.
|
||||
// They return the value of the respective level of the touchable.
|
||||
//
|
||||
// 7) MoveUpHistory(num) moves the current pointer inside the touchable
|
||||
// to point "num" levels up the history tree. Thus, eg, calling
|
||||
// it with num=1 will cause the internal pointer to move to the mother
|
||||
// of the current volume.
|
||||
// NOTE: this method MODIFIES the touchable.
|
||||
//
|
||||
// An update method, with different arguments is available, so that the
|
||||
// information in a touchable can be updated:
|
||||
//
|
||||
// 8) UpdateYourself takes a physical volume pointer and can additionally
|
||||
// take a NavigationHistory.
|
||||
|
||||
// Created: Paul Kent, August 1996
|
||||
// ----------------------------------------------------------------------
|
||||
#ifndef G4TOUCHABLEHISTORY_HH
|
||||
#define G4TOUCHABLEHISTORY_HH
|
||||
|
||||
#include "G4NavigationHistory.hh"
|
||||
#include "G4Allocator.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4RotationMatrix.hh"
|
||||
|
||||
#include "geomwdefs.hh"
|
||||
|
||||
class G4TouchableHistory
|
||||
{
|
||||
public:
|
||||
|
||||
G4TouchableHistory();
|
||||
// The default constructor produces a touchable-history of
|
||||
// 'zero-depth', ie an "unphysical" and not very unusable one.
|
||||
// It is for initialisation only.
|
||||
|
||||
G4TouchableHistory( const G4NavigationHistory& history );
|
||||
// Copy constructor
|
||||
|
||||
virtual ~G4TouchableHistory();
|
||||
// Destructor
|
||||
|
||||
inline virtual G4VPhysicalVolume* GetVolume( G4int depth = 0 ) const;
|
||||
inline virtual G4VSolid* GetSolid( G4int depth = 0 ) const;
|
||||
virtual const G4ThreeVector& GetTranslation( G4int depth = 0 ) const;
|
||||
virtual const G4RotationMatrix* GetRotation( G4int depth = 0 ) const;
|
||||
|
||||
inline virtual G4int GetReplicaNumber( G4int depth = 0 ) const;
|
||||
inline G4int GetCopyNumber( G4int depth = 0 ) const;
|
||||
inline virtual G4int GetHistoryDepth() const;
|
||||
virtual G4int MoveUpHistory( G4int num_levels = 1 );
|
||||
// Access methods for touchables with history
|
||||
|
||||
virtual void UpdateYourself( G4VPhysicalVolume* pPhysVol,
|
||||
const G4NavigationHistory* history = nullptr );
|
||||
// Update methods for touchables with history
|
||||
|
||||
inline virtual const G4NavigationHistory* GetHistory() const;
|
||||
// Internal: used in G4Navigator::LocateGlobalPointAndSetup().
|
||||
|
||||
inline void* operator new(std::size_t);
|
||||
inline void operator delete(void* aTH);
|
||||
// Override "new" and "delete" to use "G4Allocator".
|
||||
|
||||
private:
|
||||
|
||||
inline G4int CalculateHistoryIndex( G4int stackDepth ) const;
|
||||
|
||||
G4RotationMatrix frot;
|
||||
G4ThreeVector ftlate;
|
||||
G4NavigationHistory fhistory;
|
||||
};
|
||||
|
||||
#include "G4TouchableHistory.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// class G4TouchableHistory inline implementation
|
||||
//
|
||||
// Created: Paul Kent, August 1996
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
extern G4GEOM_DLL G4Allocator<G4TouchableHistory>*& aTouchableHistoryAllocator();
|
||||
|
||||
inline
|
||||
void G4TouchableHistory::UpdateYourself( G4VPhysicalVolume* pPhysVol,
|
||||
const G4NavigationHistory* pHistory )
|
||||
{
|
||||
fhistory = *pHistory;
|
||||
const G4AffineTransform& tf = fhistory.GetTopTransform();
|
||||
if( pPhysVol == nullptr )
|
||||
{
|
||||
// This means that the track has left the World Volume.
|
||||
// Since the Navigation History does not already reflect this,
|
||||
// we must correct this problem here.
|
||||
//
|
||||
fhistory.SetFirstEntry(pPhysVol);
|
||||
}
|
||||
ftlate = tf.InverseNetTranslation();
|
||||
frot = tf.InverseNetRotation();
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::CalculateHistoryIndex( G4int stackDepth ) const
|
||||
{
|
||||
return G4int(fhistory.GetDepth()-stackDepth); // was -1
|
||||
}
|
||||
|
||||
inline
|
||||
G4VPhysicalVolume* G4TouchableHistory::GetVolume( G4int depth ) const
|
||||
{
|
||||
return fhistory.GetVolume(CalculateHistoryIndex(depth));
|
||||
}
|
||||
|
||||
inline
|
||||
G4VSolid* G4TouchableHistory::GetSolid( G4int depth ) const
|
||||
{
|
||||
return fhistory.GetVolume(CalculateHistoryIndex(depth))
|
||||
->GetLogicalVolume()->GetSolid();
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::GetReplicaNumber( G4int depth ) const
|
||||
{
|
||||
return fhistory.GetReplicaNo(CalculateHistoryIndex(depth));
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::GetCopyNumber(G4int depth) const
|
||||
{
|
||||
return GetReplicaNumber(depth);
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::GetHistoryDepth() const
|
||||
{
|
||||
return G4int(fhistory.GetDepth());
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::MoveUpHistory( G4int num_levels )
|
||||
{
|
||||
auto maxLevelsMove = G4int(fhistory.GetDepth());
|
||||
G4int minLevelsMove = 0; // Cannot redescend today!
|
||||
// Soon it will be possible
|
||||
// by adding a data member here
|
||||
// fCurrentDepth;
|
||||
if( num_levels > maxLevelsMove )
|
||||
{
|
||||
num_levels = maxLevelsMove;
|
||||
}
|
||||
else if( num_levels < minLevelsMove )
|
||||
{
|
||||
num_levels = minLevelsMove;
|
||||
}
|
||||
fhistory.BackLevel( num_levels );
|
||||
|
||||
return num_levels;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4NavigationHistory* G4TouchableHistory::GetHistory() const
|
||||
{
|
||||
return &fhistory;
|
||||
}
|
||||
|
||||
// There is no provision in case this class is subclassed.
|
||||
// If it is subclassed, this will fail and may not give errors!
|
||||
//
|
||||
inline
|
||||
void* G4TouchableHistory::operator new(std::size_t)
|
||||
{
|
||||
// Once the Navigator calls InitializeAllocator,
|
||||
// the if block below can be removed.
|
||||
//
|
||||
if (aTouchableHistoryAllocator() == nullptr)
|
||||
{
|
||||
aTouchableHistoryAllocator() = new G4Allocator<G4TouchableHistory>;
|
||||
}
|
||||
return (void *) aTouchableHistoryAllocator()->MallocSingle();
|
||||
}
|
||||
|
||||
inline
|
||||
void G4TouchableHistory::operator delete(void* aTH)
|
||||
{
|
||||
aTouchableHistoryAllocator()->FreeSingle((G4TouchableHistory *) aTH);
|
||||
}
|
||||
|
||||
+20
-7
@@ -23,12 +23,25 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// class G4VTouchable inline implementation
|
||||
// Class G4TouchableHistoryHandle
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// Class description:
|
||||
//
|
||||
// A type providing reference counting mechanism for a G4TouchableHistory
|
||||
// object.
|
||||
// The basic rule for the use of this type is that this handle must always
|
||||
// be exchanged by reference never dinamically allocated (i.e. never
|
||||
// instantiated using 'new').
|
||||
//
|
||||
// For more details see G4ReferenceCountedHandle.
|
||||
|
||||
inline
|
||||
G4int G4VTouchable::GetCopyNumber(G4int depth) const
|
||||
{
|
||||
return GetReplicaNumber(depth);
|
||||
}
|
||||
// Author: Radovan Chytracek (Radovan.Chytracek@cern.ch), March 2001
|
||||
// ----------------------------------------------------------------------
|
||||
#ifndef G4TOUCHABLEHISTORYHANDLE_HH
|
||||
#define G4TOUCHABLEHISTORYHANDLE_HH 1
|
||||
|
||||
#include "G4TouchableHandle.hh"
|
||||
|
||||
using G4TouchableHistoryHandle = G4TouchableHandle;
|
||||
|
||||
#endif // G4TOUCHABLEHISTORYHANDLE_HH
|
||||
@@ -50,9 +50,9 @@
|
||||
#include "G4Types.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
#include "G4VVolumeMaterialScanner.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
class G4VTouchable;
|
||||
class G4VSolid;
|
||||
class G4Material;
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
|
||||
#include "G4Types.hh"
|
||||
#include "G4VVolumeMaterialScanner.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
class G4VTouchable;
|
||||
class G4VSolid;
|
||||
class G4Material;
|
||||
|
||||
|
||||
@@ -27,108 +27,15 @@
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Base class for `touchable' objects capable of maintaining an
|
||||
// association between parts of the geometrical hierarchy (volumes
|
||||
// &/or solids) and their resultant transformation.
|
||||
//
|
||||
// Utilisation:
|
||||
// -----------
|
||||
// A touchable is a geometrical volume (solid) which has a unique
|
||||
// placement in a detector description. It is an abstract base class which
|
||||
// can be implemented in a variety of ways. Each way must provide the
|
||||
// capabilities of obtaining the transformation and solid that is described
|
||||
// by the touchable.
|
||||
//
|
||||
// All G4VTouchable implementations must respond to the two following
|
||||
// "requests":
|
||||
//
|
||||
// 1) GetTranslation and GetRotation that return the components of the
|
||||
// volume's transformation.
|
||||
//
|
||||
// 2) GetSolid that gives the solid of this touchable.
|
||||
//
|
||||
//
|
||||
// Additional capabilities are available from implementations with more
|
||||
// information. These have a default implementation that causes an exception.
|
||||
//
|
||||
// Several capabilities are available from touchables with physical volumes:
|
||||
//
|
||||
// 3) GetVolume gives the physical volume.
|
||||
//
|
||||
// 4) GetReplicaNumber or GetCopyNumber gives the copy number of the
|
||||
// physical volume, either if it is replicated or not.
|
||||
//
|
||||
// Touchables that store volume hierarchy (history) have the whole stack of
|
||||
// parent volumes available. Thus it is possible to add a little more state
|
||||
// in order to extend its functionality. We add a "pointer" to a level and a
|
||||
// member function to move the level in this stack. Then calling the above
|
||||
// member functions for another level, the information for that level can be
|
||||
// retrieved.
|
||||
//
|
||||
// The top of the history tree is, by convention, the world volume.
|
||||
//
|
||||
// 5) GetHistoryDepth gives the depth of the history tree.
|
||||
//
|
||||
// 6) GetReplicaNumber/GetCopyNumber, GetVolume, GetTranslation and
|
||||
// GetRotation each can be called with a depth argument.
|
||||
// They return the value of the respective level of the touchable.
|
||||
//
|
||||
// 7) MoveUpHistory(num) moves the current pointer inside the touchable
|
||||
// to point "num" levels up the history tree. Thus, eg, calling
|
||||
// it with num=1 will cause the internal pointer to move to the mother
|
||||
// of the current volume.
|
||||
// NOTE: this method MODIFIES the touchable.
|
||||
//
|
||||
// An update method, with different arguments is available, so that the
|
||||
// information in a touchable can be updated:
|
||||
//
|
||||
// 8) UpdateYourself takes a physical volume pointer and can additionally
|
||||
// take a NavigationHistory.
|
||||
// A G4TouchableHistory object.
|
||||
|
||||
// Created: Paul Kent, August 1996
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4VTOUCHABLE_HH
|
||||
#define G4VTOUCHABLE_HH 1
|
||||
|
||||
#include "G4Types.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
class G4VSolid;
|
||||
class G4NavigationHistory;
|
||||
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
class G4VTouchable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
G4VTouchable() = default;
|
||||
virtual ~G4VTouchable() = default;
|
||||
// Constructor and destructor.
|
||||
|
||||
virtual const G4ThreeVector& GetTranslation(G4int depth=0) const = 0;
|
||||
virtual const G4RotationMatrix* GetRotation(G4int depth=0) const = 0;
|
||||
// Accessors for translation and rotation.
|
||||
virtual G4VPhysicalVolume* GetVolume(G4int depth=0) const;
|
||||
virtual G4VSolid* GetSolid(G4int depth=0) const;
|
||||
// Accessors for physical volumes and solid.
|
||||
|
||||
virtual G4int GetReplicaNumber(G4int depth=0) const;
|
||||
inline G4int GetCopyNumber(G4int depth=0) const;
|
||||
virtual G4int GetHistoryDepth() const;
|
||||
virtual G4int MoveUpHistory(G4int num_levels=1);
|
||||
// Methods for touchables with history.
|
||||
|
||||
virtual void UpdateYourself(G4VPhysicalVolume* pPhysVol,
|
||||
const G4NavigationHistory* history = nullptr);
|
||||
// Update method.
|
||||
|
||||
virtual const G4NavigationHistory* GetHistory() const;
|
||||
// Method used in G4Navigator.
|
||||
};
|
||||
|
||||
#include "G4VTouchable.icc"
|
||||
using G4VTouchable = G4TouchableHistory;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user