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

#include <G4SDManager.hh>

Public Member Functions

 ~G4SDManager ()
 
void AddNewDetector (G4VSensitiveDetector *aSD)
 
void Activate (G4String dName, G4bool activeFlag)
 
G4int GetCollectionID (G4String colName)
 
G4int GetCollectionID (G4VHitsCollection *aHC)
 
G4VSensitiveDetectorFindSensitiveDetector (G4String dName, G4bool warning=true)
 
G4HCofThisEventPrepareNewEvent ()
 
void TerminateCurrentEvent (G4HCofThisEvent *HCE)
 
void AddNewCollection (G4String SDname, G4String DCname)
 
void SetVerboseLevel (G4int vl)
 
G4SDStructureGetTreeTop () const
 
void ListTree () const
 
G4int GetCollectionCapacity () const
 
G4HCtableGetHCtable () const
 
void RegisterSDFilter (G4VSDFilter *filter)
 
void DeRegisterSDFilter (G4VSDFilter *filter)
 

Static Public Member Functions

static G4SDManagerGetSDMpointer ()
 
static G4SDManagerGetSDMpointerIfExist ()
 

Protected Member Functions

 G4SDManager ()
 

Detailed Description

Definition at line 52 of file G4SDManager.hh.

Constructor & Destructor Documentation

◆ G4SDManager()

G4SDManager::G4SDManager ( )
protected

Definition at line 51 of file G4SDManager.cc.

51 :verboseLevel(0)
52{
53 G4String topName = "/";
54 treeTop = new G4SDStructure(topName);
55 theMessenger = new G4SDmessenger(this);
56 HCtable = new G4HCtable;
57}

Referenced by GetSDMpointer().

◆ ~G4SDManager()

G4SDManager::~G4SDManager ( )

Definition at line 59 of file G4SDManager.cc.

60{
61 delete theMessenger;
62 delete HCtable;
63 delete treeTop;
64 DestroyFilters();
65 theMessenger = nullptr;
66 HCtable = nullptr;
67 treeTop = nullptr;
68 fSDManager = nullptr;
69}

Member Function Documentation

◆ Activate()

void G4SDManager::Activate ( G4String  dName,
G4bool  activeFlag 
)

Definition at line 121 of file G4SDManager.cc.

122{
123 G4String pathName = dName;
124 if( pathName(0) != '/' ) pathName.prepend("/");
125 treeTop->Activate(pathName,activeFlag);
126}
void Activate(const G4String &aName, G4bool sensitiveFlag)
G4String & prepend(const char *)

Referenced by G4RTRunAction::BeginOfRunAction(), G4RTRunAction::EndOfRunAction(), G4TheRayTracer::RestoreUserActions(), G4SDmessenger::SetNewValue(), and G4TheRayTracer::StoreUserActions().

◆ AddNewCollection()

void G4SDManager::AddNewCollection ( G4String  SDname,
G4String  DCname 
)

Definition at line 92 of file G4SDManager.cc.

93{
94 G4int i = HCtable->Registor(SDname,DCname);
95 if(verboseLevel>0)
96 {
97 if(i<0) {
98 if(verboseLevel>1) G4cout << "G4SDManager::AddNewCollection : the collection <"
99 << SDname << "/" << DCname << "> has already been reginstered." << G4endl;
100 }
101 else
102 {
103 G4cout << "G4SDManager::AddNewCollection : the collection <"
104 << SDname << "/" << DCname << "> is registered at " << i << G4endl;
105 }
106 }
107}
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4int Registor(G4String SDname, G4String HCname)
Definition: G4HCtable.cc:36

Referenced by AddNewDetector(), and G4MultiFunctionalDetector::RegisterPrimitive().

◆ AddNewDetector()

void G4SDManager::AddNewDetector ( G4VSensitiveDetector aSD)

Definition at line 71 of file G4SDManager.cc.

72{
73 G4int numberOfCollections = aSD->GetNumberOfCollections();
74 G4String pathName = aSD->GetPathName();
75 if( pathName(0) != '/' ) pathName.prepend("/");
76 if( pathName(pathName.length()-1) != '/' ) pathName += "/";
77 treeTop->AddNewDetector(aSD,pathName);
78 if(numberOfCollections<1) return;
79 for(G4int i=0;i<numberOfCollections;i++)
80 {
81 G4String SDname = aSD->GetName();
82 G4String DCname = aSD->GetCollectionName(i);
83 AddNewCollection(SDname,DCname);
84 }
85 if( verboseLevel > 0 )
86 {
87 G4cout << "New sensitive detector <" << aSD->GetName()
88 << "> is registered at " << pathName << G4endl;
89 }
90}
void AddNewCollection(G4String SDname, G4String DCname)
Definition: G4SDManager.cc:92
void AddNewDetector(G4VSensitiveDetector *aSD, const G4String &treeStructure)
G4int GetNumberOfCollections() const
G4String GetCollectionName(G4int id) const
G4String GetPathName() const

