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 // $Id$ 27 // 28 // >> 29 // $Id: 28 //-------------------------------------------- 30 //--------------------------------------------------------------- 29 // 31 // 30 // G4FastTrack.hh 32 // G4FastTrack.hh 31 // 33 // 32 // Description: 34 // Description: 33 // Keeps the current track information and 35 // Keeps the current track information and special features 34 // for Parameterised Simulation Models. 36 // for Parameterised Simulation Models. 35 // 37 // 36 // History: 38 // History: 37 // Oct 97: Verderi && MoraDeFreitas - First 39 // Oct 97: Verderi && MoraDeFreitas - First Implementation. 38 // 40 // 39 //-------------------------------------------- 41 //--------------------------------------------------------------- 40 42 >> 43 41 #ifndef G4FastTrack_h 44 #ifndef G4FastTrack_h 42 #define G4FastTrack_h 45 #define G4FastTrack_h 43 46 44 #include "G4AffineTransform.hh" << 47 #include "G4VSolid.hh" 45 #include "G4LogicalVolume.hh" 48 #include "G4LogicalVolume.hh" 46 #include "G4Navigator.hh" << 47 #include "G4Region.hh" 49 #include "G4Region.hh" >> 50 #include "G4AffineTransform.hh" 48 #include "G4Track.hh" 51 #include "G4Track.hh" 49 #include "G4VSolid.hh" << 52 #include "G4Navigator.hh" 50 53 51 //--------------------------- 54 //--------------------------- 52 // For possible future needs: 55 // For possible future needs: 53 //--------------------------- 56 //--------------------------- 54 using G4Envelope = G4Region; << 57 typedef G4Region G4Envelope; >> 58 55 59 56 //------------------------------------------- 60 //------------------------------------------- 57 // 61 // 58 // G4FastTrack class 62 // G4FastTrack class 59 // 63 // 60 //------------------------------------------- 64 //------------------------------------------- 61 65 62 // Class Description: 66 // Class Description: 63 // The G4FastTrack provides you access to the 67 // The G4FastTrack provides you access to the current G4Track, 64 // gives simple access to envelope related fea 68 // gives simple access to envelope related features (G4Region, 65 // G4LogicalVolume, G4VSolid, G4AffineTransfor 69 // G4LogicalVolume, G4VSolid, G4AffineTransform references between 66 // the global and the envelope local coordinat 70 // the global and the envelope local coordinates systems) and 67 // simple access to the position, momentum exp 71 // simple access to the position, momentum expressed in the 68 // envelope coordinate system. Using those qua 72 // envelope coordinate system. Using those quantities and the 69 // G4VSolid methods, you can for example easil 73 // G4VSolid methods, you can for example easily check how far you 70 // are from the envelope boundary. << 74 // are from the envelope boundary. 71 // 75 // 72 76 >> 77 73 class G4FastTrack 78 class G4FastTrack 74 { 79 { 75 public: // without description << 80 public: // without description 76 //------------------------ << 81 //------------------------ 77 // Constructor/Destructor << 82 // Constructor/Destructor 78 //------------------------ << 83 //------------------------ 79 // Only one Constructor. By default the en << 84 // Only one Constructor. By default the envelope can 80 // be placed n-Times. If the user is sure << 85 // be placed n-Times. If the user is sure that it'll be 81 // placed just one time, the IsUnique flag << 86 // placed just one time, the IsUnique flag should be set 82 // TRUE to avoid the G4AffineTransform re- << 87 // TRUE to avoid the G4AffineTransform re-calculations each 83 // time we reach the envelope. << 88 // time we reach the envelope. 84 G4FastTrack(G4Envelope* anEnvelope, G4bool << 89 G4FastTrack(G4Envelope *anEnvelope, 85 ~G4FastTrack() = default; << 90 G4bool IsUnique); 86 << 91 ~G4FastTrack(); 87 //---------------------------------------- << 92 88 // The fast simulation manager uses the Se << 93 //------------------------------------------------------------ 89 // method to setup the current G4FastTrack << 94 // The fast simulation manager uses the SetCurrentTrack 90 //---------------------------------------- << 95 // method to setup the current G4FastTrack object 91 void SetCurrentTrack(const G4Track&, const << 96 //------------------------------------------------------------ 92 << 97 void SetCurrentTrack(const G4Track&, const G4Navigator* a = 0); 93 //---------------------------------------- << 98 94 // The fast simulation manager uses the On << 99 //------------------------------------------------------------ 95 // method to test if the particle is leavi << 100 // The fast simulation manager uses the OnTheBoundaryButExiting 96 //---------------------------------------- << 101 // method to test if the particle is leaving the envelope. 97 G4bool OnTheBoundaryButExiting() const; << 102 //------------------------------------------------------------ 98 << 103 G4bool OnTheBoundaryButExiting() const; 99 //---------------------------------- << 104 100 // Informations useful to the user : << 105 //---------------------------------- 101 // General public get functions. << 106 // Informations useful to the user : 102 //---------------------------------- << 107 // General public get functions. 103 << 108 //---------------------------------- 104 // Returns the current G4Track. << 109 105 const G4Track* GetPrimaryTrack() const; << 110 public: // with Description 106 << 111 107 // Returns the Envelope G4Region pointer. << 112 const G4Track* GetPrimaryTrack() const; 108 G4Envelope* GetEnvelope() const; << 113 // Returns the current G4Track. 109 << 114 110 // Returns the Envelope G4LogicalVolume po << 115 G4Envelope* GetEnvelope() const; 111 G4LogicalVolume* GetEnvelopeLogicalVolume( << 116 // Returns the Envelope G4Region pointer. 112 << 117 113 // Returns the Envelope G4VPhysicalVolume << 118 G4LogicalVolume* GetEnvelopeLogicalVolume() const; 114 G4VPhysicalVolume* GetEnvelopePhysicalVolu << 119 // Returns the Envelope G4LogicalVolume pointer. 115 << 120 116 // Returns the Envelope G4VSolid pointer. << 121 G4VPhysicalVolume* GetEnvelopePhysicalVolume() const; 117 G4VSolid* GetEnvelopeSolid() const; << 122 // Returns the Envelope G4VPhysicalVolume pointer. 118 << 123 119 //----------------------------------- << 124 G4VSolid* GetEnvelopeSolid() const; 120 // Primary track informations in the << 125 // Returns the Envelope G4VSolid pointer. 121 // Envelope coordinate system. << 126 122 //----------------------------------- << 127 //----------------------------------- 123 << 128 // Primary track informations in the 124 // Returns the particle position in envelo << 129 // Envelope coordinate system. 125 G4ThreeVector GetPrimaryTrackLocalPosition << 130 //----------------------------------- 126 << 131 127 // Returns the particle momentum in envelo << 132 G4ThreeVector GetPrimaryTrackLocalPosition() const; 128 G4ThreeVector GetPrimaryTrackLocalMomentum << 133 // Returns the particle position in envelope coordinates. 129 << 134 130 // Returns the particle direction in envel << 135 G4ThreeVector GetPrimaryTrackLocalMomentum() const; 131 G4ThreeVector GetPrimaryTrackLocalDirectio << 136 // Returns the particle momentum in envelope coordinates. 132 << 137 133 // Returns the particle polarization in en << 138 G4ThreeVector GetPrimaryTrackLocalDirection() const; 134 G4ThreeVector GetPrimaryTrackLocalPolariza << 139 // Returns the particle direction in envelope coordinates. 135 << 140 136 //------------------------------------ << 141 G4ThreeVector GetPrimaryTrackLocalPolarization() const; 137 // 3D transformation of the envelope: << 142 // Returns the particle polarization in envelope coordinates. 138 //------------------------------------ << 143 139 << 144 //------------------------------------ 140 // Returns the envelope Global -> Local G4 << 145 // 3D transformation of the envelope: 141 const G4AffineTransform* GetAffineTransfor << 146 //------------------------------------ 142 << 147 // Global -> Local 143 // Returns the envelope Local -> Global G4 << 148 144 const G4AffineTransform* GetInverseAffineT << 149 const G4AffineTransform* GetAffineTransformation() const; 145 << 150 // Returns the envelope Global -> Local G4AffineTransform 146 private: << 151 147 //----------------- << 152 // Local -> Global 148 // Private members << 153 const G4AffineTransform* GetInverseAffineTransformation() const; 149 //----------------- << 154 // Returns the envelope Local -> Global G4AffineTransform 150 // Current G4Track pointer << 155 151 const G4Track* fTrack{nullptr}; << 156 //----------------- 152 << 157 // Private members 153 //---------------------------------------- << 158 //----------------- 154 // Records the Affine/InverseAffine transf << 159 private: 155 // of the envelope. << 160 156 //---------------------------------------- << 161 // Current G4Track pointer 157 void FRecordsAffineTransformation(const G4 << 162 const G4Track* fTrack; 158 G4bool fAffineTransformationDefined{false} << 163 159 G4Envelope* fEnvelope; << 164 //------------------------------------------------ 160 G4bool fIsUnique; << 165 // Records the Affine/InverseAffine transformation 161 G4LogicalVolume* fEnvelopeLogicalVolume{nu << 166 // of the envelope. 162 G4VPhysicalVolume* fEnvelopePhysicalVolume << 167 //------------------------------------------------ 163 G4VSolid* fEnvelopeSolid{nullptr}; << 168 void FRecordsAffineTransformation(const G4Navigator*); 164 G4ThreeVector fLocalTrackPosition, fLocalT << 169 G4bool fAffineTransformationDefined; 165 fLocalTrackPolarization; << 170 G4Envelope* fEnvelope; 166 G4AffineTransform fAffineTransformation, f << 171 G4bool fIsUnique; >> 172 G4LogicalVolume* fEnvelopeLogicalVolume; >> 173 G4VPhysicalVolume* fEnvelopePhysicalVolume; >> 174 G4VSolid* fEnvelopeSolid; >> 175 G4ThreeVector fLocalTrackPosition, >> 176 fLocalTrackMomentum, >> 177 fLocalTrackDirection, >> 178 fLocalTrackPolarization; >> 179 G4AffineTransform fAffineTransformation, >> 180 fInverseAffineTransformation; 167 }; 181 }; 168 182 >> 183 169 // ----------------- 184 // ----------------- 170 // -- Inline methods 185 // -- Inline methods 171 // ----------------- 186 // ----------------- 172 187 173 inline G4Envelope* G4FastTrack::GetEnvelope() 188 inline G4Envelope* G4FastTrack::GetEnvelope() const 174 { 189 { 175 return fEnvelope; 190 return fEnvelope; 176 } 191 } 177 192 178 inline G4LogicalVolume* G4FastTrack::GetEnvelo 193 inline G4LogicalVolume* G4FastTrack::GetEnvelopeLogicalVolume() const 179 { 194 { 180 return fEnvelopeLogicalVolume; 195 return fEnvelopeLogicalVolume; 181 } 196 } 182 197 183 inline G4VPhysicalVolume* G4FastTrack::GetEnve 198 inline G4VPhysicalVolume* G4FastTrack::GetEnvelopePhysicalVolume() const 184 { 199 { 185 return fEnvelopePhysicalVolume; 200 return fEnvelopePhysicalVolume; 186 } 201 } 187 202 188 inline G4VSolid* G4FastTrack::GetEnvelopeSolid 203 inline G4VSolid* G4FastTrack::GetEnvelopeSolid() const 189 { 204 { 190 return fEnvelopeSolid; 205 return fEnvelopeSolid; 191 } 206 } 192 207 193 inline const G4Track* G4FastTrack::GetPrimaryT 208 inline const G4Track* G4FastTrack::GetPrimaryTrack() const 194 { 209 { 195 return fTrack; 210 return fTrack; 196 } 211 } 197 212 198 inline G4ThreeVector G4FastTrack::GetPrimaryTr 213 inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalPosition() const 199 { 214 { 200 return fLocalTrackPosition; 215 return fLocalTrackPosition; 201 } 216 } 202 217 203 inline G4ThreeVector G4FastTrack::GetPrimaryTr 218 inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalMomentum() const 204 { 219 { 205 return fLocalTrackMomentum; 220 return fLocalTrackMomentum; 206 } 221 } 207 222 208 inline G4ThreeVector G4FastTrack::GetPrimaryTr 223 inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalDirection() const 209 { 224 { 210 return fLocalTrackDirection; 225 return fLocalTrackDirection; 211 } 226 } 212 227 213 inline G4ThreeVector G4FastTrack::GetPrimaryTr 228 inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalPolarization() const 214 { 229 { 215 return fLocalTrackPolarization; 230 return fLocalTrackPolarization; 216 } 231 } 217 232 218 inline const G4AffineTransform* G4FastTrack::G 233 inline const G4AffineTransform* G4FastTrack::GetAffineTransformation() const 219 { 234 { 220 return &fAffineTransformation; 235 return &fAffineTransformation; 221 } 236 } 222 237 223 inline const G4AffineTransform* G4FastTrack::G 238 inline const G4AffineTransform* G4FastTrack::GetInverseAffineTransformation() const 224 { 239 { 225 return &fInverseAffineTransformation; 240 return &fInverseAffineTransformation; 226 } 241 } 227 242 228 inline G4bool G4FastTrack::OnTheBoundaryButExi << 243 inline G4bool G4FastTrack::OnTheBoundaryButExiting() const 229 { 244 { 230 // tests if particle are on the boundary and 245 // tests if particle are on the boundary and leaving. 231 return GetEnvelopeSolid()->DistanceToOut(Get << 246 return GetEnvelopeSolid()-> 232 Get << 247 DistanceToOut(GetPrimaryTrackLocalPosition(), 233 == 0.; << 248 GetPrimaryTrackLocalDirection())==0.; 234 } 249 } 235 250 236 #endif 251 #endif 237 252