From e7c28a8bbef8b5b0d66d45e8a81aa0e81a00867a Mon Sep 17 00:00:00 2001
From: Dave Casper <dcasper@localhost.localdomain>
Date: Sat, 14 Sep 2019 23:34:19 -0700
Subject: [PATCH] SCT in simulation (without sensitive detector yet)

---
 .../FaserGeoModel/python/SCTGMConfig.py       |  2 +-
 Simulation/G4Faser/G4FaserApp/test/runG4.py   |  4 ++--
 .../python/G4FaserServicesConfigNew.py        | 23 ++++++++-----------
 .../G4FaserTools/python/G4FieldConfigNew.py   | 10 ++++++++
 .../python/G4GeometryToolConfig.py            | 12 ++++++++++
 .../python/G4PhysicsRegionConfigNew.py        |  8 +++++++
 .../python/FaserSCT_GeoModelConfig.py         |  4 ++--
 .../test/FaserSCT_GMConfig_test.py            |  2 +-
 .../TrackerGeoModelUtils/CMakeLists.txt       |  3 ++-
 .../src/DistortedMaterialManager.cxx          |  4 ++--
 .../src/ServiceVolumeMaker.cxx                |  2 +-
 11 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/DetectorDescription/GeoModel/FaserGeoModel/python/SCTGMConfig.py b/DetectorDescription/GeoModel/FaserGeoModel/python/SCTGMConfig.py
index bee84266..e4815c75 100644
--- a/DetectorDescription/GeoModel/FaserGeoModel/python/SCTGMConfig.py
+++ b/DetectorDescription/GeoModel/FaserGeoModel/python/SCTGMConfig.py
@@ -24,7 +24,7 @@ if __name__ == "__main__":
   Configurable.configurableRun3Behavior = True
   ConfigFlags.addFlag("GeoModel.FaserVersion", "Faser-00")
   ConfigFlags.addFlag("Detector.SimulateVeto", True)
-  ConfigFlags.addFlag("Detector.SimulateSCT", True)
+  ConfigFlags.addFlag("Detector.SimulateFaserSCT", True)
 
   # from AthenaConfiguration.TestDefaults import defaultTestFiles
   # Provide MC input
diff --git a/Simulation/G4Faser/G4FaserApp/test/runG4.py b/Simulation/G4Faser/G4FaserApp/test/runG4.py
index 311e0e09..3799e2cf 100644
--- a/Simulation/G4Faser/G4FaserApp/test/runG4.py
+++ b/Simulation/G4Faser/G4FaserApp/test/runG4.py
@@ -65,8 +65,8 @@ if __name__ == "__main__":
 #
     ConfigFlags.Detector.SimulateVeto   = True
     ConfigFlags.Detector.GeometryVeto   = True
-    ConfigFlags.Detector.SimulateSCT   = True
-    ConfigFlags.Detector.GeometrySCT   = True
+    ConfigFlags.Detector.SimulateFaserSCT   = True
+    ConfigFlags.Detector.GeometryFaserSCT   = True
     ConfigFlags.GeoModel.Align.Dynamic  = False
     ConfigFlags.Sim.ReleaseGeoModel     = False
 #
diff --git a/Simulation/G4Faser/G4FaserServices/python/G4FaserServicesConfigNew.py b/Simulation/G4Faser/G4FaserServices/python/G4FaserServicesConfigNew.py
index 96c70235..b26b6b33 100644
--- a/Simulation/G4Faser/G4FaserServices/python/G4FaserServicesConfigNew.py
+++ b/Simulation/G4Faser/G4FaserServices/python/G4FaserServicesConfigNew.py
@@ -8,7 +8,7 @@ from G4AtlasServices.G4AtlasServicesConf import DetectorGeometrySvc, G4AtlasSvc,
 #
 #  Physics region tools
 #
-from G4FaserTools.G4PhysicsRegionConfigNew import ScintillatorPhysicsRegionToolCfg #, TrackerPhysicsRegionToolCfg, FaserCaloPhysicsRegionToolCfg
+from G4FaserTools.G4PhysicsRegionConfigNew import ScintillatorPhysicsRegionToolCfg, TrackerPhysicsRegionToolCfg #, FaserCaloPhysicsRegionToolCfg
 from G4FaserServices.G4FaserServicesConf import ISF__FaserGeoIDSvc
 #
 #  Geometry tools
@@ -21,7 +21,8 @@ from G4FaserTools.G4FieldConfigNew import FASERFieldManagerToolCfg, VetoFieldMan
 #
 #  Future field managers (?)
 #