Referenced by G4VScoringMesh::G4VScoringMesh(), G4VUserDetectorConstruction::SetSensitiveDetector(), and G4VUserParallelWorld::SetSensitiveDetector().

◆ DeRegisterSDFilter()

void G4SDManager::DeRegisterSDFilter ( G4VSDFilter filter)

Definition at line 158 of file G4SDManager.cc.

159{
160 for(auto f = FilterList.begin(); f != FilterList.end(); f++)
161 {
162 if(*f == filter)
163 {
164 FilterList.erase(f);
165 break;
166 }
167 }
168}

Referenced by G4VSDFilter::~G4VSDFilter().

◆ FindSensitiveDetector()

G4VSensitiveDetector * G4SDManager::FindSensitiveDetector ( G4String  dName,
G4bool  warning = true 
)

Definition at line 128 of file G4SDManager.cc.

129{
130 G4String pathName = dName;
131 if( pathName(0) != '/' ) pathName.prepend("/");
132 return treeTop->FindSensitiveDetector(pathName, warning);
133}
G4VSensitiveDetector * FindSensitiveDetector(const G4String &aName, G4bool warning=true)

◆ GetCollectionCapacity()

G4int G4SDManager::GetCollectionCapacity ( ) const
inline

Definition at line 101 of file G4SDManager.hh.

102 { return HCtable->entries(); }
G4int entries() const
Definition: G4HCtable.hh:65

◆ GetCollectionID() [1/2]

G4int G4SDManager::GetCollectionID ( G4String  colName)

Definition at line 135 of file G4SDManager.cc.

136{
137 G4int id = HCtable->GetCollectionID(colName);
138 if(id==-1)
139 { G4cout << "<" << colName << "> is not found." << G4endl; }
140 else if(id==-2)
141 { G4cout << "<" << colName << "> is ambiguous." << G4endl; }
142 return id;
143}
G4int GetCollectionID(G4String HCname) const
Definition: G4HCtable.cc:45

Referenced by G4VSensitiveDetector::GetCollectionID(), G4VPrimitiveScorer::GetCollectionID(), GetCollectionID(), and G4DigiManager::GetHitsCollectionID().

◆ GetCollectionID() [2/2]

G4int G4SDManager::GetCollectionID ( G4VHitsCollection aHC)

Definition at line 145 of file G4SDManager.cc.

146{
147 G4String HCname = aHC->GetSDname();
148 HCname += "/";
149 HCname += aHC->GetName();
150 return GetCollectionID(HCname);
151}
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
const G4String & GetSDname() const
const G4String & GetName() const

◆ GetHCtable()

G4HCtable * G4SDManager::GetHCtable ( ) const
inline

◆ GetSDMpointer()

◆ GetSDMpointerIfExist()

◆ GetTreeTop()

G4SDStructure * G4SDManager::GetTreeTop ( ) const
inline

Definition at line 97 of file G4SDManager.hh.

98 { return treeTop; }

◆ ListTree()

void G4SDManager::ListTree ( ) const
inline

Definition at line 99 of file G4SDManager.hh.

100 { treeTop->ListTree(); }

Referenced by G4SDmessenger::SetNewValue().

◆ PrepareNewEvent()

G4HCofThisEvent * G4SDManager::PrepareNewEvent ( )

Definition at line 109 of file G4SDManager.cc.

110{
111 G4HCofThisEvent* HCE = new G4HCofThisEvent(HCtable->entries());
112 treeTop->Initialize(HCE);
113 return HCE;
114}
void Initialize(G4HCofThisEvent *HCE)

Referenced by G4RunManager::RunInitialization(), G4WorkerRunManager::RunInitialization(), and G4WorkerTaskRunManager::RunInitialization().

◆ RegisterSDFilter()

void G4SDManager::RegisterSDFilter ( G4VSDFilter filter)

Definition at line 153 of file G4SDManager.cc.

154{
155 FilterList.push_back(filter);
156}

Referenced by G4VSDFilter::G4VSDFilter().

◆ SetVerboseLevel()

void G4SDManager::SetVerboseLevel ( G4int  vl)
inline

Definition at line 92 of file G4SDManager.hh.

93 {
94 verboseLevel = vl;
95 treeTop->SetVerboseLevel(vl);
96 }
void SetVerboseLevel(G4int vl)

Referenced by G4SDmessenger::SetNewValue().

◆ TerminateCurrentEvent()

void G4SDManager::TerminateCurrentEvent ( G4HCofThisEvent HCE)

Definition at line 116 of file G4SDManager.cc.

117{
118 treeTop->Terminate(HCE);
119}
void Terminate(G4HCofThisEvent *HCE)

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