diff --git a/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfig.py b/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfig.py index 2faa67f815b17c4787c7d08c7c176e1761986545..22f6adbb26b96cb241fe65c401684cbe5c29e4b0 100644 --- a/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfig.py +++ b/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfig.py @@ -71,6 +71,8 @@ def BCM_OverlayDigitizationTool(name="BCM_OverlayDigitizationTool",**kwargs): from OverlayCommonAlgs.OverlayFlags import overlayFlags if overlayFlags.isOverlayMT(): kwargs.setdefault("OnlyUseContainerName", False) + # Disable the noise + kwargs.setdefault("ModNoise", [ 0., 0., 0., 0., 0., 0., 0., 0. ]) return BCM_DigitizationTool(name,**kwargs) def BCM_OverlayDigitization(name="BCM_OverlayDigitization",**kwargs): diff --git a/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfigNew.py b/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfigNew.py index fabda023e598932e2a1a1bb7245e29b5e3463e92..67941c9cade900429cf636551b46087f973575d0 100644 --- a/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfigNew.py +++ b/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfigNew.py @@ -41,6 +41,10 @@ def BCM_DigitizationToolCfg(flags, name="BCM_DigitizationTool", **kwargs): if flags.Digitization.PileUpPremixing: kwargs.setdefault("OutputRDOKey", flags.Overlay.BkgPrefix + "BCM_RDOs") kwargs.setdefault("OutputSDOKey", flags.Overlay.BkgPrefix + "BCM_SDO_Map") + elif flags.Detector.OverlayBCM: + kwargs.setdefault("OnlyUseContainerName", False) + kwargs.setdefault("OutputRDOKey", flags.Overlay.SigPrefix + "BCM_RDOs") + kwargs.setdefault("OutputSDOKey", flags.Overlay.SigPrefix + "BCM_SDO_Map") else: kwargs.setdefault("OutputRDOKey", "BCM_RDOs") kwargs.setdefault("OutputSDOKey", "BCM_SDO_Map") @@ -88,15 +92,22 @@ def BCM_DigitizationBasicCfg(flags, **kwargs): return acc -def BCM_OverlayDigitizationBasicCfg(flags, **kwargs): +def BCM_OverlayDigitizationBasicCfg(flags, name="BCM_OverlayDigitization", **kwargs): """Return ComponentAccumulator with BCM Overlay digitization""" acc = PixelGeometryCfg(flags) - kwargs.setdefault("EvtStore", flags.Overlay.Legacy.EventStore) + if "DigitizationTool" not in kwargs: - tool = acc.popToolsAndMerge(BCM_DigitizationToolCfg(flags)) + tool = acc.popToolsAndMerge(BCM_DigitizationToolCfg(flags, name="BCM_OverlayDigitizationTool")) kwargs["DigitizationTool"] = tool + + if flags.Concurrency.NumThreads > 0: + kwargs.setdefault("Cardinality", flags.Concurrency.NumThreads) + + # Set common overlay extra inputs + kwargs.setdefault("ExtraInputs", flags.Overlay.ExtraInputs) + BCM_Digitization = CompFactory.BCM_Digitization - acc.addEventAlgo(BCM_Digitization(**kwargs)) + acc.addEventAlgo(BCM_Digitization(name, **kwargs)) return acc diff --git a/InnerDetector/InDetRawAlgs/InDetOverlay/CMakeLists.txt b/InnerDetector/InDetRawAlgs/InDetOverlay/CMakeLists.txt index e91dcc7e2dd4924be19a6eb615bf9df7ee11766c..4b222431f35887dd485890e5c7c249776e9462f4 100644 --- a/InnerDetector/InDetRawAlgs/InDetOverlay/CMakeLists.txt +++ b/InnerDetector/InDetRawAlgs/InDetOverlay/CMakeLists.txt @@ -1,29 +1,9 @@ -################################################################################ -# Package: InDetOverlay -################################################################################ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # Declare the package name: atlas_subdir( InDetOverlay ) -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - Event/EventOverlay/IDC_OverlayBase - GaudiKernel - InnerDetector/InDetRawEvent/InDetRawData - PRIVATE - Control/CxxUtils - Control/StoreGate - DetectorDescription/IdDictParser - Generators/GeneratorObjects - InnerDetector/InDetRawEvent/InDetBCM_RawData - InnerDetector/InDetDetDescr/InDetIdentifier - InnerDetector/InDetRawEvent/InDetSimData - InnerDetector/InDetRecTools/TRT_ElectronPidTools - Tracking/TrkEvent/TrkTrack - ) - -#External dependencies: +# External dependencies: find_package( CLHEP ) find_package( GTest ) @@ -33,15 +13,20 @@ set( _jobOPath set( _jobOPath "${_jobOPath}:$ENV{JOBOPTSEARCHPATH}" ) # Unit Tests +atlas_add_test( BCMOverlay_test + SOURCES test/BCMOverlay_test.cxx src/BCMOverlay.cxx + INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} + LINK_LIBRARIES AthenaBaseComps GaudiKernel CxxUtils StoreGateLib SGtests GeneratorObjects InDetBCM_RawData InDetSimData ${GTEST_LIBRARIES} ) + atlas_add_test( PixelOverlay_test SOURCES test/PixelOverlay_test.cxx src/PixelOverlay.cxx - INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps IDC_OverlayBase GaudiKernel InDetRawData CxxUtils StoreGateLib SGtests GeneratorObjects InDetIdentifier InDetSimData TrkTrack ${GTEST_LIBRARIES} ) + INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} + LINK_LIBRARIES AthenaBaseComps IDC_OverlayBase GaudiKernel InDetRawData CxxUtils StoreGateLib SGtests GeneratorObjects InDetIdentifier InDetSimData TrkTrack ${GTEST_LIBRARIES} ) atlas_add_test( SCTOverlay_test SOURCES test/SCTOverlay_test.cxx src/SCTOverlay.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps IDC_OverlayBase GaudiKernel InDetRawData CxxUtils StoreGateLib SGtests GeneratorObjects InDetIdentifier InDetSimData TrkTrack IdDictParser ${GTEST_LIBRARIES} + LINK_LIBRARIES AthenaBaseComps IDC_OverlayBase GaudiKernel InDetRawData CxxUtils StoreGateLib SGtests GeneratorObjects InDetIdentifier InDetSimData TrkTrack IdDictParser ${GTEST_LIBRARIES} ENVIRONMENT "JOBOPTSEARCHPATH=${_jobOPath}" ) @@ -50,7 +35,7 @@ atlas_add_component( InDetOverlay src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps IDC_OverlayBase GaudiKernel InDetRawData StoreGateLib SGtests GeneratorObjects InDetBCM_RawData InDetIdentifier InDetSimData TrkTrack TRT_ConditionsServicesLib) + LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps IDC_OverlayBase GaudiKernel InDetRawData StoreGateLib SGtests GeneratorObjects InDetBCM_RawData InDetIdentifier InDetSimData TrkTrack TRT_ConditionsServicesLib TRT_ElectronPidToolsLib) # Install files from the package: atlas_install_headers( InDetOverlay ) @@ -58,6 +43,10 @@ atlas_install_python_modules( python/*.py ) atlas_install_joboptions( share/StoreGateTestCommon.txt ) # Configuration tests +atlas_add_test( BCMOverlayConfig_test + SCRIPT test/BCMOverlayConfig_test.py + PROPERTIES TIMEOUT 300 ) + atlas_add_test( PixelOverlayConfig_test SCRIPT test/PixelOverlayConfig_test.py PROPERTIES TIMEOUT 300 ) @@ -69,8 +58,3 @@ atlas_add_test( SCTOverlayConfig_test atlas_add_test( TRTOverlayConfig_test SCRIPT test/TRTOverlayConfig_test.py PROPERTIES TIMEOUT 300 ) - -atlas_add_test( BCMOverlay_test - SOURCES test/BCMOverlay_test.cxx src/BCMOverlay.cxx - INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps GaudiKernel CxxUtils StoreGateLib SGtests GeneratorObjects InDetBCM_RawData InDetSimData ${GTEST_LIBRARIES} ) diff --git a/InnerDetector/InDetRawAlgs/InDetOverlay/InDetOverlay/BCMOverlay.h b/InnerDetector/InDetRawAlgs/InDetOverlay/InDetOverlay/BCMOverlay.h index 159c481cef602f1690daa9e0ce25462647900744..a59e148fb7a864963a231efe4371e6528a379256 100644 --- a/InnerDetector/InDetRawAlgs/InDetOverlay/InDetOverlay/BCMOverlay.h +++ b/InnerDetector/InDetRawAlgs/InDetOverlay/InDetOverlay/BCMOverlay.h @@ -30,14 +30,15 @@ public: virtual StatusCode initialize() override final; virtual StatusCode execute(const EventContext& ctx) const override final; - StatusCode overlayContainer(const BCM_RDO_Container *bkgContainer, + StatusCode overlayContainer(const EventContext& ctx, + const BCM_RDO_Container *bkgContainer, const BCM_RDO_Container *signalContainer, BCM_RDO_Container *outputContainer) const; private: - BCM_RawData *mergeChannel(const BCM_RawData *bkgRDO, - const BCM_RawData *signalRDO) const; + std::unique_ptr<BCM_RawData> mergeChannel(const BCM_RawData *bkgRDO, + const BCM_RawData *signalRDO) const; void overlayPulses(std::vector<std::unique_ptr<BCM_Pulse>>& merged_pulses) const; @@ -45,6 +46,9 @@ private: static bool compare(const std::unique_ptr<BCM_Pulse>& a, const std::unique_ptr<BCM_Pulse>& b); + Gaudi::Property<bool> m_dataOverlay{ this, "isDataOverlay", false, "Flag to switch between MC and data overlay" }; + Gaudi::Property<bool> m_storeAllBCID{ this, "storeAllBCID", false, "Store all BCID" }; + SG::ReadHandleKey<BCM_RDO_Container> m_bkgInputKey{ this, "BkgInputKey", "Bkg_BCM_RDOs", "ReadHandleKey for Background Input BCM_RDO_Container" }; SG::ReadHandleKey<BCM_RDO_Container> m_signalInputKey{ this, "SignalInputKey", "Sig_BCM_RDOs", "ReadHandleKey for Signal Input BCM_RDO_Container" }; SG::WriteHandleKey<BCM_RDO_Container> m_outputKey{ this, "OutputKey", "BCM_RDOs", "WriteHandleKey for Output BCM_RDO_Container" }; diff --git a/InnerDetector/InDetRawAlgs/InDetOverlay/python/BCMOverlayConfig.py b/InnerDetector/InDetRawAlgs/InDetOverlay/python/BCMOverlayConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..e9eb2a9e69bdb0d5bd5052b4942935523e2e98ce --- /dev/null +++ b/InnerDetector/InDetRawAlgs/InDetOverlay/python/BCMOverlayConfig.py @@ -0,0 +1,113 @@ +"""Define methods to construct configured BCM overlay algorithms + +Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +""" + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory + + +def BCMRawDataProviderAlgCfg(flags, name="BCMRawDataProvider", **kwargs): + """Return a ComponentAccumulator for BCM raw data provider""" + # Temporary until available in the central location + acc = ComponentAccumulator() + + kwargs.setdefault("RDOKey", flags.Overlay.BkgPrefix + "BCM_RDOs") + + BCM_RawDataProvider = CompFactory.BCM_RawDataProvider + alg = BCM_RawDataProvider(name, **kwargs) + acc.addEventAlgo(alg) + + return acc + + +def BCMDataOverlayExtraCfg(flags, **kwargs): + """Return a ComponentAccumulator with BCM data overlay specifics""" + acc = ComponentAccumulator() + + # We need to convert BS to RDO for data overlay + acc.merge(BCMRawDataProviderAlgCfg(flags)) + + return acc + + +def BCMOverlayAlgCfg(flags, name="BCMOverlay", **kwargs): + """Return a ComponentAccumulator for BCMOverlay algorithm""" + acc = ComponentAccumulator() + + kwargs.setdefault("BkgInputKey", flags.Overlay.BkgPrefix + "BCM_RDOs") + kwargs.setdefault("SignalInputKey", flags.Overlay.SigPrefix + "BCM_RDOs") + kwargs.setdefault("OutputKey", "BCM_RDOs") + + kwargs.setdefault("isDataOverlay", flags.Overlay.DataOverlay) + + # Do BCM overlay + BCMOverlay = CompFactory.BCMOverlay + alg = BCMOverlay(name, **kwargs) + acc.addEventAlgo(alg) + + # Setup output + if flags.Output.doWriteRDO: + from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg + acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[ + "BCM_RDO_Container#BCM_RDOs" + ])) + + if flags.Output.doWriteRDO_SGNL: + from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg + acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[ + "BCM_RDO_Container#" + flags.Overlay.SigPrefix + "BCM_RDOs" + ])) + + return acc + + +def BCMTruthOverlayCfg(flags, name="BCMSDOOverlay", **kwargs): + """Return a ComponentAccumulator for the BCM SDO overlay algorithm""" + acc = ComponentAccumulator() + + # We do not need background BCM SDOs + kwargs.setdefault("BkgInputKey", "") + + kwargs.setdefault("SignalInputKey", + flags.Overlay.SigPrefix + "BCM_SDO_Map") + kwargs.setdefault("OutputKey", "BCM_SDO_Map") + + # Do BCM truth overlay + InDetSDOOverlay = CompFactory.InDetSDOOverlay + alg = InDetSDOOverlay(name, **kwargs) + acc.addEventAlgo(alg) + + # Setup output + if flags.Output.doWriteRDO: + from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg + acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[ + "InDetSimDataCollection#BCM_SDO_Map" + ])) + + if flags.Output.doWriteRDO_SGNL: + from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg + acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[ + "InDetSimDataCollection#" + flags.Overlay.SigPrefix + "BCM_SDO_Map" + ])) + + return acc + + +def BCMOverlayCfg(flags): + """Configure and return a ComponentAccumulator for BCM overlay""" + acc = ComponentAccumulator() + + # Add data overlay specifics + if flags.Overlay.DataOverlay: + acc.merge(BCMDataOverlayExtraCfg(flags)) + + # Add BCM overlay digitization algorithm + from BCM_Digitization.BCM_DigitizationConfigNew import BCM_OverlayDigitizationBasicCfg + acc.merge(BCM_OverlayDigitizationBasicCfg(flags)) + # Add BCM overlay algorithm + acc.merge(BCMOverlayAlgCfg(flags)) + # Add BCM truth overlay + acc.merge(BCMTruthOverlayCfg(flags)) + + return acc diff --git a/InnerDetector/InDetRawAlgs/InDetOverlay/python/InDetOverlayConfig.py b/InnerDetector/InDetRawAlgs/InDetOverlay/python/InDetOverlayConfig.py index db4353a3fb4de431e41dd9dc2451d64d9df87c2d..b2ed2de326c5cb86d82c06537934f03e11459a8b 100644 --- a/InnerDetector/InDetRawAlgs/InDetOverlay/python/InDetOverlayConfig.py +++ b/InnerDetector/InDetRawAlgs/InDetOverlay/python/InDetOverlayConfig.py @@ -115,6 +115,8 @@ def getTRTSDOOverlay(name="TRTSDOOverlay", **kwargs): def getBCMOverlay(name="BCMOverlay", **kwargs): from OverlayCommonAlgs.OverlayFlags import overlayFlags + kwargs.setdefault("isDataOverlay", overlayFlags.isDataOverlay()) + if overlayFlags.isOverlayMT(): kwargs.setdefault("BkgInputKey", overlayFlags.bkgPrefix() + "BCM_RDOs"); kwargs.setdefault("SignalInputKey", overlayFlags.sigPrefix() + "BCM_RDOs"); diff --git a/InnerDetector/InDetRawAlgs/InDetOverlay/src/BCMOverlay.cxx b/InnerDetector/InDetRawAlgs/InDetOverlay/src/BCMOverlay.cxx index 8969078a486627902303ac12f8f4b791c7c0887c..e04f5e0628099247ba263f7a57373a88168998f3 100644 --- a/InnerDetector/InDetRawAlgs/InDetOverlay/src/BCMOverlay.cxx +++ b/InnerDetector/InDetRawAlgs/InDetOverlay/src/BCMOverlay.cxx @@ -63,13 +63,14 @@ StatusCode BCMOverlay::execute(const EventContext& ctx) const } ATH_MSG_DEBUG("Recorded output BCM RDO container " << outputContainer.name() << " in store " << outputContainer.store()); - ATH_CHECK(overlayContainer(bkgContainerPtr, signalContainer.cptr(), outputContainer.ptr())); + ATH_CHECK(overlayContainer(ctx, bkgContainerPtr, signalContainer.cptr(), outputContainer.ptr())); ATH_MSG_DEBUG("execute() end"); return StatusCode::SUCCESS; } -StatusCode BCMOverlay::overlayContainer(const BCM_RDO_Container *bkgContainer, +StatusCode BCMOverlay::overlayContainer(const EventContext& ctx, + const BCM_RDO_Container *bkgContainer, const BCM_RDO_Container *signalContainer, BCM_RDO_Container *outputContainer) const { @@ -88,38 +89,59 @@ StatusCode BCMOverlay::overlayContainer(const BCM_RDO_Container *bkgContainer, return StatusCode::SUCCESS; } - size_t containerSize = signalContainer->size(); - - for (size_t i = 0; i < containerSize; i++) { + std::unordered_map<unsigned int, const BCM_RDO_Collection *> bkgChannelMap; + for (const BCM_RDO_Collection *bkgColl : *bkgContainer) { + bkgChannelMap.emplace(bkgColl->getChannel(), bkgColl); + } - const BCM_RDO_Collection *sigColl = signalContainer->at(i); - const BCM_RDO_Collection *bkgColl = bkgContainer->at(i); + for (const BCM_RDO_Collection *sigColl : *signalContainer) { - std::unique_ptr<BCM_RDO_Collection> outputColl = std::make_unique<BCM_RDO_Collection>(); - size_t collectionSize = sigColl->size(); - if (collectionSize != bkgColl->size()) { - ATH_MSG_ERROR ("BCM signal and background collection size mismatch"); + auto it = bkgChannelMap.find(sigColl->getChannel()); + if (it == bkgChannelMap.end()) { + ATH_MSG_ERROR ("No BCM background collection with channel " << sigColl->getChannel()); return StatusCode::FAILURE; } - if (bkgColl->getChannel() == sigColl->getChannel()) { - outputColl->setChannel(sigColl->getChannel()); + const BCM_RDO_Collection *bkgColl = it->second; + bkgChannelMap.erase(it); + std::unique_ptr<BCM_RDO_Collection> outputColl = std::make_unique<BCM_RDO_Collection>(); + outputColl->setChannel(sigColl->getChannel()); + + constexpr size_t mcSize{1}; // MC always has exactly one RDO + if (m_dataOverlay.value()) { + // Data has RDOs from more BCIDs, check MC size + if (sigColl->size() != mcSize) { + ATH_MSG_ERROR ("BCM signal collection size mismatch"); + return StatusCode::FAILURE; + } } else { - ATH_MSG_ERROR ("BCM signal and background channel mismatch"); - return StatusCode::FAILURE; + // In case of MC+MC overlay collection sizes are the same + size_t collectionSize = bkgColl->size(); + if (collectionSize != sigColl->size() && collectionSize != mcSize) { + ATH_MSG_ERROR ("BCM signal and background collection size mismatch"); + return StatusCode::FAILURE; + } } - for (size_t j = 0; j < collectionSize; j++) { + int currentBCID = ctx.eventID().bunch_crossing_id(); + for (const BCM_RawData *bkgRDO : *bkgColl) { + if (m_dataOverlay.value() && bkgRDO->getBCID() != currentBCID) { + if (m_storeAllBCID.value()) { + outputColl->push_back(new BCM_RawData(bkgRDO->getWord1(), bkgRDO->getWord2())); + } + continue; + } - if (bkgColl->at(j)->getChannel() == sigColl->at(j)->getChannel()) { - BCM_RawData *mergedRDO = mergeChannel(bkgColl->at(j),sigColl->at(j)); - if (mergedRDO) outputColl->push_back(mergedRDO); - else { + const BCM_RawData *sigRDO = sigColl->front(); + if (bkgRDO->getChannel() == sigRDO->getChannel()) { + std::unique_ptr<BCM_RawData> mergedRDO = mergeChannel(bkgRDO, sigRDO); + if (mergedRDO != nullptr) { + outputColl->push_back(mergedRDO.release()); + } else { ATH_MSG_ERROR ("BCM channel merging failed"); return StatusCode::FAILURE; } - } - else { + } else { ATH_MSG_ERROR ("BCM signal and background channel mismatch"); return StatusCode::FAILURE; } @@ -131,14 +153,14 @@ StatusCode BCMOverlay::overlayContainer(const BCM_RDO_Container *bkgContainer, return StatusCode::SUCCESS; } -BCM_RawData *BCMOverlay::mergeChannel(const BCM_RawData *bkgRDO, - const BCM_RawData *signalRDO) const +std::unique_ptr<BCM_RawData> BCMOverlay::mergeChannel(const BCM_RawData *bkgRDO, + const BCM_RawData *signalRDO) const { if (bkgRDO->getPulse1Width()==0) { - return new BCM_RawData(signalRDO->getWord1(), signalRDO->getWord2()); + return std::make_unique<BCM_RawData>(signalRDO->getWord1(), signalRDO->getWord2()); } else if (signalRDO->getPulse1Width()==0) { - return new BCM_RawData(bkgRDO->getWord1(), bkgRDO->getWord2()); + return std::make_unique<BCM_RawData>(bkgRDO->getWord1(), bkgRDO->getWord2()); } unsigned int bkg_p1 = bkgRDO->getPulse1Position(); @@ -196,12 +218,12 @@ BCM_RawData *BCMOverlay::mergeChannel(const BCM_RawData *bkgRDO, } // Record two earliest pulses into the output RDO - return new BCM_RawData(signalRDO->getChannel(), - merged_p1, merged_w1, - merged_p2, merged_w2, - signalRDO->getLVL1A(), - signalRDO->getBCID(), - signalRDO->getLVL1ID()); + return std::make_unique<BCM_RawData>(bkgRDO->getChannel(), + merged_p1, merged_w1, + merged_p2, merged_w2, + bkgRDO->getLVL1A(), + bkgRDO->getBCID(), + bkgRDO->getLVL1ID()); } void BCMOverlay::overlayPulses(std::vector<std::unique_ptr<BCM_Pulse>>& merged_pulses) const @@ -264,4 +286,4 @@ bool BCMOverlay::compare(const std::unique_ptr<BCM_Pulse>& a, return a->p < b->p; -} \ No newline at end of file +} diff --git a/InnerDetector/InDetRawAlgs/InDetOverlay/test/BCMOverlayConfig_test.py b/InnerDetector/InDetRawAlgs/InDetOverlay/test/BCMOverlayConfig_test.py new file mode 100755 index 0000000000000000000000000000000000000000..42927c98feaaee35040a72e0c8328d168392cac5 --- /dev/null +++ b/InnerDetector/InDetRawAlgs/InDetOverlay/test/BCMOverlayConfig_test.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +"""Run tests on BCMOverlayConfig.py + +Copyright (C) 2002-2020 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 InDetOverlay.BCMOverlayConfig import BCMOverlayCfg +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("BCMOverlayConfig_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 BCM overlay +acc.merge(BCMOverlayCfg(ConfigFlags)) + +# Print and run +sys.exit(printAndRun(acc, ConfigFlags, args)) diff --git a/Simulation/Overlay/OverlayConfiguration/python/OverlayConfigFlags.py b/Simulation/Overlay/OverlayConfiguration/python/OverlayConfigFlags.py index 1f17d7b2796072c17a66d33546f14ba230828a99..9374df1ad321319ffcff050cc9087e60a14b93a5 100644 --- a/Simulation/Overlay/OverlayConfiguration/python/OverlayConfigFlags.py +++ b/Simulation/Overlay/OverlayConfiguration/python/OverlayConfigFlags.py @@ -17,8 +17,6 @@ def createOverlayConfigFlags(): flags.addFlag("Overlay.SigPrefix", "Sig_") # Overlay extra input dependencies flags.addFlag("Overlay.ExtraInputs", [("McEventCollection", "TruthEvent")]) - # Name of MC EvtStore to overlay - flags.addFlag("Overlay.Legacy.EventStore", "BkgEvent_0_SG") return flags diff --git a/Simulation/Overlay/OverlayConfiguration/python/OverlaySteering.py b/Simulation/Overlay/OverlayConfiguration/python/OverlaySteering.py index d3ae5172cab84712b47d2d2db69f4d823673eb78..0bfc4a9e834d4fe59eba3e7fc1c010bdcbb32ff0 100644 --- a/Simulation/Overlay/OverlayConfiguration/python/OverlaySteering.py +++ b/Simulation/Overlay/OverlayConfiguration/python/OverlaySteering.py @@ -9,6 +9,7 @@ from AthenaConfiguration.MainServicesConfig import MainServicesCfg from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from InDetOverlay.BCMOverlayConfig import BCMOverlayCfg from InDetOverlay.PixelOverlayConfig import PixelOverlayCfg from InDetOverlay.SCTOverlayConfig import SCTOverlayCfg from InDetOverlay.TRTOverlayConfig import TRTOverlayCfg @@ -59,6 +60,8 @@ def OverlayMainCfg(configFlags): acc.merge(CopyTrackRecordCollectionsCfg(configFlags)) # Inner detector + if configFlags.Detector.OverlayBCM: + acc.merge(BCMOverlayCfg(configFlags)) if configFlags.Detector.OverlayPixel: acc.merge(PixelOverlayCfg(configFlags)) if configFlags.Detector.OverlaySCT: diff --git a/Simulation/SimulationJobOptions/share/subdetectors/preInclude.BCMOnlyConfig.py b/Simulation/SimulationJobOptions/share/subdetectors/preInclude.BCMOnlyConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..4d0332f8c2a020000768da14d04fb532cc55664d --- /dev/null +++ b/Simulation/SimulationJobOptions/share/subdetectors/preInclude.BCMOnlyConfig.py @@ -0,0 +1,5 @@ +if not 'DetFlags' in dir(): + #if you configure one detflag, you're responsible for configuring them all! + from AthenaCommon.DetFlags import DetFlags + DetFlags.all_setOff() +DetFlags.BCM_setOn() diff --git a/Simulation/Tests/OverlayTests/test/test_DataOverlay_ConfigTest_Zmumu_BCM.sh b/Simulation/Tests/OverlayTests/test/test_DataOverlay_ConfigTest_Zmumu_BCM.sh new file mode 100755 index 0000000000000000000000000000000000000000..8bfa93c6ebb32b0bf76e2efa4e0f01de3c049dc0 --- /dev/null +++ b/Simulation/Tests/OverlayTests/test/test_DataOverlay_ConfigTest_Zmumu_BCM.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +# art-description: MC+data Overlay with MT support, config test +# art-type: grid +# art-include: master/Athena + +# art-output: legacyDataOverlayRDO.pool.root +# art-output: dataOverlayRDO.pool.root +# art-output: log.* +# art-output: mem.summary.* +# art-output: mem.full.* +# art-output: runargs.* +# art-output: *.pkl +# art-output: *Config.txt + +set -o pipefail + +events=2 + +OverlayBS_tf.py \ +--inputBS_SKIMFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/OverlayMonitoringRTT/mc15_valid.00200010.overlay_streamsAll_2016_pp_1.skim.DRAW.r8381/DRAW.09331084._000146.pool.root.1 \ +--inputHITSFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/OverlayMonitoringRTT/mc16_13TeV.361107.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zmumu.OverlaySim/HITS.pool.root \ +--outputRDOFile legacyDataOverlayRDO.pool.root \ +--maxEvents $events \ +--conditionsTag CONDBR2-BLKPA-2016-12 \ +--fSampltag LARElecCalibMCfSampl-G496-19213- \ +--preExec 'from LArROD.LArRODFlags import larRODFlags;larRODFlags.nSamples.set_Value_and_Lock(4);from LArConditionsCommon.LArCondFlags import larCondFlags; larCondFlags.OFCShapeFolder.set_Value_and_Lock("4samples1phase")' \ +--postExec 'outStream.ItemList.remove("xAOD::EventInfoContainer#*"); outStream.ItemList.remove("xAOD::EventInfoAuxContainer#*");' \ +--preInclude 'SimulationJobOptions/preInclude.BCMOnlyConfig.py,SimulationJobOptions/preInclude.TruthOnlyConfig.py' \ +--postInclude 'EventOverlayJobTransforms/Rt_override_CONDBR2-BLKPA-2015-12.py' \ +--ignorePatterns "L1TopoMenuLoader.+ERROR." \ +--imf False \ +--athenaopts '"--config-only=ConfigLegacy.pkl"' + +OverlayBS_tf.py \ +--inputBS_SKIMFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/OverlayMonitoringRTT/mc15_valid.00200010.overlay_streamsAll_2016_pp_1.skim.DRAW.r8381/DRAW.09331084._000146.pool.root.1 \ +--inputHITSFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/OverlayMonitoringRTT/mc16_13TeV.361107.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zmumu.OverlaySim/HITS.pool.root \ +--outputRDOFile legacyDataOverlayRDO.pool.root \ +--maxEvents $events \ +--conditionsTag CONDBR2-BLKPA-2016-12 \ +--fSampltag LARElecCalibMCfSampl-G496-19213- \ +--preExec 'from LArROD.LArRODFlags import larRODFlags;larRODFlags.nSamples.set_Value_and_Lock(4);from LArConditionsCommon.LArCondFlags import larCondFlags; larCondFlags.OFCShapeFolder.set_Value_and_Lock("4samples1phase")' \ +--postExec 'job+=CfgMgr.JobOptsDumperAlg(FileName="OverlayLegacyConfig.txt"); outStream.ItemList.remove("xAOD::EventInfoContainer#*"); outStream.ItemList.remove("xAOD::EventInfoAuxContainer#*");' \ +--preInclude 'SimulationJobOptions/preInclude.BCMOnlyConfig.py,SimulationJobOptions/preInclude.TruthOnlyConfig.py' \ +--postInclude 'EventOverlayJobTransforms/Rt_override_CONDBR2-BLKPA-2015-12.py' \ +--ignorePatterns "L1TopoMenuLoader.+ERROR." \ +--imf False + +rc=$? +echo "art-result: $rc configLegacy" +mv log.OverlayBS log.OverlayLegacy + +rc2=-9999 +if [ $rc -eq 0 ] +then + OverlayTest.py BCM -d -t 1 -n $events 2>&1 | tee log.OverlayTest + rc2=$? +fi +echo "art-result: $rc2 configNew" + +rc3=-9999 +if [ $rc2 -eq 0 ] +then + acmd.py diff-root legacyDataOverlayRDO.pool.root dataOverlayRDO.pool.root \ + --error-mode resilient --mode=semi-detailed \ + --ignore-leaves RecoTimingObj_p1_EVNTtoHITS_timings RecoTimingObj_p1_HITStoRDO_timings index_ref \ + xAOD::EventAuxInfo_v2_EventInfoAuxDyn.subEventIndex \ + xAOD::EventAuxInfo_v2_EventInfoAuxDyn.subEventTime \ + xAOD::EventAuxInfo_v2_EventInfoAuxDyn.subEventType \ + xAOD::EventAuxInfo_v2_EventInfoAux.detectorMask0 \ + xAOD::EventAuxInfo_v2_EventInfoAux.detectorMask1 \ + xAOD::EventAuxInfo_v2_EventInfoAux.detectorMask2 \ + xAOD::EventAuxInfo_v2_EventInfoAux.detectorMask3 \ + xAOD::EventAuxInfo_v2_EventInfoAux.actualInteractionsPerCrossing \ + xAOD::EventAuxInfo_v2_EventInfoAux.averageInteractionsPerCrossing + rc3=$? +fi +echo "art-result: $rc3 comparison" diff --git a/Simulation/Tests/OverlayTests/test/test_MCOverlay_ConfigTest_ttbar_BCM.sh b/Simulation/Tests/OverlayTests/test/test_MCOverlay_ConfigTest_ttbar_BCM.sh new file mode 100755 index 0000000000000000000000000000000000000000..53e048a0258154c4ecd585e0366f51002232a570 --- /dev/null +++ b/Simulation/Tests/OverlayTests/test/test_MCOverlay_ConfigTest_ttbar_BCM.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# art-description: MC+MC Overlay with MT support, config test +# art-type: grid +# art-include: master/Athena + +# art-output: legacyMcOverlayRDO.pool.root +# art-output: mcOverlayRDO.pool.root +# art-output: log.* +# art-output: mem.summary.* +# art-output: mem.full.* +# art-output: runargs.* +# art-output: *.pkl +# art-output: *Config.txt + +set -o pipefail + +events=2 + +Overlay_tf.py \ +--inputHITSFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.simul.HITS.e4993_s3091/HITS.10504490._000425.pool.root.1 \ +--inputRDO_BKGFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/OverlayMonitoringRTT/PileupPremixing/22.0/v4/RDO.merged-pileup-MT.100events.pool.root \ +--outputRDOFile legacyMcOverlayRDO.pool.root \ +--maxEvents $events \ +--conditionsTag OFLCOND-MC16-SDR-20 \ +--geometryVersion ATLAS-R2-2016-01-00-01 \ +--preExec 'from LArROD.LArRODFlags import larRODFlags;larRODFlags.NumberOfCollisions.set_Value_and_Lock(20);larRODFlags.nSamples.set_Value_and_Lock(4);larRODFlags.doOFCPileupOptimization.set_Value_and_Lock(True);larRODFlags.firstSample.set_Value_and_Lock(0);larRODFlags.useHighestGainAutoCorr.set_Value_and_Lock(True); from LArDigitization.LArDigitizationFlags import jobproperties;jobproperties.LArDigitizationFlags.useEmecIwHighGain.set_Value_and_Lock(False);' \ +--preInclude 'Overlay:SimulationJobOptions/preInclude.BCMOnlyConfig.py,SimulationJobOptions/preInclude.TruthOnlyConfig.py' \ +--imf False \ +--athenaopts '"--config-only=ConfigLegacy.pkl"' + +Overlay_tf.py \ +--inputHITSFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/OverlayMonitoringRTT/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.simul.HITS.e4993_s3091/HITS.10504490._000425.pool.root.1 \ +--inputRDO_BKGFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/OverlayMonitoringRTT/PileupPremixing/22.0/v4/RDO.merged-pileup-MT.100events.pool.root \ +--outputRDOFile legacyMcOverlayRDO.pool.root \ +--maxEvents $events \ +--conditionsTag OFLCOND-MC16-SDR-20 \ +--geometryVersion ATLAS-R2-2016-01-00-01 \ +--preExec 'from LArROD.LArRODFlags import larRODFlags;larRODFlags.NumberOfCollisions.set_Value_and_Lock(20);larRODFlags.nSamples.set_Value_and_Lock(4);larRODFlags.doOFCPileupOptimization.set_Value_and_Lock(True);larRODFlags.firstSample.set_Value_and_Lock(0);larRODFlags.useHighestGainAutoCorr.set_Value_and_Lock(True); from LArDigitization.LArDigitizationFlags import jobproperties;jobproperties.LArDigitizationFlags.useEmecIwHighGain.set_Value_and_Lock(False);' \ +--postExec 'job+=CfgMgr.JobOptsDumperAlg(FileName="OverlayLegacyConfig.txt");' \ +--preInclude 'Overlay:SimulationJobOptions/preInclude.BCMOnlyConfig.py,SimulationJobOptions/preInclude.TruthOnlyConfig.py' \ +--imf False + +rc=$? +echo "art-result: $rc configLegacy" +mv log.Overlay log.OverlayLegacy + +rc2=-9999 +if [ $rc -eq 0 ] +then + OverlayTest.py BCM -t 1 -n $events 2>&1 | tee log.OverlayTest + rc2=$? +fi +echo "art-result: $rc2 configNew" + +rc3=-9999 +if [ $rc2 -eq 0 ] +then + acmd.py diff-root legacyMcOverlayRDO.pool.root mcOverlayRDO.pool.root --error-mode resilient --mode=semi-detailed --ignore-leaves RecoTimingObj_p1_EVNTtoHITS_timings RecoTimingObj_p1_HITStoRDO_timings index_ref + rc3=$? +fi +echo "art-result: $rc3 comparison"