From 931d802fadc8f0a07b36b4a1738620ec1bf26fbc Mon Sep 17 00:00:00 2001
From: Dave Casper <dcasper@localhost.localdomain>
Date: Sat, 14 Sep 2019 20:33:25 -0700
Subject: [PATCH] Attempt to implement something like the real plane geometry

---
 .../GeoModel/FaserGeoModel/data/geomDB.sql    |   4 +-
 .../FaserSCT_GeoModel/SCT_Barrel.h            |   4 +-
 .../FaserSCT_GeoModel/SCT_BarrelParameters.h  |   9 +-
 .../FaserSCT_GeoModel/SCT_HalfPlane.h         |  64 ++++++++
 .../{SCT_Layer.h => SCT_Plane.h}              |  34 ++--
 .../FaserSCT_GeoModel/SCT_Ski.h               |  66 --------
 .../FaserSCT_GeoModel/src/SCT_Barrel.cxx      |  30 ++--
 .../src/SCT_BarrelParameters.cxx              |  25 ++-
 .../FaserSCT_GeoModel/src/SCT_HalfPlane.cxx   | 145 ++++++++++++++++++
 .../src/{SCT_Layer.cxx => SCT_Plane.cxx}      |  72 ++++-----
 .../FaserSCT_GeoModel/src/SCT_Ski.cxx         | 143 -----------------
 graphics/VTI12/README.md                      |   4 +-
 12 files changed, 299 insertions(+), 301 deletions(-)
 create mode 100644 Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_HalfPlane.h
 rename Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/{SCT_Layer.h => SCT_Plane.h} (64%)
 delete mode 100644 Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Ski.h
 create mode 100644 Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_HalfPlane.cxx
 rename Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/{SCT_Layer.cxx => SCT_Plane.cxx} (57%)
 delete mode 100644 Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Ski.cxx

diff --git a/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql b/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql
index 738ea5cb7..d2c66167e 100644
--- a/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql
+++ b/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql
@@ -1057,8 +1057,8 @@ INSERT INTO "SCTTOPLEVEL_DATA2TAG" VALUES(106788,3);
 --
 --
 DROP TABLE IF EXISTS "SCTFASERGENERAL_DATA";
-CREATE TABLE "SCTFASERGENERAL_DATA" ("SCTFASERGENERAL_DATA_ID" SLONGLONG, "NUMLAYERS" INT, "LAYERPITCH" DOUBLE, "ROWSPERLAYER" INT, "MODULESPERROW" INT, UNIQUE ( "SCTFASERGENERAL_DATA_ID") );
-INSERT INTO "SCTFASERGENERAL_DATA" VALUES (0, 3, 100.0, 4, 2);
+CREATE TABLE "SCTFASERGENERAL_DATA" ("SCTFASERGENERAL_DATA_ID" SLONGLONG, "NUMLAYERS" INT, "LAYERPITCH" DOUBLE, "ETAHALFPITCH" DOUBLE, "PHIHALFPITCH" DOUBLE, "DEPTHHALFPITCH" DOUBLE, "SIDEHALFPITCH" DOUBLE, UNIQUE ( "SCTFASERGENERAL_DATA_ID") );
+INSERT INTO "SCTFASERGENERAL_DATA" VALUES (0, 3, 100.0, 60.0, 30.0, 2.5, 2.5);
 DROP TABLE IF EXISTS "SCTFASERGENERAL_DATA2TAG";
 CREATE TABLE "SCTFASERGENERAL_DATA2TAG" ( "SCTFASERGENERAL_TAG_ID" SLONGLONG ,"SCTFASERGENERAL_DATA_ID" SLONGLONG  );
 INSERT INTO "SCTFASERGENERAL_DATA2TAG" VALUES(106789, 0);
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Barrel.h b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Barrel.h
index 2a4f370cd..63a780e16 100644
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Barrel.h
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Barrel.h
@@ -11,7 +11,7 @@ class GeoVPhysVol;
 class GeoFullPhysVol;
 class GeoLogVol;
 class SCT_Identifier;
