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: G4FastTrack.cc,v 1.10 2006/06/29 21:09:34 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-01-patch-01 $ 27 // 29 // 28 //-------------------------------------------- 30 //--------------------------------------------------------------- 29 // 31 // 30 // G4FastTrack.cc 32 // G4FastTrack.cc 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 #include "G4ios.hh" 41 #include "G4FastTrack.hh" 44 #include "G4FastTrack.hh" 42 << 43 #include "G4TouchableHandle.hh" << 44 #include "G4TransportationManager.hh" 45 #include "G4TransportationManager.hh" 45 #include "G4ios.hh" << 46 #include "G4TouchableHistoryHandle.hh" 46 47 47 // ----------- 48 // ----------- 48 // Constructor 49 // Constructor 49 // ----------- 50 // ----------- 50 // 51 // 51 G4FastTrack::G4FastTrack(G4Envelope* anEnvelop << 52 G4FastTrack::G4FastTrack(G4Envelope *anEnvelope, 52 : fEnvelope(anEnvelope), fIsUnique(IsUnique) << 53 G4bool IsUnique) : >> 54 fAffineTransformationDefined(false), fEnvelope(anEnvelope), >> 55 fIsUnique(IsUnique), fEnvelopeLogicalVolume(0), fEnvelopePhysicalVolume(0), >> 56 fEnvelopeSolid(0) >> 57 {} >> 58 >> 59 // ----------- >> 60 // Destructor: >> 61 // ----------- >> 62 G4FastTrack::~G4FastTrack() 53 {} 63 {} 54 64 55 //-------------------------------------------- 65 //------------------------------------------------------------ 56 // The parameterised simulation manager uses t 66 // The parameterised simulation manager uses the SetCurrentTrack 57 // method to setup the current G4FastTrack obj << 67 // method to setup the current G4FastTrack object 58 //-------------------------------------------- 68 //------------------------------------------------------------ 59 void G4FastTrack::SetCurrentTrack(const G4Trac << 69 void G4FastTrack::SetCurrentTrack(const G4Track& track, >> 70 const G4Navigator* theNavigator) 60 { 71 { >> 72 61 // -- Register track pointer (used everywher 73 // -- Register track pointer (used everywhere): 62 fTrack = &track; 74 fTrack = &track; 63 75 64 //------------------------------------------ 76 //----------------------------------------------------- 65 // First time the track enters the volume or 77 // First time the track enters the volume or if the 66 // Logical Volume was placed n-Times in the 78 // Logical Volume was placed n-Times in the geometry : 67 // << 79 // 68 // Records the Rotation+Translation for the 80 // Records the Rotation+Translation for the Envelope ! 69 // When the particle is inside or on the bou << 81 // When the particle is inside or on the boundary, the 70 // NavigationHistory IS UP TO DATE. 82 // NavigationHistory IS UP TO DATE. 71 //------------------------------------------ 83 //------------------------------------------------------ 72 if (!fAffineTransformationDefined || !fIsUni << 84 if (!fAffineTransformationDefined || !fIsUnique) 73 << 85 FRecordsAffineTransformation(theNavigator); >> 86 74 //------------------------------------------ 87 //------------------------------------------- 75 // Records local position/momentum/direction 88 // Records local position/momentum/direction 76 // of the Track. 89 // of the Track. 77 // They are accessible to the user through a 90 // They are accessible to the user through a 78 // set of Get functions and should be useful 91 // set of Get functions and should be useful 79 // to decide to trigger or not. 92 // to decide to trigger or not. 80 //------------------------------------------ 93 //------------------------------------------- 81 // -- local position: 94 // -- local position: 82 fLocalTrackPosition = fAffineTransformation. << 95 fLocalTrackPosition = fAffineTransformation. >> 96 TransformPoint(fTrack->GetPosition()); 83 // -- local momentum: 97 // -- local momentum: 84 fLocalTrackMomentum = fAffineTransformation. << 98 fLocalTrackMomentum = fAffineTransformation. >> 99 TransformAxis(fTrack->GetMomentum()); 85 // -- local direction: 100 // -- local direction: 86 fLocalTrackDirection = fLocalTrackMomentum.u 101 fLocalTrackDirection = fLocalTrackMomentum.unit(); 87 // -- local polarization: 102 // -- local polarization: 88 fLocalTrackPolarization = fAffineTransformat << 103 fLocalTrackPolarization = fAffineTransformation. >> 104 TransformAxis(fTrack->GetPolarization()); 89 } 105 } 90 106 91 //------------------------------------ 107 //------------------------------------ 92 // 108 // 93 // 3D transformation of the envelope 109 // 3D transformation of the envelope 94 // This is Done only one time. 110 // This is Done only one time. 95 // 111 // 96 //------------------------------------ 112 //------------------------------------ 97 void G4FastTrack::FRecordsAffineTransformation << 113 void >> 114 G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator) 98 { 115 { >> 116 99 //------------------------------------------ 117 //-------------------------------------------------------- 100 // Get the touchable history which represent 118 // Get the touchable history which represents the current 101 // volume hierachy the particle is in. 119 // volume hierachy the particle is in. 102 // Note that TouchableHistory allocated by t 120 // Note that TouchableHistory allocated by the Navigator 103 // must be deleted by G4FastTrack. 121 // must be deleted by G4FastTrack. 104 //------------------------------------------ 122 //-------------------------------------------------------- 105 const G4Navigator* NavigatorToUse; 123 const G4Navigator* NavigatorToUse; 106 if (theNavigator != nullptr) << 124 if(theNavigator != 0 ) NavigatorToUse=theNavigator; 107 NavigatorToUse = theNavigator; << 108 else 125 else 109 NavigatorToUse = G4TransportationManager:: << 126 NavigatorToUse= 110 << 127 G4TransportationManager::GetTransportationManager()-> 111 G4TouchableHandle history = NavigatorToUse-> << 128 GetNavigatorForTracking(); 112 << 129 >> 130 G4TouchableHistoryHandle history = >> 131 NavigatorToUse->CreateTouchableHistoryHandle(); >> 132 113 //------------------------------------------ 133 //----------------------------------------------------- 114 // Run accross the hierarchy to find the phy 134 // Run accross the hierarchy to find the physical volume 115 // associated with the envelope 135 // associated with the envelope 116 //------------------------------------------ 136 //----------------------------------------------------- 117 auto depth = (G4int)history->GetHistory()->G << 137 G4int depth = history->GetHistory()->GetDepth(); 118 G4int idepth; << 138 G4int idepth, Done = 0; 119 G4bool Done = false; << 139 for (idepth = 0; idepth <= depth; idepth++) 120 for (idepth = 0; idepth <= depth; ++idepth) << 140 { 121 G4VPhysicalVolume* currPV = history->GetHi 141 G4VPhysicalVolume* currPV = history->GetHistory()->GetVolume(idepth); 122 G4LogicalVolume* currLV = currPV->GetLogic << 142 G4LogicalVolume* currLV = currPV->GetLogicalVolume(); 123 if ((currLV->GetRegion() == fEnvelope) && << 143 if ( (currLV->GetRegion() == fEnvelope) && (currLV->IsRootRegion()) ) >> 144 { 124 fEnvelopePhysicalVolume = currPV; 145 fEnvelopePhysicalVolume = currPV; 125 fEnvelopeLogicalVolume = currLV; << 146 fEnvelopeLogicalVolume = currLV; 126 fEnvelopeSolid = currLV->GetSolid(); << 147 fEnvelopeSolid = currLV->GetSolid(); 127 Done = true; << 148 Done = 1; 128 break; 149 break; 129 } 150 } 130 } 151 } 131 //------------------------------------------ 152 //--------------------------------------------- 132 //-- Verification: should be removed in futu 153 //-- Verification: should be removed in future: 133 //------------------------------------------ 154 //--------------------------------------------- 134 if (!Done) { << 155 if ( !Done ) 135 G4ExceptionDescription ed; << 156 { 136 ed << "Can't find transformation for `" << << 157 G4cout << "WARNING - G4FastTrack::FRecordsAffineTransformation()" 137 G4Exception("G4FastTrack::FRecordsAffineTr << 158 << G4endl 138 } << 159 << " Can't find transformation for " 139 else { << 160 << fEnvelopePhysicalVolume->GetName() << G4endl; 140 //---------------------------------------- << 161 G4Exception("G4FastTrack::FRecordsAffineTransformation()", 141 // Records the transformation and inverse << 162 "InvalidSetup", JustWarning, 142 //---------------------------------------- << 163 "Transformation for envelope volume not found!"); 143 fAffineTransformation = history->GetHistor << 164 } 144 fInverseAffineTransformation = fAffineTran << 165 else 145 << 166 { 146 fAffineTransformationDefined = true; << 167 //------------------------------------------------------- 147 } << 168 // Records the transformation and inverse transformation: >> 169 //------------------------------------------------------- >> 170 fAffineTransformation = history->GetHistory()->GetTransform(idepth); >> 171 fInverseAffineTransformation = fAffineTransformation.Inverse(); >> 172 >> 173 fAffineTransformationDefined = true; >> 174 } 148 } 175 } 149 176