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 // class G4ErrorPropagationNavigator implement << 27 // 26 // 28 // Author: Pedro Arce, CIEMAT << 27 // $Id: G4ErrorPropagationNavigator.cc,v 1.1 2007/05/16 12:49:18 gcosmo Exp $ >> 28 // GEANT4 tag $Name: geant4-09-01-patch-02 $ >> 29 // >> 30 // >> 31 // -------------------------------------------------------------------- >> 32 // GEANT 4 class implementation file 29 // ------------------------------------------- 33 // -------------------------------------------------------------------- 30 34 31 #include "G4ErrorPropagationNavigator.hh" 35 #include "G4ErrorPropagationNavigator.hh" 32 36 33 #include "globals.hh" 37 #include "globals.hh" 34 #include "G4ThreeVector.hh" 38 #include "G4ThreeVector.hh" 35 #include "G4ErrorPropagatorData.hh" 39 #include "G4ErrorPropagatorData.hh" 36 #include "G4ErrorSurfaceTarget.hh" 40 #include "G4ErrorSurfaceTarget.hh" 37 41 38 #include "G4ErrorPlaneSurfaceTarget.hh" << 42 //------------------------------------------------------------------- 39 #include "G4ErrorCylSurfaceTarget.hh" << 43 >> 44 G4ErrorPropagationNavigator::G4ErrorPropagationNavigator() >> 45 : G4Navigator() >> 46 { >> 47 } >> 48 >> 49 //------------------------------------------------------------------- >> 50 >> 51 G4ErrorPropagationNavigator::~G4ErrorPropagationNavigator() >> 52 { >> 53 } >> 54 >> 55 //------------------------------------------------------------------- 40 56 41 G4double G4ErrorPropagationNavigator:: 57 G4double G4ErrorPropagationNavigator:: 42 ComputeStep ( const G4ThreeVector &pGlobalPoin 58 ComputeStep ( const G4ThreeVector &pGlobalPoint, 43 const G4ThreeVector &pDirection, 59 const G4ThreeVector &pDirection, 44 const G4double pCurrentProposedS 60 const G4double pCurrentProposedStepLength, 45 G4double &pNewSafety ) 61 G4double &pNewSafety ) 46 { 62 { 47 G4double safetyGeom = DBL_MAX; << 48 << 49 G4double Step = G4Navigator::ComputeStep(pGl 63 G4double Step = G4Navigator::ComputeStep(pGlobalPoint, pDirection, 50 pCu 64 pCurrentProposedStepLength, 51 saf << 65 pNewSafety); 52 66 53 G4ErrorPropagatorData* g4edata << 67 G4ErrorPropagatorData * g4edata 54 = G4ErrorPropagatorData::GetErrorPropagato 68 = G4ErrorPropagatorData::GetErrorPropagatorData(); 55 69 56 if ( g4edata != nullptr ) << 70 if (g4edata !=0) 57 { 71 { 58 const G4ErrorTarget* target = g4edata->Get 72 const G4ErrorTarget* target = g4edata->GetTarget(); 59 if( target != nullptr ) << 73 if( target != 0 ) 60 { 74 { 61 G4double StepPlane=target->GetDistanceFr << 75 G4double StepPlane(target->GetDistanceFromPoint(pGlobalPoint,pDirection)); 62 76 63 if( StepPlane < 0. ) // Negative means t << 77 if( StepPlane < 0. ) // Negative means target is crossed, will not be found 64 { // will not be foun << 78 { 65 StepPlane = DBL_MAX; 79 StepPlane = DBL_MAX; 66 } 80 } 67 #ifdef G4VERBOSE 81 #ifdef G4VERBOSE 68 if( G4ErrorPropagatorData::verbose() >= 82 if( G4ErrorPropagatorData::verbose() >= 4 ) 69 { 83 { 70 G4cout << "G4ErrorPropagationNavigator 84 G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl 71 << " Target step: " << StepPla 85 << " Target step: " << StepPlane 72 << ", Transportation step: " << 86 << ", Transportation step: " << Step << G4endl; 73 target->Dump( "G4ErrorPropagationNavig 87 target->Dump( "G4ErrorPropagationNavigator::ComputeStep Target " ); 74 } 88 } 75 #endif 89 #endif 76 90 77 if( StepPlane < Step ) << 91 if(StepPlane<Step) 78 { 92 { 79 #ifdef G4VERBOSE 93 #ifdef G4VERBOSE 80 if( G4ErrorPropagatorData::verbose() > 94 if( G4ErrorPropagatorData::verbose() >= 2 ) 81 { 95 { 82 G4cout << "G4ErrorPropagationNavigat 96 G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl 83 << " TargetCloserThanBoundar 97 << " TargetCloserThanBoundary: " << StepPlane << " < " 84 << Step << G4endl; 98 << Step << G4endl; 85 } 99 } 86 #endif 100 #endif 87 Step = StepPlane; 101 Step = StepPlane; 88 g4edata->SetState(G4ErrorState_TargetC 102 g4edata->SetState(G4ErrorState_TargetCloserThanBoundary); 89 } 103 } 90 else 104 else 91 { 105 { 92 g4edata->SetState(G4ErrorState_Propaga 106 g4edata->SetState(G4ErrorState_Propagating); 93 } 107 } 94 } 108 } 95 } 109 } 96 G4double safetyTarget = TargetSafetyFromPoin << 110 pNewSafety = ComputeSafety(pGlobalPoint, pCurrentProposedStepLength); 97 << 98 // Avoid call to G4Navigator::ComputeSafety << 99 // << 100 pNewSafety = std::min(safetyGeom, safetyTarg << 101 111 102 #ifdef G4VERBOSE 112 #ifdef G4VERBOSE 103 if( G4ErrorPropagatorData::verbose() >= 3 ) 113 if( G4ErrorPropagatorData::verbose() >= 3 ) 104 { 114 { 105 G4cout << "G4ErrorPropagationNavigator::Co 115 G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl 106 << " Step: " << Step << ", Compute 116 << " Step: " << Step << ", ComputeSafety: " << pNewSafety 107 << G4endl; 117 << G4endl; 108 } 118 } 109 #endif 119 #endif 110 120 111 return Step; 121 return Step; 112 } 122 } 113 123 114 //-------------------------------------------- 124 //------------------------------------------------------------------- 115 125 116 G4double G4ErrorPropagationNavigator:: 126 G4double G4ErrorPropagationNavigator:: 117 TargetSafetyFromPoint( const G4ThreeVector& pG << 127 ComputeSafety( const G4ThreeVector &pGlobalpoint, >> 128 const G4double pMaxLength ) 118 { 129 { 119 G4double safety = DBL_MAX; << 130 G4double newSafety = G4Navigator::ComputeSafety(pGlobalpoint, pMaxLength); 120 131 121 G4ErrorPropagatorData* g4edata << 132 G4ErrorPropagatorData *g4edata 122 = G4ErrorPropagatorData::GetErrorPropagato 133 = G4ErrorPropagatorData::GetErrorPropagatorData(); 123 134 124 if ( g4edata != nullptr ) << 135 if (g4edata !=0) 125 { 136 { 126 const G4ErrorTarget* target = g4edata->Get 137 const G4ErrorTarget* target = g4edata->GetTarget(); 127 if( target != nullptr ) << 138 if( target != 0 ) 128 { << 129 safety = target->GetDistanceFromPoint(p << 130 } << 131 } << 132 return safety; << 133 } << 134 << 135 //-------------------------------------------- << 136 << 137 G4double G4ErrorPropagationNavigator:: << 138 ComputeSafety( const G4ThreeVector &pGlobalPoi << 139 const G4double pMaxLength, << 140 const G4bool keepState ) << 141 { << 142 G4double safetyGeom = G4Navigator::ComputeSa << 143 << 144 << 145 G4double safetyTarget = TargetSafetyFromPoin << 146 << 147 return std::min(safetyGeom, safetyTarget); << 148 } << 149 << 150 //-------------------------------------------- << 151 << 152 G4ThreeVector G4ErrorPropagationNavigator:: << 153 GetGlobalExitNormal( const G4ThreeVector& poin << 154 { << 155 G4ErrorPropagatorData* g4edata << 156 = G4ErrorPropagatorData::GetErrorPropa << 157 const G4ErrorTarget* target = nullptr; << 158 << 159 G4ThreeVector normal(0.0, 0.0, 0.0); << 160 G4double distance= 0; << 161 << 162 // Determine which 'geometry' limited the st << 163 if ( g4edata != nullptr ) << 164 { << 165 target = g4edata->GetTarget(); << 166 if( target != nullptr ) << 167 { 139 { 168 distance = target->GetDistanceFromPoint( << 140 G4double distance = target->GetDistanceFromPoint(pGlobalpoint); 169 } << 141 170 } << 142 if(distance<newSafety) 171 << 143 { 172 if( distance > kCarTolerance || (target == n << 144 newSafety = distance; 173 // Not reached the target or if a target d << 145 } 174 // this seems the best we can do << 175 { << 176 normal = G4Navigator::GetGlobalExitNormal( << 177 } << 178 else << 179 { << 180 switch( target->GetType() ) << 181 { << 182 case G4ErrorTarget_GeomVolume: << 183 // The volume is in the 'real' mass ge << 184 normal = G4Navigator::GetGlobalExitNor << 185 break; << 186 case G4ErrorTarget_TrkL: << 187 normal = G4ThreeVector( 0.0, 0.0, 0.0) << 188 *valid = false; << 189 G4Exception("G4ErrorPropagationNavigat << 190 "Geometry1003", << 191 JustWarning, "Unexpected v << 192 break; << 193 case G4ErrorTarget_PlaneSurface: << 194 case G4ErrorTarget_CylindricalSurface: << 195 const auto surfTarget= static_cast<con << 196 normal = surfTarget->GetTangentPlane(p << 197 *valid = true; << 198 break; << 199 << 200 // default: << 201 // normal= G4ThreeVector( 0.0, 0.0, 0.0 << 202 // *valid = false; << 203 // G4Exception("G4ErrorPropagationNavig << 204 // "Geometry:003", << 205 // FatalException, "Impossi << 206 // break; << 207 } 146 } 208 } 147 } 209 return normal; << 148 return newSafety; 210 } << 149 } 211 << 212 150