From 4b4b589f20418a1372f1c53a30a0f56cdd859d7c Mon Sep 17 00:00:00 2001 From: Dave Casper <dcasper@uci.edu> Date: Thu, 12 May 2022 05:13:53 -0700 Subject: [PATCH] Trench integration in progress [skip ci] --- .../python/DetectorConfigFlags.py | 10 +- .../GeoModelTest/python/Faser01TestConfig.py | 1 + .../GeoModelTest/python/Faser02TestConfig.py | 3 +- .../GeoModelTest/python/Faser03TestConfig.py | 4 +- .../GeoModelTest/python/TestBeamTestConfig.py | 1 + .../GeoModelTest/src/GeoModelTestAlg.cxx | 2 +- .../GeoModel/FaserGeoModel/data/geomDB.sql | 34 ++++ .../python/FaserGeoModelConfig.py | 3 + .../FaserGeoModel/python/TrenchGMConfig.py | 13 ++ .../src/DecodeFaserVersionKey.cxx | 4 +- .../GeoModelInterfaces/IGeoDbTagSvc.h | 4 +- .../GeoModelInterfaces/IGeoModelSvc.h | 4 +- .../GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx | 6 +- .../GeoModel/GeoModelSvc/src/GeoDbTagSvc.h | 10 +- .../GeoModel/GeoModelSvc/src/GeoModelSvc.cxx | 26 +-- .../GeoModel/GeoModelSvc/src/GeoModelSvc.h | 6 +- .../TrenchGeoModel/CMakeLists.txt | 35 ++++ .../TrenchGeoModel/data/Trench.gdml | 182 ++++++++++++++++++ .../src/TrenchDetectorFactory.cxx | 88 +++++++++ .../src/TrenchDetectorFactory.h | 59 ++++++ .../src/TrenchDetectorManager.cxx | 38 ++++ .../src/TrenchDetectorManager.h | 44 +++++ .../TrenchGeoModel/src/TrenchDetectorTool.cxx | 106 ++++++++++ .../TrenchGeoModel/src/TrenchDetectorTool.h | 28 +++ .../src/components/TrenchGeoModel_entries.cxx | 3 + .../test/G4FaserAlgConfigNew_Test.py | 2 +- .../G4FaserTools/python/G4FieldConfigNew.py | 9 + .../python/G4GeometryToolConfig.py | 29 ++- .../python/G4PhysicsRegionConfigNew.py | 10 + 29 files changed, 725 insertions(+), 39 deletions(-) create mode 100644 DetectorDescription/GeoModel/FaserGeoModel/python/TrenchGMConfig.py create mode 100644 FaserGeometryCommon/TrenchGeoModel/CMakeLists.txt create mode 100644 FaserGeometryCommon/TrenchGeoModel/data/Trench.gdml create mode 100644 FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.cxx create mode 100644 FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.h create mode 100644 FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorManager.cxx create mode 100644 FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorManager.h create mode 100644 FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorTool.cxx create mode 100644 FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorTool.h create mode 100644 FaserGeometryCommon/TrenchGeoModel/src/components/TrenchGeoModel_entries.cxx diff --git a/Control/CalypsoConfiguration/python/DetectorConfigFlags.py b/Control/CalypsoConfiguration/python/DetectorConfigFlags.py index 1cd75d9c..8ffa4ccd 100644 --- a/Control/CalypsoConfiguration/python/DetectorConfigFlags.py +++ b/Control/CalypsoConfiguration/python/DetectorConfigFlags.py @@ -7,7 +7,7 @@ from CalypsoConfiguration.AutoConfigFlags import DetDescrInfo, getDefaultDetecto allDetectors = [ - 'Emulsion', 'Veto', 'Trigger', 'Preshower', 'VetoNu', 'FaserSCT', 'Ecal', 'Dipole', + 'Emulsion', 'Veto', 'Trigger', 'Preshower', 'VetoNu', 'FaserSCT', 'Ecal', 'Dipole', 'Trench' ] allGroups = { @@ -15,7 +15,8 @@ allGroups = { 'Tracker' : ['SCT'], 'Scintillator' : ['Veto', 'Trigger', 'Preshower', 'VetoNu'], 'FaserCalo' : ['Ecal'], - 'Magnet' : ['Dipole'] + 'Magnet' : ['Dipole'], + 'Cavern' : ['Trench'] } def createDetectorConfigFlags(): @@ -43,8 +44,9 @@ def createDetectorConfigFlags(): dcf.addFlag('Detector.GeometryEcal', False) dcf.addFlag('Detector.GeometryFaserCalo', lambda prevFlags : prevFlags.Detector.GeometryEcal) - # Cavern (disabled by default) - # dcf.addFlag('Detector.GeometryCavern',False) + # Trench (disabled by default) + dcf.addFlag('Detector.GeometryTrench',False) + dcf.addFlag('Detector.GeometryCavern', lambda prevFlags : (prevFlags.Detector.GeometryTrench )) # dcf.addFlag('Detector.GeometryFaser', lambda prevFlags : (prevFlags.Detector.GeometryDecayVolume or # prevFlags.Detector.GeometryScintillator or diff --git a/Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py b/Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py index 69a57833..e85fd9e4 100644 --- a/Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py @@ -19,6 +19,7 @@ def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs): GeoModelTestAlg = CompFactory.GeoModelTestAlg a.addEventAlgo(GeoModelTestAlg(name, FirstSCTStation=1, LastSCTStation=3, + NumVetoNuStations=0, **kwargs)) return a diff --git a/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py b/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py index 03913db7..ba3f91b7 100644 --- a/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py @@ -19,6 +19,7 @@ def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs): GeoModelTestAlg = CompFactory.GeoModelTestAlg a.addEventAlgo(GeoModelTestAlg(name, FirstSCTStation=0, LastSCTStation=3, + NumVetoNuStations=0, PrintSctIDs=True, **kwargs)) @@ -35,7 +36,7 @@ if __name__ == "__main__": ConfigFlags.Input.isMC = True # Needed to bypass autoconfig ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Always needed; must match FaserVersion ConfigFlags.GeoModel.FaserVersion = "FASERNU-02" # Default FASER geometry - # ConfigFlags.GeoModel.GeoExportFile = "faserGeoNu02.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + ConfigFlags.GeoModel.GeoExportFile = "FaserNu02.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) # ConfigFlags.Detector.EnableVeto = True # ConfigFlags.Detector.EnableTrigger = True # ConfigFlags.Detector.EnablePreshower= True diff --git a/Control/CalypsoExample/GeoModelTest/python/Faser03TestConfig.py b/Control/CalypsoExample/GeoModelTest/python/Faser03TestConfig.py index de144702..70322eb1 100644 --- a/Control/CalypsoExample/GeoModelTest/python/Faser03TestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/Faser03TestConfig.py @@ -35,7 +35,9 @@ if __name__ == "__main__": ConfigFlags.Input.isMC = True # Needed to bypass autoconfig ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Always needed; must match FaserVersion ConfigFlags.GeoModel.FaserVersion = "FASERNU-03" # Default FASER geometry - # ConfigFlags.GeoModel.GeoExportFile = "faserGeoNu02.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + ConfigFlags.GeoModel.GeoExportFile = "FaserNu03.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + ConfigFlags.Detector.GeometryEmulsion = True + ConfigFlags.Detector.GeometryTrench = True # ConfigFlags.Detector.EnableVeto = True # ConfigFlags.Detector.EnableTrigger = True # ConfigFlags.Detector.EnablePreshower= True diff --git a/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py b/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py index d590b125..5dd29933 100644 --- a/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py @@ -25,6 +25,7 @@ def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs): LastSCTStation=0, NumVetoStations=1, NumVetoPlatesPerStation=2, + NumVetoNuStations=0, NumTriggerStations=0, PrintSctIDs=True, **kwargs)) diff --git a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx index 8bbb0df4..0db09483 100644 --- a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx +++ b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx @@ -70,7 +70,7 @@ StatusCode GeoModelTestAlg::execute(const EventContext& ctx) const ATH_CHECK(testVeto()); - ATH_CHECK(testVetoNu()); + if (m_numVetoNuStations > 0) ATH_CHECK(testVetoNu()); ATH_CHECK(testTrigger()); diff --git a/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql b/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql index 1c2cb41f..81a979c3 100644 --- a/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql +++ b/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql @@ -735,6 +735,24 @@ CREATE TABLE IF NOT EXISTS "ECALSWITCHES_DATA2TAG" ( "ECALSWITCHES_TAG_ID" SLONGLONG, "ECALSWITCHES_DATA_ID" SLONGLONG ); +-- +DROP TABLE IF EXISTS "TRENCHSWITCHES_DATA"; +CREATE TABLE IF NOT EXISTS "TRENCHSWITCHES_DATA" ( + "TRENCHSWITCHES_DATA_ID" SLONGLONG UNIQUE, + "DETECTORNAME" TEXT , + "USEMAGFIELDSVC" INT , + "COSMICLAYOUT" INT , + "VERSIONNAME" TEXT , + "LAYOUT" TEXT , + "DESCRIPTION" TEXT, + "GDMLFILE" TEXT +); +DROP TABLE IF EXISTS "TRENCHSWITCHES_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "TRENCHSWITCHES_DATA2TAG" ( + "TRENCHSWITCHES_TAG_ID" SLONGLONG, + "TRENCHSWITCHES_DATA_ID" SLONGLONG +); + -- DROP TABLE IF EXISTS "NEUTRINOIDENTIFIER_DATA"; CREATE TABLE IF NOT EXISTS "NEUTRINOIDENTIFIER_DATA" ( @@ -793,6 +811,9 @@ CREATE TABLE IF NOT EXISTS "CALOIDENTIFIER_DATA2TAG" ( -- Data for the HVS_NODE table INSERT INTO "HVS_NODE" VALUES (0, "FASER", 0, 1, NULL); INSERT INTO "HVS_NODE" VALUES (90, "FaserCommon", 0, 0, NULL); +INSERT INTO "HVS_NODE" VALUES (5, "Cavern", 0, 1, NULL); +INSERT INTO "HVS_NODE" VALUES (51, "Trench", 5, 1, NULL); +INSERT INTO "HVS_NODE" VALUES (514, "TrenchSwitches", 0, 0, NULL); INSERT INTO "HVS_NODE" VALUES (9000, "Materials", 0, 1, NULL); INSERT INTO "HVS_NODE" VALUES (9001, "StdMaterials", 9000, 0, NULL); INSERT INTO "HVS_NODE" VALUES (9002, "StdMatComponents", 9000, 0, NULL); @@ -875,6 +896,9 @@ INSERT INTO "HVS_TAG2NODE" VALUES (0, "FASERNU-02", 107804, NULL, 0, 0, 16193088 INSERT INTO "HVS_TAG2NODE" VALUES (0, "FASER-TB00", 107834, NULL, 0, 0, 1627862400000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (0, "FASERNU-03", 107835, NULL, 0, 0, 1652054400000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (90, "FaserCommon-00", 100013, NULL, 0, 0, 1549324800000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (5, "Cavern-00", 107850, NULL, 0, 0, 1652313600000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (51, "Trench-00", 107851, NULL, 0, 0, 1652313600000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (514,"TrenchSwitches-00", 107852, NULL, 0, 0, 1652313600000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (9000, "Materials-00", 100005, NULL, 0, 0, 1549238400000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (9001, "StdMaterials-00", 100006, NULL, 0, 0, 1549238400000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (9002, "StdMatComponents-00", 100007, NULL, 0, 0, 1549238400000000000, NULL, 22); @@ -1048,6 +1072,9 @@ INSERT INTO "HVS_LTAG2LTAG" VALUES (0, 107788, 90, 100013); INSERT INTO "HVS_LTAG2LTAG" VALUES (0, 107804, 90, 100013); INSERT INTO "HVS_LTAG2LTAG" VALUES (0, 107834, 90, 100013); INSERT INTO "HVS_LTAG2LTAG" VALUES (0, 107835, 90, 100013); +INSERT INTO "HVS_LTAG2LTAG" VALUES (0, 107835, 5, 107850); +INSERT INTO "HVS_LTAG2LTAG" VALUES (5, 107850, 51, 107851); +INSERT INTO "HVS_LTAG2LTAG" VALUES (51, 107835, 514, 107852); INSERT INTO "HVS_LTAG2LTAG" VALUES (0, 100000, 9000, 100005); INSERT INTO "HVS_LTAG2LTAG" VALUES (0, 100039, 9000, 100005); INSERT INTO "HVS_LTAG2LTAG" VALUES (0, 107784, 9000, 100005); @@ -1665,6 +1692,9 @@ INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-TB00", "CaloIdentifier", "CaloIden -- INSERT INTO "HVS_TAGCACHE" VALUES ("FASERNU-03", "FASER", "FASERNU-03", 107835); INSERT INTO "HVS_TAGCACHE" VALUES ("FASERNU-03", "FaserCommon", "FaserCommon-00", 100013); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASERNU-03", "Cavern", "Cavern-00", 107850); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASERNU-03", "Trench", "Trench-00", 107851); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASERNU-03", "TrenchSwitches", "TrenchSwitches-00", 107852); INSERT INTO "HVS_TAGCACHE" VALUES ("FASERNU-03", "Materials", "Materials-00", 100005); INSERT INTO "HVS_TAGCACHE" VALUES ("FASERNU-03", "StdMaterials", "StdMaterials-00", 100006); INSERT INTO "HVS_TAGCACHE" VALUES ("FASERNU-03", "StdMatComponents", "StdMatComponents-00", 100007); @@ -2513,6 +2543,10 @@ INSERT INTO "ECALSWITCHES_DATA" VALUES ( 0, "Ecal", 1, 0, "GEO", "Development", INSERT INTO "ECALSWITCHES_DATA2TAG" VALUES (100057, 0); -- -- +INSERT INTO "TRENCHSWITCHES_DATA" VALUES ( 0, "Trench", 1, 0, "GEO", "Development", "Baseline geometry", "TrenchGeoModel/Trench.gdml"); +INSERT INTO "TRENCHSWITCHES_DATA2TAG" VALUES (107852, 0); +-- +-- INSERT INTO "NEUTRINOIDENTIFIER_DATA" VALUES (0, "Neutrino", "NeutrinoIdDictFiles/IdDictNeutrino.xml", "Baseline layout"); INSERT INTO "NEUTRINOIDENTIFIER_DATA2TAG" VALUES (100030, 0); -- diff --git a/DetectorDescription/GeoModel/FaserGeoModel/python/FaserGeoModelConfig.py b/DetectorDescription/GeoModel/FaserGeoModel/python/FaserGeoModelConfig.py index 72e1d79a..d1390bf9 100644 --- a/DetectorDescription/GeoModel/FaserGeoModel/python/FaserGeoModelConfig.py +++ b/DetectorDescription/GeoModel/FaserGeoModel/python/FaserGeoModelConfig.py @@ -23,4 +23,7 @@ def FaserGeometryCfg (flags): from EcalGeoModel.EcalGeoModelConfig import EcalGeometryCfg acc.merge(EcalGeometryCfg( flags )) + from FaserGeoModel.TrenchGMConfig import TrenchGeometryCfg + acc.merge(TrenchGeometryCfg( flags )) + return acc diff --git a/DetectorDescription/GeoModel/FaserGeoModel/python/TrenchGMConfig.py b/DetectorDescription/GeoModel/FaserGeoModel/python/TrenchGMConfig.py new file mode 100644 index 00000000..b53147bc --- /dev/null +++ b/DetectorDescription/GeoModel/FaserGeoModel/python/TrenchGMConfig.py @@ -0,0 +1,13 @@ +# +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +# +from AthenaConfiguration.ComponentFactory import CompFactory + +def TrenchGeometryCfg( flags ): + from FaserGeoModel.GeoModelConfig import GeoModelCfg + acc = GeoModelCfg( flags ) + + if flags.Detector.GeometryTrench: + TrenchDetectorTool=CompFactory.TrenchDetectorTool + acc.getPrimary().DetectorTools += [ TrenchDetectorTool() ] + return acc diff --git a/DetectorDescription/GeoModel/GeoModelFaserUtilities/src/DecodeFaserVersionKey.cxx b/DetectorDescription/GeoModel/GeoModelFaserUtilities/src/DecodeFaserVersionKey.cxx index d2d4e1b9..010fa495 100644 --- a/DetectorDescription/GeoModel/GeoModelFaserUtilities/src/DecodeFaserVersionKey.cxx +++ b/DetectorDescription/GeoModel/GeoModelFaserUtilities/src/DecodeFaserVersionKey.cxx @@ -67,12 +67,12 @@ void DecodeFaserVersionKey::defineTag(const T* svc, const std::string & node) nodeOverrideTag = svc->dipoleVersionOverride(); trackerOverrideTag = svc->trackerVersionOverride(); } else if (node == "Calorimeter") { - const T* service = dynamic_cast<const T*>(svc); nodeOverrideTag = svc->caloVersionOverride(); } else if (node == "Ecal") { - const T* service = dynamic_cast<const T*>(svc); caloOverrideTag = svc->caloVersionOverride(); nodeOverrideTag = svc->ecalVersionOverride(); + } else if (node == "Trench") { + nodeOverrideTag = svc->trenchVersionOverride(); } else { std::cout << "DecodeFaserVersionKey passed an unknown node:" << node << std::endl; nodeOverrideTag = ""; diff --git a/DetectorDescription/GeoModel/GeoModelInterfaces/GeoModelInterfaces/IGeoDbTagSvc.h b/DetectorDescription/GeoModel/GeoModelInterfaces/GeoModelInterfaces/IGeoDbTagSvc.h index 0214fac2..9f8e103c 100644 --- a/DetectorDescription/GeoModel/GeoModelInterfaces/GeoModelInterfaces/IGeoDbTagSvc.h +++ b/DetectorDescription/GeoModel/GeoModelInterfaces/GeoModelInterfaces/IGeoDbTagSvc.h @@ -41,7 +41,7 @@ class IGeoDbTagSvc : virtual public IInterface { virtual const std::string & caloVersion() const =0; virtual const std::string & ecalVersion() const =0; // virtual const std::string & magFieldVersion() const =0; - // virtual const std::string & cavernInfraVersion() const =0; + virtual const std::string & trenchVersion() const =0; virtual const std::string & neutrinoVersionOverride() const =0; virtual const std::string & emulsionVersionOverride() const =0; @@ -56,7 +56,7 @@ class IGeoDbTagSvc : virtual public IInterface { virtual const std::string & caloVersionOverride() const =0; virtual const std::string & ecalVersionOverride() const =0; // virtual const std::string & magFieldVersionOverride() const =0; - // virtual const std::string & cavernInfraVersionOverride() const =0; + virtual const std::string & trenchVersionOverride() const =0; virtual GeoModel::GeoConfig geoConfig() const = 0; }; diff --git a/DetectorDescription/GeoModel/GeoModelInterfaces/GeoModelInterfaces/IGeoModelSvc.h b/DetectorDescription/GeoModel/GeoModelInterfaces/GeoModelInterfaces/IGeoModelSvc.h index ec6c2f56..b5c7d106 100644 --- a/DetectorDescription/GeoModel/GeoModelInterfaces/GeoModelInterfaces/IGeoModelSvc.h +++ b/DetectorDescription/GeoModel/GeoModelInterfaces/GeoModelInterfaces/IGeoModelSvc.h @@ -39,7 +39,7 @@ public: virtual const std::string & caloVersion() const =0; virtual const std::string & ecalVersion() const =0; // virtual const std::string & magFieldVersion() const =0; - // virtual const std::string & cavernInfraVersion() const =0; + virtual const std::string & trenchVersion() const =0; virtual const std::string & neutrinoVersionOverride() const =0; virtual const std::string & emulsionVersionOverride() const =0; @@ -54,7 +54,7 @@ public: virtual const std::string & caloVersionOverride() const =0; virtual const std::string & ecalVersionOverride() const =0; // virtual const std::string & magFieldVersionOverride() const =0; - // virtual const std::string & cavernInfraVersionOverride() const =0; + virtual const std::string & trenchVersionOverride() const =0; virtual GeoModel::GeoConfig geoConfig() const = 0; diff --git a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx index 99ba2a02..7c641330 100644 --- a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx +++ b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx @@ -120,9 +120,9 @@ StatusCode GeoDbTagSvc::setupTags() // ? rdbAccessSvc->getChildTag("MagneticField",m_AtlasVersion,"ATLAS") // : m_MagFieldVersionOverride); - // m_CavernInfraVersion = (m_CavernInfraVersionOverride.empty() - // ? rdbAccessSvc->getChildTag("CavernInfra",m_AtlasVersion,"ATLAS") - // : m_CavernInfraVersionOverride); + m_TrenchVersion = (m_TrenchVersionOverride.empty() + ? rdbAccessSvc->getChildTag("Trench", m_FaserVersion,"FASERDD") + : m_TrenchVersionOverride); // Retrieve geometry config information (RUN1, RUN2, etc...) IRDBRecordset_ptr faserCommonRec = rdbAccessSvc->getRecordsetPtr("FaserCommon", m_FaserVersion, "FASER", "FASERDD"); diff --git a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.h b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.h index 9804e9be..4fb1b0a2 100644 --- a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.h +++ b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.h @@ -41,7 +41,7 @@ class GeoDbTagSvc : public AthService, virtual public IGeoDbTagSvc void setCaloVersionOverride(const std::string& tag) { m_CaloVersionOverride=tag; } void setEcalVersionOverride(const std::string& tag) { m_EcalVersionOverride=tag; } // void setMagFieldVersionOverride(const std::string& tag) { m_MagFieldVersionOverride=tag; } - // void setCavernInfraVersionOverride(const std::string& tag) { m_CavernInfraVersionOverride=tag; } + void setTrenchVersionOverride(const std::string& tag) { m_TrenchVersionOverride=tag; } StatusCode setupTags(); @@ -61,7 +61,7 @@ class GeoDbTagSvc : public AthService, virtual public IGeoDbTagSvc const std::string & caloVersionOverride() const { return m_CaloVersionOverride; } const std::string & ecalVersionOverride() const { return m_EcalVersionOverride; } // const std::string & magFieldVersionOverride() const { return m_MagFieldVersionOverride; } - // const std::string & cavernInfraVersionOverride() const { return m_CavernInfraVersionOverride; } + const std::string & trenchVersionOverride() const { return m_TrenchVersionOverride; } const std::string & neutrinoVersion() const { return m_NeutrinoVersion; } const std::string & emulsionVersion() const { return m_EmulsionVersion; } @@ -76,7 +76,7 @@ class GeoDbTagSvc : public AthService, virtual public IGeoDbTagSvc const std::string & caloVersion() const { return m_CaloVersion; } const std::string & ecalVersion() const { return m_EcalVersion; } // const std::string & magFieldVersion() const { return m_MagFieldVersion; } - // const std::string & cavernInfraVersion() const { return m_CavernInfraVersion; } + const std::string & trenchVersion() const { return m_TrenchVersion; } GeoModel::GeoConfig geoConfig() const { return m_geoConfig; } @@ -96,7 +96,7 @@ class GeoDbTagSvc : public AthService, virtual public IGeoDbTagSvc std::string m_CaloVersion; std::string m_EcalVersion; // std::string m_MagFieldVersion; - // std::string m_CavernInfraVersion; + std::string m_TrenchVersion; std::string m_NeutrinoVersionOverride; std::string m_EmulsionVersionOverride; @@ -111,7 +111,7 @@ class GeoDbTagSvc : public AthService, virtual public IGeoDbTagSvc std::string m_CaloVersionOverride; std::string m_EcalVersionOverride; // std::string m_MagFieldVersionOverride; - // std::string m_CavernInfraVersionOverride; + std::string m_TrenchVersionOverride; GeoModel::GeoConfig m_geoConfig; }; diff --git a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.cxx b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.cxx index 6296518f..a1bf57b7 100644 --- a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.cxx +++ b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.cxx @@ -65,7 +65,7 @@ GeoModelSvc::GeoModelSvc(const std::string& name,ISvcLocator* svc) declareProperty( "CaloVersionOverride", m_CaloVersionOverride); declareProperty( "EcalVersionOverride", m_EcalVersionOverride); // declareProperty( "MagFieldVersionOverride", m_MagFieldVersionOverride); - // declareProperty( "CavernInfraVersionOverride", m_CavernInfraVersionOverride); + declareProperty( "TrenchVersionOverride", m_TrenchVersionOverride); declareProperty( "AlignCallbacks", m_callBackON); declareProperty( "IgnoreTagDifference", m_ignoreTagDifference); declareProperty( "UseTagInfo", m_useTagInfo); @@ -199,7 +199,7 @@ StatusCode GeoModelSvc::geoInit() ATH_MSG_DEBUG("* Calo tag: " << m_CaloVersionOverride); ATH_MSG_DEBUG("* Ecal tag: " << m_EcalVersionOverride); // ATH_MSG_DEBUG("* MagField tag: " << m_MagFieldVersionOverride); - // ATH_MSG_DEBUG("* CavernInfra tag: " << m_CavernInfraVersionOverride); + ATH_MSG_DEBUG("* Trench tag: " << m_TrenchVersionOverride); // GetRDBAccessSvc and open connection to DB ServiceHandle<IRDBAccessSvc> rdbAccess("RDBAccessSvc",name()); @@ -272,7 +272,7 @@ StatusCode GeoModelSvc::geoInit() dbTagSvc->setCaloVersionOverride(m_CaloVersionOverride); dbTagSvc->setEcalVersionOverride(m_EcalVersionOverride); // dbTagSvc->setMagFieldVersionOverride(m_MagFieldVersionOverride); - // dbTagSvc->setCavernInfraVersionOverride(m_CavernInfraVersionOverride); + dbTagSvc->setTrenchVersionOverride(m_TrenchVersionOverride); if(dbTagSvc->setupTags().isFailure()) { ATH_MSG_FATAL("Failed to setup subsystem tags"); @@ -450,6 +450,8 @@ StatusCode GeoModelSvc::compareTags() tagsMatch = m_CaloVersionOverride == pair.second; else if(tagPairName=="GeoEcal") tagsMatch = m_EcalVersionOverride == pair.second; + else if(tagPairName=="GeoTrench") + tagsMatch = m_TrenchVersionOverride == pair.second; if(!tagsMatch) break; } @@ -472,7 +474,7 @@ StatusCode GeoModelSvc::compareTags() ATH_MSG_INFO("* Calo tag: " << m_CaloVersionOverride); ATH_MSG_INFO("* Ecal tag: " << m_EcalVersionOverride); // ATH_MSG_INFO("* MagField tag: " << m_MagFieldVersionOverride); - // ATH_MSG_INFO("* CavernInfra tag: " << m_CavernInfraVersionOverride); + ATH_MSG_INFO("* Trench tag: " << m_TrenchVersionOverride); ATH_MSG_INFO("** TAG INFO configuration: "); for (const auto& pair : pairs) { std::string tagPairName = pair.first; @@ -504,8 +506,8 @@ StatusCode GeoModelSvc::compareTags() ATH_MSG_INFO("*Ecal tag: " << pair.second); // else if(tagPairName=="GeoMagField") // ATH_MSG_INFO("*MagField tag: " << pair.second); - // else if(tagPairName=="GeoCavernInfra") - // ATH_MSG_INFO("*CavernInfra tag: " << pair.second); + else if(tagPairName=="GeoTrench") + ATH_MSG_INFO("*Trench tag: " << pair.second); } if(!m_ignoreTagDifference) { @@ -625,12 +627,12 @@ StatusCode GeoModelSvc::fillTagInfo() const // } // } - // if(m_CavernInfraVersionOverride != "") { - // if(m_tagInfoMgr->addTag("GeoCavernInfra",m_CavernInfraVersionOverride).isFailure()) { - // ATH_MSG_ERROR("GeoModelSvc CavernInfra tag: " << m_CavernInfraVersionOverride << " not added to TagInfo "); - // return StatusCode::FAILURE; - // } - // } + if(m_TrenchVersionOverride != "") { + if(m_tagInfoMgr->addTag("GeoTrench",m_TrenchVersionOverride).isFailure()) { + ATH_MSG_ERROR("GeoModelSvc Trench tag: " << m_TrenchVersionOverride << " not added to TagInfo "); + return StatusCode::FAILURE; + } + } return StatusCode::SUCCESS; } diff --git a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.h b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.h index 9da66beb..e40c06f9 100644 --- a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.h +++ b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.h @@ -88,7 +88,7 @@ private: std::string m_CaloVersionOverride; std::string m_EcalVersionOverride; // std::string m_MagFieldVersionOverride; - // std::string m_CavernInfraVersionOverride; + std::string m_TrenchVersionOverride; bool m_printMaterials; // Print the contents of the Material Manager at the end of geoInit bool m_callBackON; // Register callback for Detector Tools @@ -115,7 +115,7 @@ private: const std::string & caloVersionOverride() const {return m_CaloVersionOverride ;} const std::string & ecalVersionOverride() const {return m_EcalVersionOverride ;} // const std::string & magFieldVersionOverride() const {return m_MagFieldVersionOverride ;} - // const std::string & cavernInfraVersionOverride() const {return m_CavernInfraVersionOverride ;} + const std::string & trenchVersionOverride() const {return m_TrenchVersionOverride ;} const std::string & neutrinoVersion() const {return m_geoDbTagSvc->neutrinoVersion(); } const std::string & emulsionVersion() const {return m_geoDbTagSvc->emulsionVersion(); } @@ -130,7 +130,7 @@ private: const std::string & caloVersion() const {return m_geoDbTagSvc->caloVersion(); } const std::string & ecalVersion() const {return m_geoDbTagSvc->ecalVersion(); } // const std::string & magFieldVersion() const {return m_geoDbTagSvc->magFieldVersion(); } - // const std::string & cavernInfraVersion() const {return m_geoDbTagSvc->cavernInfraVersion(); } + const std::string & trenchVersion() const {return m_geoDbTagSvc->trenchVersion(); } GeoModel::GeoConfig geoConfig() const {return m_geoDbTagSvc->geoConfig();} diff --git a/FaserGeometryCommon/TrenchGeoModel/CMakeLists.txt b/FaserGeometryCommon/TrenchGeoModel/CMakeLists.txt new file mode 100644 index 00000000..041a0033 --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/CMakeLists.txt @@ -0,0 +1,35 @@ +################################################################################ +# Package: TrenchGeoModel +################################################################################ + +# Declare the package name: +atlas_subdir( TrenchGeoModel ) + +# External dependencies: +find_package( Boost COMPONENTS filesystem thread system ) +find_package( Eigen ) +find_package( GeoModel COMPONENTS GeoModelKernel GeoModelDBManager GDMLtoGM ) +find_package( XercesC ) + +# Component(s) in the package: +atlas_add_component( TrenchGeoModel + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${GEOMODEL_INCLUDE_DIR} ${XERCESC_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ${GEOMODEL_LIBRARIES} ${XERCESC_LIBRARIES} AthenaKernel GeoModelFaserUtilities GaudiKernel + StoreGateLib GeoModelInterfaces RDBAccessSvcLib PathResolver) + +add_custom_command (OUTPUT ${CMAKE_XML_OUTPUT_DIRECTORY}/TrenchGeoModel/Trench.gdml + COMMAND mkdir -p ${CMAKE_XML_OUTPUT_DIRECTORY}/TrenchGeoModel/ + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/data/Trench.gdml ${CMAKE_XML_OUTPUT_DIRECTORY}/TrenchGeoModel/Trench.gdml ) +add_custom_target (make_cavern_gdml ALL DEPENDS ${CMAKE_XML_OUTPUT_DIRECTORY}/TrenchGeoModel/Trench.gdml) +get_filename_component( _realpath ${CMAKE_CURRENT_SOURCE_DIR}/data/Trench.gdml REALPATH ) + +install(FILES ${_realpath} DESTINATION ${CMAKE_INSTALL_PREFIX}/XML/TrenchGeoModel RENAME Trench.gdml) +unset( _realpath ) + +# Install files from the package: +#atlas_install_python_modules( python/*.py ) +#atlas_install_scripts( test/*.py ) +# Not needed as done with symlink above +#atlas_install_xmls( data/*.gdml ) diff --git a/FaserGeometryCommon/TrenchGeoModel/data/Trench.gdml b/FaserGeometryCommon/TrenchGeoModel/data/Trench.gdml new file mode 100644 index 00000000..5249b55d --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/data/Trench.gdml @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gdml xsi:noNamespaceSchemaLocation="schema/gdml.xsd"> + <define> + <position name="RampinWorldpos" unit="mm" x="576.9" y="-177.6" z="-598.8"/> + <rotation name="RampinWorldrot" unit="deg" z="0" y="-9.50625" x="0.711918"/> + <position name="Subpos" unit="mm" x="-668.4" y="245.1" z="498.3" /> + <rotation name="Subrot" unit="deg" x="90.7119" y="-9.50625" z="0" /> + <constant name="WorldSize" value="20000"/> + <constant name="RampWidth" value="7000"/> + <constant name="RampLengthZ" value="8422"/> + <constant name="RampMinThickness" value="2000"/> + <constant name="RampSlope" value="0.08533"/> + </define> + <materials> + <isotope N="1.400000000000000e+01" Z="7.000000000000000e+00" name="N140x8e46440"> + <atom unit="g/mole" value="1.400310000000000e+01"/> + </isotope> + <isotope N="1.500000000000000e+01" Z="7.000000000000000e+00" name="N150x8e48da0"> + <atom unit="g/mole" value="1.500010000000000e+01"/> + </isotope> + <element name="N0x8e48c30"> + <fraction n="9.963200000000001e-01" ref="N140x8e46440"/> + <fraction n="3.680000000000000e-03" ref="N150x8e48da0"/> + </element> + <isotope N="1.600000000000000e+01" Z="8.000000000000000e+00" name="O160x1167b880"> + <atom unit="g/mole" value="1.599490000000000e+01"/> + </isotope> + <isotope N="1.700000000000000e+01" Z="8.000000000000000e+00" name="O170x1167b7d0"> + <atom unit="g/mole" value="1.699909999999999e+01"/> + </isotope> + <isotope N="1.800000000000000e+01" Z="8.000000000000000e+00" name="O180xfb79770"> + <atom unit="g/mole" value="1.799920000000000e+01"/> + </isotope> + <element name="O0x1167b4f0"> + <fraction n="9.975700000000000e-01" ref="O160x1167b880"/> + <fraction n="3.800000000000000e-04" ref="O170x1167b7d0"/> + <fraction n="2.050000000000000e-03" ref="O180xfb79770"/> + </element> + <isotope N="2.800000000000000e+01" Z="1.400000000000000e+01" name="Si280x8146230"> + <atom unit="g/mole" value="2.797690000000000e+01"/> + </isotope> + <isotope N="2.900000000000000e+01" Z="1.400000000000000e+01" name="Si290x8146280"> + <atom unit="g/mole" value="2.897650000000000e+01"/> + </isotope> + <isotope N="3.000000000000000e+01" Z="1.400000000000000e+01" name="Si300x8146e50"> + <atom unit="g/mole" value="2.997380000000000e+01"/> + </isotope> + <element name="Si0x8147580"> + <fraction n="9.222960777039223e-01" ref="Si280x8146230"/> + <fraction n="4.683195316804684e-02" ref="Si290x8146280"/> + <fraction n="3.087196912803088e-02" ref="Si300x8146e50"/> + </element> + <isotope N="4.000000000000000e+01" Z="2.000000000000000e+01" name="Ca400xee155f0"> + <atom unit="g/mole" value="3.996260000000000e+01"/> + </isotope> + <isotope N="4.200000000000000e+01" Z="2.000000000000000e+01" name="Ca420xee15640"> + <atom unit="g/mole" value="4.195860000000000e+01"/> + </isotope> + <isotope N="4.300000000000000e+01" Z="2.000000000000000e+01" name="Ca430xee15690"> + <atom unit="g/mole" value="4.295880000000000e+01"/> + </isotope> + <isotope N="4.400000000000000e+01" Z="2.000000000000000e+01" name="Ca440xee156e0"> + <atom unit="g/mole" value="4.395550000000001e+01"/> + </isotope> + <isotope N="4.600000000000000e+01" Z="2.000000000000000e+01" name="Ca460xee15730"> + <atom unit="g/mole" value="4.595370000000000e+01"/> + </isotope> + <isotope N="4.800000000000000e+01" Z="2.000000000000000e+01" name="Ca480xee15780"> + <atom unit="g/mole" value="4.795250000000000e+01"/> + </isotope> + <element name="Ca0xee154a0"> + <fraction n="9.694100000000000e-01" ref="Ca400xee155f0"/> + <fraction n="6.470000000000000e-03" ref="Ca420xee15640"/> + <fraction n="1.350000000000000e-03" ref="Ca430xee15690"/> + <fraction n="2.086000000000000e-02" ref="Ca440xee156e0"/> + <fraction n="4.000000000000000e-05" ref="Ca460xee15730"/> + <fraction n="1.870000000000000e-03" ref="Ca480xee15780"/> + </element> + <isotope N="2.300000000000000e+01" Z="1.100000000000000e+01" name="Na230x9095660"> + <atom unit="g/mole" value="2.298980000000000e+01"/> + </isotope> + <element name="Na0x90954f0"> + <fraction n="1.000000000000000e+00" ref="Na230x9095660"/> + </element> + <isotope N="5.400000000000000e+01" Z="2.600000000000000e+01" name="Fe540x11685b60"> + <atom unit="g/mole" value="5.393959999999999e+01"/> + </isotope> + <isotope N="5.600000000000000e+01" Z="2.600000000000000e+01" name="Fe560x11685bb0"> + <atom unit="g/mole" value="5.593490000000000e+01"/> + </isotope> + <isotope N="5.700000000000000e+01" Z="2.600000000000000e+01" name="Fe570x11685c00"> + <atom unit="g/mole" value="5.693540000000000e+01"/> + </isotope> + <isotope N="5.800000000000000e+01" Z="2.600000000000000e+01" name="Fe580x11685c50"> + <atom unit="g/mole" value="5.793330000000000e+01"/> + </isotope> + <element name="Fe0x116859d0"> + <fraction n="5.845000000000000e-02" ref="Fe540x11685b60"/> + <fraction n="9.175400000000000e-01" ref="Fe560x11685bb0"/> + <fraction n="2.119000000000000e-02" ref="Fe570x11685c00"/> + <fraction n="2.820000000000000e-03" ref="Fe580x11685c50"/> + </element> + <isotope N="2.700000000000000e+01" Z="1.300000000000000e+01" name="Al270x116850d0"> + <atom unit="g/mole" value="2.698150000000000e+01"/> + </isotope> + <element name="Al0x11684f90"> + <fraction n="1.000000000000000e+00" ref="Al270x116850d0"/> + </element> + <material name="Concrete" state="solid"> + <MEE unit="eV" value="1.271741855079048e+02"/> + <D unit="g/cm3" value="2.499998684602534e+00"/> + <fraction n="5.306122448979591e-01" ref="O0x1167b4f0"/> + <fraction n="3.316326530612245e-01" ref="Si0x8147580"/> + <fraction n="6.122448979591836e-02" ref="Ca0xee154a0"/> + <fraction n="1.530612244897959e-02" ref="Na0x90954f0"/> + <fraction n="2.040816326530612e-02" ref="Fe0x116859d0"/> + <fraction n="4.081632653061224e-02" ref="Al0x11684f90"/> + </material> + <material name="Air" state="gas"> + <T unit="K" value="2.930000000000000e+02"/> + <MEE unit="eV" value="8.570323231865051e+01"/> + <D unit="g/cm3" value="1.204999365978422e-03"/> + <fraction n="7.000000000000000e-01" ref="N0x8e48c30"/> + <fraction n="3.000000000000000e-01" ref="O0x1167b4f0"/> + </material> + </materials> + <solids> + <arb8 name="ramp" lunit="mm" + v1x="-RampWidth/2" v1y="-RampMinThickness" v2x="RampWidth/2" v2y="-RampMinThickness" v3x="RampWidth/2" v3y="RampSlope*RampLengthZ" v4x="-RampWidth/2" v4y="RampSlope*RampLengthZ" + v5x="-RampWidth/2" v5y="-RampMinThickness" v6x="RampWidth/2" v6y="-RampMinThickness" v7x="RampWidth/2" v7y="0" v8x="-RampWidth/2" v8y="0" + dz="RampLengthZ/2" /> + <box name="world" lunit="mm" x="WorldSize" y="WorldSize" z="WorldSize" /> + <xtru name="trenchOutline" lunit="mm"> + <twoDimVertex x="-249.75647241976003" y="-3162.7618497323056"/> + <twoDimVertex x="436.065806982358" y="-3162.7608114181166"/> + <twoDimVertex x="750.3626731862572" y="-1286.045959074479"/> + <twoDimVertex x="750.4059394616982" y="-604.5461685406792"/> + <twoDimVertex x="750.6632036024528" y="3447.692178833775"/> + <twoDimVertex x="598.5775838786217" y="3447.7018373451183"/> + <twoDimVertex x="-251.25127807309354" y="3447.755796000657"/> + <twoDimVertex x="-624.2972688145043" y="1219.150232226327"/> + <twoDimVertex x="-659.4916199548085" y="1008.9993568866641"/> + <twoDimVertex x="-659.5757293651513" y="-315.8326195671569"/> + <twoDimVertex x="-659.6885336897632" y="-2092.6465942800164"/> + <twoDimVertex x="-249.68853582392614" y="-2092.672626612777"/> + <section zOrder="0" zPosition="-375.0" xOffset="0" yOffset="0" scalingFactor="1" /> + <section zOrder="1" zPosition="375.0" xOffset="0" yOffset="0" scalingFactor="1" /> + </xtru> + <subtraction name="faserTrench"> + <first ref="ramp"/> + <firstpositionref ref="RampinWorldpos"/> + <firstrotationref ref="RampinWorldrot"/> + <second ref="trenchOutline"/> + <!-- + <rotationref ref="Subrot"/> + <positionref ref="Subpos"/> + --> + <rotation name="Xrotation" unit="deg" x="90"/> + <position name="Yshift" unit="mm" y="75"/> + </subtraction> + </solids> + <structure> + <volume name="Trench"> + <solidref ref="faserTrench"/> + <materialref ref="Concrete"/> + </volume> + <volume name="World" > + <materialref ref="Air" /> + <solidref ref="world" /> + <physvol> + <volumeref ref="Trench" /> + <!-- + <rotationref ref="RampinWorldrot"/> + <positionref ref="RampinWorldpos"/> + --> + </physvol> + </volume> + </structure> + <setup name="Default" version="1.0" > + <world ref="World" /> + </setup> +</gdml> \ No newline at end of file diff --git a/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.cxx b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.cxx new file mode 100644 index 00000000..668af4a0 --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.cxx @@ -0,0 +1,88 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrenchDetectorFactory.h" + +#include "GeoModelXMLParser/XercesParser.h" +#include "PathResolver/PathResolver.h" + + +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoNameTag.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "StoreGate/StoreGateSvc.h" + + +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" + +#include "GaudiKernel/MsgStream.h" + +#include <string> +#include <map> + +TrenchDetectorFactory::TrenchDetectorFactory(StoreGateSvc *detStore, + IRDBAccessSvc *pAccess) + :m_detectorManager(NULL), + m_detectorStore(detStore), + m_access(pAccess) +{ +} + +TrenchDetectorFactory::~TrenchDetectorFactory() +{ +} + +void TrenchDetectorFactory::create(GeoPhysVol *world) +{ + m_detectorManager=new TrenchDetectorManager(); + + std::string gdmlFile; + IRDBRecordset_ptr switchSet{m_access->getRecordsetPtr("TrenchSwitches", m_versionTag, m_versionNode, "FASERDD")}; + if (!switchSet || switchSet->size() == 0) + { + MsgStream gLog(Athena::getMessageSvc(), "TrenchDetectorFactory"); + gLog << MSG::WARNING << "Unable to retrieve switches; Trench cannot be created" << endmsg; + return; + } + const IRDBRecord* switches{(*switchSet)[0]}; + if (not switches->isFieldNull("GDMLFILE") && gdmlFile.empty()) + { + gdmlFile = switches->getString("GDMLFILE"); + } + if (gdmlFile.empty()) + { + MsgStream gLog(Athena::getMessageSvc(), "TrenchDetectorFactory"); + gLog << MSG::WARNING << "GDML file name not found; Trench cannot be created" << endmsg; + return; + } + + std::string resolvedFile = PathResolver::find_file(gdmlFile, "XMLPATH", PathResolver::RecursiveSearch); + std::cout << "creating parser" << std::endl; + XercesParser xercesParser; + std::cout << "parsing " << resolvedFile << std::endl; + xercesParser.ParseFileAndNavigate(resolvedFile); + std::cout << "done parsing " << resolvedFile << std::endl; + + const GeoLogVol* trenchLog = m_controller.retrieveLogicalVolume("Trench").first; + GeoPhysVol* trenchPhys = new GeoPhysVol(trenchLog); + GeoNameTag *tag = new GeoNameTag("Trench"); + world->add(tag); + world->add(trenchPhys); + m_detectorManager->addTreeTop(trenchPhys); +} + +const TrenchDetectorManager * TrenchDetectorFactory::getDetectorManager() const +{ + return m_detectorManager; +} + +void TrenchDetectorFactory::setTagNode(const std::string& tag, + const std::string& node) +{ + m_versionTag = tag; + m_versionNode = node; +} + diff --git a/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.h b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.h new file mode 100644 index 00000000..07dcad5c --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrenchDetectorFactory_h +#define TrenchDetectorFactory_h 1 + +#include "GeoModelKernel/GeoVDetectorFactory.h" +#include "TrenchDetectorManager.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "GDMLInterface/GDMLController.h" + +#include <string> + +class StoreGateSvc; + +class TrenchDetectorFactory : public GeoVDetectorFactory +{ + + public: + + // Constructor: + TrenchDetectorFactory(StoreGateSvc *pDetStore, + IRDBAccessSvc *pAccess); + + // Destructor: + ~TrenchDetectorFactory(); + + // Creation of geometry: + virtual void create(GeoPhysVol *world); + + // Access to the results: + virtual const TrenchDetectorManager * getDetectorManager() const; + + // Set version Tag and Node + void setTagNode(const std::string& tag, const std::string& node); + + + private: + // Illegal operations: + const TrenchDetectorFactory & operator=(const TrenchDetectorFactory &right); + TrenchDetectorFactory(const TrenchDetectorFactory &right); + + // The manager: + TrenchDetectorManager *m_detectorManager; + + StoreGateSvc *m_detectorStore; + IRDBAccessSvc *m_access; + std::string m_versionTag; + std::string m_versionNode; + + GDMLController m_controller {"TrenchGDMLController"}; + +}; + +// Class TrenchDetectorFactory +#endif + + diff --git a/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorManager.cxx b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorManager.cxx new file mode 100644 index 00000000..f8df3b92 --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorManager.cxx @@ -0,0 +1,38 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrenchDetectorManager.h" + +TrenchDetectorManager::TrenchDetectorManager() +{ + setName("Trench"); +} + + +TrenchDetectorManager::~TrenchDetectorManager() +{ + for(unsigned int i=0; i<m_treeTops.size(); i++) + m_treeTops[i]->unref(); +} + + +unsigned int TrenchDetectorManager::getNumTreeTops() const +{ + return m_treeTops.size(); +} + +PVConstLink TrenchDetectorManager::getTreeTop(unsigned int i) const +{ + if(i<m_treeTops.size()) + return m_treeTops[i]; + else + return 0; +} + +void TrenchDetectorManager::addTreeTop(PVLink link) +{ + link->ref(); + m_treeTops.push_back(link); +} + diff --git a/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorManager.h b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorManager.h new file mode 100644 index 00000000..87ea3d0c --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorManager.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrenchDetectorManager_h +#define TrenchDetectorManager_h 1 + +#include "GeoModelKernel/GeoVPhysVol.h" +#include "GeoModelKernel/GeoVDetectorManager.h" +#include <vector> + +class TrenchDetectorManager : public GeoVDetectorManager +{ + public: + + // Constructor + TrenchDetectorManager(); + + // Destructor + ~TrenchDetectorManager(); + + // Access to raw geometry: + virtual unsigned int getNumTreeTops() const; + virtual PVConstLink getTreeTop(unsigned int i) const; + + void addTreeTop(PVLink); // Add a Tree top: + + private: + + const TrenchDetectorManager & operator=(const TrenchDetectorManager &right); + TrenchDetectorManager(const TrenchDetectorManager &right); + + // Tree Tops + std::vector<PVLink> m_treeTops; +}; + +#ifndef GAUDI_NEUTRAL +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF(TrenchDetectorManager, 124400828, 1) +#endif + +#endif + + diff --git a/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorTool.cxx b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorTool.cxx new file mode 100644 index 00000000..cfd2b94f --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorTool.cxx @@ -0,0 +1,106 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrenchDetectorTool.h" +#include "TrenchDetectorFactory.h" +#include "TrenchDetectorManager.h" + +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "GeoModelFaserUtilities/GeoModelExperiment.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" + +#include "boost/algorithm/string/predicate.hpp" + +TrenchDetectorTool::TrenchDetectorTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : GeoModelTool( type, name, parent ), + m_manager(0) +{ +} + +TrenchDetectorTool::~TrenchDetectorTool() +{ +} + + +StatusCode TrenchDetectorTool::create() +{ + IGeoDbTagSvc *geoDbTag; + StatusCode sc = service ("GeoDbTagSvc",geoDbTag); + if(sc.isFailure()) { + msg(MSG::ERROR) << "Could not locate GeoDbTagSvc" << endmsg; + return sc; + } + + IRDBAccessSvc* raccess = 0; + sc = service("RDBAccessSvc",raccess); + if(sc.isFailure()) { + msg(MSG::ERROR) << "Could not locate RDBAccessSvc" << endmsg; + return sc; + } + + DecodeFaserVersionKey versionKey(geoDbTag,"Trench"); + IRDBRecordset_ptr switchSet + = raccess->getRecordsetPtr("TrenchSwitches", versionKey.tag(), versionKey.node(),"FASERDD"); + const IRDBRecord *switches = (*switchSet)[0]; + msg(MSG::DEBUG) << "Retrieved TrenchSwitches" << endmsg; + + +// std::string trenchVersion = geoDbTag->trenchVersion(); + std::string trenchVersion = versionKey.tag(); + msg(MSG::INFO) << "Building Trench geometry version " << trenchVersion << endmsg; + if(trenchVersion.empty()) { + msg(MSG::INFO) << "No Trench version for the given configuration. Skip building TrenchGeoModel" << endmsg; + return StatusCode::SUCCESS; + } + + std::string versionNode = versionKey.node(); + + GeoModelExperiment* theExpt = nullptr; + if (StatusCode::SUCCESS != detStore()->retrieve(theExpt,"FASER")) { + msg(MSG::ERROR) << "Could not find GeoModelExperiment FASER" << endmsg; + return StatusCode::FAILURE; + } + + GeoPhysVol *world=&*theExpt->getPhysVol(); + + if(!m_manager) { + // If geometry has not been built yet fall back to the default factory + TrenchDetectorFactory theTrenchFactory(detStore().operator->(),raccess); + theTrenchFactory.setTagNode(trenchVersion,versionNode); + theTrenchFactory.create(world); + m_manager = theTrenchFactory.getDetectorManager(); + } + + if(m_manager) { + theExpt->addManager(m_manager); + sc = detStore()->record(m_manager, + m_manager->getName()); + if(sc.isFailure()) { + msg(MSG::ERROR) << "Could not register Trench detector manager" << endmsg; + return sc; + } + } + else { + msg(MSG::ERROR) << "ERROR. Failed to build Trench Version " << trenchVersion << endmsg; + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode TrenchDetectorTool::clear() +{ + SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<TrenchDetectorManager>::ID(),m_manager->getName()); + if(proxy) { + proxy->reset(); + m_manager = 0; + } + return StatusCode::SUCCESS; +} + diff --git a/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorTool.h b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorTool.h new file mode 100644 index 00000000..6c540766 --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorTool.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRENCHDETECTORTOOL_H +#define TRENCHDETECTORTOOL_H + +#include "GeoModelFaserUtilities/GeoModelTool.h" +class TrenchDetectorManager; + +class TrenchDetectorTool final : public GeoModelTool +{ + public: + + // Standard Constructor + TrenchDetectorTool( const std::string& type, const std::string& name, const IInterface* parent ); + + // Standard Destructor + virtual ~TrenchDetectorTool() override final; + + virtual StatusCode create() override final; + virtual StatusCode clear() override final; + + private: + const TrenchDetectorManager* m_manager; +}; + +#endif diff --git a/FaserGeometryCommon/TrenchGeoModel/src/components/TrenchGeoModel_entries.cxx b/FaserGeometryCommon/TrenchGeoModel/src/components/TrenchGeoModel_entries.cxx new file mode 100644 index 00000000..732ee6b6 --- /dev/null +++ b/FaserGeometryCommon/TrenchGeoModel/src/components/TrenchGeoModel_entries.cxx @@ -0,0 +1,3 @@ +#include "../TrenchDetectorTool.h" + +DECLARE_COMPONENT( TrenchDetectorTool ) \ No newline at end of file diff --git a/Simulation/G4Faser/G4FaserAlg/test/G4FaserAlgConfigNew_Test.py b/Simulation/G4Faser/G4FaserAlg/test/G4FaserAlgConfigNew_Test.py index 883e1e8e..0caf7f3f 100644 --- a/Simulation/G4Faser/G4FaserAlg/test/G4FaserAlgConfigNew_Test.py +++ b/Simulation/G4Faser/G4FaserAlg/test/G4FaserAlgConfigNew_Test.py @@ -73,7 +73,7 @@ if __name__ == '__main__': if ConfigFlags.GeoModel.FaserVersion.count("FASERNU") > 0 : detectors += ['Emulsion'] if ConfigFlags.GeoModel.FaserVersion.count("FASERNU-03") > 0: - detectors += ['VetoNu'] + detectors += ['VetoNu', 'Trench'] # # Setup detector flags # diff --git a/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py b/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py index 54d41cf8..4f4de1b8 100644 --- a/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py +++ b/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py @@ -128,3 +128,12 @@ def EcalFieldManagerToolCfg(ConfigFlags, name='EcalFieldManager', **kwargs): kwargs.setdefault('MinimumEpsilonStep', 0.00001) return BasicDetectorFieldManagerToolCfg(ConfigFlags, name, **kwargs) +def TrenchFieldManagerToolCfg(ConfigFlags, name='TrenchFieldManager', **kwargs): + kwargs.setdefault("LogicalVolumes", ['Trench::Trench']) + #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 BasicDetectorFieldManagerToolCfg(ConfigFlags, name, **kwargs) + diff --git a/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py b/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py index 92a3cc96..8e9bb2aa 100644 --- a/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py +++ b/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py @@ -7,10 +7,10 @@ from AthenaConfiguration.ComponentFactory import CompFactory from AthenaCommon import Logging #the physics region tools -from G4FaserTools.G4PhysicsRegionConfigNew import NeutrinoPhysicsRegionToolCfg, TrackerPhysicsRegionToolCfg, ScintillatorPhysicsRegionToolCfg, EcalPhysicsRegionToolCfg +from G4FaserTools.G4PhysicsRegionConfigNew import NeutrinoPhysicsRegionToolCfg, TrackerPhysicsRegionToolCfg, ScintillatorPhysicsRegionToolCfg, EcalPhysicsRegionToolCfg, CavernPhysicsRegionToolCfg #the field config tools -from G4FaserTools.G4FieldConfigNew import FASERFieldManagerToolCfg, EmulsionFieldManagerToolCfg, VetoFieldManagerToolCfg, VetoNuFieldManagerToolCfg, TriggerFieldManagerToolCfg, PreshowerFieldManagerToolCfg, TrackerFieldManagerToolCfg, DipoleFieldManagerToolCfg, EcalFieldManagerToolCfg +from G4FaserTools.G4FieldConfigNew import FASERFieldManagerToolCfg, EmulsionFieldManagerToolCfg, VetoFieldManagerToolCfg, VetoNuFieldManagerToolCfg, TriggerFieldManagerToolCfg, PreshowerFieldManagerToolCfg, TrackerFieldManagerToolCfg, DipoleFieldManagerToolCfg, EcalFieldManagerToolCfg, TrenchFieldManagerToolCfg from G4FaserTools.G4FaserToolsConfigNew import SensitiveDetectorMasterToolCfg @@ -23,6 +23,7 @@ from PreshowerGeoModel.PreshowerGeoModelConfig import PreshowerGeometryCfg from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg from DipoleGeoModel.DipoleGeoModelConfig import DipoleGeometryCfg from EcalGeoModel.EcalGeoModelConfig import EcalGeometryCfg +from FaserGeoModel.TrenchGMConfig import TrenchGeometryCfg BoxEnvelope, MaterialDescriptionTool, VoxelDensityTool, G4AtlasDetectorConstructionTool = CompFactory.getComps("BoxEnvelope", "MaterialDescriptionTool", "VoxelDensityTool", "G4AtlasDetectorConstructionTool",) @@ -120,6 +121,16 @@ def EcalGeoDetectorToolCfg(ConfigFlags, name='Ecal', **kwargs): result.setPrivateTools(GeoDetectorTool(name, **kwargs)) return result +def TrenchGeoDetectorToolCfg(ConfigFlags, name='Trench', **kwargs): + #set up geometry + result=TrenchGeometryCfg(ConfigFlags) + kwargs.setdefault("DetectorName", "Trench") + #add the GeometryNotifierSvc + result.addService(G4GeometryNotifierSvcCfg(ConfigFlags)) + kwargs.setdefault("GeometryNotifierSvc", result.getService("G4GeometryNotifierSvc")) + result.setPrivateTools(GeoDetectorTool(name, **kwargs)) + return result + def generateSubDetectorList(ConfigFlags): result = ComponentAccumulator() SubDetectorList=[] @@ -155,6 +166,11 @@ def generateSubDetectorList(ConfigFlags): if ConfigFlags.Detector.GeometryEcal: toolEcal = result.popToolsAndMerge(EcalGeoDetectorToolCfg(ConfigFlags)) SubDetectorList += [ toolEcal ] + + if ConfigFlags.Detector.GeometryTrench: + toolTrench = result.popToolsAndMerge(TrenchGeoDetectorToolCfg(ConfigFlags)) + SubDetectorList += [ toolTrench ] + result.setPrivateTools(SubDetectorList) return result @@ -211,6 +227,9 @@ def getFASER_RegionCreatorList(ConfigFlags): if ConfigFlags.Detector.GeometryFaserCalo: regionCreatorList += [EcalPhysicsRegionToolCfg(ConfigFlags)] + + if ConfigFlags.Detector.GeometryCavern: + regionCreatorList += [CavernPhysicsRegionToolCfg(ConfigFlags)] return regionCreatorList @@ -262,6 +281,12 @@ def FASER_FieldMgrListCfg(ConfigFlags): tool = result.popToolsAndMerge(acc) fieldMgrList += [tool] + if ConfigFlags.Detector.GeometryTrench: + acc = TrenchFieldManagerToolCfg(ConfigFlags) + tool = result.popToolsAndMerge(acc) + fieldMgrList += [tool] + + result.setPrivateTools(fieldMgrList) return result diff --git a/Simulation/G4Faser/G4FaserTools/python/G4PhysicsRegionConfigNew.py b/Simulation/G4Faser/G4FaserTools/python/G4PhysicsRegionConfigNew.py index c6ca63e4..42016881 100644 --- a/Simulation/G4Faser/G4FaserTools/python/G4PhysicsRegionConfigNew.py +++ b/Simulation/G4Faser/G4FaserTools/python/G4PhysicsRegionConfigNew.py @@ -45,3 +45,13 @@ def EcalPhysicsRegionToolCfg(ConfigFlags, name='EcalPhysicsRegionTool', **kwargs kwargs.setdefault("PositronCut", rangeEMB) kwargs.setdefault("GammaCut", rangeEMB) return RegionCreator(name, **kwargs) + +def CavernPhysicsRegionToolCfg(ConfigFlags, name='CavernPhysicsRegionTool', **kwargs): + kwargs.setdefault("RegionName", 'Cavern') + volumeList = ['Trench::Trench'] + kwargs.setdefault("VolumeList", volumeList) + kwargs.setdefault("ElectronCut", 0.05) + kwargs.setdefault("PositronCut", 0.05) + kwargs.setdefault("GammaCut", 0.05) + return RegionCreator(name, **kwargs) + -- GitLab