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