AIDASoft / DD4hep

Detector Description Toolkit for High Energy Physics
http://dd4hep.cern.ch
GNU Lesser General Public License v3.0
50 stars 99 forks source link

materialScan on CAD-imported geometry : strange results... #1322

Closed danieljeans closed 1 month ago

danieljeans commented 1 month ago

Check duplicate issues.

Goal

list materials along a line in detector model which including CAD imports, using the materialScan utility.

Operating System and Version

ubuntu22

compiler

gcc11.4.0

ROOT Version

6.32.04

DD4hep Version

/cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh -r 2024-09-04

Reproducer

Using the model defined in https://github.com/aciarma/k4geo/tree/commonMDI/FCCee/MDI/compact/MDI_o1_v01/MDI_standalone_o1_v01.xml which includes a beampipe from a CAD geometry. (n.b. You need to download the stl geometry files from https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/MDI/MDI_o1_v01/ )

For simplicity I commented out all detector components except
<include ref="Beampipe_CADimport_o1_v02.xml"/> from the file MDI_standalone_o1_v01.xml

first I scan the geometry using a geantino, using ddsim:

ddsim --compactFile FCCee/MDI/compact/MDI_o1_v01/MDI_standalone_o1_v01.xml --enableG4Gun --runType shell
Idle> /gun/particle geantino
Idle> /tracking/verbose 1   
Idle> /gun/number 1         
Idle> /run/beamOn  

I see something reasonable: a beampipe made of various layers, with inner radius ~10mm:

*********************************************************************************************************
* G4Track Information:   Particle = geantino,   Track ID = 1,   Parent ID = 0
*********************************************************************************************************

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng  NextVolume ProcName
    0        0        0        0     1e+03        0        0         0 world_volume_1 initStep
    1     9.99        0        0     1e+03        0     9.99      9.99 AV_9!Gold_STL_2#2!"Solid1<stl_0#0 Transportation
    2       10        0        0     1e+03        0    0.005        10 AV_7!Beampipe_STL_0#0!"Componente1"_0#0 Transportation
    3     10.4        0        0     1e+03        0     0.45      10.4 AV_10!Paraffin_STL_3#3!"Solid2<stl_0#0 Transportation
    4     11.3        0        0     1e+03        0    0.874      11.3 world_volume_1 Transportation
    5     11.4        0        0     1e+03        0   0.0265      11.4 AV_7!Beampipe_STL_0#0!"Componente1"_0#0 Transportation
    6     11.7        0        0     1e+03        0    0.325      11.7 world_volume_1 Transportation
    7  2.5e+04        0        0     1e+03        0  2.5e+04   2.5e+04  OutOfWorld Transportation

Then I try to run materialScan on the same model, listing material between 0,0,0 and 10,0,0 (cm)

materialScan MDI_standalone_o1_v01.xml 0 0 0 10 0 0

which shows very different material to what is expected: essentially a block of copper. Also the path lengths don't seem to be consistent (don't sum to 10cm)?

+--------------------------------------------------------------------------------------------------------------------------------------------------
 + Material scan between: x_0 = (   0.00,   0.00,   0.00) [cm] and x_1 = (  10.00,   0.00,   0.00) [cm] : 
 +--------------------------------------------------------------------------------------------------------------------------------------------------
 |       \   Material                  Atomic               Radiation   Interaction               Path   Integrated  Integrated    Material
 | Num.   \  Name               Number/Z   Mass/A  Density    Length       Length    Thickness   Length      X0        Lambda      Endpoint/Startpoint
 | Layer   \                             [g/mole]  [g/cm3]     [cm]        [cm]          [cm]      [cm]     [cm]        [cm]     (     cm,     cm,     cm)
 +--------------------------------------------------------------------------------------------------------------------------------------------------
 | (start) AlBeMet162                  7   15.841   2.1000     18.7945      39.5633      0.000     0.00    0.000000    0.000000  (   0.00,   0.00,   0.00)
 |       1 AlBeMet162 -> Copper       29   63.546   8.9600      1.4356      15.6778      3.064     3.06    0.163026    0.077446  (   3.06,   0.00,   0.00)
 |   (end) Copper                     29   63.546   8.9600      1.4356      15.6778      0.000     0.00    0.000000    0.000000  (   0.00,   0.00,   0.00)
 +--------------------------------------------------------------------------------------------------------------------------------------------------
 |         Average Material           23   49.546   6.8581      2.0022      19.2361     10.000    10.00    4.994533    0.519855  (  10.00,   0.00,   0.00)
 +--------------------------------------------------------------------------------------------------------------------------------------------------

