Import Geant4 11.2.0.beta source tree
This commit is contained in:
@@ -29,9 +29,10 @@
|
||||
#ifndef G4TDigiCollection_h
|
||||
#define G4TDigiCollection_h 1
|
||||
|
||||
#include "G4VDigiCollection.hh"
|
||||
#include "G4Allocator.hh"
|
||||
#include "G4VDigiCollection.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <vector>
|
||||
|
||||
// class description:
|
||||
@@ -47,13 +48,13 @@
|
||||
class G4DigiCollection : public G4VDigiCollection
|
||||
{
|
||||
public:
|
||||
G4DigiCollection();
|
||||
G4DigiCollection(G4String detName, G4String colNam);
|
||||
virtual ~G4DigiCollection();
|
||||
G4bool operator==(const G4DigiCollection& right) const;
|
||||
using G4VDigiCollection::G4VDigiCollection;
|
||||
~G4DigiCollection() override = default;
|
||||
|
||||
G4bool operator==(const G4DigiCollection& right) const { return (this == &right); }
|
||||
|
||||
protected:
|
||||
void* theCollection;
|
||||
void* theCollection = nullptr;
|
||||
};
|
||||
|
||||
#if defined G4DIGI_ALLOC_EXPORT
|
||||
@@ -67,99 +68,84 @@ class G4TDigiCollection : public G4DigiCollection
|
||||
{
|
||||
public:
|
||||
G4TDigiCollection();
|
||||
|
||||
public: // with description
|
||||
G4TDigiCollection(G4String detName, G4String colNam);
|
||||
// Constructor.
|
||||
public:
|
||||
virtual ~G4TDigiCollection();
|
||||
~G4TDigiCollection() override;
|
||||
|
||||
G4bool operator==(const G4TDigiCollection& right) const;
|
||||
|
||||
inline void* operator new(size_t);
|
||||
inline void operator delete(void* aDC);
|
||||
|
||||
public: // with description
|
||||
virtual void DrawAllDigi();
|
||||
virtual void PrintAllDigi();
|
||||
// These two methods invokes Draw() and Print() methods of all of
|
||||
// digit objects stored in this collection, respectively.
|
||||
// Invoke Draw() method on all stored digit objects in collection
|
||||
void DrawAllDigi() override;
|
||||
|
||||
public: // with description
|
||||
inline T* operator[](size_t i) const
|
||||
{
|
||||
return (*((std::vector<T*>*) theCollection))[i];
|
||||
}
|
||||
// Returns a pointer to a concrete digi object.
|
||||
inline std::vector<T*>* GetVector() const
|
||||
{
|
||||
return (std::vector<T*>*) theCollection;
|
||||
}
|
||||
// Returns a collection vector.
|
||||
// Invoke Print() method on all stored digit objects in collection
|
||||
void PrintAllDigi() 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]; }
|
||||
|
||||
// Returns pointer to stored collection vector.
|
||||
inline std::vector<T*>* GetVector() const { return (std::vector<T*>*)theCollection; }
|
||||
|
||||
// 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)
|
||||
{
|
||||
std::vector<T*>* theDigiCollection = (std::vector<T*>*) theCollection;
|
||||
auto theDigiCollection = (std::vector<T*>*)theCollection;
|
||||
theDigiCollection->push_back(aHit);
|
||||
return theDigiCollection->size();
|
||||
}
|
||||
// Insert a digi object. Total number of digi objects stored in this
|
||||
// collection is returned.
|
||||
|
||||
// Returns the number of digi objects stored in this collection.
|
||||
inline size_t entries() const
|
||||
{
|
||||
std::vector<T*>* theDigiCollection = (std::vector<T*>*) theCollection;
|
||||
auto theDigiCollection = (std::vector<T*>*)theCollection;
|
||||
return theDigiCollection->size();
|
||||
}
|
||||
// Returns the number of digi objcets stored in this collection.
|
||||
|
||||
public:
|
||||
virtual G4VDigi* GetDigi(size_t i) const
|
||||
{
|
||||
return (*((std::vector<T*>*) theCollection))[i];
|
||||
}
|
||||
virtual size_t GetSize() const
|
||||
{
|
||||
return ((std::vector<T*>*) theCollection)->size();
|
||||
}
|
||||
G4VDigi* GetDigi(size_t i) const override { return (*((std::vector<T*>*)theCollection))[i]; }
|
||||
|
||||
size_t GetSize() const override { return ((std::vector<T*>*)theCollection)->size(); }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline void* G4TDigiCollection<T>::operator new(size_t)
|
||||
{
|
||||
if(aDCAllocator_G4MT_TLS_() == nullptr)
|
||||
{
|
||||
if (aDCAllocator_G4MT_TLS_() == nullptr) {
|
||||
aDCAllocator_G4MT_TLS_() = new G4Allocator<G4DigiCollection>;
|
||||
}
|
||||
return (void*) aDCAllocator_G4MT_TLS_()->MallocSingle();
|
||||
return (void*)aDCAllocator_G4MT_TLS_()->MallocSingle();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void G4TDigiCollection<T>::operator delete(void* aDC)
|
||||
{
|
||||
aDCAllocator_G4MT_TLS_()->FreeSingle((G4DigiCollection*) aDC);
|
||||
aDCAllocator_G4MT_TLS_()->FreeSingle((G4DigiCollection*)aDC);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
G4TDigiCollection<T>::G4TDigiCollection()
|
||||
{
|
||||
std::vector<T*>* theDigiCollection = new std::vector<T*>;
|
||||
theCollection = (void*) theDigiCollection;
|
||||
auto theDigiCollection = new std::vector<T*>;
|
||||
theCollection = (void*)theDigiCollection;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
G4TDigiCollection<T>::G4TDigiCollection(G4String detName, G4String colNam)
|
||||
: G4DigiCollection(detName, colNam)
|
||||
{
|
||||
std::vector<T*>* theDigiCollection = new std::vector<T*>;
|
||||
theCollection = (void*) theDigiCollection;
|
||||
auto theDigiCollection = new std::vector<T*>;
|
||||
theCollection = (void*)theDigiCollection;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
G4TDigiCollection<T>::~G4TDigiCollection()
|
||||
{
|
||||
std::vector<T*>* theDigiCollection = (std::vector<T*>*) theCollection;
|
||||
|
||||
for(size_t i = 0; i < theDigiCollection->size(); i++)
|
||||
{
|
||||
delete(*theDigiCollection)[i];
|
||||
auto theDigiCollection = (std::vector<T*>*)theCollection;
|
||||
for (const auto* digi : *theDigiCollection) {
|
||||
delete digi;
|
||||
}
|
||||
theDigiCollection->clear();
|
||||
delete theDigiCollection;
|
||||
@@ -174,22 +160,18 @@ G4bool G4TDigiCollection<T>::operator==(const G4TDigiCollection<T>& right) const
|
||||
template <class T>
|
||||
void G4TDigiCollection<T>::DrawAllDigi()
|
||||
{
|
||||
std::vector<T*>* theDigiCollection = (std::vector<T*>*) theCollection;
|
||||
size_t n = theDigiCollection->size();
|
||||
for(size_t i = 0; i < n; i++)
|
||||
{
|
||||
(*theDigiCollection)[i]->Draw();
|
||||
auto theDigiCollection = (std::vector<T*>*)theCollection;
|
||||
for (auto* digi : *theDigiCollection) {
|
||||
digi->Draw();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void G4TDigiCollection<T>::PrintAllDigi()
|
||||
{
|
||||
std::vector<T*>* theDigiCollection = (std::vector<T*>*) theCollection;
|
||||
size_t n = theDigiCollection->size();
|
||||
for(size_t i = 0; i < n; i++)
|
||||
{
|
||||
(*theDigiCollection)[i]->Print();
|
||||
auto theDigiCollection = (std::vector<T*>*)theCollection;
|
||||
for (auto* digi : *theDigiCollection) {
|
||||
digi->Print();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user