Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // G4VSensitiveDetector 27 // 28 // Class description: 29 // 30 // This is the abstract base class of the sens 31 // sensitive detector which generates hits mus 32 // class. 33 // In the derived class constructor, name(s) o 34 // are made by the sensitive detector must be 35 // vector. 36 // 37 // Author: Makoto Asai 38 // ------------------------------------------- 39 #ifndef G4VSensitiveDetector_h 40 #define G4VSensitiveDetector_h 1 41 42 #include "G4CollectionNameVector.hh" 43 #include "G4HCofThisEvent.hh" 44 #include "G4Step.hh" 45 #include "G4TouchableHistory.hh" 46 #include "G4VHit.hh" 47 #include "G4VReadOutGeometry.hh" 48 #include "G4VSDFilter.hh" 49 50 class G4VSensitiveDetector 51 { 52 public: 53 // Constructors. The user's concrete class m 54 // by the constructor initializer of the der 55 // the sensitive detector must be unique. 56 explicit G4VSensitiveDetector(const G4String 57 G4VSensitiveDetector(const G4VSensitiveDetec 58 G4VSensitiveDetector& operator=(const G4VSen 59 virtual ~G4VSensitiveDetector() = default; 60 61 G4bool operator==(const G4VSensitiveDetector 62 G4bool operator!=(const G4VSensitiveDetector 63 64 // These two methods are invoked at the beg 65 // event. The hits collection(s) created by 66 // be set to the G4HCofThisEvent object at o 67 virtual void Initialize(G4HCofThisEvent*) {} 68 virtual void EndOfEvent(G4HCofThisEvent*) {} 69 70 // This method is invoked if the event abor 71 // created but not beibg set to G4HCofThisEv 72 // deleted. Collection(s) which have already 73 // deleted automatically. 74 virtual void clear() {} 75 76 virtual void DrawAll() {} 77 virtual void PrintAll() {} 78 79 // This is the public method invoked by G4S 80 // hit(s). The actual user's implementation 81 // implemented in GenerateHits() virtual pro 82 // MUST NOT be overriden. 83 inline G4bool Hit(G4Step* aStep) 84 { 85 G4TouchableHistory* ROhis = nullptr; 86 if (! isActive()) return false; 87 if (filter != nullptr) { 88 if (! (filter->Accept(aStep))) return fa 89 } 90 if (ROgeometry != nullptr) { 91 if (! (ROgeometry->CheckROVolume(aStep, 92 } 93 return ProcessHits(aStep, ROhis); 94 } 95 96 // Register the Readout geometry. 97 inline void SetROgeometry(G4VReadOutGeometry 98 99 // Register a filter 100 inline void SetFilter(G4VSDFilter* value) { 101 102 inline G4int GetNumberOfCollections() const 103 inline const G4String& GetCollectionName(G4i 104 inline void SetVerboseLevel(G4int vl) { verb 105 inline void Activate(G4bool activeFlag) { ac 106 inline G4bool isActive() const { return acti 107 inline const G4String& GetName() const { ret 108 inline const G4String& GetPathName() const { 109 inline const G4String& GetFullPathName() con 110 inline G4VReadOutGeometry* GetROgeometry() c 111 inline G4VSDFilter* GetFilter() const { retu 112 113 virtual G4VSensitiveDetector* Clone() const; 114 115 protected: // with description 116 // The user MUST implement this method for 117 // information of G4Step object. Note that t 118 // information is kept in PreStepPoint of G4 119 // Be aware that this method is a protected 120 // by Hit() method of Base class after Reado 121 // sensitive detector is handled. 122 // "ROhist" will be given only is a Readout 123 // sensitive detector. The G4TouchableHistor 124 // is stored in the PreStepPoint object of G 125 virtual G4bool ProcessHits(G4Step* aStep, G4 126 127 // This is a utility method which returns t 128 // "i"-th collection. "i" is the order (star 129 // whose name is stored to the collectionNam 130 virtual G4int GetCollectionID(G4int i); 131 132 protected: 133 // This protected name vector must be fille 134 // concrete class for registering the name(s 135 // created by this particular sensitive dete 136 G4CollectionNameVector collectionName; 137 138 G4String SensitiveDetectorName; // detector 139 G4String thePathName; // directory path 140 G4String fullPathName; // path + detector n 141 G4int verboseLevel{0}; 142 G4bool active{true}; 143 G4VReadOutGeometry* ROgeometry{nullptr}; 144 G4VSDFilter* filter{nullptr}; 145 }; 146 147 #endif 148