Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // 27 // 28 //-------------------------------------------- 28 //--------------------------------------------------------------- 29 // 29 // 30 // G4FastTrack.hh 30 // G4FastTrack.hh 31 // 31 // 32 // Description: 32 // Description: 33 // Keeps the current track information and 33 // Keeps the current track information and special features 34 // for Parameterised Simulation Models. 34 // for Parameterised Simulation Models. 35 // 35 // 36 // History: 36 // History: 37 // Oct 97: Verderi && MoraDeFreitas - First 37 // Oct 97: Verderi && MoraDeFreitas - First Implementation. 38 // 38 // 39 //-------------------------------------------- 39 //--------------------------------------------------------------- 40 40 >> 41 41 #ifndef G4FastTrack_h 42 #ifndef G4FastTrack_h 42 #define G4FastTrack_h 43 #define G4FastTrack_h 43 44 44 #include "G4AffineTransform.hh" << 45 #include "G4VSolid.hh" 45 #include "G4LogicalVolume.hh" 46 #include "G4LogicalVolume.hh" 46 #include "G4Navigator.hh" << 47 #include "G4Region.hh" 47 #include "G4Region.hh" >> 48 #include "G4AffineTransform.hh" 48 #include "G4Track.hh" 49 #include "G4Track.hh" 49 #include "G4VSolid.hh" << 50 #include "G4Navigator.hh" 50 51 51 //--------------------------- 52 //--------------------------- 52 // For possible future needs: 53 // For possible future needs: 53 //--------------------------- 54 //--------------------------- 54 using G4Envelope = G4Region; << 55 typedef G4Region G4Envelope; >> 56 55 57 56 //------------------------------------------- 58 //------------------------------------------- 57 // 59 // 58 // G4FastTrack class 60 // G4FastTrack class 59 // 61 // 60 //------------------------------------------- 62 //------------------------------------------- 61 63 62 // Class Description: 64 // Class Description: 63 // The G4FastTrack provides you access to the 65 // The G4FastTrack provides you access to the current G4Track, 64 // gives simple access to envelope related fea 66 // gives simple access to envelope related features (G4Region, 65 // G4LogicalVolume, G4VSolid, G4AffineTransfor 67 // G4LogicalVolume, G4VSolid, G4AffineTransform references between 66 // the global and the envelope local coordinat 68 // the global and the envelope local coordinates systems) and 67 // simple access to the position, momentum exp 69 // simple access to the position, momentum expressed in the 68 // envelope coordinate system. Using those qua 70 // envelope coordinate system. Using those quantities and the 69 // G4VSolid methods, you can for example easil 71 // G4VSolid methods, you can for example easily check how far you 70 // are from the envelope boundary. << 72 // are from the envelope boundary. 71 // 73 // 72 74 >> 75 73 class G4FastTrack 76 class G4FastTrack 74 { 77 { 75 public: // without description << 78 public: // without description 76 //------------------------ << 79 //------------------------ 77 // Constructor/Destructor << 80 // Constructor/Destructor 78 //------------------------ << 81 //------------------------ 79 // Only one Constructor. By default the en << 82 // Only one Constructor. By default the envelope can 80 // be placed n-Times. If the user is sure << 83 // be placed n-Times. If the user is sure that it'll be 81 // placed just one time, the IsUnique flag << 84 // placed just one time, the IsUnique flag should be set 82 // TRUE to avoid the G4AffineTransform re- << 85 // TRUE to avoid the G4AffineTransform re-calculations each 83 // time we reach the envelope. << 86 // time we reach the envelope. 84 G4FastTrack(G4Envelope* anEnvelope, G4bool << 87 G4FastTrack(G4Envelope *anEnvelope, 85 ~G4FastTrack() = default; << 88 G4bool IsUnique); 86 << 89 ~G4FastTrack(); 87 //---------------------------------------- << 90 88 // The fast simulation manager uses the Se << 91 //------------------------------------------------------------ 89 // method to setup the current G4FastTrack << 92 // The fast simulation manager uses the SetCurrentTrack 90 //---------------------------------------- << 93 // method to setup the current G4FastTrack object 91 void SetCurrentTrack(const G4Track&, const << 94 //------------------------------------------------------------ 92 << 95 void SetCurrentTrack(const G4Track&, const G4Navigator* a = 0); 93 //---------------------------------------- << 96 94 // The fast simulation manager uses the On << 97 //------------------------------------------------------------ 95 // method to test if the particle is leavi << 98 // The fast simulation manager uses the OnTheBoundaryButExiting 96 //---------------------------------------- << 99 // method to test if the particle is leaving the envelope. 97 G4bool OnTheBoundaryButExiting() const; << 100 //------------------------------------------------------------ 98 << 101 G4bool OnTheBoundaryButExiting() const; 99 //---------------------------------- << 102 100 // Informations useful to the user : << 103 //---------------------------------- 101 // General public get functions. << 104 // Informations useful to the user : 102 //---------------------------------- << 105 // General public get functions. 103 << 106 //---------------------------------- 104 // Returns the current G4Track. << 107 105 const G4Track* GetPrimaryTrack() const; << 108 public: // with Description 106 << 109 107 // Returns the Envelope G4Region pointer. << 110 const G4Track* GetPrimaryTrack() const; 108 G4Envelope* GetEnvelope() const; << 111 // Returns the current G4Track. 109 << 112 110 // Returns the Envelope G4LogicalVolume po << 113 G4Envelope* GetEnvelope() const; 111 G4LogicalVolume* GetEnvelopeLogicalVolume( << 114 // Returns the Envelope G4Region pointer. 112 << 115 113 // Returns the Envelope G4VPhysicalVolume << 116 G4LogicalVolume* GetEnvelopeLogicalVolume() const; 114 G4VPhysicalVolume* GetEnvelopePhysicalVolu << 117 // Returns the Envelope G4LogicalVolume pointer. 115 << 118 116 // Returns the Envelope G4VSolid pointer. << 119 G4VPhysicalVolume* GetEnvelopePhysicalVolume() const; 117 G4VSolid* GetEnvelopeSolid() const; << 120 // Returns the Envelope G4VPhysicalVolume pointer. 118 << 121 119 //----------------------------------- << 122 G4VSolid* GetEnvelopeSolid() const; 120 // Primary track informations in the << 123 // Returns the Envelope G4VSolid pointer. 121 // Envelope coordinate system. << 124 122 //----------------------------------- << 125 //----------------------------------- 123 << 126 // Primary track informations in the 124 // Returns the particle position in envelo << 127 // Envelope coordinate system. 125 G4ThreeVector GetPrimaryTrackLocalPosition << 128 //----------------------------------- 126 << 129 127 // Returns the particle momentum in envelo << 130 G4ThreeVector GetPrimaryTrackLocalPosition() const; 128 G4ThreeVector GetPrimaryTrackLocalMomentum << 131 // Returns the particle position in envelope coordinates. 129 << 132 130 // Returns the particle direction in envel << 133 G4ThreeVector GetPrimaryTrackLocalMomentum() const; 131 G4ThreeVector GetPrimaryTrackLocalDirectio << 134 // Returns the particle momentum in envelope coordinates. 132 << 135 133 // Returns the particle polarization in en << 136 G4ThreeVector GetPrimaryTrackLocalDirection() const; 134 G4ThreeVector GetPrimaryTrackLocalPolariza << 137 // Returns the particle direction in envelope coordinates. 135 << 138 136 //------------------------------------ << 139 G4ThreeVector GetPrimaryTrackLocalPolarization() const; 137 // 3D transformation of the envelope: << 140 // Returns the particle polarization in envelope coordinates. 138 //------------------------------------ << 141 139 << 142 //------------------------------------ 140 // Returns the envelope Global -> Local G4 << 143 // 3D transformation of the envelope: 141 const G4AffineTransform* GetAffineTransfor << 144 //------------------------------------ 142 << 145 // Global -> Local 143 // Returns the envelope Local -> Global G4 << 146 144 const G4AffineTransform* GetInverseAffineT << 147 const G4AffineTransform* GetAffineTransformation() const; 145 << 148 // Returns the envelope Global -> Local G4AffineTransform 146 private: << 149 147 //----------------- << 150 // Local -> Global 148 // Private members << 151 const G4AffineTransform* GetInverseAffineTransformation() const; 149 //----------------- << 152 // Returns the envelope Local -> Global G4AffineTransform 150 // Current G4Track pointer << 153 151 const G4Track* fTrack{nullptr}; << 154 //----------------- 152 << 155 // Private members 153 //---------------------------------------- << 156 //----------------- 154 // Records the Affine/InverseAffine transf << 157 private: 155 // of the envelope. << 158 156 //---------------------------------------- << 159 // Current G4Track pointer 157 void FRecordsAffineTransformation(const G4 << 160 const G4Track* fTrack; 158 G4bool fAffineTransformationDefined{false} << 161 159 G4Envelope* fEnvelope; << 162 //------------------------------------------------ 160 G4bool fIsUnique; << 163 // Records the Affine/InverseAffine transformation 161 G4LogicalVolume* fEnvelopeLogicalVolume{nu << 164 // of the envelope. 162 G4VPhysicalVolume* fEnvelopePhysicalVolume << 165 //------------------------------------------------ 163 G4VSolid* fEnvelopeSolid{nullptr}; << 166 void FRecordsAffineTransformation(const G4Navigator*); 164 G4ThreeVector fLocalTrackPosition, fLocalT << 167 G4bool fAffineTransformationDefined; 165 fLocalTrackPolarization; << 168 G4Envelope* fEnvelope; 166 G4AffineTransform fAffineTransformation, f << 169 G4bool fIsUnique; >> 170 G4LogicalVolume* fEnvelopeLogicalVolume; >> 171 G4VPhysicalVolume* fEnvelopePhysicalVolume; >> 172 G4VSolid* fEnvelopeSolid; >> 173 G4ThreeVector fLocalTrackPosition, >> 174 fLocalTrackMomentum, >> 175 fLocalTrackDirection, >> 176 fLocalTrackPolarization; >> 177 G4AffineTransform fAffineTransformation, >> 178 fInverseAffineTransformation; 167 }; 179 }; 168 180 >> 181 169 // ----------------- 182 // ----------------- 170 // -- Inline methods 183 // -- Inline methods 171 // ----------------- 184 // ----------------- 172 185 173 inline G4Envelope* G4FastTrack::GetEnvelope() 186 inline G4Envelope* G4FastTrack::GetEnvelope() const 174 { 187 { 175 return fEnvelope; 188 return fEnvelope; 176 } 189 } 177 190 178 inline G4LogicalVolume* G4FastTrack::GetEnvelo 191 inline G4LogicalVolume* G4FastTrack::GetEnvelopeLogicalVolume() const 179 { 192 { 180 return fEnvelopeLogicalVolume; 193 return fEnvelopeLogicalVolume; 181 } 194 } 182 195 183 inline G4VPhysicalVolume* G4FastTrack::GetEnve 196 inline G4VPhysicalVolume* G4FastTrack::GetEnvelopePhysicalVolume() const 184 { 197 { 185 return fEnvelopePhysicalVolume; 198 return fEnvelopePhysicalVolume; 186 } 199 } 187 200 188 inline G4VSolid* G4FastTrack::GetEnvelopeSolid 201 inline G4VSolid* G4FastTrack::GetEnvelopeSolid() const 189 { 202 { 190 return fEnvelopeSolid; 203 return fEnvelopeSolid; 191 } 204 } 192 205 193 inline const G4Track* G4FastTrack::GetPrimaryT 206 inline const G4Track* G4FastTrack::GetPrimaryTrack() const 194 { 207 { 195 return fTrack; 208 return fTrack; 196 } 209 } 197 210 198 inline G4ThreeVector G4FastTrack::GetPrimaryTr 211 inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalPosition() const 199 { 212 { 200 return fLocalTrackPosition; 213 return fLocalTrackPosition; 201 } 214 } 202 215 203 inline G4ThreeVector G4FastTrack::GetPrimaryTr 216 inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalMomentum() const 204 { 217 { 205 return fLocalTrackMomentum; 218 return fLocalTrackMomentum; 206 } 219 } 207 220 208 inline G4ThreeVector G4FastTrack::GetPrimaryTr 221 inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalDirection() const 209 { 222 { 210 return fLocalTrackDirection; 223 return fLocalTrackDirection; 211 } 224 } 212 225 213 inline G4ThreeVector G4FastTrack::GetPrimaryTr 226 inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalPolarization() const 214 { 227 { 215 return fLocalTrackPolarization; 228 return fLocalTrackPolarization; 216 } 229 } 217 230 218 inline const G4AffineTransform* G4FastTrack::G 231 inline const G4AffineTransform* G4FastTrack::GetAffineTransformation() const 219 { 232 { 220 return &fAffineTransformation; 233 return &fAffineTransformation; 221 } 234 } 222 235 223 inline const G4AffineTransform* G4FastTrack::G 236 inline const G4AffineTransform* G4FastTrack::GetInverseAffineTransformation() const 224 { 237 { 225 return &fInverseAffineTransformation; 238 return &fInverseAffineTransformation; 226 } 239 } 227 240 228 inline G4bool G4FastTrack::OnTheBoundaryButExi << 241 inline G4bool G4FastTrack::OnTheBoundaryButExiting() const 229 { 242 { 230 // tests if particle are on the boundary and 243 // tests if particle are on the boundary and leaving. 231 return GetEnvelopeSolid()->DistanceToOut(Get << 244 return GetEnvelopeSolid()-> 232 Get << 245 DistanceToOut(GetPrimaryTrackLocalPosition(), 233 == 0.; << 246 GetPrimaryTrackLocalDirection())==0.; 234 } 247 } 235 248 236 #endif 249 #endif 237 250