How to get Scoring mesh for two circular targets

Hello I simulated a e+ beam 45GeV hitting 2 circualr targets having diameter 1.5 cm, thickness 3mm and distance between them 2cm.

I’m interested to stud the released energy from e+ in the 2 targets. In this post Target temperature @mkelsey some weeks ago proposed me to add the scoring mesh or to store in the ROOT file the hit points in my 2 targets (called Envelope and Envelope2) so to get Root plots of releases energy vs hit points. Given that I have the steppingaction in my simulation, I did the second one. Anyway, my supervisor asked me to add the scoring mesh, so

  1. In exampleB1.cc I addes
    a. #include “G4ScoringManager.hh”
    b. G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManager();
    as you can see in the following printscreen

  1. Following the \extended\runAndEvent\RE03 example, I wrote in my run1.mac this code

a.

/score/create/cylinderMesh Envelope1
/score/mesh/cylinderSize 0 cm. 0.75 cm 0.15 cm 0. 6.28
/score/mesh/nBin 30 30 30
/score/quantity/energyDeposit eDep
/score/quantity/nOfStep nOfStepGamma
/score/filter/particle gammaFilter gamma
/score/quantity/nOfStep nOfStepEMinus
/score/filter/particle eMinusFilter e-
/score/filter/particle muMinusFilter mu-
/score/quantity/nOfStep nOfStepEPlus
/score/filter/particle ePlusFilter e+
/score/filter/particle muPlusFilter mu+
/score/close
/score/list

Notice that I wrote /score/mesh/cylinderSize 0 cm. 0.75 cm 0.15 cm 0. 6.28 because I have 2 circular targets having diameter 1.5 cm, thickness 3mm and distaince between them 2cm; i.e. I wrote the numbers following the way to define the G4Tubs

Anyway

1.I get this error


2. I have to do the scoring mesh for my two targets, not just one! The first one is centered in 0,0,0 the second one in 0,0,2.3 cm

How can I solve?

@mkelsey due that you proposed me to use the scoring mesh, i guess you are able to help me to do it…

Thank you

The error tells you that you make a mistake in the parameters of /score/mesh/cylinderSize (“parameter out of range R>0”).
Have a more careful look at the RE03 example (in particular at run4.mac which contains a cylindrical mesh) and do not guess the parameters. You can also check it in the GUI of your example, the help tree contains all the commands with guidance.
Also, pay attention to little details like cm., the dot at the end would prompt the next error (if it wasn’t for the 0 in front).

Thank you @anna I read the run4.mac of the RE03 example, so given that my tartgets have diameter 1.5cm and thickness 0.3 cm, I guess I must write

/score/mesh/cylinderSize 0.75 0.15 cm

Moreover, given that my second target is placed in 0., 0., 2.3cm I guess that I must write (for the second target) /score/mesh/translate/xyz 0. 0. 2.3 cm

So I wrote in my run1.mac macro file

  1. for the first target

/score/create/cylinderMesh boxMesh_1
/score/mesh/cylinderSize 0.75 0.15 cm
/score/mesh/nBin 30 30 30
/score/quantity/energyDeposit eDep
/score/quantity/nOfStep nOfStepGamma
/score/filter/particle gammaFilter gamma
/score/quantity/nOfStep nOfStepEMinus
/score/filter/particle eMinusFilter e-
/score/filter/particle muMinusFilter mu-
/score/quantity/nOfStep nOfStepEPlus
/score/filter/particle ePlusFilter e+
/score/filter/particle muPlusFilter mu+
/score/close
/score/list

  1. For the second target
/score/create/cylinderMesh boxMesh_2
/score/mesh/cylinderSize 0.75 0.15 cm
/score/mesh/translate/xyz 0. 0. 2.3 cm
/score/mesh/nBin 30 30 30
/score/quantity/energyDeposit eDep
/score/quantity/nOfStep nOfStepGamma
/score/filter/particle gammaFilter gamma
/score/quantity/nOfStep nOfStepEMinus
/score/filter/particle eMinusFilter e-
/score/filter/particle muMinusFilter mu-
/score/quantity/nOfStep nOfStepEPlus
/score/filter/particle ePlusFilter e+
/score/filter/particle muPlusFilter mu+
/score/close
/score/list

