ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MultiSensitiveDetector.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4MultiSensitiveDetector.hh
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 
30 #include "G4VSensitiveDetector.hh"
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
47  virtual ~G4MultiSensitiveDetector();
48 
50 public:
51  //interface from G4VSensitiveDetector starts here.
52  //See G4VSensitiveDetector for documentation.
53  //All these methods forward the call to each of the SD
54  //attached to this proxy.
55  virtual void Initialize(G4HCofThisEvent*);
56  virtual void EndOfEvent(G4HCofThisEvent*);
57  virtual void clear();
58  virtual void DrawAll();
59  virtual void PrintAll();
60 protected:
61  //The return value is an AND of the called SDs return values.
62  //This method will call the "Hit(G4Step*)" method of all
63  //added SDs. Note that the ROhist of this method is not used
64  virtual G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
65  //The following method does not have a meaning for this concrete class
66  virtual G4int GetCollectionID(G4int i) final;
67 public:
68  //Note, that cloning works only if all the contained SDs are also
69  //clonable.
70  virtual G4VSensitiveDetector* Clone() const;
71 public:
72  //===== Main interface of this special SD
73  using sds_t = std::vector<G4VSensitiveDetector*>;
74  using sdsConstIter = sds_t::const_iterator;
75  G4VSensitiveDetector* GetSD(const int i) const { return fSensitiveDetectors[i]; }
76  sds_t::size_type GetSize() const { return fSensitiveDetectors.size(); }
77  sdsConstIter GetBegin() const { return fSensitiveDetectors.begin(); }
78  sdsConstIter GetEnd() const { return fSensitiveDetectors.end(); }
79  void ClearSDs() { fSensitiveDetectors.clear(); }
80  void AddSD( G4VSensitiveDetector* sd) { fSensitiveDetectors.push_back(sd); }
81 private:
83 };
84 
85 #endif //G4MULTISENSITIVEDETECTOR_H