From 9262f9f9a98045f77ddee46b1725969fd0564c1a Mon Sep 17 00:00:00 2001
From: Nikiforos Nikiforou <Nikiforos.Nikiforou@cern.ch>
Date: Fri, 2 Oct 2015 07:17:46 +0000
Subject: [PATCH] Minor correction in createGearForCLIC

---
 DDRec/src/gear/createGearForCLIC.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/DDRec/src/gear/createGearForCLIC.cpp b/DDRec/src/gear/createGearForCLIC.cpp
index 9f9c5d93b..5fdd700c2 100644
--- a/DDRec/src/gear/createGearForCLIC.cpp
+++ b/DDRec/src/gear/createGearForCLIC.cpp
@@ -354,9 +354,16 @@ namespace DD4hep{
             //The positioning should come out right, but the absorber thickness should be overestimated due to the presence of 
             //other less dense material
 	    if( i == 0 ) {
+            //First layer is positioned with only its inner thickness taken into account
 	      gearCalo->layerLayout().positionLayer( l.distance/dd4hep::mm, (l.inner_thickness+l.sensitive_thickness/2.)/dd4hep::mm , 
 						     l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness-l.sensitive_thickness/2.)/dd4hep::mm ) ;
-	    }else{
+	    }else if ( i == nL -1 ) {
+                    //Need to handle outermost layer differently; add its outer thickness
+                    //This gives the right extent, but the "wrong" distance for the last layer
+            	      gearCalo->layerLayout().addLayer((l.inner_thickness+l.outer_thickness+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm , 
+									    l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness+l.outer_thickness-l.sensitive_thickness+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm) ;
+        }else{
+            //All other layers need to be added taking into account the previous layer outer thicknesses
 	      gearCalo->layerLayout().addLayer((l.inner_thickness+l.sensitive_thickness/2.+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm , 
 									    l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness-l.sensitive_thickness/2.+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm) ;
 	    }
-- 
GitLab