DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Generic hit container class using Geant4HitWrapper objects. More...
#include <Geant4HitCollection.h>
Classes | |
union | CollectionFlags |
Union defining the hit collection flags for processing. More... | |
class | Compare |
Generic class template to compare/select hits in Geant4HitCollection objects. More... | |
Public Types | |
enum | OptimizationFlags { OPTIMIZE_NONE = 0, OPTIMIZE_REPEATEDLOOKUP = 1<<0, OPTIMIZE_MAPPEDLOOKUP = 1<<1, OPTIMIZE_LAST } |
Enumeration for collection optimization types. More... | |
typedef std::vector< Geant4HitWrapper > | WrappedHits |
Hit wrapper. More... | |
typedef Geant4HitWrapper::HitManipulator | Manip |
Hit manipulator. More... | |
typedef std::map< VolumeID, size_t > | Keys |
Hit key map for fast random lookup. More... | |
Public Member Functions | |
template<typename TYPE > | |
Geant4HitCollection (const std::string &det, const std::string &coll, Geant4Sensitive *sd) | |
Initializing constructor (C++ version) More... | |
template<typename TYPE > | |
Geant4HitCollection (const std::string &det, const std::string &coll, Geant4Sensitive *sd, const TYPE *) | |
Initializing constructor. More... | |
virtual | ~Geant4HitCollection () |
Default destructor. More... | |
const ComponentCast & | type () const |
Type information of the object stored. More... | |
const ComponentCast & | vector_type () const |
Type information of the vector type for extracting data. More... | |
virtual void | clear () |
Clear the collection (Deletes all valid references to real hits) More... | |
void | setOptimize (int flag) |
Set optimization flags. More... | |
void | setSensitive (Geant4Sensitive *detector) |
Set the sensitive detector. More... | |
Geant4Sensitive * | sensitive () const |
Access the sensitive detector. More... | |
virtual G4VHit * | GetHit (size_t which) const override |
Access individual hits. More... | |
virtual size_t | GetSize () const override |
Access the collection size. More... | |
Geant4HitWrapper & | hit (size_t which) |
Access the hit wrapper. More... | |
const Geant4HitWrapper & | hit (size_t which) const |
Access the hit wrapper (CONST) More... | |
template<typename TYPE > | |
void | add (TYPE *hit_pointer) |
Add a new hit with a check, that the hit is of the same type. More... | |
template<typename TYPE > | |
void | add (VolumeID key, TYPE *hit_pointer) |
Add a new hit with a check, that the hit is of the same type. More... | |
template<typename TYPE > | |
TYPE * | find (const Compare &cmp) |
Find hits in a collection by comparison of attributes. More... | |
template<typename TYPE > | |
TYPE * | findByKey (VolumeID key) |
Find hits in a collection by comparison of key value. More... | |
template<typename TYPE > | |
std::vector< TYPE * > | releaseHits () |
Release all hits from the Geant4 container and pass ownership to the caller. More... | |
void | releaseHitsUnchecked (std::vector< void * > &result) |
Release all hits from the Geant4 container and pass ownership to the caller. More... | |
template<typename TYPE > | |
std::vector< TYPE * > | getHits () |
Release all hits from the Geant4 container. Ownership stays with the container. More... | |
void | getHitsUnchecked (std::vector< void * > &result) |
Release all hits from the Geant4 container. Ownership stays with the container. More... | |
Protected Member Functions | |
void | newInstance () |
Notification to increase the instance counter. More... | |
void * | findHit (const Compare &cmp) |
Find hit in a collection by comparison of attributes. More... | |
Geant4HitWrapper * | findHitByKey (VolumeID key) |
Find hit in a collection by comparison of the key. More... | |
void | releaseData (const ComponentCast &cast, std::vector< void * > *result) |
Release all hits from the Geant4 container and pass ownership to the caller. More... | |
void | getData (const ComponentCast &cast, std::vector< void * > *result) |
Release all hits from the Geant4 container. Ownership stays with the container. More... | |
Protected Attributes | |
WrappedHits | m_hits |
The collection of hit pointers in the wrapped format. More... | |
Geant4Sensitive * | m_detector |
Handle to the sensitive detector. More... | |
Manip * | m_manipulator |
The type of the objects in this collection. Set by the constructor. More... | |
size_t | m_lastHit |
Memorize for speedup the last searched hit. More... | |
Keys | m_keys |
Hit key map for fast random lookup. More... | |
CollectionFlags | m_flags |
Optimization flags. More... | |
Generic hit container class using Geant4HitWrapper objects.
Opaque hit collection. This hit collection is for good reasons homomorph, Polymorphism without an explicit type would only confuse most users.
Note: This hit collection is optimized to search repeatedly the same cell using
template <typename TYPE> TYPE* find(const Compare& cmp) const;
by remembering the last search index. The collection uses this optimization if the corresponding flag OPTIMIZE_REPEATEDLOOKUP is set:
setOptimize(OPTIMIZE_REPEATEDLOOKUP);
The last search index is automatically set to last object insertion, if one happened between 2 search calls. For the typical use case, there always contributions to the same hit are added, this should reduce the lookup speed from O(n) to O(1). This obviously only helps, if contributions to the same cell come in sequence ie. from the same G4Track.
Definition at line 201 of file Geant4HitCollection.h.
typedef std::map<VolumeID, size_t> dd4hep::sim::Geant4HitCollection::Keys |
Hit key map for fast random lookup.
Definition at line 209 of file Geant4HitCollection.h.
Hit manipulator.
Definition at line 207 of file Geant4HitCollection.h.
typedef std::vector<Geant4HitWrapper> dd4hep::sim::Geant4HitCollection::WrappedHits |
Enumeration for collection optimization types.
Enumerator | |
---|---|
OPTIMIZE_NONE | |
OPTIMIZE_REPEATEDLOOKUP | |
OPTIMIZE_MAPPEDLOOKUP | |
OPTIMIZE_LAST |
Definition at line 267 of file Geant4HitCollection.h.
|
inline |
Initializing constructor (C++ version)
Definition at line 276 of file Geant4HitCollection.h.
|
inline |
Initializing constructor.
Definition at line 287 of file Geant4HitCollection.h.
|
virtual |
Default destructor.
Definition at line 80 of file Geant4HitCollection.cpp.
|
inline |
Add a new hit with a check, that the hit is of the same type.
Definition at line 333 of file Geant4HitCollection.h.
|
inline |
Add a new hit with a check, that the hit is of the same type.
Definition at line 339 of file Geant4HitCollection.h.
|
virtual |
Clear the collection (Deletes all valid references to real hits)
Definition at line 102 of file Geant4HitCollection.cpp.
|
inline |
Find hits in a collection by comparison of attributes.
Definition at line 350 of file Geant4HitCollection.h.
|
inline |
Find hits in a collection by comparison of key value.
Definition at line 354 of file Geant4HitCollection.h.
|
protected |
Find hit in a collection by comparison of attributes.
Definition at line 109 of file Geant4HitCollection.cpp.
|
protected |
Find hit in a collection by comparison of the key.
Definition at line 125 of file Geant4HitCollection.cpp.
|
protected |
Release all hits from the Geant4 container. Ownership stays with the container.
Definition at line 148 of file Geant4HitCollection.cpp.
|
inlineoverridevirtual |
Access individual hits.
Definition at line 317 of file Geant4HitCollection.h.
|
inline |
Release all hits from the Geant4 container. Ownership stays with the container.
Definition at line 375 of file Geant4HitCollection.h.
void Geant4HitCollection::getHitsUnchecked | ( | std::vector< void * > & | result | ) |
Release all hits from the Geant4 container. Ownership stays with the container.
Definition at line 172 of file Geant4HitCollection.cpp.
|
inlineoverridevirtual |
Access the collection size.
Definition at line 321 of file Geant4HitCollection.h.
|
inline |
Access the hit wrapper.
Definition at line 325 of file Geant4HitCollection.h.
|
inline |
Access the hit wrapper (CONST)
Definition at line 329 of file Geant4HitCollection.h.
|
protected |
Notification to increase the instance counter.
Definition at line 97 of file Geant4HitCollection.cpp.
|
protected |
Release all hits from the Geant4 container and pass ownership to the caller.
Definition at line 133 of file Geant4HitCollection.cpp.
|
inline |
Release all hits from the Geant4 container and pass ownership to the caller.
Definition at line 362 of file Geant4HitCollection.h.
void Geant4HitCollection::releaseHitsUnchecked | ( | std::vector< void * > & | result | ) |
Release all hits from the Geant4 container and pass ownership to the caller.
Definition at line 161 of file Geant4HitCollection.cpp.
|
inline |
Access the sensitive detector.
Definition at line 313 of file Geant4HitCollection.h.
|
inline |
Set optimization flags.
Definition at line 305 of file Geant4HitCollection.h.
|
inline |
Set the sensitive detector.
Definition at line 309 of file Geant4HitCollection.h.
const dd4hep::ComponentCast & Geant4HitCollection::type | ( | ) | const |
Type information of the object stored.
Definition at line 87 of file Geant4HitCollection.cpp.
const dd4hep::ComponentCast & Geant4HitCollection::vector_type | ( | ) | const |
Type information of the vector type for extracting data.
Definition at line 92 of file Geant4HitCollection.cpp.
|
protected |
Handle to the sensitive detector.
Definition at line 243 of file Geant4HitCollection.h.
|
protected |
Optimization flags.
Definition at line 251 of file Geant4HitCollection.h.
|
protected |
The collection of hit pointers in the wrapped format.
Definition at line 241 of file Geant4HitCollection.h.
|
protected |
Hit key map for fast random lookup.
Definition at line 249 of file Geant4HitCollection.h.
|
protected |
Memorize for speedup the last searched hit.
Definition at line 247 of file Geant4HitCollection.h.
|
protected |
The type of the objects in this collection. Set by the constructor.
Definition at line 245 of file Geant4HitCollection.h.