Skip to content

Fix computation of the radiation length and nuclear interaction lengt…#11060

Merged
agheata merged 2 commits intoroot-project:masterfrom
MarkusFrankATcernch:fix_radlen_g4units
Jul 29, 2022
Merged

Fix computation of the radiation length and nuclear interaction lengt…#11060
agheata merged 2 commits intoroot-project:masterfrom
MarkusFrankATcernch:fix_radlen_g4units

Conversation

@MarkusFrankATcernch
Copy link
Copy Markdown
Contributor

…h when ROOT uses G4 units

This Pull request:

The PR fixes the computation of the radiation length and nuclear interaction length
which are computed wrongly when ROOT uses in G4 units.

Changes or fixes:

All in TGeoMaterial.cpp
The fix is based on an initial pull request from Ivana:
#9401
which did miss the necessary changes for mixtures.

Output from constructing Iron from:

99.5 %   Element: FE      Z=26   N=56.000000   A=55.845000 [g/mole]
 0.5 %   Element: C      Z=6   N=12.000000   A=12.010700 [g/mole]
  • ROOT units:
    $> root.exe material_test.C\(\"ROOT\"\)
Material Iron    A=55.845 Z=26 rho=7.874 radlen=1.75666 intlen=0.0271712 index=0
TGeoMaterial   Iron
		 Density:  		7.874 [g/cm^3]
		 Radiation   Length: 	1.75666 [cm] 
		 Interaction Length: 	16.9589 [cm] 
  • Geant4 units:
    $> root.exe material_test.C\(\"G4\"\)
Material Iron    A=55.845 Z=26 rho=7.874 radlen=17.5666 intlen=0.271712 index=3
TGeoMaterial   Iron
		 Density:  		7.874 [g/cm^3]
		 Radiation   Length: 	17.5666 [mm] 
		 Interaction Length: 	169.589 [mm] 

PDG (https://pdg.lbl.gov/2020/AtomicNuclearProperties/HTML/iron_Fe.html):

Specific gravity 	        7.874 	g cm-3
Nuclear interaction length 	132.1 	g cm-2 	16.77 	cm
Radiation length 	        13.84 	g cm-2 	1.757 	cm

Checklist:

  • [X ] tested changes locally
  • updated the docs (if necessary)

This PR fixes #

@phsft-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@MarkusFrankATcernch
Copy link
Copy Markdown
Contributor Author

MarkusFrankATcernch commented Jul 27, 2022

Small AClick test to verify that radiation length and nuclear interaction length are computed correctly when ROOT uses in G4 units. To invoke:

    $> root.exe material_test.C\(\"ROOT\"\)
or
    $> root.exe material_test.C\(\"G4\"\)

material_test.C.txt

Copy link
Copy Markdown
Member

@agheata agheata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarkusFrankATcernch it looks like this fixes several inconsistencies from the previous implementation. I trust that you have thoroughly checked the ROOT/G4 cases. However, we should prevent future bugs in material calculations and backward incompatibilities. Can you please provide a test macro validating the properties for some materials/mixtures when changing units?

@MarkusFrankATcernch
Copy link
Copy Markdown
Contributor Author

Would something like this be sufficient ?
It checks three materials against the PDG values from https://pdg.lbl.gov/2020/AtomicNuclearProperties

$> root.exe test_material_units.C\(\"G4\"\)
$> root.exe test_material_units.C\(\"ROOT\"\)

test_material_units.C.txt

Whenever it would say "TEST FAILED" an error condition occurred.
On Success:

Processing ../test_material_units.C("G4")...
Info in <TGeoManager>: Changing system of units to Geant4 units (mm, ns, MeV).
 Using Geant4 system of units. 
Element: SI      Z=14   N=28.000000   A=28.085500 [g/mole]
Material Si    A=28.0855 Z=14 rho=2.329 radlen=93.5361 intlen=457.729 index=0
TEST SUCCEEDED Si       TGeoMaterial Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.17   %  IntLen:  1.6  % 
TEST SUCCEEDED Mix_1_Si TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.17   %  IntLen:  1.6  % 
TEST SUCCEEDED Mix_1_Si TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.0015 %  IntLen:  1.6  % 
TEST SUCCEEDED Mix_2_Si TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.17   %  IntLen:  1.6  % 
TEST SUCCEEDED Mix_3_Si TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.17   %  IntLen:  1.6  % 
Element: FE      Z=26   N=56.000000   A=55.845000 [g/mole]
Material Fe    A=55.845 Z=26 rho=7.874 radlen=17.5666 intlen=169.589 index=4
TEST SUCCEEDED Fe       TGeoMaterial Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.019  %  IntLen:  1.1  % 
TEST SUCCEEDED Mix_1_Fe TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.019  %  IntLen:  1.1  % 
TEST SUCCEEDED Mix_1_Fe TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.028  %  IntLen:  1.1  % 
TEST SUCCEEDED Mix_2_Fe TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.019  %  IntLen:  1.1  % 
TEST SUCCEEDED Mix_3_Fe TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.019  %  IntLen:  1.1  % 
Element: U      Z=92   N=238.000000   A=238.028900 [g/mole]
Material U    A=238.029 Z=92 rho=18.95 radlen=3.16948 intlen=114.473 index=8
TEST SUCCEEDED U        TGeoMaterial Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.11   %  IntLen:  3.8  % 
TEST SUCCEEDED Mix_1_U  TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.11   %  IntLen:  3.8  % 
TEST SUCCEEDED Mix_1_U  TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.0093 %  IntLen:  3.8  % 
TEST SUCCEEDED Mix_2_U  TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.11   %  IntLen:  3.8  % 
TEST SUCCEEDED Mix_3_U  TGeoMixture  Units: Geant4 Deviation to PDG density: 0  %  RadLen:  0.11   %  IntLen:  3.8  % 

@agheata
Copy link
Copy Markdown
Member

agheata commented Jul 28, 2022

@MarkusFrankATcernch this looks quite good, but ideally, we need the macro to call both the "G4" and "ROOT" in the same session versions and compare them between each other, not only versus the PDG reference. Is it easy to do that? When this works properly, we merge this PR and add the macro as a separate PR, to be integrated with the CI/nightlies. We can do this next Monday when I'm back at work.

@MarkusFrankATcernch
Copy link
Copy Markdown
Contributor Author

@agheata
I am a bit hesitant to have one TGeoManager with materials created with different systems of units....

Concerning the comparison:
if PDG == TROOTMaterial and PDG == TGeant4Material then also: TROOTMaterial == TGeant4Material

Clearly both tests must succeed.

@agheata
Copy link
Copy Markdown
Member

agheata commented Jul 28, 2022

@agheata I am a bit hesitant to have one TGeoManager with materials created with different systems of units....

We can use 2 different TGeoManager, deleting in between, and caching the results in a struct.

Concerning the comparison: if PDG == TROOTMaterial and PDG == TGeant4Material then also: TROOTMaterial == TGeant4Material

Clearly both tests must succeed.

AFAICT you only compare to PDG with some tolerance, but it is essential that the equality above is strict between TROOTMaterial == TGeant4Material

@MarkusFrankATcernch
Copy link
Copy Markdown
Contributor Author

Here you go!

  • It checks pdg against TGeoROOT with tolerance
  • It checks pdg against TGeoG4 with tolerance
  • It checks TGeoROOT against TGeoG4 with numerical tolerance 1e-15 (some math simply is different)
$> root.exe test_material_units.C
  ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jul 27 2022, 14:22:00                 |
  | From heads/fix_radlen_g4units@v6-25-01-4723-g1344269685          |
  | With                                                             |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] 
Processing ../test_material_units.C...
 Using ROOT system of units. 
Element: SI      Z=14   N=28.000000   A=28.085500 [g/mole]
Material Mat_Si_TGeo    A=28.0855 Z=14 rho=2.329 radlen=9.35361 intlen=45.7729 index=0
Element: FE      Z=26   N=56.000000   A=55.845000 [g/mole]
Material Mat_Fe_TGeo    A=55.845 Z=26 rho=7.874 radlen=1.75666 intlen=16.9589 index=4
Element: U      Z=92   N=238.000000   A=238.028900 [g/mole]
Material Mat_U_TGeo    A=238.029 Z=92 rho=18.95 radlen=0.316948 intlen=11.4473 index=8
Info in <TGeoManager>: Changing system of units to Geant4 units (mm, ns, MeV).
 Using Geant4 system of units. 
Element: SI      Z=14   N=28.000000   A=28.085500 [g/mole]
Material Mat_Si_G4    A=28.0855 Z=14 rho=2.329 radlen=93.5361 intlen=457.729 index=0
Element: FE      Z=26   N=56.000000   A=55.845000 [g/mole]
Material Mat_Fe_G4    A=55.845 Z=26 rho=7.874 radlen=17.5666 intlen=169.589 index=4
Element: U      Z=92   N=238.000000   A=238.028900 [g/mole]
Material Mat_U_G4    A=238.029 Z=92 rho=18.95 radlen=3.16948 intlen=114.473 index=8
TEST PASSED Si             vs. Mat_Si_TGeo    Units: TGeo Deviation  density: 0  %  RadLen:  0.17     %  IntLen:  1.6  % 
TEST PASSED Si             vs. Mix_1_Si_TGeo  Units: TGeo Deviation  density: 0  %  RadLen:  0.0015   %  IntLen:  1.6  % 
TEST PASSED Si             vs. Mix_2_Si_TGeo  Units: TGeo Deviation  density: 0  %  RadLen:  0.17     %  IntLen:  1.6  % 
TEST PASSED Si             vs. Mix_3_Si_TGeo  Units: TGeo Deviation  density: 0  %  RadLen:  0.17     %  IntLen:  1.6  % 
TEST PASSED Si             vs. Mat_Si_G4      Units: G4   Deviation  density: 0  %  RadLen:  0.17     %  IntLen:  1.6  % 
TEST PASSED Si             vs. Mix_1_Si_G4    Units: G4   Deviation  density: 0  %  RadLen:  0.0015   %  IntLen:  1.6  % 
TEST PASSED Si             vs. Mix_2_Si_G4    Units: G4   Deviation  density: 0  %  RadLen:  0.17     %  IntLen:  1.6  % 
TEST PASSED Si             vs. Mix_3_Si_G4    Units: G4   Deviation  density: 0  %  RadLen:  0.17     %  IntLen:  1.6  % 
TEST PASSED Mat_Si_TGeo    vs. Mat_Si_G4      Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 
TEST PASSED Mix_1_Si_TGeo  vs. Mix_1_Si_G4    Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 
TEST PASSED Mix_2_Si_TGeo  vs. Mix_2_Si_G4    Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 
TEST PASSED Mix_3_Si_TGeo  vs. Mix_3_Si_G4    Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 
TEST PASSED Fe             vs. Mat_Fe_TGeo    Units: TGeo Deviation  density: 0  %  RadLen:  0.019    %  IntLen:  1.1  % 
TEST PASSED Fe             vs. Mix_1_Fe_TGeo  Units: TGeo Deviation  density: 0  %  RadLen:  0.028    %  IntLen:  1.1  % 
TEST PASSED Fe             vs. Mix_2_Fe_TGeo  Units: TGeo Deviation  density: 0  %  RadLen:  0.019    %  IntLen:  1.1  % 
TEST PASSED Fe             vs. Mix_3_Fe_TGeo  Units: TGeo Deviation  density: 0  %  RadLen:  0.019    %  IntLen:  1.1  % 
TEST PASSED Fe             vs. Mat_Fe_G4      Units: G4   Deviation  density: 0  %  RadLen:  0.019    %  IntLen:  1.1  % 
TEST PASSED Fe             vs. Mix_1_Fe_G4    Units: G4   Deviation  density: 0  %  RadLen:  0.028    %  IntLen:  1.1  % 
TEST PASSED Fe             vs. Mix_2_Fe_G4    Units: G4   Deviation  density: 0  %  RadLen:  0.019    %  IntLen:  1.1  % 
TEST PASSED Fe             vs. Mix_3_Fe_G4    Units: G4   Deviation  density: 0  %  RadLen:  0.019    %  IntLen:  1.1  % 
TEST PASSED Mat_Fe_TGeo    vs. Mat_Fe_G4      Units: G4   Deviation  density: 0  %  RadLen:  2.2e-14  %  IntLen:  0    % 
TEST PASSED Mix_1_Fe_TGeo  vs. Mix_1_Fe_G4    Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 
TEST PASSED Mix_2_Fe_TGeo  vs. Mix_2_Fe_G4    Units: G4   Deviation  density: 0  %  RadLen:  2.2e-14  %  IntLen:  0    % 
TEST PASSED Mix_3_Fe_TGeo  vs. Mix_3_Fe_G4    Units: G4   Deviation  density: 0  %  RadLen:  2.2e-14  %  IntLen:  0    % 
TEST PASSED U              vs. Mat_U_TGeo     Units: TGeo Deviation  density: 0  %  RadLen:  0.11     %  IntLen:  3.8  % 
TEST PASSED U              vs. Mix_1_U_TGeo   Units: TGeo Deviation  density: 0  %  RadLen:  0.0093   %  IntLen:  3.8  % 
TEST PASSED U              vs. Mix_2_U_TGeo   Units: TGeo Deviation  density: 0  %  RadLen:  0.11     %  IntLen:  3.8  % 
TEST PASSED U              vs. Mix_3_U_TGeo   Units: TGeo Deviation  density: 0  %  RadLen:  0.11     %  IntLen:  3.8  % 
TEST PASSED U              vs. Mat_U_G4       Units: G4   Deviation  density: 0  %  RadLen:  0.11     %  IntLen:  3.8  % 
TEST PASSED U              vs. Mix_1_U_G4     Units: G4   Deviation  density: 0  %  RadLen:  0.0093   %  IntLen:  3.8  % 
TEST PASSED U              vs. Mix_2_U_G4     Units: G4   Deviation  density: 0  %  RadLen:  0.11     %  IntLen:  3.8  % 
TEST PASSED U              vs. Mix_3_U_G4     Units: G4   Deviation  density: 0  %  RadLen:  0.11     %  IntLen:  3.8  % 
TEST PASSED Mat_U_TGeo     vs. Mat_U_G4       Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 
TEST PASSED Mix_1_U_TGeo   vs. Mix_1_U_G4     Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 
TEST PASSED Mix_2_U_TGeo   vs. Mix_2_U_G4     Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 
TEST PASSED Mix_3_U_TGeo   vs. Mix_3_U_G4     Units: G4   Deviation  density: 0  %  RadLen:  0        %  IntLen:  0    % 

TEST PASSED  Hurray!!!! 0 failures detected.

test_material_units.C.txt

@agheata
Copy link
Copy Markdown
Member

agheata commented Jul 29, 2022

OK @MarkusFrankATcernch looks good, LGTM and we can commit separately your macro in the test suite, but let's do this Monday to check how to integrate it properly.

@agheata agheata merged commit 103bb7e into root-project:master Jul 29, 2022
@MarkusFrankATcernch MarkusFrankATcernch deleted the fix_radlen_g4units branch July 29, 2022 13:13
agheata pushed a commit to agheata/root that referenced this pull request Aug 3, 2022
root-project#11060)

* Fix computation of the radiation length and nuclear interaction length when ROOT uses G4 units

* Fix computation of the radiation length and nuclear interaction length when ROOT uses G4 units

(cherry picked from commit 103bb7e)
agheata pushed a commit to agheata/root that referenced this pull request Aug 3, 2022
root-project#11060)

* Fix computation of the radiation length and nuclear interaction length when ROOT uses G4 units

* Fix computation of the radiation length and nuclear interaction length when ROOT uses G4 units

(cherry picked from commit 103bb7e)
agheata added a commit that referenced this pull request Aug 3, 2022
#11060) (#11103)

* Fix computation of the radiation length and nuclear interaction length when ROOT uses G4 units

* Fix computation of the radiation length and nuclear interaction length when ROOT uses G4 units

(cherry picked from commit 103bb7e)

Co-authored-by: MarkusFrankATcernch <[email protected]>
agheata added a commit that referenced this pull request Aug 4, 2022
#11060) (#11104)

* Fix computation of the radiation length and nuclear interaction length when ROOT uses G4 units

* Fix computation of the radiation length and nuclear interaction length when ROOT uses G4 units

(cherry picked from commit 103bb7e)

Co-authored-by: MarkusFrankATcernch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants