Geant4-11
Public Member Functions | Private Attributes
G4HCtable Class Reference

#include <G4HCtable.hh>

Public Member Functions

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

Private Attributes

std::vector< G4StringHClist
 
std::vector< G4StringSDlist
 

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
std::vector< G4String > HClist
Definition: G4HCtable.hh:62

References HClist.

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(size_t j = 0; j < HClist.size(); j++)
54 {
55 if(HClist[j] == HCname)
56 {
57 if(i >= 0)
58 return -2;
59 i = j;
60 }
61 }
62 }
63 else
64 {
65 for(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 = j;
75 }
76 }
77 }
78 return i;
79}
std::vector< G4String > SDlist
Definition: G4HCtable.hh:61

References HClist, and SDlist.

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(size_t k = 0; k < SDlist.size(); k++)
102 {
103 if(SDlist[k] == aSD->GetName())
104 return 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

References G4cerr, G4endl, G4VSensitiveDetector::GetCollectionName(), G4VSensitiveDetector::GetName(), G4VSensitiveDetector::GetNumberOfCollections(), and SDlist.

◆ 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

References entries(), and HClist.

◆ 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 }

References entries(), and SDlist.

◆ 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 {
40 if(HClist[i] == HCname && SDlist[i] == SDname)
41 return -1;
42 }
43 HClist.push_back(HCname);
44 SDlist.push_back(SDname);
45 return HClist.size();
46}

References HClist, and SDlist.

Referenced by G4SDManager::AddNewCollection().

Field Documentation

◆ HClist

std::vector<G4String> G4HCtable::HClist
private

Definition at line 62 of file G4HCtable.hh.

Referenced by entries(), GetCollectionID(), GetHCname(), and Registor().

◆ SDlist

std::vector<G4String> G4HCtable::SDlist
private

Definition at line 61 of file G4HCtable.hh.

Referenced by GetCollectionID(), GetSDname(), and Registor().


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