/score/colorMap/setMinMax ! 0. 200.
/control/alias iAxis 1
/control/loop drawCylinderSlice.mac iColumn 0 29 7

Lastly I copied in my B1 home directory (the same directory in wich I’ve the run1.mac file) the drawCylinderSlice.mac from the RE03 example.

I could compile without errors, but when I run

  1. I get these warnings

    so, can’t I get the scoring mesh for energy released by both e+/- (primaries and secondaries) and mu+/- ?
  2. It says it’s impossibile to open the drawCylinderSlice.mac file
  3. I don’t get any plots about the released energy in my two targets (that is what my supervisor wants )…

please @anna or @mkelsey , can you check what I’m getting wrong? Moreover, I would like to know if it’s possible to save the plots of scoring mesh in my Root file (when I will be able to get them)

Thank you

For (1), it looks like you’re defining the same filters twice, in the blocks for the two separate meshes. Check the documentation to see if that’s necessary.

For (2), are you sure you’re running in the correct directory? At your terminal prompt, what does

ls drawCylinderSlice.mac

report back? Do you have a /control/macroPath command in your macros?

Thank you @mkelsey

I wrote

##Target 1###
/score/create/cylinderMesh boxMesh_1
/score/mesh/cylinderSize 0.75 0.15 cm
#/score/mesh/translate/xyz 0.1 0.1 0.0 cm
/score/mesh/nBin 30 30 30
/score/quantity/energyDeposit eDep
/score/quantity/nOfStep nOfStepGamma
/score/filter/particle gammaFilter gamma
/score/quantity/nOfStep nOfStepEMinus
/score/filter/particle eMinusFilter e-
/score/filter/particle muMinusFilter mu-
/score/quantity/nOfStep nOfStepEPlus
/score/filter/particle ePlusFilter e+
/score/filter/particle muPlusFilter mu+
/score/close
/score/list

##Target 2###
/score/create/cylinderMesh boxMesh_2
/score/mesh/cylinderSize 0.75 0.15 cm
/score/mesh/translate/xyz 0. 0. 2.3 cm
/score/mesh/nBin 30 30 30
/score/quantity/energyDeposit eDep
/score/quantity/nOfStep nOfStepGamma
/score/filter/particle gammaFilter gamma
/score/quantity/nOfStep nOfStepEMinus
#/score/filter/particle eMinusFilter e-
#/score/filter/particle muMinusFilter mu-
/score/quantity/nOfStep nOfStepEPlus
#/score/filter/particle ePlusFilter e+
#/score/filter/particle muPlusFilter mu+
/score/close
/score/list

(i.e now I’ve just one of each filter)
but I still get the warning

If I understand right, it says that eMinusFilter is overwitten by muMinusFilter and ePlusFilter by muPlusFilters, but I setted e+/- and mu+/- filters because I want both energies released by e+/- and mu+/-.

Yes, I’m running in the correct directory!
This is my B1 directory in wich I’ve both run1.mac and drawCylinderSlice.mac and this is the run command

(I always runned in that way)

This is the result of ls drawCylinderSlice.mac

in italian it means that ls isn’t an internal or external command, a program or batch file

Given that my macro is in C:/B1, I added the line

/control/macroPath /B1

as you can see here

image

but I get this error

and, obviously, I don’t get the plot

Yes, I see. Screen shots are very hard to read; sorry.

The ls command is how you get a directory listing in Linux. If you’re on Windows, use whatever comman is appropriate. Is the file you’re expecting to see in your current working directory when you are running?

You should need a /control/macroPath to find file in your current working directorly.

What documentation are you reading to try to solve these problems for yourself? Can you provide links to the documentation you have used? That would help the Geant4 developers to improve the documentation.

