|
||||
File indexing completed on 2025-01-18 09:59:21
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 0027 #ifndef G4VFASTSIMSENSITIVEDETECTOR_HH 0028 #define G4VFASTSIMSENSITIVEDETECTOR_HH 0029 0030 #include "G4FastHit.hh" 0031 #include "G4FastTrack.hh" 0032 #include "G4TouchableHistory.hh" 0033 #include "G4VReadOutGeometry.hh" 0034 #include "G4VSensitiveDetector.hh" 0035 0036 /** 0037 * @brief Base class for the sensitive detector used within the fast simulation 0038 * 0039 * Base class for a sensitive detector that allows to store hits created in the 0040 * fast simulation models. It must me used in addition to inheritance from the 0041 * usual base class `G4VSensitiveDetector` for processing of energy deposited 0042 * in G4Step. 0043 * ProcessHits(...) method must be implemented and describe how hits should be 0044 * saved in the hit collections. It is invoked by Hit method which is public and 0045 * can be called directly in the fast simulation model (if sensitive detector is 0046 * known to the model), or via the helper class G4FastSimHitMaker that will 0047 * locate appropriate volume and retrieve its sensitive detector. 0048 * An extended example extended/parameterisations/Par03 demonstrates how to use 0049 * G4VFastSimSensitiveDetector to deposit energy from fast simulation and 0050 * compare it to the detailed simulation. 0051 * 0052 */ 0053 0054 class G4VFastSimSensitiveDetector 0055 { 0056 public: 0057 virtual ~G4VFastSimSensitiveDetector() = default; 0058 0059 /// Create a hit. 0060 /// 0061 /// It checks if G4VSensitiveDetector is also used as a base class, 0062 /// and takes into account the readout geometry, if it is defined. 0063 /// User instruction on how to deposit energy needs to be implemented in 0064 /// ProcessHits method. 0065 /// @param[in] aHit Created hit (energy and position) 0066 /// @param[in] aTrack Fast track with access to particle's track and 0067 /// properties in envelope's local coordinates 0068 /// @param[in] aTouchable Touchable with relevant transformations 0069 inline G4bool Hit(const G4FastHit* aHit, const G4FastTrack* aTrack, 0070 G4TouchableHandle* aTouchable) 0071 { 0072 G4bool result = true; 0073 auto sensDet = dynamic_cast<G4VSensitiveDetector*>(this); 0074 if (sensDet == nullptr) { 0075 G4Exception("G4VFastSimSensitiveDetector::Hit()", "InvalidSetup", FatalException, 0076 "Sensitive detector needs also to inherit also from " 0077 "G4VSensitiveDetector if full " 0078 "simulation is used instead!"); 0079 } 0080 if (sensDet->isActive()) { 0081 G4VReadOutGeometry* ROgeometry = sensDet->GetROgeometry(); 0082 G4TouchableHistory* ROhistory = nullptr; 0083 0084 if (ROgeometry != nullptr) { 0085 // create fake pre-step point updating the touchable from read-out 0086 // geometry. 0087 G4Step fakeStep; 0088 const G4Track* currentTrack = aTrack->GetPrimaryTrack(); 0089 G4StepPoint* tmpPoint = fakeStep.GetPreStepPoint(); 0090 tmpPoint->SetTouchableHandle(*aTouchable); 0091 tmpPoint->SetPosition(aHit->GetPosition()); 0092 tmpPoint->SetMomentumDirection(currentTrack->GetMomentumDirection()); 0093 result = ROgeometry->CheckROVolume(&fakeStep, ROhistory); 0094 } 0095 else { 0096 ROhistory = static_cast<G4TouchableHistory*>((*aTouchable)()); 0097 } 0098 if (result) result = ProcessHits(aHit, aTrack, ROhistory); 0099 } 0100 else { 0101 result = false; 0102 } 0103 return result; 0104 } 0105 0106 private: 0107 /// Describes how energy and position of deposits are inserted into the hits 0108 /// collection. It is a private method and it will be invoked by Hit() method 0109 /// of the base class once the readout geometry that may be associated to the 0110 /// corresponding G4VSensitiveDetector is taken into account. 0111 /// It needs to be implemented in the derived class. 0112 /// @param[in] aHit Created hit (energy and position) 0113 /// @param[in] aTrack Fast track with access to particle's track and 0114 /// properties in envelope's local coordinates 0115 /// @param[in] aROHistory Touchable history with relevant transformations 0116 virtual G4bool ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack, 0117 G4TouchableHistory* aROHistory) = 0; 0118 }; 0119 #endif /* G4VFASTSIMSENSITIVEDETECTOR_HH */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |