ATLAS Offline Software
SensitiveDetectorBase.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 G4ATLASTOOLS_SENSITIVEDETECTORBASE_H
6 #define G4ATLASTOOLS_SENSITIVEDETECTORBASE_H
7 
8 // Base classes
11 
12 // Members
13 #include "G4VSensitiveDetector.hh"
14 #include "G4Types.hh"
15 #ifdef G4MULTITHREADED
16 # include "tbb/concurrent_unordered_map.h"
17 #endif
18 
19 // STL library
20 #include <string>
21 #include <vector>
22 #include <thread>
23 
24 // Forward declarations
25 class G4LogicalVolume;
26 class G4VSensitiveDetector;
27 
28 
41 class SensitiveDetectorBase : public extends<AthAlgTool, ISensitiveDetector>
42 {
43 
44  public:
45 
47  SensitiveDetectorBase(const std::string& type, const std::string& name,
48  const IInterface *parent);
51 
57  StatusCode initializeSD() override;
58 
60 
62  virtual StatusCode SetupEvent() override { return StatusCode::SUCCESS; }
63 
65 
67  virtual StatusCode Gather() override { return StatusCode::SUCCESS; }
68 
69  protected:
70 
72 
73  StatusCode assignSD(G4VSensitiveDetector* sd,
74  const std::vector<std::string>& volumes) const;
75 
77 
79  G4VSensitiveDetector* getSD();
80 
82  Gaudi::Property<std::vector<std::string> > m_volumeNames{this, "LogicalVolumeNames", {}};
84  Gaudi::Property<std::vector<std::string> > m_outputCollectionNames{this, "OutputCollectionNames", {}};
85 
87  Gaudi::Property<bool> m_noVolumes{this, "NoVolumes", false};
88 
90  void SetSensitiveDetector(G4LogicalVolume*, G4VSensitiveDetector*) const;
91 
92  private:
93 
95 
96  void setSD(G4VSensitiveDetector*);
97 
99 
101  static bool matchStrings(const char *first, const char * second);
102 
103 #ifdef G4MULTITHREADED
104  using SDThreadMap_t = tbb::concurrent_unordered_map
106  < std::thread::id, G4VSensitiveDetector*, std::hash<std::thread::id> >;
108  SDThreadMap_t m_sdThreadMap;
109 #else
110  G4VSensitiveDetector* m_SD{};
112 #endif
113 
114 }; // class SensitiveDetectorBase
115 
116 #endif
SensitiveDetectorBase::SetupEvent
virtual StatusCode SetupEvent() override
Beginning of an athena event.
Definition: SensitiveDetectorBase.h:62
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
SensitiveDetectorBase::m_SD
G4VSensitiveDetector * m_SD
The sensitive detector to which this thing corresponds.
Definition: SensitiveDetectorBase.h:111
SensitiveDetectorBase::~SensitiveDetectorBase
virtual ~SensitiveDetectorBase()
Empty virtual destructor.
Definition: SensitiveDetectorBase.h:50
SensitiveDetectorBase
Common base class for tools that create and manage Geant4 sensitive detectors.
Definition: SensitiveDetectorBase.h:42
SensitiveDetectorBase::SensitiveDetectorBase
SensitiveDetectorBase(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: SensitiveDetectorBase.cxx:22
SensitiveDetectorBase::getSD
G4VSensitiveDetector * getSD()
Retrieve the current SD.
Definition: SensitiveDetectorBase.cxx:123
python.selector.AtlRunQuerySelectorLhcOlc.sd
sd
Definition: AtlRunQuerySelectorLhcOlc.py:612
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SensitiveDetectorBase::initializeSD
StatusCode initializeSD() override
Setup an SD in the current thread.
Definition: SensitiveDetectorBase.cxx:30
SensitiveDetectorBase::m_outputCollectionNames
Gaudi::Property< std::vector< std::string > > m_outputCollectionNames
Names of all output collections written out by this SD.
Definition: SensitiveDetectorBase.h:84
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SensitiveDetectorBase::SetSensitiveDetector
void SetSensitiveDetector(G4LogicalVolume *, G4VSensitiveDetector *) const
Method stolen from G4VUserDetectorConstruction in G4 10.2.
Definition: SensitiveDetectorBase.cxx:178
SensitiveDetectorBase::matchStrings
static bool matchStrings(const char *first, const char *second)
Match two strings with wildcard support.
Definition: SensitiveDetectorBase.cxx:150
SensitiveDetectorBase::m_volumeNames
Gaudi::Property< std::vector< std::string > > m_volumeNames
All the volumes to which this SD is assigned.
Definition: SensitiveDetectorBase.h:82
SensitiveDetectorBase::m_noVolumes
Gaudi::Property< bool > m_noVolumes
This SensitiveDetector has no volumes associated with it.
Definition: SensitiveDetectorBase.h:87
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DeMoScan.first
bool first
Definition: DeMoScan.py:536
SensitiveDetectorBase::Gather
virtual StatusCode Gather() override
End of an athena event.
Definition: SensitiveDetectorBase.h:67
SensitiveDetectorBase::setSD
void setSD(G4VSensitiveDetector *)
Set the current SD.
Definition: SensitiveDetectorBase.cxx:137
ISensitiveDetector.h
SensitiveDetectorBase::assignSD
StatusCode assignSD(G4VSensitiveDetector *sd, const std::vector< std::string > &volumes) const
Assign SD to a list of volumes.
Definition: SensitiveDetectorBase.cxx:70