Thank you @mkelsey

Sorry, you are right. This is the command

Yes, it is in c:/B1 directory!

As I wrote in my previous post, I added the line

/control/macroPath /B1

but it gives this error

Did I write wrong the command?

In this topic Target temperature you suggested me to read this documentation http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/commandScore.html,
moreover, my supervisor suggested me this one https://indico.cern.ch/event/782305/contributions/3256028/attachments/1793321/2922301/2c_Scoring.pdf
@anna suggested me to look the run4.mac of RE03 example and I’m also trying to search on google scoring mesh geant4 , but I just find the basic command of the RE03 example…

@mkelsey and/or @anna do you have sone news about my problem please?

Once again, I suggest to have a look at the error that is printed, it is vital to understanding what is wrong. What you point with an arrow says “Illegal parameter”, not a wrong command. It’s what you pass to it that poses a problem. Did you try to pass the path in a different way? E.g. a relative path? I have no clue how it should work on windows, maybe c:/B1/ would, that’s what was the output of your previous search.

Thank you @anna

Obviously I read the printed error, but I still can’t find the correct solution…sorry!

Yes, it looks like running by writing

/control/macroPath C:/B1

but

  1. I still get the warning that we were talking about with @mkelsey (ie the e+/- mu+/- replacing)


2. Even if I added the lines
/vis/disable
/run/beamOn 1000
/vis/enable

I don’t get the plot (it says I don’t have a visualization system


but I have visualization, because if I run by using the vis.mac I get the image

Hi @anna I also tried to add the line

/vis/sceneHandler/create
or
/vis/open

as you can read in my the printscreen of my previous message, but if I add this line I get this error

so I don’t know how to get the plot…

@anna any idea please?

Unfortunately, I do not know much about the visualisation on Windows, I suggest you open a thread in the visualisation category.

@anna thank you I’m going to open a thread in that category!
Anyway, I get the same error even if I try to run on the laboratory machine (it isn’t a windows machine)! Following your help I use Geant in this way using cvmfs.

  1. source /cvmfs/sft.cern.ch/lcg/contrib/gcc/8.3.0/x86_64-centos7-gcc8-opt/setup.sh
  2. source /cvmfs/geant4.cern.ch/geant4/10.6.p02/x86_64-centos7-gcc8-optdeb-MT/bin/geant4.sh
  3. /cvmfs/sft.cern.ch/lcg/contrib/CMake/3.14.2/Linux-x86_64/bin/cmake …/
  4. make
  5. ./exampleB1 …/run1.mac

but I get the same error

maybe are you able to fix it using the cvmfs?

It’s not clear what you have inside your macro. Do you execute vis.mac from run1.mac? vis.mac contains all the necessary UI commands to run the visualization.

thank you @anna
In my run1.mac I’ve these lines

/vis/disable
/run/beamOn 1000
/vis/enable

Do I’ve to execute vis.mac from run1.mac? How can I do it?

It’s executed from init_vis.mac if you want to know how to execute it. But you do not need it, however you need parts of it that initialize visualization. Have a look inside, it is heavily documented.

thank you @anna , looking inside of init_vis.mac I wrote in my run1.mac the line

/control/execute vis.mac

as you can see here

but I still get the error

Hi @anna my supervisor just said me that I can do the scoring mesh saving the results into a ASCII files instead of the visualization method…is there an example to do the scoring mesh saving results into a ASCII file?

I looked again at this very long thread. We all try to help you, but, as Anna said, you have to look at the output and fix things. For example, the scoring manager is telling you there is no vis system. This is probably because you /vis/disable (why did you do that?).

(a) You have to write the numbers as required by the command. Look at the command guidance
help /score/mesh/cylinderSize
It may or may not be the same as the way to define G4Tubs.

(b) There is an obvious mistake in your line. There should not be a dot after cm.

The scoring manager allows you to dump the results of scoring to a file. There are several commands. Use help /score or ls /score.