From 4320fc93af639396b864096fca927467e5f88624 Mon Sep 17 00:00:00 2001
From: Nicolas Koehler <nicolas.koehler@cern.ch>
Date: Mon, 24 Feb 2020 15:50:24 +0000
Subject: [PATCH] Add muonLayout option to VP1

---
 .../GeoModelStandalone/DumpGeo/share/dump-geo |  8 -----
 .../DumpGeo/share/dump-geo.py                 |  9 ------
 graphics/VP1/VP1Algs/share/vp1                | 17 ++++++-----
 graphics/VP1/VP1Algs/share/vp1.py             | 29 ++++++++-----------
 4 files changed, 22 insertions(+), 41 deletions(-)

diff --git a/DetectorDescription/GeoModel/GeoModelStandalone/DumpGeo/share/dump-geo b/DetectorDescription/GeoModel/GeoModelStandalone/DumpGeo/share/dump-geo
index 5d0f827c48c..62fd52b32a5 100755
--- a/DetectorDescription/GeoModel/GeoModelStandalone/DumpGeo/share/dump-geo
+++ b/DetectorDescription/GeoModel/GeoModelStandalone/DumpGeo/share/dump-geo
@@ -99,7 +99,6 @@ FLAG_MC=0
 FLAG_FATRAS=0
 FLAG_NOGUI=0
 FLAG_CGAL=0
-FLAG_NSW=0
 FLAG_SLHC=0
 FLAG_CUSTOMGEOMETRY=0
 MULTINP_SRC=""
