Message: Re: Subtraction of G4Cons from G4Sphere crashes the visualisation Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Subtraction of G4Cons from G4Sphere crashes the visualisation 

Forum: Geometry
Re: None Subtraction of G4Cons from G4Sphere crashes the visualisation
Re: None Re: Subtraction of G4Cons from G4Sphere crashes the visualisation
Re: More Re: Subtraction of G4Cons from G4Sphere crashes the visualisation (Gabriele Cosmo)
Date: 06 Jul, 2016
From: John Allison <John Allison>

Hi Dymtro

I can reproduce your symptom. I have spent quite a lot if time on this. First some comments...

You have presented us with a problem that may indicate a bug in Geant4. Whenever that happens we take it seriously and devote as much time as it takes - sometimes a lot of precious time - to discover the problem. If it turns out to be a Geant4 bug we will be very grateful to you. But I have to say that if I were presenting a problem I would check and double check my own code and I would make the code tidy and bug free.

The code is not properly indented - that makes it difficult to read.

You have several arrays - you don't seem to be able to decide whether they should have a size of 11 or 18 or DETNUM. It does not inspire confidence.

Here is a minor error...

  G4double ball_rad=15.*cm, hole_rad=3.*cm;
  ...
  G4VSolid *asolidHole =new G4Cons("solidHole", 0.*cm, 1.0*cm, 0.*cm,
                                   hole_rad*cm, (DetSourceDist-0.6*cm)/2, 0.*deg, 360.*deg);

hole_rad is already in internal units; it should not be multiplied by cm again.

Here is the cause of the problem...

    if (i<1) { //i<100
      SolidBall[i+1]= new G4SubtractionSolid("LeadBallSubtracted",
                                             SolidBall[i], asolidHole, rm[i],
                                             G4ThreeVector(((DetSourceDist-0.15*cm)/2)*cos(phi[i]),
                                                           ((DetSourceDist-0.15*cm)/2)*sin(phi[i]),
                                                           ((DetSourceDist+1.0*cm)/2)*cos(phi_z[i])));

The if statement prevents the subtractions and SolidBall[10], which you use later on, will contain rubbish, hence the crash that you describe.

    G4LogicalVolume* alogicBall = new G4LogicalVolume(SolidBall[10],

If I comment out the if statement the app loops in BooleanProcessor - a completely different place but one which indicates a real bug.

If I change from G4Cons to G4Tubs, it works fine (with the if statement commented out) and produces a nice picture.

I'm afraid it is well known that the BooleanProcessor sometimes fails and we do not have a quick solution. Its job is to create a polyhedral representation for the purposes of visualisation with OpenGL and other systems. It is asking a lot to create 10 subtractions of subtractions. However, this does not affect tracking. Tracking should be OK (but may be slow).

You can visualise your solid with RayTracer or RayTracerX - please try.

Users...please...check your code carefully.

John

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Subtraction of G4Cons from G4Sphere crashes the visualisation   (Dmytro - 08 Jul, 2016)
 Add Message Add Message
to: "Re: Subtraction of G4Cons from G4Sphere crashes the visualisation"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]