49G4AdjointCrossSurfChecker::~G4AdjointCrossSurfChecker() {
delete instance; }
70 if (r1 <= sphere_radius && r2 > sphere_radius) {
74 else if (r2 <= sphere_radius && r1 > sphere_radius) {
85 b = 2. * pos1.dot(dr);
86 c = r12 - sphere_radius * sphere_radius;
87 d = std::sqrt(b * b - 4. * a * c);
89 if (l > 1.) l = (-b - d) / 2. / a;
90 crossing_pos = pos1 + l * dr;
91 cos_th = std::abs(dr.
cosTheta(crossing_pos));
103 if (step_at_boundary) {
106 if ((preStepTouchable !=
nullptr) && (postStepTouchable !=
nullptr) &&
107 (postStepTouchable->
GetVolume() !=
nullptr) && (preStepTouchable->
GetVolume() !=
nullptr))
112 if (post_vol_name == volume_name) {
116 else if (pre_vol_name == volume_name) {
133 if (step_at_boundary) {
137 (postStepTouchable !=
nullptr) ? postStepTouchable->
GetVolume() :
nullptr;
139 (preStepTouchable !=
nullptr) ? preStepTouchable->
GetVolume() :
nullptr;
140 if (preStepTouchable !=
nullptr && postStepTouchable !=
nullptr && postVol !=
nullptr &&
147 if (post_vol_name == volume_name && pre_log_vol_name == mother_logical_vol_name) {
151 else if (pre_vol_name == volume_name && post_log_vol_name == mother_logical_vol_name) {
166 G4int ind = FindRegisteredSurface(surface_name);
179 G4String surf_type = ListOfSurfaceType[ind];
180 G4double radius = ListOfSphereRadius[ind];
182 G4String vol1 = ListOfVol1Name[ind];
183 G4String vol2 = ListOfVol2Name[ind];
186 if (surf_type ==
"Sphere") {
187 did_cross =
CrossingASphere(aStep, radius, center, crossing_pos, cos_to_surface, GoingIn);
189 else if (surf_type ==
"ExternalSurfaceOfAVolume") {
193 else if (surf_type ==
"BoundaryBetweenTwoVolumes") {
195 aStep, vol1, vol2, crossing_pos, cos_to_surface, GoingIn);
205 for (std::size_t i = 0; i < ListOfSurfaceName.size(); ++i) {
207 surface_name = ListOfSurfaceName[i];
221 if (step_at_boundary) {
224 if ((preStepTouchable !=
nullptr) && (postStepTouchable !=
nullptr)) {
226 if (post_vol_name.empty()) {
230 if (pre_vol_name.empty()) {
233 if (pre_vol_name == vol1_name && post_vol_name == vol2_name) {
237 else if (pre_vol_name == vol2_name && post_vol_name == vol1_name) {
251 G4int ind = FindRegisteredSurface(SurfaceName);
252 Area = 4. * pi * radius * radius;
254 ListOfSurfaceType[ind] =
"Sphere";
255 ListOfSphereRadius[ind] = radius;
256 ListOfSphereCenter[ind] = pos;
257 ListOfVol1Name[ind] =
"";
258 ListOfVol2Name[ind] =
"";
259 AreaOfSurface[ind] = Area;
262 ListOfSurfaceName.push_back(SurfaceName);
263 ListOfSurfaceType.emplace_back(
"Sphere");
264 ListOfSphereRadius.push_back(radius);
265 ListOfSphereCenter.push_back(pos);
266 ListOfVol1Name.emplace_back(
"");
267 ListOfVol2Name.emplace_back(
"");
268 AreaOfSurface.push_back(Area);
281 thePhysicalVolume = thePhysVolStore->
GetVolume(volume_name);
282 if (thePhysicalVolume !=
nullptr) {
286 while (mother !=
nullptr) {
287 theTransformationFromPhysVolToWorld *=
289 for (std::size_t i = 0; i < thePhysVolStore->size(); ++i) {
290 if ((*thePhysVolStore)[i]->GetLogicalVolume() == mother) {
291 daughter = (*thePhysVolStore)[i];
298 G4cout <<
"Center of the spherical surface is at the position: " << center / cm <<
" cm"
312 G4int ind = FindRegisteredSurface(SurfaceName);
316 thePhysicalVolume = thePhysVolStore->
GetVolume(volume_name);
317 if (thePhysicalVolume ==
nullptr) {
324 if (theMother !=
nullptr) mother_vol_name = theMother->
GetName();
326 ListOfSurfaceType[ind] =
"ExternalSurfaceOfAVolume";
327 ListOfSphereRadius[ind] = 0.;
329 ListOfVol1Name[ind] = volume_name;
330 ListOfVol2Name[ind] = mother_vol_name;
331 AreaOfSurface[ind] = Area;
334 ListOfSurfaceName.push_back(SurfaceName);
335 ListOfSurfaceType.emplace_back(
"ExternalSurfaceOfAVolume");
336 ListOfSphereRadius.push_back(0.);
337 ListOfSphereCenter.emplace_back(0., 0., 0.);
338 ListOfVol1Name.push_back(volume_name);
339 ListOfVol2Name.push_back(mother_vol_name);
340 AreaOfSurface.push_back(Area);
350 G4int ind = FindRegisteredSurface(SurfaceName);
353 ListOfSurfaceType[ind] =
"BoundaryBetweenTwoVolumes";
354 ListOfSphereRadius[ind] = 0.;
356 ListOfVol1Name[ind] = volume_name1;
357 ListOfVol2Name[ind] = volume_name2;
358 AreaOfSurface[ind] = Area;
361 ListOfSurfaceName.push_back(SurfaceName);
362 ListOfSurfaceType.emplace_back(
"BoundaryBetweenTwoVolumes");
363 ListOfSphereRadius.push_back(0.);
364 ListOfSphereCenter.emplace_back(0., 0., 0.);
365 ListOfVol1Name.push_back(volume_name1);
366 ListOfVol2Name.push_back(volume_name2);
367 AreaOfSurface.push_back(Area);
376 ListOfSurfaceName.clear();
377 ListOfSurfaceType.clear();
378 ListOfSphereRadius.clear();
379 ListOfSphereCenter.clear();
380 ListOfVol1Name.clear();
381 ListOfVol2Name.clear();
386G4int G4AdjointCrossSurfChecker::FindRegisteredSurface(
const G4String& name)
388 for (std::size_t i = 0; i < ListOfSurfaceName.size(); ++i) {
389 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()
G4VPhysicalVolume * GetVolume(const G4String &name, G4bool verbose=true, G4bool reverseSearch=false) const
const G4VTouchable * GetTouchable() const
const G4ThreeVector & GetPosition() const
G4StepPoint * GetPreStepPoint() const
G4StepPoint * GetPostStepPoint() const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
G4LogicalVolume * GetMotherLogical() const
G4LogicalVolume * GetLogicalVolume() const
const G4RotationMatrix * GetFrameRotation() const
const G4String & GetName() const
G4ThreeVector GetObjectTranslation() const
virtual G4double GetSurfaceArea()