From feea778c9d19b3271260d467d16b76f9cc59d451 Mon Sep 17 00:00:00 2001
From: Tobias Boeckh <tobias.boeckh@cern.ch>
Date: Wed, 20 Jan 2021 01:07:17 +0100
Subject: [PATCH] cosmics

---
 .../python/TrackerDataAccessExampleConfig.py  |   4 +-
 .../python/MagFieldServicesConfig.py          |   9 +-
 .../src/TrackerDataDecoderTool.cxx            |   2 +-
 .../FaserSpacePoints/CMakeLists.txt           |  12 ++
 .../python/FaserSpacePointsCosmics.py         |  92 ++++++++++++++++
 .../FaserSpacePoints/python/__init__.py       |   0
 .../FaserSpacePoints/src/FaserSpacePoints.cxx | 104 ++++++++++++++++++
 .../FaserSpacePoints/src/FaserSpacePoints.h   |  46 ++++++++
 .../components/FaserSpacePoints_entries.cxx   |   3 +
 .../test/FaserSCT_ClusterizationDbgCosmics.py |  66 +++++++++++
 .../TrackerSpacePointFormationDbgCosmics.py   |  66 +++++++++++
 11 files changed, 397 insertions(+), 7 deletions(-)
 create mode 100644 Tracker/TrackerRecAlgs/FaserSpacePoints/CMakeLists.txt
 create mode 100644 Tracker/TrackerRecAlgs/FaserSpacePoints/python/FaserSpacePointsCosmics.py
 create mode 100644 Tracker/TrackerRecAlgs/FaserSpacePoints/python/__init__.py
 create mode 100644 Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.cxx
 create mode 100644 Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.h
 create mode 100644 Tracker/TrackerRecAlgs/FaserSpacePoints/src/components/FaserSpacePoints_entries.cxx
 create mode 100644 Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbgCosmics.py
 create mode 100644 Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/TrackerSpacePointFormationDbgCosmics.py

diff --git a/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py b/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py
index e54397f4..d420ec08 100644
--- a/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py
+++ b/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py
@@ -33,11 +33,11 @@ if __name__ == "__main__":
     ConfigFlags.Input.isMC = False                               # Needed to bypass autoconfig
     ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX"          # Needed to bypass autoconfig, only the "OFLCOND" matters at the moment
     ConfigFlags.IOVDb.DatabaseInstance = "OFLP200"               # Use MC conditions for now
-    ConfigFlags.GeoModel.FaserVersion     = "FASER-CR"           # FASER cosmic ray geometry (station 2 only)
+    ConfigFlags.GeoModel.FaserVersion     = "FASER-01"           # FASER geometry
     ConfigFlags.Input.ProjectName = "data20"                     # Needed to bypass autoconfig
     ConfigFlags.GeoModel.Align.Dynamic    = False
     ConfigFlags.Input.Files = ["cosmics.raw"]
-    ConfigFlags.Output.RDOFileName = "tracker.RDO.pool.root"
+    ConfigFlags.Output.RDOFileName = "my.RDO.pool.root"
     ConfigFlags.lock()
 
 # Configure components
diff --git a/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py b/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py
index eea0f453..4ebac8a5 100644
--- a/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py
+++ b/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py
@@ -50,10 +50,11 @@ def MagneticFieldSvcCfg(flags, **kwargs):
     # This handles addFolderSplitMC https://gitlab.cern.ch/atlas/athena/blob/master/Database/IOVDbSvc/python/CondDB.py#L240
     # i.e. replaces conddb.addFolderSplitMC('GLOBAL','/GLOBAL/BField/Maps <noover/>','/GLOBAL/BField/Maps <noover/>')
     # def addFolders(configFlags,folderstrings,detDb=None,className=None):
-    if flags.Input.isMC:
-        db='GLOBAL_OFL'
-    else:
-        db='GLOBAL'
+    db='GLOBAL_OFL'
+    # if flags.Input.isMC:
+    #     db='GLOBAL_OFL'
+    # else:
+    #     db='GLOBAL'
         
     result.merge(addFolders(flags,['/GLOBAL/BField/Maps <noover/>'],detDb=db, className="CondAttrListCollection") )
     result.merge(addFolders(flags,['/GLOBAL/BField/Scales <noover/>'],detDb=db, className="CondAttrListCollection") )
diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx
index 7f7763b8..b84a5fd1 100644
--- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx
+++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx
@@ -114,7 +114,7 @@ TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re,
     ATH_MSG_DEBUG("Fragment:\n" << *frag);
     uint32_t trb = frag->source_id() & 0x0000FFFF;
     // FIXME: will need to be updated for interface detector
-    int station = 2 + trb / TrackerDataFragment::PLANES_PER_STATION; 
+    int station = 1 + trb / TrackerDataFragment::PLANES_PER_STATION; 
     int plane = trb % TrackerDataFragment::PLANES_PER_STATION;
     
     // Exceptions are a no-no in Athena/Calypso, so catch any thrown by faser-common
diff --git a/Tracker/TrackerRecAlgs/FaserSpacePoints/CMakeLists.txt b/Tracker/TrackerRecAlgs/FaserSpacePoints/CMakeLists.txt
new file mode 100644
index 00000000..4978495c
--- /dev/null
+++ b/Tracker/TrackerRecAlgs/FaserSpacePoints/CMakeLists.txt
@@ -0,0 +1,12 @@
+################################################################################
+# Package: FaserSpacePoints
+################################################################################
+
+# Declare the package name:
+atlas_subdir( FaserSpacePoints )
+
+atlas_add_component( FaserSpacePoints
+                     src/components/*.cxx src/*.cxx src/*.h
+	                   LINK_LIBRARIES AthenaBaseComps TrackerSpacePoint TrackerPrepRawData)
+
+atlas_install_python_modules( python/*.py )
\ No newline at end of file
diff --git a/Tracker/TrackerRecAlgs/FaserSpacePoints/python/FaserSpacePointsCosmics.py b/Tracker/TrackerRecAlgs/FaserSpacePoints/python/FaserSpacePointsCosmics.py
new file mode 100644
index 00000000..3285654c
--- /dev/null
+++ b/Tracker/TrackerRecAlgs/FaserSpacePoints/python/FaserSpacePointsCosmics.py
@@ -0,0 +1,92 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+import sys
+from AthenaCommon.Logging import log, logging
+from AthenaCommon.Constants import DEBUG, VERBOSE, INFO
+from AthenaCommon.Configurable import Configurable
+from CalypsoConfiguration.AllConfigFlags import ConfigFlags
+from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
+from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
+# from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
+from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
+# from Digitization.DigitizationParametersConfig import writeDigitizationMetadata
+from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg
+from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from AthenaConfiguration.ComponentFactory import CompFactory
+
+Tracker__TruthSeededTrackFinder, THistSvc=CompFactory.getComps("Tracker::FaserSpacePoints", "THistSvc")
+
+
+def TruthSeededTrackFinderBasicCfg(flags, **kwargs):
+    """Return ComponentAccumulator for TruthSeededTrackFinder"""
+    acc = ComponentAccumulator()
+    kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer")
+    acc.addEventAlgo(Tracker__TruthSeededTrackFinder(**kwargs))
+   # attach ToolHandles
+    return acc
+
+def TruthSeededTrackFinder_OutputCfg(flags):
+    """Return ComponentAccumulator with Output for SCT. Not standalone."""
+    acc = ComponentAccumulator()
+    acc.merge(OutputStreamCfg(flags, "ESD"))
+    ostream = acc.getEventAlgo("OutputStreamESD")
+    ostream.TakeItemsFromInput = True
+    return acc
+
+def FaserSpacePointsCfg(flags, **kwargs):
+    acc=TruthSeededTrackFinderBasicCfg(flags, **kwargs)
+    histSvc= THistSvc()
+    histSvc.Output += [ "TruthTrackSeeds DATAFILE='truthtrackseeds.root' OPT='RECREATE'" ]
+    acc.addService(histSvc)
+    acc.merge(TruthSeededTrackFinder_OutputCfg(flags))
+    return acc
+
+if __name__ == "__main__":
+  log.setLevel(DEBUG)
+  Configurable.configurableRun3Behavior = True
+
+  # Configure
+  ConfigFlags.Input.Files = ['my.RDO.pool.root']
+  ConfigFlags.Output.ESDFileName = "mySeeds.ESD.pool.root"
+  ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX"
+  ConfigFlags.IOVDb.DatabaseInstance = "OFLP200"               # Use MC conditions for now
+  ConfigFlags.Input.ProjectName = "data20"                     # Needed to bypass autoconfig
+  ConfigFlags.Input.isMC = False                               # Needed to bypass autoconfig
+  ConfigFlags.GeoModel.FaserVersion     = "FASER-01"           # FASER cosmic ray geometry (station 2 only)
+  ConfigFlags.Common.isOnline = False
+  ConfigFlags.GeoModel.Align.Dynamic = False
+  ConfigFlags.Beam.NumberOfCollisions = 0.
+
+  ConfigFlags.lock()
+
+  # Core components
+  acc = MainServicesCfg(ConfigFlags)
+  acc.merge(PoolReadCfg(ConfigFlags))
+
+  #acc.merge(writeDigitizationMetadata(ConfigFlags))
+
+  # Inner Detector
+  acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags))
+  acc.merge(TrackerSpacePointFinderCfg(ConfigFlags))
+  acc.merge(FaserSpacePointsCfg(ConfigFlags))
+
+  # Timing
+  #acc.merge(MergeRecoTimingObjCfg(ConfigFlags))
+
+  # Dump config
+  logging.getLogger('forcomps').setLevel(VERBOSE)
+  acc.foreach_component("*").OutputLevel = VERBOSE
+  acc.foreach_component("*ClassID*").OutputLevel = INFO
+  # acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE
+  # acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE
+  acc.getService("StoreGateSvc").Dump = True
+  acc.getService("ConditionStore").Dump = True
+  acc.printConfig(withDetails=True)
+  ConfigFlags.dump()
+
+  # Execute and finish
+  sc = acc.run(maxEvents=-1)
+
+  # Success should be 0
+  sys.exit(not sc.isSuccess())
diff --git a/Tracker/TrackerRecAlgs/FaserSpacePoints/python/__init__.py b/Tracker/TrackerRecAlgs/FaserSpacePoints/python/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.cxx b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.cxx
new file mode 100644
index 00000000..cda36287
--- /dev/null
+++ b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.cxx
@@ -0,0 +1,104 @@
+#include "FaserSpacePoints.h"
+#include "Identifier/Identifier.h"
+#include "TrkSpacePoint/SpacePoint.h"
+#include "TrackerPrepRawData/TrackerClusterCollection.h"
+
+namespace Tracker {
+  FaserSpacePoints::FaserSpacePoints(const std::string& name, ISvcLocator* pSvcLocator)
+    : AthReentrantAlgorithm(name, pSvcLocator) { }
+
+  
+  StatusCode FaserSpacePoints::initialize() {
+    ATH_MSG_INFO(name() << "::" << __FUNCTION__);
+
+    if ( m_sct_spcontainer.key().empty()) {
+      ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters");
+      return StatusCode::FAILURE;
+    }
+    ATH_CHECK( m_sct_spcontainer.initialize() );
+
+    ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID"));
+
+    std::string filePath = m_filePath;
+    m_outputFile = TFile::Open(filePath.c_str(), "RECREATE");
+    if (m_outputFile == nullptr) {
+      ATH_MSG_ERROR("Unable to open output file at " << m_filePath);
+      return StatusCode::FAILURE;
+    }
+    m_outputFile->cd();
+
+    std::string treeName = m_treeName;
+    m_outputTree = new TTree(treeName.c_str(), "tree");
+    if (m_outputTree == nullptr) {
+      ATH_MSG_ERROR("Unable to create TTree");
+      return StatusCode::FAILURE;
+    }
+
+    FaserSpacePoints::initializeTree();
+    return StatusCode::SUCCESS;
+  }
+
+  
+  StatusCode FaserSpacePoints::finalize() {
+    ATH_MSG_INFO(name() << "::" << __FUNCTION__);
+    m_outputFile->cd();
+    m_outputTree->Write();
+    return StatusCode::SUCCESS;
+  }
+
+  
+  StatusCode FaserSpacePoints::execute(const EventContext& ctx) const {
+    ATH_MSG_INFO(name() << "::" << __FUNCTION__);
+  
+    m_run = ctx.eventID().run_number();
+    m_event = ctx.eventID().event_number();
+    ATH_MSG_DEBUG("run = " << m_run);
+    ATH_MSG_DEBUG("event = " << m_event);
+
+    SG::ReadHandle<SpacePointContainer> sct_spcontainer( m_sct_spcontainer, ctx );
+    if (!sct_spcontainer.isValid()){
+      ATH_MSG_FATAL("Could not find the data object " << sct_spcontainer.name());
+      return StatusCode::RECOVERABLE;
+    }
+
+    m_nCollections = sct_spcontainer->size();
+    ATH_MSG_DEBUG("nCollections = " << m_nCollections);
+    SpacePointContainer::const_iterator it = sct_spcontainer->begin();
+    SpacePointContainer::const_iterator it_end = sct_spcontainer->end();
+
+    for(; it != it_end; ++it) {
+      const SpacePointCollection* col = *it;
+      m_nSpacepoints = col->size();
+      ATH_MSG_DEBUG("nSpacepoints = " << m_nSpacepoints);
+
+      SpacePointCollection::const_iterator it_sp = col->begin();
+      SpacePointCollection::const_iterator it_sp_end = col->end();
+      for (; it_sp != it_sp_end; ++it_sp) {
+        const Trk::SpacePoint* sp = *it_sp;
+        const Identifier id = sp->clusterList().first->identify();
+        int station = m_idHelper->station(id);
+        int plane = m_idHelper->layer(id);
+        m_layer = (station - 1) * 3 + plane;
+
+        Amg::Vector3D position = sp->globalPosition();
+        m_x = position.x();
+        m_y = position.y();
+        m_z = position.z();
+
+        m_outputTree->Fill();
+      }
+    }
+    return StatusCode::SUCCESS;
+  }
+
+  void FaserSpacePoints::initializeTree() {
+    m_outputTree->Branch("run", &m_run);
+    m_outputTree->Branch("event", &m_event);
+    m_outputTree->Branch("layer", &m_layer);
+    m_outputTree->Branch("n_collections", &m_nCollections);
+    m_outputTree->Branch("n_spacepoints", &m_nSpacepoints);
+    m_outputTree->Branch("x", &m_x);
+    m_outputTree->Branch("y", &m_y);
+    m_outputTree->Branch("z", &m_z);
+  }
+}
\ No newline at end of file
diff --git a/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.h b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.h
new file mode 100644
index 00000000..06749929
--- /dev/null
+++ b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.h
@@ -0,0 +1,46 @@
+#ifndef FASERSPACEPOINTS_H
+#define FASERSPACEPOINTS_H
+
+#include "AthenaBaseComps/AthReentrantAlgorithm.h"
+#include "TrackerIdentifier/FaserSCT_ID.h"
+#include "TrkSpacePoint/SpacePointContainer.h"
+#include <string>
+#include <atomic>
+
+#include "TTree.h"
+#include "TFile.h"
+
+namespace Tracker {
+  class FaserSpacePoints : public AthReentrantAlgorithm {
+   public:
+    FaserSpacePoints(const std::string& name, ISvcLocator* pSvcLocator);
+    virtual ~FaserSpacePoints() = default;
+
+    virtual StatusCode initialize() override;
+    virtual StatusCode execute(const EventContext& ctx) const override;
+    virtual StatusCode finalize() override;
+
+   private:
+    void initializeTree();
+
+    mutable int m_run{0};
+    mutable int m_event{0};
+    mutable int m_layer{0};
+    mutable int m_nCollections{0};
+    mutable int m_nSpacepoints{0};
+    mutable float m_x{0};
+    mutable float m_y{0};
+    mutable float m_z{0};
+
+    const FaserSCT_ID* m_idHelper{nullptr};
+    SG::ReadHandleKey<SpacePointContainer> m_sct_spcontainer{this, "SpacePointsSCTName", "SCT spacepoint container"};
+
+    Gaudi::Property<std::string> m_filePath{this, "FilePath", "spacepoints.root", "Output root file for spacepoints"};
+    Gaudi::Property<std::string> m_treeName{this, "TreeName", "tree", ""};
+
+    TFile* m_outputFile;
+    TTree* m_outputTree;
+  };
+}
+
+#endif // FASERSPACEPOINTS_H
\ No newline at end of file
diff --git a/Tracker/TrackerRecAlgs/FaserSpacePoints/src/components/FaserSpacePoints_entries.cxx b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/components/FaserSpacePoints_entries.cxx
new file mode 100644
index 00000000..d8d0460a
--- /dev/null
+++ b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/components/FaserSpacePoints_entries.cxx
@@ -0,0 +1,3 @@
+#include "../FaserSpacePoints.h"
+
+DECLARE_COMPONENT( Tracker::FaserSpacePoints )
\ No newline at end of file
diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbgCosmics.py b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbgCosmics.py
new file mode 100644
index 00000000..cbc4beec
--- /dev/null
+++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbgCosmics.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+"""Test various ComponentAccumulator Digitization configuration modules
+
+Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+"""
+import sys
+from AthenaCommon.Logging import log, logging
+from AthenaCommon.Constants import DEBUG, VERBOSE, INFO
+from AthenaCommon.Configurable import Configurable
+from CalypsoConfiguration.AllConfigFlags import ConfigFlags
+from AthenaConfiguration.TestDefaults import defaultTestFiles
+from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
+from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
+from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
+from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
+#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata
+from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg
+#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg
+
+# Set up logging and new style config
+log.setLevel(DEBUG)
+Configurable.configurableRun3Behavior = True
+
+# Configure
+ConfigFlags.Input.Files = ['my.RDO.pool.root']
+ConfigFlags.Output.ESDFileName = "myClusters.ESD.pool.root"
+ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX"          # Needed to bypass autoconfig, only the "OFLCOND" matters at the moment
+ConfigFlags.IOVDb.DatabaseInstance = "OFLP200"               # Use MC conditions for now
+ConfigFlags.Input.ProjectName = "data20"                     # Needed to bypass autoconfig
+ConfigFlags.Input.isMC = False                               # Needed to bypass autoconfig
+ConfigFlags.GeoModel.FaserVersion     = "FASER-01"           # FASER cosmic ray geometry (station 2 only)
+ConfigFlags.Common.isOnline = False
+ConfigFlags.GeoModel.Align.Dynamic = False
+ConfigFlags.Beam.NumberOfCollisions = 0.
+
+ConfigFlags.lock()
+
+# Core components
+acc = MainServicesCfg(ConfigFlags)
+acc.merge(PoolReadCfg(ConfigFlags))
+acc.merge(PoolWriteCfg(ConfigFlags))
+
+#acc.merge(writeDigitizationMetadata(ConfigFlags))
+
+# Inner Detector
+acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags))
+                   
+# Timing
+#acc.merge(MergeRecoTimingObjCfg(ConfigFlags))
+
+# Dump config
+# logging.getLogger('forcomps').setLevel(VERBOSE)
+# acc.foreach_component("*").OutputLevel = VERBOSE
+# acc.foreach_component("*ClassID*").OutputLevel = INFO
+# acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE
+# acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE
+# acc.getService("StoreGateSvc").Dump = True
+# acc.getService("ConditionStore").Dump = True
+# acc.printConfig(withDetails=True)
+# ConfigFlags.dump()
+
+# Execute and finish
+sc = acc.run(maxEvents=-1)
+
+# Success should be 0
+sys.exit(not sc.isSuccess())
\ No newline at end of file
diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/TrackerSpacePointFormationDbgCosmics.py b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/TrackerSpacePointFormationDbgCosmics.py
new file mode 100644
index 00000000..a02500c2
--- /dev/null
+++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/TrackerSpacePointFormationDbgCosmics.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+"""Test various ComponentAccumulator Digitization configuration modules
+
+Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+"""
+import sys
+from AthenaCommon.Logging import log, logging
+from AthenaCommon.Constants import DEBUG, VERBOSE, INFO
+from AthenaCommon.Configurable import Configurable
+from CalypsoConfiguration.AllConfigFlags import ConfigFlags
+from AthenaConfiguration.TestDefaults import defaultTestFiles
+from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
+from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
+from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
+from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
+#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata
+from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg
+from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg
+#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg
+
+# Set up logging and new style config
+log.setLevel(DEBUG)
+Configurable.configurableRun3Behavior = True
+
+# Configure
+ConfigFlags.Input.Files = ['my.RDO.pool.root']
+ConfigFlags.Output.ESDFileName = "mySpacePoints.ESD.pool.root"
+ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX"
+ConfigFlags.IOVDb.DatabaseInstance = "OFLP200"               # Use MC conditions for now
+ConfigFlags.Input.ProjectName = "data20"                     # Needed to bypass autoconfig
+ConfigFlags.Input.isMC = False                               # Needed to bypass autoconfig
+ConfigFlags.Common.isOnline = False
+ConfigFlags.GeoModel.FaserVersion     = "FASER-01"           # FASER cosmic ray geometry (station 2 only)
+ConfigFlags.GeoModel.Align.Dynamic = False
+ConfigFlags.Beam.NumberOfCollisions = 0.
+ConfigFlags.lock()
+
+# Core components
+acc = MainServicesCfg(ConfigFlags)
+acc.merge(PoolReadCfg(ConfigFlags))
+acc.merge(PoolWriteCfg(ConfigFlags))
+
+#acc.merge(writeDigitizationMetadata(ConfigFlags))
+
+# Inner Detector
+acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags))
+acc.merge(TrackerSpacePointFinderCfg(ConfigFlags))
+                   
+# Timing
+#acc.merge(MergeRecoTimingObjCfg(ConfigFlags))
+
+# Dump config
+# logging.getLogger('forcomps').setLevel(VERBOSE)
+# acc.foreach_component("*").OutputLevel = VERBOSE
+# acc.foreach_component("*ClassID*").OutputLevel = INFO
+# acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE
+# acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE
+# acc.getService("StoreGateSvc").Dump = True
+# acc.getService("ConditionStore").Dump = True
+# acc.printConfig(withDetails=True)
+# ConfigFlags.dump()
+
+# Execute and finish
+sc = acc.run(maxEvents=-1)
+# Success should be 0
+sys.exit(not sc.isSuccess())
-- 
GitLab