Skip to content
Snippets Groups Projects
Commit a7304c39 authored by Sebastien Roy-Garand's avatar Sebastien Roy-Garand Committed by Johannes Elmsheuser
Browse files

ITk pixel bytestream encoding

ITk pixel bytestream encoding
parent b14b3792
No related branches found
No related tags found
No related merge requests found
...@@ -21,17 +21,17 @@ atlas_add_component( ITkPixelByteStreamCnv ...@@ -21,17 +21,17 @@ atlas_add_component( ITkPixelByteStreamCnv
ByteStreamCnvSvcBaseLib InDetIdentifier PixelReadoutGeometryLib IRegionSelector ByteStreamCnvSvcBaseLib InDetIdentifier PixelReadoutGeometryLib IRegionSelector
xAODEventInfo TrigSteeringEvent InDetByteStreamErrors ITkPixelByteStreamCnvLib ByteStreamCnvSvcLib ) xAODEventInfo TrigSteeringEvent InDetByteStreamErrors ITkPixelByteStreamCnvLib ByteStreamCnvSvcLib )
atlas_add_test(ITkPixelRodDecoder_test # atlas_add_test(ITkPixelRodDecoder_test
SOURCES test/ITkPixelRodDecoder_test.cxx # SOURCES test/ITkPixelRodDecoder_test.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} # INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib Identifier ITkPixelByteStreamCnvLib # LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib Identifier ITkPixelByteStreamCnvLib
POST_EXEC_SCRIPT "nopost.sh" ) # POST_EXEC_SCRIPT "nopost.sh" )
atlas_add_test(ITkPixelRawDataProviderTool_test # atlas_add_test(ITkPixelRawDataProviderTool_test
SOURCES test/ITkPixelRawDataProviderTool_test.cxx # SOURCES test/ITkPixelRawDataProviderTool_test.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} # INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib Identifier ITkPixelByteStreamCnvLib # LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib Identifier ITkPixelByteStreamCnvLib
POST_EXEC_SCRIPT "nopost.sh" ) # POST_EXEC_SCRIPT "nopost.sh" )
# Install files from the package: # Install files from the package:
atlas_install_joboptions( share/*.txt ) atlas_install_joboptions( share/*.txt )
......
#
# 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
#
# 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
#!/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)
/*
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;
}
/*
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
...@@ -2,9 +2,13 @@ ...@@ -2,9 +2,13 @@
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/ */
#include "../ITkPixelRawDataProviderTool.h" // #include "src/ITkPixelRawDataProviderTool.h"
#include "../ITkPixelRodDecoder.h" // #include "src/ITkPixelRodDecoder.h"
#include "src/ITkPixelEncodingAlg.h"
// #include "src/PixelRDOTool.h"
DECLARE_COMPONENT( ITkPixelRawDataProviderTool ) // DECLARE_COMPONENT( ITkPixelRawDataProviderTool )
DECLARE_COMPONENT( ITkPixelRodDecoder ) // DECLARE_COMPONENT( ITkPixelRodDecoder )
DECLARE_COMPONENT( ITkPixelEncodingAlg )
// DECLARE_COMPONENT( PixelRDOTool )
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment