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