Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
+132 -74
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4THitsMap.hh 67992 2013-03-13 10:59:57Z gcosmo $
// $Id: G4THitsMap.hh 99262 2016-09-09 13:18:19Z gcosmo $
//
#ifndef G4THitsMap_h
#define G4THitsMap_h 1
@@ -33,6 +33,8 @@
#include "globals.hh"
#include <map>
class G4StatDouble;
// class description:
//
// This is a template class of hits map and parametrized by
@@ -53,7 +55,36 @@ template <typename T> class G4THitsMap : public G4HitsCollection
public:
virtual ~G4THitsMap();
G4int operator==(const G4THitsMap<T> &right) const;
G4THitsMap<T> & operator+=(const G4THitsMap<T> &right) const;
public: // with description
// Operator += between same kind of classes
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
{
std::map<G4int,T*> * aHitsMap = right.GetMap();
typename std::map<G4int,T*>::iterator itr = aHitsMap->begin();
for(; itr != aHitsMap->end(); itr++) {
add(itr->first, *(itr->second));
}
return (G4THitsMap<T>&)(*this);
}
// Operator for G4THitsMap<G4StatDouble> += G4THitsMap<G4double>
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
{
std::map<G4int,U*> * aHitsMap = right.GetMap();
typename std::map<G4int,U*>::iterator itr = aHitsMap->begin();
for(; itr != aHitsMap->end(); itr++) {
typename std::map<G4int,T*>::iterator mapItr = this->GetMap()->find(itr->first);
if(mapItr==this->GetMap()->end())
{ (*this->GetMap())[itr->first] = new T(0.); }
add(itr->first, *(itr->second));
}
return (G4THitsMap<T>&)(*this);
}
public: // with description
virtual void DrawAllHits();
@@ -62,23 +93,114 @@ template <typename T> class G4THitsMap : public G4HitsCollection
// hit objects stored in this map, respectively.
public: // with description
inline T* operator[](G4int key) const;
// Returns a pointer to a concrete hit object.
inline T* operator[](G4int key) const;
// Returns a collection map.
inline std::map<G4int,T*>* GetMap() const
{ return (std::map<G4int,T*>*)theCollection; }
// Returns a collection map.
inline G4int add(const G4int & key, T * &aHit) const;
inline G4int add(const G4int & key, T &aHit) const;
// Insert a hit object. Total number of hit objects stored in this
// map is returned.
inline G4int set(const G4int & key, T * &aHit) const;
inline 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>
inline G4int add(const G4int & key, T * &aHit) const
{
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) != theHitsMap->end()) {
*(*theHitsMap)[key] += *aHit;
} else {
(*theHitsMap)[key] = aHit;
}
return theHitsMap->size();
}
template <typename U = T,
typename std::enable_if<std::is_same<U,T>::value,int>::type=0>
inline G4int add(const G4int & key, T &aHit) const
{
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) == theHitsMap->end()) {
(*theHitsMap)[key] = new T(0.);
}
*(*theHitsMap)[key] += aHit;
return theHitsMap->size();
}
template <typename U = T,
typename std::enable_if<std::is_same<U,G4double>::value &&
std::is_same<T,G4StatDouble>::value,int>::type=0>
inline G4int add(const G4int & key, U * &aHit) const
{
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) == theHitsMap->end()) {
(*theHitsMap)[key] = new T(0.);
}
*(*theHitsMap)[key] += *aHit;
return theHitsMap->size();
}
template <typename U = T,
typename std::enable_if<std::is_same<U,G4double>::value &&
std::is_same<T,G4StatDouble>::value,int>::type=0>
inline G4int add(const G4int & key, U &aHit) const
{
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) == theHitsMap->end()) {
(*theHitsMap)[key] = new T(0.);
}
*(*theHitsMap)[key] += aHit;
return theHitsMap->size();
}
// Overwrite a hit object. Total number of hit objects stored in this
// map is returned.
template <typename U = T,
typename std::enable_if<std::is_same<U,T>::value,int>::type=0>
inline G4int set(const G4int & key, T * &aHit) const
{
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) != theHitsMap->end()) {
delete (*theHitsMap)[key]->second;
}
(*theHitsMap)[key] = aHit;
return theHitsMap->size();
}
template <typename U = T,
typename std::enable_if<std::is_same<U,T>::value,int>::type=0>
inline G4int set(const G4int & key, T &aHit) const
{
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) == theHitsMap->end())
{ (*theHitsMap)[key] = new T(0.); }
*(*theHitsMap)[key] = aHit;
return theHitsMap->size();
}
template <typename U = T,
typename std::enable_if<std::is_same<U,G4double>::value &&
std::is_same<T,G4StatDouble>::value,int>::type=0>
inline G4int set(const G4int & key, U * &aHit) const
{
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) != theHitsMap->end()) {
delete (*theHitsMap)[key]->second;
}
(*theHitsMap)[key] = aHit;
return theHitsMap->size();
}
template <typename U = T,
typename std::enable_if<std::is_same<U,G4double>::value &&
std::is_same<T,G4StatDouble>::value,int>::type=0>
inline G4int set(const G4int & key, U &aHit) const
{
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) == theHitsMap->end())
{ (*theHitsMap)[key] = new T(0.); }
*(*theHitsMap)[key] = aHit;
return theHitsMap->size();
}
// Returns the number of hit objects stored in this map
inline G4int entries() const
{ return ((std::map<G4int,T*>*)theCollection)->size(); }
// Returns the number of hit objects stored in this map
// Clear the entry
inline void clear();
public:
@@ -113,17 +235,6 @@ template <typename T> G4THitsMap<T>::~G4THitsMap()
template <typename T> G4int G4THitsMap<T>::operator==(const G4THitsMap<T> &right) const
{ return (collectionName==right.collectionName); }
template <typename T> G4THitsMap<T> &
G4THitsMap<T>::operator+=(const G4THitsMap<T> &right) const
{
std::map<G4int,T*> * aHitsMap = right.GetMap();
typename std::map<G4int,T*>::iterator itr = aHitsMap->begin();
for(; itr != aHitsMap->end(); itr++) {
add(itr->first, *(itr->second));
}
return (G4THitsMap<T>&)(*this);
}
template <typename T> inline T*
G4THitsMap<T>::operator[](G4int key) const {
std::map<G4int,T*> * theHitsMap = GetMap();
@@ -134,59 +245,6 @@ G4THitsMap<T>::operator[](G4int key) const {
}
}
template <typename T> inline G4int
G4THitsMap<T>::add(const G4int & key, T * &aHit) const {
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) != theHitsMap->end()) {
*(*theHitsMap)[key] += *aHit;
} else {
(*theHitsMap)[key] = aHit;
}
return theHitsMap->size();
}
template <typename T> inline G4int
G4THitsMap<T>::add(const G4int & key, T &aHit) const {
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) != theHitsMap->end()) {
*(*theHitsMap)[key] += aHit;
} else {
T * hit = new T;
*hit = aHit;
(*theHitsMap)[key] = hit;
}
return theHitsMap->size();
}
template <typename T> inline G4int
G4THitsMap<T>::set(const G4int & key, T * &aHit) const {
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) != theHitsMap->end()) {
delete (*theHitsMap)[key]->second;
}
(*theHitsMap)[key] = aHit;
return theHitsMap->size();
}
template <typename T> inline G4int
G4THitsMap<T>::set(const G4int & key, T &aHit) const {
typename std::map<G4int,T*> * theHitsMap = GetMap();
if(theHitsMap->find(key) != theHitsMap->end()) {
*(*theHitsMap)[key] = aHit;
} else {
T * hit = new T;
*hit = aHit;
(*theHitsMap)[key] = hit;
}
return theHitsMap->size();
}
template <typename T> void G4THitsMap<T>::DrawAllHits()
{;}