Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:42

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 //
0027 #ifndef G4MULTISENSITIVEDETECTOR_H
0028 #define G4MULTISENSITIVEDETECTOR_H
0029 
0030 #include "G4VSensitiveDetector.hh"
0031 
0032 #include <vector>
0033 
0034 // class description:
0035 // This class allows to assign multiple sensitive detectors to a single
0036 // logical-volume.
0037 // SDs are added to this proxy and an instance of the proxy is assigned
0038 // to the logical volume. Calls to SD methods are forwarded to ALL
0039 // user-defined SD that are added.
0040 
0041 class G4MultiSensitiveDetector : public G4VSensitiveDetector
0042 {
0043  public:
0044   using sds_t = std::vector<G4VSensitiveDetector*>;
0045   using sdsConstIter = sds_t::const_iterator;
0046 
0047  public:
0048   using G4VSensitiveDetector::G4VSensitiveDetector;
0049   ~G4MultiSensitiveDetector() override = default;
0050 
0051   G4MultiSensitiveDetector(const G4MultiSensitiveDetector& rhs) = default;
0052   G4MultiSensitiveDetector& operator=(const G4MultiSensitiveDetector& rhs) = default;
0053 
0054  public:
0055   // interface from G4VSensitiveDetector starts here.
0056   // See G4VSensitiveDetector for documentation.
0057   // All these methods forward the call to each of the SD
0058   // attached to this proxy.
0059   void Initialize(G4HCofThisEvent*) override;
0060   void EndOfEvent(G4HCofThisEvent*) override;
0061   void clear() override;
0062   void DrawAll() override;
0063   void PrintAll() override;
0064 
0065   // Return clone of this detector
0066   // Requires all held SDs to be cloneable
0067   G4VSensitiveDetector* Clone() const override;
0068 
0069   G4VSensitiveDetector* GetSD(const int i) const { return fSensitiveDetectors[i]; }
0070 
0071   sds_t::size_type GetSize() const { return fSensitiveDetectors.size(); }
0072   sdsConstIter GetBegin() const { return fSensitiveDetectors.begin(); }
0073   sdsConstIter GetEnd() const { return fSensitiveDetectors.end(); }
0074   void ClearSDs() { fSensitiveDetectors.clear(); }
0075   void AddSD(G4VSensitiveDetector* sd) { fSensitiveDetectors.push_back(sd); }
0076 
0077  protected:
0078   // The return value is an AND of the called SDs return values.
0079   // This method will call the "Hit(G4Step*)" method of all
0080   // added SDs. Note that the ROhist of this method is not used
0081   G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist) override;
0082 
0083   // The following method does not have a meaning for this concrete class
0084   G4int GetCollectionID(G4int i) final;
0085 
0086  private:
0087   sds_t fSensitiveDetectors;
0088 };
0089 
0090 #endif  // G4MULTISENSITIVEDETECTOR_H