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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/navigation/src/G4ErrorPropagationNavigator.cc (Version 11.3.0) and /geometry/navigation/src/G4ErrorPropagationNavigator.cc (Version 10.4.p2)


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