From 5fb22dfd655d239c9c3b1ba0c4e3a913e0f6df6e Mon Sep 17 00:00:00 2001
From: John Derek Chapman <chapman@hep.phy.cam.ac.uk>
Date: Thu, 26 Jan 2017 16:56:58 +0100
Subject: [PATCH] python/LArG4FastSimulationConfig.py (getFCALFastShower,
 getFCAL2FastShower): increase EMinEneShowerLib from 0.51 MeV to 3 MeV.
 ATLASSIM-2188. Tagging: LArG4FastSimulation-05-00-08-01
 (LArG4FastSimulation-05-00-08-01)

	* Branch for 20.3.7.7 and 21.0.15
	* python/LArG4FastSimulationConfig.py
	(getFCALFastShower, getFCAL2FastShower): increase EMinEneShowerLib
	from 0.51 MeV to 3 MeV. ATLASSIM-2188
	* Tagging: LArG4FastSimulation-05-00-08-01

2016-09-01 Steve Farrell <Steven.Farrell@cern.ch>
	* Cleaned up long lines, whitespace, variable naming conventions.
	* Changed loop-by-value to loop-by-reference over EnergySpot in
	  LArFastShower to prevent unnecessary copies.
	* Fixed thread-unsafe usage of static LArG4Identifiers in the fastsim
	  SDs by converting them into class members.
	* Tagging: LArG4FastSimulation-05-00-08

2016-06-01  Zach Marshall <ZLMarshall@lbl.gov>

	* Tagging: LArG4FastSimulation-05-00-07
	* No shower libraries at very low energy.  Skipping the application for
	such particles.
...
(Long ChangeLog diff - truncated)
---
 .../python/LArG4FastSimulationConfig.py       |   4 +
 .../src/BarrelFastSimDedicatedSD.cxx          |  21 ++-
 .../src/BarrelFastSimDedicatedSD.h            |   5 +
 .../src/EndcapFastSimDedicatedSD.cxx          |   9 +-
 .../src/EndcapFastSimDedicatedSD.h            |   4 +
 .../src/FCALFastSimDedicatedSD.cxx            |  19 ++-
 .../src/FCALFastSimDedicatedSD.h              |   5 +
 .../src/IFastSimDedicatedSD.h                 |   6 +-
 .../LArG4FastSimulation/src/LArFastShower.cxx | 135 ++++++++++--------
 .../LArG4FastSimulation/src/LArFastShower.h   |  96 +++++++------
 .../src/LArFastShowerTool.cxx                 |  49 +++----
 .../src/LArFastShowerTool.h                   |   3 +-
 12 files changed, 202 insertions(+), 154 deletions(-)

diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py b/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py
index d68ab43046f..6dfc534ca5f 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py
@@ -20,6 +20,7 @@ def getEMBFastShower(name="EMBFastShower", **kwargs):
     kwargs.setdefault("AbsCrackEta2",       1.1)
     kwargs.setdefault("DetectorTag",        100000)
     kwargs.setdefault("SensitiveDetector",  "BarrelFastSimDedicatedSD")
+    kwargs.setdefault("EMinEneShowerLib",   0.51)
     return CfgMgr.LArFastShowerTool(name, **kwargs)
 
 def getEMECFastShower(name="EMECFastShower", **kwargs):
@@ -37,6 +38,7 @@ def getEMECFastShower(name="EMECFastShower", **kwargs):
     kwargs.setdefault("AbsCrackEta2",       2.8)
     kwargs.setdefault("DetectorTag",        200000)
     kwargs.setdefault("SensitiveDetector", "EndcapFastSimDedicatedSD")
+    kwargs.setdefault("EMinEneShowerLib",   0.51)
     return CfgMgr.LArFastShowerTool(name, **kwargs)
 
 def getFCALFastShower(name="FCALFastShower", **kwargs):
@@ -51,6 +53,7 @@ def getFCALFastShower(name="FCALFastShower", **kwargs):
     kwargs.setdefault("AbsHighEta",         4.4)
     kwargs.setdefault("DetectorTag",        300000)
     kwargs.setdefault("SensitiveDetector", "FCALFastSimDedicatedSD")
+    kwargs.setdefault("EMinEneShowerLib",   3.0)
     return CfgMgr.LArFastShowerTool(name, **kwargs)
 
 def getFCAL2FastShower(name="FCAL2FastShower", **kwargs):
@@ -65,4 +68,5 @@ def getFCAL2FastShower(name="FCAL2FastShower", **kwargs):
     kwargs.setdefault("AbsHighEta",         4.4)
     kwargs.setdefault("DetectorTag",        400000)
     kwargs.setdefault("SensitiveDetector", "FCALFastSimDedicatedSD")
+    kwargs.setdefault("EMinEneShowerLib",   1.0)
     return CfgMgr.LArFastShowerTool(name, **kwargs)
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.cxx
index 8c38939f999..8e424d99fc4 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.cxx
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.cxx
@@ -10,7 +10,6 @@
 #include "LArReadoutGeometry/EMBAccordionDetails.h"
 #include "LArReadoutGeometry/GeoStraightAccSection.h"
 #include "LArG4Code/EnergySpot.h"
-#include "LArG4Code/LArG4Identifier.h"
 #include "StoreGate/StoreGateSvc.h"
 
 using HepGeom::Point3D;
@@ -138,17 +137,17 @@ void BarrelFastSimDedicatedSD::ProcessSpot(const EnergySpot  & spot){
           }
         }
 
