20#include <G4LogicalVolume.hh>
21#include <G4LogicalVolumeStore.hh>
22#include <G4Material.hh>
23#include <G4VSensitiveDetector.hh>
25#include <TVirtualMCSensitiveDetector.h>
34G4ThreadLocal std::map<G4String, TVirtualMCSensitiveDetector*>*
50 "Cannot create two instances of singleton.");
78 G4LogicalVolume* lv, G4int
id, G4bool )
88 auto instanceId =
static_cast<std::size_t
>(lv->GetInstanceID());
95 const G4String& volumeName, TVirtualMCSensitiveDetector* userSD)
105 fgUserSDs =
new std::set<TVirtualMCSensitiveDetector*>();
106 fgUserSDMap =
new std::map<G4String, TVirtualMCSensitiveDetector*>();
116 (*fgUserSDMap)[volumeName] = userSD;
120 TString(
"A sensitive detector for volume ") + TString(volumeName.data()) +
122 TString(
"Setting was ingored."));
134 <<
" sensitive detectors" << G4endl;
146 <<
" entries:" << G4endl;
148 std::map<G4String, G4int>::const_iterator it;
150 G4cout <<
"Map element " << std::right << std::setw(3) << counter++
152 G4cout << std::left << std::setw(20) << it->first <<
" ";
153 G4cout << std::right << std::setw(8) << it->second <<
" ";
166 <<
" entries:" << G4endl;
168 std::multimap<G4int, G4LogicalVolume*>::const_iterator it;
170 G4cout <<
"Map element " << std::right << std::setw(3) << counter++
172 G4cout << std::right << std::setw(8) << it->first <<
" ";
173 G4cout << std::right << std::setw(12) << it->second <<
" ";
174 G4cout << std::left << std::setw(20) << it->second->GetName() <<
" ";
175 G4cout << std::right << G4endl;
185 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
187 G4cout <<
"Sensitive volumes (volId, volName): " << G4endl;
188 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
189 G4LogicalVolume* lv = (*lvStore)[i];
190 if (lv->GetSensitiveDetector()) {
192 G4cout << std::right << std::setw(4) <<
GetVolumeID(lv) <<
" ";
193 G4cout << std::left << std::setw(20) << lv->GetName();
194 G4cout << std::right << G4endl;
204 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
206 G4cout <<
"User sensitive detectors (volId, volName, sdName): " << G4endl;
207 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
208 G4LogicalVolume* lv = (*lvStore)[i];
210 TVirtualMCSensitiveDetector* userSD = sd ? sd->
GetUserSD() :
nullptr;
213 G4cout << std::right << std::setw(4) <<
GetVolumeID(lv) <<
" ";
214 G4cout << std::left << std::setw(20) << lv->GetName() <<
" ";
215 G4cout << std::left << std::setw(20) << userSD->GetName() <<
" ";
216 G4cout << std::right << G4endl;
226 std::map<G4String, G4int>::const_iterator it =
fVolNameToIdMap.find(volName);
230 "Unknown Volume Id for " + TString(volName.data()));
243 auto instanceId =
static_cast<std::size_t
>(logicalVolume->GetInstanceID());
247 "Unknown Volume Id for " + TString(logicalVolume->GetName()));
281 G4String volumeName, G4bool warn)
const
286 std::map<G4String, TVirtualMCSensitiveDetector*>::const_iterator it =
292 "No sensitive detector is defined for volume " +
293 TString(volumeName.data()));
311 TString text =
"volumeId=";
314 "Sensitive detector with " + text +
" is not defined.");
324 std::vector<G4LogicalVolume*> result;
326 for (
auto it = range.first; it != range.second; ++it) result.push_back(it->second);
332 G4int volumeId, G4bool warn)
const
337 std::multimap<G4int, G4LogicalVolume*>::const_iterator it =
342 TString text =
"volumeId=";
345 "Sensitive detector with " + text +
" is not defined.");
382 "Wrong sensitive detector type.");
399 return lv->GetNoDaughters();
412 G4int nofDaughters = lv->GetNoDaughters();
413 if (i < 0 || i >= nofDaughters) {
414 TString text =
"index=";
417 "Mother volume " + TString(volName) +
" has no daughter with " + text +
422 G4VPhysicalVolume* daughter = lv->GetDaughter(i);
424 static thread_local G4String name;
439 G4int nofDaughters = lv->GetNoDaughters();
440 if (i < 0 || i >= nofDaughters) {
441 TString text =
"index=";
444 "Mother volume " + TString(volName) +
" has no daughter with " + text +
449 return lv->GetDaughter(i)->GetCopyNo();
Definition of the TG4GeometryServices class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4SDServices class.
Definition of the TG4SensitiveDetector class.
G4int GetMediumId(G4LogicalVolume *lv) const
const G4String & UserVolumeName(const G4String &name) const
static TG4GeometryServices * Instance()
static void PrintStars(G4bool emptyLineFirst)
static void Warning(const TString &className, const TString &methodName, const TString &text)
static void Exception(const TString &className, const TString &methodName, const TString &text)
Sensitive detectors services.
G4int GetMediumID(G4LogicalVolume *volume) const
static G4ThreadLocal std::set< TVirtualMCSensitiveDetector * > * fgUserSDs
vector of user SDs
static TG4SDServices * fgInstance
this instance
G4bool fIsUserSDs
info about user SDs
static G4ThreadLocal std::map< G4String, TVirtualMCSensitiveDetector * > * fgUserSDMap
map volume name -> user SD
TG4SensitiveDetector * GetSensitiveDetector(G4VSensitiveDetector *sd) const
std::vector< G4int > fInstanceToVolId
Dense read-only stepping cache, indexed by Geant4 instance ID.
std::map< G4LogicalVolume *, G4int > fLVToVolIdMap
map logical volume -> volume id
TVirtualMCSensitiveDetector * GetUserSD(G4String volumeName, G4bool warn=true) const
void PrintUserSensitiveDetectors() const
G4int GetVolumeID(const G4String &volumeName) const
G4bool fIsStopRun
info about run stopping by user
void PrintSensitiveVolumes() const
void PrintVolNameToIdMap() const
Int_t NofVolDaughters(const char *volName) const
void MapVolume(G4LogicalVolume *lv, G4int id, G4bool fillLVToVolIdMap)
std::map< G4String, G4int > fVolNameToIdMap
map volume name -> volume id
static const G4int fgkFirstVolumeId
the first volume id
Int_t NofSensitiveDetectors() const
void MapUserSD(const G4String &volumeName, TVirtualMCSensitiveDetector *userSD)
void PrintStatistics(G4bool open, G4bool close) const
void PrintVolIdToLVMap() const
Int_t VolDaughterCopyNo(const char *volName, Int_t i) const
G4String GetVolumeName(G4int volumeId) const
std::vector< G4LogicalVolume * > GetLogicalVolumes(G4int volumeId) const
G4int GetMediumId(G4int volumeId) const
std::multimap< G4int, G4LogicalVolume * > fVolIdToLVMap
one VMC source ID -> all its Geant4 representations
G4LogicalVolume * GetLogicalVolume(G4int volumeId, G4bool warn=true) const
const char * VolDaughterName(const char *volName, Int_t i) const
Sensitive detector class for calling a user defined stepping function.
static G4int GetTotalNofSensitiveDetectors()
G4int GetMediumID() const
TVirtualMCSensitiveDetector * GetUserSD() const