Geant4-11
G4HCtable.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28
29#include "G4HCtable.hh"
31
33
35
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}
47
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}
80
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}
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
std::vector< G4String > SDlist
Definition: G4HCtable.hh:61
G4int Registor(G4String SDname, G4String HCname)
Definition: G4HCtable.cc:36
std::vector< G4String > HClist
Definition: G4HCtable.hh:62
G4int GetCollectionID(G4String HCname) const
Definition: G4HCtable.cc:48
~G4HCtable()
Definition: G4HCtable.cc:34
G4int GetNumberOfCollections() const
G4String GetCollectionName(G4int id) const