-        static LArG4Identifier id;
-        id.clear();
-        id     << 4          // LArCalorimeter
-               << 1          // LArEM
-               << ((zIndex==0) ? -1:1)
-               << samplingIndex
-               << regionIndex
-               << etaIndex
-               << phiIndex;
+        //static LArG4Identifier id;
+        m_larID.clear();
+        m_larID << 4          // LArCalorimeter
+                << 1          // LArEM
+                << ((zIndex==0) ? -1:1)
+                << samplingIndex
+                << regionIndex
+                << etaIndex
+                << phiIndex;
         // call process to add this to the collection 
-        SimpleHit(id, spot.GetTime(), spot.GetEnergy());
+        SimpleHit(m_larID, spot.GetTime(), spot.GetEnergy());
 
         return;
       }
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.h
index 010a4ca226b..3bb033fc5eb 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.h
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.h
@@ -10,7 +10,9 @@
 // of:  we DO want it to execute it's end-
 
 #include "IFastSimDedicatedSD.h"
+#include "LArG4Code/LArG4Identifier.h"
 
+// Forward declarations
 class EnergySpot;
 class G4HCofThisEvent;
 class LArVHitMerger;
@@ -19,6 +21,7 @@ class EMBAccordionDetails;
 class GeoStraightAccSection;
 class StoreGateSvc;
 
+/// NEEDS DOCUMENTATION
 class BarrelFastSimDedicatedSD : public IFastSimDedicatedSD
 {
 
@@ -39,6 +42,8 @@ private:
   const EMBAccordionDetails *m_accordionDetails;
   const GeoStraightAccSection *m_absorberSections;
 
+  /// My LAr identifier
+  LArG4Identifier m_larID;
 };
 
 #endif //LARG4FASTSIMULATION_BARRELFASTSIMDEDICATEDSD_H
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx
index 76163a30848..e1001702ad3 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx
@@ -9,7 +9,6 @@
 #include "LArReadoutGeometry/EMECDetectorRegion.h"
 #include "LArG4Code/EnergySpot.h"
 #include "LArSimEvent/LArHitContainer.h"
-#include "LArG4Code/LArG4Identifier.h"
 #include "GeoSpecialShapes/LArWheelCalculator.h"
 #include "StoreGate/StoreGateSvc.h"
 
@@ -113,9 +112,9 @@ void EndcapFastSimDedicatedSD::ProcessSpot(const EnergySpot  & spot){
 
         //std::cout << didIt <<  "Compare phi gap: " << nGaps << ' ' << nBins << ' ' << gapsPerBin << ':' << phiBin <<  '/' << phiIndex << std::endl;
 
-        static LArG4Identifier id;
-        id.clear();
-        id             << 4          // LArCalorimeter
+        //static LArG4Identifier id;
+        m_larID.clear();
+        m_larID        << 4          // LArCalorimeter
                        << 1          // LArEM
                        << sWheel
                        << samplingIndex
@@ -123,7 +122,7 @@ void EndcapFastSimDedicatedSD::ProcessSpot(const EnergySpot  & spot){
                        << etaIndex
                        << phiBin;
         // call process to add this to the collection 
-        SimpleHit(id, spot.GetTime(), spot.GetEnergy());
+        SimpleHit(m_larID, spot.GetTime(), spot.GetEnergy());
         return;
       }
     }
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.h
index 18c7c4fe197..74ea067bf01 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.h
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.h
@@ -10,6 +10,7 @@
 // of:  we DO want it to execute it's end-
 
 #include "IFastSimDedicatedSD.h"
+#include "LArG4Code/LArG4Identifier.h"
 
 class EnergySpot;
 class G4HCofThisEvent;
@@ -18,6 +19,7 @@ class EMECDetectorManager;
 class LArWheelCalculator;
 class StoreGateSvc;
 
+/// NEEDS DOCUMENTATION
 class EndcapFastSimDedicatedSD : public IFastSimDedicatedSD
 {
 
@@ -40,6 +42,8 @@ private:
   LArWheelCalculator  * m_outerWheelCalculatorPos;
   LArWheelCalculator  * m_outerWheelCalculatorNeg;
 
+  /// My LAr identifier
+  LArG4Identifier m_larID;
 };
 
 #endif //LARG4FASTSIMULATION_ENDCAPFASTSIMDEDICATEDSD_H
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.cxx
index 25e007b2056..9b3847a23f4 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.cxx
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.cxx
@@ -9,7 +9,6 @@
 #include "LArReadoutGeometry/FCALModule.h"
 #include "LArG4Code/EnergySpot.h"
 #include "LArSimEvent/LArHitContainer.h"
-#include "LArG4Code/LArG4Identifier.h"
 #include "GeoModelKernel/GeoTubs.h"
 #include "StoreGate/StoreGateSvc.h"
 
@@ -83,20 +82,20 @@ void FCALFastSimDedicatedSD::ProcessSpot(const EnergySpot  & spot){
 
   // zSide is negative if z<0.
   int zSide = iAmPositive ? 2:-2;
-  static LArG4Identifier id;
-  id.clear();
+  //static LArG4Identifier id;
+  m_larID.clear();
   if (ok){
-    id << 4          // LArCalorimeter
-       << 3          // LArFCAL
-       << zSide      // EndCap
-       << sampling   // FCal Module #
-       << etaIndex
-       << phiIndex;
+    m_larID << 4          // LArCalorimeter
+            << 3          // LArFCAL
+            << zSide      // EndCap
+            << sampling   // FCal Module #
+            << etaIndex
+            << phiIndex;
   } else {
     return;
   }
 
   // call process to add this to the collection 
-  SimpleHit(id, spot.GetTime(), spot.GetEnergy());
+  SimpleHit(m_larID, spot.GetTime(), spot.GetEnergy());
   return;
 }
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.h
index 43f542e1e32..60938e82a2f 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.h
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.h
@@ -10,12 +10,14 @@
 // of:  we DO want it to execute it's end-
 
 #include "IFastSimDedicatedSD.h"
