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