Verified Commit 17a62c7b authored by Tadej Novak's avatar Tadej Novak
Browse files

Add HGTD overlay placeholder algorithm

parent 52c90d09
Pipeline #3994961 passed with stage
in 0 seconds
......@@ -28,12 +28,14 @@ def HGTD_TimingResolutionCfg(flags, name="HGTD_TimingResolution", **kwargs):
acc.setPrivateTools(CompFactory.HGTD_TimingResolution(name, **kwargs))
return acc
def HGTD_FrontEndToolCfg(flags, name="HGTD_FrontEndTool", **kwargs):
acc = ComponentAccumulator()
acc.setPrivateTools(CompFactory.HGTD_FrontEndTool(name, **kwargs))
return acc
def HGTD_SurfaceChargesGeneratorCfg(flags, name="HGTD_SurfaceChargesGenerator", **kwargs):
acc = ComponentAccumulator()
......@@ -43,6 +45,7 @@ def HGTD_SurfaceChargesGeneratorCfg(flags, name="HGTD_SurfaceChargesGenerator",
acc.setPrivateTools(CompFactory.HGTD_SurfaceChargesGenerator(name, **kwargs))
return acc
def HGTD_DigitizationBasicToolCfg(flags, name="HGTD_DigitizationBasicTool", **kwargs):
"""Return ComponentAccumulator with configured HGTD_DigitizationTool"""
acc = HGTD_ReadoutGeometryCfg(flags)
......@@ -60,6 +63,7 @@ def HGTD_DigitizationBasicToolCfg(flags, name="HGTD_DigitizationBasicTool", **kw
acc.setPrivateTools(CompFactory.HGTD_DigitizationTool(name, **kwargs))
return acc
def HGTD_DigitizationToolCfg(flags, name="HGTD_DigitizationTool", **kwargs):
"""Return ComponentAccumulator with configured HGTD_DigitizationBasicTool"""
acc = ComponentAccumulator()
......@@ -69,17 +73,25 @@ def HGTD_DigitizationToolCfg(flags, name="HGTD_DigitizationTool", **kwargs):
intervals += [acc.popToolsAndMerge(HGTD_RangeCfg(flags))]
kwargs.setdefault("MergeSvc", acc.getPrimaryAndMerge(PileUpMergeSvcCfg(flags, Intervals=intervals)).name)
else:
kwargs.setdefault("MergeSvc", '')
kwargs.setdefault("MergeSvc", "")
kwargs.setdefault("OnlyUseContainerName", flags.Digitization.PileUp)
if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
kwargs.setdefault("OutputObjectName", flags.Overlay.BkgPrefix + "HGTD_RDOs")
kwargs.setdefault("OutputSDOName", flags.Overlay.BkgPrefix + "HGTD_SDO_Map")
kwargs.setdefault("OutputObjectName", f"{flags.Overlay.BkgPrefix}HGTD_RDOs")
kwargs.setdefault("OutputSDOName", f"{flags.Overlay.BkgPrefix}HGTD_SDO_Map")
else:
kwargs.setdefault("OutputObjectName", "HGTD_RDOs")
kwargs.setdefault("OutputSDOName", "HGTD_SDO_Map")
tool = acc.popToolsAndMerge(HGTD_DigitizationBasicToolCfg(flags, name, **kwargs))
acc.setPrivateTools(tool)
return acc
return HGTD_DigitizationBasicToolCfg(flags, name, **kwargs)
def HGTD_OverlayDigitizationToolCfg(flags, name="HGTD_OverlayDigitizationTool", **kwargs):
"""Return ComponentAccumulator with HGTD_DigitizationTool configured for overlay"""
kwargs.setdefault("OnlyUseContainerName", False)
kwargs.setdefault("OutputObjectName", f"{flags.Overlay.SigPrefix}HGTD_RDOs")
kwargs.setdefault("OutputSDOName", f"{flags.Overlay.SigPrefix}HGTD_SDO_Map")
kwargs.setdefault("MergeSvc", "")
return HGTD_DigitizationBasicToolCfg(flags, name, **kwargs)
def HGTD_RangeCfg(flags, name="HGTD_Range", **kwargs):
"""Return a configured PileUpXingFolder tool"""
......@@ -89,6 +101,7 @@ def HGTD_RangeCfg(flags, name="HGTD_Range", **kwargs):
kwargs.setdefault("ItemList", ["SiHitCollection#HGTD_Hits"])
return PileUpXingFolderCfg(flags, name, **kwargs)
def HGTD_OutputCfg(flags):
"""Return ComponentAccumulator with Output for HGTD. Not standalone."""
acc = ComponentAccumulator()
......@@ -100,15 +113,36 @@ def HGTD_OutputCfg(flags):
acc.merge(OutputStreamCfg(flags, "RDO", ItemList))
return acc
def HGTD_DigitizationBasicCfg(flags, **kwargs):
"""Return ComponentAccumulator for HGTD digitization"""
acc = ComponentAccumulator()
if "PileUpTools" not in kwargs:
PileUpTools = acc.popToolsAndMerge(HGTD_DigitizationToolCfg(flags))
kwargs["PileUpTools"] = PileUpTools
kwargs["PileUpTools"] = acc.popToolsAndMerge(HGTD_DigitizationToolCfg(flags))
acc.merge(PileUpToolsCfg(flags, **kwargs))
return acc
def HGTD_OverlayDigitizationBasicCfg(flags, **kwargs):
"""Return ComponentAccumulator with HGTD Overlay digitization"""
acc = ComponentAccumulator()
if flags.Common.ProductionStep != ProductionStep.FastChain:
from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
acc.merge(SGInputLoaderCfg(flags, ["SiHitCollection#HGTD_Hits"]))
if "DigitizationTool" not in kwargs:
kwargs["DigitizationTool"] = acc.popToolsAndMerge(HGTD_OverlayDigitizationToolCfg(flags))
if flags.Concurrency.NumThreads > 0:
kwargs.setdefault("Cardinality", flags.Concurrency.NumThreads)
# Set common overlay extra inputs
kwargs.setdefault("ExtraInputs", flags.Overlay.ExtraInputs)
acc.addEventAlgo(CompFactory.HGTD_Digitization(name="HGTD_OverlayDigitization", **kwargs))
return acc
# with output defaults
def HGTD_DigitizationCfg(flags, **kwargs):
"""Return ComponentAccumulator for HGTD digitization and Output"""
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "HGTD_Digitization.h"
HGTD_Digitization::HGTD_Digitization(const std::string &name,
ISvcLocator *pSvcLocator)
: AthAlgorithm(name, pSvcLocator)
{
}
StatusCode HGTD_Digitization::initialize()
{
ATH_MSG_DEBUG("initialize()");
ATH_CHECK(m_HGTD_DigitizationTool.retrieve());
ATH_MSG_DEBUG("Successfully retreived HGTD digitization tool.");
return StatusCode::SUCCESS;
}
StatusCode HGTD_Digitization::execute()
{
ATH_MSG_DEBUG("execute()");
return m_HGTD_DigitizationTool->processAllSubEvents(Gaudi::Hive::currentContext());
}
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef HGTDDIGITIZATION_HGTDDIGITIZATION_H
#define HGTDDIGITIZATION_HGTDDIGITIZATION_H
#include <AthenaBaseComps/AthAlgorithm.h>
#include <GaudiKernel/ToolHandle.h>
#include <PileUpTools/IPileUpTool.h>
class HGTD_Digitization : public AthAlgorithm
{
public:
HGTD_Digitization(const std::string &name, ISvcLocator *pSvcLocator);
virtual ~HGTD_Digitization() = default;
virtual StatusCode initialize() override final;
virtual StatusCode execute() override final;
virtual bool isClonable() const override final { return true; }
private:
ToolHandle<IPileUpTool> m_HGTD_DigitizationTool {
this, "DigitizationTool", "HGTD_DigitizationTool", "HGTD_DigitizationTool name"
};
};
#endif // HGTDDIGITIZATION_HGTDDIGITIZATION_H
#include "../HGTD_Digitization.h"
#include "../HGTD_DigitizationTool.h"
#include "../HGTD_FrontEndTool.h"
#include "../HGTD_SurfaceChargesGenerator.h"
#include "../HGTD_TimingResolution.h"
DECLARE_COMPONENT(HGTD_Digitization)
DECLARE_COMPONENT(HGTD_DigitizationTool)
DECLARE_COMPONENT(HGTD_FrontEndTool)
DECLARE_COMPONENT(HGTD_SurfaceChargesGenerator)
......
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( HGTD_Overlay )
# External dependencies:
find_package( CLHEP )
find_package( GTest )
find_package( GMock )
# Unit Tests
atlas_add_test( HGTD_Overlay_test
SOURCES test/HGTD_Overlay_test.cxx src/HGTD_Overlay.cxx
INCLUDE_DIRS ${GTEST_INCLUDE_DIRS}
LINK_LIBRARIES ${GTEST_LIBRARIES} CxxUtils IDC_OverlayBase HGTD_RawData StoreGateLib TestTools
POST_EXEC_SCRIPT nopost.sh )
# Component(s) in the package:
atlas_add_component( HGTD_Overlay
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps AthenaKernel AtlasHepMCLib GaudiKernel IDC_OverlayBase HGTD_RawData )
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
# Configuration tests
# TODO: to be enabled once we have reasonable inputs
# atlas_add_test( HGTD_OverlayConfig_test
# SCRIPT test/HGTD_OverlayConfig_test.py
# POST_EXEC_SCRIPT nopost.sh )
"""Define methods to construct configured HGTD overlay algorithms
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
"""
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
def HGTD_OverlayAlgCfg(flags, name="HGTD_Overlay", **kwargs):
"""Return a ComponentAccumulator for HGTD overlay algorithm"""
acc = ComponentAccumulator()
kwargs.setdefault("BkgInputKey", f"{flags.Overlay.BkgPrefix}HGTD_RDOs")
kwargs.setdefault("SignalInputKey", f"{flags.Overlay.SigPrefix}HGTD_RDOs")
kwargs.setdefault("OutputKey", "HGTD_RDOs")
if not flags.Overlay.DataOverlay:
from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
acc.merge(SGInputLoaderCfg(flags, [f'HGTD_RDO_Container#{kwargs["BkgInputKey"]}']))
# Do HGTD overlay
acc.addEventAlgo(CompFactory.HGTD_Overlay(name, **kwargs))
# Setup output
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
"HGTD_RDO_Container#HGTD_RDOs"
]))
if flags.Output.doWriteRDO_SGNL:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[
f"HGTD_RDO_Container#{flags.Overlay.SigPrefix}HGTD_RDOs"
]))
return acc
def HGTD_TruthOverlayCfg(flags, name="HGTD_SDOOverlay", **kwargs):
"""Return a ComponentAccumulator for the HGTD SDO overlay algorithm"""
acc = ComponentAccumulator()
# We do not need background Pixel SDOs
kwargs.setdefault("BkgInputKey", "")
kwargs.setdefault("SignalInputKey", f"{flags.Overlay.SigPrefix}HGTD_SDO_Map")
kwargs.setdefault("OutputKey", "HGTD_SDO_Map")
# Do Pixel truth overlay
acc.addEventAlgo(CompFactory.InDetSDOOverlay(name, **kwargs))
# Setup output
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
"InDetSimDataCollection#HGTD_SDO_Map"
]))
if flags.Output.doWriteRDO_SGNL:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[
f"InDetSimDataCollection#{flags.Overlay.SigPrefix}HGTD_SDO_Map"
]))
return acc
def HGTD_OverlayCfg(flags):
"""Configure and return a ComponentAccumulator for HGTD overlay"""
acc = ComponentAccumulator()
# Add HGTD overlay digitization algorithm
from HGTD_Digitization.HGTD_DigitizationConfig import HGTD_OverlayDigitizationBasicCfg
acc.merge(HGTD_OverlayDigitizationBasicCfg(flags))
# Add HGTD overlay algorithm
acc.merge(HGTD_OverlayAlgCfg(flags))
# Add HGTD truth overlay
acc.merge(HGTD_TruthOverlayCfg(flags))
return acc
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "HGTD_Overlay.h"
#include <IDC_OverlayBase/IDC_OverlayHelpers.h>
namespace Overlay
{
// Specialize mergeChannelData() for the HGTD
template <>
void mergeChannelData(HGTD_RDO &/* baseDatum */,
const HGTD_RDO &/* additionalDatum */,
const IDC_OverlayBase *algorithm)
{
algorithm->msg(MSG::DEBUG) << "Overlay::mergeChannelData<HGTD_RDORawData>(): "
<< "Merging of data on the same channel is not explicitly implemented for HGTD_RDORawData" << endmsg;
}
// Specialize copyCollection() for the HGTD
template<>
std::unique_ptr<HGTD_RDO_Collection> copyCollection(const IdentifierHash &hashId,
const HGTD_RDO_Collection *collection)
{
auto outputCollection = std::make_unique<HGTD_RDO_Collection>(hashId);
outputCollection->setIdentifier(collection->identify());
for (const HGTD_RDO *existingDatum : *collection) {
// Owned by the collection
auto *datumCopy = new HGTD_RDO(existingDatum->identify(), existingDatum->getTOA(), existingDatum->getTOT(),
existingDatum->getBCID(), existingDatum->getL1ID(), existingDatum->getL1A());
outputCollection->push_back(datumCopy);
}
return outputCollection;
}
} // namespace Overlay
HGTD_Overlay::HGTD_Overlay(const std::string &name, ISvcLocator *pSvcLocator)
: IDC_OverlayBase(name, pSvcLocator)
{
}
StatusCode HGTD_Overlay::initialize()
{
ATH_MSG_DEBUG("Initializing...");
// Check and initialize keys
ATH_CHECK( m_bkgInputKey.initialize(!m_bkgInputKey.key().empty()) );
ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgInputKey);
ATH_CHECK( m_signalInputKey.initialize() );
ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalInputKey);
ATH_CHECK( m_outputKey.initialize() );
ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey);
return StatusCode::SUCCESS;
}
StatusCode HGTD_Overlay::execute(const EventContext& ctx) const
{
ATH_MSG_DEBUG("execute() begin");
// Reading the input RDOs
ATH_MSG_VERBOSE("Retrieving input RDO containers");
const HGTD_RDO_Container *bkgContainerPtr = nullptr;
if (!m_bkgInputKey.empty()) {
SG::ReadHandle<HGTD_RDO_Container> bkgContainer(m_bkgInputKey, ctx);
if (!bkgContainer.isValid()) {
ATH_MSG_ERROR("Could not get background HGTD RDO container " << bkgContainer.name() << " from store " << bkgContainer.store());
return StatusCode::FAILURE;
}
bkgContainerPtr = bkgContainer.cptr();
ATH_MSG_DEBUG("Found background HGTD RDO container " << bkgContainer.name() << " in store " << bkgContainer.store());
ATH_MSG_DEBUG("HGTD Background = " << Overlay::debugPrint(bkgContainer.cptr()));
}
SG::ReadHandle<HGTD_RDO_Container> signalContainer(m_signalInputKey, ctx);
if (!signalContainer.isValid()) {
ATH_MSG_ERROR("Could not get signal HGTD RDO container " << signalContainer.name() << " from store " << signalContainer.store());
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG("Found signal HGTD RDO container " << signalContainer.name() << " in store " << signalContainer.store());
ATH_MSG_DEBUG("HGTD Signal = " << Overlay::debugPrint(signalContainer.cptr()));
// Creating output RDO container
SG::WriteHandle<HGTD_RDO_Container> outputContainer(m_outputKey, ctx);
ATH_CHECK(outputContainer.record(std::make_unique<HGTD_RDO_Container>(signalContainer->size())));
if (!outputContainer.isValid()) {
ATH_MSG_ERROR("Could not record output HGTD RDO container " << outputContainer.name() << " to store " << outputContainer.store());
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG("Recorded output HGTD RDO container " << outputContainer.name() << " in store " << outputContainer.store());
ATH_CHECK(overlayContainer(bkgContainerPtr, signalContainer.cptr(), outputContainer.ptr()));
ATH_MSG_DEBUG("HGTD Result = " << Overlay::debugPrint(outputContainer.ptr()));
ATH_MSG_DEBUG("execute() end");
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef HGTDOVERLAY_HGTDOVERLAY_H
#define HGTDOVERLAY_HGTDOVERLAY_H
#include <IDC_OverlayBase/IDC_OverlayBase.h>
#include <HGTD_RawData/HGTD_RDO_Container.h>
class HGTD_Overlay : public IDC_OverlayBase
{
public:
HGTD_Overlay(const std::string &name, ISvcLocator *pSvcLocator);
virtual StatusCode initialize() override final;
virtual StatusCode execute(const EventContext& ctx) const override final;
private:
SG::ReadHandleKey<HGTD_RDO_Container> m_bkgInputKey{ this, "BkgInputKey", "Bkg_HGTD_RDOs", "ReadHandleKey for Background Input HGTD_RDO_Container" };
SG::ReadHandleKey<HGTD_RDO_Container> m_signalInputKey{ this, "SignalInputKey", "Sig_HGTD_RDOs", "ReadHandleKey for Signal Input HGTD_RDO_Container" };
SG::WriteHandleKey<HGTD_RDO_Container> m_outputKey{ this, "OutputKey", "HGTD_RDOs", "WriteHandleKey for Output HGTD_RDO_Container" };
};
#endif // HGTDOVERLAY_HGTDOVERLAY_H
#!/usr/bin/env python
"""Run tests on HGTD_OverlayConfig.py
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
"""
import sys
from AthenaCommon.Configurable import Configurable
from AthenaConfiguration.AllConfigFlags import ConfigFlags
from AthenaConfiguration.MainServicesConfig import MainServicesCfg
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
from HGTD_Overlay.HGTD_OverlayConfig import HGTD_OverlayCfg
from OverlayConfiguration.OverlayTestHelpers import \
CommonTestArgumentParser, defaultTestFlags, postprocessAndLockFlags, printAndRun
from OverlayCopyAlgs.OverlayCopyAlgsConfig import CopyMcEventCollectionCfg
from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoOverlayCfg
# Configure
Configurable.configurableRun3Behavior = True
# Argument parsing
parser = CommonTestArgumentParser("HGTD_OverlayConfig_test.py")
args = parser.parse_args()
# Configure
defaultTestFlags(ConfigFlags, args)
postprocessAndLockFlags(ConfigFlags, args)
# Construct our accumulator to run
acc = MainServicesCfg(ConfigFlags)
acc.merge(PoolReadCfg(ConfigFlags))
# Add event and truth overlay (needed downstream)
acc.merge(EventInfoOverlayCfg(ConfigFlags))
acc.merge(CopyMcEventCollectionCfg(ConfigFlags))
# Add HGTD overlay
acc.merge(HGTD_OverlayCfg(ConfigFlags))
# Dump the pickle
with open("HGTD_OverlayCfg.pkl", "wb") as f:
acc.store(f)
# Print and run
sys.exit(printAndRun(acc, ConfigFlags, args))
......@@ -16,6 +16,7 @@ from InDetOverlay.ITkStripOverlayConfig import ITkStripOverlayCfg
from InDetOverlay.PixelOverlayConfig import PixelOverlayCfg
from InDetOverlay.SCTOverlayConfig import SCTOverlayCfg
from InDetOverlay.TRTOverlayConfig import TRTOverlayCfg
from HGTD_Overlay.HGTD_OverlayConfig import HGTD_OverlayCfg
from LArDigitization.LArDigitizationConfigNew import LArOverlayCfg, LArSuperCellOverlayCfg
from MuonConfig.CSC_OverlayConfig import CSC_OverlayCfg
from MuonConfig.MDT_OverlayConfig import MDT_OverlayCfg
......@@ -81,6 +82,10 @@ def OverlayMainContentCfg(configFlags):
if configFlags.Detector.EnableITkStrip:
acc.merge(ITkStripOverlayCfg(configFlags))
# HGTD
if configFlags.Detector.EnableHGTD:
acc.merge(HGTD_OverlayCfg(configFlags))
# Calorimeters
if configFlags.Detector.EnableLAr:
acc.merge(LArOverlayCfg(configFlags))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment