23#include <G4LogicalVolume.hh>
24#include <G4LogicalVolumeStore.hh>
25#include <G4SDManager.hh>
26#include <G4Threading.hh>
28#include <TGeoManager.h>
29#include <TGeoVolume.h>
30#include <TVirtualMCApplication.h>
31#include <TVirtualMCSensitiveDetector.h>
33#include <TVirtualMC.h>
62 G4LogicalVolume* lv, TVirtualMCSensitiveDetector* userSD)
const
67 G4cout <<
"TG4SDConstruction::CreateSD: lv=" << lv->GetName()
68 <<
" userSD=" << userSD << G4endl;
72 G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
76 sdName = userSD->GetName();
84 sd = pSDManager->FindSensitiveDetector(sdName,
false);
93 G4cout <<
"Created TG4GflashSensitiveDetector with sdName=" << sdName
94 <<
" mediumId=" << mediumId << G4endl;
100 G4cout <<
"Created TG4SensitiveDetector with userSD=" << userSD
101 <<
" mediumId=" << mediumId
108 G4cout <<
"Created TG4SensitiveDetector with sdName=" << sdName
109 <<
" mediumId=" << mediumId << G4endl;
112 pSDManager->AddNewDetector(newSD);
114 G4cout <<
"Sensitive detector " << sdName <<
" ID=" << newSD->
GetID()
115 <<
" medium ID=" << newSD->
GetMediumID() <<
" has been created."
120 G4cout <<
"Sensitive detector " << sdName <<
", " << sd
121 <<
" already exists." << G4endl;
126 lv->SetSensitiveDetector(sd);
138 "TG4SDServices",
"FillSDSelectionFromTGeo",
"TGeo manager not defined.");
141 TObjArray* volumes = gGeoManager->GetListOfVolumes();
142 TIterator* it = volumes->MakeIterator();
143 TGeoVolume* volume = 0;
144 while ((volume = (
static_cast<TGeoVolume*
>(it->Next())))) {
145 if (TString(volume->GetOption()) == TString(
fSVLabel.data())) {
146 G4cout <<
"Adding volume " << volume->GetName() <<
" in SD selection"
153 TString text =
"No volumes with the option = \"";
155 text +=
"\" were found in TGeo geometry.\n";
156 text +=
" The SD selection will not be applied.";
167 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
168 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
169 G4LogicalVolume* lv = (*lvStore)[i];
172 G4cout <<
"Candidate volId from instance Id "
174 <<
" to " << lv->GetName() << G4endl;
192 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
193 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
194 G4LogicalVolume* lv = (*lvStore)[i];
197 if (lv->GetSensitiveDetector()) {
206 G4cout <<
"Candidate volId from SD id " <<
id <<
" to " << lv->GetName()
224 if (
VerboseLevel() > 1) G4cout <<
"TG4SDConstruction::Construct" << G4endl;
226 G4bool isMaster = !G4Threading::IsWorkerThread();
233 TVirtualMCApplication::Instance()->ConstructSensitiveDetectors();
238 G4bool isUserSD =
false;
239 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
241 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
242 G4LogicalVolume* lv = (*lvStore)[i];
244 const G4String selectionName =
248 TVirtualMCSensitiveDetector* userSD =
286 TVirtualMCApplication::Instance()->InitGeometry();
292 userSD->Initialize();
308 G4cout <<
"TG4SDConstruction::Construct done" << G4endl;
317 std::istringstream is(selection);
319 while (is >> token) {
321 G4cout <<
"Adding volume " << token <<
" in SD selection." << G4endl;
Definition of the TG4GeometryServices class.
Definition of the TG4GflashSensitiveDetector class.
Definition of the TG4SDConstruction class.
Definition of the TG4SDServices class.
Definition of the TG4SensitiveDetector class.
Definition of the TG4StateManager class.
Services for accessing to Geant4 geometry.
G4int GetMediumId(G4LogicalVolume *lv) const
void BuildConstituentVolumes()
const G4String & UserVolumeName(const G4String &name) const
static TG4GeometryServices * Instance()
Sensitive detector with Gflash.
static void Warning(const TString &className, const TString &methodName, const TString &text)
static void Exception(const TString &className, const TString &methodName, const TString &text)
void CreateSD(G4LogicalVolume *lv, TVirtualMCSensitiveDetector *userSD) const
void FillSDSelectionFromTGeo()
G4String fSVLabel
the label used to flag sensitive volumes in TGeo
std::set< G4String > fSelection
the set of volumes names which are selected as sensitive
void AddSelection(const G4String &selection)
G4bool fIsGflash
the flag to acivate creating Gflash sensitive detectors
void MapVolumesToInstanceIds()
static const G4String fgkDefaultSVLabel
default value of the sensitive volumes label
G4bool fExclusiveSDScoring
the flag to activate new scoring via user defined sensitive detectors
TG4SDMessenger fMessenger
messenger
virtual ~TG4SDConstruction()
G4bool fSelectionFromTGeo
the flag to activate retrieving sensitive volumes from TGeo
TVirtualMCSensitiveDetector * GetUserSD(G4String volumeName, G4bool warn=true) const
void PrintUserSensitiveDetectors() const
void PrintSensitiveVolumes() const
void PrintVolNameToIdMap() const
void MapVolume(G4LogicalVolume *lv, G4int id, G4bool fillLVToVolIdMap)
void PrintVolIdToLVMap() const
static TG4SDServices * Instance()
static G4int GetFirstVolumeId()
Sensitive detector class for calling a user defined stepping function.
static G4int GetTotalNofSensitiveDetectors()
G4int GetMediumID() const
void SetNewState(TG4ApplicationState state)
static TG4StateManager * Instance()
virtual G4int VerboseLevel() const
TG4Verbose(const G4String &cmdName)
@ kConstructSD
in ConstructSensitiveDetectors
@ kNotInApplication
not in VMC application
@ kInitGeometry
in InitGeometry