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