Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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 50 of file G4HCtable.hh.

Constructor & Destructor Documentation

G4HCtable::G4HCtable ( )

Definition at line 33 of file G4HCtable.cc.

33 {;}
G4HCtable::~G4HCtable ( )

Definition at line 35 of file G4HCtable.cc.

35 {;}

Member Function Documentation

G4int G4HCtable::entries ( ) const
inline

Definition at line 66 of file G4HCtable.hh.

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

67  { return HClist.size(); }
G4int G4HCtable::GetCollectionID ( G4String  HCname) const

Definition at line 46 of file G4HCtable.cc.

References G4String::index().

Referenced by G4SDManager::GetCollectionID().

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

Definition at line 77 of file G4HCtable.cc.

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

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

Definition at line 73 of file G4HCtable.hh.

References entries().

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

Definition at line 68 of file G4HCtable.hh.

References entries().

69  {
70  if(i<0||i>entries()) return "***Not Defined***";
71  return SDlist[i];
72  }
G4int entries() const
Definition: G4HCtable.hh:66
G4int G4HCtable::Registor ( G4String  SDname,
G4String  HCname 
)

Definition at line 37 of file G4HCtable.cc.

Referenced by G4SDManager::AddNewCollection().

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

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