As far as I can see, materialScan uses DDRec/MaterialScan, and then further on DDRec/MaterialManager...

Any suggestions? thanks!

Additional context

No response

atolosadelgado commented 1 month ago

Hi @danieljeans

thank you for reporting the error. In addition to materialScan tool, there is another one called g4MaterialScan, it can be used as follows:

g4MaterialScan -c MDI_standalone_o1_v01.xml -p "0,0,0" -d "1,0,0"

...

Gun                               INFO  Particle [0] geantino     Mom:20.000 GeV vertex:( 0.000  0.000  0.000)[mm] direction:( 1.000  0.000  0.000)
MaterialScan                      WARN  Starting tracking action for track ID=1
 +--------------------------------------------------------------------------------------------------------------------------------------------------
 + Material scan between: x_0 = (   0.00,   0.00,   0.00) [cm] and x_1 = (2500.00,   0.00,   0.00) [cm]  TrackID:1: 
 +--------------------------------------------------------------------------------------------------------------------------------------------------
 |     \   Material           Atomic                 Radiation   Interaction               Path   Integrated  Integrated    Material
 | Num. \  Name          Number/Z   Mass/A  Density    Length       Length    Thickness   Length      X0        Lambda      Endpoint  
 | Layer \                        [g/mole]  [g/cm3]     [cm]        [cm]          [cm]      [cm]     [cm]        [cm]     (     cm,     cm,     cm)
 +--------------------------------------------------------------------------------------------------------------------------------------------------
 |     1 Air                    7   14.784   0.0012  30528.8402   71282.7920      0.999     1.00    0.000033    0.000014  (   1.00,   0.00,   0.00)
 |     2 Au                    79  196.967  19.3200      0.3344      10.5404      0.001     1.00    0.001528    0.000061  (   1.00,   0.00,   0.00)
 |     3 AlBeMet162             7   15.841   2.1000     18.7945      39.2502      0.045     1.04    0.003922    0.001208  (   1.04,   0.00,   0.00)
 |     4 LiquidNDecane          5   10.296   0.7300     61.5867      91.4187      0.087     1.13    0.005341    0.002163  (   1.13,   0.00,   0.00)
 |     5 Air                    7   14.784   0.0012  30528.8402   71282.7920      0.003     1.14    0.005341    0.002164  (   1.14,   0.00,   0.00)
 |     6 AlBeMet162             7   15.841   2.1000     18.7945      39.2502      0.033     1.17    0.007070    0.002992  (   1.17,   0.00,   0.00)
 |     7 Air                    7   14.784   0.0012  30528.8402   71282.7920   2498.832  2500.00    0.088922    0.038047  (2500.00,   0.00,   0.00)

Are these numbers more sensible? Maybe @aciarma can comment on this :)

By the way, there is an error reported by Geant4, do you know if this can cause problems to geantinos?

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomSolids1001
      issued by : G4TessellatedSolid::SetSolidClosed()
Defects in solid: "Componente1"_shape_0xdc263d0 - some facets have wrong orientation!
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomSolids1001
      issued by : G4TessellatedSolid::SetSolidClosed()
Defects in solid: "Componente1"_shape_0xe9e3710 - some facets have wrong orientation!
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------
danieljeans commented 1 month ago

Thanks @atolosadelgado

the results from g4MaterialScan look reasonable to me.

It seems like the material description in g4 is fine, but that something is lost in translation when we look via the DDRec/MaterialManager ?

Regarding the "some facets have wrong orientation!" warning, I have no idea where this comes from (maybe a question for @aciarma ?) , or if this can cause any problems.

MarkusFrankATcernch commented 1 month ago

So.....I did some research. The DDRec MaterialManager and hence the corresponding MaterialScan use TGeo tracking through volumes. Tracking in TGeo is not implemented for tessellated shapes as they result from CAD shapes. Though TGeo tracking is used in the material scanner.... In TGeo tessellated surfaces behave like their bounding box. Hence they have no real shape and for this reason you only see a "box". This is my understanding. TGeo tracking will only be implemented once TGeo moves to VecGeom. For this reason the G4 material scan works and the TGeo material scan not.

I guess we can close this issue. Maybe we have to implement some warning if the traversed volume has a tessellated shape.

Victor-Schwan commented 1 month ago

Thanks for pinpointing the cause. Adding a warning is an excellent idea in my opinion, and I suggest keeping the issue open until this is done

atolosadelgado commented 1 month ago

VecGeom tessellated navigation does not work properly (I reported that some time ago) but it looks to me very difficult to fix

andresailer commented 1 month ago

A warning was added that covers this case.