45 G4AdjointCrossSurfChecker::instance =
nullptr;
49G4AdjointCrossSurfChecker::G4AdjointCrossSurfChecker()
55G4AdjointCrossSurfChecker::~G4AdjointCrossSurfChecker()
81 if (r1<=sphere_radius && r2>sphere_radius)
86 else if (r2<=sphere_radius && r1>sphere_radius)
100 c = r12-sphere_radius*sphere_radius;
101 d = std::sqrt(b*b-4.*a*c);
103 if (l > 1.) l=(-b-d)/2./a;
104 crossing_pos = pos1+l*dr;
105 cos_th = std::abs(dr.
cosTheta(crossing_pos));
119 if (step_at_boundary)
125 if (preStepTouchable && postStepTouchable
131 if (post_vol_name == volume_name )
136 else if (pre_vol_name == volume_name)
151 const G4String& mother_logical_vol_name,
158 if (step_at_boundary)
165 ? postStepTouchable->
GetVolume() :
nullptr;
167 ? preStepTouchable->
GetVolume() :
nullptr;
168 if (preStepTouchable !=
nullptr && postStepTouchable !=
nullptr
169 && postVol !=
nullptr && preVol !=
nullptr)
175 if (post_vol_name == volume_name
176 && pre_log_vol_name == mother_logical_vol_name)
181 else if (pre_vol_name == volume_name
182 && post_log_vol_name == mother_logical_vol_name )
200 G4int ind = FindRegisteredSurface(surface_name);
205 cos_to_surface, GoingIn);
217 G4String surf_type = ListOfSurfaceType[ind];
218 G4double radius = ListOfSphereRadius[ind];
220 G4String vol1 = ListOfVol1Name[ind];
221 G4String vol2 = ListOfVol2Name[ind];
224 if (surf_type ==
"Sphere")
227 cos_to_surface, GoingIn);
229 else if (surf_type ==
"ExternalSurfaceOfAVolume")
232 cos_to_surface, GoingIn);
235 else if (surf_type ==
"BoundaryBetweenTwoVolumes")
239 cos_to_surface, GoingIn);
252 for (std::size_t i=0; i<ListOfSurfaceName.size(); ++i)
255 cos_to_surface, GoingIn))
257 surface_name = ListOfSurfaceName[i];
276 if (step_at_boundary)
282 if (preStepTouchable && postStepTouchable)
285 if (post_vol_name ==
"")
291 if (pre_vol_name ==
"")
296 if (pre_vol_name == vol1_name && post_vol_name == vol2_name)
301 else if (pre_vol_name == vol2_name && post_vol_name == vol1_name)
317 G4int ind = FindRegisteredSurface(SurfaceName);
318 Area = 4.*pi*radius*radius;
321 ListOfSurfaceType[ind] =
"Sphere";
322 ListOfSphereRadius[ind] = radius;
323 ListOfSphereCenter[ind] = pos;
324 ListOfVol1Name[ind] =
"";
325 ListOfVol2Name[ind] =
"";
326 AreaOfSurface[ind] = Area;
330 ListOfSurfaceName.push_back(SurfaceName);
331 ListOfSurfaceType.push_back(
"Sphere");
332 ListOfSphereRadius.push_back(radius);
333 ListOfSphereCenter.push_back(pos);
334 ListOfVol1Name.push_back(
"");
335 ListOfVol2Name.push_back(
"");
336 AreaOfSurface.push_back(Area);
352 for (std::size_t i=0; i<thePhysVolStore->size(); ++i)
354 if ((*thePhysVolStore)[i]->GetName() == volume_name)
356 thePhysicalVolume = (*thePhysVolStore)[i];
359 if (thePhysicalVolume !=
nullptr)
364 while (mother !=
nullptr)
366 theTransformationFromPhysVolToWorld *=
369 for ( std::size_t i=0; i<thePhysVolStore->size(); ++i)
371 if ((*thePhysVolStore)[i]->GetLogicalVolume() == mother)
373 daughter = (*thePhysVolStore)[i];
380 G4cout <<
"Center of the spherical surface is at the position: "
381 << center/cm <<
" cm" <<
G4endl;
385 G4cout <<
"The physical volume with name " << volume_name
386 <<
" does not exist!! " <<
G4endl;
398 G4int ind = FindRegisteredSurface(SurfaceName);
402 for (std::size_t i=0; i<thePhysVolStore->size(); ++i)
404 if ((*thePhysVolStore)[i]->GetName() == volume_name)
406 thePhysicalVolume = (*thePhysVolStore)[i];
409 if (thePhysicalVolume ==
nullptr)
411 G4cout <<
"The physical volume with name " << volume_name
412 <<
" does not exist!!" <<
G4endl;
419 if (theMother !=
nullptr) mother_vol_name= theMother->
GetName();
422 ListOfSurfaceType[ind] =
"ExternalSurfaceOfAVolume";
423 ListOfSphereRadius[ind] = 0.;
425 ListOfVol1Name[ind] = volume_name;
426 ListOfVol2Name[ind] = mother_vol_name;
427 AreaOfSurface[ind] = Area;
431 ListOfSurfaceName.push_back(SurfaceName);
432 ListOfSurfaceType.push_back(
"ExternalSurfaceOfAVolume");
433 ListOfSphereRadius.push_back(0.);
435 ListOfVol1Name.push_back(volume_name);
436 ListOfVol2Name.push_back(mother_vol_name);
437 AreaOfSurface.push_back(Area);
449 G4int ind = FindRegisteredSurface(SurfaceName);
453 ListOfSurfaceType[ind] =
"BoundaryBetweenTwoVolumes";
454 ListOfSphereRadius[ind] = 0.;
456 ListOfVol1Name[ind] = volume_name1;
457 ListOfVol2Name[ind] = volume_name2;
458 AreaOfSurface[ind] = Area;
462 ListOfSurfaceName.push_back(SurfaceName);
463 ListOfSurfaceType.push_back(
"BoundaryBetweenTwoVolumes");
464 ListOfSphereRadius.push_back(0.);
466 ListOfVol1Name.push_back(volume_name1);
467 ListOfVol2Name.push_back(volume_name2);
468 AreaOfSurface.push_back(Area);
477 ListOfSurfaceName.clear();
478 ListOfSurfaceType.clear();
479 ListOfSphereRadius.clear();
480 ListOfSphereCenter.clear();
481 ListOfVol1Name.clear();
482 ListOfVol2Name.clear();
487G4int G4AdjointCrossSurfChecker::FindRegisteredSurface(
const G4String& name)
489 for (std::size_t i=0; i<ListOfSurfaceName.size(); ++i)
491 if (name == ListOfSurfaceName[i])
return G4int(i);
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
G4bool CrossingAGivenRegisteredSurface(const G4Step *aStep, const G4String &surface_name, G4ThreeVector &cross_pos, G4double &cos_to_surface, G4bool &GoingIn)
G4bool CrossingAnInterfaceBetweenTwoVolumes(const G4Step *aStep, const G4String &vol1_name, const G4String &vol2_name, G4ThreeVector &cross_pos, G4double &cos_to_surface, G4bool &GoingIn)
void ClearListOfSelectedSurface()
G4bool CrossingOneOfTheRegisteredSurface(const G4Step *aStep, G4String &surface_name, G4ThreeVector &cross_pos, G4double &cos_to_surface, G4bool &GoingIn)
G4bool AddaSphericalSurface(const G4String &SurfaceName, G4double radius, G4ThreeVector pos, G4double &area)
G4bool GoingInOrOutOfaVolumeByExtSurface(const G4Step *aStep, const G4String &volume_name, const G4String &mother_lvol_name, G4double &cos_to_surface, G4bool &GoingIn)
G4bool AddanExtSurfaceOfAvolume(const G4String &SurfaceName, const G4String &volume_name, G4double &area)
static G4AdjointCrossSurfChecker * GetInstance()
G4bool AddanInterfaceBetweenTwoVolumes(const G4String &SurfaceName, const G4String &volume_name1, const G4String &volume_name2, G4double &area)
G4bool AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(const G4String &SurfaceName, G4double radius, const G4String &volume_name, G4ThreeVector ¢er, G4double &area)
G4bool GoingInOrOutOfaVolume(const G4Step *aStep, const G4String &volume_name, G4double &cos_to_surface, G4bool &GoingIn)
G4bool CrossingASphere(const G4Step *aStep, G4double sphere_radius, G4ThreeVector sphere_center, G4ThreeVector &cross_pos, G4double &cos_to_surface, G4bool &GoingIn)
G4VSolid * GetSolid() const
const G4String & GetName() const
static G4PhysicalVolumeStore * GetInstance()
G4StepStatus GetStepStatus() const
const G4VTouchable * GetTouchable() const
const G4ThreeVector & GetPosition() const
G4StepPoint * GetPreStepPoint() const
G4StepPoint * GetPostStepPoint() const
G4LogicalVolume * GetMotherLogical() const
G4LogicalVolume * GetLogicalVolume() const
const G4RotationMatrix * GetFrameRotation() const
const G4String & GetName() const
G4ThreeVector GetObjectTranslation() const
virtual G4double GetSurfaceArea()
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const