Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SDStructure Class Reference

#include <G4SDStructure.hh>

Public Member Functions

 G4SDStructure (G4String aPath)
 
 ~G4SDStructure ()
 
G4int operator== (const G4SDStructure &right) const
 
void AddNewDetector (G4VSensitiveDetector *aSD, G4String treeStructure)
 
void Activate (G4String aName, G4bool sensitiveFlag)
 
void Initialize (G4HCofThisEvent *HCE)
 
void Terminate (G4HCofThisEvent *HCE)
 
G4VSensitiveDetectorFindSensitiveDetector (G4String aName, G4bool warning=true)
 
G4VSensitiveDetectorGetSD (G4String aName)
 
void ListTree ()
 
void SetVerboseLevel (G4int vl)
 

Detailed Description

Definition at line 47 of file G4SDStructure.hh.

Constructor & Destructor Documentation

◆ G4SDStructure()

G4SDStructure::G4SDStructure ( G4String  aPath)

Definition at line 34 of file G4SDStructure.cc.

34 :verboseLevel(0)
35{
36 pathName = aPath;
37 dirName = aPath;
38 G4int i = dirName.length();
39 if( i > 1 )
40 {
41 dirName.remove(i-1);
42 G4int isl = dirName.last('/');
43 dirName.remove(0,isl+1);
44 dirName += "/";
45 }
46}
int G4int
Definition: G4Types.hh:66
G4String & remove(str_size)
G4int last(char) const

◆ ~G4SDStructure()

G4SDStructure::~G4SDStructure ( )

Definition at line 48 of file G4SDStructure.cc.

49{
50 size_t nTree = structure.size();
51 for(size_t iTree=0;iTree<nTree;iTree++)
52 { delete structure[iTree]; }
53 size_t nDet = detector.size();
54 for(size_t iDet=0;iDet<nDet;iDet++)
55 { delete detector[iDet]; }
56}

Member Function Documentation

◆ Activate()

void G4SDStructure::Activate ( G4String  aName,
G4bool  sensitiveFlag 
)

Definition at line 123 of file G4SDStructure.cc.

124{
125 G4String aPath = aName;
126 aPath.remove(0,pathName.length());
127 if( aPath.first('/') != G4int(std::string::npos) )
128 { // Command is ordered for a subdirectory.
129 G4String subD = ExtractDirName(aPath);
130 G4SDStructure* tgtSDS = FindSubDirectory(subD);
131 if( tgtSDS == 0 )
132 { // The subdirectory is not found
133 G4cout << subD << " is not found in " << pathName << G4endl;
134 }
135 else
136 {
137 tgtSDS->Activate(aName,sensitiveFlag);
138 }
139 }
140 else if( aPath.isNull() )
141 { // Command is ordered for all detectors in this directory.
142 for( size_t i=0; i<detector.size(); i++)
143 {
144 detector[i]->Activate(sensitiveFlag);
145 }
146 for( size_t j=0;j<structure.size(); j++)
147 {
148 structure[j]->Activate(G4String("/"),sensitiveFlag);
149 }
150 }
151 else
152 { // Command is ordered to a particular detector.
153 G4VSensitiveDetector* tgtSD = GetSD(aPath);
154 if( tgtSD == 0 )
155 { // The detector is not found.
156 G4cout << aPath << " is not found in " << pathName << G4endl;
157 }
158 else
159 {
160 tgtSD->Activate(sensitiveFlag);
161 }
162 }
163}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void Activate(G4String aName, G4bool sensitiveFlag)
G4VSensitiveDetector * GetSD(G4String aName)
G4bool isNull() const
G4int first(char) const
void Activate(G4bool activeFlag)

Referenced by Activate(), and G4SDManager::Activate().

◆ AddNewDetector()

void G4SDStructure::AddNewDetector ( G4VSensitiveDetector aSD,
G4String  treeStructure 
)

Definition at line 63 of file G4SDStructure.cc.

65{
66 G4String remainingPath = treeStructure;
67 remainingPath.remove(0,pathName.length());
68 if( ! remainingPath.isNull() )
69 { // The detector should be kept in subdirectory.
70 // First, check if the subdirectoy exists.
71 G4String subD = ExtractDirName( remainingPath );
72 G4SDStructure* tgtSDS = FindSubDirectory(subD);
73 if( tgtSDS == 0 )
74 { // Subdirectory not found. Create a new directory.
75 subD.prepend(pathName);
76 tgtSDS = new G4SDStructure(subD);
77 structure.push_back( tgtSDS );
78 }
79 tgtSDS->AddNewDetector(aSD,treeStructure);
80 }
81 else
82 { // The sensitive detector should be kept in this directory.
83 G4VSensitiveDetector* tgtSD = GetSD( aSD->GetName() );
84 if( tgtSD != 0 )
85 {
86 G4cout << aSD->GetName() << " had already stored in "
87 << pathName << G4endl;
88 }
89 else
90 {
91 detector.push_back( aSD );
92 }
93 }
94}
void AddNewDetector(G4VSensitiveDetector *aSD, G4String treeStructure)
G4String & prepend(const char *)

