Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4THitsMap< T > Class Template Reference

#include <G4THitsMap.hh>

Inheritance diagram for G4THitsMap< T >:
Collaboration diagram for G4THitsMap< T >:

Public Member Functions

 G4THitsMap ()
 
 G4THitsMap (G4String detName, G4String colNam)
 
virtual ~G4THitsMap ()
 
G4int operator== (const G4THitsMap< T > &right) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4THitsMap< T > & operator+= (const G4THitsMap< T > &right) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4THitsMap< T > & operator+= (const G4THitsMap< U > &right) const
 
virtual void DrawAllHits ()
 
virtual void PrintAllHits ()
 
T * operator[] (G4int key) const
 
std::map< G4int, T * > * GetMap () const
 
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4int add (const G4int &key, T *&aHit) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4int add (const G4int &key, T &aHit) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4int add (const G4int &key, U *&aHit) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4int add (const G4int &key, U &aHit) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4int set (const G4int &key, T *&aHit) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4int set (const G4int &key, T &aHit) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4int set (const G4int &key, U *&aHit) const
 
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4int set (const G4int &key, U &aHit) const
 
G4int entries () const
 
void clear ()
 
virtual G4VHitGetHit (size_t) const
 
virtual size_t GetSize () const
 
- Public Member Functions inherited from G4HitsCollection
 G4HitsCollection ()
 
 G4HitsCollection (G4String detName, G4String colNam)
 
virtual ~G4HitsCollection ()
 
G4int operator== (const G4HitsCollection &right) const
 
 G4HitsCollection ()
 
 G4HitsCollection (G4String detName, G4String colNam)
 
virtual ~G4HitsCollection ()
 
G4int operator== (const G4HitsCollection &right) const
 
 G4HitsCollection ()
 
 G4HitsCollection (G4String detName, G4String colNam)
 
virtual ~G4HitsCollection ()
 
G4int operator== (const G4HitsCollection &right) const
 
- Public Member Functions inherited from G4VHitsCollection
 G4VHitsCollection ()
 
 G4VHitsCollection (G4String detName, G4String colNam)
 
virtual ~G4VHitsCollection ()
 
G4int operator== (const G4VHitsCollection &right) const
 
G4String GetName ()
 
G4String GetSDname ()
 
 G4VHitsCollection ()
 
 G4VHitsCollection (G4String detName, G4String colNam)
 
virtual ~G4VHitsCollection ()
 
G4int operator== (const G4VHitsCollection &right) const
 
G4String GetName ()
 
G4String GetSDname ()
 
 G4VHitsCollection ()
 
 G4VHitsCollection (G4String detName, G4String colNam)
 
virtual ~G4VHitsCollection ()
 
G4int operator== (const G4VHitsCollection &right) const
 
G4StringGetName ()
 
G4StringGetSDname ()
 
void SetColID (G4int i)
 
G4int GetColID () const
 

Additional Inherited Members

- Protected Attributes inherited from G4HitsCollection
voidtheCollection
 
- Protected Attributes inherited from G4VHitsCollection
G4String collectionName
 
G4String SDname
 
G4int colID
 

Detailed Description

template<typename T>
class G4THitsMap< T >

Definition at line 48 of file G4THitsMap.hh.

Constructor & Destructor Documentation

template<typename T >
G4THitsMap< T >::G4THitsMap ( )

Definition at line 213 of file G4THitsMap.hh.

214 {
215  theCollection = (void*)new std::map<G4int,T*>;
216 }
template<typename T >
G4THitsMap< T >::G4THitsMap ( G4String  detName,
G4String  colNam 
)

Definition at line 218 of file G4THitsMap.hh.

219  : G4HitsCollection(detName,colNam)
220 {
221  theCollection = (void*)new std::map<G4int,T*>;
222 }
template<typename T >
G4THitsMap< T >::~G4THitsMap ( )
virtual

Definition at line 224 of file G4THitsMap.hh.

225 {
226  typename std::map<G4int,T*> * theHitsMap = GetMap();
227  typename std::map<G4int,T*>::iterator itr = theHitsMap->begin();
228  for(; itr != theHitsMap->end(); itr++) {
229  delete itr->second;
230  }
231 
232  delete theHitsMap;
233 }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99

Member Function Documentation

template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4int G4THitsMap< T >::add ( const G4int key,
T *&  aHit 
) const
inline

Definition at line 106 of file G4THitsMap.hh.

107  {
108  typename std::map<G4int,T*> * theHitsMap = GetMap();
109  if(theHitsMap->find(key) != theHitsMap->end()) {
110  *(*theHitsMap)[key] += *aHit;
111  } else {
112  (*theHitsMap)[key] = aHit;
113  }
114  return theHitsMap->size();
115  }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99

Here is the caller graph for this function:

template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4int G4THitsMap< T >::add ( const G4int key,
T &  aHit 
) const
inline

Definition at line 118 of file G4THitsMap.hh.

119  {
120  typename std::map<G4int,T*> * theHitsMap = GetMap();
121  if(theHitsMap->find(key) == theHitsMap->end()) {
122  (*theHitsMap)[key] = new T(0.);
123  }
124  *(*theHitsMap)[key] += aHit;
125  return theHitsMap->size();
126  }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4int G4THitsMap< T >::add ( const G4int key,
U *&  aHit 
) const
inline

Definition at line 130 of file G4THitsMap.hh.

131  {
132  typename std::map<G4int,T*> * theHitsMap = GetMap();
133  if(theHitsMap->find(key) == theHitsMap->end()) {
134  (*theHitsMap)[key] = new T(0.);
135  }
136  *(*theHitsMap)[key] += *aHit;
137  return theHitsMap->size();
138  }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4int G4THitsMap< T >::add ( const G4int key,
U &  aHit 
) const
inline

Definition at line 142 of file G4THitsMap.hh.

143  {
144  typename std::map<G4int,T*> * theHitsMap = GetMap();
145  if(theHitsMap->find(key) == theHitsMap->end()) {
146  (*theHitsMap)[key] = new T(0.);
147  }
148  *(*theHitsMap)[key] += aHit;
149  return theHitsMap->size();
150  }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
template<typename T >
void G4THitsMap< T >::clear ( void  )
inline

Definition at line 267 of file G4THitsMap.hh.

267  {
268 
269  std::map<G4int,T*> * theHitsMap = GetMap();
270  typename std::map<G4int, T*>::iterator itr = theHitsMap->begin();
271  for(; itr != theHitsMap->end(); itr++) {
272  delete itr->second;
273  }
274  theHitsMap->clear();
275 
276 }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99

Here is the caller graph for this function:

template<typename T >
void G4THitsMap< T >::DrawAllHits ( )
virtual

Reimplemented from G4VHitsCollection.

Definition at line 248 of file G4THitsMap.hh.

249 {;}
template<typename T>
G4int G4THitsMap< T >::entries ( ) const
inline

Definition at line 200 of file G4THitsMap.hh.

201  { return ((std::map<G4int,T*>*)theCollection)->size(); }

Here is the caller graph for this function:

template<typename T>
virtual G4VHit* G4THitsMap< T >::GetHit ( size_t  ) const
inlinevirtual

Reimplemented from G4VHitsCollection.

Definition at line 207 of file G4THitsMap.hh.

207 {return 0;}
template<typename T>
std::map<G4int,T*>* G4THitsMap< T >::GetMap ( ) const
inline

Definition at line 99 of file G4THitsMap.hh.

100  { return (std::map<G4int,T*>*)theCollection; }
template<typename T>
virtual size_t G4THitsMap< T >::GetSize ( ) const
inlinevirtual

Reimplemented from G4VHitsCollection.

Definition at line 208 of file G4THitsMap.hh.

209  { return ((std::map<G4int,T*>*)theCollection)->size(); }

Here is the caller graph for this function:

template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4THitsMap<T>& G4THitsMap< T >::operator+= ( const G4THitsMap< T > &  right) const
inline

Definition at line 63 of file G4THitsMap.hh.

64  {
65  std::map<G4int,T*> * aHitsMap = right.GetMap();
66  typename std::map<G4int,T*>::iterator itr = aHitsMap->begin();
67  for(; itr != aHitsMap->end(); itr++) {
68  add(itr->first, *(itr->second));
69  }
70  return (G4THitsMap<T>&)(*this);
71  }
G4int add(const G4int &key, T *&aHit) const
Definition: G4THitsMap.hh:106
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4THitsMap<T>& G4THitsMap< T >::operator+= ( const G4THitsMap< U > &  right) const
inline

