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*>*
49 "Cannot create two instances of singleton.");
67 G4LogicalVolume* lv, G4int
id, G4bool fillLVToVolIdMap)
81 if (fillLVToVolIdMap) {
88 const G4String& volumeName, TVirtualMCSensitiveDetector* userSD)
98 fgUserSDs =
new std::set<TVirtualMCSensitiveDetector*>();
99 fgUserSDMap =
new std::map<G4String, TVirtualMCSensitiveDetector*>();
109 (*fgUserSDMap)[volumeName] = userSD;
113 TString(
"A sensitive detector for volume ") + TString(volumeName.data()) +
115 TString(
"Setting was ingored."));
127 <<
" sensitive detectors" << G4endl;
139 <<
" entries:" << G4endl;
141 std::map<G4String, G4int>::const_iterator it;
143 G4cout <<
"Map element " << std::right << std::setw(3) << counter++
145 G4cout << std::left << std::setw(20) << it->first <<
" ";
146 G4cout << std::right << std::setw(8) << it->second <<
" ";
159 <<
" entries:" << G4endl;
161 std::map<G4int, G4LogicalVolume*>::const_iterator it;
163 G4cout <<
"Map element " << std::right << std::setw(3) << counter++
165 G4cout << std::right << std::setw(8) << it->first <<
" ";
166 G4cout << std::right << std::setw(12) << it->second <<
" ";
167 G4cout << std::left << std::setw(20) << it->second->GetName() <<
" ";
168 G4cout << std::right << G4endl;
178 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
180 G4cout <<
"Sensitive volumes (volId, volName): " << G4endl;
181 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
182 G4LogicalVolume* lv = (*lvStore)[i];
183 if (lv->GetSensitiveDetector()) {
185 G4cout << std::right << std::setw(4) <<
GetVolumeID(lv) <<
" ";
186 G4cout << std::left << std::setw(20) << lv->GetName();
187 G4cout << std::right << G4endl;
197 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
199 G4cout <<
"User sensitive detectors (volId, volName, sdName): " << G4endl;
200 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
201 G4LogicalVolume* lv = (*lvStore)[i];
202 TVirtualMCSensitiveDetector* userSD =
207 G4cout << std::right << std::setw(4) <<
GetVolumeID(lv) <<
" ";
208 G4cout << std::left << std::setw(20) << lv->GetName() <<
" ";
209 G4cout << std::left << std::setw(20) << userSD->GetName() <<
" ";
210 G4cout << std::right << G4endl;
222 std::map<G4String, G4int>::const_iterator it =
fVolNameToIdMap.find(volName);
226 "Unknown Volume Id for " + TString(volName.data()));
251 std::map<G4LogicalVolume*, G4int>::const_iterator it;
258 "Unknown Volume Id for " + TString(logicalVolume->GetName()));
267 std::map<G4LogicalVolume*, G4int>::const_iterator it;
274 "Unknown Volume Id for" + TString(logicalVolume->GetName()));
311 G4String volumeName, G4bool warn)
const
316 std::map<G4String, TVirtualMCSensitiveDetector*>::const_iterator it =
322 "No sensitive detector is defined for volume " +
323 TString(volumeName.data()));
341 TString text =
"volumeId=";
344 "Sensitive detector with " + text +
" is not defined.");
353 G4int volumeId, G4bool warn)
const
358 std::map<G4int, G4LogicalVolume*>::const_iterator it =
363 TString text =
"volumeId=";
366 "Sensitive detector with " + text +
" is not defined.");
403 "Wrong sensitive detector type.");
420 return lv->GetNoDaughters();
433 G4int nofDaughters = lv->GetNoDaughters();
434 if (i < 0 || i >= nofDaughters) {
435 TString text =
"index=";
438 "Mother volume " + TString(volName) +
" has no daughter with " + text +
443 G4VPhysicalVolume* daughter = lv->GetDaughter(i);
444 G4String g4Name = daughter->GetLogicalVolume()->GetName();
459 G4int nofDaughters = lv->GetNoDaughters();
460 if (i < 0 || i >= nofDaughters) {
461 TString text =
"index=";
464 "Mother volume " + TString(volName) +
" has no daughter with " + text +
469 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
G4String CutName(const char *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
std::map< G4int, G4LogicalVolume * > fVolIdToLVMap
map volume id -> logical volume
TG4SensitiveDetector * GetSensitiveDetector(G4VSensitiveDetector *sd) const
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
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
G4int GetMediumId(G4int volumeId) const
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