Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -23,9 +23,21 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4DCofThisEvent
//
// Class description:
//
// This is a class which stores digi collections generated at one event.
// This class is exclusively constructed by G4DigiManager when the first
// digi collection of an event is passed to the manager, and this class
// object is deleted by G4RunManager when a G4Event class object is deleted.
// Almost all public methods must be used by Geant4 kernel classes and
// the user should not invoke them. The user can use two const methods,
// GetDC() and GetNumberOfCollections() for accessing to the stored digi
// collection(s).
//
// Author: Makoto Asai
// --------------------------------------------------------------------
#ifndef G4DCofThisEvent_h
#define G4DCofThisEvent_h 1
@@ -35,52 +47,43 @@
#include <vector>
// class description:
//
// This is a class which stores digi collections generated at one event.
// This class is exclusively constructed by G4DigiManager when the first
// digi collection of an event is passed to the manager, and this class
// object is deleted by G4RunManager when a G4Event class object is deleted.
// Almost all public methods must be used by Geant4 kernel classes and
// the user should not invoke them. The user can use two const methods,
// GetDC() and GetNumberOfCollections() for accessing to the stored digi
// collection(s).
class G4DCofThisEvent
{
public:
G4DCofThisEvent();
explicit G4DCofThisEvent(G4int cap);
~G4DCofThisEvent();
G4DCofThisEvent(const G4DCofThisEvent&);
G4DCofThisEvent& operator=(const G4DCofThisEvent&);
public:
inline void* operator new(size_t);
inline void operator delete(void* anDCoTE);
G4DCofThisEvent();
explicit G4DCofThisEvent(G4int cap);
~G4DCofThisEvent();
G4DCofThisEvent(const G4DCofThisEvent&);
G4DCofThisEvent& operator=(const G4DCofThisEvent&);
void AddDigiCollection(G4int DCID, G4VDigiCollection* aDC);
inline void* operator new(std::size_t);
inline void operator delete(void* anDCoTE);
// Returns a pointer to a digi collection.
// Returns `nullptr` if the particular collection is not stored in the current event.
// The integer argument is ID number which is assigned by G4DigiManager
// and the number can be obtained by G4DigiManager::GetDigiCollectionID()
// method.
inline G4VDigiCollection* GetDC(G4int i) const { return (*DC)[i]; }
void AddDigiCollection(G4int DCID, G4VDigiCollection* aDC);
// Return number of digi collections stored
inline G4int GetNumberOfCollections() const
{
G4int n = 0;
for (const G4VDigiCollection* dc : *DC) {
if (dc != nullptr) n++;
// Returns a pointer to a digi collection.
// Returns `nullptr` if the particular collection is not stored in the current event.
// The integer argument is ID number which is assigned by G4DigiManager
// and the number can be obtained by G4DigiManager::GetDigiCollectionID()
// method.
inline G4VDigiCollection* GetDC(G4int i) const { return (*DC)[i]; }
// Return number of digi collections stored
inline G4int GetNumberOfCollections() const
{
G4int n = 0;
for (const G4VDigiCollection* dc : *DC) {
if (dc != nullptr) ++n;
}
return n;
}
return n;
}
inline size_t GetCapacity() const { return DC->size(); }
inline std::size_t GetCapacity() const { return DC->size(); }
private:
std::vector<G4VDigiCollection*>* DC;
private:
std::vector<G4VDigiCollection*>* DC;
};
#if defined G4DIGI_ALLOC_EXPORT
@@ -89,7 +92,7 @@ extern G4DLLEXPORT G4Allocator<G4DCofThisEvent>*& anDCoTHAllocator_G4MT_TLS_();
extern G4DLLIMPORT G4Allocator<G4DCofThisEvent>*& anDCoTHAllocator_G4MT_TLS_();
#endif
inline void* G4DCofThisEvent::operator new(size_t)
inline void* G4DCofThisEvent::operator new(std::size_t)
{
if (anDCoTHAllocator_G4MT_TLS_() == nullptr) {
anDCoTHAllocator_G4MT_TLS_() = new G4Allocator<G4DCofThisEvent>;
@@ -23,9 +23,20 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4TDigiCollection & G4DigiCollection
//
// Class description:
//
// This is a template class of digi collection and parametrised by
// The concrete class of G4VDigi. This is a uniform collection for
// a particular concrete digi class objects.
// An intermediate layer class G4DigiCollection appeared in this
// header file is used just for G4Allocator, because G4Allocator
// cannot be instantiated with a template class. Thus G4DigiCollection
// class MUST NOT be directly used by the user.
//
// Author: Makoto Asai
// --------------------------------------------------------------------
#ifndef G4TDigiCollection_h
#define G4TDigiCollection_h 1
@@ -35,26 +46,18 @@
#include <vector>
// class description:
//
// This is a template class of digi collection and parametrized by
// The concrete class of G4VDigi. This is a uniform collection for
// a particular concrete digi class objects.
// An intermediate layer class G4DigiCollection appeared in this
// header file is used just for G4Allocator, because G4Allocator
// cannot be instansiated with a template class. Thus G4DigiCollection
// class MUST NOT be directly used by the user.
class G4DigiCollection : public G4VDigiCollection
{
public:
using G4VDigiCollection::G4VDigiCollection;
~G4DigiCollection() override = default;
public:
G4bool operator==(const G4DigiCollection& right) const { return (this == &right); }
using G4VDigiCollection::G4VDigiCollection;
~G4DigiCollection() override = default;
protected:
void* theCollection = nullptr;
G4bool operator==(const G4DigiCollection& right) const { return (this == &right); }
protected:
void* theCollection = nullptr;
};
#if defined G4DIGI_ALLOC_EXPORT
@@ -66,52 +69,53 @@ extern G4DLLIMPORT G4Allocator<G4DigiCollection>*& aDCAllocator_G4MT_TLS_();
template <class T>
class G4TDigiCollection : public G4DigiCollection
{
public:
G4TDigiCollection();
G4TDigiCollection(G4String detName, G4String colNam);
~G4TDigiCollection() override;
public:
G4bool operator==(const G4TDigiCollection& right) const;
G4TDigiCollection();
G4TDigiCollection(const G4String& detName, const G4String& colNam);
~G4TDigiCollection() override;
inline void* operator new(size_t);
inline void operator delete(void* aDC);
G4bool operator==(const G4TDigiCollection& right) const;
// Invoke Draw() method on all stored digit objects in collection
void DrawAllDigi() override;
inline void* operator new(std::size_t);
inline void operator delete(void* aDC);
// Invoke Print() method on all stored digit objects in collection
void PrintAllDigi() override;
// Invoke Draw() method on all stored digit objects in collection
void DrawAllDigi() override;
// Returns pointer to the concrete digi object at index i
// Not bounds checked
inline T* operator[](size_t i) const { return (*((std::vector<T*>*)theCollection))[i]; }
// Invoke Print() method on all stored digit objects in collection
void PrintAllDigi() override;
// Returns pointer to stored collection vector.
inline std::vector<T*>* GetVector() const { return (std::vector<T*>*)theCollection; }
// Returns pointer to the concrete digi object at index i
// Not bounds checked
inline T* operator[](std::size_t i) const { return (*((std::vector<T*>*)theCollection))[i]; }
// Insert a digit object in the collection, taking ownership
// Returns the total number of digi objects stored after insertion
inline size_t insert(T* aHit)
{
auto theDigiCollection = (std::vector<T*>*)theCollection;
theDigiCollection->push_back(aHit);
return theDigiCollection->size();
}
// Returns pointer to stored collection vector.
inline std::vector<T*>* GetVector() const { return (std::vector<T*>*)theCollection; }
// Returns the number of digi objects stored in this collection.
inline size_t entries() const
{
auto theDigiCollection = (std::vector<T*>*)theCollection;
return theDigiCollection->size();
}
// Insert a digit object in the collection, taking ownership
// Returns the total number of digi objects stored after insertion
inline std::size_t insert(T* aHit)
{
auto theDigiCollection = (std::vector<T*>*)theCollection;
theDigiCollection->push_back(aHit);
return theDigiCollection->size();
}
G4VDigi* GetDigi(size_t i) const override { return (*((std::vector<T*>*)theCollection))[i]; }
// Returns the number of digi objects stored in this collection.
inline std::size_t entries() const
{
auto theDigiCollection = (std::vector<T*>*)theCollection;
return theDigiCollection->size();
}
size_t GetSize() const override { return ((std::vector<T*>*)theCollection)->size(); }
G4VDigi* GetDigi(std::size_t i) const override { return (*((std::vector<T*>*)theCollection))[i]; }
std::size_t GetSize() const override { return ((std::vector<T*>*)theCollection)->size(); }
};
template <class T>
inline void* G4TDigiCollection<T>::operator new(size_t)
inline void* G4TDigiCollection<T>::operator new(std::size_t)
{
if (aDCAllocator_G4MT_TLS_() == nullptr) {
aDCAllocator_G4MT_TLS_() = new G4Allocator<G4DigiCollection>;
@@ -133,7 +137,7 @@ G4TDigiCollection<T>::G4TDigiCollection()
}
template <class T>
G4TDigiCollection<T>::G4TDigiCollection(G4String detName, G4String colNam)
G4TDigiCollection<T>::G4TDigiCollection(const G4String& detName, const G4String& colNam)
: G4DigiCollection(detName, colNam)
{
auto theDigiCollection = new std::vector<T*>;
+27 -25
View File
@@ -23,9 +23,18 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VDigi
//
// Class description:
//
// This is the base class of digi object. The user should derive this
// base class to make his/her own digi class. Two virtual method Draw()
// and Print() can be implemented if the user wants these functionalities.
// If a concrete digi class is used as a transient class, G4Allocator
// must be used.
//
// Author: Makoto Asai
// --------------------------------------------------------------------
#ifndef G4VDigi_h
#define G4VDigi_h 1
@@ -37,36 +46,29 @@
class G4AttDef;
class G4AttValue;
// class description:
//
// This is the base class of digi object. The user should derive this
// base class to make his/her own digi class. Two virtual method Draw()
// and Print() can be implemented if the user wants these functionarities.
// If a concrete digi class is used as a transient class, G4Allocator
// must be used.
class G4VDigi
{
public:
G4VDigi() = default;
virtual ~G4VDigi() = default;
public:
G4bool operator==(const G4VDigi& right) const { return (this == &right); }
G4VDigi() = default;
virtual ~G4VDigi() = default;
virtual void Draw(){};
virtual void Print(){};
G4bool operator==(const G4VDigi& right) const { return (this == &right); }
// Returns pointer to map of attribute definitions for this digit
// Caller is responsible for checking validity of returned pointer.
// See `G4Trajectory` for a concrete implementation.
virtual const std::map<G4String, G4AttDef>* GetAttDefs() const { return nullptr; }
virtual void Draw() {}
virtual void Print() {}
// Returns pointer to list of attributes for this digit
// Each attribute must correspond to a definition returned by `GetAffDefs`.
// Caller is responsible for checking validity of returned pointer.
// See `G4Trajectory` for a concrete implementation, and
// `G4VTrajectory::ShowTrajectory` for an example of its use.
virtual std::vector<G4AttValue>* CreateAttValues() const { return nullptr; }
// Returns pointer to map of attribute definitions for this digit
// Caller is responsible for checking validity of returned pointer.
// See `G4Trajectory` for a concrete implementation.
virtual const std::map<G4String, G4AttDef>* GetAttDefs() const { return nullptr; }
// Returns pointer to list of attributes for this digit
// Each attribute must correspond to a definition returned by `GetAffDefs`.
// Caller is responsible for checking validity of returned pointer.
// See `G4Trajectory` for a concrete implementation, and
// `G4VTrajectory::ShowTrajectory` for an example of its use.
virtual std::vector<G4AttValue>* CreateAttValues() const { return nullptr; }
};
#endif
@@ -23,9 +23,18 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VDigiCollection
//
// Class description:
//
// This is the base class of digi collection. The user is advised to
// use G4TDigiCollection template class in case his/her collection is
// transient. While, in case the collection is persistent,
// the concrete collection class can be directly derived from this
// class. Geant4 kernel will use this class methods.
//
// Author: Makoto Asai
// --------------------------------------------------------------------
#ifndef G4VDigiCollection_h
#define G4VDigiCollection_h 1
@@ -33,39 +42,32 @@
class G4VDigi;
// class description:
//
// This is the base class of digi collection. The user is advised to
// use G4TDigiCollection template class in case his/her collection is
// transient. While, in case the collection is persistent with ODBMS,
// the concrete collection class can be directly derived from this
// class.
// Geant4 kernel will use this class methods.
class G4VDigiCollection
{
public:
G4VDigiCollection() = default;
G4VDigiCollection(G4String DMnam, G4String colNam);
virtual ~G4VDigiCollection() = default;
G4bool operator==(const G4VDigiCollection& right) const;
public:
virtual void DrawAllDigi(){};
virtual void PrintAllDigi(){};
G4VDigiCollection() = default;
G4VDigiCollection(const G4String& DMnam, const G4String& colNam);
virtual ~G4VDigiCollection() = default;
G4bool operator==(const G4VDigiCollection& right) const;
inline const G4String& GetName() const { return collectionName; }
inline const G4String& GetDMname() const { return DMname; }
virtual void DrawAllDigi() {}
virtual void PrintAllDigi() {}
// GetDigi and GetSize are given a default implementation here so
// that the template G4TDigiCollection can be used, but they
// are re-implemented in G4TDigiCollection.
virtual G4VDigi* GetDigi(size_t) const { return nullptr; }
virtual size_t GetSize() const { return 0; }
inline const G4String& GetName() const { return collectionName; }
inline const G4String& GetDMname() const { return DMname; }
protected:
// Collection name
G4String collectionName = "Unknown";
G4String DMname = "Unknown";
// GetDigi and GetSize are given a default implementation here so
// that the template G4TDigiCollection can be used, but they
// are re-implemented in G4TDigiCollection.
virtual G4VDigi* GetDigi(std::size_t) const { return nullptr; }
virtual std::size_t GetSize() const { return 0; }
protected:
// Collection name
G4String collectionName = "Unknown";
G4String DMname = "Unknown";
};
#endif