-# from G4FaserTools.G4FieldConfigNew import TriggerFieldManagerToolCfg, PreshowerFieldManagerToolCfg, UpstreamTrackerFieldManagerToolCfg, CentralTrackerFieldManagerToolCfg, DownstreamTrackerFieldManagerToolCfg, UpstreamDipoleFieldManagerToolCfg, CentralDipoleFieldManagerToolCfg, DownstreamDipleFieldManagerToolCfg, FaserCaloFieldManagerToolCfg
+# from G4FaserTools.G4FieldConfigNew import TriggerFieldManagerToolCfg, PreshowerFieldManagerToolCfg, UpstreamDipoleFieldManagerToolCfg, CentralDipoleFieldManagerToolCfg, DownstreamDipleFieldManagerToolCfg, FaserCaloFieldManagerToolCfg
+from G4FaserTools.G4FieldConfigNew import TrackerFieldManagerToolCfg
 #
 #
 def FaserGeoIDSvcCfg(ConfigFlags, name="ISF_FaserGeoIDSvc", **kwargs):
@@ -41,8 +42,8 @@ def getFASER_RegionCreatorList(ConfigFlags):
     if ConfigFlags.Detector.SimulateScintillator:
         regionCreatorList += [ScintillatorPhysicsRegionToolCfg(ConfigFlags)]
 
-    # if ConfigFlags.Detector.SimulateTracker:
-    #     regionCreatorList += [TrackerPhysicsRegionToolCfg(ConfigFlags)]
+    if ConfigFlags.Detector.SimulateTracker:
+        regionCreatorList += [TrackerPhysicsRegionToolCfg(ConfigFlags)]
 
     # if ConfigFlags.Detector.SimulateFaserCalo:
     #     regionCreatorList += [FaserCaloPhysicsRegionToolCfg(ConfigFlags)]
@@ -82,16 +83,10 @@ def FASER_FieldMgrListCfg(ConfigFlags):
     #     acc = PreshowerFieldManagerToolCfg(ConfigFlags)
     #     tool = result.popToolsAndMerge(acc)
     #     fieldMgrList += [tool]
-    # if ConfigFlags.Detector.SimulateTracker:
-    #     acc = UpstreamTrackerFieldManagerToolCfg(ConfigFlags)
-    #     tool  = result.popToolsAndMerge(acc)
-    #     fieldMgrList += [tool]
-    #     acc = CentralTrackerFieldManagerToolCfg(ConfigFlags)
-    #     tool  = result.popToolsAndMerge(acc)
-    #     fieldMgrList += [tool]
-    #     acc = DownstreamTrackerFieldManagerToolCfg(ConfigFlags)
-    #     tool  = result.popToolsAndMerge(acc)
-    #     fieldMgrList += [tool]
+    if ConfigFlags.Detector.SimulateTracker:
+        acc = TrackerFieldManagerToolCfg(ConfigFlags)
+        tool  = result.popToolsAndMerge(acc)
+        fieldMgrList += [tool]
     # if ConfigFlags.Detector.SimulateFaserCalo:
     #     acc = FaserCaloFieldManagerToolCfg(ConfigFlags)
     #     tool  = result.popToolsAndMerge(acc)
diff --git a/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py b/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py
index 2b2ede24..64ae2125 100644
--- a/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py
+++ b/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py
@@ -96,6 +96,16 @@ def VetoFieldManagerToolCfg(ConfigFlags, name='VetoFieldManager', **kwargs):
     kwargs.setdefault('MinimumEpsilonStep', 0.00001)
     return BasicDetectorConstantFieldManagerToolCfg(ConfigFlags, name, **kwargs)
 
+
+def TrackerFieldManagerToolCfg(ConfigFlags, name='TrackerFieldManager', **kwargs):
+    kwargs.setdefault("LogicalVolumes", ['SCT::Station'])
+    #kwargs.setdefault('DeltaChord',         0.00001)
+    kwargs.setdefault('DeltaIntersection',  0.00001)
+    kwargs.setdefault('DeltaOneStep',       0.0001)
+    kwargs.setdefault('MaximumEpsilonStep', 0.001)
+    kwargs.setdefault('MinimumEpsilonStep', 0.00001)
+    return BasicDetectorConstantFieldManagerToolCfg(ConfigFlags, name, **kwargs)
+
 # def BeamPipeFieldManagerToolCfg(ConfigFlags, name='BeamPipeFieldManager', **kwargs):
 #     kwargs.setdefault("LogicalVolumes", ['BeamPipe::BeamPipe'])
 #     #kwargs.setdefault('DeltaChord',         0.00001)
