Geant4  10.00.p01
CCalSensitiveDetectors.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 //
27 // File: CCalSensitiveDetectors.cc
28 // Description: Provides a map of logicalvolume pointers which can be sensitive
30 
32 
33 //#define debug
34 
36 
37 
40  return theInstance;
41 }
42 
43 
46 
47  theLVs.insert(mmslv::value_type(string, logv));
48 #ifdef debug
49  G4cout << "CCalSensitiveDetectors : Register " << logv->GetName()
50  << " in category " << string << G4endl;
51 #endif
52 }
53 
54 std::vector<G4LogicalVolume*> CCalSensitiveDetectors::getVolumes (const G4String& string,
55  bool exist) {
56 
57  mmslv::const_iterator mmscite;
58  std::pair<mmslv::iterator, mmslv::iterator> mmsdi;
59  mmsdi = theLVs.equal_range(string);
60  std::vector<G4LogicalVolume*> lvs;
61  for (mmscite = mmsdi.first; mmscite != mmsdi.second; mmscite++ ) {
62  lvs.push_back(const_cast<G4LogicalVolume*>((*mmscite).second));
63  }
64 
65  if (exist) G4cout << "CCalSensitiveDetector : " << lvs.size()
66  << " detectors for " << string << G4endl;
67 
68  return lvs;
69 }
70 
71 
73  G4VSensitiveDetector* sens) {
74 
75  bool result=false;
76  mmslv::const_iterator mmscite;
77  std::pair<mmslv::iterator, mmslv::iterator> mmsdi;
78  mmsdi = theLVs.equal_range(string);
79  for (mmscite = mmsdi.first; mmscite != mmsdi.second; mmscite++ ) {
80  G4LogicalVolume* lv = const_cast<G4LogicalVolume*>((*mmscite).second);
81  lv ->SetSensitiveDetector(sens);
82  result = true;
83 #ifdef debug
84  G4cout << " Associate SD " << sens->GetName() << " to " << lv->GetName()
85  << G4endl;
86 #endif
87  }
88  return result;
89 
90 }
G4String GetName() const
std::vector< G4LogicalVolume * > getVolumes(const G4String &name, bool exists=0)
static CCalSensitiveDetectors * getInstance()
static CCalSensitiveDetectors * theInstance
void logv(const uint32_t size, G4double const *__restrict__ iarray, G4double *__restrict__ oarray)
void registerVolume(const G4String &name, G4LogicalVolume *)
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
bool setSensitive(const G4String &string, G4VSensitiveDetector *sens)