@@ -173,8 +172,6 @@ while [ $i -le $# ]; do
 	FLAG_NOGUI=1
     elif [ "x${arg}" == "x-cgal" ]; then
 	FLAG_CGAL=1
-    elif [ "x${arg}" == "x-nsw" ]; then
-	FLAG_NSW=1
     elif [ "x${arg}" == "x-slhc" ]; then
         echo "SLHC Mode: ON"
         FLAG_SLHC=1
@@ -701,7 +698,6 @@ if [ "x$TREETOPFILTER" != "x" ]; then
 fi
 if [ "x$FLAG_FORCE" != "x0" ]; then
     #if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
-    #OPTS="${OPTS}vp1NSW=True"
     export DUMPGEOOVERWRITE=$FLAG_FORCE
     echo "User's Overwrite local geometry dump file, if present: ${DUMPGEOOVERWRITE}"
 fi
@@ -808,10 +804,6 @@ if [ "x$FLAG_FATRAS" != "x0" ]; then
     if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
     OPTS="${OPTS}vp1Fatras=True"
 fi
-if [ "x$FLAG_NSW" != "x0" ]; then
-    if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
-    OPTS="${OPTS}vp1NSW=True"
-fi
 if [ "x$FLAG_SLHC" != "x0" ]; then
     if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
     OPTS="${OPTS}vp1SLHC=True"
diff --git a/DetectorDescription/GeoModel/GeoModelStandalone/DumpGeo/share/dump-geo.py b/DetectorDescription/GeoModel/GeoModelStandalone/DumpGeo/share/dump-geo.py
index 291ddadb5d4..43cb96e9ed0 100644
--- a/DetectorDescription/GeoModel/GeoModelStandalone/DumpGeo/share/dump-geo.py
+++ b/DetectorDescription/GeoModel/GeoModelStandalone/DumpGeo/share/dump-geo.py
@@ -36,7 +36,6 @@ if not 'vp1ToyDetector' in dir(): vp1ToyDetector=False
 if not 'vp1GeoModelStats' in dir(): vp1GeoModelStats=False
 if not 'vp1NoAutoConf' in dir(): vp1NoAutoConf=False
 if not 'vp1Trig' in dir(): vp1Trig=False
-if not 'vp1NSW' in dir(): vp1NSW=False
 if not 'vp1CustomGeometry' in dir(): vp1CustomGeometry=False
 if not 'vp1SLHC' in dir(): vp1SLHC=False
 
@@ -61,10 +60,6 @@ if ( vp1FatrasTruthKey != "" and not vp1Fatras ):
     vp1CfgErr("FatrasTruthKey set but Fatras not enabled. Unsetting FatrasTruthKey.")
     vp1FatrasTruthKey=""
 
-if (vp1NSW and not vp1Muon):
-    vp1CfgErr("Muon New Small Wheel (NSW) turned on, but no Muon geometry. Disabling NSW.")
-    vp1NSW=False
-
 #print "*** VP1 NOTE *** setting COIN_GLXGLUE env vars to make screenshots working remotely..."
 #print "*** VP1 NOTE *** COIN_GLXGLUE_NO_GLX13_PBUFFERS=1 - " + "COIN_GLXGLUE_NO_PBUFFERS=1"
 #os.putenv("COIN_GLXGLUE_NO_GLX13_PBUFFERS","1")
@@ -180,7 +175,6 @@ if (vp1ForwardRegion): DetFlags.FwdRegion_setOn()
 else:          DetFlags.FwdRegion_setOff()
 if (vp1ZDC): DetFlags.ZDC_setOn()
 else:          DetFlags.ZDC_setOff()
-if (vp1NSW): DetFlags.Micromegas_setOn() #FIXME - sTGC?
 DetFlags.Print()
 if (vp1CustomGeometry):
     print "Configuring Custom geometry."
@@ -238,9 +232,6 @@ if vp1ToyDetector:
 #  - Muon is ON
 #  - Major geometry version is greater than 10
 if (vp1Muon):
-    if (vp1NSW):
-      #DetDescrVersion="ATLAS-GEO-21-00-01"
-      include('MuonGeoModelTest/NSWGeoSetup.py')
 
     from AtlasGeoModel import Agdd2Geo
 
diff --git a/graphics/VP1/VP1Algs/share/vp1 b/graphics/VP1/VP1Algs/share/vp1
index 9383d791e3f..b7605277790 100755
--- a/graphics/VP1/VP1Algs/share/vp1
+++ b/graphics/VP1/VP1Algs/share/vp1
@@ -129,6 +129,7 @@ FLAG_DATA=0
 FLAG_TEST=0
 ERRORS=""
 DETDESCRTAG=""
+MUONLAYOUT=""
 NSWAGDDFILE=""
 GLOBCONDTAG=""
 SKIPEVENTS=""
@@ -166,7 +167,6 @@ FLAG_MC=0
 FLAG_FATRAS=0
 FLAG_NOGUI=0
 FLAG_CGAL=0
-FLAG_NSW=0
 FLAG_SLHC=0
 #FLAG_CUSTOMGEOMETRY=0 # currently not used
 FLAG_ADVANCED_ANTIALIASING=0
@@ -307,8 +307,6 @@ while [ $i -le $# ]; do
 	FLAG_NOGUI=1
     elif [ "x${arg}" == "x-cgal" ]; then
 	FLAG_CGAL=1
-    elif [ "x${arg}" == "x-nsw" ]; then
-	FLAG_NSW=1
     elif [ "x${arg}" == "x-slhc" ]; then
         echo "SLHC"
         FLAG_SLHC=1
@@ -331,6 +329,11 @@ while [ $i -le $# ]; do
 	if [ "x$DETDESCRTAG_2" == "x" ]; then
 	    ERRORS="$ERRORS\nNeed argument to -detdescr. Example: -detdescr=ATLAS-GEO-20-00-01"
 	fi
+    elif [ "x${arg:0:12}" == "x-muonLayout=" ]; then
+	MUONLAYOUT=${arg:12:$((${#arg}-12))}
+	if [ "x$MUONLAYOUT" == "x" ]; then
+	    ERRORS="$ERRORS\nNeed argument to -muonLayout. Example: -muonLayout=MuonSpectrometer-R.09.00.AsymNSW"
+	fi
     elif [ "x${arg:0:9}" == "x-nswagdd=" ]; then
 	NSWAGDDFILE=${arg:9:$((${#arg}-9))}
 	if [ "x$NSWAGDDFILE" == "x" ]; then
@@ -920,6 +923,10 @@ if [ "x$DETDESCRTAG" != "x" ]; then
     if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
     OPTS="${OPTS}DetDescrVersion=\"$DETDESCRTAG\""
 fi
+if [ "x$MUONLAYOUT" != "x" ]; then
+    if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
+    OPTS="${OPTS}vp1MuonLayout=\"$MUONLAYOUT\""
+fi
 if [ "x$NSWAGDDFILE" != "x" ]; then
     if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
     OPTS="${OPTS}vp1NSWAGDDFiles=[\"${NSWAGDDFILE}\"]"
@@ -1040,10 +1047,6 @@ if [ "x$FLAG_FATRAS" != "x0" ]; then
     if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
     OPTS="${OPTS}vp1Fatras=True"
 fi
-if [ "x$FLAG_NSW" != "x0" ]; then
-    if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
-    OPTS="${OPTS}vp1NSW=True"
-fi
 if [ "x$FLAG_SLHC" != "x0" ]; then
     if [ "x$OPTS" != "x" ]; then OPTS="$OPTS;"; fi
     OPTS="${OPTS}vp1SLHC=True"
diff --git a/graphics/VP1/VP1Algs/share/vp1.py b/graphics/VP1/VP1Algs/share/vp1.py
index 15f8ba90a4c..cbde61703ff 100644
--- a/graphics/VP1/VP1Algs/share/vp1.py
+++ b/graphics/VP1/VP1Algs/share/vp1.py
@@ -35,8 +35,8 @@ if not 'vp1SpacePoints' in dir(): vp1SpacePoints=False
 if not 'vp1Cavern' in dir(): vp1Cavern=False
 if not 'vp1NoAutoConf' in dir(): vp1NoAutoConf=False
 if not 'vp1Trig' in dir(): vp1Trig=False
-if not 'vp1NSW' in dir(): vp1NSW=False
 if not 'vp1NSWAGDDFiles' in dir(): vp1NSWAGDDFiles=[]
+if not 'vp1MuonLayout' in dir(): vp1MuonLayout=""
 
 def vp1CfgErr(s): print "VP1 CONFIGURATION ERROR: %s" % s
 
@@ -59,13 +59,6 @@ if ( vp1FatrasTruthKey != "" and not vp1Fatras ):
     vp1CfgErr("FatrasTruthKey set but Fatras not enabled. Unsetting FatrasTruthKey.")
     vp1FatrasTruthKey=""
 
-if (vp1NSW and not vp1Muon):
-    vp1CfgErr("Muon New Small Wheel (NSW) turned on, but no Muon geometry. Disabling NSW.")
-    vp1NSW=False
-
-
-
-
 print "*** VP1 NOTE *** setting COIN_GLXGLUE env vars to make screenshots working remotely..."
 print "*** VP1 NOTE *** COIN_GLXGLUE_NO_GLX13_PBUFFERS=1 - " + "COIN_GLXGLUE_NO_PBUFFERS=1"
 os.putenv("COIN_GLXGLUE_NO_GLX13_PBUFFERS","1")
@@ -91,9 +84,6 @@ if (vp1InputFiles == []):
     # Set geometry version
     if (not "DetDescrVersion" in dir()):
         DetDescrVersion = "ATLAS-R2-2016-01-00-01" # default Run 2 geometry
-        if (vp1NSW): 
-            print("You set the '-nsw' flag, so the Geometry Tag 'ATLAS-R3S-2021-01-00-00' will be used...")
-            DetDescrVersion="ATLAS-R3S-2021-01-00-00"
 
     globalflags.DetDescrVersion = DetDescrVersion
     
@@ -249,7 +239,12 @@ if (vp1ID): DetFlags.ID_setOn()
 else:       DetFlags.ID_setOff()
 if (vp1Calo): DetFlags.Calo_setOn()
 else:         DetFlags.Calo_setOff()
-if (vp1Muon): DetFlags.Muon_setOn()
+if (vp1Muon):
+    DetFlags.Muon_setOn()
+    from AtlasGeoModel.MuonGMJobProperties import MuonGeometryFlags
+    if not MuonGeometryFlags.hasCSC(): DetFlags.CSC_setOff()
+    if not MuonGeometryFlags.hasMM(): DetFlags.Micromegas_setOff()
+    if not MuonGeometryFlags.hasSTGC(): DetFlags.sTGC_setOff()
 else:         DetFlags.Muon_setOff()
 if (vp1LUCID): DetFlags.Lucid_setOn()
 else:          DetFlags.Lucid_setOff()
@@ -259,11 +254,6 @@ if (vp1ForwardRegion): DetFlags.FwdRegion_setOn()
 else:          DetFlags.FwdRegion_setOff()
 if (vp1ZDC): DetFlags.ZDC_setOn()
 else:          DetFlags.ZDC_setOff()
-if (vp1NSW): 
-    DetFlags.Micromegas_setOn()
-    DetFlags.sTGC_setOn()
-    DetFlags.CSC_setOff()
-    
     
 DetFlags.Print()
 
@@ -283,6 +273,11 @@ if vp1Muon and len(vp1NSWAGDDFiles)>0:
     from MuonAGDD.MuonAGDDConf import NSWAGDDTool
     NSWAGDDTool = CfgMgr.NSWAGDDTool("NewSmallWheel", DefaultDetector="Muon", ReadAGDD=False, XMLFiles=vp1NSWAGDDFiles, Volumes=["NewSmallWheel"])
     AGDD2Geo.Builders += [ NSWAGDDTool ]
+if vp1Muon and vp1MuonLayout!="":
+    print "*** VP1 NOTE *** You specified custom vp1MuonLayout, using %s as muon geometry"%vp1MuonLayout
+    from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
+    GeoModelSvc = GeoModelSvc()
+    GeoModelSvc.MuonVersionOverride=vp1MuonLayout
 
 from AthenaCommon.AppMgr import ServiceMgr as svcMgr
 
-- 
GitLab