From 31cf94080503bc0fc04c8acbda42a16c8337e025 Mon Sep 17 00:00:00 2001
From: Christian Grefe <Christian.Grefe@cern.ch>
Date: Mon, 16 Sep 2013 08:53:26 +0000
Subject: [PATCH] Add access to interaction layer from Material

---
 DDCore/include/DD4hep/Objects.h |  4 +++-
 DDCore/src/Objects.cpp          | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h
index f7a8d5358..c711533c1 100644
--- a/DDCore/include/DD4hep/Objects.h
+++ b/DDCore/include/DD4hep/Objects.h
@@ -221,8 +221,10 @@ namespace DD4hep {
       Material(const Handle<Q>& e) : Handle<TGeoMedium>(e) {}
       /// String representation of this object
       std::string toString()  const;
-      /// Access the radiation length of the undrelying material
+      /// Access the radiation length of the underlying material
       double radLength() const;
+      /// Access the interaction length of the underlying material
+      double intLength() const;
     };
 
     /** @class VisAttr Objects.h
diff --git a/DDCore/src/Objects.cpp b/DDCore/src/Objects.cpp
index 1f68daf77..e0f337224 100644
--- a/DDCore/src/Objects.cpp
+++ b/DDCore/src/Objects.cpp
@@ -167,7 +167,7 @@ Atom::Atom(const string& name, const string& formula, int Z, int N, double densi
   m_element = e;
 }
 
-/// Access the radiation length of the undrelying material
+/// Access the radiation length of the underlying material
 double Material::radLength() const {
   Handle<TGeoMedium>  val(*this);
   if ( val.isValid() ) {
@@ -178,6 +178,17 @@ double Material::radLength() const {
   throw runtime_error("Attempt to access radiation length from invalid material handle!");
 }
 
+/// Access the radiation length of the underlying material
+double Material::intLength() const {
+  Handle<TGeoMedium>  val(*this);
+  if ( val.isValid() ) {
+    TGeoMaterial* m = val->GetMaterial();
+    if ( m ) return m->GetIntLen();
+    throw runtime_error("The medium "+string(val->GetName())+" has an invalid material reference!");
+  }
+  throw runtime_error("Attempt to access interaction length from invalid material handle!");
+}
+
 /// String representation of this object
 string Material::toString()  const {
   Handle<TGeoMedium>  val(*this);
-- 
GitLab