2 circular targets

Hi every one, I must to modify the target of the B1 example. Currently I deleted all the internal shells and I have

// Envelope parameters
  //
  G4double env_sizeXY = 20*cm, env_sizeZ = 6*cm;
  G4Material* env_mat = nist->FindOrBuildMaterial("G4_GRAPHITE");

but I must simulate 2 circular beryllium targets, having diameter 1.5cm thikness 3mm and the distance between them must be 2cm.
Please, can someone help me?

Thanks

Hi, please…someone?
Thanks

Please have a look at the user guide on geometry, in particular on the solids.

Hi @anna thank you for your reply. I first started trying to modify the parallelepiped box to cylindrical one having diameter 1.5cm and thikness 3mm

Here my code in B1DetectorConstruction.cc

[...]
        /**************************** START DEFINE NEW CYLINDRICAL BOX  LIBRARIES************************/
    #include "G4Tubs.hh"

    /**************************** END DEFINE NEW CYLINDRICAL BOX  LIBRARIES************************/

        [...]

        /**************************** START DEFINE NEW CYLINDRICAL BOX  PARAMETERS************************/
          G4double pi = 3.14159265358979323846;
          G4double pRMin = 0., pRMax = 0.75*cm, pDz = 1.5*mm, pSPhi = 2*pi, pDPhi = 0.;
          
          /**************************** END DEFINE NEW CYLINDRICAL BOX  PARAMETERS************************/

    [...]

 [...]
 /**************************** START DEFINE NEW CYLINDRICAL BOX ************************/
   /* G4Box* solidEnv =    
     new G4Box("Envelope",                    //its name
         0.5*env_sizeXY, 0.5*env_sizeXY, 0.5*env_sizeZ); //its size*/
      
 	G4Tubs* solidEnv =    
     new G4Tubs("Envelope",                    //its name
         pRMin, pRMax, pDz, pSPhi, pDPhi);    //its size*/
         
 /**************************** END DEFINE NEW CYLINDRICAL BOX ************************/
 
 [...]

I don’t get errors when I compile, but I get error when I run the .exe file

 C:\B1\B1-build\Release>exampleB1.exe ..\run1.mac
 
 **************************************************************
  Geant4 version Name: geant4-10-06    (6-December-2019)
                        Copyright : Geant4 Collaboration
                       References : NIM A 506 (2003), 250-303
                                  : IEEE-TNS 53 (2006), 270-278
                                  : NIM A 835 (2016), 186-225
                              WWW : http://geant4.org/
 **************************************************************
 
 <<< Reference Physics List QBBC
 Visualization Manager instantiating with verbosity "warnings (3)"...
 Visualization Manager initialising...
 Registering graphics systems...
 
 You have successfully registered the following graphics systems.
 Current available graphics systems are:
 ASCIITree (ATree)
 DAWNFILE (DAWNFILE)
 G4HepRep (HepRepXML)
 G4HepRepFile (HepRepFile)
 RayTracer (RayTracer)
 VRML1FILE (VRML1FILE)
 VRML2FILE (VRML2FILE)
 gMocrenFile (gMocrenFile)
 
 Registering model factories...
 
 You have successfully registered the following model factories.
 Registered model factories:
   generic
   drawByAttribute
   drawByCharge
   drawByOriginVolume   drawByParticleID
   drawByEncounteredVolume
 
 Registered filter factories:
   attributeFilter
   chargeFilter
   originVolumeFilter
   particleFilter
   encounteredVolumeFilter
 
 You have successfully registered the following user vis actions.
 Run Duration User Vis Actions: none
 End of Event User Vis Actions: none
 End of Run User Vis Actions: none
 
 Some /vis commands (optionally) take a string to specify colour.
 "/vis/list" to see available colours.
 
 -------- EEEE ------- G4Exception-START -------- EEEE -------
 *** G4Exception : GeomSolids0002
       issued by : G4Tubs::CheckDPhiAngle()
 Invalid dphi.
 Negative or zero delta-Phi (0), for solid: Envelope
 *** Fatal Exception *** core dump ***
  **** Track information is not available at this moment
  **** Step information is not available at this moment
 
 -------- EEEE -------- G4Exception-END --------- EEEE -------
 
 
 *** G4Exception: Aborting execution ***

In attahcment the ful B1DetectorConstruction file

B1DetectorConstruction.cc (8.5 KB)

The complaint is about the solid Envelope and the azimuthal angle:

*** G4Exception : GeomSolids0002
       issued by : G4Tubs::CheckDPhiAngle()
 Invalid dphi.
 Negative or zero delta-Phi (0), for solid: Envelope

According to the documentation the angles passed in the constructor are defined as follows:
pSPhi - Starting phi angle in radians
pDPhi - Angle of the segment in radians

You define them as:
pSPhi = 2*pi, pDPhi = 0.

which means that you try to create a cylinder that starts at 2*pi and has the angle of 0 (non-physical), I imagine you wanted it to be a cylinder = have a full angle (2*pi), so change the values to:

pSPhi = 0, pDPhi = 2*pi

Hi @anna thank you for you reply! I fixed my error by following your advice and it worked! Now I must do the second step ( i.e. to add a second target equal to the first one and far 2cm from the first one). Do you have any simple advices please?

You have at the moment one cylinder placed inside the world volume. G4PVPlacement takes as the second argument the relative position where your volume is placed: G4ThreeVector() means at (x,y,z)= (0,0,0) so in the centre of the world. You need to place a second cylinder volume with a different position argument (shift of 2cm in the direction that you want).

