From f10ee783ddcd0217b8e8a9d8689501e2d3462403 Mon Sep 17 00:00:00 2001
From: Dave Casper <dcasper@uci.edu>
Date: Tue, 3 Aug 2021 15:22:41 +0000
Subject: [PATCH] Disable B-field for testbeam, and add example from Carl

---
 .../GeoModelTest/python/TestBeamTestConfig.py |  4 +++
 .../WaveformAnalysisExample/CMakeLists.txt    |  8 ++++++
 .../src/WaveformHitAlg.cxx                    | 26 +++++++++++++++++
 .../src/WaveformHitAlg.h                      | 28 +++++++++++++++++++
 .../WaveformAnalysisExample_entries.cxx       |  3 ++
 .../G4Faser/G4FaserAlg/test/runG4TestBeam.py  |  4 +++
 6 files changed, 73 insertions(+)
 create mode 100644 Control/CalypsoExample/WaveformAnalysisExample/CMakeLists.txt
 create mode 100644 Control/CalypsoExample/WaveformAnalysisExample/src/WaveformHitAlg.cxx
 create mode 100644 Control/CalypsoExample/WaveformAnalysisExample/src/WaveformHitAlg.h
 create mode 100644 Control/CalypsoExample/WaveformAnalysisExample/src/components/WaveformAnalysisExample_entries.cxx

diff --git a/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py b/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py
index f843b34d..641c9a75 100644
--- a/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py
+++ b/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py
@@ -14,6 +14,10 @@ def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs):
     # Initialize field service
     from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg
     a.merge(MagneticFieldSvcCfg(flags))
+    # Disable the field
+    cacheAlg = a.getCondAlgo("FaserFieldCacheCondAlg")
+    cacheAlg.UseDipoScale = 0.0
+    cacheAlg.UseDCS = False
 
     # Configure the algorithm itself
     GeoModelTestAlg = CompFactory.GeoModelTestAlg
diff --git a/Control/CalypsoExample/WaveformAnalysisExample/CMakeLists.txt b/Control/CalypsoExample/WaveformAnalysisExample/CMakeLists.txt
new file mode 100644
index 00000000..3c40f4c6
--- /dev/null
+++ b/Control/CalypsoExample/WaveformAnalysisExample/CMakeLists.txt
@@ -0,0 +1,8 @@
+atlas_subdir( WaveformAnalysisExample )
+
+atlas_add_component( WaveformAnalysisExample
+                    src/*.cxx
+		            src/components/WaveformAnalysisExample_entries.cxx
+                    LINK_LIBRARIES AthenaBaseComps xAODFaserWaveform
+        )
+
diff --git a/Control/CalypsoExample/WaveformAnalysisExample/src/WaveformHitAlg.cxx b/Control/CalypsoExample/WaveformAnalysisExample/src/WaveformHitAlg.cxx
new file mode 100644
index 00000000..1e6a1a68
--- /dev/null
+++ b/Control/CalypsoExample/WaveformAnalysisExample/src/WaveformHitAlg.cxx
@@ -0,0 +1,26 @@
+#include "WaveformHitAlg.h"
+
+WaveformHitAlg::WaveformHitAlg(const std::string& name, ISvcLocator* pSvcLocator)
+  : AthHistogramAlgorithm(name, pSvcLocator) { }
+
+WaveformHitAlg::~WaveformHitAlg() { }
+
+StatusCode WaveformHitAlg::initialize()
+{
+  //ATH_CHECK( m_faserWaveformHitKey.initialize() );
+  //ATH_MSG_INFO( "Using Faser WaveformHit collection with key " << m_faserWaveformHitKey.key());
+
+  return StatusCode::SUCCESS;
+}
+
+
+StatusCode WaveformHitAlg::execute()
+{
+  return StatusCode::SUCCESS;
+}
+
+
+StatusCode WaveformHitAlg::finalize()
+{
+  return StatusCode::SUCCESS;
+}
diff --git a/Control/CalypsoExample/WaveformAnalysisExample/src/WaveformHitAlg.h b/Control/CalypsoExample/WaveformAnalysisExample/src/WaveformHitAlg.h
new file mode 100644
index 00000000..6aa6798c
--- /dev/null
+++ b/Control/CalypsoExample/WaveformAnalysisExample/src/WaveformHitAlg.h
@@ -0,0 +1,28 @@
+#ifndef WAVEFORMANALYSISEXAMPLE_WAVEFORMHITALG_H
+#define WAVEFORMANALYSISEXAMPLE_WAVEFORMHITALG_H
+
+#include "AthenaBaseComps/AthHistogramAlgorithm.h"
+#include "xAODFaserWaveform/WaveformHitContainer.h"
+
+#include <TH1.h>
+
+/* WaveformHit reading example - Carl Gwilliam + Lottie Cavanagh, Liverpool */
+
+class WaveformHitAlg : public AthHistogramAlgorithm
+{
+public:
+  WaveformHitAlg(const std::string& name, ISvcLocator* pSvcLocator);
+  
+  virtual ~WaveformHitAlg();
+  
+  StatusCode initialize();
+  StatusCode execute();
+  StatusCode finalize();
+  
+private:
+  
+  SG::ReadHandle<xAOD::WaveformHitContainer> m_waveformHits;   
+  //SG::ReadHandleKey<xAOD::WaveformHitContainer> m_faserWaveformHitKey { this, "WaveformHitContainerKey", "CaloWaveformHits" };
+};
+
+#endif
diff --git a/Control/CalypsoExample/WaveformAnalysisExample/src/components/WaveformAnalysisExample_entries.cxx b/Control/CalypsoExample/WaveformAnalysisExample/src/components/WaveformAnalysisExample_entries.cxx
new file mode 100644
index 00000000..370b5668
--- /dev/null
+++ b/Control/CalypsoExample/WaveformAnalysisExample/src/components/WaveformAnalysisExample_entries.cxx
@@ -0,0 +1,3 @@
+#include "../WaveformHitAlg.h"
+
+DECLARE_COMPONENT( WaveformHitAlg )
diff --git a/Simulation/G4Faser/G4FaserAlg/test/runG4TestBeam.py b/Simulation/G4Faser/G4FaserAlg/test/runG4TestBeam.py
index acaec378..667e7605 100755
--- a/Simulation/G4Faser/G4FaserAlg/test/runG4TestBeam.py
+++ b/Simulation/G4Faser/G4FaserAlg/test/runG4TestBeam.py
@@ -112,6 +112,10 @@ if __name__ == "__main__":
 #    
     acc.merge(FaserGeometryCfg(ConfigFlags))
     acc.merge(G4FaserAlgCfg(ConfigFlags))
+    # Disable magnetic field
+    cacheAlg = acc.getCondAlgo("FaserFieldCacheCondAlg")
+    cacheAlg.UseDipoScale = 0.0
+    cacheAlg.UseDCS = False
     acc.addService(G4GeometryNotifierSvcCfg(ConfigFlags, ActivateLVNotifier=True))
 #
 # Verbosity
-- 
GitLab