Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // >> 24 // $Id: G4FastTrack.cc,v 1.7 2003/11/10 08:57:22 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-06-00 $ 27 // 26 // 28 //-------------------------------------------- 27 //--------------------------------------------------------------- 29 // 28 // 30 // G4FastTrack.cc 29 // G4FastTrack.cc 31 // 30 // 32 // Description: 31 // Description: 33 // Keeps the current track information and 32 // Keeps the current track information and special features 34 // for Parameterised Simulation Models. 33 // for Parameterised Simulation Models. 35 // 34 // 36 // History: 35 // History: 37 // Oct 97: Verderi && MoraDeFreitas - First 36 // Oct 97: Verderi && MoraDeFreitas - First Implementation. 38 // 37 // 39 //-------------------------------------------- 38 //--------------------------------------------------------------- 40 39 >> 40 #include "G4ios.hh" 41 #include "G4FastTrack.hh" 41 #include "G4FastTrack.hh" 42 << 43 #include "G4TouchableHandle.hh" << 44 #include "G4TransportationManager.hh" 42 #include "G4TransportationManager.hh" 45 #include "G4ios.hh" << 43 #include "G4TouchableHistoryHandle.hh" 46 44 47 // ----------- 45 // ----------- 48 // Constructor 46 // Constructor 49 // ----------- 47 // ----------- 50 // 48 // 51 G4FastTrack::G4FastTrack(G4Envelope* anEnvelop << 49 G4FastTrack::G4FastTrack(G4Envelope *anEnvelope, 52 : fEnvelope(anEnvelope), fIsUnique(IsUnique) << 50 G4bool IsUnique) : >> 51 fAffineTransformationDefined(false), fEnvelope(anEnvelope), >> 52 fIsUnique(IsUnique), fEnvelopeSolid(fEnvelope->GetSolid()) >> 53 {} >> 54 >> 55 // ----------- >> 56 // Destructor: >> 57 // ----------- >> 58 G4FastTrack::~G4FastTrack() 53 {} 59 {} 54 60 55 //-------------------------------------------- 61 //------------------------------------------------------------ 56 // The parameterised simulation manager uses t 62 // The parameterised simulation manager uses the SetCurrentTrack 57 // method to setup the current G4FastTrack obj << 63 // method to setup the current G4FastTrack object 58 //-------------------------------------------- 64 //------------------------------------------------------------ 59 void G4FastTrack::SetCurrentTrack(const G4Trac << 65 void G4FastTrack::SetCurrentTrack(const G4Track& track, >> 66 const G4Navigator* theNavigator) 60 { 67 { >> 68 61 // -- Register track pointer (used everywher 69 // -- Register track pointer (used everywhere): 62 fTrack = &track; 70 fTrack = &track; 63 71 64 //------------------------------------------ 72 //----------------------------------------------------- 65 // First time the track enters the volume or 73 // First time the track enters the volume or if the 66 // Logical Volume was placed n-Times in the 74 // Logical Volume was placed n-Times in the geometry : 67 // << 75 // 68 // Records the Rotation+Translation for the 76 // Records the Rotation+Translation for the Envelope ! 69 // When the particle is inside or on the bou << 77 // When the particle is inside or on the boundary, the 70 // NavigationHistory IS UP TO DATE. 78 // NavigationHistory IS UP TO DATE. 71 //------------------------------------------ 79 //------------------------------------------------------ 72 if (!fAffineTransformationDefined || !fIsUni << 80 if (!fAffineTransformationDefined || !fIsUnique) 73 << 81 FRecordsAffineTransformation(theNavigator); >> 82 74 //------------------------------------------ 83 //------------------------------------------- 75 // Records local position/momentum/direction 84 // Records local position/momentum/direction 76 // of the Track. 85 // of the Track. 77 // They are accessible to the user through a 86 // They are accessible to the user through a 78 // set of Get functions and should be useful 87 // set of Get functions and should be useful 79 // to decide to trigger or not. 88 // to decide to trigger or not. 80 //------------------------------------------ 89 //------------------------------------------- 81 // -- local position: 90 // -- local position: 82 fLocalTrackPosition = fAffineTransformation. << 91 fLocalTrackPosition = fAffineTransformation. >> 92 TransformPoint(fTrack->GetPosition()); 83 // -- local momentum: 93 // -- local momentum: 84 fLocalTrackMomentum = fAffineTransformation. << 94 fLocalTrackMomentum = fAffineTransformation. >> 95 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. >> 100 TransformAxis(fTrack->GetPolarization()); 89 } 101 } 90 102 91 //------------------------------------ 103 //------------------------------------ 92 // 104 // 93 // 3D transformation of the envelope 105 // 3D transformation of the envelope 94 // This is Done only one time. 106 // This is Done only one time. 95 // 107 // 96 //------------------------------------ 108 //------------------------------------ 97 void G4FastTrack::FRecordsAffineTransformation << 109 void >> 110 G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator) 98 { 111 { >> 112 99 //------------------------------------------ 113 //-------------------------------------------------------- 100 // Get the touchable history which represent 114 // Get the touchable history which represents the current 101 // volume hierachy the particle is in. 115 // volume hierachy the particle is in. 102 // Note that TouchableHistory allocated by t 116 // Note that TouchableHistory allocated by the Navigator 103 // must be deleted by G4FastTrack. 117 // must be deleted by G4FastTrack. 104 //------------------------------------------ 118 //-------------------------------------------------------- 105 const G4Navigator* NavigatorToUse; 119 const G4Navigator* NavigatorToUse; 106 if (theNavigator != nullptr) << 120 if(theNavigator != 0 ) NavigatorToUse=theNavigator; 107 NavigatorToUse = theNavigator; << 108 else 121 else 109 NavigatorToUse = G4TransportationManager:: << 122 NavigatorToUse= 110 << 123 G4TransportationManager::GetTransportationManager()-> 111 G4TouchableHandle history = NavigatorToUse-> << 124 GetNavigatorForTracking(); 112 << 125 >> 126 G4TouchableHistoryHandle history = >> 127 NavigatorToUse->CreateTouchableHistoryHandle(); >> 128 113 //------------------------------------------ 129 //----------------------------------------------------- 114 // Run accross the hierarchy to find the phy 130 // Run accross the hierarchy to find the physical volume 115 // associated with the envelope 131 // associated with the envelope 116 //------------------------------------------ 132 //----------------------------------------------------- 117 auto depth = (G4int)history->GetHistory()->G << 133 int depth = history->GetHistory()->GetDepth(); 118 G4int idepth; << 134 int idepth, Done = 0; 119 G4bool Done = false; << 135 for (idepth = 0; idepth <= depth; idepth++) { 120 for (idepth = 0; idepth <= depth; ++idepth) << 136 if (history->GetHistory()->GetVolume(idepth)->GetLogicalVolume() == 121 G4VPhysicalVolume* currPV = history->GetHi << 137 fEnvelope) { 122 G4LogicalVolume* currLV = currPV->GetLogic << 138 fEnvelopePhysicalVolume=history->GetHistory()->GetVolume(idepth); 123 if ((currLV->GetRegion() == fEnvelope) && << 139 Done = 1; 124 fEnvelopePhysicalVolume = currPV; << 125 fEnvelopeLogicalVolume = currLV; << 126 fEnvelopeSolid = currLV->GetSolid(); << 127 Done = true; << 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 G4cout << "\n\nERROR !!! can't find Transform for " << 137 G4Exception("G4FastTrack::FRecordsAffineTr << 149 fEnvelopePhysicalVolume->GetName() << "\n\n" << G4endl; 138 } << 150 } 139 else { << 151 else 140 //---------------------------------------- << 152 { 141 // Records the transformation and inverse << 153 //------------------------------------------------------- 142 //---------------------------------------- << 154 // Records the transformation and inverse transformation: 143 fAffineTransformation = history->GetHistor << 155 //------------------------------------------------------- 144 fInverseAffineTransformation = fAffineTran << 156 fAffineTransformation = history->GetHistory()->GetTransform(idepth); 145 << 157 fInverseAffineTransformation = fAffineTransformation.Inverse(); 146 fAffineTransformationDefined = true; << 158 147 } << 159 fAffineTransformationDefined = true; >> 160 } 148 } 161 } 149 162