From ad4151a408e70d2e7cf66d26f1131bb2c18af9d1 Mon Sep 17 00:00:00 2001
From: Yorgos Voutsinas <georgios.voutsinas@desy.de>
Date: Thu, 23 Mar 2017 18:05:35 +0100
Subject: [PATCH] adding a layered calorimeter struct that copes with conical
 calorimeters

---
 DDRec/include/DDRec/DetectorData.h | 144 +++++++++++++++++++++++++++++
 DDRec/src/DetectorData.cpp         |  59 ++++++++++--
 2 files changed, 193 insertions(+), 10 deletions(-)

diff --git a/DDRec/include/DDRec/DetectorData.h b/DDRec/include/DDRec/DetectorData.h
index 3e507cf38..d225d5446 100644
--- a/DDRec/include/DDRec/DetectorData.h
+++ b/DDRec/include/DDRec/DetectorData.h
@@ -449,6 +449,150 @@ namespace DD4hep {
 
 
 
+
+
+
+
+
+
+
+
+
+    /** Simple data structure defining a layered calorimeter layout for
+     *  reconstruction. Modified version of the above LayeredCalorimeterStruct that
+     *  can deal with a conical shaped calorimeter
+     * 
+     * @author Y.Voutsinas, CERN
+     * @date March, 2017
+     * @version $Id: $
+     */
+    struct LayeredConicalCalorimeterStruct{
+      
+      /// enum for encoding the sensor type in typeFlags
+      enum LayoutType{
+	BarrelLayout=0,
+	EndcapLayout
+      };
+
+      /// type of layout: BarrelLayout or EndcapLayout
+      LayoutType layoutType ;
+
+      /// extent of the calorimeter in the r-z-plane [ RminInn, RmaxInn, RminOut, RmaxOut, zmin, zmax ] in mm.
+      double extent[6] ;
+
+      /** the order of the rotational symmetry at the outside, e.g.
+       *  8 for an octagonal barrel calorimeter.
+       */
+      int outer_symmetry ;
+
+      /** the order of the rotational symmetry at the inside, e.g.
+       *  4 for an endcap with a rectangular cout out at the inside.
+       */
+      int inner_symmetry ;
+
+      /** Angle between the normal to the first outer face of the 
+       *  calorimeter and the x-axis, where the first face is defined
+       *  to be the one with the smallest positve angle.
+       *  Example:
+       *  outer_phi0=0 corresponds to the first face beeing vertical and 
+       *  thus the bottom face being parallel to the floor for a 
+       *  symmetry that is a multiple of 4.
+       */      
+      double  outer_phi0  ;
+
+      /** Same as outer_phi for the first inner face.
+       */
+      double  inner_phi0  ;
+      
+      
+      /** Azimuthal angle of the first module in barrel layout
+       *  DEPRECATED! PLEASE POPULATE INNER/OUTER PHI0 INSTEAD
+       */
+      double  phi0  ;
+      
+      /// Gap between modules(eg. stave gap) in the phi-direction
+      double gap0;
+      
+      /// Gap between modules(eg. middle stave gap) in the z-direction
+      double gap1;
+      
+      /// Gap between modules(reserved for future use) e.g in the r-direction
+      double gap2;
+      
+
+      struct Layer {
+	
+	Layer() :
+	  distance(0),
+	  phi0(0),
+	  absorberThickness(0),
+	  inner_nRadiationLengths(0),
+	  inner_nInteractionLengths(0),        
+	  outer_nRadiationLengths(0),
+	  outer_nInteractionLengths(0), 
+	  inner_thickness(0),
+	  outer_thickness(0),
+	  sensitive_thickness(0),
+	  cellSize0(0),
+	  cellSize1(0) {
+	}
+	
+	/// distance from Origin (or the z-axis) to the inner-most face of the layer
+	double distance;
+        
+	/// phi0 of layer: potential rotation around normal to absorber plane, e.g. if layers are 'staggered' in phi in fwd. calos 
+	double phi0 ;
+	
+        /// thickness of the absorber part of the layer. Consider using inner/outer_nRadiationLengths and inner/outer_nInteractionLengths
+	double absorberThickness ;
+        
+        ///Absorber material in front of sensitive element in the layer, units of radiation lengths
+        double inner_nRadiationLengths ;
+        ///Absorber material in front of sensitive element in the layer, units of radiation lengths
+        double inner_nInteractionLengths ;        
+        
+        ///Absorber material in behind of sensitive element in the layer, units of radiation lengths
+        double outer_nRadiationLengths ;
+        ///Absorber material in behind of sensitive element in the layer, units of radiation lengths
+        double outer_nInteractionLengths ; 
+        
+        ///Distance between the innermost face of the layer (closest to IP) and the center of the sensitive element
+        double inner_thickness;
+        
+        ///Distance between the center of the sensitive element and the outermost face of the layer
+        double outer_thickness;
+        
+        ///Thickness of the sensitive element (e.g. scintillator)
+        double sensitive_thickness;
+        
+        
+        
+	/// cell size along the first axis where first is either along the beam (BarrelLayout) or up (EndcapLayout) or the direction closest to that. 
+	double cellSize0 ;
+	/// second cell size, perpendicular to the first direction cellSize0 and the depth of the layers. 
+	double cellSize1 ;
+      } ;   
+
+      std::vector<Layer> layers ;	
+    } ;
+
+    typedef StructExtension<LayeredConicalCalorimeterStruct> LayeredConicalCalorimeterData ;
+
+    std::ostream& operator<<( std::ostream& io , const LayeredConicalCalorimeterData& d ) ;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     /** Simple data strucuture that holds maps of ids of the nearest neighbour surfaces in the same, next and previous layers
      *  of a tracking detector. Could be used as extension object for tracking DetectorElements and used in 
      *  pattern recognition. The exact details of the neighbouring criteria depend on the algorithm that is used.
diff --git a/DDRec/src/DetectorData.cpp b/DDRec/src/DetectorData.cpp
index 56259b3d5..d83c86e31 100644
--- a/DDRec/src/DetectorData.cpp
+++ b/DDRec/src/DetectorData.cpp
@@ -1,14 +1,10 @@
 #include "DDRec/DetectorData.h"
 
-#include <boost/io/ios_state.hpp>
-
 namespace DD4hep {
   namespace DDRec {
 
 
     std::ostream& operator<<( std::ostream& io , const FixedPadSizeTPCData& d ){
-      boost::io::ios_base_all_saver ifs(io);
-
       io <<  " --FixedPadSizeTPCData: "  << std::scientific << std::endl ; 
       io <<  "   zHalf : "              <<  d.zHalf  << std::endl ; 
       io <<  "   rMin : "               <<  d.rMin << std::endl ; 
@@ -29,7 +25,6 @@ namespace DD4hep {
 
 
     std::ostream& operator<<( std::ostream& io , const ZPlanarData& d ) {
-      boost::io::ios_base_all_saver ifs(io);
 
       io <<  " -- ZPlanarData: "  << std::scientific << std::endl ; 
       io <<  " zHalfShell  : " <<  d.zHalfShell  << std::endl ; 
@@ -73,7 +68,6 @@ namespace DD4hep {
     }
 
     std::ostream& operator<<( std::ostream& io , const ZDiskPetalsData& d ) {
-      boost::io::ios_base_all_saver ifs(io);
 
       io <<  " -- ZDiskPetalsData: "  << std::scientific << std::endl ; 
       io <<  "  widthStrip : " <<  d.widthStrip  << std::endl ; 
@@ -122,7 +116,6 @@ namespace DD4hep {
 
     
     std::ostream& operator<<( std::ostream& io , const ConicalSupportData& d ) {
-      boost::io::ios_base_all_saver ifs(io);
 
       io <<  " -- ConicalSupportData : "  << std::scientific << std::endl ; 
       io <<  "  isSymmetricInZ : " <<  d.isSymmetricInZ  << std::endl ; 
@@ -146,7 +139,6 @@ namespace DD4hep {
 
     
     std::ostream& operator<<( std::ostream& io , const LayeredCalorimeterData& d ) {
-      boost::io::ios_base_all_saver ifs(io);
 
       io <<  " -- LayeredCalorimeterData : "  << std::scientific << std::endl ; 
       io <<  "  LayoutType : " <<  ( d.layoutType == LayeredCalorimeterStruct::BarrelLayout ?
@@ -187,9 +179,56 @@ namespace DD4hep {
 
 
 
-    std::ostream& operator<<( std::ostream& io , const NeighbourSurfacesData& d ){
-      boost::io::ios_base_all_saver ifs(io);
 
+
+
+    std::ostream& operator<<( std::ostream& io , const LayeredConicalCalorimeterData& d ) {
+
+      io <<  " -- LayeredConicalCalorimeterData : "  << std::scientific << std::endl ; 
+      io <<  "  LayoutType : " <<  ( d.layoutType == LayeredCalorimeterStruct::BarrelLayout ?
+				     "BarrelLayout" : "EndcapLayout" ) << std::endl ; 
+      io <<  "  extent[  RminInn, RmaxInn, RminOut, RmaxOut, zmin, zmax  ] : " 
+	 <<  d.extent[0] << " "  << d.extent[1] << " "  << d.extent[2] << " " << d.extent[3] << " " << d.extent[4] << " " << d.extent[5]  << std::endl ; 
+      io <<  " outer_symmetry : " <<  d.outer_symmetry  << std::endl ; 
+      io <<  " inner_symmetry : " <<  d.inner_symmetry  << std::endl ; 
+      io <<  " outer_phi0 : " <<  d.outer_phi0  << std::endl ; 
+      io <<  " inner_phi0 : " <<  d.inner_phi0  << std::endl ; 
+      io <<  " gap1 : " <<  d.gap1  << std::endl ; 
+      io <<  " gap2 : " <<  d.gap2  << std::endl ; 
+      
+      std::vector<LayeredConicalCalorimeterData::Layer> layers = d.layers ;
+
+      io <<  " Layers : " << std::endl 
+	 <<  "  distance      inner_nX0   outer_nX0    inner_nInt    outer_nInt  inner_thick outer_thick   sense_thick" 
+	 << std::endl ;
+      //"distance inner_nX0   outer_nX0 inner_nLambda outer_nLambda inner_thick outer_thick sensitive_thick" << std::endl ;
+
+      for(unsigned i=0,N=layers.size() ; i<N ; ++i){
+
+	LayeredConicalCalorimeterData::Layer l = layers[i] ;
+
+	io << " " << l.distance
+	   << " " << l.inner_nRadiationLengths
+	   << " " << l.outer_nRadiationLengths
+	   << " " << l.inner_nInteractionLengths 
+	   << " " << l.outer_nInteractionLengths
+	   << " " << l.inner_thickness
+	   << " " << l.outer_thickness
+	   << " " << l.sensitive_thickness
+	   << std::endl ;
+      }
+
+      return io ;
+    }
+
+
+
+
+
+
+
+
+    std::ostream& operator<<( std::ostream& io , const NeighbourSurfacesData& d ){
       io <<  " --NeighbourSurfacesData: "  << std::scientific << std::endl ; 
       io <<  "   sameLayer.size() : " << d.sameLayer.size() << std::endl ; 
       return io ;
-- 
GitLab