Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -42,9 +42,6 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef G4TAtomicHitsMap_h
|
||||
#define G4TAtomicHitsMap_h 1
|
||||
|
||||
@@ -71,68 +68,61 @@
|
||||
template <typename T>
|
||||
class G4TAtomicHitsMap : public G4VHitsCollection
|
||||
{
|
||||
protected:
|
||||
protected:
|
||||
static_assert(std::is_fundamental<T>::value,
|
||||
"G4TAtomicHitsMap must use fundamental type");
|
||||
|
||||
public:
|
||||
typedef G4atomic<T> value_type;
|
||||
typedef value_type* mapped_type;
|
||||
typedef typename std::map<G4int, mapped_type> container_type;
|
||||
typedef typename container_type::iterator iterator;
|
||||
public:
|
||||
typedef G4atomic<T> value_type;
|
||||
typedef value_type* mapped_type;
|
||||
typedef typename std::map<G4int, mapped_type> container_type;
|
||||
typedef typename container_type::iterator iterator;
|
||||
typedef typename container_type::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
public:
|
||||
G4TAtomicHitsMap();
|
||||
|
||||
public: // with description
|
||||
public: // with description
|
||||
G4TAtomicHitsMap(G4String detName, G4String colNam);
|
||||
// constructor.
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual ~G4TAtomicHitsMap();
|
||||
G4bool operator==(const G4TAtomicHitsMap<T> &right) const;
|
||||
G4TAtomicHitsMap<T> & operator+=(const G4TAtomicHitsMap<T> &right) const;
|
||||
G4TAtomicHitsMap<T> & operator+=(const G4THitsMap<T> &right) const;
|
||||
G4bool operator==(const G4TAtomicHitsMap<T>& right) const;
|
||||
G4TAtomicHitsMap<T>& operator+=(const G4TAtomicHitsMap<T>& right) const;
|
||||
G4TAtomicHitsMap<T>& operator+=(const G4THitsMap<T>& right) const;
|
||||
|
||||
public: // with description
|
||||
public: // with description
|
||||
virtual void DrawAllHits();
|
||||
virtual void PrintAllHits();
|
||||
// These two methods invokes Draw() and Print() methods of all of
|
||||
// hit objects stored in this map, respectively.
|
||||
|
||||
public: // with description
|
||||
public: // with description
|
||||
inline value_type* operator[](G4int key) const;
|
||||
|
||||
// Returns a pointer to a concrete hit object.
|
||||
inline container_type* GetMap() const
|
||||
{ return theCollection; }
|
||||
inline container_type* GetMap() const { return theCollection; }
|
||||
// Returns a collection map.
|
||||
inline G4int add(const G4int & key, value_type*& aHit) const;
|
||||
inline G4int add(const G4int & key, T& aHit) const;
|
||||
inline G4int add(const G4int& key, value_type*& 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, value_type*& aHit) const;
|
||||
inline G4int set(const G4int & key, T& aHit) const;
|
||||
inline G4int set(const G4int& key, value_type*& aHit) const;
|
||||
inline G4int set(const G4int& key, T& aHit) const;
|
||||
// Overwrite a hit object. Total number of hit objects stored in this
|
||||
// map is returned.
|
||||
inline G4int entries() const
|
||||
{
|
||||
return theCollection->size();
|
||||
}
|
||||
inline G4int entries() const { return theCollection->size(); }
|
||||
// Returns the number of hit objects stored in this map
|
||||
inline void clear();
|
||||
|
||||
public:
|
||||
virtual G4VHit* GetHit(size_t) const {return 0;}
|
||||
virtual size_t GetSize() const
|
||||
{
|
||||
return theCollection->size();
|
||||
}
|
||||
public:
|
||||
virtual G4VHit* GetHit(size_t) const { return 0; }
|
||||
virtual size_t GetSize() const { return theCollection->size(); }
|
||||
|
||||
virtual size_t size() const { return theCollection->size(); }
|
||||
|
||||
public:
|
||||
public:
|
||||
iterator begin() { return theCollection->begin(); }
|
||||
iterator end() { return theCollection->end(); }
|
||||
|
||||
@@ -145,63 +135,62 @@ public:
|
||||
iterator find(G4int p) { return theCollection->find(p); }
|
||||
const_iterator find(G4int p) const { return theCollection->find(p); }
|
||||
|
||||
private:
|
||||
container_type* theCollection;
|
||||
mutable G4Mutex fMutex;
|
||||
|
||||
private:
|
||||
container_type* theCollection;
|
||||
mutable G4Mutex fMutex;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
G4TAtomicHitsMap<T>::G4TAtomicHitsMap()
|
||||
: theCollection(new container_type)
|
||||
{ }
|
||||
{}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
G4TAtomicHitsMap<T>::G4TAtomicHitsMap(G4String detName,
|
||||
G4String colNam)
|
||||
: G4VHitsCollection(detName,colNam),
|
||||
theCollection(new container_type)
|
||||
{ }
|
||||
G4TAtomicHitsMap<T>::G4TAtomicHitsMap(G4String detName, G4String colNam)
|
||||
: G4VHitsCollection(detName, colNam)
|
||||
, theCollection(new container_type)
|
||||
{}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
G4TAtomicHitsMap<T>::~G4TAtomicHitsMap()
|
||||
{
|
||||
for(auto itr = theCollection->begin(); itr != theCollection->end(); itr++)
|
||||
delete itr->second;
|
||||
delete itr->second;
|
||||
|
||||
delete theCollection;
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
G4bool G4TAtomicHitsMap<T>::operator==(const G4TAtomicHitsMap<T> &right) const
|
||||
G4bool G4TAtomicHitsMap<T>::operator==(const G4TAtomicHitsMap<T>& right) const
|
||||
{
|
||||
return (collectionName == right.collectionName);
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
G4TAtomicHitsMap<T>&
|
||||
G4TAtomicHitsMap<T>::operator+=(const G4TAtomicHitsMap<T>& rhs) const
|
||||
G4TAtomicHitsMap<T>& G4TAtomicHitsMap<T>::operator+=(
|
||||
const G4TAtomicHitsMap<T>& rhs) const
|
||||
{
|
||||
for(auto itr = rhs.GetMap()->begin(); itr != rhs.GetMap()->end(); itr++)
|
||||
add(itr->first, *(itr->second));
|
||||
|
||||
return (G4TAtomicHitsMap<T>&)(*this);
|
||||
return (G4TAtomicHitsMap<T>&) (*this);
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
G4TAtomicHitsMap<T>&
|
||||
G4TAtomicHitsMap<T>::operator+=(const G4THitsMap<T>& rhs) const
|
||||
G4TAtomicHitsMap<T>& G4TAtomicHitsMap<T>::operator+=(
|
||||
const G4THitsMap<T>& rhs) const
|
||||
{
|
||||
for(auto itr = rhs.GetMap()->begin(); itr != rhs.GetMap()->end(); itr++)
|
||||
add(itr->first, *(itr->second));
|
||||
|
||||
return (G4TAtomicHitsMap<T>&)(*this);
|
||||
return (G4TAtomicHitsMap<T>&) (*this);
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
inline typename G4TAtomicHitsMap<T>::value_type*
|
||||
G4TAtomicHitsMap<T>::operator[](G4int key) const
|
||||
inline
|
||||
typename G4TAtomicHitsMap<T>::value_type* G4TAtomicHitsMap<T>::operator[](
|
||||
G4int key) const
|
||||
{
|
||||
if(theCollection->find(key) != theCollection->end())
|
||||
return theCollection->find(key)->second;
|
||||
@@ -210,17 +199,17 @@ G4TAtomicHitsMap<T>::operator[](G4int key) const
|
||||
G4AutoLock l(&fMutex);
|
||||
if(theCollection->find(key) == theCollection->end())
|
||||
{
|
||||
value_type* ptr = new value_type;
|
||||
value_type* ptr = new value_type;
|
||||
(*theCollection)[key] = ptr;
|
||||
return ptr;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return theCollection->find(key)->second;
|
||||
}
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
inline G4int
|
||||
G4TAtomicHitsMap<T>::add(const G4int& key, value_type*& aHit) const
|
||||
inline G4int G4TAtomicHitsMap<T>::add(const G4int& key, value_type*& aHit) const
|
||||
{
|
||||
if(theCollection->find(key) != theCollection->end())
|
||||
*(*theCollection)[key] += *aHit;
|
||||
@@ -234,16 +223,14 @@ G4TAtomicHitsMap<T>::add(const G4int& key, value_type*& aHit) const
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
inline G4int
|
||||
G4TAtomicHitsMap<T>::add(const G4int& key, T& aHit) const
|
||||
inline G4int G4TAtomicHitsMap<T>::add(const G4int& key, T& aHit) const
|
||||
{
|
||||
|
||||
if(theCollection->find(key) != theCollection->end())
|
||||
*(*theCollection)[key] += aHit;
|
||||
else
|
||||
{
|
||||
value_type* hit = new value_type;
|
||||
*hit = aHit;
|
||||
*hit = aHit;
|
||||
G4AutoLock l(&fMutex);
|
||||
(*theCollection)[key] = hit;
|
||||
}
|
||||
@@ -252,11 +239,10 @@ G4TAtomicHitsMap<T>::add(const G4int& key, T& aHit) const
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
inline G4int
|
||||
G4TAtomicHitsMap<T>::set(const G4int& key, value_type*& aHit) const
|
||||
inline G4int G4TAtomicHitsMap<T>::set(const G4int& key, value_type*& aHit) const
|
||||
{
|
||||
if(theCollection->find(key) != theCollection->end())
|
||||
delete (*theCollection)[key]->second;
|
||||
delete(*theCollection)[key]->second;
|
||||
|
||||
(*theCollection)[key] = aHit;
|
||||
G4AutoLock l(&fMutex);
|
||||
@@ -264,24 +250,23 @@ G4TAtomicHitsMap<T>::set(const G4int& key, value_type*& aHit) const
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
inline G4int
|
||||
G4TAtomicHitsMap<T>::set(const G4int& key, T& aHit) const
|
||||
inline G4int G4TAtomicHitsMap<T>::set(const G4int& key, T& aHit) const
|
||||
{
|
||||
if(theCollection->find(key) != theCollection->end())
|
||||
*(*theCollection)[key] = aHit;
|
||||
else
|
||||
{
|
||||
value_type* hit = new value_type;
|
||||
*hit = aHit;
|
||||
(*theCollection)[key] = hit;
|
||||
}
|
||||
G4AutoLock l(&fMutex);
|
||||
return theCollection->size();
|
||||
if(theCollection->find(key) != theCollection->end())
|
||||
*(*theCollection)[key] = aHit;
|
||||
else
|
||||
{
|
||||
value_type* hit = new value_type;
|
||||
*hit = aHit;
|
||||
(*theCollection)[key] = hit;
|
||||
}
|
||||
G4AutoLock l(&fMutex);
|
||||
return theCollection->size();
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
void G4TAtomicHitsMap<T>::DrawAllHits()
|
||||
{ }
|
||||
{}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
template <typename T>
|
||||
void G4TAtomicHitsMap<T>::PrintAllHits()
|
||||
@@ -299,7 +284,6 @@ void G4TAtomicHitsMap<T>::clear()
|
||||
delete itr->second;
|
||||
|
||||
theCollection->clear();
|
||||
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
Reference in New Issue
Block a user