ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
FCS_Param::detail::SDWrapper< SDType, HitContainerType > Class Template Reference

A template class which wraps multiple sensitive detectors. More...

#include <SDWrapper.h>

Inheritance diagram for FCS_Param::detail::SDWrapper< SDType, HitContainerType >:
Collaboration diagram for FCS_Param::detail::SDWrapper< SDType, HitContainerType >:

Public Types

using SDList_t = std::vector< std::unique_ptr< SDType > >
 Alias to the SD list type. More...
 

Public Member Functions

 SDWrapper (const std::string &name, const std::string &hitCollectionName)
 Construct the wrapper from the output collection name. More...
 
void addSD (std::unique_ptr< SDType > sd)
 Add an SD to this wrapper. More...
 
virtual void Initialize (G4HCofThisEvent *) override final
 Beginning of G4 event; initialize the hit collection. More...
 
virtual bool ProcessHits (G4Step *, G4TouchableHistory *) override final
 This method should not be called. It will throw. More...
 
void EndOfAthenaEvent ()
 Gather the hits into the WriteHandle from all the SDs. More...
 

Private Attributes

std::string m_hitCollName
 The hit container name. More...
 
SG::WriteHandle< HitContainerType > m_hitColl
 The hit container handle. More...
 
SDList_t m_sdList
 The list of sensitive detectors that I own and manage. More...
 

Detailed Description

template<class SDType, class HitContainerType>
class FCS_Param::detail::SDWrapper< SDType, HitContainerType >

A template class which wraps multiple sensitive detectors.

Allows for SD tools to manage several SDs which collaborate to fill one hit container in a multi-threading-friendly way. The wrapper owns the WriteHandle for the hit container and gathers hits from each SD at the end of an event.

The inheritance from G4VSensitiveDetector is merely a trick so the SD tool can save this object in the SensitiveDetectorBase thread-local container. It also allows to create the hit container at the right time via the SD Initialize method invoked by Geant4.

Clients shouldn't use this generic template directly, but should use the explicitly allowed specializations given below.

Author
Steve Farrell Steve.nosp@m.n.Fa.nosp@m.rrell.nosp@m.@cer.nosp@m.n.ch

Definition at line 50 of file Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h.

Member Typedef Documentation

◆ SDList_t

template<class SDType , class HitContainerType >
using FCS_Param::detail::SDWrapper< SDType, HitContainerType >::SDList_t = std::vector< std::unique_ptr<SDType> >

Alias to the SD list type.

Definition at line 56 of file Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h.

Constructor & Destructor Documentation

◆ SDWrapper()

template<class SDType , class HitContainerType >
FCS_Param::detail::SDWrapper< SDType, HitContainerType >::SDWrapper ( const std::string &  name,
const std::string &  hitCollectionName 
)

Construct the wrapper from the output collection name.

Definition at line 28 of file SDWrapper.cxx.

30  : G4VSensitiveDetector(name),
31  m_hitCollName(hitCollectionName),
32  m_hitColl(hitCollectionName)
33  {}

Member Function Documentation

◆ addSD()

template<class SDType , class HitContainerType >
void FCS_Param::detail::SDWrapper< SDType, HitContainerType >::addSD ( std::unique_ptr< SDType >  sd)

Add an SD to this wrapper.

Definition at line 39 of file SDWrapper.cxx.

41  {
42  m_sdList.push_back( std::move(sd) );
43  }

◆ EndOfAthenaEvent()

template<class SDType , class HitContainerType >
void FCS_Param::detail::SDWrapper< SDType, HitContainerType >::EndOfAthenaEvent

Gather the hits into the WriteHandle from all the SDs.

Definition at line 78 of file SDWrapper.cxx.

80  {
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: " +
85  m_hitColl.name());
86  }
87  // Loop over each SD and fill the container
88  for(auto& sd : m_sdList) {
89  sd->EndOfAthenaEvent( &*m_hitColl );
90  }
91  }

◆ Initialize()

template<class SDType , class HitContainerType >
void FCS_Param::detail::SDWrapper< SDType, HitContainerType >::Initialize ( G4HCofThisEvent *  )
finaloverridevirtual

Beginning of G4 event; initialize the hit collection.

Definition at line 49 of file SDWrapper.cxx.

51  {
52  if(!m_hitColl.isValid()) {
53  if(verboseLevel >= 5) {
54  G4cout << GetName() << " \tDEBUG\t" << "Initializing hit container: "
55  << m_hitCollName << G4endl;
56  }
57  m_hitColl = std::make_unique<HitContainerType>();
58  }
59  }

◆ ProcessHits()

template<class SDType , class HitContainerType >
bool FCS_Param::detail::SDWrapper< SDType, HitContainerType >::ProcessHits ( G4Step *  ,
G4TouchableHistory *   
)
finaloverridevirtual

This method should not be called. It will throw.

Definition at line 65 of file SDWrapper.cxx.

67  {
68  G4ExceptionDescription description;
69  description << "ProcessHits: this SD shouldn't be assigned to volumes!";
70  G4Exception(GetName(), "SDError", FatalException, description);
71  return false;
72  }

Member Data Documentation

◆ m_hitColl

template<class SDType , class HitContainerType >
SG::WriteHandle<HitContainerType> FCS_Param::detail::SDWrapper< SDType, HitContainerType >::m_hitColl
private

The hit container handle.

Definition at line 79 of file Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h.

◆ m_hitCollName

template<class SDType , class HitContainerType >
std::string FCS_Param::detail::SDWrapper< SDType, HitContainerType >::m_hitCollName
private

The hit container name.

Definition at line 76 of file Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h.

◆ m_sdList

template<class SDType , class HitContainerType >
SDList_t FCS_Param::detail::SDWrapper< SDType, HitContainerType >::m_sdList
private

The list of sensitive detectors that I own and manage.

Definition at line 82 of file Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h.


The documentation for this class was generated from the following files:
FCS_Param::detail::SDWrapper::m_hitColl
SG::WriteHandle< HitContainerType > m_hitColl
The hit container handle.
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h:79
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
FCS_Param::detail::SDWrapper::m_hitCollName
std::string m_hitCollName
The hit container name.
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h:76
python.selector.AtlRunQuerySelectorLhcOlc.sd
sd
Definition: AtlRunQuerySelectorLhcOlc.py:612
FCS_Param::detail::SDWrapper::m_sdList
SDList_t m_sdList
The list of sensitive detectors that I own and manage.
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h:82
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88