Definition at line 76 of file G4THitsMap.hh.

77  {
78  std::map<G4int,U*> * aHitsMap = right.GetMap();
79  typename std::map<G4int,U*>::iterator itr = aHitsMap->begin();
80  for(; itr != aHitsMap->end(); itr++) {
81  typename std::map<G4int,T*>::iterator mapItr = this->GetMap()->find(itr->first);
82  if(mapItr==this->GetMap()->end())
83  { (*this->GetMap())[itr->first] = new T(0.); }
84  add(itr->first, *(itr->second));
85  }
86  return (G4THitsMap<T>&)(*this);
87  }
G4int add(const G4int &key, T *&aHit) const
Definition: G4THitsMap.hh:106
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
template<typename T>
G4int G4THitsMap< T >::operator== ( const G4THitsMap< T > &  right) const

Definition at line 235 of file G4THitsMap.hh.

236 { return (collectionName==right.collectionName); }
template<typename T >
T * G4THitsMap< T >::operator[] ( G4int  key) const
inline

Definition at line 239 of file G4THitsMap.hh.

239  {
240  std::map<G4int,T*> * theHitsMap = GetMap();
241  if(theHitsMap->find(key) != theHitsMap->end()) {
242  return theHitsMap->find(key)->second;
243  } else {
244  return 0;
245  }
246 }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
template<typename T >
void G4THitsMap< T >::PrintAllHits ( )
virtual

Reimplemented from G4VHitsCollection.

Definition at line 251 of file G4THitsMap.hh.

252 {
253  G4cout << "G4THitsMap " << SDname << " / " << collectionName << " --- " << entries() << " entries" << G4endl;
254 /*----- commented out for the use-case where <T> cannot be initialized
255  to be zero or does not support += operator.
256  std::map<G4int,T*> * theHitsMap = GetMap();
257  typename std::map<G4int, T*>::iterator itr = theHitsMap->begin();
258  T sum = 0.;
259  for(; itr != theHitsMap->end(); itr++) {
261  sum += *(itr->second);
262  }
263  G4cout << " Total : " << sum << G4endl;
264 ----------------------------------------------------------------------*/
265 }
G4GLOB_DLL std::ostream G4cout
G4int entries() const
Definition: G4THitsMap.hh:200
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4int G4THitsMap< T >::set ( const G4int key,
T *&  aHit 
) const
inline

Definition at line 156 of file G4THitsMap.hh.

157  {
158  typename std::map<G4int,T*> * theHitsMap = GetMap();
159  if(theHitsMap->find(key) != theHitsMap->end()) {
160  delete (*theHitsMap)[key]->second;
161  }
162  (*theHitsMap)[key] = aHit;
163  return theHitsMap->size();
164  }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99

Here is the caller graph for this function:

template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, T >::value, int >::type = 0>
G4int G4THitsMap< T >::set ( const G4int key,
T &  aHit 
) const
inline

Definition at line 167 of file G4THitsMap.hh.

168  {
169  typename std::map<G4int,T*> * theHitsMap = GetMap();
170  if(theHitsMap->find(key) == theHitsMap->end())
171  { (*theHitsMap)[key] = new T(0.); }
172  *(*theHitsMap)[key] = aHit;
173  return theHitsMap->size();
174  }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4int G4THitsMap< T >::set ( const G4int key,
U *&  aHit 
) const
inline

Definition at line 178 of file G4THitsMap.hh.

179  {
180  typename std::map<G4int,T*> * theHitsMap = GetMap();
181  if(theHitsMap->find(key) != theHitsMap->end()) {
182  delete (*theHitsMap)[key]->second;
183  }
184  (*theHitsMap)[key] = aHit;
185  return theHitsMap->size();
186  }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
template<typename T>
template<typename U = T, typename std::enable_if< std::is_same< U, G4double >::value &&std::is_same< T, G4StatDouble >::value, int >::type = 0>
G4int G4THitsMap< T >::set ( const G4int key,
U &  aHit 
) const
inline

Definition at line 190 of file G4THitsMap.hh.

191  {
192  typename std::map<G4int,T*> * theHitsMap = GetMap();
193  if(theHitsMap->find(key) == theHitsMap->end())
194  { (*theHitsMap)[key] = new T(0.); }
195  *(*theHitsMap)[key] = aHit;
196  return theHitsMap->size();
197  }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99

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