diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelByteStreamCnvConfig.py b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelByteStreamCnvConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..64d39c2f6b9a37735b04a65e1841aa5650f8c378 --- /dev/null +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelByteStreamCnvConfig.py @@ -0,0 +1,52 @@ +# +# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +# + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory + +def ITkPixelDecodingAlgCfg(flags, name = "ITkPixelDecodingAlg", **kwargs) -> ComponentAccumulator: + acc = ComponentAccumulator() + + # Required for PixelID + from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg + acc.merge(ITkPixelReadoutGeometryCfg(flags)) + + acc.addEventAlgo(CompFactory.ITkPixelDecodingAlg(name, **kwargs)) + + return acc + +def ITkPixelEncodingAlgCfg(flags, name = "ITkPixelEncodingAlg", + doMonitoring = False, **kwargs) -> ComponentAccumulator: + acc = ComponentAccumulator() + + # Required for PixelID + from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg + acc.merge(ITkPixelReadoutGeometryCfg(flags)) + + if doMonitoring and 'DataRateMonitoringTool' not in kwargs: + kwargs.setdefault("DataRateMonitoringTool", acc.getPrimaryAndMerge(ITkPixelDataRateMonToolCfg(flags)))) + + acc.addEventAlgo(CompFactory.ITkPixelEncodingAlg(name, **kwargs)) + + return acc + + +def ITkPixelEncMonHistSvcCfg(flags, + HistogramGroup: str="DataRateMon", + FileName: str='ITkPixelEncodingMonitoring.root') -> ComponentAccumulator: + acc = ComponentAccumulator() + if HistogramGroup is not None and len(HistogramGroup) > 0 and FileName is not None and len(FileName) > 0 : + print("ITkPixelEncMonHistSvcCfg",HistogramGroup,FileName,[f"{HistogramGroup} DATAFILE='{FileName}', OPT='RECREATE'"]) + histSvc = CompFactory.THistSvc(Output = [f"{HistogramGroup} DATAFILE='{FileName}', OPT='RECREATE'"] ) + acc.addService(histSvc) + return acc + +def ITkPixelDataRateMonToolCfg(flags, + name = "ITkPixelDataRateMonTool", + HistogramGroup: str="DataRateMon", + FileName: str='ITkPixelEncodingMonitoring.root') -> ComponentAccumulator: + acc = ComponentAccumulator() + acc.merge(ITkPixelEncMonHistSvcCfg(flags, HistogramGroup, FileName)) + acc.addPublicTool(CompFactory.ITkPixelDataRateMonTool(name), primary=True) + return acc diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelDecodingAlgConfig.py b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelDecodingAlgConfig.py deleted file mode 100644 index 79bfa46b27999615be850c64edef943c81738590..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelDecodingAlgConfig.py +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration -# - -from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator -from AthenaConfiguration.ComponentFactory import CompFactory - -def ITkPixelDecodingAlgCfg(flags, name = "ITkPixelDecodingAlg", **kwargs): - acc = ComponentAccumulator() - - # Required for PixelID - from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg - acc.merge(ITkPixelReadoutGeometryCfg(flags)) - - acc.addEventAlgo(CompFactory.ITkPixelDecodingAlg(name, **kwargs)) - - return acc diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelEncodingAlgConfig.py b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelEncodingAlgConfig.py deleted file mode 100644 index 280675f7dc8438004501a88046d317fdc3a6fceb..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelEncodingAlgConfig.py +++ /dev/null @@ -1,25 +0,0 @@ -# -# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration -# - -from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator -from AthenaConfiguration.ComponentFactory import CompFactory - - -def ITkPixelEncodingAlgCfg(flags, name = "ITkPixelEncodingAlg", doDataRateMonitoring = False, **kwargs): - acc = ComponentAccumulator() - - # Required for PixelID - from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg - acc.merge(ITkPixelReadoutGeometryCfg(flags)) - - # Encoding algorithm - ITkPixelEncodingAlgJobOptions = CompFactory.ITkPixelEncodingAlg(name, **kwargs) - - # Specifying if monitoring of data rate must be done - - ITkPixelEncodingAlgJobOptions.DoDataRateMonitoring = doDataRateMonitoring - - acc.addEventAlgo(ITkPixelEncodingAlgJobOptions) - - return acc diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/scripts/RunITkPixelEncodingMonitoring.py b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/scripts/RunITkPixelEncodingMonitoring.py new file mode 100644 index 0000000000000000000000000000000000000000..9db37a7bf543d4991a93e8abe8c606b52276eec6 --- /dev/null +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/scripts/RunITkPixelEncodingMonitoring.py @@ -0,0 +1,72 @@ +# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration + +#!/usr/bin/env python +""" + +Run encoding and monitoring of the RDO to pixel bytestream conversion + +""" +from argparse import ArgumentParser + +# Argument parsing +parser = ArgumentParser("RunITkPixelEncodingMonitoring.py") +parser.add_argument("-V", "--verboseAccumulators", default=False, + action="store_true", + help="Print full details of the AlgSequence") +parser.add_argument("-S", "--verboseStoreGate", default=False, + action="store_true", + help="Dump the StoreGate(s) each event iteration") +parser.add_argument("--maxEvents",default=10, type=int, + help="The number of events to run. 0 skips execution") +parser.add_argument("--inputfile", + default="RDO.pool.root", + help="The input RDO file to use") +args = parser.parse_args() + +# Some info about the job +print("----Run encoding and monitoring of the RDO to pixel bytestream conversion----") +print() + +from AthenaConfiguration.AllConfigFlags import initConfigFlags +flags = initConfigFlags() + +# make logging more verbose +from AthenaCommon.Logging import log +from AthenaCommon.Constants import DEBUG, INFO +log.setLevel(INFO) + +flags.Input.isMC = True +import glob +flags.Input.Files = glob.glob(args.inputfile) + +flags.Detector.GeometryCalo = False +flags.Detector.GeometryMuon = False + +# This should run serially for the moment. +flags.Concurrency.NumThreads = 1 +flags.Concurrency.NumConcurrentEvents = 1 + +log.debug('Lock config flags now.') +flags.lock() + +### setup dumping of additional information +if args.verboseAccumulators: + cfg.printConfig(withDetails=True) +if args.verboseStoreGate: + cfg.getService("StoreGateSvc").Dump = True + +log.debug('Dumping of ConfigFlags now.') +flags.dump() + +from AthenaConfiguration.MainServicesConfig import MainServicesCfg +cfg=MainServicesCfg(flags) + +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +cfg.merge(PoolReadCfg(flags)) + +# Adds the encoding alg +from ITkPixelByteStreamCnv.ITkPixelEncodingAlgConfig import ITkPixelEncodingAlgCfg +cfg.merge( ITkPixelEncodingAlgCfg(flags, doMonitoring = True) ) + +# loop over 1 events +cfg.run(1) diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.cxx b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.cxx index 6e6cf56515297fac0e991c7c06ae7f77d74a9b42..645065f6115790c510bed6fc1810456525fe4bb5 100644 --- a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.cxx +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.cxx @@ -15,11 +15,9 @@ ITkPixelEncodingAlg::ITkPixelEncodingAlg(const std::string& name, ISvcLocator* p AthReentrantAlgorithm(name, pSvcLocator), m_hitSortingTool("ITkPixelHitSortingTool", this), m_encodingTool("ITkPixelEncodingTool", this), - m_dataRateMonTool("ITkPixelDataRateMonTool", this), m_packingTool("ITkPixelDataPackingTool", this), m_doDataRateMonitoring(false) { - declareProperty("DoDataRateMonitoring" , m_doDataRateMonitoring ); } @@ -34,7 +32,7 @@ StatusCode ITkPixelEncodingAlg::initialize() ATH_CHECK(m_packingTool.retrieve()); - if (m_doDataRateMonitoring) ATH_CHECK(m_dataRateMonTool.retrieve()); + ATH_CHECK(m_dataRateMonTool.retrieve()); ATH_CHECK(m_EncodedStreamKey.initialize()); @@ -64,7 +62,7 @@ StatusCode ITkPixelEncodingAlg::execute(const EventContext& ctx) const for (auto& i : encodedStream) ATH_MSG_DEBUG(" " << std::hex << i); // Launches the monitoring tool if asked in the job option file - if (m_doDataRateMonitoring) { + if (not m_dataRateMonTool.empty()) { // Passes the online id and the stream to the datager rate monitoring tool, alongside with the hitmap to extract chip occupancy m_dataRateMonTool->fillDataRates((iter->first), encodedStream); m_dataRateMonTool->fillHitMaps((iter->first), (iter->second)); @@ -81,4 +79,4 @@ StatusCode ITkPixelEncodingAlg::execute(const EventContext& ctx) const return StatusCode::SUCCESS; -} \ No newline at end of file +} diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.h b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.h index cd5513d7a6bef84b7402b77f5a0cfc4ac924b580..a0e23dd2cb4f63b01db3d1bb06d360de12e520b0 100644 --- a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.h +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.h @@ -34,12 +34,11 @@ class ITkPixelEncodingAlg : public AthReentrantAlgorithm private: - bool m_doDataRateMonitoring; - typedef std::vector< std::vector<uint32_t >> ITkPacketCollection; SG::ReadHandleKey<PixelRDO_Container> m_pixelRDOKey{this, "PixelRDOKey", "ITkPixelRDOs", "StoreGate Key of Pixel RDOs"}; SG::WriteHandleKey<std::vector<uint32_t>> m_EncodedStreamKey{this, "EncodedStreamKey", "ITkEncodedStream", "StoreGate Key for Encoded Stream"}; + ToolHandle<ITkPixelDataRateMonTool> m_dataRateMonTool {this, "DataRateMonitoringTool", "", "Monitoring tool for data rate evaluation"}; static constexpr float s_pitch50x50=0.050; @@ -47,7 +46,6 @@ class ITkPixelEncodingAlg : public AthReentrantAlgorithm ToolHandle<ITkPixelHitSortingTool> m_hitSortingTool; ToolHandle<ITkPixelEncodingTool> m_encodingTool; ToolHandle<ITkPixelDataPackingTool> m_packingTool; - ToolHandle<ITkPixelDataRateMonTool> m_dataRateMonTool; };