diff --git a/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py b/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py
index b48c9ebe..7cc2a317 100644
--- a/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py
+++ b/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py
@@ -7,6 +7,7 @@ from G4AtlasTools.G4AtlasToolsConf import CylindricalEnvelope, PolyconicalEnvelo
 
 from AthenaCommon.SystemOfUnits import mm, cm, m
 from VetoGeoModel.VetoGeoModelConfig import VetoGeometryCfg
+from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg
 
 #ToDo - finish migrating this (dnoel)
 #Todo - just return component accumulator
@@ -19,6 +20,12 @@ def VetoGeoDetectorToolCfg(ConfigFlags, name='Veto', **kwargs):
     kwargs.setdefault("DetectorName", "Veto")
     return result, GeoDetectorTool(name, **kwargs)
 
+def SCTGeoDetectorToolCfg(ConfigFlags, name='SCT', **kwargs):
+    #set up geometry
+    result=FaserSCT_GeometryCfg(ConfigFlags)
+    kwargs.setdefault("DetectorName", "SCT")
+    return result, GeoDetectorTool(name, **kwargs)
+
 def generateSubDetectorList(ConfigFlags):
     result = ComponentAccumulator()
     SubDetectorList=[]
@@ -28,6 +35,11 @@ def generateSubDetectorList(ConfigFlags):
         SubDetectorList += [ toolVeto ]
         result.merge(accVeto)
 
+    if ConfigFlags.Detector.SimulateFaserSCT:
+        accSCT, toolSCT = SCTGeoDetectorToolCfg(ConfigFlags)
+        SubDetectorList += [ toolSCT ]
+        result.merge(accSCT)
+
     return result, SubDetectorList
 
 def FASEREnvelopeCfg(ConfigFlags, name="Faser", **kwargs):
diff --git a/Simulation/G4Faser/G4FaserTools/python/G4PhysicsRegionConfigNew.py b/Simulation/G4Faser/G4FaserTools/python/G4PhysicsRegionConfigNew.py
index 3dab4476..092950bd 100644
--- a/Simulation/G4Faser/G4FaserTools/python/G4PhysicsRegionConfigNew.py
+++ b/Simulation/G4Faser/G4FaserTools/python/G4PhysicsRegionConfigNew.py
@@ -71,6 +71,14 @@ def ScintillatorPhysicsRegionToolCfg(ConfigFlags, name='ScintillatorPhysicsRegio
     kwargs.setdefault("GammaCut",    0.05)
     return RegionCreator(name, **kwargs)
 
+def TrackerPhysicsRegionToolCfg(ConfigFlags, name="TrackerPhysicsRegionTool", **kwargs):
+    kwargs.setdefault("RegionName", "Tracker")
+    volumeList = ['SCT::BRLSensor']
+    kwargs.setdefault("VolumeList", volumeList)
+    kwargs.setdefault("ElectronCut", 0.05)
+    kwargs.setdefault("PositronCut", 0.05)
+    kwargs.setdefault("GammaCut",    0.05)
+    return RegionCreator(name, **kwargs)
 
 # def SCTPhysicsRegionToolCfg(ConfigFlags, name='SCTPhysicsRegionTool', **kwargs):
 #     kwargs.setdefault("RegionName", 'SCT')
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py
index 647e449c..7c8e771c 100644
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py
@@ -38,12 +38,12 @@ def FaserSCT_GeometryCfg( flags ):
     #     acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL2/SCT","/Indet/AlignL2/SCT",className="CondAttrListCollection"))
     #     acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL3","/Indet/AlignL3",className="AlignableTransformContainer"))
     # else:
-    #     if (not flags.Detector.SimulateSCT) or flags.Detector.OverlaySCT:
+    #     if (not flags.Detector.SimulateFaserSCT) or flags.Detector.OverlaySCT:
     #         acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/Align","/Indet/Align",className="AlignableTransformContainer"))
     #     else:
     #         acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/Align","/Indet/Align"))
     # if flags.Common.Project is not "AthSimulation": # Protection for AthSimulation builds
-    #     if (not flags.Detector.SimulateSCT) or flags.Detector.OverlaySCT:
+    #     if (not flags.Detector.SimulateFaserSCT) or flags.Detector.OverlaySCT:
     #         from SCT_ConditionsAlgorithms.SCT_ConditionsAlgorithmsConf import SCT_AlignCondAlg
     #         sctAlignCondAlg = SCT_AlignCondAlg(name = "SCT_AlignCondAlg",
     #                                            UseDynamicAlignFolders = flags.GeoModel.Align.Dynamic)
diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/test/FaserSCT_GMConfig_test.py b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/test/FaserSCT_GMConfig_test.py
index c72b8ad2..13b78ebe 100755
--- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/test/FaserSCT_GMConfig_test.py
+++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/test/FaserSCT_GMConfig_test.py
@@ -11,7 +11,7 @@ if __name__ == "__main__":
 
     ConfigFlags.Input.Files = defaultTestFiles.HITS
     ConfigFlags.IOVDb.GlobalTag         = "OFLCOND-MC16-SDR-16"
-    ConfigFlags.Detector.SimulateSCT    = False
+    ConfigFlags.Detector.SimulateFaserSCT    = False
     ConfigFlags.GeoModel.Align.Dynamic  = False
     ConfigFlags.lock()
 
diff --git a/Tracker/TrackerDetDescr/TrackerGeoModelUtils/CMakeLists.txt b/Tracker/TrackerDetDescr/TrackerGeoModelUtils/CMakeLists.txt
index ba356f00..c1afb08a 100644
--- a/Tracker/TrackerDetDescr/TrackerGeoModelUtils/CMakeLists.txt
+++ b/Tracker/TrackerDetDescr/TrackerGeoModelUtils/CMakeLists.txt
@@ -14,6 +14,7 @@ atlas_depends_on_subdirs( PUBLIC
                           Control/StoreGate
                           DetectorDescription/GeoModel/GeoModelInterfaces
                           DetectorDescription/GeoModel/GeoModelUtilities
+                          DetectorDescription/GeoModel/GeoModelFaserUtilities
                           DetectorDescription/GeoPrimitives
                           DetectorDescription/GeometryDBSvc )
 
@@ -30,5 +31,5 @@ atlas_add_library( TrackerGeoModelUtils
                    INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
                    DEFINITIONS ${CLHEP_DEFINITIONS}
                    LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaKernel GaudiKernel StoreGateLib SGtests
-                   PRIVATE_LINK_LIBRARIES GeoModelUtilities )
+                   PRIVATE_LINK_LIBRARIES GeoModelUtilities GeoModelFaserUtilities )
 
