Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 ( 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 }
G4String & remove(str_size)
int G4int
Definition: G4Types.hh:78
G4int last(char) const

Here is the call graph for this function:

Here is the caller graph for this function:

G4SDStructure::~G4SDStructure ( )

Definition at line 48 of file G4SDStructure.cc.

49 {
50  for(auto st : structure) delete st;
51  structure.clear();
52  for(auto dt : detector) delete dt;
53  detector.clear();
54 }

Member Function Documentation

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

Definition at line 127 of file G4SDStructure.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 61 of file G4SDStructure.cc.

63 {
64  G4String remainingPath = treeStructure;
65  remainingPath.remove(0,pathName.length());
66  if( ! remainingPath.isNull() )
67  { // The detector should be kept in subdirectory.
68  // First, check if the subdirectoy exists.
69  G4String subD = ExtractDirName( remainingPath );
70  G4SDStructure* tgtSDS = FindSubDirectory(subD);
71  if( tgtSDS == nullptr )
72  { // Subdirectory not found. Create a new directory.
73  subD.prepend(pathName);
74  tgtSDS = new G4SDStructure(subD);
75  structure.push_back( tgtSDS );
76  }
77  tgtSDS->AddNewDetector(aSD,treeStructure);
78  }
79  else
80  { // The sensitive detector should be kept in this directory.
81  G4VSensitiveDetector* tgtSD = GetSD( aSD->GetName() );
82  if(!tgtSD)
83  { detector.push_back( aSD ); }
84  else if( tgtSD != aSD )
85  {
86 #ifdef G4VERBOSE
88  ed << aSD->GetName() << " had already been stored in "
89  << pathName << ". Object pointer is overwitten.\n";
90  ed << "It's users' responsibility to delete the old sensitive detector object.";
91  G4Exception("G4SDStructure::AddNewDetector()","DET1010",JustWarning,ed);
92 #endif
93  RemoveSD( tgtSD );
94  detector.push_back( aSD );
95  }
96  }
97 }
void AddNewDetector(G4VSensitiveDetector *aSD, G4String treeStructure)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String & remove(str_size)
G4String & prepend(const char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VSensitiveDetector * GetSD(G4String aName)
G4SDStructure(G4String aPath)
G4bool isNull() const

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 163 of file G4SDStructure.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4VSensitiveDetector * G4SDStructure::GetSD ( G4String  aName)

Definition at line 106 of file G4SDStructure.cc.

107 {
108  for(auto det : detector)
109  { if(aSDName == det->GetName()) return det; }
110  return nullptr;
111 }

Here is the caller graph for this function:

void G4SDStructure::Initialize ( G4HCofThisEvent HCE)

Definition at line 194 of file G4SDStructure.cc.

195 {
196  // Broadcast to subdirectories.
197  for(auto st : structure)
198  { st->Initialize(HCE); }
199  // Initialize all detectors in this directory.
200  for(auto dt : detector)
201  { if(dt->isActive()) dt->Initialize(HCE); }
202 }

Here is the caller graph for this function:

void G4SDStructure::ListTree ( )

Definition at line 214 of file G4SDStructure.cc.

215 {
216  G4cout << pathName << G4endl;
217  for(auto sd : detector)
218  {
219  G4cout << pathName << sd->GetName();
220  if( sd->isActive() )
221  { G4cout << " *** Active "; }
222  else
223  { G4cout << " XXX Inactive "; }
224  G4cout << G4endl;
225  }
226  for(auto st : structure) st->ListTree();
227 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 56 of file G4SDStructure.cc.

57 {
58  return (this==&right);
59 }
void G4SDStructure::SetVerboseLevel ( G4int  vl)
inline

Definition at line 76 of file G4SDStructure.hh.

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

Here is the caller graph for this function:

void G4SDStructure::Terminate ( G4HCofThisEvent HCE)

Definition at line 204 of file G4SDStructure.cc.

205 {
206  // Broadcast to subdirectories.
207  for(auto st : structure)
208  { st->Terminate(HCE); }
209  // Terminate all detectors in this directory.
210  for(auto dt : detector)
211  { if(dt->isActive()) dt->EndOfEvent(HCE); }
212 }

Here is the caller graph for this function:


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