Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:27

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