38 auto i = dirName.length();
41 auto isl = dirName.rfind(
'/');
42 dirName.erase(0, isl + 1);
49 for (
auto st : structure)
52 for (
auto dt : detector)
61 G4String remainingPath = treeStructure;
62 remainingPath.erase(0, pathName.length());
63 if (! remainingPath.empty()) {
65 G4String subD = ExtractDirName(remainingPath);
67 if (tgtSDS ==
nullptr) {
68 subD.insert(0, pathName);
70 structure.push_back(tgtSDS);
76 if (tgtSD ==
nullptr) {
77 detector.push_back(aSD);
79 else if (tgtSD != aSD) {
82 ed << aSD->
GetName() <<
" had already been stored in " << pathName
83 <<
". Object pointer is overwritten.\n";
84 ed <<
"It's users' responsibility to delete the old sensitive detector "
89 detector.push_back(aSD);
96 for (
auto st : structure) {
97 if (subD == st->dirName)
return st;
104 for (
auto det : detector) {
105 if (aSDName == det->GetName())
return det;
112 auto det = std::find(detector.begin(), detector.end(), sd);
113 if (det != detector.end()) detector.erase(det);
119 auto i = aName.find(
'/');
120 if (i != G4String::npos) subD.erase(i + 1);
127 aPath.erase(0, pathName.length());
128 if (aPath.find(
'/') != std::string::npos) {
129 G4String subD = ExtractDirName(aPath);
131 if (tgtSDS ==
nullptr) {
132 G4cout << subD <<
" is not found in " << pathName <<
G4endl;
135 tgtSDS->
Activate(aName, sensitiveFlag);
138 else if (aPath.empty()) {
139 for (
auto det : detector)
140 det->Activate(sensitiveFlag);
141 for (
auto st : structure)
142 st->Activate(
G4String(
"/"), sensitiveFlag);
146 if (tgtSD ==
nullptr) {
147 G4cout << aPath <<
" is not found in " << pathName <<
G4endl;
158 aPath.erase(0, pathName.length());
159 if (aPath.find(
'/') != std::string::npos) {
160 G4String subD = ExtractDirName(aPath);
162 if (tgtSDS ==
nullptr) {
163 if (warning)
G4cout << subD <<
" is not found in " << pathName <<
G4endl;
172 if (tgtSD ==
nullptr) {
173 if (warning)
G4cout << aPath <<
" is not found in " << pathName <<
G4endl;
181 for (
auto st : structure) {
185 for (
auto dt : detector) {
186 if (dt->isActive()) dt->Initialize(HCE);
193 for (
auto st : structure) {
197 for (
auto dt : detector) {
198 if (dt->isActive()) dt->EndOfEvent(HCE);
205 for (
auto sd : detector) {
211 G4cout <<
" XXX Inactive ";
215 for (
auto st : structure)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
void Initialize(G4HCofThisEvent *HCE)
G4bool operator==(const G4SDStructure &right) const
G4VSensitiveDetector * GetSD(const G4String &aName)
void Activate(const G4String &aName, G4bool sensitiveFlag)
void Terminate(G4HCofThisEvent *HCE)
G4VSensitiveDetector * FindSensitiveDetector(const G4String &aName, G4bool warning=true)
G4SDStructure(const G4String &aPath)
void AddNewDetector(G4VSensitiveDetector *aSD, const G4String &treeStructure)
void Activate(G4bool activeFlag)