diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/CMakeLists.txt b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/CMakeLists.txt index 029d3099118fabf3d73512b93cc489fa5ae86f58..3df5e64bd043651cb497ea0eb9ebc334294465e1 100644 --- a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/CMakeLists.txt +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/CMakeLists.txt @@ -21,17 +21,17 @@ atlas_add_component( ITkPixelByteStreamCnv ByteStreamCnvSvcBaseLib InDetIdentifier PixelReadoutGeometryLib IRegionSelector xAODEventInfo TrigSteeringEvent InDetByteStreamErrors ITkPixelByteStreamCnvLib ByteStreamCnvSvcLib ) -atlas_add_test(ITkPixelRodDecoder_test - SOURCES test/ITkPixelRodDecoder_test.cxx - INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib Identifier ITkPixelByteStreamCnvLib - POST_EXEC_SCRIPT "nopost.sh" ) +# atlas_add_test(ITkPixelRodDecoder_test +# SOURCES test/ITkPixelRodDecoder_test.cxx +# INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} +# LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib Identifier ITkPixelByteStreamCnvLib +# POST_EXEC_SCRIPT "nopost.sh" ) -atlas_add_test(ITkPixelRawDataProviderTool_test - SOURCES test/ITkPixelRawDataProviderTool_test.cxx - INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib Identifier ITkPixelByteStreamCnvLib - POST_EXEC_SCRIPT "nopost.sh" ) +# atlas_add_test(ITkPixelRawDataProviderTool_test +# SOURCES test/ITkPixelRawDataProviderTool_test.cxx +# INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} +# LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib Identifier ITkPixelByteStreamCnvLib +# POST_EXEC_SCRIPT "nopost.sh" ) # Install files from the package: atlas_install_joboptions( share/*.txt ) diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelByteStreamCnvConfig.py b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelByteStreamCnvConfig.py deleted file mode 100644 index e1b139503b98db17e0c3bd24ced1e80d13d5ee7b..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelByteStreamCnvConfig.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration -# - -from AthenaConfiguration.ComponentFactory import CompFactory - -def ITkPixelRawDataProviderAlgCfg(flags, RDOKey="PixelRDOs", **kwargs): - """ Main function to configure ITkPixel raw data decoding """ - - from PixelReadoutGeometry.PixelReadoutGeometryConfig import ITkPixelReadoutManagerCfg - acc = ITkPixelReadoutManagerCfg(flags) - - from RegionSelector.RegSelToolConfig import regSelTool_ITkPixel_Cfg - regSelTool = acc.popToolsAndMerge(regSelTool_ITkPixel_Cfg(flags)) - - suffix = kwargs.pop("suffix","") - decoder = CompFactory.ITkPixelRodDecoder(name="ITkPixelRodDecoder"+suffix) - - providerTool = CompFactory.ITkPixelRawDataProviderTool(name="ITkPixelRawDataProviderTool"+suffix, - Decoder = decoder) - - acc.addEventAlgo(CompFactory.ITkPixelRawDataProvider(RDOKey = RDOKey, - RegSelTool = regSelTool, - ProviderTool = providerTool, - **kwargs)) - return acc - - -def TrigITkPixelRawDataProviderAlgCfg(flags, suffix, RoIs): - trigargs = { - 'name' : 'TrigPixelRawDataProvider'+suffix, - 'suffix' : suffix, - 'RoIs' : RoIs, - 'isRoI_Seeded': True, - 'RDOCacheKey' : 'PixRDOCache', - 'BSErrorsCacheKey' : 'PixBSErrCache' - } - return ITkPixelRawDataProviderAlgCfg(flags, **trigargs) \ No newline at end of file diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelEncodingAlgConfig.py b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelEncodingAlgConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..e510d9df8fa06f588ec33e1c90186118f88ab0d1 --- /dev/null +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/python/ITkPixelEncodingAlgConfig.py @@ -0,0 +1,17 @@ +# +# 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", **kwargs): + acc = ComponentAccumulator() + + # Required for PixelID + from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg + acc.merge(ITkPixelReadoutGeometryCfg(flags)) + + acc.addEventAlgo(CompFactory.ITkPixelEncodingAlg(name, **kwargs)) + + return acc diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/run/JO.py b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/run/JO.py new file mode 100644 index 0000000000000000000000000000000000000000..b3b928102b3d87626bd21f61f5f470afa383e160 --- /dev/null +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/run/JO.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +# # Example to add additional algorithms: +# from AthenaConfiguration.ComponentFactory import CompFactory +# def MyAlgCfg(flags, name='MyAlg', **kwargs): +# acc = ComponentAccumulator() +# kwargs.setdefault(',"Property', default_value) +# acc.addEventAlgo(CompFactory.MyAlg(name, +# **kwargs)) +# return acc + + +if __name__=="__main__": + # test job skeleton reading pool files + + from AthenaConfiguration.AllConfigFlags import initConfigFlags + flags = initConfigFlags() + + # make logging more verbose + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + # log.setLevel(DEBUG) + + # --- set flags + # the input file + flags.Input.Files = ['/eos/user/s/sroygara/ITk/BytestreamDev/run/mc21_14TeV.900498.PG_single_muonpm_Pt100_etaFlatnp0_43.recon.RDO.e8481_s4149_r14697/RDO.33675668._000028.pool.root.1'] + + + # --- end flag customization + flags.lock() + + + flags.dump() + # minimum stuff to read files: + from AthenaConfiguration.MainServicesConfig import MainServicesCfg + cfg = MainServicesCfg(flags) + + from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg + cfg.merge(PoolReadCfg(flags)) + + # example runs pixel clusterization + from ITkPixelByteStreamCnv.ITkPixelEncodingAlgConfig import ITkPixelEncodingAlgCfg + cfg.merge( ITkPixelEncodingAlgCfg(flags) ) + + cfg.printConfig(withDetails=True, summariseProps=True, printDefaults=True) + # loop over 10 events + cfg.run(10) diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ATLAS_CHECK_THREAD_SAFETY b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.cxx b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8376310276903845079358a655fe0b8fb6b2079b --- /dev/null +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.cxx @@ -0,0 +1,145 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +#include "ITkPixelEncodingAlg.h" +#include "InDetReadoutGeometry/SiDetectorElement.h" +#include "PixelReadoutGeometry/PixelModuleDesign.h" +#include "InDetRawData/InDetRawDataContainer.h" +#include "InDetRawData/InDetRawDataCLASS_DEF.h" +#include "StoreGate/ReadHandle.h" +#include "InDetIdentifier/PixelID.h" +#include "PixelReadoutGeometry/IPixelReadoutManager.h" +#include "PixelReadoutGeometry/PixelDetectorManager.h" + + +ITkPixelEncodingAlg::ITkPixelEncodingAlg(const std::string& name, ISvcLocator* pSvcLocator) : + AthReentrantAlgorithm(name, pSvcLocator), + m_pixelManager(nullptr), + m_pixIdHelper(nullptr) +{ + +} + + +StatusCode ITkPixelEncodingAlg::initialize() +{ + + ATH_CHECK(m_pixelRDOKey.initialize()); + + // retrieve PixelID helper + if (!detStore()->retrieve(m_pixIdHelper, "PixelID").isSuccess()) { + ATH_MSG_FATAL("Unable to retrieve PixelID helper"); + return StatusCode::FAILURE; + } + + // retrieve PixelDetectorManager + if (!detStore()->retrieve(m_pixelManager,"ITkPixel").isSuccess()) { + ATH_MSG_FATAL("Unable to retrieve PixelDetectorManager"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode ITkPixelEncodingAlg::execute(const EventContext& ctx) const +{ + + // const PixelRDO_Container p_pixelRDO_cont = nullptr; + SG::ReadHandle<PixelRDO_Container> p_pixelRDO_cont(m_pixelRDOKey, ctx); + + InDetDD::SiDetectorElementCollection::const_iterator element; + + for (element = m_pixelManager->getDetectorElementBegin(); element != m_pixelManager->getDetectorElementEnd(); ++element) { + + if (!(*element)) continue; + + const InDetDD::PixelModuleDesign *design = dynamic_cast<const InDetDD::PixelModuleDesign*>(&((*element)->design())); + + // get the IdHash of the detector element + IdentifierHash IdHash = (*element)->identifyHash(); + + // get the module and chip definitions + const int chips = design->numberOfCircuits(); + int rowsPerChip = design->rowsPerCircuit(); + int columnsPerChip = design->columnsPerCircuit(); + // const int chipsInPhi = design->rows()/rowsPerChip; + // const int chipsinEta = design->columns()/columnsPerChip; + + // const float phiPitch = design->phiPitch(); + // bool use50x50 = true; + // if (phiPitch < s_pitch50x50) + // use50x50 = false; + + + Region region = (*element)->isBarrel() ? BARREL : ENDCAP; + + bool doSwapCoordinates = false; + // takle the case where the chips are rotated. You need to swap the phi/eta indices for the pixel + // since the front-end as well is rotated and the chip map has to get the right coordinates + // It happens for all the single chip modules in the endcap: + // - innermost layer + // - shorties in the next-to-innermost layer + if (region==ENDCAP and chips==1) { + doSwapCoordinates = true; + } + + // swap dimensions if needed + if (doSwapCoordinates) + std::swap(columnsPerChip, rowsPerChip); + + + // The chipmap was initialized here -- sroygara + // std::vector<ChipMap> chip_maps = std::vector<ChipMap>(chips, ChipMap(columnsPerChip, rowsPerChip, use50x50)); + + // get the RDO collection associated to the detector element + PixelRDO_Container::const_iterator rdoCont_itr(p_pixelRDO_cont->indexFind(IdHash)); + + // if the collection is filled, fill the chip map, otherwise leave it empty + if (rdoCont_itr!=p_pixelRDO_cont->end()) { + + // loop though the rdo collection + for (auto rdo_itr = (*rdoCont_itr)->begin() ; rdo_itr != (*rdoCont_itr)->end() ; ++rdo_itr) { + + // Get info from RDO + const Identifier rdoID((*rdo_itr)->identify()); + int pixPhiIx(m_pixIdHelper->phi_index(rdoID)); + int pixEtaIx(m_pixIdHelper->eta_index(rdoID)); + const int tot((*rdo_itr)->getToT()); + + // swap coordinates if needed + if (doSwapCoordinates) { + std::swap(pixEtaIx,pixPhiIx); + } + + // evaluating the chip number considering the number of rows and columns per chip and + // the total number of rows and columns on the sensor + // int chip = std::ceil(pixEtaIx/columnsPerChip) + chipsInPhi*std::ceil(pixPhiIx/rowsPerChip); + + // get the eta/phi index wrt to the chip, not the module + int pixEta = pixEtaIx - std::ceil(pixEtaIx/columnsPerChip)*columnsPerChip; + int pixPhi = pixPhiIx - std::ceil(pixPhiIx/rowsPerChip)*rowsPerChip; + + ATH_MSG_DEBUG("nChips: " + std::to_string(chips) + " ToT: " + std::to_string(tot) + " pixEta: " + std::to_string(pixEta) + " pixPhi: " + std::to_string(pixPhi)); + + // The info is then passed to some sort of chip map -- sroygara + //chip_maps.at(chip).fillChipMap(pixEta, pixPhi, tot); + + } + } + } + + // fillChipMaps(ctx); + + return StatusCode::SUCCESS; +} + + + + + + + + + + diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.h b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..9729baf13937133dfaa797a13f2d7857a3dfe0b7 --- /dev/null +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/ITkPixelEncodingAlg.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ITKPIXEL_ENCODINGALG_H +#define ITKPIXEL_ENCODINGALG_Hi + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "InDetRawData/PixelRDO_Container.h" +#include "StoreGate/ReadHandleKey.h" + +namespace InDetDD { + class PixelDetectorManager; +} + +class PixelID; + + +class ITkPixelEncodingAlg : public AthReentrantAlgorithm +{ + public: + ITkPixelEncodingAlg(const std::string &name, ISvcLocator *pSvcLocator); + ~ITkPixelEncodingAlg(){} + + virtual StatusCode initialize(); + virtual StatusCode execute (const EventContext& ctx) const; + + private: + + enum Region { + INVALID_REGION=-1, BARREL, ENDCAP, N_REGIONS + }; + + SG::ReadHandleKey<PixelRDO_Container> m_pixelRDOKey{this,"PixelRDOKey","ITkPixelRDOs","StoreGate Key of Pixel RDOs"}; + const InDetDD::PixelDetectorManager* m_pixelManager; + const PixelID* m_pixIdHelper; + + static constexpr float s_pitch50x50=0.050; + +}; +#endif + diff --git a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/components/ITkPixelByteStreamCnv_entries.cxx b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/components/ITkPixelByteStreamCnv_entries.cxx index bcfcdbb2ac2ee2275549475728a5ac86fa972e33..279d9b7f3970e87dcbacdbc4362e6535a0e6a6ec 100644 --- a/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/components/ITkPixelByteStreamCnv_entries.cxx +++ b/InnerDetector/InDetEventCnv/ITkPixelByteStreamCnv/src/components/ITkPixelByteStreamCnv_entries.cxx @@ -2,9 +2,13 @@ Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ -#include "../ITkPixelRawDataProviderTool.h" -#include "../ITkPixelRodDecoder.h" +// #include "src/ITkPixelRawDataProviderTool.h" +// #include "src/ITkPixelRodDecoder.h" +#include "src/ITkPixelEncodingAlg.h" +// #include "src/PixelRDOTool.h" -DECLARE_COMPONENT( ITkPixelRawDataProviderTool ) -DECLARE_COMPONENT( ITkPixelRodDecoder ) +// DECLARE_COMPONENT( ITkPixelRawDataProviderTool ) +// DECLARE_COMPONENT( ITkPixelRodDecoder ) +DECLARE_COMPONENT( ITkPixelEncodingAlg ) +// DECLARE_COMPONENT( PixelRDOTool ) \ No newline at end of file