37 G4int i = dirName.length();
49 for(
auto st : structure)
delete st;
51 for(
auto dt : detector)
delete dt;
57 return (
this==&right);
63 G4String remainingPath = treeStructure;
64 remainingPath.
remove(0,pathName.length());
65 if( ! remainingPath.
isNull() )
68 G4String subD = ExtractDirName( remainingPath );
70 if( tgtSDS ==
nullptr )
74 structure.push_back( tgtSDS );
82 { detector.push_back( aSD ); }
83 else if( tgtSD != aSD )
87 ed << aSD->
GetName() <<
" had already been stored in "
88 << pathName <<
". Object pointer is overwritten.\n";
89 ed <<
"It's users' responsibility to delete the old sensitive detector object.";
93 detector.push_back( aSD );
100 for(
auto st : structure)
101 {
if( subD == st->dirName )
return st; }
107 for(
auto det : detector)
108 {
if(aSDName == det->GetName())
return det; }
114 auto det = std::find(detector.begin(), detector.end(), sd);
115 if(det!=detector.end()) detector.erase(det);
122 if( i !=
G4int(std::string::npos) ) subD.
remove(i+1);
129 aPath.
remove(0,pathName.length());
130 if( aPath.
first(
'/') != std::string::npos )
132 G4String subD = ExtractDirName(aPath);
134 if( tgtSDS ==
nullptr )
136 G4cout << subD <<
" is not found in " << pathName <<
G4endl;
140 tgtSDS->
Activate(aName,sensitiveFlag);
145 for(
auto det : detector) det->Activate(sensitiveFlag);
146 for(
auto st : structure) st->Activate(
G4String(
"/"),sensitiveFlag);
151 if( tgtSD ==
nullptr )
153 G4cout << aPath <<
" is not found in " << pathName <<
G4endl;
165 aPath.
remove(0,pathName.length());
166 if( aPath.
first(
'/') != std::string::npos )
168 G4String subD = ExtractDirName(aPath);
170 if( tgtSDS ==
nullptr )
173 G4cout << subD <<
" is not found in " << pathName <<
G4endl;
184 if( tgtSD ==
nullptr )
187 G4cout << aPath <<
" is not found in " << pathName <<
G4endl;
196 for(
auto st : structure)
197 { st->Initialize(HCE); }
199 for(
auto dt : detector)
200 {
if(dt->isActive()) dt->Initialize(HCE); }
206 for(
auto st : structure)
207 { st->Terminate(HCE); }
209 for(
auto dt : detector)
210 {
if(dt->isActive()) dt->EndOfEvent(HCE); }
216 for(
auto sd : detector)
220 {
G4cout <<
" *** Active "; }
222 {
G4cout <<
" XXX Inactive "; }
225 for(
auto st : structure) st->ListTree();
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)
G4String & remove(str_size)
G4String & prepend(const char *)
std::size_t last(char) const
std::size_t first(char) const
void Activate(G4bool activeFlag)