-class SCT_Layer;
+class SCT_Plane;
 
 class SCT_Barrel : public SCT_UniqueComponentFactory
 {
@@ -34,7 +34,7 @@ private:
   void getParameters();
   virtual const GeoLogVol * preBuild();
 
-  SCT_Layer* m_layer;
+  SCT_Plane* m_plane;
 
   int    m_numLayers;
   double m_layerPitch;
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_BarrelParameters.h b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_BarrelParameters.h
index 0c94262c0..9005a5a20 100644
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_BarrelParameters.h
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_BarrelParameters.h
@@ -16,14 +16,15 @@ public:
   // Constructor 
   SCT_BarrelParameters(SCT_DataBase* rdb);
 
-  int modulesPerRow() const;
-  int rowsPerLayer() const;
-
+  double etaHalfPitch() const;
+  double phiHalfPitch() const;
+  double depthHalfPitch() const;
+  double sideHalfPitch() const;
 
   // Barrel General
   int    numLayers() const;
   double layerPitch() const;
- private:
+private:
   SCT_DataBase * m_rdb;
 
 };
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_HalfPlane.h b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_HalfPlane.h
new file mode 100644
index 000000000..3fa09c9ad
--- /dev/null
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_HalfPlane.h
@@ -0,0 +1,64 @@
+/*
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef FASERSCT_GEOMODEL_SCT_HALFPLANE_H
+#define FASERSCT_GEOMODEL_SCT_HALFPLANE_H
+
+#include "FaserSCT_GeoModel/SCT_ComponentFactory.h"
+
+#include <string>
+
+class GeoMaterial;
+class GeoVPhysVol;
+class GeoLogVol;
+class SCT_Module;
+class SCT_Identifier;
+
+class SCT_HalfPlane: public SCT_UniqueComponentFactory
+{
+public:
+  SCT_HalfPlane(const std::string & name,
+                TrackerDD::SCT_DetectorManager* detectorManager,
+                const SCT_GeometryManager* geometryManager,
+                SCT_MaterialManager* materials);
+
+  ~SCT_HalfPlane();
+  //Explicitly disallow copy, assign to appease coverity
+  SCT_HalfPlane(const SCT_HalfPlane &) = delete;
+  SCT_HalfPlane & operator=(const SCT_HalfPlane &) = delete;
+
+  virtual GeoVPhysVol* build(SCT_Identifier id) { return build(id, +1); }
+  virtual GeoVPhysVol * build(SCT_Identifier id, int etaSign);
+
+
+public:
+  
+  double width()  const      { return m_width; }         // y dimension of half-plane (local/module)
+  double length() const      { return m_length; }        // z dimension of half-plane (local/module)
+  double thickness() const   { return m_thickness; }     // x dimension of half-plane (local/module)
+
+private:
+  void getParameters();
+  virtual const GeoLogVol * preBuild();
+
+  void activeEnvelopeExtent(double & dx, double & dy, double & dz);
+
+  // Layer number
+  double m_safety;
+  double m_etaHalfPitch;            // horizontal global direction
+  double m_phiHalfPitch;            // vertical global direction
+  double m_depthHalfPitch;          // axial global direction
+  
+  double m_width;
+  double m_length;
+  double m_thickness;
+  // double m_activeWidth;
+  // double m_activeThickness;
+  // double m_activeLength;
+
+  SCT_Module*              m_module;
+  const GeoLogVol*         m_logVolume;
+};
+
+#endif // FASERSCT_GEOMODEL_SCT_HALFPLANE_H
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Layer.h b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Plane.h
similarity index 64%
rename from Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Layer.h
rename to Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Plane.h
index f9e291800..d52658a5f 100644
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Layer.h
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Plane.h
@@ -3,11 +3,8 @@
 */
 
 //
-// CPW 17/8/06
-// Version using new model of services from A. Tricoli
-// 
-#ifndef FASERSCT_GEOMODEL_SCT_LAYER_H
-#define FASERSCT_GEOMODEL_SCT_LAYER_H
+#ifndef FASERSCT_GEOMODEL_SCT_PLANE_H
+#define FASERSCT_GEOMODEL_SCT_PLANE_H
 
 #include "FaserSCT_GeoModel/SCT_ComponentFactory.h"
 
@@ -16,31 +13,31 @@
 class GeoMaterial;
 class GeoVPhysVol;
 class GeoLogVol;
-class SCT_Ski;
+class SCT_HalfPlane;
 class SCT_Module;
 class SCT_Identifier;
 
