Geant4-11
Public Types | Public Member Functions | Protected Attributes | Private Types | Private Member Functions
G4VTHitsMap< T, Map_t > Class Template Reference

#include <G4THitsMap.hh>

Inheritance diagram for G4VTHitsMap< T, Map_t >:
G4HitsCollection G4VHitsCollection

Public Types

typedef map_type::const_iterator const_iterator
 
typedef map_type::iterator iterator
 
typedef Map_t map_type
 
typedef G4VTHitsMap< T, Map_t > this_type
 
typedef T value_type
 

Public Member Functions

template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t add (const G4int &key, U &aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t add (const G4int &key, U &aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t add (const G4int &key, U &aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t add (const G4int &key, U &aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t< is_same_t(U, T) &&!is_mmap_t(MapU_t), G4int > = 0>
size_t add (const G4int &key, U *&aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t add (const G4int &key, U *&aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t add (const G4int &key, U *&aHit) const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
void clear ()
 
virtual void DrawAllHits ()
 
iterator end ()
 
const_iterator end () const
 
size_t entries () const
 
 G4VTHitsMap ()
 
 G4VTHitsMap (G4String detName, G4String colNam)
 
G4int GetColID () const
 
Map_t * GetContainer () const
 
virtual G4VHitGetHit (size_t) const
 
Map_t::size_type GetIndex (const_iterator itr) const
 
Map_t::size_type GetIndex (iterator itr)
 
Map_t * GetMap () const
 
const G4StringGetName () const
 
const T * GetObject (const_iterator itr) const
 
template<typename MapU_t = Map_t, enable_if_t<!is_mmap_t(MapU_t), G4int > = 0>
T * GetObject (G4int idx) const
 
template<typename MapU_t = Map_t, enable_if_t< is_mmap_t(MapU_t), G4int > = 0>
T * GetObject (G4int idx) const
 
T * GetObject (iterator itr) const
 
const G4StringGetSDname () const
 
virtual size_t GetSize () const
 
template<typename U , typename MapU_t >
this_typeoperator+= (const G4VTHitsMap< U, MapU_t > &right) const
 
G4bool operator== (const G4HitsCollection &right) const
 
G4bool operator== (const G4VHitsCollection &right) const
 
G4bool operator== (const G4VTHitsMap< T, Map_t > &right) const
 
template<typename MapU_t = Map_t, enable_if_t<!is_mmap_t(MapU_t), G4int > = 0>
T * operator[] (G4int key) const
 
template<typename MapU_t = Map_t, enable_if_t< is_mmap_t(MapU_t), G4int > = 0>
T * operator[] (G4int key) const
 
virtual void PrintAllHits ()
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t set (const G4int &key, U &aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t set (const G4int &key, U &aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t set (const G4int &key, U &aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t set (const G4int &key, U &aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t set (const G4int &key, U *&aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t set (const G4int &key, U *&aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t set (const G4int &key, U *&aHit) const
 
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t set (const G4int &key, U *&aHit) const
 
void SetColID (G4int i)
 
Map_t::size_type size ()
 
virtual ~G4VTHitsMap ()
 

Protected Attributes

G4int colID
 
G4String collectionName
 
G4String SDname
 
void * theCollection
 

Private Types

template<bool _Bp, typename _Tp = void>
using enable_if_t = typename std::enable_if< _Bp, _Tp >::type
 
typedef std::multimap< G4int, T * > mmap_t
 
typedef std::pair< G4int, T * > pair_t
 
typedef std::unordered_multimap< G4int, T * > uommap_t
 

Private Member Functions

template<typename U = T, enable_if_t< is_fundamental_t(U), G4int > = 0>
T * allocate () const
 
template<typename U = T, enable_if_t<!is_fundamental_t(U), G4int > = 0>
T * allocate () const
 

Detailed Description

template<typename T, typename Map_t = std::map<G4int, T*>>
class G4VTHitsMap< T, Map_t >

Definition at line 48 of file G4THitsMap.hh.

Member Typedef Documentation

◆ const_iterator

template<typename T , typename Map_t = std::map<G4int, T*>>
typedef map_type::const_iterator G4VTHitsMap< T, Map_t >::const_iterator

Definition at line 84 of file G4THitsMap.hh.

◆ enable_if_t

template<typename T , typename Map_t = std::map<G4int, T*>>
template<bool _Bp, typename _Tp = void>
using G4VTHitsMap< T, Map_t >::enable_if_t = typename std::enable_if<_Bp, _Tp>::type
private

Definition at line 62 of file G4THitsMap.hh.

◆ iterator

template<typename T , typename Map_t = std::map<G4int, T*>>
typedef map_type::iterator G4VTHitsMap< T, Map_t >::iterator

Definition at line 83 of file G4THitsMap.hh.

◆ map_type

template<typename T , typename Map_t = std::map<G4int, T*>>
typedef Map_t G4VTHitsMap< T, Map_t >::map_type

Definition at line 82 of file G4THitsMap.hh.

◆ mmap_t

template<typename T , typename Map_t = std::map<G4int, T*>>
typedef std::multimap<G4int, T*> G4VTHitsMap< T, Map_t >::mmap_t
private

Definition at line 51 of file G4THitsMap.hh.

◆ pair_t

template<typename T , typename Map_t = std::map<G4int, T*>>
typedef std::pair<G4int, T*> G4VTHitsMap< T, Map_t >::pair_t
private

Definition at line 52 of file G4THitsMap.hh.

◆ this_type

template<typename T , typename Map_t = std::map<G4int, T*>>
typedef G4VTHitsMap<T, Map_t> G4VTHitsMap< T, Map_t >::this_type

Definition at line 80 of file G4THitsMap.hh.

◆ uommap_t

template<typename T , typename Map_t = std::map<G4int, T*>>
typedef std::unordered_multimap<G4int, T*> G4VTHitsMap< T, Map_t >::uommap_t
private

Definition at line 53 of file G4THitsMap.hh.

◆ value_type

template<typename T , typename Map_t = std::map<G4int, T*>>
typedef T G4VTHitsMap< T, Map_t >::value_type

Definition at line 81 of file G4THitsMap.hh.

Constructor & Destructor Documentation

◆ G4VTHitsMap() [1/2]

template<typename T , typename Map_t >
G4VTHitsMap< T, Map_t >::G4VTHitsMap

Definition at line 458 of file G4THitsMap.hh.

459{
460 theCollection = (void*) new Map_t;
461}

◆ G4VTHitsMap() [2/2]

template<typename T , typename Map_t >
G4VTHitsMap< T, Map_t >::G4VTHitsMap ( G4String  detName,
G4String  colNam 
)

Definition at line 466 of file G4THitsMap.hh.

467 : G4HitsCollection(detName, colNam)
468{
469 theCollection = (void*) new Map_t;
470}

References G4HitsCollection::theCollection.

◆ ~G4VTHitsMap()

template<typename T , typename Map_t >
G4VTHitsMap< T, Map_t >::~G4VTHitsMap
virtual

Definition at line 475 of file G4THitsMap.hh.

476{
477 map_type* theHitsMap = GetMap();
478 for(iterator itr = theHitsMap->begin(); itr != theHitsMap->end(); ++itr)
479 delete itr->second;
480 delete theHitsMap;
481}
map_type::iterator iterator
Definition: G4THitsMap.hh:83
Map_t * GetMap() const
Definition: G4THitsMap.hh:155
Map_t map_type
Definition: G4THitsMap.hh:82

Member Function Documentation

◆ add() [1/7]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::add ( const G4int key,
U &  aHit 
) const
inline

Definition at line 221 of file G4THitsMap.hh.

222 {
223 map_type* theHitsMap = GetMap();
224 if(theHitsMap->find(key) == theHitsMap->end())
225 theHitsMap->insert(pair_t(key, new T(aHit)));
226 else
227 *theHitsMap->find(key)->second += aHit;
228 return theHitsMap->size();
229 }
std::pair< G4int, T * > pair_t
Definition: G4THitsMap.hh:52

References G4VTHitsMap< T, Map_t >::GetMap().

◆ add() [2/7]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::add ( const G4int key,
U &  aHit 
) const
inline

Definition at line 236 of file G4THitsMap.hh.

237 {
238 map_type* theHitsMap = GetMap();
239 if(theHitsMap->find(key) == theHitsMap->end())
240 theHitsMap->insert(pair_t(key, allocate()));
241 *theHitsMap->find(key)->second += aHit;
242 return theHitsMap->size();
243 }
T * allocate() const
Definition: G4THitsMap.hh:66

References G4VTHitsMap< T, Map_t >::allocate(), and G4VTHitsMap< T, Map_t >::GetMap().

◆ add() [3/7]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::add ( const G4int key,
U &  aHit 
) const
inline

Definition at line 249 of file G4THitsMap.hh.

250 {
251 map_type* theHitsMap = GetMap();
252 theHitsMap->insert(pair_t(key, new T(aHit)));
253 return theHitsMap->size();
254 }

References G4VTHitsMap< T, Map_t >::GetMap().

◆ add() [4/7]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::add ( const G4int key,
U &  aHit 
) const
inline

Definition at line 261 of file G4THitsMap.hh.

262 {
263 map_type* theHitsMap = GetMap();
264 T* hit = allocate();
265 *hit += aHit;
266 theHitsMap->insert(pair_t(key, hit));
267 return theHitsMap->size();
268 }

References G4VTHitsMap< T, Map_t >::allocate(), and G4VTHitsMap< T, Map_t >::GetMap().

◆ add() [5/7]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t< is_same_t(U, T) &&!is_mmap_t(MapU_t), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::add ( const G4int key,
U *&  aHit 
) const
inline

◆ add() [6/7]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::add ( const G4int key,
U *&  aHit 
) const
inline

Definition at line 191 of file G4THitsMap.hh.

192 {
193 map_type* theHitsMap = GetMap();
194 theHitsMap->insert(pair_t(key, aHit));
195 return theHitsMap->size();
196 }

References G4VTHitsMap< T, Map_t >::GetMap().

◆ add() [7/7]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::add ( const G4int key,
U *&  aHit 
) const
inline

Definition at line 203 of file G4THitsMap.hh.

204 {
205 map_type* theHitsMap = GetMap();
206 T* hit = allocate();
207 *hit += *aHit;
208 theHitsMap->insert(pair_t(key, hit));
209 return theHitsMap->size();
210 }

References G4VTHitsMap< T, Map_t >::allocate(), and G4VTHitsMap< T, Map_t >::GetMap().

◆ allocate() [1/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, enable_if_t< is_fundamental_t(U), G4int > = 0>
T * G4VTHitsMap< T, Map_t >::allocate ( ) const
inlineprivate

Definition at line 66 of file G4THitsMap.hh.

67 {
68 return new T(0.);
69 }

Referenced by G4VTHitsMap< T, Map_t >::add(), and G4VTHitsMap< T, Map_t >::set().

◆ allocate() [2/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, enable_if_t<!is_fundamental_t(U), G4int > = 0>
T * G4VTHitsMap< T, Map_t >::allocate ( ) const
inlineprivate

Definition at line 74 of file G4THitsMap.hh.

75 {
76 return new T();
77 }

◆ begin() [1/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
iterator G4VTHitsMap< T, Map_t >::begin ( )
inline

Definition at line 146 of file G4THitsMap.hh.

146{ return GetContainer()->begin(); }
Map_t * GetContainer() const
Definition: G4THitsMap.hh:118

References G4VTHitsMap< T, Map_t >::GetContainer().

◆ begin() [2/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
const_iterator G4VTHitsMap< T, Map_t >::begin ( ) const
inline

Definition at line 148 of file G4THitsMap.hh.

148{ return GetContainer()->begin(); }

References G4VTHitsMap< T, Map_t >::GetContainer().

◆ cbegin()

template<typename T , typename Map_t = std::map<G4int, T*>>
const_iterator G4VTHitsMap< T, Map_t >::cbegin ( ) const
inline

Definition at line 150 of file G4THitsMap.hh.

150{ return GetContainer()->cbegin(); }

References G4VTHitsMap< T, Map_t >::GetContainer().

◆ cend()

template<typename T , typename Map_t = std::map<G4int, T*>>
const_iterator G4VTHitsMap< T, Map_t >::cend ( ) const
inline

Definition at line 151 of file G4THitsMap.hh.

151{ return GetContainer()->cend(); }

References G4VTHitsMap< T, Map_t >::GetContainer().

◆ clear()

template<typename T , typename Map_t >
void G4VTHitsMap< T, Map_t >::clear
inline

◆ DrawAllHits()

template<typename T , typename Map_t >
void G4VTHitsMap< T, Map_t >::DrawAllHits
virtual

Reimplemented from G4VHitsCollection.

Definition at line 495 of file G4THitsMap.hh.

496{
497 ;
498}

◆ end() [1/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
iterator G4VTHitsMap< T, Map_t >::end ( )
inline

Definition at line 147 of file G4THitsMap.hh.

147{ return GetContainer()->end(); }

References G4VTHitsMap< T, Map_t >::GetContainer().

◆ end() [2/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
const_iterator G4VTHitsMap< T, Map_t >::end ( ) const
inline

Definition at line 149 of file G4THitsMap.hh.

149{ return GetContainer()->end(); }

References G4VTHitsMap< T, Map_t >::GetContainer().

◆ entries()

template<typename T , typename Map_t = std::map<G4int, T*>>
size_t G4VTHitsMap< T, Map_t >::entries ( ) const
inline

◆ GetColID()

G4int G4VHitsCollection::GetColID ( ) const
inlineinherited

Definition at line 66 of file G4VHitsCollection.hh.

66{ return colID; }

References G4VHitsCollection::colID.

◆ GetContainer()

template<typename T , typename Map_t = std::map<G4int, T*>>
Map_t * G4VTHitsMap< T, Map_t >::GetContainer ( ) const
inline

◆ GetHit()

template<typename T , typename Map_t = std::map<G4int, T*>>
virtual G4VHit * G4VTHitsMap< T, Map_t >::GetHit ( size_t  ) const
inlinevirtual

Reimplemented from G4VHitsCollection.

Definition at line 163 of file G4THitsMap.hh.

163{ return 0; }

◆ GetIndex() [1/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
Map_t::size_type G4VTHitsMap< T, Map_t >::GetIndex ( const_iterator  itr) const
inline

Definition at line 124 of file G4THitsMap.hh.

125 {
126 return itr->first;
127 }

◆ GetIndex() [2/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
Map_t::size_type G4VTHitsMap< T, Map_t >::GetIndex ( iterator  itr)
inline

Definition at line 122 of file G4THitsMap.hh.

122{ return itr->first; }

◆ GetMap()

template<typename T , typename Map_t = std::map<G4int, T*>>
Map_t * G4VTHitsMap< T, Map_t >::GetMap ( ) const
inline

◆ GetName()

const G4String & G4VHitsCollection::GetName ( ) const
inlineinherited

Definition at line 63 of file G4VHitsCollection.hh.

63{ return collectionName; }

References G4VHitsCollection::collectionName.

Referenced by G4SDManager::GetCollectionID().

◆ GetObject() [1/4]

template<typename T , typename Map_t = std::map<G4int, T*>>
const T * G4VTHitsMap< T, Map_t >::GetObject ( const_iterator  itr) const
inline

Definition at line 144 of file G4THitsMap.hh.

144{ return itr->second; }

◆ GetObject() [2/4]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename MapU_t = Map_t, enable_if_t<!is_mmap_t(MapU_t), G4int > = 0>
T * G4VTHitsMap< T, Map_t >::GetObject ( G4int  idx) const
inline

Definition at line 130 of file G4THitsMap.hh.

131 {
132 return (GetContainer()->count(idx) != 0) ? (*GetContainer())[idx] : nullptr;
133 }

References G4VTHitsMap< T, Map_t >::GetContainer().

◆ GetObject() [3/4]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename MapU_t = Map_t, enable_if_t< is_mmap_t(MapU_t), G4int > = 0>
T * G4VTHitsMap< T, Map_t >::GetObject ( G4int  idx) const
inline

Definition at line 136 of file G4THitsMap.hh.

137 {
138 return (GetContainer()->count(idx) != 0) ? GetContainer()->find(idx)->second
139 : nullptr;
140 }

References G4VTHitsMap< T, Map_t >::GetContainer().

◆ GetObject() [4/4]

template<typename T , typename Map_t = std::map<G4int, T*>>
T * G4VTHitsMap< T, Map_t >::GetObject ( iterator  itr) const
inline

Definition at line 142 of file G4THitsMap.hh.

142{ return itr->second; }

◆ GetSDname()

const G4String & G4VHitsCollection::GetSDname ( ) const
inlineinherited

Definition at line 64 of file G4VHitsCollection.hh.

64{ return SDname; }

References G4VHitsCollection::SDname.

Referenced by G4SDManager::GetCollectionID().

◆ GetSize()

template<typename T , typename Map_t = std::map<G4int, T*>>
virtual size_t G4VTHitsMap< T, Map_t >::GetSize ( ) const
inlinevirtual

Reimplemented from G4VHitsCollection.

Definition at line 164 of file G4THitsMap.hh.

164{ return ((Map_t*) theCollection)->size(); }

References G4HitsCollection::theCollection.

◆ operator+=()

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U , typename MapU_t >
this_type & G4VTHitsMap< T, Map_t >::operator+= ( const G4VTHitsMap< U, MapU_t > &  right) const
inline

Definition at line 101 of file G4THitsMap.hh.

102 {
103 MapU_t* aHitsMap = right.GetMap();
104 for(auto itr = aHitsMap->begin(); itr != aHitsMap->end(); ++itr)
105 add<U, map_type>(itr->first, *(itr->second));
106 return (this_type&) (*this);
107 }
G4VTHitsMap< T, Map_t > this_type
Definition: G4THitsMap.hh:80

References G4VTHitsMap< T, Map_t >::GetMap().

◆ operator==() [1/3]

G4bool G4HitsCollection::operator== ( const G4HitsCollection right) const
inherited

Definition at line 61 of file G4THitsCollection.cc.

62{
65 return (collectionName == right.collectionName);
66}
G4Allocator< G4HitsCollection > *& anHCAllocator_G4MT_TLS_()

References anHCAllocator_G4MT_TLS_(), and G4VHitsCollection::collectionName.

◆ operator==() [2/3]

G4bool G4VHitsCollection::operator== ( const G4VHitsCollection right) const
inherited

Definition at line 49 of file G4VHitsCollection.cc.

50{
51 return ((collectionName == right.collectionName) && (SDname == right.SDname));
52}

References G4VHitsCollection::collectionName, and G4VHitsCollection::SDname.

◆ operator==() [3/3]

template<typename T , typename Map_t >
G4bool G4VTHitsMap< T, Map_t >::operator== ( const G4VTHitsMap< T, Map_t > &  right) const

Definition at line 486 of file G4THitsMap.hh.

488{
489 return (collectionName == right.collectionName);
490}

References G4VHitsCollection::collectionName.

◆ operator[]() [1/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename MapU_t = Map_t, enable_if_t<!is_mmap_t(MapU_t), G4int > = 0>
T * G4VTHitsMap< T, Map_t >::operator[] ( G4int  key) const
inline

Definition at line 417 of file G4THitsMap.hh.

418 {
419 map_type* theHitsMap = GetMap();
420 if(theHitsMap->find(key) != theHitsMap->end())
421 return theHitsMap->find(key)->second;
422 return nullptr;
423 }

References G4VTHitsMap< T, Map_t >::GetMap().

◆ operator[]() [2/2]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename MapU_t = Map_t, enable_if_t< is_mmap_t(MapU_t), G4int > = 0>
T * G4VTHitsMap< T, Map_t >::operator[] ( G4int  key) const
inline

Definition at line 426 of file G4THitsMap.hh.

427 {
428#ifdef G4VERBOSE
429 static bool _first = true;
430 if(_first)
431 {
432 _first = false;
433 G4Exception("G4THitsMap operator[]", "calling [] on multimap",
434 JustWarning, "Returning the last matching entry");
435 }
436#endif
437 map_type* theHitsMap = GetMap();
438 iterator itr = theHitsMap->find(key);
439 if(itr != theHitsMap->end())
440 {
441 std::advance(itr, theHitsMap->count(key) - 1);
442 return itr->second;
443 }
444 return nullptr;
445 }
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35

References G4Exception(), G4VTHitsMap< T, Map_t >::GetMap(), and JustWarning.

◆ PrintAllHits()

template<typename T , typename Map_t >
void G4VTHitsMap< T, Map_t >::PrintAllHits
virtual

Reimplemented from G4VHitsCollection.

Definition at line 503 of file G4THitsMap.hh.

504{
505 G4cout << "G4THitsMap " << SDname << " / " << collectionName << " --- "
506 << entries() << " entries" << G4endl;
507 /*----- commented out for the use-case where <T> cannot be initialized
508 to be zero or does not support += operator.
509 Map_t * theHitsMap = GetMap();
510 typename Map_t::iterator itr = theHitsMap->begin();
511 T sum = 0.;
512 for(; itr != theHitsMap->end(); ++itr) {
513 G4cout << " " << itr->first << " : "
514 << *(itr->second) << G4endl;
515 sum += *(itr->second);
516 }
517 G4cout << " Total : " << sum << G4endl;
518 ----------------------------------------------------------------------*/
519}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
size_t entries() const
Definition: G4THitsMap.hh:158

References G4cout, and G4endl.

◆ set() [1/8]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::set ( const G4int key,
U &  aHit 
) const
inline

Definition at line 351 of file G4THitsMap.hh.

352 {
353 map_type* theHitsMap = GetMap();
354 T* hit = nullptr;
355 if(theHitsMap->find(key) != theHitsMap->end())
356 hit = theHitsMap->find(key)->second;
357 else
358 theHitsMap->insert(pair_t(key, hit = allocate()));
359 *hit = aHit;
360 return theHitsMap->size();
361 }

References G4VTHitsMap< T, Map_t >::allocate(), and G4VTHitsMap< T, Map_t >::GetMap().

◆ set() [2/8]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::set ( const G4int key,
U &  aHit 
) const
inline

Definition at line 367 of file G4THitsMap.hh.

368 {
369 map_type* theHitsMap = GetMap();
370 if(theHitsMap->find(key) != theHitsMap->end())
371 *theHitsMap->find(key)->second = aHit;
372 else
373 theHitsMap->insert(pair_t(key, new T(aHit)));
374 return theHitsMap->size();
375 }

References G4VTHitsMap< T, Map_t >::GetMap().

◆ set() [3/8]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::set ( const G4int key,
U &  aHit 
) const
inline

Definition at line 381 of file G4THitsMap.hh.

382 {
383 map_type* theHitsMap = GetMap();
384 T* hit = nullptr;
385 if(theHitsMap->find(key) == theHitsMap->end())
386 theHitsMap->insert(std::make_pair(key, hit = allocate()));
387 else
388 hit = theHitsMap->find(key)->second;
389 *hit += aHit;
390 return theHitsMap->size();
391 }

References G4VTHitsMap< T, Map_t >::allocate(), and G4VTHitsMap< T, Map_t >::GetMap().

◆ set() [4/8]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::set ( const G4int key,
U &  aHit 
) const
inline

Definition at line 397 of file G4THitsMap.hh.

398 {
399 map_type* theHitsMap = GetMap();
400 T* hit = allocate();
401 *hit += aHit;
402 if(theHitsMap->find(key) != theHitsMap->end())
403 *theHitsMap->find(key)->second = *hit;
404 else
405 theHitsMap->insert(pair_t(key, hit));
406 return theHitsMap->size();
407 }

References G4VTHitsMap< T, Map_t >::allocate(), and G4VTHitsMap< T, Map_t >::GetMap().

◆ set() [5/8]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::set ( const G4int key,
U *&  aHit 
) const
inline

Definition at line 280 of file G4THitsMap.hh.

281 {
282 map_type* theHitsMap = GetMap();
283 if(theHitsMap->find(key) != theHitsMap->end())
284 delete theHitsMap->find(key)->second;
285 theHitsMap->find(key)->second = aHit;
286 return theHitsMap->size();
287 }

References G4VTHitsMap< T, Map_t >::GetMap().

Referenced by G4PSMinKinEAtGeneration::ProcessHits().

◆ set() [6/8]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::set ( const G4int key,
U *&  aHit 
) const
inline

Definition at line 293 of file G4THitsMap.hh.

294 {
295 map_type* theHitsMap = GetMap();
296 if(theHitsMap->find(key) != theHitsMap->end())
297 theHitsMap->insert(pair_t(key, aHit));
298 else
299 {
300 delete theHitsMap->find(key)->second;
301 theHitsMap->find(key)->second = aHit;
302 }
303 return theHitsMap->size();
304 }

References G4VTHitsMap< T, Map_t >::GetMap().

◆ set() [7/8]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&!is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::set ( const G4int key,
U *&  aHit 
) const
inline

Definition at line 310 of file G4THitsMap.hh.

311 {
312 map_type* theHitsMap = GetMap();
313 T* hit = nullptr;
314 if(theHitsMap->find(key) == theHitsMap->end())
315 theHitsMap->insert(std::make_pair(key, hit = allocate()));
316 else
317 hit = theHitsMap->find(key)->second;
318 *hit += *aHit;
319 return theHitsMap->size();
320 }

References G4VTHitsMap< T, Map_t >::allocate(), and G4VTHitsMap< T, Map_t >::GetMap().

◆ set() [8/8]

template<typename T , typename Map_t = std::map<G4int, T*>>
template<typename U = T, typename MapU_t = Map_t, enable_if_t<(!is_same_t(U, T) &&is_mmap_t(MapU_t)), G4int > = 0>
size_t G4VTHitsMap< T, Map_t >::set ( const G4int key,
U *&  aHit 
) const
inline

Definition at line 326 of file G4THitsMap.hh.

327 {
328 map_type* theHitsMap = GetMap();
329 T* hit = allocate();
330 *hit += *aHit;
331 if(theHitsMap->find(key) != theHitsMap->end())
332 theHitsMap->insert(pair_t(key, hit));
333 else
334 {
335 delete theHitsMap->find(key)->second;
336 theHitsMap->find(key)->second = hit;
337 }
338 return theHitsMap->size();
339 }

References G4VTHitsMap< T, Map_t >::allocate(), and G4VTHitsMap< T, Map_t >::GetMap().

◆ SetColID()

void G4VHitsCollection::SetColID ( G4int  i)
inlineinherited

Definition at line 65 of file G4VHitsCollection.hh.

65{ colID = i; }

References G4VHitsCollection::colID.

Referenced by G4HCofThisEvent::AddHitsCollection().

◆ size()

template<typename T , typename Map_t = std::map<G4int, T*>>
Map_t::size_type G4VTHitsMap< T, Map_t >::size ( )
inline

Definition at line 120 of file G4THitsMap.hh.

120{ return GetContainer()->size(); }

References G4VTHitsMap< T, Map_t >::GetContainer().

Field Documentation

◆ colID

G4int G4VHitsCollection::colID
protectedinherited

◆ collectionName

G4String G4VHitsCollection::collectionName
protectedinherited

◆ SDname

G4String G4VHitsCollection::SDname
protectedinherited

◆ theCollection

void* G4HitsCollection::theCollection
protectedinherited

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