Referenced by G4SDManager::AddNewDetector(), and AddNewDetector().

◆ FindSensitiveDetector()

G4VSensitiveDetector * G4SDStructure::FindSensitiveDetector ( G4String  aName,
G4bool  warning = true 
)

Definition at line 165 of file G4SDStructure.cc.

166{
167 G4String aPath = aName;
168 aPath.remove(0,pathName.length());
169 if( aPath.first('/') != G4int(std::string::npos) )
170 { // SD exists in sub-directory
171 G4String subD = ExtractDirName(aPath);
172 G4SDStructure* tgtSDS = FindSubDirectory(subD);
173 if( tgtSDS == 0 )
174 { // The subdirectory is not found
175 if (warning)
176 G4cout << subD << " is not found in " << pathName << G4endl;
177 return 0;
178 }
179 else
180 {
181 return tgtSDS->FindSensitiveDetector(aName);
182 }
183 }
184 else
185 { // SD must exist in this directory
186 G4VSensitiveDetector* tgtSD = GetSD(aPath);
187 if( tgtSD == 0 )
188 { // The detector is not found.
189 if (warning)
190 G4cout << aPath << " is not found in " << pathName << G4endl;
191 }
192 return tgtSD;
193 }
194}
G4VSensitiveDetector * FindSensitiveDetector(G4String aName, G4bool warning=true)

Referenced by FindSensitiveDetector(), and G4SDManager::FindSensitiveDetector().

◆ GetSD()

G4VSensitiveDetector * G4SDStructure::GetSD ( G4String  aName)

Definition at line 105 of file G4SDStructure.cc.

106{
107 for( size_t i=0; i<detector.size(); i++ )
108 {
109 G4VSensitiveDetector* tgtSD = detector[i];
110 if( aSDName == tgtSD->GetName() ) return tgtSD;
111 }
112 return 0;
113}

Referenced by Activate(), AddNewDetector(), and FindSensitiveDetector().

◆ Initialize()

void G4SDStructure::Initialize ( G4HCofThisEvent HCE)

Definition at line 196 of file G4SDStructure.cc.

197{
198 size_t i;
199 // Broadcast to subdirectories.
200 for( i=0; i<structure.size(); i++ )
201 {
202 structure[i]->Initialize(HCE);
203 }
204 // Initialize all detectors in this directory.
205 for( i=0; i<detector.size(); i++ )
206 {
207 if(detector[i]->isActive()) detector[i]->Initialize(HCE);
208 }
209}

Referenced by G4SDManager::PrepareNewEvent().

◆ ListTree()

void G4SDStructure::ListTree ( )

Definition at line 226 of file G4SDStructure.cc.

227{
228 G4cout << pathName << G4endl;
229 for(size_t i=0; i<detector.size(); i++)
230 {
231 G4VSensitiveDetector* sd = detector[i];
232 G4cout << pathName << sd->GetName();
233 if( sd->isActive() )
234 { G4cout << " *** Active "; }
235 else
236 { G4cout << " XXX Inactive "; }
237 G4cout << G4endl;
238 }
239 for(size_t j=0; j<structure.size(); j++)
240 { structure[j]->ListTree(); }
241}

Referenced by G4SDManager::ListTree().

◆ operator==()

G4int G4SDStructure::operator== ( const G4SDStructure right) const

Definition at line 58 of file G4SDStructure.cc.

59{
60 return (this==&right);
61}

◆ SetVerboseLevel()

void G4SDStructure::SetVerboseLevel ( G4int  vl)
inline

Definition at line 75 of file G4SDStructure.hh.

76 {
77 verboseLevel = vl;
78 for(size_t i=0; i<structure.size(); i++)
79 { structure[i]->SetVerboseLevel(vl); }
80 for(size_t j=0; j<detector.size(); j++)
81 { detector[j]->SetVerboseLevel(vl); }
82 };

Referenced by G4SDManager::SetVerboseLevel().

◆ Terminate()

void G4SDStructure::Terminate ( G4HCofThisEvent HCE)

Definition at line 211 of file G4SDStructure.cc.

212{
213 size_t i;
214 // Broadcast to subdirectories.
215 for( i=0; i<structure.size(); i++ )
216 {
217 structure[i]->Terminate(HCE);
218 }
219 // Initialize all detectors in this directory.
220 for( i=0; i<detector.size(); i++ )
221 {
222 if(detector[i]->isActive()) detector[i]->EndOfEvent(HCE);
223 }
224}

Referenced by G4SDManager::TerminateCurrentEvent().


The documentation for this class was generated from the following files: