The primary origin of the generated particles are not located at the expected position

REST version : v2.3.15

Hi everyone,

to explain my problem I will take the example found here in box.gdml and basicSim.rml.

I want to generate cosmic particles above the “box” geometry.
Then in basicSim.rml, in the TRestGeant4Metadata section, I write:

<generator type="cosmic">
  <source particle="geantino">
    <energy type="formula2" name="CosmicMuons" nPoints="2000"/>
    <angular type="formula2" direction="(0,-1,0)" nPoints="500"/>
  </source>
</generator>

But, [in a restRoot -m 1 session] when I visualize the events with REST_Geant4_ViewEvent, I have:

As you can see, the “cosmic” are generated inside the volume, which shouldn’t be the case.

I did another test, this time sending the primary particles from a surface:

<generator type="surface" shape="circle"
           position="(50,50,50)mm" size="(0,0,0)mm"
           rotationAngle="90deg" rotationAxis="(1,0,0)">
  <source particle="geantino">
    <angular type="formula" name="Cos2" direction="(0,-1,0)"/>
    <energy type="formula" name="CosmicNeutrons"/>
  </source>
</generator>

where you can pay attention to the coordinates of the primary events position="(50,50,50)mm.

And here the visualization:

As you can see, the coordinates of the primary events do not correspond to what is displayed on the (x,y,z) axes.
So maybe the problem with the cosmic generator is related to that.

Does someone already had the same issue?

Thanks,
Cloe

Hi @girardcarillo,

probably for the second case the problem is that the size of the generator is zero. You may need to define one dimension, the radius of the circle, then my first guess is that you need to define size="(100,0,0)mm" for a 10cm circle generator.

For the first case I am sure @lobis has some insights.

You may have a look to the following examples:

See also examples/descritption at TRestGeant4Metadata documentation:

https://sultan.unizar.es/rest/classTRestGeant4Metadata.html

Hi @jgalan,

Thank you for your quick answer.
All the examples I’m testing come from TRestGeant4Metadata documentation as well as the restG4 examples section.

Concerning the second problem with the particles launched from a circle:
A priori the size=(0,0,0)mm just defines a ponctual primary origin. I tried with size="(100,0,0)mm and the same problem appears.

In the meanwhile, I realized that the axes displayed on the visualization may be in cm.
So, if I setup position="(0,100,0)cm", I obtain this:

But that would mean that my box would measure 100cm, which is not the case, as in box.gdml we set 100mm. It’s like there is a matching problem between what I set in the .gdml and the .rml files.

Concerning the first case with the cosmic, if @lobis you have some advises, I would highly appreciate :slight_smile:

Ok, not sure what the problem is now, but from what I see, the generator is doing as expected. You would need to get some statistics and plot the primary origin X-Y distribution to see that it is in a circle of radius 10cm.

Perhaps it is an issue related with the visualisation of the geometry and the hits.

I advice you to have a look to PrintEvent() to see if things make sense there.

1 Like

Perhaps it is an issue related with the visualisation of the geometry and the hits.

I think this issue is exactly the same problem that I have!
So I tried to replace #define GEOM_SCALE 0.1 by #define GEOM_SCALE 1.0 in source/framework/core/inc/TRestEveEventViewer.h, and recompiled the Rest framework.

This solved the issue.
So it’s just a problem with the visualization then.

Should we raise an issue on Github?

Thank you for your help, I would not have found alone.

1 Like

Yes, I think it is worth an issue

1 Like

This has happened to others in the past. I am not sure why this is the case but I don’t think the problem is in REST itself but perhaps the root version and gdml file. I think it had something to do with default units, when omitted it would choose different units depending on the root version or something similar. Probably if you explicitly set the units in the gdml file the problem goes away, but I am not 100% sure.

2 Likes

I am already explicitly setting all the units in my gdml file. I took care of that after having noticed this problem of scale.

So at the end changing GEOM_SCALE worked.
I see in the commits that in September 2021 @jgalan set GEOM_SCALE to 1 for all Root versions, but in September 2022, @lobis set it back to 0.1.
So I am wondering if I’m not making a mistake by setting it to 1, will I mess with something?

Yes, setting it back to 1.0 will probably mess something up, we never really understood this, and we couldn’t think of any way to automatically validate this, so the pipeline will pass even if the visualization is broken.

Can you confirm the version of root and geant4 you are using please?

Ah… So I’m doomed to have cosmic displayed in the middle of my detector hahaha

Root version: 6.26/10
Geant4 version: 11.0.3

You could always use a modified REST installation where you change this parameter, or we could make this value not hard-coded and instead be obtained from an environment variable. However I think this should not be necessary and could be avoided if we understood the issue.

1 Like

Perhaps the right value is GEOM_SCALE=1? And when you think is messing things up is because units were not defined at the GDML?

It makes sense that we do not have to introduce any scale (GEOM_SCALE=1) if after all both geometry and hits have units.

@girardcarillo could you try to visualize the results of some restG4 examples (should be available in your REST installation)? You could try for instance example 04.MuonScan/CosmicMuons.rml and 13.IAXO/Neutrons.rml.

In my installation I can view the events without issue with a GEOM_SCALE=0.1.

I tested 04.MuonScan/CosmicMuons.rml last week and I had the same visualization problem