Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4THitsCollection< T > Class Template Reference

#include <G4THitsCollection.hh>

+ Inheritance diagram for G4THitsCollection< T >:

Public Member Functions

 G4THitsCollection ()
 
 G4THitsCollection (G4String detName, G4String colNam)
 
virtual ~G4THitsCollection ()
 
G4bool operator== (const G4THitsCollection< T > &right) const
 
void * operator new (size_t)
 
void operator delete (void *anHC)
 
virtual void DrawAllHits ()
 
virtual void PrintAllHits ()
 
T * operator[] (size_t i) const
 
std::vector< T * > * GetVector () const
 
size_t insert (T *aHit)
 
size_t entries () const
 
virtual G4VHitGetHit (size_t i) const
 
virtual size_t GetSize () const
 
- Public Member Functions inherited from G4HitsCollection
 G4HitsCollection ()
 
 G4HitsCollection (G4String detName, G4String colNam)
 
virtual ~G4HitsCollection ()
 
G4bool operator== (const G4HitsCollection &right) const
 
- Public Member Functions inherited from G4VHitsCollection
 G4VHitsCollection ()
 
 G4VHitsCollection (G4String detName, G4String colNam)
 
virtual ~G4VHitsCollection ()
 
G4bool operator== (const G4VHitsCollection &right) const
 
virtual void DrawAllHits ()
 
virtual void PrintAllHits ()
 
const G4StringGetName () const
 
const G4StringGetSDname () const
 
void SetColID (G4int i)
 
G4int GetColID () const
 
virtual G4VHitGetHit (size_t) const
 
virtual size_t GetSize () const
 

Additional Inherited Members

- Protected Attributes inherited from G4HitsCollection
void * theCollection
 
- Protected Attributes inherited from G4VHitsCollection
G4String collectionName
 
G4String SDname
 
G4int colID
 

Detailed Description

template<class T>
class G4THitsCollection< T >

Definition at line 67 of file G4THitsCollection.hh.

Constructor & Destructor Documentation

◆ G4THitsCollection() [1/2]

template<class T >
G4THitsCollection< T >::G4THitsCollection

Definition at line 142 of file G4THitsCollection.hh.

143{
144 std::vector<T*>* theHitsCollection = new std::vector<T*>;
145 theCollection = (void*) theHitsCollection;
146}

◆ G4THitsCollection() [2/2]

template<class T >
G4THitsCollection< T >::G4THitsCollection ( G4String  detName,
G4String  colNam 
)

Definition at line 149 of file G4THitsCollection.hh.

150 : G4HitsCollection(detName, colNam)
151{
152 std::vector<T*>* theHitsCollection = new std::vector<T*>;
153 theCollection = (void*) theHitsCollection;
154}

◆ ~G4THitsCollection()

template<class T >
G4THitsCollection< T >::~G4THitsCollection
virtual

Definition at line 157 of file G4THitsCollection.hh.

158{
159 std::vector<T*>* theHitsCollection = (std::vector<T*>*) theCollection;
160 // theHitsCollection->clearAndDestroy();
161 for(size_t i = 0; i < theHitsCollection->size(); ++i)
162 {
163 delete(*theHitsCollection)[i];
164 }
165 theHitsCollection->clear();
166 delete theHitsCollection;
167}

Member Function Documentation

◆ DrawAllHits()

template<class T >
void G4THitsCollection< T >::DrawAllHits
virtual

Reimplemented from G4VHitsCollection.

Definition at line 176 of file G4THitsCollection.hh.

177{
178 std::vector<T*>* theHitsCollection = (std::vector<T*>*) theCollection;
179 size_t n = theHitsCollection->size();
180 for(size_t i = 0; i < n; ++i)
181 {
182 (*theHitsCollection)[i]->Draw();
183 }
184}

◆ entries()

template<class T >
size_t G4THitsCollection< T >::entries ( ) const
inline

Definition at line 107 of file G4THitsCollection.hh.

108 {
109 std::vector<T*>* theHitsCollection = (std::vector<T*>*) theCollection;
110 return theHitsCollection->size();
111 }

◆ GetHit()

template<class T >
virtual G4VHit * G4THitsCollection< T >::GetHit ( size_t  i) const
inlinevirtual

Reimplemented from G4VHitsCollection.

Definition at line 115 of file G4THitsCollection.hh.

116 {
117 return (*((std::vector<T*>*) theCollection))[i];
118 }

◆ GetSize()

template<class T >
virtual size_t G4THitsCollection< T >::GetSize ( ) const
inlinevirtual

Reimplemented from G4VHitsCollection.

Definition at line 119 of file G4THitsCollection.hh.

120 {
121 return ((std::vector<T*>*) theCollection)->size();
122 }

◆ GetVector()

template<class T >
std::vector< T * > * G4THitsCollection< T >::GetVector ( ) const
inline

Definition at line 94 of file G4THitsCollection.hh.

95 {
96 return (std::vector<T*>*) theCollection;
97 }

◆ insert()

template<class T >
size_t G4THitsCollection< T >::insert ( T *  aHit)
inline

Definition at line 99 of file G4THitsCollection.hh.

100 {
101 std::vector<T*>* theHitsCollection = (std::vector<T*>*) theCollection;
102 theHitsCollection->push_back(aHit);
103 return theHitsCollection->size();
104 }

◆ operator delete()

template<class T >
void G4THitsCollection< T >::operator delete ( void *  anHC)
inline

Definition at line 136 of file G4THitsCollection.hh.

137{
138 anHCAllocator_G4MT_TLS_()->FreeSingle((G4HitsCollection*) anHC);
139}
G4DLLIMPORT G4Allocator< G4HitsCollection > *& anHCAllocator_G4MT_TLS_()

◆ operator new()

template<class T >
void * G4THitsCollection< T >::operator new ( size_t  )
inline

Definition at line 126 of file G4THitsCollection.hh.

127{
128 if(anHCAllocator_G4MT_TLS_() == nullptr)
129 {
131 }
132 return (void*) anHCAllocator_G4MT_TLS_()->MallocSingle();
133}

◆ operator==()

template<class T >
G4bool G4THitsCollection< T >::operator== ( const G4THitsCollection< T > &  right) const

Definition at line 170 of file G4THitsCollection.hh.

171{
172 return (collectionName == right.collectionName);
173}

◆ operator[]()

template<class T >
T * G4THitsCollection< T >::operator[] ( size_t  i) const
inline

Definition at line 89 of file G4THitsCollection.hh.

90 {
91 return (*((std::vector<T*>*) theCollection))[i];
92 }

◆ PrintAllHits()

template<class T >
void G4THitsCollection< T >::PrintAllHits
virtual

Reimplemented from G4VHitsCollection.

Definition at line 187 of file G4THitsCollection.hh.

188{
189 std::vector<T*>* theHitsCollection = (std::vector<T*>*) theCollection;
190 size_t n = theHitsCollection->size();
191 for(size_t i = 0; i < n; ++i)
192 {
193 (*theHitsCollection)[i]->Print();
194 }
195}

The documentation for this class was generated from the following file: