8 #include "G4SDManager.hh"
27 template<
class SDType,
class HitContainerType>
29 SDWrapper(
const std::string&
name,
const std::string& hitCollectionName)
30 : G4VSensitiveDetector(
name),
31 m_hitCollName(hitCollectionName),
32 m_hitColl(hitCollectionName)
38 template<
class SDType,
class HitContainerType>
40 addSD(std::unique_ptr<SDType>
sd)
42 m_sdList.push_back( std::move(
sd) );
48 template<
class SDType,
class HitContainerType>
52 if(!m_hitColl.isValid()) {
53 if(verboseLevel >= 5) {
54 G4cout << GetName() <<
" \tDEBUG\t" <<
"Initializing hit container: "
55 << m_hitCollName << G4endl;
57 m_hitColl = std::make_unique<HitContainerType>();
64 template<
class SDType,
class HitContainerType>
69 description <<
"ProcessHits: this SD shouldn't be assigned to volumes!";
70 G4Exception(GetName(),
"SDError", FatalException,
description);
77 template<
class SDType,
class HitContainerType>
81 if(!m_hitColl.isValid()) {
82 G4cerr << GetName() <<
" \tERROR\t" <<
"Hit collection WriteHandle is "
83 <<
"invalid!" << G4endl;
84 throw std::runtime_error(
"Invalid hit container WriteHandle: " +
88 for(
auto&
sd : m_sdList) {
89 sd->EndOfAthenaEvent( &*m_hitColl );