19 #include "G4Allocator.hh"
21 using namespace DD4hep;
22 using namespace DD4hep::Simulation;
31 : cast(c), vec_type(v) {
49 void* Geant4HitWrapper::operator
new(size_t) {
57 void Geant4HitWrapper::operator
delete(
void *p) {
65 m_data.second = manipulator<InvalidHit>();
73 m_data.second = manipulator<InvalidHit>();
90 return m_manipulator->
cast;
95 return m_manipulator->vec_type;
105 m_lastHit = ULONG_MAX;
113 WrappedHits::const_iterator i = m_hits.begin();
114 if (
m_flags.bits.repeatedLookup && m_lastHit < m_hits.size() ) {
115 if ( (p = cmp(*(i+m_lastHit))) != 0 )
return p;
117 for (
size_t cnt=0; i != m_hits.end(); ++i, ++cnt) {
118 if ((p = cmp(*i)) != 0) {
128 Keys::const_iterator i=m_keys.find(key);
129 if ( i == m_keys.end() )
return 0;
130 m_lastHit = (*i).second;
131 return &m_hits.at(m_lastHit);
136 for (
size_t j = 0, n = m_hits.size(); j < n; ++j) {
139 if (&cast == &m->
cast)
140 result->push_back(w.
release());
144 m_lastHit = ULONG_MAX;
150 for (
size_t j = 0, n = m_hits.size(); j < n; ++j) {
153 if (&cast == &m->
cast)
154 result->push_back(w.
data());
162 for (
size_t j = 0, n = m_hits.size(); j < n; ++j) {
166 m_lastHit = ULONG_MAX;
172 for (
size_t j = 0, n = m_hits.size(); j < n; ++j) {
174 result.push_back(w.
data());
void releaseData(const ComponentCast &cast, std::vector< void * > *result)
Release all hits from the Geant4 container and pass ownership to the caller.
void * findHit(const Compare &cmp)
Find hit in a collection by comparison of attributes.
static void decrement(T *)
Decrement count according to type information.
Geant4HitWrapper * findHitByKey(VolumeID key)
Find hit in a collection by comparison of the key.
void * release()
Pointer/Object release.
const ComponentCast & vector_type() const
Type information of the vector type for extracting data.
void newInstance()
Notification to increase the instance counter.
G4ThreadLocal G4Allocator< Geant4HitWrapper > * HitWrapperAllocator
HitManipulator(const ComponentCast &c, const ComponentCast &v)
Initializing Constructor.
Generic wrapper class for hit structures created in Geant4 sensitive detectors.
void getData(const ComponentCast &cast, std::vector< void * > *result)
Release all hits from the Geant4 container. Ownership stays with the container.
Generic class template to compare/select hits in Geant4HitCollection objects.
void * apply_downCast(const ComponentCast &to, const void *ptr) const
Apply cast using typeinfo instead of dynamic_cast.
HitManipulator::Wrapper Wrapper
virtual ~Geant4HitWrapper()
Default destructor.
void releaseHitsUnchecked(std::vector< void * > &result)
Release all hits from the Geant4 container and pass ownership to the caller.
Class to perform dynamic casts using unknown pointers.
static void increment(T *)
Increment count according to type information.
virtual ~Geant4HitCollection()
Default destructor.
~HitManipulator()
Default destructor.
virtual ~Compare()
Default destructor.
HitManipulator * manip() const
Access to cast grammar.
void * data()
Pointer/Object access.
const ComponentCast & type() const
Type information of the object stored.
const ComponentCast & cast
void getHitsUnchecked(std::vector< void * > &result)
Release all hits from the Geant4 container. Ownership stays with the container.
Wrapper releaseData()
Release data for copy.
Generic type manipulation class for generic hit structures created in Geant4 sensitive detectors...
virtual void clear()
Clear the collection (Deletes all valid references to real hits)
static unsigned long m_flags