ATLAS Offline Software
SDWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "SDWrapper.h"
6 
7 // Geant4 includes
8 #include "G4SDManager.hh"
9 
10 // Framework utilities
11 
12 // Project includes
14 
15 // Local includes
16 #include "FCS_StepInfoSD.h"
17 
18 namespace FCS_Param {
19 
20 namespace detail {
21 
22 //-------------------------------------------------------------------------
23 // Construct with a hit collection name
24 //-------------------------------------------------------------------------
25 template <class SDType, class HitContainerType>
27  const std::string& name, const std::string& hitCollectionName)
28  : G4VSensitiveDetector(name),
29  m_hitCollName(hitCollectionName),
30  m_hitColl(hitCollectionName) {}
31 
32 //-------------------------------------------------------------------------
33 // Add a unique SD to the list
34 //-------------------------------------------------------------------------
35 template <class SDType, class HitContainerType>
36 void SDWrapper<SDType, HitContainerType>::addSD(std::unique_ptr<SDType> sd) {
37  m_sdList.push_back(std::move(sd));
38 }
39 
40 //-------------------------------------------------------------------------
41 // Initialize the hit collection at the beginning of the G4 event
42 //-------------------------------------------------------------------------
43 template <class SDType, class HitContainerType>
45  if (!m_hitColl.isValid()) {
46  if (verboseLevel >= 5) {
47  G4cout << GetName() << " \tDEBUG\t"
48  << "Initializing hit container: " << m_hitCollName << G4endl;
49  }
50  m_hitColl = std::make_unique<HitContainerType>();
51  }
52 }
53 
54 //-------------------------------------------------------------------------
55 // This should not be called
56 //-------------------------------------------------------------------------
57 template <class SDType, class HitContainerType>
59  G4TouchableHistory*) {
60  G4ExceptionDescription description;
61  description << "ProcessHits: this SD shouldn't be assigned to volumes!";
62  G4Exception(GetName(), "SDError", FatalException, description);
63  return false;
64 }
65 
66 //-------------------------------------------------------------------------
67 // Gather the hits into the WriteHandle from all the SDs
68 //-------------------------------------------------------------------------
69 template <class SDType, class HitContainerType>
71  if (!m_hitColl.isValid()) {
72  G4cerr << GetName() << " \tERROR\t" << "Hit collection WriteHandle is "
73  << "invalid!" << G4endl;
74  throw std::runtime_error("Invalid hit container WriteHandle: " +
75  m_hitColl.name());
76  }
77  // Loop over each SD and fill the container
78  for (auto& sd : m_sdList) {
79  sd->EndOfAthenaEvent(&*m_hitColl);
80  }
81 }
82 
83 //-------------------------------------------------------------------------
84 // Explit template instantiations
85 //-------------------------------------------------------------------------
86 template class SDWrapper<FCS_StepInfoSD,
88 
89 } // namespace detail
90 
91 } // namespace FCS_Param
FCS_StepInfoCollection.h
FCS_StepInfoSD.h
detail
Definition: extract_histogram_tag.cxx:14
python.selector.AtlRunQuerySelectorLhcOlc.sd
sd
Definition: AtlRunQuerySelectorLhcOlc.py:611
FCS_Param
Definition: FCS_StepInfoSD.h:35
SDWrapper.h
FCS_Param::detail::SDWrapper::SDWrapper
SDWrapper(const std::string &name, const std::string &hitCollectionName)
Construct the wrapper from the output collection name.
Definition: SDWrapper.cxx:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
FCS_Param::detail::SDWrapper::EndOfAthenaEvent
void EndOfAthenaEvent()
Gather the hits into the WriteHandle from all the SDs.
Definition: SDWrapper.cxx:70
FCS_Param::detail::SDWrapper::Initialize
virtual void Initialize(G4HCofThisEvent *) override final
Beginning of G4 event; initialize the hit collection.
Definition: SDWrapper.cxx:44
FCS_StepInfoSD
Common sensitive detector class for LAr systems.
Definition: FCS_StepInfoSD.h:71
ISF_FCS_Parametrization::FCS_StepInfoCollection
Class for collection of StepInfo class (G4 hits) copied and modified version to ISF.
Definition: FCS_StepInfoCollection.h:30
FCS_Param::detail::SDWrapper
A template class which wraps multiple sensitive detectors.
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/SDWrapper.h:47
FCS_Param::detail::SDWrapper::addSD
void addSD(std::unique_ptr< SDType > sd)
Add an SD to this wrapper.
Definition: SDWrapper.cxx:36
FCS_Param::detail::SDWrapper::ProcessHits
virtual bool ProcessHits(G4Step *, G4TouchableHistory *) override final
This method should not be called. It will throw.
Definition: SDWrapper.cxx:58
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88