Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-05 09:42:15

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4MultiSensitiveDetector
0027 //
0028 // Class description:
0029 //
0030 // This class allows to assign multiple sensitive detectors to a single
0031 // logical-volume.
0032 // SDs are added to this proxy and an instance of the proxy is assigned
0033 // to the logical volume. Calls to SD methods are forwarded to ALL
0034 // user-defined SD that are added.
0035 //
0036 // Author: Makoto Asai
0037 // --------------------------------------------------------------------
0038 #ifndef G4MULTISENSITIVEDETECTOR_H
0039 #define G4MULTISENSITIVEDETECTOR_H 1
0040 
0041 #include "G4VSensitiveDetector.hh"
0042 
0043 #include <vector>
0044 
0045 class G4MultiSensitiveDetector : public G4VSensitiveDetector
0046 {
0047  public:
0048   using sds_t = std::vector<G4VSensitiveDetector*>;
0049   using sdsConstIter = sds_t::const_iterator;
0050 
0051  public:
0052   using G4VSensitiveDetector::G4VSensitiveDetector;
0053   ~G4MultiSensitiveDetector() override = default;
0054 
0055   G4MultiSensitiveDetector(const G4MultiSensitiveDetector& rhs) = default;
0056   G4MultiSensitiveDetector& operator=(const G4MultiSensitiveDetector& rhs) = default;
0057 
0058  public:
0059   // interface from G4VSensitiveDetector starts here.
0060   // See G4VSensitiveDetector for documentation.
0061   // All these methods forward the call to each of the SD
0062   // attached to this proxy.
0063   void Initialize(G4HCofThisEvent*) override;
0064   void EndOfEvent(G4HCofThisEvent*) override;
0065   void clear() override;
0066   void DrawAll() override;
0067   void PrintAll() override;
0068 
0069   // Return clone of this detector
0070   // Requires all held SDs to be cloneable
0071   G4VSensitiveDetector* Clone() const override;
0072 
0073   G4VSensitiveDetector* GetSD(const int i) const { return fSensitiveDetectors[i]; }
0074 
0075   sds_t::size_type GetSize() const { return fSensitiveDetectors.size(); }
0076   sdsConstIter GetBegin() const { return fSensitiveDetectors.begin(); }
0077   sdsConstIter GetEnd() const { return fSensitiveDetectors.end(); }
0078   void ClearSDs() { fSensitiveDetectors.clear(); }
0079   void AddSD(G4VSensitiveDetector* sd) { fSensitiveDetectors.push_back(sd); }
0080 
0081  protected:
0082   // The return value is an AND of the called SDs return values.
0083   // This method will call the "Hit(G4Step*)" method of all
0084   // added SDs. Note that the ROhist of this method is not used
0085   G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist) override;
0086 
0087   // The following method does not have a meaning for this concrete class
0088   G4int GetCollectionID(G4int i) final;
0089 
0090  private:
0091   sds_t fSensitiveDetectors;
0092 };
0093 
0094 #endif  // G4MULTISENSITIVEDETECTOR_H