Geant4 11.2.2
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 ()=default
 
 ~G4HCtable ()=default
 
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 ( )
default

◆ ~G4HCtable()

G4HCtable::~G4HCtable ( )
default

Member Function Documentation

◆ entries()

G4int G4HCtable::entries ( ) const
inline

Definition at line 60 of file G4HCtable.hh.

60{ 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 43 of file G4HCtable.cc.

44{
45 G4int i = -1;
46 if (HCname.find('/') == std::string::npos) // HCname only
47 {
48 for (std::size_t j = 0; j < HClist.size(); ++j) {
49 if (HClist[j] == HCname) {
50 if (i >= 0) return -2;
51 i = (G4int)j;
52 }
53 }
54 }
55 else {
56 for (std::size_t j = 0; j < HClist.size(); ++j) {
57 G4String tgt = SDlist[j];
58 tgt += "/";
59 tgt += HClist[j];
60 if (tgt == HCname) {
61 if (i >= 0) return -2;
62 i = (G4int)j;
63 }
64 }
65 }
66 return i;
67}

Referenced by G4SDManager::GetCollectionID().

◆ GetCollectionID() [2/2]

G4int G4HCtable::GetCollectionID ( G4VSensitiveDetector * aSD) const

Definition at line 69 of file G4HCtable.cc.

70{
71 if (aSD->GetNumberOfCollections() < 1) {
72 G4cerr << "Sensitive detector <" << aSD->GetName()
73 << "> does not have a registered hits collection." << G4endl;
74 return -1;
75 }
76 if (aSD->GetNumberOfCollections() > 1) {
77 G4cerr << "Sensitive detector <" << aSD->GetName()
78 << "> has more than one registered hits collections." << G4endl;
79 G4cerr << "Candidates are : ";
80 for (G4int j = 0; j < aSD->GetNumberOfCollections(); ++j) {
81 G4cerr << aSD->GetCollectionName(j) << " ";
82 }
83 G4cerr << G4endl;
84 return -1;
85 }
86 for (std::size_t k = 0; k < SDlist.size(); ++k) {
87 if (SDlist[k] == aSD->GetName()) return (G4int)k;
88 }
89 return -1;
90}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67
G4String GetCollectionName(G4int id) const

◆ GetHCname()

G4String G4HCtable::GetHCname ( G4int i) const
inline

Definition at line 68 of file G4HCtable.hh.

69 {
70 if (i < 0 || i > entries()) return "***Not Defined***";
71 return HClist[i];
72 }
G4int entries() const
Definition G4HCtable.hh:60

◆ GetSDname()

G4String G4HCtable::GetSDname ( G4int i) const
inline

Definition at line 62 of file G4HCtable.hh.

63 {
64 if (i < 0 || i > entries()) return "***Not Defined***";
65 return SDlist[i];
66 }

◆ Registor()

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

Definition at line 33 of file G4HCtable.cc.

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

Referenced by G4SDManager::AddNewCollection().


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