Hi @anna, thank you for your reply. Following your reply I wrote:

/**************************** START DEFINE 2 NEW CYLINDRICAL BOXES ************************/
 G4Box* solidEnv =    
new G4Box("Envelope",                    //its name
    0.5*env_sizeXY, 0.5*env_sizeXY, 0.5*env_sizeZ); //its size*/
 
	G4Tubs* solidEnv =    
new G4Tubs("Envelope",                    //its name
    pRMin, pRMax, pDz, pSPhi, pDPhi);    //its size*/
    
G4Tubs* solidEnv2 =    
new G4Tubs("Envelope2",                    //its name
    pRMin, pRMax, pDz, pSPhi, pDPhi);    //its size*/
    
G4LogicalVolume* logicEnv =                         
new G4LogicalVolume(solidEnv,            //its solid
                    env_mat,             //its material
                    "Envelope");         //its name
                    
G4LogicalVolume* logicEnv2 =                         
new G4LogicalVolume(solidEnv,            //its solid
                    env_mat,             //its material
                    "Envelope2");         //its name
               
  new G4PVPlacement(0,                       //no rotation
                G4ThreeVector(),         //at (0,0,0)
                logicEnv,                //its logical volume
                "Envelope",              //its name
                logicWorld,              //its mother  volume
                false,                   //no boolean operation
                0,                       //copy number
                checkOverlaps);          //overlaps checking
                
 new G4PVPlacement(0,                       //no rotation
                G4ThreeVector(2,0,0),         //at (0,0,0)
                logicEnv2,                //its logical volume
                "Envelope2",              //its name
                logicWorld,              //its mother  volume
                false,                   //no boolean operation
                0,                       //copy number
                checkOverlaps);          //overlaps checking
                
/**************************** END DEFINE 2 NEW CYLINDRICAL BOXES ************************/ 

I didnt’ get errors …but I would like sure that I really simulated 2 targets. I checked other .cc files, but it doesn’t look like to me that I’ve to modify other files. Do you think that I got what I need (2 targets shifted 2 cm )?

In attachment my B1DetectorConstrucion.cc file

B1DetectorConstruction.cc (9.7 KB)

Did you try using visualisation? (See any example on how to do it)

Hi @anna, how can I install and use visualisation (windows user)? Sorry, but I’m a new Geant4 user…

Did you follow those instalation guidelines?
There are several visualisation drivers and to enable them you need to first make sure you have those libraries installed on your windows; then you need to add appropriate cmake flag, e.g. -DGEANT4_USE_QT=ON (needs Qt5 and OpenGL) and recompile Geant4.

Hi @anna, when I installed Geant4, I followed instructions paragraphs On Windows Platform
and Geant4 Build Options

moreover I setted paths following the Postinstall Setup guideline

In the Standard Options I read that the

DGEANT4_USE_QT 

is setted OFF , then what should I do now to set it ON?

You need to pass this to cmake and recompile Geant4.
It means the step:

cmake -DCMAKE_INSTALL_PREFIX="%HOMEPATH%\Geant4\geant4_10_06-install" "%HOMEPATH%\Geant4\geant4_10_06"

needs additional flag:

cmake -DCMAKE_INSTALL_PREFIX="%HOMEPATH%\Geant4\geant4_10_06-install" "%HOMEPATH%\Geant4\geant4_10_06" -DGEANT4_USE_QT=ON

And redo everything from this step.
But make sure you have Qt5 and OpenGL installed as well.

OpenGl and Mingw are?

You can read on Qt5 here.
With OpenGL alone, you can probably use this flag: -DGEANT4_USE_OPENGL_WIN32=ON. Just try to compile G4 and see if you get any warning/error messages.

Hi @anna,
Regarding to OpenGl, I followed tthis guide to install OpenGl (it uses freeglut and codeblocks. Is it ok?

Regarding to Qt5, I downloaded the offline installer. Which component of the list (see pic) should I install?

Hi @anna I used the flag -DGEANT4_USE_OPENGL_WIN32=ON
you can see in attachment the log. it looks like that installation was succesfully, but I read there are missing files…do I need to download them?

Moreover, now, what should I do to use visualisation?

log.txt (3.1 KB)

You need to install G4 data, so you also need to add flag -DGEANT4_INSTALL_DATA=ON to your cmake. But you probably have them already, downloaded in your previous installation. Therefore, you can use -D GEANT4_INSTALL_DATADIR= ... if you know where they are.
Have a look in the installation guide.

For the visualisation, you need to recompile your application using the new G4 installation. Have a look at one of the examples and read more in the application guide.

Hi @anna thank you. I had that files, but they were in C:\Program Files\geant4_10_06-install\share\Geant4-10.6.0 instead of C:\Program Files\geant4_10_06-install\share\Geant4-10.6.0\data

I just moved the file to the C:\Program Files\geant4_10_06-install\share\Geant4-10.6.0\data directory and I modified the evnviroments variables paths. Then I added the flag -DGEANT4_USE_OPENGL_WIN32=ON and it looks like was succesfully now (see the attachment).

log -DGEANT4_USE_OPENGL_WIN32=ON.txt (989 Bytes)

Moreover, I compiled and runned my modified B1 example and it looks like it was succesfully too (See the attachment).

log B1 modified.txt (42.2 KB)

Now I’m going to read the application guide for visualisation.

The first log file is the output of the configuration process. I trust you did build it afterwards? (cmake --build . --config Release --target install)