Sensitive volume not working for saving specific events

System : Linux
REST version : v2.3.12

I am trying to do a very simple simulation of cosmics on a single scintillator plate. The geometry has only one physical volume, the plate itself. I would like to store only those events that leave any energy in the scintillator, and for that, I have defined the storage section as follows:

[...]
        <parameter name="saveAllEvents" value="false"/>
[...]
        <storage sensitiveVolume="scintillator">
            <parameter name="energyRange" value="(0,10)" units="GeV"/>
            <activeVolume name="scintillator" chance="1" maxStepSize="100" units="um"/>
        </storage>
[...]

But in the end, the simulation stores all the events, even though they did not cross the scintillator. For example:
Screenshot 2022-06-01 144749

When I inspected this same event, I found out that the simulation is somehow considering the world as the sensitive volume, because all the energy of the event is considered as deposited in the sensitive volume, when clearly, it is not.

*******************************************************
 EVENT ID : 4
 TIME : Wed, 01 Jun 2022 12:11:25 +0000 (GMT) +        0 nsec
 SUB-EVENT ID : 0
 Status : OK
*******************************************************
Total energy : 2477 keV
Sensitive volume energy : 2477 keV
Source origin : (28.88,5,-21.23) mm
Source 0 Particle name : mu-
Source 0 direction : (-0.5569,-0.6803,-0.4766)
Source 0 energy : 5.479e+05 keV
Number of active volumes : 1
Active volume 0: has been stored.
Total energy deposit in volume 0: : 2477 keV
------------------------------------------------------------
Total number of tracks : 146
+++++++++++++++++++++++++++++++++++

It also happens when the muon goes through the scintillator, as in this example,
image

But when inspecting it, there is only one volume, which is not the scintillator, because it contains the total energy of the event, when in reality, only a small part of the event occurs inside the scintillator volume:

*******************************************************
 EVENT ID : 0
 TIME : Wed, 01 Jun 2022 12:11:25 +0000 (GMT) +        0 nsec
 SUB-EVENT ID : 0
 Status : OK
*******************************************************
Total energy : 3644 keV
Sensitive volume energy : 3644 keV
Source origin : (6.299,5,25.45) mm
Source 0 Particle name : mu-
Source 0 direction : (-0.7195,-0.6945,-0.004744)
Source 0 energy : 3.128e+06 keV
Number of active volumes : 1
Active volume 0: has been stored.
Total energy deposit in volume 0: : 3644 keV
-----------------------------------------------
Total number of tracks : 225
+++++++++++++++++++++++++++++++++++++++++++

So, any idea of why is this happening? Must the sensitive volume be a gas?

Can you please share your geometry files? Maybe there is a silly mistake such as naming the world “scintillator” or something similar. This behaviour is very strange otherwise, as the restG4 examples are very similar to your use case and they work fine.

Here it is, it is very simple but maybe I overlooked something!

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<!DOCTYPE gdml [
    <!ENTITY materials SYSTEM "../../../miscellaneous/materials.xml">
]>

<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
<!-- ******DEFINE****** -->
    <!-- GLOBAL -->
    <define>
        <!-- variables used for looping -->
        <constant name="PI" value="3.14159265358979323846264" />
        <constant name="degToRad" value="PI/180." />
        <!-- Target gas -->
        <!-- We must define these variables that are hardcoded in materials.xml. They have no use in this example since we do not use a gas mixture in our simulation -->
        <variable name="target_pressure" value="1"/> <!-- bar -->
        <variable name="target_temperature" value="300.0"/> <!-- K -->
        <variable name="target_quencher" value="0"/> <!-- % -->

        <!-- World -->
        <constant name="world_size" value="2000" unit="mm" /> 
        <constant name="world_tall" value="100" unit="mm" /> 
    </define>
    <!-- SCINTILLATOR -->
    <define>
        <variable name="scintLong" value="600" unit="mm" />
        <variable name="scintWide" value="200" unit="mm" />
        <variable name="scintThick" value="10" unit="mm" />
        <position name="scintPosition" unit="mm" x="0" y="0" z="0" />
    </define>

<!-- ******MATERIALS****** -->
    &materials;

<!-- ******SOLIDS****** -->
    <!-- WORLD -->
    <solids>
        <box name="WorldSolid" x="world_size" y="world_tall" z="world_size" lunit="mm" />
    </solids>
    <!-- SCINTILLATOR -->
    <solids>
        <box name="scintSolid" x="scintWide" y="scintThick" z="scintLong" lunit="mm" />
    </solids>

<!-- ******STRUCTURE****** -->
    <!-- SCINTILLATOR -->
    <structure>
        <volume name="scintVolume">
            <materialref ref="BC408" />
            <solidref ref="scintSolid" />
        </volume>

   <!-- WORLD (physical volumes) -->
        <volume name="World">
            <!-- WORLD -->
            <materialref ref="Vacuum" />
            <solidref ref="WorldSolid" />
            <!-- CHAMBER -->
            <physvol name="scintillator">
                <volumeref ref="scintVolume" />
                <positionref ref="scintPosition" />
            </physvol>
        </volume>
    </structure>

<!-- ******SETUP****** -->
    <setup name="Default" version="1.0">
        <world ref="World" />
    </setup>

</gdml><?xml version="1.0" encoding="UTF-8" standalone="no" ?>

Geometry looks good to me, I will take a look. Can you try to run any of the examples (for example, 04.Muons) and see if this also happens? Perhaps you could modify this example little by little until you see this issue appear.

I tested the example you sugested, Luis, and it seems to work. When I inspect the events, I can see that not all the energy of the event was deposited in the sensitive volume, as expected.

*******************************************************
 EVENT ID : 0
 TIME : Tue, 07 Jun 2022 09:47:41 +0000 (GMT) +        0 nsec
 SUB-EVENT ID : 0
 Status : OK
*******************************************************
Total energy : 14.78 keV
Sensitive volume energy : 8.394 keV
Source origin : (0,0,-500) mm
Source 0 Particle name : mu-
Source 0 direction : (0,0,1)
Source 0 energy : 1e+08 keV
Number of active volumes : 2
Active volume 0: has been stored.
Total energy deposit in volume 0: : 8.394 keV
Active volume 1: has been stored.
Total energy deposit in volume 1: : 6.383 keV
---------------------------------------------------------------------------
Total number of tracks : 3
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

I will follow your suggestion and try to modify the example directly, and see if I find what is wrong. Thanks!!

1 Like

I think the problem is not with the simulation, but with the visualization tool… :upside_down_face: Looking at the positions of the hits, it seems that the simulation is working correctly (good news). But the restGeant4_ViewEvent visualization tool I think is not. It is showing the event and the geometry in different scales, or something like that, and so, it looks like the event is out of the volume when, in reality, it is not.

Well, I lost a lot of time on this, but at least nothing important is broken :sweat_smile:

There is a parameter that we had to use to fix an issue with the geometry scale in the visualization. Not sure why sometimes this parameter (GEOM_SCALE) needs to be 0.1 and sometimes needs to be 1.0.

It is defined at TRestEveEventViewer

#define GEOM_SCALE 1

That affects where the hits are placed on the scene

 fEnergyDeposits->SetNextPoint(x * GEOM_SCALE, y * GEOM_SCALE, z * GEOM_SCALE);
1 Like