diff --git a/Tracker/TrackerDetDescr/TrackerGeoModelUtils/src/DistortedMaterialManager.cxx b/Tracker/TrackerDetDescr/TrackerGeoModelUtils/src/DistortedMaterialManager.cxx
index 321fa22c..329f28e0 100755
--- a/Tracker/TrackerDetDescr/TrackerGeoModelUtils/src/DistortedMaterialManager.cxx
+++ b/Tracker/TrackerDetDescr/TrackerGeoModelUtils/src/DistortedMaterialManager.cxx
@@ -5,7 +5,7 @@
 
 #include "TrackerGeoModelUtils/DistortedMaterialManager.h"
 #include "GeoModelInterfaces/StoredMaterialManager.h"
-#include "GeoModelUtilities/DecodeVersionKey.h"
+#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h"
 #include "AthenaKernel/MsgStreamMember.h"
 #include "StoreGate/StoreGate.h"
 #include "RDBAccessSvc/IRDBAccessSvc.h"
@@ -29,7 +29,7 @@ namespace TrackerDD {
     if (sc.isFailure()) log << MSG::FATAL << "Could not locate RDBAccessSvc" << endmsg;
 
     // Get version tag and node for Tracker.
-    DecodeVersionKey versionKey("Tracker");
+    DecodeFaserVersionKey versionKey("Tracker");
     std::string detectorKey = versionKey.tag();
     std::string detectorNode = versionKey.node();
 
diff --git a/Tracker/TrackerDetDescr/TrackerGeoModelUtils/src/ServiceVolumeMaker.cxx b/Tracker/TrackerDetDescr/TrackerGeoModelUtils/src/ServiceVolumeMaker.cxx
index f3e409f4..d930bf90 100755
--- a/Tracker/TrackerDetDescr/TrackerGeoModelUtils/src/ServiceVolumeMaker.cxx
+++ b/Tracker/TrackerDetDescr/TrackerGeoModelUtils/src/ServiceVolumeMaker.cxx
@@ -6,7 +6,7 @@
 #include "TrackerGeoModelUtils/ServiceVolume.h"
 #include "TrackerGeoModelUtils/TrackerDDAthenaComps.h"
 
-#include "GeoModelUtilities/DecodeVersionKey.h"
+#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h"
 
 #include "RDBAccessSvc/IRDBRecordset.h"
 #include "GeometryDBSvc/IGeometryDBSvc.h"
-- 
GitLab