Geant4-11
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
32#include "G4VHit.hh"
33#include "G4Step.hh"
34#include "G4HCofThisEvent.hh"
35#include "G4VReadOutGeometry.hh"
36#include "G4TouchableHistory.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: // with description
54 // Constructors. The user's concrete class must use one of these constructors
55 // by the constructor initializer of the derived class. The name of
56 // the sensitive detector must be unique.
57
58 public:
59 virtual ~G4VSensitiveDetector();
60
62
63 G4bool operator==(const G4VSensitiveDetector& right) const;
64 G4bool operator!=(const G4VSensitiveDetector& right) const;
65
66 public: // with description
67 virtual void Initialize(G4HCofThisEvent*);
68 virtual void EndOfEvent(G4HCofThisEvent*);
69 // These two methods are invoked at the begining and at the end of each
70 // event. The hits collection(s) created by this sensitive detector must
71 // be set to the G4HCofThisEvent object at one of these two methods.
72 virtual void clear();
73 // This method is invoked if the event abortion is occured. Hits collections
74 // created but not beibg set to G4HCofThisEvent at the event should be
75 // deleted. Collection(s) which have already set to G4HCofThisEvent will be
76 // deleted automatically.
77
78 public:
79 virtual void DrawAll();
80 virtual void PrintAll();
81
82 protected: // with description
83 virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist) = 0;
84 // The user MUST implement this method for generating hit(s) using the
85 // information of G4Step object. Note that the volume and the position
86 // information is kept in PreStepPoint of G4Step.
87 // Be aware that this method is a protected method and it sill be invoked
88 // by Hit() method of Base class after Readout geometry associated to the
89 // sensitive detector is handled.
90 // "ROhist" will be given only is a Readout geometry is defined to this
91 // sensitive detector. The G4TouchableHistory object of the tracking geometry
92 // is stored in the PreStepPoint object of G4Step.
93 virtual G4int GetCollectionID(G4int i);
94 // This is a utility method which returns the hits collection ID of the
95 // "i"-th collection. "i" is the order (starting with zero) of the collection
96 // whose name is stored to the collectionName protected vector.
98 // This protected name vector must be filled at the constructor of the user's
99 // concrete class for registering the name(s) of hits collection(s) being
100 // created by this particular sensitive detector.
101
102 protected:
104 G4String thePathName; // directory path
105 G4String fullPathName; // path + detector name
110
111 public: // with description
112 inline G4bool Hit(G4Step* aStep)
113 {
114 G4TouchableHistory* ROhis = 0;
115 if(!isActive())
116 return false;
117 if(filter)
118 {
119 if(!(filter->Accept(aStep)))
120 return false;
121 }
122 if(ROgeometry)
123 {
124 if(!(ROgeometry->CheckROVolume(aStep, ROhis)))
125 return false;
126 }
127 return ProcessHits(aStep, ROhis);
128 }
129 // This is the public method invoked by G4SteppingManager for generating
130 // hit(s). The actual user's implementation for generating hit(s) must be
131 // implemented in GenerateHits() virtual protected method. This method
132 // MUST NOT be overrided.
133 inline void SetROgeometry(G4VReadOutGeometry* value) { ROgeometry = value; }
134 // Register the Readout geometry.
135 inline void SetFilter(G4VSDFilter* value) { filter = value; }
136 // Register a filter
137
138 public:
140 {
141 return G4int(collectionName.size());
142 }
144 {
145 return collectionName[id];
146 }
147 inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
148 inline void Activate(G4bool activeFlag) { active = activeFlag; }
149 inline G4bool isActive() const { return active; }
150 inline G4String GetName() const { return SensitiveDetectorName; }
151 inline G4String GetPathName() const { return thePathName; }
152 inline G4String GetFullPathName() const { return fullPathName; }
153 inline G4VReadOutGeometry* GetROgeometry() const { return ROgeometry; }
154 inline G4VSDFilter* GetFilter() const { return filter; }
155
156 public:
157 virtual G4VSensitiveDetector* Clone() const;
158};
159
160#endif
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
Definition: G4Step.hh:62
virtual G4bool CheckROVolume(G4Step *, G4TouchableHistory *&)
virtual G4bool Accept(const G4Step *) const =0
virtual void EndOfEvent(G4HCofThisEvent *)
virtual G4VSensitiveDetector * Clone() const
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)
G4int GetNumberOfCollections() const
G4bool operator!=(const G4VSensitiveDetector &right) const
void SetFilter(G4VSDFilter *value)
G4VSensitiveDetector & operator=(const G4VSensitiveDetector &right)
G4VReadOutGeometry * ROgeometry
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)=0
G4String GetCollectionName(G4int id) const
G4String GetFullPathName() const
G4String GetPathName() const
G4VReadOutGeometry * GetROgeometry() const
const char * name(G4int ptype)