Geant4-11
G4MultiSensitiveDetector.hh
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#ifndef G4MULTISENSITIVEDETECTOR_H
28#define G4MULTISENSITIVEDETECTOR_H
29
31#include <vector>
32
33// class description:
34// This class allows to assign multiple sensitive detectors to a single
35// logical-volume.
36// SDs are added to this proxy and an instance of the proxy is assigned
37// to the logical volume. Calls to SD methods are forwarded to ALL
38// user-defined SD that are added.
39
41{
42 public:
44 // Second optional parameter allows to append to the SDname a random string
46 // Cosntructors. The name of the instance must be unique
48
50
51 public:
52 // interface from G4VSensitiveDetector starts here.
53 // See G4VSensitiveDetector for documentation.
54 // All these methods forward the call to each of the SD
55 // attached to this proxy.
56 virtual void Initialize(G4HCofThisEvent*);
57 virtual void EndOfEvent(G4HCofThisEvent*);
58 virtual void clear();
59 virtual void DrawAll();
60 virtual void PrintAll();
61
62 protected:
63 // The return value is an AND of the called SDs return values.
64 // This method will call the "Hit(G4Step*)" method of all
65 // added SDs. Note that the ROhist of this method is not used
66 virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist);
67 // The following method does not have a meaning for this concrete class
68 virtual G4int GetCollectionID(G4int i) final;
69
70 public:
71 // Note, that cloning works only if all the contained SDs are also
72 // clonable.
73 virtual G4VSensitiveDetector* Clone() const;
74
75 public:
76 //===== Main interface of this special SD
77 using sds_t = std::vector<G4VSensitiveDetector*>;
78 using sdsConstIter = sds_t::const_iterator;
79 G4VSensitiveDetector* GetSD(const int i) const
80 {
81 return fSensitiveDetectors[i];
82 }
83 sds_t::size_type GetSize() const { return fSensitiveDetectors.size(); }
84 sdsConstIter GetBegin() const { return fSensitiveDetectors.begin(); }
85 sdsConstIter GetEnd() const { return fSensitiveDetectors.end(); }
86 void ClearSDs() { fSensitiveDetectors.clear(); }
87 void AddSD(G4VSensitiveDetector* sd) { fSensitiveDetectors.push_back(sd); }
88
89 private:
91};
92
93#endif // G4MULTISENSITIVEDETECTOR_H
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4MultiSensitiveDetector & operator=(const G4MultiSensitiveDetector &rhs)
virtual G4int GetCollectionID(G4int i) final
void AddSD(G4VSensitiveDetector *sd)
virtual void Initialize(G4HCofThisEvent *)
std::vector< G4VSensitiveDetector * > sds_t
virtual void EndOfEvent(G4HCofThisEvent *)
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
virtual G4VSensitiveDetector * Clone() const
sds_t::const_iterator sdsConstIter
sds_t::size_type GetSize() const
G4VSensitiveDetector * GetSD(const int i) const
Definition: G4Step.hh:62
const char * name(G4int ptype)