Scoring mesh ....visualization problem

Hello I need the scoring mesh for a simulation about a 45GeV positron beam hitting two circular targets.
@anna was helping me to write the code as you can read in this topic https://geant4-forum.web.cern.ch/t/how-to-get-scoring-mesh-for-two-circular-targets/
but I’ve visualization problem.
Firstly, this is my macro

run1.txt (2.1 KB)

notice that you will read 2 macropaths

/control/macroPath C:/B1
#/control/macroPath /home/xxxxxxx/B1

because I use the first one to run on my computer (windows machine) and the second one to run on laboratory machine (by ssh connection)

Unfortunately, both if I run on my computer and on laboratory one I get visualization problem

This the error that I get by using my computer

this is the error that I get by using the laboratory machine (ssh connection)

Notice that on laboratory machine, I use geant and cmake on cvmf i.e. I run in this way

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

Have you instantiated a vis system at all? You need to instantiate G4VisExective - see, for example, example/basic/B1/exampleB1.cc.

Or is it that you intend not to have visualisation but you have some drawing code in your app. As it says (in effect) in the WARNING, you must either (a) instantiate a vis manager or (b) protect your code (see examples/basic/B5/src/*Hit.cc:

auto visManager = G4VVisManager::GetConcreteInstance();
if (! visManager) return;

But why would you need any drawing code at all?

Hello @allison thank you

I modified the B1 example…then I’ve

G4VisManager* visManager = new G4VisExecutive;

visManager->Initialize();

in my personal exampleB1.cc as you can see in the file

exampleB1.cc (4.1 KB)

Yes, I’ve the code for the visualization in my exampleB1.cc (because as I said I modified the B1 example), moreover, in this file I added the lines

a. #include “G4ScoringManager.hh”
b. G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManager();

to get the scoring mesh (you can read the exampleB1.cc)

Lastly I wrote the code in my run1.mac as you can see here

run1.txt (2.1 KB)

my surpervisor asked me to do the scoring mesh…but I’m having this problem…are you able to help me please?

Mmm. OK. I don’t see why it shouldn’t work for you. I’ll try to repeat your problem this weekend.

You ask the scoring manager to draw (your drawCylinderSlice.mac). The scoring manager’s drawing code should be protected by

auto visManager = G4VVisManager::GetConcreteInstance();
if (visManager) { // Do drawing

I will check. But to allow your app to do some drawing, open a graphics viewer. What graphics viewers have you built? If you have built with OpenGL, in interactive mode you can

/vis/open OGL
/control/execute run1.mac

or in batch mode you could add

/vis/open DAWNFILE

to your run1.txt. This would produce a file that can be viewed offline. VRMLFILE should be available too.

Let me know if you make any progress.

John

Thank you @allison,

Thank you @allison I hope tou can help me to solve it.

Where should I write it?

Yes, my supervisor just told me that if I’ve problems I can save the scoring mesh results in a ASCII files so I added the line

/vis/open DAWNFILE

in my run1.mac but I still get that error…

/vis/open DAWNFILE
Where did you put it? Send me the new run1.mac.

Thank you @allison

this is my full simulation https://we.tl/t-osh7SLp18q , so you can try to compile and run it (I think it can help you to debug it).

I’m sorry. I meant I would try to help you solve the visualisation problem. But there is no visualisation problem - only in your use of it. And I don’t think there is any problem with the scorer - only in your use of it. Please continue to read the documentation, consult command guidance and take action on warning and error messages.

Thank you @allison then did you run my simulation getting the scoring mesh visualization??

Anyway, as I said you in my previous message, my supervisor said me that I can do the scoring mesh saving the results on a ASCII file instead of using the visualization way.

Please can you help me to do this??? I need to to do it to be admitted to next Phd year in october…but I’m having problems to do it…

Hello @allison and @anna , today I tried to use

/vis/open DAWNFILE

it looks like working, but I simulated 100 events and I get 100 files like this one

g4_0000.txt (1.4 KB)

but how can I merge all results?

Dear Fausto

I have downloaded your app and tried to run it. I have found many problems. Let us take them one at a time.

First, let us be clear. There are two modes of operations - interactive and batch. This is defined by the code in your main routine (which you can change if you want, but this is how it is at present). If you supply a macro file as argument, it executes it. We call this a batch job or batch mode. For such a job you have no interaction and no visual graphics (although, as you have discovered, you can “draw” to file-writing graphics systems such as DAWNFILE).

So let me start by editing your run1.mac so that it runs in batch. For now, let us forget DAWNFILE. For now, let us forget drawing altogether. You want it to run lots of events and score something and just dump the meshes to file. I attach an edited version of run1.mac (I changed it to run1.txt so that it would upload). run1.txt (2.0 KB) Here are the dumps generated with 100,000 events to two files. boxMesh_1.txt (1.8 MB) boxMesh_2.txt (2.2 MB) It took about 10 minutes on my Mac.

Next, I will look at the problem of visualising the meshes. This will need a little thought because of the need to initialise the vis and the scorers separately. I will post another message later.

John

OK. Visualisation. There might be a simpler way, but here is my solution.

I created init_run.mac. init_run.txt (160 Bytes) (You will have to change the name back to init_run.mac.)

I modified exampleB1.cc (4.1 KB) to add a line to read init_run.mac:

// batch mode
UImanager->ApplyCommand("/control/execute init_run.mac");
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);

I also changed CMakeLists.txt to add init_run.mac and drawCylinderSlice.mac to the list of files that are copied to your build directory. This means one can run in the build directory, and you no longer have to use /control/macroPath. CMakeLists.txt (2.4 KB)

I modified init_vis.mac to read into_run.mac. init_vis.txt (330 Bytes)

Finally I cleaned up run1.mac run1.txt (1.7 KB) so that you can use it

  • in batch mode: ./exampleB1 run1.mac
  • in interactive mode:
    /control/execute run1.mac
    /score/colorMap/setMinMax ! 0. 200.
    /control/alias iAxis 1
    /control/loop drawCylinderSlice.mac iColumn 0 29 7

Those last 4 commands I added to the bottom of vis.mac so you could see them. vis.txt (4.0 KB)

Your scoring meshes seemed not to been the right place, but I leave that for you to fix.

Hope this helps.

John

I forgot to upload a couple of screen shots from your app:
After /control/execute run1.mac:


After /control/loop ...:

Hello @allison and first of all thank you for your very big help! I’ve some question please

  1. Batch mode

a. I first tried to use the batch mode. I think it worked because I got the two dump files but during the run I read this error

and I don’t know if it’s important or not


It looks like to be regagardin of a box 3…but I’ve just 2 targets…

This is the full log (if it can be usefull for you)
log dump file.txt (76.2 KB)

b. Which software should I use to plot data saved on the files?

  1. Visualization mode

a. I followed all you wrote to create and to modify the files then I compiled and runned the app on my computer
When I lunched the command (I use Windows on my computer)
exampleB1.exe
I got this image


the I lunched the commands for interactive mode, but I got these errors and I don’t see the events on the image

Given that I read that it can’t find drawCylinderSlice.mac I also added

the line

/control/macroPath C:/B1/B1-build/Release

image
because exampleB1.exe is in C:/B1/B1-build/Release then I copied all the macro files in this directory before to run exampleB1.exe

but I still get the errors


and I don’t see the pics in my image…

b. Later I tried to use the app in visualization mode on the laboratory machine by ssh connection to check if I can run it on laboratory machine

I used the source
source /cvmfs/sft.cern.ch/lcg/contrib/gcc/8.3.0/x86_64-centos7-gcc8-opt/setup.sh
source /cvmfs/geant4.cern.ch/geant4/10.6.p02/x86_64-centos7-gcc8-optdeb-MT/bin/geant4.sh
source /cvmfs/geant4.cern.ch/geant4/10.6.p02/x86_64-centos7-gcc8-optdeb-MT/CMake-setup.sh
/cvmfs/sft.cern.ch/lcg/contrib/CMake/3.14.2/Linux-x86_64/bin/cmake …/

then I compiled and runned by the command

./exampleB1

but I got this error

maybe do I need other sourcers from cvmfs?

c. What do you mean here?

It will not affect the results significantly.

No particular software. Figure out what the numbers are and put them in a spreadsheet?

Have you used all the files I sent you? Did you put the new CMakeLists.txt in the source directory and rebuild? drawCylinderSlice.mac should then be in the build directory C:/B1/B1-build/Release. You don’t need /control/macroPath.

Well, I mean the scoring meshes seem not to be in the same place as the cylinders.

Thank you @allison
I checked and I found a mistake in run1.mac! Moreover I saw that I forgot to copy drawCyilinderSlice.mac in Relaease directory! So now I get

  1. This plot after /control/execute run1.mac

and this one after
/control/loop drawCylinderSlice.mac iColumn 0 29 7

They looks like similiar to your print screen but in windows they are not so beautiful as on mac!

Anyway, I notice that in the second image there is a color scale but the targets don’t have the colors …I mean that I don’t get something like this to understand the hit points

maybe is it due to this problem?

Should I move the position of scoring mesh?

It’s strange because for the target one I have

#/score/mesh/translate/xyz 0.1 0.1 0.0 cm
so, the traslation is commented the I guess the score is in 0. 0. 0. cm that is the position of my first target x=0, y=0, z=0

and for the target 2 I have

/score/mesh/translate/xyz 0. 0. 2.3 cm
that is the position of my second target x=0, y=0, z=2.3cm

Maybe is it the problrm in drawCylinderSlice.mac?
In this file the is just the line because I copied the file from an example

/score/drawColumn boxMesh_1 nOfStepGamma {iAxis} {iColumn}

but I’ve two targets…so shoud I add the line

/score/drawColumn boxMesh_2 nOfStepGamma {iAxis} {iColumn}

?