Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VSensitiveDetector.hh
Go to the documentation of this file.
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//
28
29#ifndef G4VSensitiveDetector_h
30#define G4VSensitiveDetector_h 1
31
33#include "G4HCofThisEvent.hh"
34#include "G4Step.hh"
35#include "G4TouchableHistory.hh"
36#include "G4VHit.hh"
37#include "G4VReadOutGeometry.hh"
38#include "G4VSDFilter.hh"
39
40// class description:
41//
42// This is the abstract base class of the sensitive detector. The user's
43// sensitive detector which generates hits must be derived from this
44// class.
45// In the derived class constructor, name(s) of hits collection(s) which
46// are made by the sensitive detector must be set to "collectionName" string
47// vector.
48
50{
51 public:
52 // Constructors. The user's concrete class must use one of these constructors
53 // by the constructor initializer of the derived class. The name of
54 // the sensitive detector must be unique.
55 explicit G4VSensitiveDetector(G4String name);
58 virtual ~G4VSensitiveDetector() = default;
59
60 G4bool operator==(const G4VSensitiveDetector& right) const;
61 G4bool operator!=(const G4VSensitiveDetector& right) const;
62
63 // These two methods are invoked at the begining and at the end of each
64 // event. The hits collection(s) created by this sensitive detector must
65 // be set to the G4HCofThisEvent object at one of these two methods.
66 virtual void Initialize(G4HCofThisEvent*) {}
67 virtual void EndOfEvent(G4HCofThisEvent*) {}
68
69 // This method is invoked if the event abortion is occured. Hits collections
70 // created but not beibg set to G4HCofThisEvent at the event should be
71 // deleted. Collection(s) which have already set to G4HCofThisEvent will be
72 // deleted automatically.
73 virtual void clear() {}
74
75 virtual void DrawAll() {}
76 virtual void PrintAll() {}
77
78 // This is the public method invoked by G4SteppingManager for generating
79 // hit(s). The actual user's implementation for generating hit(s) must be
80 // implemented in GenerateHits() virtual protected method. This method
81 // MUST NOT be overriden.
82 inline G4bool Hit(G4Step* aStep)
83 {
84 G4TouchableHistory* ROhis = nullptr;
85 if (! isActive()) return false;
86 if (filter != nullptr) {
87 if (! (filter->Accept(aStep))) return false;
88 }
89 if (ROgeometry != nullptr) {
90 if (! (ROgeometry->CheckROVolume(aStep, ROhis))) return false;
91 }
92 return ProcessHits(aStep, ROhis);
93 }
94
95 // Register the Readout geometry.
96 inline void SetROgeometry(G4VReadOutGeometry* value) { ROgeometry = value; }
97
98 // Register a filter
99 inline void SetFilter(G4VSDFilter* value) { filter = value; }
100
101 inline G4int GetNumberOfCollections() const { return G4int(collectionName.size()); }
102 inline G4String GetCollectionName(G4int id) const { return collectionName[id]; }
103 inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
104 inline void Activate(G4bool activeFlag) { active = activeFlag; }
105 inline G4bool isActive() const { return active; }
106 inline G4String GetName() const { return SensitiveDetectorName; }
107 inline G4String GetPathName() const { return thePathName; }
108 inline G4String GetFullPathName() const { return fullPathName; }
109 inline G4VReadOutGeometry* GetROgeometry() const { return ROgeometry; }
110 inline G4VSDFilter* GetFilter() const { return filter; }
111
112 virtual G4VSensitiveDetector* Clone() const;
113
114 protected: // with description
115 // The user MUST implement this method for generating hit(s) using the
116 // information of G4Step object. Note that the volume and the position
117 // information is kept in PreStepPoint of G4Step.
118 // Be aware that this method is a protected method and it sill be invoked
119 // by Hit() method of Base class after Readout geometry associated to the
120 // sensitive detector is handled.
121 // "ROhist" will be given only is a Readout geometry is defined to this
122 // sensitive detector. The G4TouchableHistory object of the tracking geometry
123 // is stored in the PreStepPoint object of G4Step.
124 virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist) = 0;
125
126 // This is a utility method which returns the hits collection ID of the
127 // "i"-th collection. "i" is the order (starting with zero) of the collection
128 // whose name is stored to the collectionName protected vector.
129 virtual G4int GetCollectionID(G4int i);
130
131 protected:
132 // This protected name vector must be filled at the constructor of the user's
133 // concrete class for registering the name(s) of hits collection(s) being
134 // created by this particular sensitive detector.
136
138 G4String thePathName; // directory path
139 G4String fullPathName; // path + detector name
144};
145
146#endif
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
virtual G4bool CheckROVolume(G4Step *, G4TouchableHistory *&)
virtual G4bool Accept(const G4Step *) const =0
virtual G4VSensitiveDetector * Clone() const
virtual ~G4VSensitiveDetector()=default
void SetROgeometry(G4VReadOutGeometry *value)
G4bool operator==(const G4VSensitiveDetector &right) const
virtual G4int GetCollectionID(G4int i)
G4bool Hit(G4Step *aStep)
G4CollectionNameVector collectionName
void Activate(G4bool activeFlag)
virtual void Initialize(G4HCofThisEvent *)
G4VSDFilter * GetFilter() const
G4VSensitiveDetector(G4String name)
G4bool operator!=(const G4VSensitiveDetector &right) const
void SetFilter(G4VSDFilter *value)
G4VSensitiveDetector & operator=(const G4VSensitiveDetector &right)
virtual void EndOfEvent(G4HCofThisEvent *)
G4VReadOutGeometry * ROgeometry
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)=0
G4String GetCollectionName(G4int id) const
G4String GetFullPathName() const
G4VReadOutGeometry * GetROgeometry() const