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.6 2001/10/26 14:43:37 mverderi Exp $ >> 25 // GEANT4 tag $Name: geant4-05-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" << 46 43 47 // ----------- 44 // ----------- 48 // Constructor 45 // Constructor 49 // ----------- 46 // ----------- 50 // 47 // 51 G4FastTrack::G4FastTrack(G4Envelope* anEnvelop << 48 G4FastTrack::G4FastTrack(G4Envelope *anEnvelope, 52 : fEnvelope(anEnvelope), fIsUnique(IsUnique) << 49 G4bool IsUnique) : >> 50 fAffineTransformationDefined(false), fEnvelope(anEnvelope), >> 51 fIsUnique(IsUnique), fEnvelopeSolid(fEnvelope->GetSolid()) >> 52 {} >> 53 >> 54 // ----------- >> 55 // Destructor: >> 56 // ----------- >> 57 G4FastTrack::~G4FastTrack() 53 {} 58 {} 54 59 55 //-------------------------------------------- 60 //------------------------------------------------------------ 56 // The parameterised simulation manager uses t 61 // The parameterised simulation manager uses the SetCurrentTrack 57 // method to setup the current G4FastTrack obj << 62 // method to setup the current G4FastTrack object 58 //-------------------------------------------- 63 //------------------------------------------------------------ 59 void G4FastTrack::SetCurrentTrack(const G4Trac << 64 void G4FastTrack::SetCurrentTrack(const G4Track& track, >> 65 const G4Navigator* theNavigator) 60 { 66 { >> 67 61 // -- Register track pointer (used everywher 68 // -- Register track pointer (used everywhere): 62 fTrack = &track; 69 fTrack = &track; 63 70 64 //------------------------------------------ 71 //----------------------------------------------------- 65 // First time the track enters the volume or 72 // First time the track enters the volume or if the 66 // Logical Volume was placed n-Times in the 73 // Logical Volume was placed n-Times in the geometry : 67 // << 74 // 68 // Records the Rotation+Translation for the 75 // Records the Rotation+Translation for the Envelope ! 69 // When the particle is inside or on the bou << 76 // When the particle is inside or on the boundary, the 70 // NavigationHistory IS UP TO DATE. 77 // NavigationHistory IS UP TO DATE. 71 //------------------------------------------ 78 //------------------------------------------------------ 72 if (!fAffineTransformationDefined || !fIsUni << 79 if (!fAffineTransformationDefined || !fIsUnique) 73 << 80 FRecordsAffineTransformation(theNavigator); >> 81 74 //------------------------------------------ 82 //------------------------------------------- 75 // Records local position/momentum/direction 83 // Records local position/momentum/direction 76 // of the Track. 84 // of the Track. 77 // They are accessible to the user through a 85 // They are accessible to the user through a 78 // set of Get functions and should be useful 86 // set of Get functions and should be useful 79 // to decide to trigger or not. 87 // to decide to trigger or not. 80 //------------------------------------------ 88 //------------------------------------------- 81 // -- local position: 89 // -- local position: 82 fLocalTrackPosition = fAffineTransformation. << 90 fLocalTrackPosition = fAffineTransformation. >> 91 TransformPoint(fTrack->GetPosition()); 83 // -- local momentum: 92 // -- local momentum: 84 fLocalTrackMomentum = fAffineTransformation. << 93 fLocalTrackMomentum = fAffineTransformation. >> 94 TransformAxis(fTrack->GetMomentum()); 85 // -- local direction: 95 // -- local direction: 86 fLocalTrackDirection = fLocalTrackMomentum.u 96 fLocalTrackDirection = fLocalTrackMomentum.unit(); 87 // -- local polarization: 97 // -- local polarization: 88 fLocalTrackPolarization = fAffineTransformat << 98 fLocalTrackPolarization = fAffineTransformation. >> 99 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; << 108 else 120 else 109 NavigatorToUse = G4TransportationManager:: << 121 NavigatorToUse= 110 << 122 G4TransportationManager::GetTransportationManager()-> 111 G4TouchableHandle history = NavigatorToUse-> << 123 GetNavigatorForTracking(); 112 << 124 >> 125 G4TouchableHistory *history = >> 126 NavigatorToUse->CreateTouchableHistory(); >> 127 113 //------------------------------------------ 128 //----------------------------------------------------- 114 // Run accross the hierarchy to find the phy 129 // Run accross the hierarchy to find the physical volume 115 // associated with the envelope 130 // associated with the envelope 116 //------------------------------------------ 131 //----------------------------------------------------- 117 auto depth = (G4int)history->GetHistory()->G << 132 int depth = history->GetHistory()->GetDepth(); 118 G4int idepth; << 133 int idepth, Done = 0; 119 G4bool Done = false; << 134 for (idepth = 0; idepth <= depth; idepth++) { 120 for (idepth = 0; idepth <= depth; ++idepth) << 135 if (history->GetHistory()->GetVolume(idepth)->GetLogicalVolume() == 121 G4VPhysicalVolume* currPV = history->GetHi << 136 fEnvelope) { 122 G4LogicalVolume* currLV = currPV->GetLogic << 137 fEnvelopePhysicalVolume=history->GetHistory()->GetVolume(idepth); 123 if ((currLV->GetRegion() == fEnvelope) && << 138 Done = 1; 124 fEnvelopePhysicalVolume = currPV; << 125 fEnvelopeLogicalVolume = currLV; << 126 fEnvelopeSolid = currLV->GetSolid(); << 127 Done = true; << 128 break; 139 break; 129 } 140 } 130 } 141 } 131 //------------------------------------------ 142 //--------------------------------------------- 132 //-- Verification: should be removed in futu 143 //-- Verification: should be removed in future: 133 //------------------------------------------ 144 //--------------------------------------------- 134 if (!Done) { << 145 if ( !Done ) 135 G4ExceptionDescription ed; << 146 { 136 ed << "Can't find transformation for `" << << 147 G4cout << "\n\nERROR !!! can't find Transform for " << 137 G4Exception("G4FastTrack::FRecordsAffineTr << 148 fEnvelopePhysicalVolume->GetName() << "\n\n" << G4endl; 138 } << 149 } 139 else { << 150 else 140 //---------------------------------------- << 151 { 141 // Records the transformation and inverse << 152 //------------------------------------------------------- 142 //---------------------------------------- << 153 // Records the transformation and inverse transformation: 143 fAffineTransformation = history->GetHistor << 154 //------------------------------------------------------- 144 fInverseAffineTransformation = fAffineTran << 155 fAffineTransformation = history->GetHistory()->GetTransform(idepth); 145 << 156 fInverseAffineTransformation = fAffineTransformation.Inverse(); 146 fAffineTransformationDefined = true; << 157 147 } << 158 fAffineTransformationDefined = true; >> 159 } >> 160 >> 161 //------------------------------------------------------ >> 162 // Delete the TouchableHistory created by the Navigator: >> 163 //------------------------------------------------------ >> 164 delete history; >> 165 history = 0; 148 } 166 } >> 167 >> 168 149 169