+#include "LArG4Code/LArG4Identifier.h"
 
 class EnergySpot;
 class LArVHitMerger;
 class FCALDetectorManager;
 class StoreGateSvc;
 
+/// NEEDS DOCUMENTATION
 class FCALFastSimDedicatedSD : public IFastSimDedicatedSD
 {
 public:
@@ -32,6 +34,9 @@ public:
 private:
 
   FCALDetectorManager * m_fcalManager;
+
+  /// My LAr identifier
+  LArG4Identifier m_larID;
 };
 
 #endif //LARG4FASTSIMULATION_FCALFASTSIMDEDICATEDSD_H
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/IFastSimDedicatedSD.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/IFastSimDedicatedSD.h
index 64652804b18..1f0ea27ce8f 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/IFastSimDedicatedSD.h
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/IFastSimDedicatedSD.h
@@ -5,21 +5,21 @@
 #ifndef LARG4FASTSIMULATION_IFASTSIMDEDICATEDSD_H
 #define LARG4FASTSIMULATION_IFASTSIMDEDICATEDSD_H
 
-// This is the interface for the fast simulation dedicated sensitive detector.
 #include "LArG4Code/LArG4SimpleSD.h"
 class EnergySpot;
 class StoreGateSvc;
 
+/// This is the interface for the fast simulation dedicated sensitive detector.
 class IFastSimDedicatedSD : public LArG4SimpleSD {
 
  public:
 
-  // Simple constructor and destructor
+  /// Simple constructor and destructor
   IFastSimDedicatedSD( std::string name , StoreGateSvc * detStore ) : LArG4SimpleSD( name , detStore ) {}
 
   ~IFastSimDedicatedSD() {}
 
-  // ProcessHitsMethod
+  /// ProcessHitsMethod
   /** Process a single energy spot from a frozen shower.
       The appropriate region of the sensitive detector is calculated and a LArIdentifier is constructed*/
   virtual void ProcessSpot(const EnergySpot & spot) = 0;
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShower.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShower.cxx
index cd6e6e007e6..2d508dd2a2c 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShower.cxx
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShower.cxx
@@ -30,16 +30,18 @@
 #undef _INFO_FSM_
 
 
-LArFastShower::LArFastShower(const std::string& name, const FastShowerConfigStruct& config, IFastSimDedicatedSD* fastSimDedicatedSD):
+LArFastShower::LArFastShower(const std::string& name, const FastShowerConfigStruct& config,
+                             IFastSimDedicatedSD* fastSimDedicatedSD):
   G4VFastSimulationModel(name),
   m_configuration(config),
-  m_FastSimDedicatedSD(fastSimDedicatedSD),
+  m_fastSimDedicatedSD(fastSimDedicatedSD),
   m_showerLibSvc(nullptr),
   m_generate_starting_points(false),
   m_starting_points_file(),
   m_eventNum(0)
 {
-  enum DETECTOR {EMB=100000,EMEC=200000,FCAL1=300000,FCAL2=400000,FCAL3=500000,HECLOC=600000,HEC=700000};
+  enum DETECTOR { EMB=100000, EMEC=200000, FCAL1=300000, FCAL2=400000,
+                  FCAL3=500000, HECLOC=600000, HEC=700000 };
 
   m_detmap["EMB"]=EMB;
   m_detmap["EMEC"]=EMEC;
@@ -52,10 +54,10 @@ LArFastShower::LArFastShower(const std::string& name, const FastShowerConfigStru
 
 IFastSimDedicatedSD* LArFastShower::fastShowerSD()
 {
-  if ( !m_FastSimDedicatedSD ) {
+  if ( !m_fastSimDedicatedSD ) {
     throw std::runtime_error("LArFastShower: no pointer to IFastSimDedicatedSD!");
   }
-  return m_FastSimDedicatedSD;
+  return m_fastSimDedicatedSD;
 }
 
 
@@ -86,8 +88,10 @@ G4bool LArFastShower::IsApplicable(const G4ParticleDefinition& particleType)
     return m_applicableMap.find(particleType.GetPDGEncoding())->second;
   }
   bool rez = false;
-  if (( flagToShowerLib(particleType) )
-      && ( m_generate_starting_points || showerLibSvc()->checkLibrary( particleType.GetPDGEncoding() , m_configuration.m_detector_tag ) ))
+  if ( flagToShowerLib(particleType) &&
+       ( m_generate_starting_points ||
+         showerLibSvc()->checkLibrary( particleType.GetPDGEncoding(),
+                                       m_configuration.m_detector_tag ) ))
     rez = true;
   m_applicableMap[particleType.GetPDGEncoding()] = rez;
   return rez;
@@ -95,12 +99,12 @@ G4bool LArFastShower::IsApplicable(const G4ParticleDefinition& particleType)
 
 G4bool LArFastShower::ModelTrigger(const G4FastTrack& fastTrack)
 {
-  /* ============================================================================================================
+  /* ==========================================================================
      Determine if the particle is to be returned to full Geant4 simulation.
-     In the event where the particle is EITHER killed and parameterised OR simply killed, this must be done
-     in the appropriate LArFastShower DoIt method.
+     In the event where the particle is EITHER killed and parameterised OR
+     simply killed, this must be done in the appropriate LArFastShower DoIt method.
      This method Checks: 1) Geometry; 2) Energy; 3) (for e+/e-) Containment
-     ============================================================================================================ */
+     ========================================================================== */
 
 #ifdef _TRACE_FSM_
   G4cout << "LArFastShower::commonTrigger" << G4endl;
@@ -109,20 +113,20 @@ G4bool LArFastShower::ModelTrigger(const G4FastTrack& fastTrack)
   // We are in a parameterized volume
 
   // Check if the particle is within energy bounds
-  G4double  ParticleEnergy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
-  G4ParticleDefinition& ParticleType = *(fastTrack.GetPrimaryTrack()->GetDefinition());
+  G4double particleEnergy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
+  const G4ParticleDefinition& particleType = *(fastTrack.GetPrimaryTrack()->GetDefinition());
 
-  if ( flagToShowerLib(ParticleType) == true &&
-       ParticleEnergy > minEneToShowerLib(ParticleType) &&
-       ParticleEnergy < maxEneToShowerLib(ParticleType) ) {
+  if ( flagToShowerLib(particleType) == true &&
+       particleEnergy > minEneToShowerLib(particleType) &&
+       particleEnergy < maxEneToShowerLib(particleType) ) {
 
 #ifdef _TRACE_FSM_
-    G4cout << "Particle has energy (" << ParticleEnergy << ") for shower lib and shower lib is on! Accept particle!" << G4endl;
+    G4cout << "Particle has energy (" << particleEnergy << ") for shower lib and shower lib is on! Accept particle!" << G4endl;
 #endif
   }  else {
 
 #ifdef _TRACE_FSM_
-    G4cout << "Particle has energy (" << ParticleEnergy << ") outside killing, shower lib and parametrisation "
+    G4cout << "Particle has energy (" << particleEnergy << ") outside killing, shower lib and parametrisation "
            << "or some features are switched off ... returning it to Geant  " << G4endl;
 #endif
 
@@ -132,7 +136,7 @@ G4bool LArFastShower::ModelTrigger(const G4FastTrack& fastTrack)
   if (ForcedAccept(fastTrack)) return true;
   if (ForcedDeny(fastTrack)) return false;
 
-  if( CheckContainment(fastTrack)==false) {
+  if (CheckContainment(fastTrack)==false) {
 #ifdef _TRACE_FSM_
     G4cout << "LArFastShower::ModelTrigger() particle failed CheckContainment()... will not be parameterised: " << G4endl;
 #endif
@@ -202,17 +206,19 @@ void LArFastShower::UseShowerLib(const G4FastTrack& fastTrack, G4FastStep& fastS
     // -----------------------------
     // Get Shower from ShowerLibSvc
     // -----------------------------
-    const std::vector<EnergySpot> shower = showerLibSvc()->getShower(fastTrack, m_configuration.m_detector_tag);
+    const std::vector<EnergySpot> shower =
+      showerLibSvc()->getShower(fastTrack, m_configuration.m_detector_tag);
 
 #ifdef _TRACE_DOIT_
     G4cout << "Got shower (" << shower.size() << ") from shower lib" << G4endl;
 #endif
 
     // loop over hits in shower
-    for (auto a_spot : shower) {
+    for (const auto& a_spot : shower) {
 
 #ifdef _TRACE_DOIT_
-      G4cout << "Make Spot: " << a_spot.GetPosition().x() << " " << a_spot.GetPosition().y() << " " << a_spot.GetPosition().z()
+      G4cout << "Make Spot: " << a_spot.GetPosition().x() << " "
+             << a_spot.GetPosition().y() << " " << a_spot.GetPosition().z()
              << " " << a_spot.GetEnergy() << " " << a_spot.GetTime() << G4endl;
 #endif
       fastShowerSD()->ProcessSpot(a_spot);
@@ -229,6 +235,8 @@ void LArFastShower::UseShowerLib(const G4FastTrack& fastTrack, G4FastStep& fastS
 
     return;
   }
+
+  // FIXME: Catching all exceptions and suppressing them? That's awful!!
   catch (const std::exception & e) {
     G4cout << "FastShower::UseShowerLib ERROR Handling an exception in LArFastShower::" << e.what() << G4endl;
     return;
@@ -239,14 +247,14 @@ void LArFastShower::UseShowerLib(const G4FastTrack& fastTrack, G4FastStep& fastS
 G4bool LArFastShower::CheckContainment(const G4FastTrack &fastTrack)
 {
 
-  G4ThreeVector DirectionShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
-  G4ThreeVector InitialPositionShower = fastTrack.GetPrimaryTrack()->GetPosition();
-  G4ThreeVector OrthoShower = DirectionShower.orthogonal();
-  G4ThreeVector CrossShower = DirectionShower.cross(OrthoShower);
+  G4ThreeVector showerDirection = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
+  G4ThreeVector initialShowerPosition = fastTrack.GetPrimaryTrack()->GetPosition();
+  G4ThreeVector orthoShower = showerDirection.orthogonal();
+  G4ThreeVector crossShower = showerDirection.cross(orthoShower);
 
 #ifdef _TRACE_FSM_
-  G4cout << "LArFastShower::CheckContainment() OrthoShower: " << OrthoShower << G4endl;
-  G4cout << "LArFastShower::CheckContainment() CrossShower: " << CrossShower << G4endl;
+  G4cout << "LArFastShower::CheckContainment() orthoShower: " << orthoShower << G4endl;
+  G4cout << "LArFastShower::CheckContainment() crossShower: " << crossShower << G4endl;
 #endif
 
   //Build 5 points at the shower max. edges and far end
@@ -267,42 +275,46 @@ G4bool LArFastShower::CheckContainment(const G4FastTrack &fastTrack)
   G4double R = showerLibSvc()->getContainmentR(fastTrack,m_configuration.m_detector_tag);
 
   if (Z == 0.0 && R == 0.0) {
-    //no containment check
+    // no containment check
     return true;
   }
-  G4double Zmx = Z / 3; //<-here is OUR magic number. looking on the hit distribution plot, it seems that that way most of hits will be inside
 
-  G4int CosPhi[4] = {1,0,-1,0};
-  G4int SinPhi[4] = {0,1,0,-1};
+  // Here is OUR magic number. Looking on the hit distribution plot,
+  // it seems that that way most of hits will be inside
+  G4double Zmx = Z / 3;
+
+  G4int cosPhi[4] = {1,0,-1,0};
+  G4int sinPhi[4] = {0,1,0,-1};
 
 #ifdef _TRACE_FSM_
   G4cout << "LArFastShower::CheckContainment() R =          " << R   << G4endl;
   G4cout << "LArFastShower::CheckContainment() Z =          " << Z   << G4endl;
 #endif
 
-  G4ThreeVector Position;
+  G4ThreeVector position;
 
-  G4VSolid* SolidCalo = fastTrack.GetEnvelopeSolid();
-  const G4AffineTransform* AffineTransformation = fastTrack.GetAffineTransformation();
+  G4VSolid* caloSolid = fastTrack.GetEnvelopeSolid();
+  const G4AffineTransform* affineTransformation = fastTrack.GetAffineTransformation();
 
   //Startpoint
-  Position = InitialPositionShower;
-  AffineTransformation->ApplyPointTransform(Position);
-  if(SolidCalo->Inside(Position) == kOutside)
+  position = initialShowerPosition;
+  affineTransformation->ApplyPointTransform(position);
+  if(caloSolid->Inside(position) == kOutside)
     return false;
 
   //Longitudinal Endpoint
-  Position = InitialPositionShower + Z*DirectionShower;
-  AffineTransformation->ApplyPointTransform(Position);
-  if(SolidCalo->Inside(Position) == kOutside)
+  position = initialShowerPosition + Z*showerDirection;
+  affineTransformation->ApplyPointTransform(position);
+  if(caloSolid->Inside(position) == kOutside)
     return false;
 
   //Lateral Spread
   for(int i=0; i<4 ;i++)
     {
-      Position = InitialPositionShower + Zmx*DirectionShower + R*CosPhi[i]*OrthoShower + R*SinPhi[i]*CrossShower;
-      AffineTransformation->ApplyPointTransform(Position);
-      if(SolidCalo->Inside(Position) == kOutside)
+      position = initialShowerPosition + Zmx*showerDirection +
+                 R*cosPhi[i]*orthoShower + R*sinPhi[i]*crossShower;
+      affineTransformation->ApplyPointTransform(position);
+      if(caloSolid->Inside(position) == kOutside)
         return false;
     }
 
@@ -316,8 +328,8 @@ G4bool LArFastShower::CheckContainment(const G4FastTrack &fastTrack)
 
 HepMC::GenEvent * LArFastShower::GetGenEvent(const G4FastTrack &fastTrack)
 {
-  G4ThreeVector PositionShower = fastTrack.GetPrimaryTrack()->GetPosition();
-  G4ThreeVector MomentumShower = fastTrack.GetPrimaryTrack()->GetMomentum();
+  G4ThreeVector showerPos = fastTrack.GetPrimaryTrack()->GetPosition();
+  G4ThreeVector showerMom = fastTrack.GetPrimaryTrack()->GetMomentum();
 
   G4double energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
 
@@ -325,12 +337,15 @@ HepMC::GenEvent * LArFastShower::GetGenEvent(const G4FastTrack &fastTrack)
   if (pdgcode < 0) pdgcode = -pdgcode; // hack for positrons. let it be electrons.
 
   // new event. Signal processing = 0, event number "next"
-  HepMC::GenEvent * ge = new HepMC::GenEvent( 0, ++m_eventNum);
+  HepMC::GenEvent* ge = new HepMC::GenEvent( 0, ++m_eventNum);
   // vertex. Position of the shower, time = 0
-  HepMC::GenVertex * gv = new HepMC::GenVertex(HepMC::FourVector(PositionShower.x(),PositionShower.y(),PositionShower.z(),0));
+  HepMC::GenVertex* gv = new HepMC::GenVertex(
+      HepMC::FourVector(showerPos.x(), showerPos.y(), showerPos.z(), 0) );
   ge->add_vertex(gv);
   // particle. FourVector of the shower, pdgcode, status = 1
-  HepMC::GenParticle * gp = new HepMC::GenParticle(HepMC::FourVector(MomentumShower.x(),MomentumShower.y(),MomentumShower.z(),energy), pdgcode,1);
+  HepMC::GenParticle* gp = new HepMC::GenParticle(
+      HepMC::FourVector(showerMom.x(), showerMom.y(), showerMom.z(), energy),
+      pdgcode, 1 );
   gv->add_particle_out(gp);
 
   // return auto_pointer. will be deleted automatically
@@ -393,25 +408,25 @@ bool LArFastShower::generateFSStartingPoint( const HepMC::GenEvent * ge ) const
 }
 G4bool LArFastShower::ForcedAccept(const G4FastTrack & fastTrack)
 {
-  G4ThreeVector InitialPositionShower = fastTrack.GetPrimaryTrack()->GetPosition();
+  G4ThreeVector initialShowerPosition = fastTrack.GetPrimaryTrack()->GetPosition();
 
   // if ( !m_configuration.m_containHigh &&
-  //     ( InitialPositionShower.eta()>=m_configuration.m_absHighEta ||
-  //       InitialPositionShower.eta()<=-m_configuration.m_absHighEta ) ) return true;
+  //     ( initialShowerPosition.eta()>=m_configuration.m_absHighEta ||
+  //       initialShowerPosition.eta()<=-m_configuration.m_absHighEta ) ) return true;
 
   if ( !m_configuration.m_containHigh &&
-      ( InitialPositionShower.eta()>m_configuration.m_absHighEta ||
-        InitialPositionShower.eta()<-m_configuration.m_absHighEta ) ) return true;
+      ( initialShowerPosition.eta()>m_configuration.m_absHighEta ||
+        initialShowerPosition.eta()<-m_configuration.m_absHighEta ) ) return true;
 
   if ( !m_configuration.m_containCrack &&
-      ( ( InitialPositionShower.eta()>m_configuration.m_absCrackEta1 &&
-          InitialPositionShower.eta()<m_configuration.m_absCrackEta2 ) ||
-        ( InitialPositionShower.eta()<-m_configuration.m_absCrackEta1 &&
-          InitialPositionShower.eta()>-m_configuration.m_absCrackEta2 ) ) ) return true;
+      ( ( initialShowerPosition.eta()>m_configuration.m_absCrackEta1 &&
+          initialShowerPosition.eta()<m_configuration.m_absCrackEta2 ) ||
+        ( initialShowerPosition.eta()<-m_configuration.m_absCrackEta1 &&
+          initialShowerPosition.eta()>-m_configuration.m_absCrackEta2 ) ) ) return true;
 
   if ( !m_configuration.m_containLow &&
-      ( InitialPositionShower.eta()<m_configuration.m_absLowEta ||
-        InitialPositionShower.eta()>-m_configuration.m_absLowEta ) ) return true;
+      ( initialShowerPosition.eta()<m_configuration.m_absLowEta ||
+        initialShowerPosition.eta()>-m_configuration.m_absLowEta ) ) return true;
   return false;
 }
 
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShower.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShower.h
index 507380e3ab9..541532e5bd3 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShower.h
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShower.h
@@ -5,14 +5,17 @@
 #ifndef LARG4FASTSIMULATION_LARFASTSHOWER_H
 #define LARG4FASTSIMULATION_LARFASTSHOWER_H
 
+// STL includes
+#include <string>
+#include <map>
+
+// Geant4 includes
 #include "G4VFastSimulationModel.hh"
 
-// Needed by the tool handle
+// Local includes
 #include "FastShowerConfigStruct.h"
 
-#include <string>
-#include <map>
-
+// Forward declarations
 namespace HepMC {
   class GenEvent;
   class IO_GenEvent;
@@ -20,63 +23,76 @@ namespace HepMC {
 class IFastSimDedicatedSD;
 class ILArG4ShowerLibSvc;
 
-class LArFastShower: public G4VFastSimulationModel
+
+/// NEEDS DOCUMENTATION
+class LArFastShower : public G4VFastSimulationModel
 {
-public:
+  public:
 
-  LArFastShower(const std::string& name, const FastShowerConfigStruct& config, IFastSimDedicatedSD *fastSimDedicatedSD);  //!< Default constructor
+    /// Constructor
+    LArFastShower(const std::string& name, const FastShowerConfigStruct& config,
+                  IFastSimDedicatedSD* fastSimDedicatedSD);
 
-  virtual ~LArFastShower() {}                 //!< Default destructor
+    /// Empty destructor
+    virtual ~LArFastShower() {}
 
-  /** Determines the applicability of the fast sim model to this particle type
+    /** Determines the applicability of the fast sim model to this particle type
       Called once for each track picked up by Geant as it enters a region with the fast sim assigned to it.
       Currently returns false for all but photons and electrons.*/
-  G4bool IsApplicable(const G4ParticleDefinition&) override;
+    G4bool IsApplicable(const G4ParticleDefinition&) override;
 
-  /** Determines the applicability of the fast sim model to this particular track.
+    /** Determines the applicability of the fast sim model to this particular track.
       Checks that geometric location, energy, and particle type are within bounds.  Also checks for
       containment of the particle's shower within a specific detector region.*/
-  virtual G4bool ModelTrigger(const G4FastTrack &) override;
+    virtual G4bool ModelTrigger(const G4FastTrack &) override;
 
-  virtual G4bool ForcedAccept(const G4FastTrack &);//!< If it returns true, the particle will be parameterized without further checks
-  virtual G4bool ForcedDeny  (const G4FastTrack &); //!< If it returns true, the particle will be returned to G4 without further checks
+    virtual G4bool ForcedAccept(const G4FastTrack &);//!< If it returns true, the particle will be parameterized without further checks
+    virtual G4bool ForcedDeny  (const G4FastTrack &); //!< If it returns true, the particle will be returned to G4 without further checks
 
-  /** Assigns the track to the appropriate method for application of the fast simulation.
+    /** Assigns the track to the appropriate method for application of the fast simulation.
       Only called if ModelTrigger returns true.*/
-  void DoIt(const G4FastTrack&, G4FastStep&) override;
+    void DoIt(const G4FastTrack&, G4FastStep&) override;
+
+  protected:
+
+    IFastSimDedicatedSD* fastShowerSD();
+    ILArG4ShowerLibSvc* showerLibSvc();
 
-private:
-  const FastShowerConfigStruct            m_configuration;
-protected:
+    /// Method to kill a particle and deposit its energy using exponential decay function
+    void KillParticle(const G4FastTrack&, G4FastStep&);
+    /// Function for the application of shower library
+    void UseShowerLib(const G4FastTrack&, G4FastStep&);
 
-  IFastSimDedicatedSD *m_FastSimDedicatedSD;   //!< Shower library sensitive detector for this shower
-  IFastSimDedicatedSD* fastShowerSD();
-  ILArG4ShowerLibSvc *m_showerLibSvc;       //!< Pointer to the shower library service
-  ILArG4ShowerLibSvc* showerLibSvc();
+    /// Function to check the containment of a shower within a regular detector region
+    virtual G4bool CheckContainment(const G4FastTrack &fastTrack);
 
-  // Method to kill a particle and deposit its energy using exponential decay function
-  void KillParticle(const G4FastTrack&, G4FastStep&);    //!< Simple kill function for low energy particles
-  void UseShowerLib(const G4FastTrack&, G4FastStep&);    //!< Function for the application of shower library
+    HepMC::GenEvent* GetGenEvent(const G4FastTrack &fastTrack);
 
-  virtual G4bool CheckContainment(const G4FastTrack &fastTrack); //!< Function to check the containment of a shower within a regular detector region
+    /// get switch for frozen showers
+    bool   flagToShowerLib  ( const G4ParticleDefinition& particleType ) const;
+    /// get lower energy limit for frozen showers
+    double maxEneToShowerLib( const G4ParticleDefinition& particleType ) const;
+    /// get upper energy limit for frozen showers
+    double minEneToShowerLib( const G4ParticleDefinition& particleType ) const;
 
-  HepMC::GenEvent * GetGenEvent(const G4FastTrack &fastTrack);
+    bool generateFSStartingPoint( const HepMC::GenEvent * ge) const;
 
-  // data members for configuration
-  bool             m_generate_starting_points;
-  HepMC::IO_GenEvent *m_starting_points_file;
-  std::string     m_detector_tag_str;
-  std::map<std::string,int> m_detmap;
+  private:
+    const FastShowerConfigStruct m_configuration;
 
-  bool   flagToShowerLib  ( const G4ParticleDefinition& particleType ) const;          //!< get switch for frozen showers
-  double maxEneToShowerLib( const G4ParticleDefinition& particleType ) const;          //!< get lower energy limit for frozen showers
-  double minEneToShowerLib( const G4ParticleDefinition& particleType ) const;          //!< get upper energy limit for frozen showers
+    /// Shower library sensitive detector for this shower
+    IFastSimDedicatedSD *m_fastSimDedicatedSD;
+    /// Pointer to the shower library service
+    ILArG4ShowerLibSvc *m_showerLibSvc;
 
-  bool              generateFSStartingPoint( const HepMC::GenEvent * ge) const;
+    // data members for configuration
+    bool m_generate_starting_points;
+    HepMC::IO_GenEvent* m_starting_points_file;
+    std::string m_detector_tag_str;
+    std::map<std::string,int> m_detmap;
 
-private:
-  int m_eventNum;
-  std::map<int,bool> m_applicableMap;
+    int m_eventNum;
+    std::map<int,bool> m_applicableMap;
 
 };
 
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.cxx
index 9f91b326887..7f2fa604fa6 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.cxx
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.cxx
@@ -9,12 +9,11 @@
 #include "LArFastShower.h"
 #include "G4SDManager.hh"
 
-LArFastShowerTool::LArFastShowerTool(const std::string& type, const std::string& name, const IInterface *parent):
-  FastSimulationBase(type,name,parent),
-  m_FastSimDedicatedSD (""), //Empty by default. FIXME Currently
-                             //public tool to reproduce old output,
-                             //switch to be private tool eventually.
-  m_showerLibSvc( "LArG4ShowerLibSvc" , name )
+LArFastShowerTool::LArFastShowerTool(const std::string& type, const std::string& name,
+                                     const IInterface *parent)
+  : FastSimulationBase(type, name, parent),
+    m_fastSimDedicatedSD (""), // Empty by default.
+    m_showerLibSvc("LArG4ShowerLibSvc", name)
 {
   declareProperty("EFlagToShowerLib", m_configuration.m_e_FlagShowerLib = true, "Switch for e+/- frozen showers");
   declareProperty("EMinEneShowerLib", m_configuration.m_e_MinEneShowerLib = 0.0*CLHEP::GeV, "Minimum energy for e+/- frozen showers");
@@ -32,27 +31,28 @@ LArFastShowerTool::LArFastShowerTool(const std::string& type, const std::string&
   declareProperty("PionMinEneShowerLib", m_configuration.m_Pion_MinEneShowerLib = 0.0*CLHEP::GeV, "Minimum energy for neutron frozen showers");
   declareProperty("PionMaxEneShowerLib", m_configuration.m_Pion_MaxEneShowerLib = 2.0*CLHEP::GeV, "Maximum energy for neutron frozen showers");
 
-  declareProperty("ContainLow",          m_configuration.m_containLow = true, "Switch for containment at low eta");
-  declareProperty("AbsLowEta",           m_configuration.m_absLowEta, "");
-  declareProperty("ContainHigh",         m_configuration.m_containHigh = true, "Switch for containment at high eta");
-  declareProperty("AbsHighEta",          m_configuration.m_absHighEta, "");
-  declareProperty("ContainCrack",        m_configuration.m_containCrack = true, "Switch for containment in the crack region");
-  declareProperty("AbsCrackEta1",        m_configuration.m_absCrackEta1, "");
-  declareProperty("AbsCrackEta2",        m_configuration.m_absCrackEta2, "");
+  declareProperty("ContainLow",   m_configuration.m_containLow = true, "Switch for containment at low eta");
+  declareProperty("AbsLowEta",    m_configuration.m_absLowEta, "");
+  declareProperty("ContainHigh",  m_configuration.m_containHigh = true, "Switch for containment at high eta");
+  declareProperty("AbsHighEta",   m_configuration.m_absHighEta, "");
+  declareProperty("ContainCrack", m_configuration.m_containCrack = true, "Switch for containment in the crack region");
+  declareProperty("AbsCrackEta1", m_configuration.m_absCrackEta1, "");
+  declareProperty("AbsCrackEta2", m_configuration.m_absCrackEta2, "");
 
-  declareProperty("GeneratedStartingPointsFile", m_configuration.m_generated_starting_points_file = "", "Name of file for generated SPs. Do not touch until you want to produce a new library");
+  declareProperty("GeneratedStartingPointsFile", m_configuration.m_generated_starting_points_file = "",
+                  "Name of file for generated SPs. Do not touch until you want to produce a new library");
   declareProperty("GeneratedStartingPointsRatio", m_configuration.m_generated_starting_points_ratio = 0.02, "Ratio of SPs that goes to output");
   declareProperty("DetectorTag", m_configuration.m_detector_tag, "Which detector is this?");
-  declareProperty("SensitiveDetector" , m_FastSimDedicatedSD , "Fast sim dedicated SD for this setup");
+  declareProperty("SensitiveDetector" , m_fastSimDedicatedSD , "Fast sim dedicated SD for this setup");
   declareProperty("ShowerLibSvc" , m_showerLibSvc, "Handle on the shower library service");
-  m_configuration.m_showerLibSvcName=m_showerLibSvc.name();
+  m_configuration.m_showerLibSvcName = m_showerLibSvc.name();
 
   declareInterface<IFastSimulation>(this);
 }
 
 StatusCode LArFastShowerTool::initialize()
 {
-  ATH_MSG_VERBOSE( name() << "::initialize()");
+  ATH_MSG_VERBOSE( name() << "::initialize()" );
   CHECK( m_showerLibSvc.retrieve() );
   return FastSimulationBase::initialize();
 }
@@ -60,23 +60,24 @@ StatusCode LArFastShowerTool::initialize()
 G4VFastSimulationModel* LArFastShowerTool::makeFastSimModel()
 {
   ATH_MSG_DEBUG( "Initializing Fast Sim Model" );
-  IFastSimDedicatedSD * fastSD = dynamic_cast<IFastSimDedicatedSD*>(G4SDManager::GetSDMpointer()->FindSensitiveDetector(m_FastSimDedicatedSD,false));
+  IFastSimDedicatedSD* fastSD = dynamic_cast<IFastSimDedicatedSD*>(
+    G4SDManager::GetSDMpointer()->FindSensitiveDetector(m_fastSimDedicatedSD, false) );
   if (fastSD){
-    ATH_MSG_INFO( "SD " << m_FastSimDedicatedSD << " already created." );
-  } else if ("BarrelFastSimDedicatedSD"==m_FastSimDedicatedSD){
+    ATH_MSG_INFO( "SD " << m_fastSimDedicatedSD << " already created." );
+  } else if ("BarrelFastSimDedicatedSD" == m_fastSimDedicatedSD){
     fastSD = new BarrelFastSimDedicatedSD( &*detStore() );
-  } else if ("EndcapFastSimDedicatedSD"==m_FastSimDedicatedSD){
+  } else if ("EndcapFastSimDedicatedSD" == m_fastSimDedicatedSD){
     fastSD = new EndcapFastSimDedicatedSD( &*detStore() );
-  } else if ("FCALFastSimDedicatedSD"==m_FastSimDedicatedSD){
+  } else if ("FCALFastSimDedicatedSD" == m_fastSimDedicatedSD){
     fastSD = new FCALFastSimDedicatedSD( &*detStore() );
   } else {
-    ATH_MSG_FATAL( "Fast sim SD type " << m_FastSimDedicatedSD << " not found!" );
+    ATH_MSG_FATAL( "Fast sim SD type " << m_fastSimDedicatedSD << " not found!" );
     throw std::runtime_error("Bad SD name");
   }
   G4SDManager::GetSDMpointer()->AddNewDetector(fastSD);
 
   // Create a fresh Fast Sim Model
-  return new LArFastShower(name(),m_configuration, fastSD);
+  return new LArFastShower(name(), m_configuration, fastSD);
 }
 
 StatusCode LArFastShowerTool::EndOfAthenaEvent()
diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.h
index bbc2c4a5652..88a951f4227 100644
--- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.h
+++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.h
@@ -18,6 +18,7 @@
 
 class G4FastSimulationModel;
 
+/// NEEDS DOCUMENTATION
 class LArFastShowerTool: public FastSimulationBase
 {
 public:
@@ -37,7 +38,7 @@ protected:
   virtual G4VFastSimulationModel* makeFastSimModel() override final;
 
 private:
-  std::string                       m_FastSimDedicatedSD; //!< Shower library sensitive detector for this shower
+  std::string                       m_fastSimDedicatedSD; //!< Shower library sensitive detector for this shower
   ServiceHandle<ILArG4ShowerLibSvc> m_showerLibSvc;       //!< Pointer to the shower library service
   FastShowerConfigStruct            m_configuration;
 };
-- 
GitLab