Tool for constructing H62004 SDs for FCAL.
More...
#include <H62004FCALSDTool.h>
|
| LArG4SimpleSD * | makeOneSD (const std::string &name, ILArCalculatorSvc *calc, const std::vector< std::string > &volumes) const |
| | Override helper method to create one SD.
|
| bool | useFrozenShowers () const |
| | Are we handling frozen shower fast sim?
|
| StatusCode | assignSD (std::unique_ptr< G4VSensitiveDetector > sd, const std::vector< std::string > &volumes) const |
| | Assign SD to a list of volumes.
|
| G4VSensitiveDetector * | getSD () |
| | Retrieve the current SD.
|
| void | SetSensitiveDetector (G4LogicalVolume *, G4VSensitiveDetector *) const |
| | Method stolen from G4VUserDetectorConstruction in G4 10.2.
|
|
| Gaudi::Property< std::vector< std::string > > | m_volumeNames {this, "LogicalVolumeNames", {}} |
| | All the volumes to which this SD is assigned.
|
| Gaudi::Property< std::vector< std::string > > | m_outputCollectionNames {this, "OutputCollectionNames", {}} |
| | Names of all output collections written out by this SD.
|
| Gaudi::Property< bool > | m_noVolumes {this, "NoVolumes", false} |
| | This SensitiveDetector has no volumes associated with it.
|
| Gaudi::Property< std::string > | m_timeBinType {this, "TimeBinType", "Default"} |
| | What time binning type for regular hits?
|
| Gaudi::Property< float > | m_timeBinWidth {this, "TimeBinWidth", 2.5*CLHEP::ns} |
| | What time bin width for regular hits?
|
| Gaudi::Property< G4bool > | m_useFrozenShowers {this, "UseFrozenShowers", false} |
| | Is there going to be a fast simulation coming into this SD?
|
| const LArEM_ID * | m_larEmID {nullptr} |
| const LArFCAL_ID * | m_larFcalID {nullptr} |
| const LArHEC_ID * | m_larHecID {nullptr} |
|
| StatusCode | initializeCalculators () override final |
| | Initialize Calculator Services.
|
| G4VSensitiveDetector * | makeSD () const override final |
| | Create the SD wrapper for current worker thread.
|
| void | setSD (G4VSensitiveDetector *) |
| | Set the current SD.
|
|
| static bool | matchStrings (const char *first, const char *second) |
| | Match two strings with wildcard support.
|
Tool for constructing H62004 SDs for FCAL.
Based on the previous LArG4H62004FCALSDTool implementation.
This implementation uses the LAr SD wrapper design for managing multiple SDs when running multi-threaded. See ATLASSIM-2606 for discussions.
Definition at line 27 of file H62004FCALSDTool.h.
◆ H62004FCALSDTool()
| LArG4::H62004FCALSDTool::H62004FCALSDTool |
( |
const std::string & | type, |
|
|
const std::string & | name, |
|
|
const IInterface * | parent ) |
◆ assignSD()
| StatusCode SensitiveDetectorBase::assignSD |
( |
std::unique_ptr< G4VSensitiveDetector > | sd, |
|
|
const std::vector< std::string > & | volumes ) const |
|
protectedinherited |
Assign SD to a list of volumes.
This method supports wild card matching
Definition at line 64 of file SensitiveDetectorBase.cxx.
66{
67
68 if(msgLvl(MSG::VERBOSE))
sd->SetVerboseLevel(10);
69 else if(msgLvl(MSG::DEBUG))
sd->SetVerboseLevel(5);
70
71
72
73 auto sdMgr = G4SDManager::GetSDMpointer();
74 auto sdPtr =
sd.get();
75
76 sdMgr->AddNewDetector(
sd.release());
77
78 if(!volumes.empty()) {
79 bool gotOne = false;
80 auto logicalVolumeStore = G4LogicalVolumeStore::GetInstance();
81 for(const auto& volumeName : volumes) {
82
83
84 int numFound = 0;
85
86
87 for(auto* logVol : *logicalVolumeStore) {
88
89 ATH_MSG_VERBOSE(
"Check whether "<<logVol->GetName()<<
" belongs to the set of sensitive detectors "<<volumeName);
90 if(
matchStrings( volumeName.data(), logVol->GetName() ) ){
91 ++numFound;
93 }
94
95 }
96
97 if(numFound == 0) {
99 " not found in G4LogicalVolumeStore.");
100 }
101 else {
102 ATH_MSG_VERBOSE(
"Found " << numFound <<
" copies of LV " << volumeName <<
103 "; SD " <<
sd->GetName() <<
" assigned.");
104 gotOne = true;
105 }
106
107 }
108
109
110 if(!gotOne) {
112 " and expected at least one. Size of the volume store "<<G4LogicalVolumeStore::GetInstance()->
size() );
113 return StatusCode::FAILURE;
114 }
115 }
116
117 return StatusCode::SUCCESS;
118}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static bool matchStrings(const char *first, const char *second)
Match two strings with wildcard support.
void SetSensitiveDetector(G4LogicalVolume *, G4VSensitiveDetector *) const
Method stolen from G4VUserDetectorConstruction in G4 10.2.
◆ Gather() [1/2]
| StatusCode LArG4::SimpleSDTool::Gather |
( |
| ) |
|
|
finaloverridevirtualinherited |
Calls down to all the SDs to pack their hits into one collection.
Reimplemented from SensitiveDetectorBase.
◆ Gather() [2/2]
|
|
inlineoverridevirtualinherited |
Reimplemented in BCMSensorSDTool, BLMSensorSDTool, CSCSensitiveDetectorCosmicsTool, CSCSensitiveDetectorTool, GenericMuonSensitiveDetectorTool, MDTSensitiveDetectorCosmicsTool, MDTSensitiveDetectorTool, MicromegasSensitiveDetectorTool, PixelSensorSDTool, RPCSensitiveDetectorCosmicsTool, RPCSensitiveDetectorTool, SctSensor_CTBTool, SctSensorSDTool, sTGCSensitiveDetectorTool, TGCSensitiveDetectorCosmicsTool, TGCSensitiveDetectorTool, TileGeoG4CalibSDTool, TileGeoG4SDTool, and TRTSensitiveDetectorTool.
Definition at line 79 of file SensitiveDetectorBase.h.
79 {
81 };
virtual StatusCode Gather() override
End of an athena event.
◆ getSD()
| G4VSensitiveDetector * SensitiveDetectorBase::getSD |
( |
| ) |
|
|
protectedinherited |
Retrieve the current SD.
In AthenaMT, this means the thread-local SD. Otherwise, it is simply the single SD.
Definition at line 120 of file SensitiveDetectorBase.cxx.
121{
122#ifdef G4MULTITHREADED
123
124 const auto tid = std::this_thread::get_id();
125
126 auto sdPair = m_sdThreadMap.find(tid);
127 if(sdPair == m_sdThreadMap.end()) return nullptr;
128 return sdPair->second;
129#else
131#endif
132}
G4VSensitiveDetector * m_SD
The sensitive detector to which this thing corresponds.
◆ initialize()
| StatusCode LArG4::SimpleSDTool::initialize |
( |
| ) |
|
|
finaloverrideinherited |
◆ initializeCalculators()
| StatusCode LArG4::H62004FCALSDTool::initializeCalculators |
( |
| ) |
|
|
finaloverrideprivatevirtual |
◆ initializeSD()
| StatusCode SensitiveDetectorBase::initializeSD |
( |
| ) |
|
|
overrideinherited |
Setup an SD in the current thread.
Separate from the AthAlgTool initialize() method because it needs to be called once per worker thread in AthenaMT. Don't confuse this with the G4 SD method Initialize which is called at the beginning of every G4 event.
Definition at line 25 of file SensitiveDetectorBase.cxx.
26{
28
29
30
33 << (
m_noVolumes?
"true" :
"false") <<
", but LogicalVolumeNames = "
35 return StatusCode::FAILURE;
36 }
37
38
40 {
42 return StatusCode::FAILURE;
43 }
44
45
46 auto sd = std::unique_ptr<G4VSensitiveDetector>(makeSD());
47 if(!sd)
48 {
50 return StatusCode::FAILURE;
51 }
53
54
56
58 return StatusCode::SUCCESS;
59}
#define ATH_CHECK
Evaluate an expression and check for errors.
StatusCode assignSD(std::unique_ptr< G4VSensitiveDetector > sd, const std::vector< std::string > &volumes) const
Assign SD to a list of volumes.
Gaudi::Property< std::vector< std::string > > m_volumeNames
All the volumes to which this SD is assigned.
Gaudi::Property< bool > m_noVolumes
This SensitiveDetector has no volumes associated with it.
G4VSensitiveDetector * getSD()
Retrieve the current SD.
void setSD(G4VSensitiveDetector *)
Set the current SD.
◆ makeOneSD()
| LArG4SimpleSD * LArG4::H62004SimpleSDTool::makeOneSD |
( |
const std::string & | name, |
|
|
ILArCalculatorSvc * | calc, |
|
|
const std::vector< std::string > & | volumes ) const |
|
protectedinherited |
Override helper method to create one SD.
◆ makeSD()
| G4VSensitiveDetector * LArG4::H62004FCALSDTool::makeSD |
( |
| ) |
const |
|
finaloverrideprivate |
Create the SD wrapper for current worker thread.
◆ matchStrings()
| bool SensitiveDetectorBase::matchStrings |
( |
const char * | first, |
|
|
const char * | second ) |
|
staticprivateinherited |
Match two strings with wildcard support.
Compares two strings character by character with optional * wildcard in the first argument
Definition at line 147 of file SensitiveDetectorBase.cxx.
148{
149
150 if (*first == '\0' && *second == '\0')
151 return true;
152
153
154
155 if(*first == '*' && *(first + 1) == '*')
157
158
159 if (*first == '*' && *(first + 1) != '\0' && *second == '\0')
160 return false;
161
162
163 if (*first == *second)
165
166
167
168
169 if (*first == '*')
171 return false;
172}
◆ setSD()
| void SensitiveDetectorBase::setSD |
( |
G4VSensitiveDetector * | sd | ) |
|
|
privateinherited |
Set the current SD.
In hive, this gets assigned as the thread-local SD.
Definition at line 134 of file SensitiveDetectorBase.cxx.
135{
136#ifdef G4MULTITHREADED
137 const auto tid = std::this_thread::get_id();
138 ATH_MSG_DEBUG(
"Creating and registering SD " << sd <<
" in thread " << tid);
139 m_sdThreadMap.insert( std::make_pair(tid, sd) );
140#else
142#endif
143}
◆ SetSensitiveDetector()
| void SensitiveDetectorBase::SetSensitiveDetector |
( |
G4LogicalVolume * | logVol, |
|
|
G4VSensitiveDetector * | aSD ) const |
|
protectedinherited |
Method stolen from G4VUserDetectorConstruction in G4 10.2.
Definition at line 174 of file SensitiveDetectorBase.cxx.
176{
177
178
179
180
181 G4VSensitiveDetector* originalSD = logVol->GetSensitiveDetector();
182 if ( originalSD == nullptr )
183 {
184 logVol->SetSensitiveDetector(aSD);
185 }
186 else
187 {
188 G4MultiSensitiveDetector* msd = dynamic_cast<G4MultiSensitiveDetector*>(originalSD);
189 if ( msd != nullptr )
190 {
191 msd->AddSD(aSD);
192 }
193 else
194 {
195
196 std::stringstream
ss;
198 const G4String msdname =
"/MultiSD_" + logVol->GetName() +
ss.str();
199 msd = new G4MultiSensitiveDetector(std::move(msdname));
200
201 G4SDManager::GetSDMpointer()->AddNewDetector(msd);
202 msd->AddSD(originalSD);
203 msd->AddSD(aSD);
204 logVol->SetSensitiveDetector(msd);
205 }
206 }
207}
◆ SetupEvent() [1/2]
| virtual StatusCode SensitiveDetectorBase::SetupEvent |
( |
| ) |
|
|
inlineoverridevirtualinherited |
◆ SetupEvent() [2/2]
|
|
inlineoverridevirtualinherited |
Reimplemented in BCMSensorSDTool, BLMSensorSDTool, CSCSensitiveDetectorCosmicsTool, CSCSensitiveDetectorTool, GenericMuonSensitiveDetectorTool, MDTSensitiveDetectorCosmicsTool, MDTSensitiveDetectorTool, MicromegasSensitiveDetectorTool, PixelSensorSDTool, RPCSensitiveDetectorCosmicsTool, RPCSensitiveDetectorTool, SctSensor_CTBTool, SctSensorSDTool, sTGCSensitiveDetectorTool, TGCSensitiveDetectorCosmicsTool, TGCSensitiveDetectorTool, TileGeoG4CalibSDTool, TileGeoG4SDTool, and TRTSensitiveDetectorTool.
Definition at line 71 of file SensitiveDetectorBase.h.
71 {
73 }
virtual StatusCode SetupEvent() override
Beginning of an athena event.
◆ useFrozenShowers()
| bool LArG4::SimpleSDTool::useFrozenShowers |
( |
| ) |
const |
|
inlineprotectedinherited |
Are we handling frozen shower fast sim?
Definition at line 71 of file SimpleSDTool.h.
◆ m_fcal1calc
◆ m_fcal1Volumes
| Gaudi::Property<std::vector<std::string> > LArG4::H62004FCALSDTool::m_fcal1Volumes {this, "FCAL1Volumes"} |
|
private |
◆ m_fcal2calc
◆ m_fcal2Volumes
| Gaudi::Property<std::vector<std::string> > LArG4::H62004FCALSDTool::m_fcal2Volumes {this, "FCAL2Volumes"} |
|
private |
◆ m_fcalcoldcalc
Definition at line 48 of file H62004FCALSDTool.h.
48{this, "FCALColdCalculator", "FCALColdCalculator"};
◆ m_fcalColdVolumes
| Gaudi::Property<std::vector<std::string> > LArG4::H62004FCALSDTool::m_fcalColdVolumes {this, "FCALColdVolumes"} |
|
private |
◆ m_hitCollName
| std::string LArG4::H62004FCALSDTool::m_hitCollName {"LArHitFCAL"} |
|
private |
◆ m_larEmID
| const LArEM_ID* LArG4::SimpleSDTool::m_larEmID {nullptr} |
|
protectedinherited |
◆ m_larFcalID
| const LArFCAL_ID* LArG4::SimpleSDTool::m_larFcalID {nullptr} |
|
protectedinherited |
◆ m_larHecID
| const LArHEC_ID* LArG4::SimpleSDTool::m_larHecID {nullptr} |
|
protectedinherited |
◆ m_noVolumes
| Gaudi::Property<bool> SensitiveDetectorBase::m_noVolumes {this, "NoVolumes", false} |
|
protectedinherited |
This SensitiveDetector has no volumes associated with it.
Definition at line 101 of file SensitiveDetectorBase.h.
101{this, "NoVolumes", false};
◆ m_outputCollectionNames
| Gaudi::Property<std::vector<std::string> > SensitiveDetectorBase::m_outputCollectionNames {this, "OutputCollectionNames", {}} |
|
protectedinherited |
Names of all output collections written out by this SD.
Definition at line 98 of file SensitiveDetectorBase.h.
98{this, "OutputCollectionNames", {}};
◆ m_SD
| G4VSensitiveDetector* SensitiveDetectorBase::m_SD {} |
|
privateinherited |
◆ m_timeBinType
| Gaudi::Property<std::string> LArG4::SimpleSDTool::m_timeBinType {this, "TimeBinType", "Default"} |
|
protectedinherited |
What time binning type for regular hits?
Definition at line 79 of file SimpleSDTool.h.
79{this, "TimeBinType", "Default"};
◆ m_timeBinWidth
| Gaudi::Property<float> LArG4::SimpleSDTool::m_timeBinWidth {this, "TimeBinWidth", 2.5*CLHEP::ns} |
|
protectedinherited |
What time bin width for regular hits?
Definition at line 81 of file SimpleSDTool.h.
81{this, "TimeBinWidth", 2.5*CLHEP::ns};
◆ m_useFrozenShowers
| Gaudi::Property<G4bool> LArG4::SimpleSDTool::m_useFrozenShowers {this, "UseFrozenShowers", false} |
|
protectedinherited |
Is there going to be a fast simulation coming into this SD?
Definition at line 83 of file SimpleSDTool.h.
83{this, "UseFrozenShowers", false};
◆ m_volumeNames
| Gaudi::Property<std::vector<std::string> > SensitiveDetectorBase::m_volumeNames {this, "LogicalVolumeNames", {}} |
|
protectedinherited |
All the volumes to which this SD is assigned.
Definition at line 96 of file SensitiveDetectorBase.h.
96{this, "LogicalVolumeNames", {}};
The documentation for this class was generated from the following file: