Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:16:08

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 // G4VSensitiveDetector
0027 //
0028 // Class description:
0029 //
0030 // This is the abstract base class of the sensitive detector. The user's
0031 // sensitive detector which generates hits must be derived from this
0032 // class.
0033 // In the derived class constructor, name(s) of hits collection(s) which
0034 // are made by the sensitive detector must be set to "collectionName" string
0035 // vector.
0036 //
0037 // Author: Makoto Asai
0038 // ---------------------------------------------------------------------
0039 #ifndef G4VSensitiveDetector_h
0040 #define G4VSensitiveDetector_h 1
0041 
0042 #include "G4CollectionNameVector.hh"
0043 #include "G4HCofThisEvent.hh"
0044 #include "G4Step.hh"
0045 #include "G4TouchableHistory.hh"
0046 #include "G4VHit.hh"
0047 #include "G4VReadOutGeometry.hh"
0048 #include "G4VSDFilter.hh"
0049 
0050 class G4VSensitiveDetector
0051 {
0052  public:
0053   // Constructors. The user's concrete class must use one of these constructors
0054   // by the constructor initializer of the derived class. The name of
0055   // the sensitive detector must be unique.
0056   explicit G4VSensitiveDetector(const G4String& name);
0057   G4VSensitiveDetector(const G4VSensitiveDetector& right);
0058   G4VSensitiveDetector& operator=(const G4VSensitiveDetector& right);
0059   virtual ~G4VSensitiveDetector() = default;
0060 
0061   G4bool operator==(const G4VSensitiveDetector& right) const;
0062   G4bool operator!=(const G4VSensitiveDetector& right) const;
0063 
0064   //  These two methods are invoked at the begining and at the end of each
0065   // event. The hits collection(s) created by this sensitive detector must
0066   // be set to the G4HCofThisEvent object at one of these two methods.
0067   virtual void Initialize(G4HCofThisEvent*) {}
0068   virtual void EndOfEvent(G4HCofThisEvent*) {}
0069 
0070   //  This method is invoked if the event abortion is occured. Hits collections
0071   // created but not beibg set to G4HCofThisEvent at the event should be
0072   // deleted. Collection(s) which have already set to G4HCofThisEvent will be
0073   // deleted automatically.
0074   virtual void clear() {}
0075 
0076   virtual void DrawAll() {}
0077   virtual void PrintAll() {}
0078 
0079   //  This is the public method invoked by G4SteppingManager for generating
0080   // hit(s). The actual user's implementation for generating hit(s) must be
0081   // implemented in GenerateHits() virtual protected method. This method
0082   // MUST NOT be overriden.
0083   inline G4bool Hit(G4Step* aStep)
0084   {
0085     G4TouchableHistory* ROhis = nullptr;
0086     if (! isActive()) return false;
0087     if (filter != nullptr) {
0088       if (! (filter->Accept(aStep))) return false;
0089     }
0090     if (ROgeometry != nullptr) {
0091       if (! (ROgeometry->CheckROVolume(aStep, ROhis))) return false;
0092     }
0093     return ProcessHits(aStep, ROhis);
0094   }
0095 
0096   //  Register the Readout geometry.
0097   inline void SetROgeometry(G4VReadOutGeometry* value) { ROgeometry = value; }
0098 
0099   //  Register a filter
0100   inline void SetFilter(G4VSDFilter* value) { filter = value; }
0101 
0102   inline G4int GetNumberOfCollections() const { return G4int(collectionName.size()); }
0103   inline const G4String& GetCollectionName(G4int id) const { return collectionName[id]; }
0104   inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
0105   inline void Activate(G4bool activeFlag) { active = activeFlag; }
0106   inline G4bool isActive() const { return active; }
0107   inline const G4String& GetName() const { return SensitiveDetectorName; }
0108   inline const G4String& GetPathName() const { return thePathName; }
0109   inline const G4String& GetFullPathName() const { return fullPathName; }
0110   inline G4VReadOutGeometry* GetROgeometry() const { return ROgeometry; }
0111   inline G4VSDFilter* GetFilter() const { return filter; }
0112 
0113   virtual G4VSensitiveDetector* Clone() const;
0114 
0115  protected:  // with description
0116   //  The user MUST implement this method for generating hit(s) using the
0117   // information of G4Step object. Note that the volume and the position
0118   // information is kept in PreStepPoint of G4Step.
0119   //  Be aware that this method is a protected method and it sill be invoked
0120   // by Hit() method of Base class after Readout geometry associated to the
0121   // sensitive detector is handled.
0122   //  "ROhist" will be given only is a Readout geometry is defined to this
0123   // sensitive detector. The G4TouchableHistory object of the tracking geometry
0124   // is stored in the PreStepPoint object of G4Step.
0125   virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist) = 0;
0126 
0127   //  This is a utility method which returns the hits collection ID of the
0128   // "i"-th collection. "i" is the order (starting with zero) of the collection
0129   // whose name is stored to the collectionName protected vector.
0130   virtual G4int GetCollectionID(G4int i);
0131 
0132  protected:
0133   //  This protected name vector must be filled at the constructor of the user's
0134   // concrete class for registering the name(s) of hits collection(s) being
0135   // created by this particular sensitive detector.
0136   G4CollectionNameVector collectionName;
0137 
0138   G4String SensitiveDetectorName;  // detector name
0139   G4String thePathName;  // directory path
0140   G4String fullPathName;  // path + detector name
0141   G4int verboseLevel{0};
0142   G4bool active{true};
0143   G4VReadOutGeometry* ROgeometry{nullptr};
0144   G4VSDFilter* filter{nullptr};
0145 };
0146 
0147 #endif