-class SCT_Layer: public SCT_UniqueComponentFactory
+class SCT_Plane: public SCT_UniqueComponentFactory
 {
 public:
-  SCT_Layer(const std::string & name,
+  SCT_Plane(const std::string & name,
             TrackerDD::SCT_DetectorManager* detectorManager,
             const SCT_GeometryManager* geometryManager,
             SCT_MaterialManager* materials);
 
-  ~SCT_Layer();
+  ~SCT_Plane();
   //Explicitly disallow copy, assign to appease coverity
-  SCT_Layer(const SCT_Layer &) = delete;
-  SCT_Layer & operator=(const SCT_Layer &) = delete;
+  SCT_Plane(const SCT_Plane &) = delete;
+  SCT_Plane & operator=(const SCT_Plane &) = delete;
 
   virtual GeoVPhysVol * build(SCT_Identifier id);
 
 
 public:
   
-  double width()  const   {return m_width;}         // x dimension of layer
-  double height() const   {return m_height;}        // y dimension of layer
-  double thickness() const   {return m_thickness;}  // z dimension of layer
+  double width()  const   {return m_width;}         // x dimension of layer (global)
+  double height() const   {return m_height;}        // y dimension of layer (global)
+  double thickness() const   {return m_thickness;}  // z dimension of layer (global)
 
 private:
   void getParameters();
@@ -54,14 +51,11 @@ private:
   double m_width;
   double m_height;
   double m_thickness;
-  double m_activeWidth;
-  double m_activeHeight;
-  double m_activeThickness;
 
-  int    m_rowsPerLayer;
+  double m_sideHalfPitch;
 
-  SCT_Ski*      m_ski;
+  SCT_HalfPlane*      m_halfPlane;
   const GeoLogVol*    m_logVolume;
 };
 
-#endif // FASERSCT_GEOMODEL_SCT_LAYER_H
+#endif // FASERSCT_GEOMODEL_SCT_PLANE_H
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Ski.h b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Ski.h
deleted file mode 100644
index 35c2b8195..000000000
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/FaserSCT_GeoModel/SCT_Ski.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
-*/
-
-//
-// CPW 17/8/06
-// Version using new model of services from A. Tricoli
-// 
-#ifndef FASERSCT_GEOMODEL_SCT_SKI_H
-#define FASERSCT_GEOMODEL_SCT_SKI_H
-
-#include "FaserSCT_GeoModel/SCT_ComponentFactory.h"
-
-#include <string>
-
-class GeoMaterial;
-class GeoVPhysVol;
-class GeoLogVol;
-class SCT_Module;
-class SCT_Identifier;
-
-class SCT_Ski: public SCT_UniqueComponentFactory
-{
-public:
-  SCT_Ski(const std::string & name,
-          TrackerDD::SCT_DetectorManager* detectorManager,
-          const SCT_GeometryManager* geometryManager,
-          SCT_MaterialManager* materials);
-
-  ~SCT_Ski();
-  //Explicitly disallow copy, assign to appease coverity
-  SCT_Ski(const SCT_Ski &) = delete;
-  SCT_Ski & operator=(const SCT_Ski &) = delete;
-
-  virtual GeoVPhysVol * build(SCT_Identifier id);
-
-
-public:
-  
-  double width()  const      { return m_width; }         // y dimension of ski
-  double length() const      { return m_length; }        // z dimension of ski
-  double thickness() const   { return m_thickness; }  // x dimension of ski
-
-private:
-  void getParameters();
-  virtual const GeoLogVol * preBuild();
-
-  void activeEnvelopeExtent(double & dx, double & dy, double & dz);
-
-  // Layer number
-  double m_safety;
-  
-  double m_width;
-  double m_length;
-  double m_thickness;
-  double m_activeWidth;
-  double m_activeThickness;
-  double m_activeLength;
-
-  int    m_modulesPerRow;
-
-  SCT_Module*        m_module;
-  const GeoLogVol*         m_logVolume;
-};
-
-#endif // FASERSCT_GEOMODEL_SCT_SKI_H
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Barrel.cxx b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Barrel.cxx
index d18019352..003be477e 100644
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Barrel.cxx
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Barrel.cxx
@@ -11,7 +11,7 @@
 #include "FaserSCT_GeoModel/SCT_GeneralParameters.h"
 #include "FaserSCT_GeoModel/SCT_Identifier.h"
 
-#include "FaserSCT_GeoModel/SCT_Layer.h"
+#include "FaserSCT_GeoModel/SCT_Plane.h"
 
 #include "TrackerReadoutGeometry/SCT_DetectorManager.h"
 
@@ -54,9 +54,7 @@ SCT_Barrel::getParameters()
   
   m_numLayers  = parameters->numLayers(); 
   m_layerPitch = parameters->layerPitch();
-  int modulesPerRow = parameters->modulesPerRow();
-  int rowsPerLayer  = parameters->rowsPerLayer();
-  std::cout << "Retrieved parameters: " << m_numLayers << " "<<  m_layerPitch << " " << modulesPerRow << " " << rowsPerLayer << std::endl;
+  std::cout << "Retrieved parameters: " << m_numLayers << " "<<  m_layerPitch << std::endl;
   // Set numerology
   std::cout << "Setting num layers" << std::endl;
   // Set numerology
@@ -64,19 +62,19 @@ SCT_Barrel::getParameters()
   std::cout << "Setting modules per layer" << std::endl;
   for (int i = 0; i < m_numLayers; i++)
   {
-    m_detectorManager->numerology().setNumEtaModulesForLayer(i, modulesPerRow);
-    m_detectorManager->numerology().setNumPhiModulesForLayer(i, rowsPerLayer);
+    m_detectorManager->numerology().setNumEtaModulesForLayer(i, 2);
+    m_detectorManager->numerology().setNumPhiModulesForLayer(i, 4);
   }
 }
 
 const GeoLogVol * 
 SCT_Barrel::preBuild()
 {
-  std::cout << "Instantiating Layer" << std::endl;
-  m_layer = new SCT_Layer("Layer", m_detectorManager, m_geometryManager, m_materials);
-  m_width = m_layer->width() + m_safety;
-  m_height = m_layer->height() + m_safety;
-  m_thickness = m_layer->thickness() * m_numLayers + m_layerPitch * (m_numLayers - 1) + m_safety;
+  std::cout << "Instantiating Plane" << std::endl;
+  m_plane = new SCT_Plane("Plane", m_detectorManager, m_geometryManager, m_materials);
+  m_width = m_plane->width() + m_safety;
+  m_height = m_plane->height() + m_safety;
+  m_thickness = m_plane->thickness() * m_numLayers + m_layerPitch * (m_numLayers - 1) + m_safety;
 
   // Create the barrel volume
   // Tube envelope containing the barrel.
@@ -93,20 +91,20 @@ SCT_Barrel::build(SCT_Identifier id)
 
   double activeDepth = m_thickness - m_safety/2;
 
-  double layerThickness = m_layer->thickness();
+  double layerThickness = m_plane->thickness();
   for (int iLayer = 0; iLayer < m_numLayers; iLayer++) {
     // Create the layers
-    barrel->add(new GeoNameTag("Layer#"+intToString(iLayer)));
+    barrel->add(new GeoNameTag("Plane#"+intToString(iLayer)));
     barrel->add(new GeoIdentifierTag(iLayer)); // Identifier layer= iLayer
     id.setLayer(iLayer); 
     GeoAlignableTransform* transform = new GeoAlignableTransform(GeoTrf::Translate3D(0.0, 
                                                                                      0.0,
                                                                                      (layerThickness - activeDepth)/2 + iLayer * m_layerPitch) );
     barrel->add(transform);
-    GeoVPhysVol * layerPV = m_layer->build(id);
-    barrel->add(layerPV);
+    GeoVPhysVol * planePV = m_plane->build(id);
+    barrel->add(planePV);
     // Store alignable transform
-    m_detectorManager->addAlignableTransform(2, id.getWaferId(), transform, layerPV);
+    m_detectorManager->addAlignableTransform(2, id.getWaferId(), transform, planePV);
   }
 
   // Extra Material
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_BarrelParameters.cxx b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_BarrelParameters.cxx
index 4798f4b50..749a239be 100644
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_BarrelParameters.cxx
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_BarrelParameters.cxx
@@ -23,17 +23,30 @@ SCT_BarrelParameters::SCT_BarrelParameters(SCT_DataBase* rdb)
 // Barrel Layer
 //
 
-  int
-  SCT_BarrelParameters::modulesPerRow() const
+  double
+  SCT_BarrelParameters::etaHalfPitch() const
   {
-    return m_rdb->brlGeneral()->getInt("MODULESPERROW");
+    return m_rdb->brlGeneral()->getDouble("ETAHALFPITCH");
   }
 
-  int
-  SCT_BarrelParameters::rowsPerLayer() const
+  double
+  SCT_BarrelParameters::phiHalfPitch() const
   {
-    return m_rdb->brlGeneral()->getInt("ROWSPERLAYER");
+    return m_rdb->brlGeneral()->getDouble("PHIHALFPITCH");
   }
+
+  double
+  SCT_BarrelParameters::depthHalfPitch() const
+  {
+    return m_rdb->brlGeneral()->getDouble("DEPTHHALFPITCH");
+  }
+
+  double
+  SCT_BarrelParameters::sideHalfPitch() const
+  {
+    return m_rdb->brlGeneral()->getDouble("SIDEHALFPITCH");
+  }
+
 //
 // Barrel General
 //
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_HalfPlane.cxx b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_HalfPlane.cxx
new file mode 100644
index 000000000..4c4e45ec4
--- /dev/null
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_HalfPlane.cxx
@@ -0,0 +1,145 @@
+/*
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "FaserSCT_GeoModel/SCT_HalfPlane.h"
+#include "FaserSCT_GeoModel/SCT_Identifier.h"
+#include "FaserSCT_GeoModel/SCT_GeometryManager.h"
+#include "FaserSCT_GeoModel/SCT_MaterialManager.h"
+#include "FaserSCT_GeoModel/SCT_BarrelParameters.h"
+#include "FaserSCT_GeoModel/SCT_GeneralParameters.h"
+#include "FaserSCT_GeoModel/SCT_Module.h"
+
+#include "TrackerGeoModelUtils/ExtraMaterial.h"
+#include "TrackerReadoutGeometry/SCT_DetectorManager.h"
+
+#include "GeoModelKernel/GeoBox.h"
+#include "GeoModelKernel/GeoLogVol.h"
+#include "GeoModelKernel/GeoPhysVol.h"
+#include "GeoModelKernel/GeoFullPhysVol.h"
+#include "GeoModelKernel/GeoNameTag.h"
+#include "GeoModelKernel/GeoIdentifierTag.h"
+#include "GeoModelKernel/GeoTransform.h"
+#include "GeoModelKernel/GeoAlignableTransform.h"
+#include "GeoModelKernel/GeoMaterial.h"
+#include "GeoModelKernel/GeoShapeSubtraction.h"
+#include "GeoModelKernel/GeoDefinitions.h"
+#include "GaudiKernel/SystemOfUnits.h"
+
+#include <sstream>
+#include <cmath>
+
+inline double sqr(double x) {return x * x;}
+
+SCT_HalfPlane::SCT_HalfPlane(const std::string & name,
+                             TrackerDD::SCT_DetectorManager* detectorManager,
+                             const SCT_GeometryManager* geometryManager,
+                             SCT_MaterialManager* materials)
+  : SCT_UniqueComponentFactory(name, detectorManager, geometryManager, materials)
+{
+  getParameters();
+  m_logVolume = preBuild();
+}
+
+SCT_HalfPlane::~SCT_HalfPlane()
+{
+  if (m_module != nullptr) delete m_module;
+}
+
+void
+SCT_HalfPlane::getParameters()
+{
+  const SCT_BarrelParameters * parameters = m_geometryManager->barrelParameters();
+  const SCT_GeneralParameters * generalParameters = m_geometryManager->generalParameters();
+    
+  m_safety         = generalParameters->safety();
+  m_etaHalfPitch   = parameters->etaHalfPitch();
+  m_phiHalfPitch   = parameters->phiHalfPitch();
+  m_depthHalfPitch = parameters->depthHalfPitch();
+}
+
+const GeoLogVol * 
+SCT_HalfPlane::preBuild()
+{
+  std::cout << "Instantiating Module" << std::endl;
+  m_module = new SCT_Module("Module", m_detectorManager, m_geometryManager, m_materials);
+  std::cout << "Module created" << std::endl;
+  //
+  // Active Layer Envelope extent
+  // Envelope for the active part (ie containing all the skis for the layer)
+  //
+  double activeWidth, activeThickness, activeLength;
+
+  // Returns the outer dimensions of the active envelope
+  activeEnvelopeExtent(activeThickness, activeWidth, activeLength);
+
+  // Add some safety
+  activeWidth  += m_safety;
+  activeThickness += m_safety;
+  activeLength += m_safety;
+
+  //
+  // Overall Layer Envelope extent
+  //
+  m_width = activeWidth;
+  m_thickness = activeThickness;
+  m_length = activeLength;
+  //
+  // Make envelope for layer
+  //
+  const GeoBox* halfPlaneEnvelopeBox = new GeoBox(0.5 * m_thickness, 0.5 * m_width, 0.5 * m_length);
+  GeoLogVol* logVolume = new GeoLogVol(getName(), halfPlaneEnvelopeBox, m_materials->gasMaterial());
+
+  // Check for overlap.
+
+  return logVolume;
+}
+
+GeoVPhysVol * 
+SCT_HalfPlane::build(SCT_Identifier id, int etaSign)
+{
+  // We make this a fullPhysVol
+  GeoFullPhysVol * halfPlane = new GeoFullPhysVol(m_logVolume);
+
+  for (int module = 0; module < 4; module++)
+  {
+    int iz = 1 - 2 * (module % 2);
+    int iy = -3 + 2 * module;
+    int ix = iz;
+    int iEta = iz * etaSign;
+    halfPlane->add(new GeoNameTag("Module#" + intToString(module)));
+    halfPlane->add(new GeoIdentifierTag(module));
+    id.setPhiModule(module);
+    id.setEtaModule(iEta);
+    GeoTrf::Transform3D position(GeoTrf::Translation3D(ix * m_depthHalfPitch, iy * m_phiHalfPitch, iz * m_etaHalfPitch));
+    GeoAlignableTransform* transform = nullptr;
+    if ( module%2 == 0 )
+    {
+      transform = new GeoAlignableTransform(position * GeoTrf::RotateX3D(180*Gaudi::Units::deg));
+    }
+    else
+    {
+      transform = new GeoAlignableTransform(position);
+    }
+    halfPlane->add(transform);
+    GeoVPhysVol* modulePV = m_module->build(id);
+    halfPlane->add(modulePV);
+    m_detectorManager->addAlignableTransform(1, id.getWaferId(), transform, modulePV);
+  }
+  return halfPlane;
+}
+
+void
+SCT_HalfPlane::activeEnvelopeExtent(double & dx, double & dy, double & dz)
+{
+  double layerThickness = 2 * m_depthHalfPitch + m_module->thickness() + m_safety;  // this is the x-coordinate (depth) of the modules
+  const GeoTrf::Vector3D* refPt = m_module->env1RefPointVector();
+  double moduleHalfWidth = std::fabs(-refPt->y()-m_module->env1Width()/2);
+  double layerWidth = 2 * moduleHalfWidth + 6 * m_phiHalfPitch + m_safety;          // this is the y-coordinate (phi) of the modules
+  double moduleHalfLength = std::fabs(-refPt->z()-m_module->env1Length()/2);
+  double layerLength = 2 * moduleHalfLength + 2 * m_etaHalfPitch + m_safety;        // this is the z-coordinate (eta) of the modules
+
+  dx = layerThickness;
+  dy = layerWidth;
+  dz = layerLength;
+}
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Layer.cxx b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Plane.cxx
similarity index 57%
rename from Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Layer.cxx
rename to Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Plane.cxx
index d8dfcd756..8bd925cde 100644
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Layer.cxx
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Plane.cxx
@@ -6,13 +6,13 @@
 // CPW 17/8/06
 // Version using new model of services from A. Tricoli
 // 
-#include "FaserSCT_GeoModel/SCT_Layer.h"
+#include "FaserSCT_GeoModel/SCT_Plane.h"
 #include "FaserSCT_GeoModel/SCT_Identifier.h"
 #include "FaserSCT_GeoModel/SCT_GeometryManager.h"
 #include "FaserSCT_GeoModel/SCT_MaterialManager.h"
 #include "FaserSCT_GeoModel/SCT_BarrelParameters.h"
 #include "FaserSCT_GeoModel/SCT_GeneralParameters.h"
-#include "FaserSCT_GeoModel/SCT_Ski.h"
+#include "FaserSCT_GeoModel/SCT_HalfPlane.h"
 #include "FaserSCT_GeoModel/SCT_Module.h"
 
 #include "TrackerGeoModelUtils/ExtraMaterial.h"
@@ -36,7 +36,7 @@
 
 inline double sqr(double x) {return x * x;}
 
-SCT_Layer::SCT_Layer(const std::string & name,
+SCT_Plane::SCT_Plane(const std::string & name,
                      TrackerDD::SCT_DetectorManager* detectorManager,
                      const SCT_GeometryManager* geometryManager,
                      SCT_MaterialManager* materials)
@@ -46,29 +46,29 @@ SCT_Layer::SCT_Layer(const std::string & name,
   m_logVolume = preBuild();
 }
 
-SCT_Layer::~SCT_Layer()
+SCT_Plane::~SCT_Plane()
 {
 }
 
 void
-SCT_Layer::getParameters()
+SCT_Plane::getParameters()
 {
   const SCT_BarrelParameters * parameters = m_geometryManager->barrelParameters();
   const SCT_GeneralParameters * generalParameters = m_geometryManager->generalParameters();
     
-  m_safety       = generalParameters->safety();
-  m_rowsPerLayer  = parameters->rowsPerLayer();
+  m_safety         = generalParameters->safety();
+  m_sideHalfPitch  = parameters->sideHalfPitch();
 
 }
 
 const GeoLogVol * 
-SCT_Layer::preBuild()
+SCT_Plane::preBuild()
 {
-  std::cout << "Instantiating Ski" << std::endl;
-  m_ski = new SCT_Ski("Row", m_detectorManager, m_geometryManager, m_materials);
+  std::cout << "Instantiating Half Plane" << std::endl;
+  m_halfPlane = new SCT_HalfPlane("HalfPlane", m_detectorManager, m_geometryManager, m_materials);
   //
   // Active Layer Envelope extent
-  // Envelope for the active part (ie containing all the skis for the layer)
+  // Envelope for the active part (ie containing both half-planes for the layer)
   //
   double activeWidth, activeHeight, activeThickness;
 
@@ -80,16 +80,12 @@ SCT_Layer::preBuild()
   activeHeight += m_safety;
   activeThickness += m_safety;
 
-  m_activeWidth = activeWidth;
-  m_activeHeight = activeHeight;
-  m_activeThickness = activeThickness;
   //
   // Overall Layer Envelope extent
   //
-  // Same as active dimensions, since there is no support material yet
-  m_width = m_activeWidth;
-  m_height = m_activeHeight;
-  m_thickness = m_activeThickness;
+  m_width = activeWidth;
+  m_height = activeHeight;
+  m_thickness = activeThickness;
   //
   // Make envelope for layer
   //
@@ -102,43 +98,39 @@ SCT_Layer::preBuild()
 }
 
 GeoVPhysVol * 
-SCT_Layer::build(SCT_Identifier id)
+SCT_Plane::build(SCT_Identifier id)
 {
   // We make this a fullPhysVol
-  GeoFullPhysVol * layer = new GeoFullPhysVol(m_logVolume);
+  GeoFullPhysVol * plane = new GeoFullPhysVol(m_logVolume);
 
-  double activeHeight = m_height - m_safety/2;
-  double rowHeight = m_ski->width();
-  for (int iPhi = 0; iPhi < m_rowsPerLayer; iPhi++)
+  for (int side = 0; side < 2; side++)
   {
-    layer->add(new GeoNameTag("Row#"+intToString(iPhi)));
-    layer->add(new GeoIdentifierTag(iPhi)); 
-    id.setPhiModule(iPhi); 
-    GeoAlignableTransform* transform = new GeoAlignableTransform(GeoTrf::Translate3D(0.0, 
-                                                                                     (rowHeight - activeHeight)/2 + iPhi * rowHeight,
-                                                                                     0.0 ) *
-                                                                 GeoTrf::RotateY3D(90*Gaudi::Units::deg));
-    layer->add(transform);
-    GeoVPhysVol * skiPV = m_ski->build(id);
-    layer->add(skiPV);
-    // Store alignable transform
-    m_detectorManager->addAlignableTransform(2, id.getWaferId(), transform, skiPV);    
+    plane->add(new GeoNameTag("Side#" + intToString(side)));
+    plane->add(new GeoIdentifierTag(side));
+    int iz = -1 + 2 * side;
+    GeoAlignableTransform* transform = new GeoAlignableTransform(GeoTrf::Translate3D(0.0, 0.0, iz * m_sideHalfPitch) * 
+                                                                 GeoTrf::RotateY3D(iz * 90 * Gaudi::Units::deg));
+    plane->add(transform);
+    GeoVPhysVol* halfPlanePV = m_halfPlane->build(id, -iz);
+    plane->add(halfPlanePV);
+    // Store alignable transform; unclear if we can do this...
+    m_detectorManager->addAlignableTransform(2, id.getWaferId(), transform, halfPlanePV);    
   }
 
   // Extra Material
   // TrackerDD::ExtraMaterial xMat(m_geometryManager->distortedMatManager());
   // xMat.add(layer, "SCTLayer");
 
-  return layer;
+  return plane;
 }
 
 void
-SCT_Layer::activeEnvelopeExtent(double & dx, double & dy, double & dz)
+SCT_Plane::activeEnvelopeExtent(double & dx, double & dy, double & dz)
 {
   // Do this in a very simple-minded and unrealistic way to start
-  double layerThickness = m_ski->thickness() + m_safety;              // this is the x-coordinate of the module/ski and the z-coordinate of the layer
-  double layerWidth = m_ski->length() + m_safety;                     // this is the z-coordinate (eta) of the module/ski, and the x-coordinate of the layer
-  double layerHeight = m_rowsPerLayer * m_ski->width() + m_safety; // this is the y-coordinate (phi) of the module/ski, and the y-coordinate of the layer
+  double layerThickness = m_halfPlane->thickness() + 2 * m_sideHalfPitch + m_safety;// this is the x-coordinate of the modules and the z-coordinate of the plane
+  double layerWidth = m_halfPlane->length() + m_safety;                             // this is the z-coordinate (eta) of the modules, and the x-coordinate of the plane
+  double layerHeight = m_halfPlane->width() + m_safety;                             // this is the y-coordinate (phi) of the modules, and the y-coordinate of the plane
 
   dx = layerWidth;
   dy = layerHeight;
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Ski.cxx b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Ski.cxx
deleted file mode 100644
index c01541f6d..000000000
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_Ski.cxx
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
-*/
-
-//
-// CPW 17/8/06
-// Version using new model of services from A. Tricoli
-// 
-#include "FaserSCT_GeoModel/SCT_Ski.h"
-#include "FaserSCT_GeoModel/SCT_Identifier.h"
-#include "FaserSCT_GeoModel/SCT_GeometryManager.h"
-#include "FaserSCT_GeoModel/SCT_MaterialManager.h"
-#include "FaserSCT_GeoModel/SCT_BarrelParameters.h"
-#include "FaserSCT_GeoModel/SCT_GeneralParameters.h"
-#include "FaserSCT_GeoModel/SCT_Module.h"
-
-#include "TrackerGeoModelUtils/ExtraMaterial.h"
-#include "TrackerReadoutGeometry/SCT_DetectorManager.h"
-
-#include "GeoModelKernel/GeoBox.h"
-#include "GeoModelKernel/GeoLogVol.h"
-#include "GeoModelKernel/GeoPhysVol.h"
-#include "GeoModelKernel/GeoFullPhysVol.h"
-#include "GeoModelKernel/GeoNameTag.h"
-#include "GeoModelKernel/GeoIdentifierTag.h"
-#include "GeoModelKernel/GeoTransform.h"
-#include "GeoModelKernel/GeoAlignableTransform.h"
-#include "GeoModelKernel/GeoMaterial.h"
-#include "GeoModelKernel/GeoShapeSubtraction.h"
-#include "GeoModelKernel/GeoDefinitions.h"
-#include "GaudiKernel/SystemOfUnits.h"
-
-#include <sstream>
-#include <cmath>
-
-inline double sqr(double x) {return x * x;}
-
-SCT_Ski::SCT_Ski(const std::string & name,
-                     TrackerDD::SCT_DetectorManager* detectorManager,
-                     const SCT_GeometryManager* geometryManager,
-                     SCT_MaterialManager* materials)
-  : SCT_UniqueComponentFactory(name, detectorManager, geometryManager, materials)
-{
-  getParameters();
-  m_logVolume = preBuild();
-}
-
-SCT_Ski::~SCT_Ski()
-{
-}
-
-void
-SCT_Ski::getParameters()
-{
-  const SCT_BarrelParameters * parameters = m_geometryManager->barrelParameters();
-  const SCT_GeneralParameters * generalParameters = m_geometryManager->generalParameters();
-    
-  m_safety       = generalParameters->safety();
-  m_modulesPerRow = parameters->modulesPerRow();
-
-}
-
-const GeoLogVol * 
-SCT_Ski::preBuild()
-{
-  std::cout << "Instantiating Module" << std::endl;
-  m_module = new SCT_Module("Module", m_detectorManager, m_geometryManager, m_materials);
-  std::cout << "Module created" << std::endl;
-  //
-  // Active Layer Envelope extent
-  // Envelope for the active part (ie containing all the skis for the layer)
-  //
-  double activeWidth, activeThickness, activeLength;
-
-  // Returns the outer dimensions of the active envelope
-  activeEnvelopeExtent(activeThickness, activeWidth, activeLength);
-
-  // Add some safety
-  activeWidth  += m_safety;
-  activeThickness += m_safety;
-  activeLength += m_safety;
-
-  m_activeWidth = activeWidth;
-  m_activeThickness = activeThickness;
-  m_activeLength = activeLength;
-  //
-  // Overall Layer Envelope extent
-  //
-  // Same as active dimensions, since there is no support material yet
-  m_width = m_activeWidth;
-  m_thickness = m_activeThickness;
-  m_length = m_activeLength;
-  //
-  // Make envelope for layer
-  //
-  const GeoBox* skiEnvelopeBox = new GeoBox(0.5 * m_thickness, 0.5 * m_width, 0.5 * m_length);
-  GeoLogVol* logVolume = new GeoLogVol(getName(), skiEnvelopeBox, m_materials->gasMaterial());
-
-  // Check for overlap.
-
-  return logVolume;
-}
-
-GeoVPhysVol * 
-SCT_Ski::build(SCT_Identifier id)
-{
-  // We make this a fullPhysVol
-  GeoFullPhysVol * ski = new GeoFullPhysVol(m_logVolume);
-
-  double activeLength = m_length - m_safety/2;
-  double moduleLength = m_module->length();
-  for (int iEta = -m_modulesPerRow/2; iEta <= m_modulesPerRow/2; iEta++)
-  {
-    if (iEta == 0) continue;
-    ski->add(new GeoNameTag("Module#"+intToString(iEta)));
-    ski->add(new GeoIdentifierTag(iEta)); 
-    id.setEtaModule(iEta); 
-    double zEta = (iEta < 0 ? iEta + 0.5 : iEta - 0.5);
-    GeoAlignableTransform* transform = new GeoAlignableTransform(GeoTrf::Translate3D(0.0, 
-                                                                                     0.0,
-                                                                                     (moduleLength - activeLength)/2 + zEta * moduleLength));
-    ski->add(transform);
-    GeoVPhysVol * modulePV = m_module->build(id);
-    ski->add(modulePV);
-    // Store alignable transform
-    m_detectorManager->addAlignableTransform(1, id.getWaferId(), transform, modulePV);    
-  }
-
-  return ski;
-}
-
-void
-SCT_Ski::activeEnvelopeExtent(double & dx, double & dy, double & dz)
-{
-  // Do this in a very simple-minded and unrealistic way to start
-  double layerThickness = m_module->thickness() + m_safety;              // this is the x-coordinate of the module/ski
-  double layerWidth = m_module->width() + m_safety;                      // this is the y-coordinate (phi) of the module/ski
-  double layerLength = m_modulesPerRow * m_module->length() + m_safety;  // this is the z-coordinate (eta) of the module/ski
-
-  dx = layerThickness;
-  dy = layerWidth;
-  dz = layerLength;
-}
diff --git a/graphics/VTI12/README.md b/graphics/VTI12/README.md
index 48657faa6..c8b26dcb1 100644
--- a/graphics/VTI12/README.md
+++ b/graphics/VTI12/README.md
@@ -4,6 +4,6 @@ To run on Calypso MC data (from an installation (run) directory):
 
 % export VP1PLUGINPATH=./lib
 
-% vti12 -mc -noautoconf &lt;input HITS or EVNT file&gt;
+% vti12 -mc -noautoconf -nosortdbreplicas &lt;input HITS or EVNT file&gt;
 
-Note that VP1PLUGINPATH can be ninja-changed by asetup, and if it does not include the installation library folder, nothing will work
\ No newline at end of file
+Note that VP1PLUGINPATH can be ninja-changed by asetup, and if it does not include the Calypso installation library folder, nothing will work
\ No newline at end of file
-- 
GitLab