ATLAS Offline Software
LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef LARG4CODE_SDWRAPPER_H
6 #define LARG4CODE_SDWRAPPER_H
7 
8 // System includes
9 #include <string>
10 #include <vector>
11 #include <memory>
12 
13 // External includes
14 #include "G4VSensitiveDetector.hh"
15 
16 // Framework includes
17 #include "StoreGate/WriteHandle.h"
18 
19 
20 // Forward declarations
21 class LArG4SimpleSD;
22 class LArHitContainer;
23 class LArG4CalibSD;
25 
26 
27 namespace LArG4
28 {
29 
30  namespace detail
31  {
32 
51  template<class SDType, class HitContainerType>
52  class SDWrapper : public G4VSensitiveDetector
53  {
54 
55  public:
56 
58  using SDList_t = std::vector< std::unique_ptr<SDType> >;
59 
61  SDWrapper(const std::string& name, const std::string& hitCollectionName, const std::string& deadHitCollectionName="");
62 
64  void addSD(std::unique_ptr<SDType> sd);
65 
67  void addFastSimSD(const std::string& fastSimSDName);
68 
70  virtual void Initialize(G4HCofThisEvent*) override final;
71 
73  virtual bool ProcessHits(G4Step*, G4TouchableHistory*) override final;
74 
77 
78 #ifdef SDWRAPPER_TEST//here use conditional compiling to solve the private members accessing problem from test code since adding-friend method can not work in this context(where there are two layer namespaces)
79  public:
80 #else
81  private:
82 #endif
83 
85  std::string m_hitCollName;
86 
89 
91  std::string m_deadHitCollName;
92 
95 
98 
101  std::string m_fastSimSDName;
102 
103  }; // class SDWrapper
104 
105  template<>
107 
108  } // namespace detail
109 
110 
113 
116 
117 } // namespace LArG4
118 
119 #endif
LArG4::detail::SDWrapper
A template class which wraps multiple sensitive detectors.
Definition: LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h:53
LArG4::detail::SDWrapper::m_hitCollName
std::string m_hitCollName
The hit container name.
Definition: LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h:85
CaloCalibrationHitContainer
Definition: CaloCalibrationHitContainer.h:25
LArG4::detail::SDWrapper::EndOfAthenaEvent
void EndOfAthenaEvent()
Gather the hits into the WriteHandle from all the SDs.
LArG4::detail::SDWrapper::ProcessHits
virtual bool ProcessHits(G4Step *, G4TouchableHistory *) override final
This method should not be called. It will throw.
LArG4::detail::SDWrapper::addSD
void addSD(std::unique_ptr< SDType > sd)
Add an SD to this wrapper.
LArG4::detail::SDWrapper::m_sdList
SDList_t m_sdList
The list of sensitive detectors that I own and manage.
Definition: LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h:97
LArG4::detail::SDWrapper::m_deadHitCollName
std::string m_deadHitCollName
The hit container name.
Definition: LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h:91
LArG4SimpleSD
Common sensitive detector class for LAr systems.
Definition: LArG4SimpleSD.h:36
LArHitContainer
Hit collection.
Definition: LArHitContainer.h:26
detail
Definition: extract_histogram_tag.cxx:14
LArG4
Definition: LArWheelCalculatorEnums.h:8
LArG4::detail::SDWrapper::SDWrapper
SDWrapper(const std::string &name, const std::string &hitCollectionName, const std::string &deadHitCollectionName="")
Construct the wrapper from the output collection name.
LArG4::detail::SDWrapper::Initialize
virtual void Initialize(G4HCofThisEvent *) override final
Beginning of G4 event; initialize the hit collection.
python.selector.AtlRunQuerySelectorLhcOlc.sd
sd
Definition: AtlRunQuerySelectorLhcOlc.py:612
WriteHandle.h
Handle class for recording to StoreGate.
LArG4::detail::SDWrapper::m_fastSimSDName
std::string m_fastSimSDName
A fastsim SD name that I do not own but invoke in order to share my hit container.
Definition: LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h:101
LArG4CalibSD
A specialized SD class for saving LAr calibration hits.
Definition: LArG4CalibSD.h:38
LArG4::detail::SDWrapper::SDList_t
std::vector< std::unique_ptr< SDType > > SDList_t
Alias to the SD list type.
Definition: LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h:58
LArG4::detail::SDWrapper::m_deadHitColl
SG::WriteHandle< HitContainerType > m_deadHitColl
The hit container handle.
Definition: LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h:94
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::WriteHandle< HitContainerType >
LArG4::detail::SDWrapper::addFastSimSD
void addFastSimSD(const std::string &fastSimSDName)
Add a (non-owned) fast-sim SD by name.
LArG4::detail::SDWrapper::m_hitColl
SG::WriteHandle< HitContainerType > m_hitColl
The hit container handle.
Definition: LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h:88