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

#include <G4HCtable.hh>

Public Member Functions

 G4HCtable ()
 
 ~G4HCtable ()
 
G4int Registor (G4String SDname, G4String HCname)
 
G4int GetCollectionID (G4String HCname) const
 
G4int GetCollectionID (G4VSensitiveDetector *aSD) const
 
G4int entries () const
 
G4String GetSDname (G4int i) const
 
G4String GetHCname (G4int i) const
 

Detailed Description

Definition at line 49 of file G4HCtable.hh.

Constructor & Destructor Documentation

◆ G4HCtable()

G4HCtable::G4HCtable ( )

Definition at line 32 of file G4HCtable.cc.

32{ ; }

◆ ~G4HCtable()

G4HCtable::~G4HCtable ( )

Definition at line 34 of file G4HCtable.cc.

34{ ; }

Member Function Documentation

◆ entries()

G4int G4HCtable::entries ( ) const
inline

Definition at line 65 of file G4HCtable.hh.

65{ return G4int(HClist.size()); }
int G4int
Definition: G4Types.hh:85

Referenced by G4SDManager::GetCollectionCapacity(), GetHCname(), GetSDname(), and G4SDManager::PrepareNewEvent().

◆ GetCollectionID() [1/2]

G4int G4HCtable::GetCollectionID ( G4String  HCname) const

Definition at line 48 of file G4HCtable.cc.

49{
50 G4int i = -1;
51 if(HCname.find("/") == std::string::npos) // HCname only
52 {
53 for(std::size_t j = 0; j < HClist.size(); ++j)
54 {
55 if(HClist[j] == HCname)
56 {
57 if(i >= 0)
58 return -2;
59 i = (G4int)j;
60 }
61 }
62 }
63 else
64 {
65 for(std::size_t j = 0; j < HClist.size(); ++j)
66 {
67 G4String tgt = SDlist[j];
68 tgt += "/";
69 tgt += HClist[j];
70 if(tgt == HCname)
71 {
72 if(i >= 0)
73 return -2;
74 i = (G4int)j;
75 }
76 }
77 }
78 return i;
79}

Referenced by G4SDManager::GetCollectionID().

◆ GetCollectionID() [2/2]

G4int G4HCtable::GetCollectionID ( G4VSensitiveDetector aSD) const

Definition at line 81 of file G4HCtable.cc.

82{
83 if(aSD->GetNumberOfCollections() < 1)
84 {
85 G4cerr << "Sensitive detector <" << aSD->GetName()
86 << "> does not have a registered hits collection." << G4endl;
87 return -1;
88 }
89 if(aSD->GetNumberOfCollections() > 1)
90 {
91 G4cerr << "Sensitive detector <" << aSD->GetName()
92 << "> has more than one registered hits collections." << G4endl;
93 G4cerr << "Candidates are : ";
94 for(G4int j = 0; j < aSD->GetNumberOfCollections(); ++j)
95 {
96 G4cerr << aSD->GetCollectionName(j) << " ";
97 }
98 G4cerr << G4endl;
99 return -1;
100 }
101 for(std::size_t k = 0; k < SDlist.size(); ++k)
102 {
103 if(SDlist[k] == aSD->GetName())
104 return (G4int)k;
105 }
106 return -1;
107}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4int GetNumberOfCollections() const
G4String GetCollectionName(G4int id) const

◆ GetHCname()

G4String G4HCtable::GetHCname ( G4int  i) const
inline

Definition at line 72 of file G4HCtable.hh.

73 {
74 if(i < 0 || i > entries())
75 return "***Not Defined***";
76 return HClist[i];
77 }
G4int entries() const
Definition: G4HCtable.hh:65

◆ GetSDname()

G4String G4HCtable::GetSDname ( G4int  i) const
inline

Definition at line 66 of file G4HCtable.hh.

67 {
68 if(i < 0 || i > entries())
69 return "***Not Defined***";
70 return SDlist[i];
71 }

◆ Registor()

G4int G4HCtable::Registor ( G4String  SDname,
G4String  HCname 
)

Definition at line 36 of file G4HCtable.cc.

37{
38 for(std::size_t i = 0; i < HClist.size(); ++i)
39 {
40 if(HClist[i] == HCname && SDlist[i] == SDname)
41 return -1;
42 }
43 HClist.push_back(HCname);
44 SDlist.push_back(SDname);
45 return (G4int)HClist.size();
46}

Referenced by G4SDManager::AddNewCollection().


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