Geant4 10.7.0
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.

66 { 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 45 of file G4HCtable.cc.

46{
47 G4int i = -1;
48 if(HCname.index("/")==std::string::npos) // HCname only
49 {
50 for(size_t j=0;j<HClist.size();j++)
51 {
52 if(HClist[j]==HCname)
53 {
54 if(i>=0) return -2;
55 i = j;
56 }
57 }
58 }
59 else
60 {
61 for(size_t j=0;j<HClist.size();j++)
62 {
63 G4String tgt = SDlist[j];
64 tgt += "/";
65 tgt += HClist[j];
66 if(tgt==HCname)
67 {
68 if(i>=0) return -2;
69 i = j;
70 }
71 }
72 }
73 return i;
74}
str_size index(const char *, G4int pos=0) const

Referenced by G4SDManager::GetCollectionID().

◆ GetCollectionID() [2/2]

G4int G4HCtable::GetCollectionID ( G4VSensitiveDetector aSD) const

Definition at line 76 of file G4HCtable.cc.

77{
78 if(aSD->GetNumberOfCollections()<1)
79 {
80 G4cerr << "Sensitive detector <" << aSD->GetName()
81 << "> does not have a registered hits collection."
82 << G4endl;
83 return -1;
84 }
85 if(aSD->GetNumberOfCollections()>1)
86 {
87 G4cerr << "Sensitive detector <" << aSD->GetName()
88 << "> has more than one registered hits collections."
89 << G4endl;
90 G4cerr << "Candidates are : ";
91 for(G4int j=0;j<aSD->GetNumberOfCollections();j++)
92 { G4cerr << aSD->GetCollectionName(j) << " "; }
93 G4cerr << G4endl;
94 return -1;
95 }
96 for(size_t k=0;k<SDlist.size();k++)
97 { if(SDlist[k]==aSD->GetName()) return k; }
98 return -1;
99}
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()) return "***Not Defined***";
75 return HClist[i];
76 }
G4int entries() const
Definition: G4HCtable.hh:65

◆ GetSDname()

G4String G4HCtable::GetSDname ( G4int  i) const
inline

Definition at line 67 of file G4HCtable.hh.

68 {
69 if(i<0||i>entries()) 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(size_t i=0;i<HClist.size();i++)
39 { if(HClist[i]==HCname && SDlist[i]==SDname) return -1; }
40 HClist.push_back(HCname);
41 SDlist.push_back(SDname);
42 return HClist.size();
43}

Referenced by G4SDManager::AddNewCollection().


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