diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/NoiseMapBuilder.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/NoiseMapBuilder.h index 86739afd2aa8d844496e6c1d4707181b2215cdab..6b254d6bea637c7cb70006e7ae0b3095386376b1 100755 --- a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/NoiseMapBuilder.h +++ b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/NoiseMapBuilder.h @@ -21,7 +21,6 @@ class PixelID; class TH2D; class TH2C; class TH1D; -class ISpecialPixelMapSvc; namespace InDetDD{ class PixelDetectorManager; @@ -68,7 +67,6 @@ class NoiseMapBuilder: public AthAlgorithm{ ServiceHandle <ITHistSvc> m_tHistSvc; ServiceHandle <IInDetConditionsSvc> m_pixelConditionsSummarySvc; ServiceHandle <IPixelByteStreamErrorsSvc> m_BSErrorsSvc; - ServiceHandle <ISpecialPixelMapSvc> m_specialPixelMapSvc; const InDetDD::PixelDetectorManager *m_pixman; const PixelID *m_pixelID; diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx index 8868e7b3f34826729fd1a09c3e2d2ca441a6acc9..dc4fad3b13a8a510707b0d6e5d7b13f3383decf4 100755 --- a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx +++ b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // PixelCalibAlgs @@ -9,8 +9,6 @@ // PixelConditions #include "InDetConditionsSummaryService/IInDetConditionsSvc.h" #include "PixelConditionsServices/IPixelByteStreamErrorsSvc.h" -#include "PixelConditionsServices/ISpecialPixelMapSvc.h" -#include "PixelConditionsData/SpecialPixelMap.h" // Gaudi #include "GaudiKernel/ITHistSvc.h" @@ -43,7 +41,6 @@ NoiseMapBuilder::NoiseMapBuilder(const std::string& name, ISvcLocator* pSvcLocat m_tHistSvc("THistSvc", name), m_pixelConditionsSummarySvc("PixelConditionsSummarySvc", name), m_BSErrorsSvc("PixelByteStreamErrorsSvc",name), - m_specialPixelMapSvc("SpecialPixelMapSvc", name), m_pixman(0), m_pixelID(0), m_pixelRDOKey("PixelRDOs"), @@ -182,13 +179,6 @@ StatusCode NoiseMapBuilder::initialize(){ return StatusCode::FAILURE; } - // retrieve SpecialPixelMapSvc - sc = m_specialPixelMapSvc.retrieve(); - if(!sc.isSuccess()){ - ATH_MSG_FATAL("Unable to retrieve SpecialPixelMapSvc"); - return StatusCode::FAILURE; - } - // retrieve PixelDetectorManager sc = detStore()->retrieve(m_pixman,"Pixel"); if(!sc.isSuccess()){ diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelCablingCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelCablingCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b201c5f9139484a0c0c057e8612f44e215ba016e --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelCablingCondAlg.cxx @@ -0,0 +1,314 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PixelCablingCondAlg.h" +#include "GaudiKernel/EventIDRange.h" + +#include <iostream> +#include <fstream> +#include <sstream> + +#include "PathResolver/PathResolver.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdContext.h" +#include "CoralBase/Blob.h" + +PixelCablingCondAlg::PixelCablingCondAlg(const std::string& name, ISvcLocator* pSvcLocator): + ::AthAlgorithm(name, pSvcLocator), + m_pixelID(nullptr), + m_condSvc("CondSvc", name), + m_useConditions(true), + m_rodidForSingleLink40(0), + m_dump_map_to_file(false) +{ + declareProperty("MappingFile", m_final_mapping_file="PixelCabling/Pixels_Atlas_IdMapping_2016.dat"); + declareProperty("UseConditions", m_useConditions); + declareProperty("RodIDForSingleLink40", m_rodidForSingleLink40); + declareProperty("DumpMapToFile", m_dump_map_to_file); +} + +StatusCode PixelCablingCondAlg::initialize() { + ATH_MSG_DEBUG("PixelCablingCondAlg::initialize()"); + + ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID")); + + ATH_CHECK(m_condSvc.retrieve()); + ATH_CHECK(m_readoutspeedKey.initialize()); + ATH_CHECK(m_readKey.initialize()); + + ATH_CHECK(m_writeKey.initialize()); + if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { + ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); + return StatusCode::FAILURE; + } + + ATH_MSG_WARNING("Special treatment: Once RegionSelectorTable is fixed, these lines should be removed."); + + SG::WriteCondHandle<PixelCablingCondData> writeHandle(m_writeKey); + if (writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order."); + return StatusCode::SUCCESS; + } + std::unique_ptr<PixelCablingCondData> writeCdo(std::make_unique<PixelCablingCondData>()); + const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + EventIDRange rangeW{start, stop}; + + // Signed values + int barrel_ec, eta_module; + + // Unsigned 32 bit values + uint32_t layer_disk, phi_module; + uint32_t robid, rodid; + uint32_t sl_40_fmt, sl_40_link, sl_80_fmt, sl_80_link; + + // Unsigned 64-bit values + uint64_t onlineId = 0; + uint64_t linknumber = 0; + + // Strings + std::string DCSname; + std::string line; + + std::string filename = PathResolverFindCalibFile(m_final_mapping_file); + if (filename.size()==0) { + ATH_MSG_FATAL("Mapping File: " << m_final_mapping_file << " not found!"); + return StatusCode::FAILURE; + } + std::ifstream fin(filename.c_str()); + if (!fin) { return StatusCode::FAILURE; } + std::stringstream instr; + instr << fin.rdbuf(); + + while (instr.good() && getline(instr, line)) { + if (line.size()==0) { continue; } + if (line.substr(0,1)==" " || line.substr(0,1)=="#") { continue; } + if (line.length()<21) { continue; } + if (line.substr(line.length()-3,line.length())=="GMT") { continue; } + std::istringstream parse(line); + parse >> barrel_ec >> layer_disk >> phi_module >> eta_module >> std::hex >> robid >> rodid >> sl_40_fmt >> sl_40_link >> sl_80_fmt >> sl_80_link >> DCSname; + Identifier offlineId = m_pixelID->wafer_id(barrel_ec,layer_disk,phi_module,eta_module); + if ((robid & 0xFFFFFF)>=0x140000) { + linknumber = sl_40_link | (sl_40_fmt<<4) | (sl_80_link<<8) | (sl_80_fmt<<12); + } + else { + // Valid for data + bool readoutSpeed = true; + if (rodid>m_rodidForSingleLink40) { readoutSpeed=false; } + if (readoutSpeed==false) { linknumber=(sl_40_link & 0xF) | ((sl_40_fmt & 0xF)<<4); } + else { linknumber=(sl_80_link & 0xF) | ((sl_80_fmt & 0xF)<<4); } + } + onlineId = (robid & 0xFFFFFF) | (linknumber<<24); + IdentifierHash hashId; + IdContext cntxpixel = m_pixelID->wafer_context(); + if (m_pixelID->get_hash(offlineId, hashId, &cntxpixel)) { + ATH_MSG_WARNING("Could not get hash from offlineId"); + } + writeCdo->add_entry_onoff(onlineId, offlineId); + writeCdo->add_entry_offon(offlineId, onlineId); + writeCdo->add_entry_offlineList(robid,offlineId); + writeCdo->add_entry_offrob(offlineId, robid); + writeCdo->add_entry_rodrob(rodid, robid); + writeCdo->add_entry_robrod(robid, rodid); + writeCdo->add_entry_DCSoffline(DCSname, offlineId); + } + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { + ATH_MSG_FATAL("Could not record PixelCablingCondData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_WARNING("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store"); + ATH_MSG_WARNING("Tempolary fix!!: Refilled pixel cabling from file \"" << m_final_mapping_file << "\""); + + return StatusCode::SUCCESS; +} + +StatusCode PixelCablingCondAlg::execute() { + ATH_MSG_DEBUG("PixelCablingCondAlg::execute()"); + + SG::WriteCondHandle<PixelCablingCondData> writeHandle(m_writeKey); + ATH_MSG_WARNING("Conditions updates every event!!! This should be avoided once RegionSelectorTable was fixed!!"); +// if (writeHandle.isValid()) { +// ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order."); +// return StatusCode::SUCCESS; +// } + + // Construct the output Cond Object and fill it in + std::unique_ptr<PixelCablingCondData> writeCdo(std::make_unique<PixelCablingCondData>()); + + const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + EventIDRange rangeW{start, stop}; + + // Signed values + int barrel_ec, eta_module; + + // Unsigned 32 bit values + uint32_t layer_disk, phi_module; + uint32_t robid, rodid; + uint32_t sl_40_fmt, sl_40_link, sl_80_fmt, sl_80_link; + + // Unsigned 64-bit values + uint64_t onlineId = 0; + uint64_t linknumber = 0; + + // Strings + std::string DCSname; + std::string line; + + // For debugging purposes + std::ofstream output_mapping_file_raw; + if (m_dump_map_to_file) { output_mapping_file_raw.open("pixel_cabling_map_raw.txt"); } + std::ofstream output_mapping_file_interpreted; + if (m_dump_map_to_file) { output_mapping_file_interpreted.open("pixel_cabling_map_interpreted.txt"); } + + std::stringstream instr; + if (m_useConditions) { + SG::ReadCondHandle<AthenaAttributeList> readHandle(m_readKey); + const AthenaAttributeList* readCdo = *readHandle; + if (readCdo==nullptr) { + ATH_MSG_FATAL("Null pointer to the read conditions object"); + return StatusCode::FAILURE; + } + // Get the validitiy range + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("Size of AthenaAttributeList " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size()); + ATH_MSG_INFO("Range of input is " << rangeW); + + const coral::Blob& blob_cabling=(*readCdo)["CablingMapData"].data<coral::Blob>(); + const char* p_cabling = static_cast<const char*>(blob_cabling.startingAddress()); + + unsigned int len_cabling = blob_cabling.size()/sizeof(char); + ATH_MSG_DEBUG("blob_cabling.size() = " << blob_cabling.size() << ", len_cabling = " << len_cabling); + + instr.str(std::string(p_cabling,blob_cabling.size())); + } + else { + std::string filename = PathResolverFindCalibFile(m_final_mapping_file); + if (filename.size()==0) { + ATH_MSG_FATAL("Mapping File: " << m_final_mapping_file << " not found!"); + return StatusCode::FAILURE; + } + std::ifstream fin(filename.c_str()); + if (!fin) { return StatusCode::FAILURE; } + instr << fin.rdbuf(); + ATH_MSG_INFO("Refilled pixel cabling from file \"" << m_final_mapping_file << "\""); + } + + // Each entry in the mapping is sepated by a newline. + // Loop over all lines and parse the values + std::map<uint32_t,bool> rodReadoutMap = SG::ReadCondHandle<PixelReadoutSpeedData>(m_readoutspeedKey)->getReadoutMap(); + + while (instr.good() && getline(instr, line)) { + + if (m_dump_map_to_file) { output_mapping_file_raw << line << std::endl; } + + // Skip empty lines and comments (i.e. starting with a hash or a space) + if (line.empty()) { continue; } + if (line[0]==' ' || line[0]=='#') { continue; } + + // There are 11 columns, so there must be at least 21 characters in a valid line. + if (line.length()<21) { continue; } + + // If reading from COOL, skip the datestamp + if (line.substr(line.length()-3,line.length())=="GMT") { continue; } + + std::istringstream parse(line); + parse >> barrel_ec >> layer_disk >> phi_module >> eta_module >> std::hex >> robid >> rodid >> sl_40_fmt >> sl_40_link >> sl_80_fmt >> sl_80_link >> DCSname; + + // Debug + if (m_dump_map_to_file) { + output_mapping_file_interpreted << barrel_ec << "\t" << layer_disk << "\t" << phi_module << "\t" + << eta_module << "\t" << std::hex << robid << "\t" << rodid << "\t" + << sl_40_fmt << "\t" << sl_40_link << "\t" << sl_80_fmt << "\t" + << sl_80_link << "\t" << DCSname << std::dec << std::endl; + } + + // Get the offline ID for this module + Identifier offlineId = m_pixelID->wafer_id(barrel_ec,layer_disk,phi_module,eta_module); + + // Set linknumber for IBL / DBM entries + if ((robid & 0xFFFFFF)>=0x140000) { + linknumber = sl_40_link | (sl_40_fmt<<4) | (sl_80_link<<8) | (sl_80_fmt<<12); + } + // Set linknumber for pixel entries + else { + bool readoutSpeed = false; + if (rodReadoutMap.find(rodid)!=rodReadoutMap.end()) { readoutSpeed=rodReadoutMap[rodid]; } + + if (readoutSpeed==false) { linknumber=(sl_40_link & 0xF) | ((sl_40_fmt & 0xF)<<4); } + else { linknumber=(sl_80_link & 0xF) | ((sl_80_fmt & 0xF)<<4); } + } + + // Compute onlineId + onlineId = (robid & 0xFFFFFF) | (linknumber<<24); + + IdentifierHash hashId; + + // Do checks to verify consistency + IdContext cntxpixel = m_pixelID->wafer_context(); + if (m_pixelID->get_hash(offlineId, hashId, &cntxpixel)) { + ATH_MSG_WARNING("Could not get hash from offlineId"); + } + + if (hashId>m_pixelID->wafer_hash_max()) { + ATH_MSG_ERROR("IdHash overflow! HashId is 0x" << std::hex << hashId); + ATH_MSG_ERROR("not mapped OfflineID: " << std::hex << offlineId << std::dec << " barrel_ec: " << barrel_ec + << " layer_disk: " << layer_disk << " phi_module: " << phi_module << " eta_module: " << eta_module); + ATH_MSG_ERROR("to OnlineID: 0x" << std::hex << onlineId << " robid: 0x" << robid << " rodid: 0x" << rodid << std::dec + << " link: 0x" << std::hex /*<< link*/ << " -> Linknumber: 0x" << linknumber << " HashId: 0x" << hashId << std::dec); + + // Check if offlineId fail was caused by exceeding eta_module range + if (eta_module>m_pixelID->eta_module_max(offlineId) || eta_module<m_pixelID->eta_module_min(offlineId)) { + // eta_module_max == -999 indicates the module does not exist + if (m_pixelID->eta_module_max(offlineId)==-999 && m_pixelID->eta_module_min(offlineId)==-999) { + ATH_MSG_ERROR("Module does not exist in geometry"); + } + else { + ATH_MSG_ERROR("eta_module range exceeded: Got eta_module = " << eta_module + << ", but allowed range is [" << m_pixelID->eta_module_min(offlineId) + << "," << m_pixelID->eta_module_max(offlineId) << "]"); + ATH_MSG_ERROR("Input geometry tag may not be compatible with mapping file"); + } + } + } + + // Fill the maps + writeCdo->add_entry_onoff(onlineId, offlineId); + writeCdo->add_entry_offon(offlineId, onlineId); + writeCdo->add_entry_offlineList(robid,offlineId); + writeCdo->add_entry_offrob(offlineId, robid); + writeCdo->add_entry_rodrob(rodid, robid); + writeCdo->add_entry_robrod(robid, rodid); + writeCdo->add_entry_DCSoffline(DCSname, offlineId); + + // Debug messages + ATH_MSG_DEBUG("Mapped offlineID: " << std::hex << offlineId << " to onlineID: 0x" << onlineId + << ", robID: 0x" << robid << ", barrel_ec: " << std::dec << barrel_ec << ", layer_disk: " << layer_disk + << ", eta_module: " << eta_module << ", phi_module: " << phi_module << ", linknumber: 0x" << std::hex << linknumber); + } + + if (m_dump_map_to_file) { + output_mapping_file_raw.close(); + output_mapping_file_interpreted.close(); + } + + ATH_MSG_DEBUG("Size of ROD readoutspeed map: " << rodReadoutMap.size()); + writeCdo->set_readout_map(rodReadoutMap); + + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { + ATH_MSG_FATAL("Could not record PixelCablingCondData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store"); + + return StatusCode::SUCCESS; +} + +StatusCode PixelCablingCondAlg::finalize() { + ATH_MSG_DEBUG("PixelCablingCondAlg::finalize()"); + return StatusCode::SUCCESS; +} diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelCablingCondAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelCablingCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..d88e26b83445ce77b71cc8e9252de9a489c76176 --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelCablingCondAlg.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PIXELCABLINGCONDALG_H +#define PIXELCABLINGCONDALG_H + +#include "AthenaBaseComps/AthAlgorithm.h" + +#include "StoreGate/ReadCondHandleKey.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" + +#include "StoreGate/WriteCondHandleKey.h" +#include "PixelConditionsData/PixelReadoutSpeedData.h" +#include "PixelConditionsData/PixelCablingCondData.h" + +#include "InDetIdentifier/PixelID.h" + +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/Property.h" + +#include <map> +#include <stdint.h> +#include <string> +#include <istream> + +class PixelCablingCondAlg : public AthAlgorithm { + public: + PixelCablingCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~PixelCablingCondAlg() = default; + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + private: + const PixelID* m_pixelID; + ServiceHandle<ICondSvc> m_condSvc; + bool m_useConditions; + uint32_t m_rodidForSingleLink40; + bool m_dump_map_to_file; + std::string m_final_mapping_file; + + SG::ReadCondHandleKey<PixelReadoutSpeedData> m_readoutspeedKey + {this, "PixelReadoutSpeedData", "PixelReadoutSpeedData", "Pixel readout speed data"}; + + SG::ReadCondHandleKey<AthenaAttributeList> m_readKey + {this, "ReadKey", "/PIXEL/CablingMap", "Input cabling folder"}; + + SG::WriteCondHandleKey<PixelCablingCondData> m_writeKey + {this, "WriteKey", "PixelCablingCondData", "Output cabling data"}; + +}; + +#endif diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelHitDiscCnfgAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelHitDiscCnfgAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a6206c0d9973b5e84e49fde67415ef4e4171dbef --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelHitDiscCnfgAlg.cxx @@ -0,0 +1,135 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PixelHitDiscCnfgAlg.h" +#include "GaudiKernel/EventIDRange.h" + +#include "CoralBase/Blob.h" + +#include <map> +#include <stdint.h> +#include <string> +#include <istream> + +PixelHitDiscCnfgAlg::PixelHitDiscCnfgAlg(const std::string& name, ISvcLocator* pSvcLocator): + ::AthAlgorithm(name, pSvcLocator), + m_condSvc("CondSvc", name), + m_defaultHitDiscCnfg(2) +{ + declareProperty("FEI4HitDiscConfig", m_defaultHitDiscCnfg); +} + +StatusCode PixelHitDiscCnfgAlg::initialize() { + ATH_MSG_DEBUG("PixelHitDiscCnfgAlg::initialize()"); + + ATH_CHECK(m_condSvc.retrieve()); + + ATH_CHECK(m_readKey.initialize()); + ATH_CHECK(m_writeKey.initialize()); + if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { + ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode PixelHitDiscCnfgAlg::execute() { + ATH_MSG_DEBUG("PixelHitDiscCnfgAlg::execute()"); + + SG::WriteCondHandle<PixelHitDiscCnfgData> writeHandle(m_writeKey); + if (writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order."); + return StatusCode::SUCCESS; + } + + SG::ReadCondHandle<AthenaAttributeList> readHandle(m_readKey); + const AthenaAttributeList* readCdo = *readHandle; + if (readCdo==nullptr) { + ATH_MSG_FATAL("Null pointer to the read conditions object"); + return StatusCode::FAILURE; + } + // Get the validitiy range + EventIDRange rangeW; + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("Size of AthenaAttributeList " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size()); + ATH_MSG_INFO("Range of input is " << rangeW); + + // Construct the output Cond Object and fill it in + std::unique_ptr<PixelHitDiscCnfgData> writeCdo(std::make_unique<PixelHitDiscCnfgData>()); + + const coral::Blob& blob=(*readCdo)["HitDiscCnfgData"].data<coral::Blob>(); + const uint32_t* p = static_cast<const uint32_t*>(blob.startingAddress()); + + uint32_t cooldata; + unsigned int len = blob.size()/sizeof(uint32_t); + ATH_MSG_DEBUG("blob.size() = " << blob.size() << ", len = " << len); + + int nhitPL = 0; + int hitPL = 0; + int nhit3D = 0; + int hit3D = 0; + for (unsigned int i = 0; i < len; ++i) { + + cooldata = *p++; + + ATH_MSG_DEBUG("Got hitdisccnfgData[" << i << "] = 0x" << std::hex << cooldata << std::dec); + + // The implementation below uses one common value, one common 3D value, + // and an exception list of individual FEs, in order to save DB space. + // Here we convert this into only one common value and an exception list, i.e. + // if the 3D FEs have a different common value they are all added to the exception list + if ((cooldata & 0x8FFFFFFF)==0x0) { // undefined. + ATH_MSG_DEBUG("Setting common HitDiscCnfg value to " << ((cooldata&0x30000000) >> 28)); + nhitPL++; + hitPL+=((cooldata&0x30000000) >> 28); + } + // Update all 3D sensors with a common value, identified by 0xZ0000000, where Z = 10hh + else if ((cooldata & 0x8FFFFFFF)==0x80000000) { + ATH_MSG_DEBUG("Setting common 3D HitDiscCnfg value to " << ((cooldata&0x30000000) >> 28)); + nhit3D++; + hit3D+=((cooldata&0x30000000) >> 28); + } + // Update a single link, 0xHLDDRRRR + else { + ATH_MSG_DEBUG("Setting HitDiscCnfg value to " << ((cooldata&0x30000000) >> 28) + << " for ROB 0x" << std::hex << (cooldata & 0xFFFFFF) + << ", link " << std::dec << ((cooldata & 0xF000000) >> 24)); + nhitPL++; + hitPL+=((cooldata&0x30000000) >> 28); + } + } + // Take average. + double aveHitPL = 1.0*m_defaultHitDiscCnfg; + double aveHit3D = 1.0*m_defaultHitDiscCnfg; + if (nhitPL) { aveHitPL = hitPL/(1.0*nhitPL); } + + if (nhit3D) { aveHit3D = hit3D/(1.0*nhit3D); } + else { aveHit3D = aveHitPL; } + + if (aveHitPL-(double)(int)aveHitPL<0.5) { aveHitPL=(double)(int)aveHitPL; } + else { aveHitPL=(double)(int)(aveHitPL+0.9); } + + if (aveHit3D-(double)(int)aveHit3D<0.5) { aveHit3D=(double)(int)aveHit3D; } + else { aveHit3D=(double)(int)(aveHit3D+0.9); } + + writeCdo -> setHitDiscCnfgPL((int)aveHitPL); + writeCdo -> setHitDiscCnfg3D((int)aveHit3D); + + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { + ATH_MSG_FATAL("Could not record PixelHitDiscCnfgData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store"); + + return StatusCode::SUCCESS; +} + +StatusCode PixelHitDiscCnfgAlg::finalize() { + ATH_MSG_DEBUG("PixelHitDiscCnfgAlg::finalize()"); + return StatusCode::SUCCESS; +} diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelHitDiscCnfgAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelHitDiscCnfgAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..f68793e34228bac86b913970ca7608de387cc8f1 --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelHitDiscCnfgAlg.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PIXELHITDISCCNFGALG_H +#define PIXELHITDISCCNFGALG_H + +#include "AthenaBaseComps/AthAlgorithm.h" + +#include "StoreGate/ReadCondHandleKey.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" + +#include "StoreGate/WriteCondHandleKey.h" +#include "PixelConditionsData/PixelHitDiscCnfgData.h" + +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/Property.h" + +class PixelHitDiscCnfgAlg : public AthAlgorithm { + public: + PixelHitDiscCnfgAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~PixelHitDiscCnfgAlg() = default; + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + private: + ServiceHandle<ICondSvc> m_condSvc; + int m_defaultHitDiscCnfg; + + SG::ReadCondHandleKey<AthenaAttributeList> m_readKey + {this, "ReadKey", "/PIXEL/HitDiscCnfg", "Input HitDiscCnfg folder"}; + + SG::WriteCondHandleKey<PixelHitDiscCnfgData> m_writeKey + {this, "WriteKey", "PixelHitDiscCnfgData", "Output HitDiscCnfg data"}; + +}; + +#endif diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelReadoutSpeedAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelReadoutSpeedAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..253499ce13bfa7f3276cd9468e2f827ad016a717 --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelReadoutSpeedAlg.cxx @@ -0,0 +1,98 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PixelReadoutSpeedAlg.h" +#include "GaudiKernel/EventIDRange.h" + +#include "CoralBase/Blob.h" + +#include <map> +#include <stdint.h> +#include <string> +#include <istream> + +PixelReadoutSpeedAlg::PixelReadoutSpeedAlg(const std::string& name, ISvcLocator* pSvcLocator): + ::AthAlgorithm(name, pSvcLocator), + m_condSvc("CondSvc", name) +{ +} + +StatusCode PixelReadoutSpeedAlg::initialize() { + ATH_MSG_DEBUG("PixelReadoutSpeedAlg::initialize()"); + + ATH_CHECK(m_condSvc.retrieve()); + + ATH_CHECK(m_readKey.initialize()); + ATH_CHECK(m_writeKey.initialize()); + if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { + ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode PixelReadoutSpeedAlg::execute() { + ATH_MSG_DEBUG("PixelReadoutSpeedAlg::execute()"); + + SG::WriteCondHandle<PixelReadoutSpeedData> writeHandle(m_writeKey); + if (writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order."); + return StatusCode::SUCCESS; + } + + SG::ReadCondHandle<AthenaAttributeList> readHandle(m_readKey); + const AthenaAttributeList* readCdo = *readHandle; + if (readCdo==nullptr) { + ATH_MSG_FATAL("Null pointer to the read conditions object"); + return StatusCode::FAILURE; + } + // Get the validitiy range + EventIDRange rangeW; + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("Size of AthenaAttributeList " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size()); + ATH_MSG_INFO("Range of input is " << rangeW); + + // Construct the output Cond Object and fill it in + std::unique_ptr<PixelReadoutSpeedData> writeCdo(std::make_unique<PixelReadoutSpeedData>()); + + const coral::Blob& blob=(*readCdo)["readoutspeed_per_ROD"].data<coral::Blob>(); + const char* p = static_cast<const char*>(blob.startingAddress()); + unsigned int len = blob.size(); + std::map<uint32_t,bool> rodReadoutMap; // save readout speed for each ROD. Is set to 40 MBit (false) by default + std::string dataString; + dataString.resize(len); + for (unsigned int i=0; i!=len; ++i) { dataString[i]=*p++; } + + int pos=0; + while (dataString.find(",",pos)!=std::string::npos) { + std::istringstream iss(dataString.substr(pos,dataString.find(",",pos))); + uint32_t rod; + iss >> std::hex >> rod; + + const std::string speed = dataString.substr(dataString.find(",",pos)+1,dataString.find("\n",pos)-dataString.find(",",pos)-1); + + if (speed!="SINGLE_40") { rodReadoutMap[rod]=true; } + else { rodReadoutMap[rod]=false; } + + pos = dataString.find("\n",pos)+1; + } + writeCdo -> setReadoutMap(rodReadoutMap); + + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { + ATH_MSG_FATAL("Could not record PixelReadoutSpeedData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store"); + + return StatusCode::SUCCESS; +} + +StatusCode PixelReadoutSpeedAlg::finalize() { + ATH_MSG_DEBUG("PixelReadoutSpeedAlg::finalize()"); + return StatusCode::SUCCESS; +} diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelReadoutSpeedAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelReadoutSpeedAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..60388c7cfb987839d293cf734fb4a983e9b559a2 --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelReadoutSpeedAlg.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PIXELREADOUTSPEEDALG_H +#define PIXELREADOUTSPEEDALG_H + +#include "AthenaBaseComps/AthAlgorithm.h" + +#include "StoreGate/ReadCondHandleKey.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" + +#include "StoreGate/WriteCondHandleKey.h" +#include "PixelConditionsData/PixelReadoutSpeedData.h" + +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/Property.h" + +class PixelReadoutSpeedAlg : public AthAlgorithm { + public: + PixelReadoutSpeedAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~PixelReadoutSpeedAlg() = default; + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + private: + ServiceHandle<ICondSvc> m_condSvc; + + SG::ReadCondHandleKey<AthenaAttributeList> m_readKey + {this, "ReadKey", "/PIXEL/ReadoutSpeed", "Input readout speed folder"}; + + SG::WriteCondHandleKey<PixelReadoutSpeedData> m_writeKey + {this, "WriteKey", "PixelReadoutSpeedData", "Output readout speed data"}; + +}; + +#endif diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/SpecialPixelMapCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/SpecialPixelMapCondAlg.cxx deleted file mode 100644 index 39fcdb919919fb9a089e670b04cb161ecb2750a5..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/SpecialPixelMapCondAlg.cxx +++ /dev/null @@ -1,653 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#include "SpecialPixelMapCondAlg.h" -#include "InDetIdentifier/PixelID.h" -#include "GeoModelInterfaces/IGeoModelSvc.h" -#include "InDetReadoutGeometry/PixelDetectorManager.h" -#include "Identifier/Identifier.h" -#include "InDetReadoutGeometry/PixelModuleDesign.h" -#include "InDetReadoutGeometry/SiDetectorElement.h" - - -SpecialPixelMapCondAlg::SpecialPixelMapCondAlg (const std::string& name, ISvcLocator* pSvcLocator) : - AthReentrantAlgorithm(name, pSvcLocator), - m_pixelID(nullptr), - m_geoModelSvc("GeoModelSvc",name), m_condSvc("CondSvc",name) -{ - declareProperty("GeoModelService", m_geoModelSvc); -} - -SpecialPixelMapCondAlg::~SpecialPixelMapCondAlg() { - -} - -constexpr size_t s_max=4; - -StatusCode SpecialPixelMapCondAlg::initialize() -{ - ATH_CHECK(detStore()->retrieve( m_pixelID, "PixelID" )); - ATH_CHECK( m_condSvc.retrieve() ); - - ATH_CHECK(m_geoModelSvc.retrieve()); - if(m_geoModelSvc->geoConfig()!=GeoModel::GEO_RUN1 && m_geoModelSvc->geoConfig()!=GeoModel::GEO_TESTBEAM)m_isIBL=true; - if(!m_isIBL)m_isIBL = m_geoModelSvc->geoConfig()==GeoModel::GEO_RUN1 && m_pixelID->wafer_hash_max()==2048; // second chance ! - - const InDetDD::PixelDetectorManager* pixman=nullptr; - ATH_CHECK(detStore()->retrieve( pixman, "Pixel" )); - InDetDD::SiDetectorElementCollection::const_iterator itermin, itermax; - itermin = pixman->getDetectorElementBegin(); - itermax = pixman->getDetectorElementEnd(); - for(auto &iter=itermin; iter !=itermax; ++iter) { - const InDetDD::SiDetectorElement* element = *iter; - if(element ==0) continue; - Identifier ident = element->identify(); - if(m_pixelID->is_pixel(ident)) { // OK this Element is included - const InDetDD::PixelModuleDesign* design = dynamic_cast<const InDetDD::PixelModuleDesign*>(&element->design()); - if(!design)continue; - unsigned int mchips = design->numberOfCircuits(); - int mrow =design->rows(); - if(mchips==8||abs(m_pixelID->barrel_ec(ident))==2||(m_pixelID->barrel_ec(ident)==0&&m_pixelID->layer_disk(ident)>0)) { - mchips *=2; // guess numberOfCircuits() - mrow /=2; // number of chips in row - } - unsigned int i(0); - if(mrow==336)i = 1; - else if(mrow==672) i = 2; - else if(mrow==339) i = 3; - else if(mrow==678) i = 4; - unsigned int idsh = m_pixelID->wafer_hash(ident); - m_chips[idsh]=mchips*10 + i; - //m_calibobjs.push_back(std::make_pair(ident,mchips)); - // write up the dump calibration here with default value: - } - } - - if (m_maskLayers && !m_layersToMask.size() && !m_disksToMask.size()) { - ATH_MSG_DEBUG( "Layer/Disk masking enabled, but no layer/disk specified!" ); - m_maskLayers = false; - } - - if (!m_maskLayers && (m_layersToMask.size() || m_disksToMask.size())) { - ATH_MSG_DEBUG( "Layer/Disk to mask specified, but masking is disabled!" ); - } - - if (m_maskLayers && m_disksToMask.size() && (std::find(m_disksToMask.begin(), m_disksToMask.end(),0)!=m_disksToMask.end())) { - ATH_MSG_WARNING( "0th Disk not defined (-N to N) - check your setup!" ); - } - - - if(m_condAttrListCollectionKeys.size() != m_specialPixelMapKeys.size()) { - ATH_MSG_FATAL("Inputs do not match outputs, check configuration"); - return StatusCode::FAILURE; - } - { //Limited scope to help avoid errors - std::array<SG::ReadCondHandleKey<CondAttrListCollection>*, s_max> condarray{{ &m_ConAttrList1, &m_ConAttrList2, &m_ConAttrList3, &m_ConAttrList4 }}; - if(m_condAttrListCollectionKeys.size() > s_max) { - ATH_MSG_FATAL("Too many collection keys provided, improve code (this was a messy comprimise)"); - return StatusCode::FAILURE; - } - for(size_t i=0; i< m_condAttrListCollectionKeys.size(); i++) { - *(condarray.at(i)) = m_condAttrListCollectionKeys[i]; - ATH_CHECK((*condarray.at(i)).initialize()); - } - } - { - std::array<SG::WriteCondHandleKey<DetectorSpecialPixelMap>*,s_max> outarray{{ &m_pixmap1, &m_pixmap2, &m_pixmap3, &m_pixmap4 }}; - for(size_t i=0; i< m_specialPixelMapKeys.size(); i++) { - *(outarray.at(i)) = m_specialPixelMapKeys[i]; - if((*outarray.at(i)).initialize().isFailure()){ - ATH_MSG_WARNING("Failed to register " << m_specialPixelMapKeys[i] << ", possibly already exists because of old service. Fix later in migration"); - *(outarray.at(i)) = std::string(""); - } - else ATH_CHECK(m_condSvc->regHandle(this, *outarray.at(i))); - } - } - - if(!m_overlayFolder.key().empty()) ATH_CHECK(m_overlayFolder.initialize()); - if(!m_overlayKey.key().empty()){ - if(m_overlayKey.initialize().isSuccess()){ - ATH_MSG_INFO("Registering " << m_overlayKey.key()); - ATH_CHECK(m_condSvc->regHandle(this, m_overlayKey)); - ATH_MSG_INFO("Registering done" << m_overlayKey.key()); - }else{ - ATH_MSG_WARNING("Failed to register " << m_overlayKey.key() << ", possibly already exists because of old service. Fix later in migration"); - m_overlayKey = std::string(""); - } - } - if(!m_maskingOverlayKey.key().empty()) { - if(m_maskingOverlayKey.initialize().isSuccess()) ATH_CHECK(m_condSvc->regHandle(this, m_maskingOverlayKey)); - else { - ATH_MSG_WARNING("Failed to register " << m_maskingOverlayKey.key() << ", possibly already exists because of old service. Fix later in migration"); - m_maskingOverlayKey = std::string(""); - } - } - if(!m_outputFolder.key().empty()) { - if(m_outputFolder.initialize().isSuccess()) ATH_CHECK(m_condSvc->regHandle(this, m_outputFolder)); - else { - ATH_MSG_WARNING("Failed to register " << m_outputFolder.key() << ", possibly already exists because of old service. Fix later in migration"); - m_outputFolder = std::string(""); - } - } - if(!m_outputLongFolder.key().empty()) { - if(m_outputLongFolder.initialize().isSuccess()) ATH_CHECK(m_condSvc->regHandle(this, m_outputLongFolder)); - else { - ATH_MSG_WARNING("Failed to register " << m_outputLongFolder.key() << ", possibly already exists because of old service. Fix later in migration"); - m_outputLongFolder = std::string(""); - } - } - if(!m_overlayLongFolder.key().empty()){ - if(m_overlayLongFolder.initialize().isSuccess()) ATH_CHECK(m_condSvc->regHandle(this, m_overlayLongFolder)); - else { - ATH_MSG_WARNING("Failed to register " << m_overlayLongFolder.key() << ", possibly already exists because of old service. Fix later in migration"); - m_overlayLongFolder = std::string(""); - } - } - if(!m_overlayLongKey.key().empty()) { - if(m_overlayLongKey.initialize()) ATH_CHECK(m_condSvc->regHandle(this, m_overlayLongKey)); - else { - ATH_MSG_WARNING("Failed to register " << m_overlayLongKey.key() << ", possibly already exists because of old service. Fix later in migration"); - m_overlayLongKey = std::string(""); - } - } - return StatusCode::SUCCESS; -} - -StatusCode SpecialPixelMapCondAlg::execute (const EventContext& ctx) const -{ - ATH_MSG_DEBUG("Entering SpecialPixelMapCondAlg"); - const std::array<const SG::ReadCondHandleKey<CondAttrListCollection>*, s_max> condarray{{ &m_ConAttrList1, &m_ConAttrList2, &m_ConAttrList3, &m_ConAttrList4 }}; - const std::array<const SG::WriteCondHandleKey<DetectorSpecialPixelMap>*, s_max> outarray{{ &m_pixmap1, &m_pixmap2, &m_pixmap3, &m_pixmap4 }}; - std::array<bool, s_max> newobject; newobject.fill(true); - const size_t N = m_condAttrListCollectionKeys.size();//should never be higher than s_max, check in initialize - std::array<DetectorSpecialPixelMap*, s_max> ptrcache; - std::array<EventIDRange, s_max> rangearray; - std::vector<EventIDRange> spmrange; - ptrcache.fill(nullptr); - DetectorSpecialPixelMap* &spm = ptrcache[0]; - - for (size_t i=0; i<N; i++) { - if(condarray[i]->key().empty()) continue; - SG::WriteCondHandle<DetectorSpecialPixelMap> outhandle(*outarray[i], ctx); - if (outhandle.isValid()) { - ATH_MSG_DEBUG((*outarray[i]).key() << " already valid"); - newobject[i] = false; - } - } - if(std::accumulate(newobject.begin(), newobject.begin() + N, 0) == 0){ - ATH_MSG_DEBUG("No new objects needed"); - return StatusCode::SUCCESS; - } - - - for (size_t i=0; i<N; i++) { - if(condarray[i]->key().empty()) continue; - ATH_MSG_DEBUG("Attempting to retrieve " << condarray[i]->key() ); - SG::ReadCondHandle<CondAttrListCollection> attrListColl(*condarray[i], ctx); - if(!attrListColl.range(rangearray[i])) { - ATH_MSG_ERROR("Failed to retrieve validity range for " << attrListColl.key()); - return StatusCode::FAILURE; - } - ATH_CHECK(createFromDetectorStore(attrListColl.retrieve(), true, ptrcache[i])); - newobject[i] = true; - } - - - if(N>0) spmrange.push_back(rangearray.at(0)); - if(m_mergePixelMaps && newobject[0]) { - for(size_t i=1; i<N; i++) { - if(ptrcache[i]==nullptr) continue; - if(newobject[i] ==false){ - SG::ReadCondHandleKey<DetectorSpecialPixelMap> key(outarray[i]->key()); - SG::ReadCondHandle<DetectorSpecialPixelMap> inhandle(key, ctx); - *spm += *inhandle.retrieve(); - }else{ - spm->merge(ptrcache[i]); - } - spmrange.push_back(rangearray[i]); - } - } - if( !m_overlayFolder.key().empty() && !SG::WriteCondHandle<DetectorSpecialPixelMap>(m_overlayKey, ctx).isValid() ) { - - DetectorSpecialPixelMap* overlay =nullptr; - DetectorSpecialPixelMap* maskoverlay=nullptr; - SG::ReadCondHandle<CondAttrListCollection> overlayfolder(m_overlayFolder, ctx); - std::vector<EventIDRange> overlayRanges; - EventIDRange r; - if(!overlayfolder.range(r)) { - ATH_MSG_ERROR("Failed to retrieve validity range for " << overlayfolder.key()); - return StatusCode::FAILURE; - } - overlayRanges.push_back(r); - ATH_CHECK(createFromDetectorStore(overlayfolder.retrieve(), !m_moduleLevelOverlay, overlay )); - - if(m_maskLayers) { - - ATH_CHECK(createMaskingOverlay(maskoverlay)); - SG::WriteCondHandle<DetectorSpecialPixelMap> writeh(m_maskingOverlayKey, ctx); - ATH_MSG_DEBUG("Record condition handle " << m_maskingOverlayKey.key() << " " << r); - ATH_CHECK(writeh.record(r, maskoverlay)); - ATH_CHECK(registerCondAttrListCollection(maskoverlay, spm, ctx, r)); - overlay->merge(maskoverlay); - - } - if( !m_overlayLongFolder.key().empty() ) { - DetectorSpecialPixelMap* overlaylong = nullptr; - SG::ReadCondHandle<CondAttrListCollection> overlayfolder(m_overlayLongFolder, ctx); - EventIDRange r; - if(!overlayfolder.range(r)) { - ATH_MSG_ERROR("Failed to retrieve validity range for " << overlayfolder.key()); - return StatusCode::FAILURE; - } - overlayRanges.push_back(r); - ATH_CHECK(createFromDetectorStore(overlayfolder.retrieve(), !m_moduleLevelOverlay, overlaylong)); - overlay->merge( overlaylong ); - } - - - - for(unsigned int i = 0; i < m_pixelID->wafer_hash_max(); i++) { - if( m_moduleLevelOverlay ) { - if( (*overlay)[i] != 0 ) { - *(*spm)[i] = *(*overlay)[i]; - } - } - else { - unsigned int moduleStatus = (*overlay)[i]->moduleStatus(); - if( moduleStatus != 0 ) { - (*spm)[i]->setModuleStatus(moduleStatus); - } - if( (*overlay)[i]->hasSpecialChips() ) { - for( unsigned int chip = 0; chip < (*overlay)[i]->chipsPerModule(); ++chip ) { - unsigned int chipStatus = (*overlay)[i]->chipStatus(chip); - if( chipStatus != 0 ) { - (*spm)[i]->setChipStatus(chip, chipStatus); - } - } - } - - if( (*overlay)[i]->hasSpecialColumnPairs() ) { - for( unsigned int chip = 0; chip < (*overlay)[i]->chipsPerModule(); ++chip ) { - if( (*overlay)[i]->hasSpecialColumnPairs(chip) ) { - for( unsigned int columnPair = 0; - columnPair < (*overlay)[i]->columnsPerChip() / 2; ++columnPair ) { - unsigned int columnPairStatus = (*overlay)[i]->columnPairStatus(chip, columnPair); - if( columnPairStatus != 0 ) { - (*spm)[i]->setColumnPairStatus(chip, columnPair, columnPairStatus); - } - } - } - } - } - - for(ModuleSpecialPixelMap::const_iterator pixel = (*overlay)[i]->begin(); - pixel != (*overlay)[i]->end(); ++pixel) { - (*spm)[i]->setPixelStatus(pixel->first, pixel->second); - } - } - } - - EventIDRange rangeIntersection; - if(overlayRanges.size() == 2) rangeIntersection = EventIDRange::intersect(overlayRanges[0], overlayRanges[1]); - else if (overlayRanges.size() == 1)rangeIntersection = overlayRanges[0]; - else ATH_MSG_ERROR("Logic error line " << __LINE__); - spmrange.insert(spmrange.end(), overlayRanges.begin(), overlayRanges.end()); - if(overlay){ - SG::WriteCondHandle<DetectorSpecialPixelMap> handleoverlay(m_overlayKey, ctx); - ATH_MSG_DEBUG("Record condition handle " << m_overlayKey.key() << " " << rangeIntersection); - ATH_CHECK(handleoverlay.record(rangeIntersection, overlay )); - } - } - - for(size_t i=1; i<N; i++) {//Write i>0 - if(newobject[i] ==false) continue; - SG::WriteCondHandle<DetectorSpecialPixelMap> spmhandle(*outarray[i], ctx); - ATH_MSG_DEBUG("Record condition handle " << outarray[i]->key() << " " << rangearray[i]); - ATH_CHECK(spmhandle.record(rangearray[i], ptrcache[i])); - } - //write i=0 - if(newobject[0]){ - SG::WriteCondHandle<DetectorSpecialPixelMap> spmhandle(*outarray[0], ctx); - EventIDRange spmIntersect = spmrange[0]; - for(size_t i = 1; i<spmrange.size(); i++) spmIntersect = EventIDRange::intersect(spmIntersect, spmrange[i]); - ATH_MSG_DEBUG("Record condition handle " << outarray[0]->key() << " " << spmIntersect); - ATH_CHECK(spmhandle.record(spmIntersect, spm)); - } - - return StatusCode::SUCCESS; -} - - -unsigned int SpecialPixelMapCondAlg::getChips(const unsigned int index) const { - unsigned int i =index; - std::unordered_map<unsigned int, unsigned int> ::const_iterator it= m_chips.find(i); - if(it !=m_chips.end()) return (*it).second; - ATH_MSG_ERROR( " Unable to retrieve the number of chips for module idhash "<<index); - return 0; -} - - -StatusCode SpecialPixelMapCondAlg::createFromDetectorStore(const CondAttrListCollection *attrListColl, - bool fillMissing, DetectorSpecialPixelMap*& cacheoutput) const { - - auto spm = std::make_unique< DetectorSpecialPixelMap>(); - spm->resize(m_pixelID->wafer_hash_max(),NULL); - - - - if( attrListColl == nullptr ) { - ATH_MSG_ERROR( "Unable to retrieve CondAttrListCollection," << " constructing empty DetectorSpecialPixelMap" ); - } - else { - ATH_MSG_DEBUG( "CondAttrListCollection retrieved" ); - - if( attrListColl->size() == 0 ) { - ATH_MSG_INFO( "CondAttrListCollection is empty," << " constructing empty DetectorSpecialPixelMap" ); - } - else { - - for(auto attrList = attrListColl->begin(); attrList != attrListColl->end(); ++attrList) { - - std::ostringstream attrStr; - (*attrList).second.toOutputStream(attrStr); - ATH_MSG_VERBOSE( "ChanNum " << (*attrList).first << " Attribute list " << attrStr.str() ); - - CondAttrListCollection::ChanNum chanNum = (*attrList).first; - CondAttrListCollection::iov_const_iterator iovIt = attrListColl->chanIOVPair(chanNum); - const IOVRange& range = (*iovIt).second; - - if(range.start().isTimestamp()) { - ATH_MSG_VERBOSE( "Range timestamp : from " << range.start().timestamp() << " until " << range.stop().timestamp() ); - } - else { - ATH_MSG_VERBOSE( "Range R/E : from " << range.start().run() << " " << range.start().event() << " until " << range.stop().run() << " " << range.stop().event() ); - } - - const unsigned int moduleID = static_cast<unsigned int>((*attrList).second["moduleID"].data<const int>()); - unsigned int idhash; - if (m_forceNewDBContent) idhash = IdentifierHash(moduleID); - else if(m_isIBL) { - if(m_dummy || IdentifierHash(moduleID)>m_pixelID->wafer_hash_max()) { - // continue (useful to transport the old DB to new DB with IBL!; - int component = static_cast<int>((moduleID & (3 << 25)) / 33554432) * 2 - 2; - unsigned int layer = (moduleID & (3 << 23)) / 8388608 ; - if(component==0)layer +=1; // shift layer - unsigned int phi = (moduleID & (63 << 17)) / 131072 ; - int eta = static_cast<int>((moduleID & (15 << 13)) / 8192) - 6 ; - Identifier id = m_pixelID->wafer_id( component, layer, phi, eta ); - idhash = m_pixelID->wafer_hash(id); - } - else { - idhash = IdentifierHash(moduleID); - } - } - else { - int component = static_cast<int>((moduleID & (3 << 25)) / 33554432) * 2 - 2; - unsigned int layer = (moduleID & (3 << 23)) / 8388608 ; - unsigned int phi = (moduleID & (63 << 17)) / 131072 ; - int eta = static_cast<int>((moduleID & (15 << 13)) / 8192) - 6 ; - Identifier id = m_pixelID->wafer_id( component, layer, phi, eta ); - idhash = m_pixelID->wafer_hash(id); - } - if( idhash < m_pixelID->wafer_hash_max()) { - - coral::AttributeList::const_iterator attribute = (*attrList).second.begin(); - ++attribute; - if( (*attribute).specification().typeName() == "blob" ) { - - const coral::Blob& blob = (*attrList).second["SpecialPixelMap"].data<const coral::Blob>(); - delete (*spm)[idhash]; //May not be necessary? - (*spm)[idhash] = new ModuleSpecialPixelMap(blob, getChips(idhash) ); - } - else { - - const std::string& clob = (*attrList).second["ModuleSpecialPixelMap_Clob"].data<const std::string>(); - delete (*spm)[idhash];//May not be necessary? - (*spm)[idhash] = new ModuleSpecialPixelMap(clob, getChips(idhash) ); - } - } - else { - ATH_MSG_FATAL( "Module hashID out of range: " << idhash ); - return StatusCode::FAILURE; - } - } - } - } - if( fillMissing ) { - for(unsigned int i = 0; i < m_pixelID->wafer_hash_max(); i++) { - if( (*spm)[i] == 0 ) { - (*spm)[i] = new ModuleSpecialPixelMap(); - (*spm)[i]->setchipsPerModule(getChips(i)); - } - } - } - cacheoutput = spm.release(); - - return StatusCode::SUCCESS; -} - - -StatusCode SpecialPixelMapCondAlg::createMaskingOverlay(DetectorSpecialPixelMap*& cacheptr) const { - - auto spm = std::make_unique< DetectorSpecialPixelMap >(); - - spm->resize(m_pixelID->wafer_hash_max()); - - if(m_condAttrListCollectionKeys.size() == 0) { - ATH_MSG_FATAL( "No database folder specified" ); - return StatusCode::FAILURE; - } - else if(m_condAttrListCollectionKeys.size() > 1) { - ATH_MSG_INFO( "Multiple database folders specified" ); - ATH_MSG_INFO( "Trying to store special pixel map at " - << m_condAttrListCollectionKeys[0] ); - } - int mk(0); - for(unsigned int i = 0; i < m_pixelID->wafer_hash_max(); i++) { - Identifier mID( m_pixelID->wafer_id(i) ); - (*spm)[i] = new ModuleSpecialPixelMap(); - (*spm)[i]->setchipsPerModule( getChips(i) ); - if ( - (m_pixelID->barrel_ec(mID) == 0 && (std::find(m_layersToMask.begin(), m_layersToMask.end(), m_pixelID->layer_disk(mID)) != m_layersToMask.end())) || - (m_pixelID->barrel_ec(mID) == 2 && (std::find(m_disksToMask.begin(), m_disksToMask.end(), (m_pixelID->layer_disk(mID) + 1)) != m_disksToMask.end())) || - (m_pixelID->barrel_ec(mID) == -2 && (std::find(m_disksToMask.begin(), m_disksToMask.end(), -1*(m_pixelID->layer_disk(mID) + 1)) != m_disksToMask.end())) - ) { - (*spm)[i]->setModuleStatus(1); - ATH_MSG_INFO( "List of modules killed "<<mk<<" hash "<<i<<" ["<<m_pixelID->barrel_ec(mID)<<","<< m_pixelID->layer_disk(mID)<<","<< - m_pixelID->phi_module(mID)<<","<<m_pixelID->eta_module(mID)<<"]"); - ++mk; - } - } - - cacheptr = spm.release(); - - return StatusCode::SUCCESS; -} - - - -StatusCode SpecialPixelMapCondAlg::registerCondAttrListCollection(const DetectorSpecialPixelMap* spm, - const DetectorSpecialPixelMap* referenceMap, const EventContext& ctx, const EventIDRange &r) const { - - coral::AttributeListSpecification* attrSpec = new coral::AttributeListSpecification();//memory leak? - - attrSpec->extend("moduleID", "int"); - - if( m_writeBlobs ) { - attrSpec->extend("SpecialPixelMap", "blob" ); - } - else { - attrSpec->extend("ModuleSpecialPixelMap_Clob", "string"); - } - - coral::AttributeListSpecification* attrSpecLong = new coral::AttributeListSpecification();//memory leak? - attrSpecLong->extend("moduleID", "int"); - attrSpecLong->extend("SpecialPixelMap", "blob" ); - - CondAttrListCollection* attrListColl = new CondAttrListCollection(true); - CondAttrListCollection* attrListCollLong = 0; - - if( m_useDualFolderStructure ) { - attrListCollLong = new CondAttrListCollection(true); - } - - CondAttrListCollection::ChanNum chanNum = 0; - - for(DetectorSpecialPixelMap::const_iterator moduleMap = spm->begin(); moduleMap != spm->end(); ++moduleMap) { - - ++chanNum; - - if( m_differentialUpdates && (*moduleMap)->to_string() == (*referenceMap)[moduleMap - spm->begin()]->to_string() ) { - continue; - } - - coral::AttributeList attrList(*attrSpec); - std::ostringstream attrStr; - - Identifier moduleID ( m_pixelID->wafer_id(moduleMap - spm->begin()) ); - - unsigned int hashID; - if(m_isIBL) { - hashID = m_pixelID->wafer_hash(moduleID); - } - else { - hashID = ( ((m_pixelID->barrel_ec(moduleID) + 2) / 2) << 25 ) + - ( m_pixelID->layer_disk(moduleID) << 23) + - ( m_pixelID->phi_module(moduleID) << 17) + - ( (m_pixelID->eta_module(moduleID) + 6) << 13); - } - - if( m_writeBlobs ) { - - coral::Blob* blob = (*moduleMap)->to_blob(); - - attrList["moduleID"].setValue( static_cast<int>( hashID ) ); - attrList["SpecialPixelMap"].setValue(*blob); - - if( msgLvl(MSG::DEBUG) ) { - attrList.toOutputStream(attrStr); - } - ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr.str() ); - - attrListColl->add(chanNum, attrList); - - delete blob; - } - else { - - std::string clob = (*moduleMap)->to_string(); - std::string referenceClob; - - if( m_useDualFolderStructure && m_differentialUpdates ) { - referenceClob = (*referenceMap)[moduleMap - spm->begin()]->to_string(); - } - - if( m_useDualFolderStructure && clob.size() > 3999 ) { - - coral::AttributeList attrListLong(*attrSpecLong); - - coral::Blob* blob = (*moduleMap)->to_blob(); - - attrListLong["moduleID"].setValue( static_cast<int>( hashID ) ); - attrListLong["SpecialPixelMap"].setValue(*blob); - - if( msgLvl(MSG::DEBUG) ) { - attrListLong.toOutputStream(attrStr); - } - ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr.str() ); - - attrListCollLong->add(chanNum, attrListLong); - - delete blob; - - ModuleSpecialPixelMap moduleMap; - clob = moduleMap.to_string(); - } - else if( m_useDualFolderStructure && referenceClob.size() > 3999 ) { - - coral::AttributeList attrListLong(*attrSpecLong); - - ModuleSpecialPixelMap moduleMap; - coral::Blob* blob = moduleMap.to_blob(); - - attrListLong["moduleID"].setValue( static_cast<int>( hashID ) ); - attrListLong["SpecialPixelMap"].setValue(*blob); - - if( msgLvl(MSG::DEBUG) ) { - attrListLong.toOutputStream(attrStr); - } - ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr.str() ); - - attrListCollLong->add(chanNum, attrListLong); - - delete blob; - } - - attrList["moduleID"].setValue( static_cast<int>( hashID ) ); - attrList["ModuleSpecialPixelMap_Clob"].setValue( clob ); - - if( msgLvl(MSG::DEBUG) ) { - attrList.toOutputStream(attrStr); - } - ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr.str() ); - - attrListColl->add(chanNum, attrList); - } - } - - if( m_useDualFolderStructure && attrListCollLong->size() == 0 ) { - - coral::AttributeList attrListLong(*attrSpecLong); - - coral::Blob* blob = 0; - - std::string referenceClob; - - if( m_differentialUpdates ) { - referenceClob = (*referenceMap)[0]->to_string(); - } - - if( m_differentialUpdates && referenceClob.size() > 3999 ) { - blob = (*referenceMap)[0]->to_blob(); - } - else { - ModuleSpecialPixelMap moduleMap; - blob = moduleMap.to_blob(); - } - - Identifier moduleID ( m_pixelID->wafer_id(0) ); - - unsigned int hashID; - if(m_isIBL) { - hashID = m_pixelID->wafer_hash(moduleID); - } - else { - hashID = ( ((m_pixelID->barrel_ec(moduleID) + 2) / 2) << 25 ) + - ( m_pixelID->layer_disk(moduleID) << 23) + - ( m_pixelID->phi_module(moduleID) << 17) + - ( (m_pixelID->eta_module(moduleID) + 6) << 13); - } - attrListLong["moduleID"].setValue( static_cast<int>( hashID ) ); - attrListLong["SpecialPixelMap"].setValue(*blob); - - attrListCollLong->add(1, attrListLong); - - delete blob; - } - - { - SG::WriteCondHandle<CondAttrListCollection> output(m_outputFolder, ctx); - ATH_MSG_DEBUG("Record condition handle " << m_outputFolder.key() << " " << r); - ATH_CHECK(output.record(r, attrListColl)); - } - if( m_useDualFolderStructure ) { - SG::WriteCondHandle<CondAttrListCollection> outputlong(m_outputLongFolder, ctx); - ATH_MSG_DEBUG("Record condition handle " << m_outputLongFolder.key() << " " << r); - ATH_CHECK(outputlong.record(r, attrListCollLong)); - } - - return StatusCode::SUCCESS; -} - - diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/SpecialPixelMapCondAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/SpecialPixelMapCondAlg.h deleted file mode 100644 index 02be8f33b188ae5768873de8540226be2fd140a2..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/SpecialPixelMapCondAlg.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef SPECIAL_PIXEL_MAPCONDALG_H -#define SPECIAL_PIXEL_MAPCONDALG_H - -#include "AthenaBaseComps/AthReentrantAlgorithm.h" -#include <vector> -#include <string> -#include "StoreGate/ReadCondHandleKey.h" -#include "AthenaPoolUtilities/CondAttrListCollection.h" -#include "PixelConditionsData/SpecialPixelMap.h" -#include "GaudiKernel/ICondSvc.h" - -class PixelID; -class IGeoModelSvc; - -class SpecialPixelMapCondAlg: public AthReentrantAlgorithm { - - public: - SpecialPixelMapCondAlg (const std::string& name, ISvcLocator* pSvcLocator); - ~SpecialPixelMapCondAlg(); - - virtual StatusCode initialize() override; - virtual StatusCode execute (const EventContext&) const override; - - -private: - unsigned int getChips(const unsigned int index) const; - StatusCode createFromDetectorStore(const CondAttrListCollection*, - bool fillMissing, DetectorSpecialPixelMap*& ) const; - - StatusCode createMaskingOverlay(DetectorSpecialPixelMap*&) const; - StatusCode registerCondAttrListCollection(const DetectorSpecialPixelMap* , - const DetectorSpecialPixelMap* , const EventContext&, const EventIDRange &r ) const; - - const PixelID* m_pixelID; - Gaudi::Property<bool> m_forceNewDBContent{this, "ForceNewDBContent", false}; - Gaudi::Property<bool> m_dummy{this, "MakingDummyMaps", false}; - Gaudi::Property<bool> m_isIBL{this, "isIBL", false}; - Gaudi::Property<bool> m_mergePixelMaps{this, "MergePixelMaps", true}; - Gaudi::Property<bool> m_moduleLevelOverlay{this, "ModuleLevelOverlay", false}; - Gaudi::Property<bool> m_maskLayers{this, "MaskLayers", false, "Mask full layers/disks in overlay"}; - Gaudi::Property<bool> m_differentialUpdates{"DifferentialUpdates", false, "Switch for differential updates"}; - Gaudi::Property<bool> m_useDualFolderStructure{"UseDualFolderStructure", false, - "Use dual folder structure when creating a CondAttrListCollection"}; - Gaudi::Property<bool> m_writeBlobs{"WriteBlobs", false, "Switch between blob and clob writing"}; - - Gaudi::Property<std::vector<std::string>> m_condAttrListCollectionKeys{this, "DBFolders", { }, "list of database folders to be accessed" }; - Gaudi::Property<std::vector<std::string>> m_specialPixelMapKeys{this, "SpecialPixelMapKeys", {}, "StoreGate keys at which pixel maps are to be stored" }; - SG::ReadCondHandleKey<CondAttrListCollection> m_overlayFolder{this, "OverlayFolder", ""}; - SG::WriteCondHandleKey<DetectorSpecialPixelMap> m_overlayKey{this , "OverlayKey", "PixMapOverlay"}; - SG::WriteCondHandleKey<DetectorSpecialPixelMap> m_maskingOverlayKey{this , "MaskingOverlayKey", "MaskingOverlay"}; - - SG::WriteCondHandleKey<CondAttrListCollection> m_outputFolder{this, "OutputFolder", "", "Name of output folder"}; - SG::WriteCondHandleKey<CondAttrListCollection> m_outputLongFolder{this, "OutputLongFolder", "", "Name of output folder for long maps"}; - - ServiceHandle< IGeoModelSvc > m_geoModelSvc; - std::unordered_map<unsigned int, unsigned int> m_chips; - SG::ReadCondHandleKey<CondAttrListCollection> m_ConAttrList1{this, "ConAttrList1", ""}; - SG::ReadCondHandleKey<CondAttrListCollection> m_ConAttrList2{this, "ConAttrList2", ""}; - SG::ReadCondHandleKey<CondAttrListCollection> m_ConAttrList3{this, "ConAttrList3", ""}; - SG::ReadCondHandleKey<CondAttrListCollection> m_ConAttrList4{this, "ConAttrList4", ""}; - - SG::WriteCondHandleKey<DetectorSpecialPixelMap> m_pixmap1{this , "PixelMap1", ""}; - SG::WriteCondHandleKey<DetectorSpecialPixelMap> m_pixmap2{this , "PixelMap2", ""}; - SG::WriteCondHandleKey<DetectorSpecialPixelMap> m_pixmap3{this , "PixelMap3", ""}; - SG::WriteCondHandleKey<DetectorSpecialPixelMap> m_pixmap4{this , "PixelMap4", ""}; - - SG::ReadCondHandleKey<CondAttrListCollection> m_overlayLongFolder{this , "OverlayLongFolder", "", "Name of long overlay DB folder"}; - SG::WriteCondHandleKey<DetectorSpecialPixelMap> m_overlayLongKey{this , "OverlayLongKey", "PixMapOverlayLong", "StoreGate key for long overlay map"}; - - Gaudi::Property<std::vector<int>> m_layersToMask{this, "LayersToMask", {}, "Which barrel layers to mask out, goes from 0 to N-1"}; - Gaudi::Property<std::vector<int>> m_disksToMask{this, "DisksToMask", {}, "Which endcap disks to mask out, goes from -N+1 to N+1 , skipping zero"}; - ServiceHandle<ICondSvc> m_condSvc; -}; - - -#endif - diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/components/PixelConditionsAlgorithms_entries.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/components/PixelConditionsAlgorithms_entries.cxx index e79e48568ec1ff512ba0bf9b2c8aea252278847d..fba7c05c8ecb2339354f4e14adbf75dff901e36a 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/components/PixelConditionsAlgorithms_entries.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/components/PixelConditionsAlgorithms_entries.cxx @@ -5,8 +5,10 @@ #include "../PixelChargeCalibCondAlg.h" #include "../PixelTDAQCondAlg.h" #include "../PixelSiliconConditionsTestAlg.h" -#include "../SpecialPixelMapCondAlg.h" #include "../PixelOfflineCalibCondAlg.h" +#include "../PixelReadoutSpeedAlg.h" +#include "../PixelCablingCondAlg.h" +#include "../PixelHitDiscCnfgAlg.h" #include "../PixelAlignCondAlg.h" #include "../PixelDetectorElementCondAlg.h" @@ -17,7 +19,9 @@ DECLARE_COMPONENT( PixelConfigCondAlg ) DECLARE_COMPONENT( PixelChargeCalibCondAlg ) DECLARE_COMPONENT( PixelTDAQCondAlg ) DECLARE_COMPONENT( PixelSiliconConditionsTestAlg ) -DECLARE_COMPONENT( SpecialPixelMapCondAlg ) DECLARE_COMPONENT( PixelOfflineCalibCondAlg ) +DECLARE_COMPONENT( PixelReadoutSpeedAlg ) +DECLARE_COMPONENT( PixelCablingCondAlg ) +DECLARE_COMPONENT( PixelHitDiscCnfgAlg ) DECLARE_COMPONENT( PixelAlignCondAlg ) DECLARE_COMPONENT( PixelDetectorElementCondAlg ) diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelCablingCondData.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelCablingCondData.h new file mode 100755 index 0000000000000000000000000000000000000000..3883bed048021025065855e00dadf7eafe90b1db --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelCablingCondData.h @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PIXELCABLINGCONDDATA_H +#define PIXELCABLINGCONDDATA_H + +//#define PIXEL_DEBUG +#include "AthenaKernel/CLASS_DEF.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" + +#include "Identifier/Identifier.h" +#include <map> +#include <deque> +#include <stdint.h> +#include <utility> +#include <string> +#include <unordered_map> + +struct idHasher { + std::size_t operator()(const Identifier& id) const { + return std::hash<Identifier::value_type>{}(id.get_compact()); + } +}; + +class PixelCablingCondData { + public: + PixelCablingCondData(); + virtual ~PixelCablingCondData(); + PixelCablingCondData(const PixelCablingCondData &other) = delete; + PixelCablingCondData& operator= (const PixelCablingCondData &other) = delete; + + void add_entry_onoff(const uint64_t, const Identifier); // add entries to m_idMap_onoff + void add_entry_offon(const Identifier, const uint64_t); // add entries in m_idMap_offon + void add_entry_offrob(const Identifier, const uint32_t); // add entries in m_idMap_offrob + void add_entry_rodrob(int rodid, int robid); // add entries in m_idMap_rodrob + void add_entry_robrod(int robid, int rodid); + void add_entry_offlineList(const uint32_t, const Identifier); // add entries in m_offlineListVect + void add_entry_DCSoffline(std::string, const Identifier); // add entries in m_offlineListVect + + Identifier find_entry_onoff(const uint64_t) const; // search entry in the map m_idMap_onoff - get the offlineId from the onlineId + uint64_t find_entry_offon(const Identifier) const; // search entry in the map m_idMap_offon - get the onlineId from the offlineId + uint32_t find_entry_offrob(Identifier offlineId) const; // search entry in the map m_idMap_offrob - get the ROBId from the offlineId + int find_entry_rodrob(const int rodid) const; + int find_entry_robrod(const int robid) const; + std::deque<Identifier> find_entry_offlineList(uint32_t robid) const; // return entries from m_offlineListVect for a ROBId + Identifier find_entry_DCSoffline(std::string DCSname) const; + std::string find_entry_offlineDCS(const Identifier offlineId) const; + uint64_t getOnlineIdFromRobId(uint32_t robid, uint32_t link) const; + + std::vector<uint32_t>& get_allRods() const; + std::vector<uint32_t>& get_allRobs() const; + + unsigned int get_size_onoff() {return m_idMap_onoff.size();} + + void set_readout_map(std::map<uint32_t,bool> rodReadoutMap); + + std::unordered_map<uint64_t, Identifier> get_idMap_onoff() const; + std::unordered_map<Identifier, uint64_t, idHasher> get_idMap_offon() const; + std::unordered_map<Identifier, uint32_t, idHasher> get_idMap_offrob() const; + std::unordered_map<int,int> get_idMap_rodrob() const; + std::unordered_map<int,int> get_idMap_robrod() const; + std::unordered_map<std::string, Identifier> get_idMapDCSoff() const; + + void clear(); + + private: + + std::unordered_map<uint64_t, Identifier> m_idMap_onoff; ///< offline identifier -> online identifier map + std::unordered_map<Identifier, uint64_t, idHasher> m_idMap_offon; ///< online identifier -> offline identifier map + std::unordered_map<Identifier, uint32_t, idHasher> m_idMap_offrob; ///< offline identifier -> ROBId map + std::unordered_map<int,int> m_idMap_rodrob; ///< RODId -> ROBId map + std::unordered_map<int,int> m_idMap_robrod; ///< ROBId -> RODId map (reverse of m_idMap_rodrob) + std::map<uint32_t, std::deque<Identifier> > m_offlineListVect; ///< ROBId -> offline identifier list + std::unordered_map<std::string, Identifier> m_idMapDCSoff; ///< DCS name -> offline identifier + std::map<uint32_t,bool> m_rodReadoutMap; ///< Readout speed for each ROD. false=40MBit, true=80MBit + + std::vector<uint32_t>* m_allRods; // vector containing all RODs in the m_idMap_rodrob + std::vector<uint32_t>* m_allRobs; // vector containing all ROBs +}; + +CLASS_DEF( PixelCablingCondData , 107566278 , 1 ) // class definition with CLID + +#include "AthenaKernel/CondCont.h" +CONDCONT_DEF( PixelCablingCondData, 107566279 ); + +#endif diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelHitDiscCnfgData.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelHitDiscCnfgData.h new file mode 100755 index 0000000000000000000000000000000000000000..b0d1bb7c7abac3bfff4368ebbe9299e5267a1790 --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelHitDiscCnfgData.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PIXELHITDISCCONFIGDATA_H +#define PIXELHITDISCCONFIGDATA_H + +#include "AthenaKernel/CLASS_DEF.h" +#include <map> + +class PixelHitDiscCnfgData { + public: + PixelHitDiscCnfgData(); + virtual ~PixelHitDiscCnfgData(); + PixelHitDiscCnfgData(const PixelHitDiscCnfgData &other) = delete; + PixelHitDiscCnfgData& operator= (const PixelHitDiscCnfgData &other) = delete; + + void setHitDiscCnfgPL(int hitDiscCnfgPL); + void setHitDiscCnfg3D(int hitDiscCnfg3D); + int getHitDiscCnfgPL() const; + int getHitDiscCnfg3D() const; + + private: + int m_hitDiscCnfgPL; + int m_hitDiscCnfg3D; +}; + +CLASS_DEF( PixelHitDiscCnfgData , 107567218 , 1 ) // class definition with CLID + +#include "AthenaKernel/CondCont.h" +CONDCONT_DEF( PixelHitDiscCnfgData, 107567619 ); + +#endif diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelReadoutSpeedData.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelReadoutSpeedData.h new file mode 100755 index 0000000000000000000000000000000000000000..02629133d8ffc352e76ee53f9377066084b7865e --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelReadoutSpeedData.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PIXELREADOUTSPEEDDATA_H +#define PIXELREADOUTSPEEDDATA_H + +//#define PIXEL_DEBUG +#include "AthenaKernel/CLASS_DEF.h" +#include <map> + +class PixelReadoutSpeedData { + public: + PixelReadoutSpeedData(); + virtual ~PixelReadoutSpeedData(); + PixelReadoutSpeedData(const PixelReadoutSpeedData &other) = delete; + PixelReadoutSpeedData& operator= (const PixelReadoutSpeedData &other) = delete; + + void setReadoutMap(std::map<uint32_t,bool> rodReadoutMap); + std::map<uint32_t,bool> getReadoutMap() const; + + void clear(); + + private: + std::map<uint32_t,bool> m_rodReadoutMap; ///< Readout speed for each ROD. false=40MBit, true=80MBit +}; + +inline void PixelReadoutSpeedData::setReadoutMap(std::map<uint32_t,bool> rodReadoutMap) { m_rodReadoutMap=rodReadoutMap; } + +inline std::map<uint32_t,bool> PixelReadoutSpeedData::getReadoutMap() const { return m_rodReadoutMap; } + +CLASS_DEF( PixelReadoutSpeedData , 107567278 , 1 ) // class definition with CLID + +#include "AthenaKernel/CondCont.h" +CONDCONT_DEF( PixelReadoutSpeedData, 107567679 ); + +#endif diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelCablingCondData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelCablingCondData.cxx new file mode 100755 index 0000000000000000000000000000000000000000..0210668b8d71192b47a8848115238740333502aa --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelCablingCondData.cxx @@ -0,0 +1,242 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PixelConditionsData/PixelCablingCondData.h" +#include "Identifier/Identifier.h" +#include <iostream> +#include <fstream> +#include <sstream> + +PixelCablingCondData::PixelCablingCondData(): + m_idMap_onoff(), + m_idMap_offon(), + m_idMap_offrob(), + m_idMap_rodrob(), + m_idMap_robrod(), + m_offlineListVect(), + m_idMapDCSoff(), + m_rodReadoutMap(), + m_allRods(), + m_allRobs() +{ + m_allRods = new std::vector<uint32_t>; + m_allRobs = new std::vector<uint32_t>; +} + +PixelCablingCondData::~PixelCablingCondData() { } + +void PixelCablingCondData::add_entry_onoff(const uint64_t onlineId, const Identifier offlineId) { + m_idMap_onoff.insert(std::make_pair(onlineId, offlineId)); // add online identifier -> offline identifier pair in m_idMap_onoff +} + +void PixelCablingCondData::add_entry_offon(const Identifier offlineId, const uint64_t onlineId) { + m_idMap_offon.insert(std::make_pair(offlineId, onlineId)); // add offline identifier -> online identifier pair in m_idMap_offon +} + +void PixelCablingCondData::add_entry_offrob(const Identifier offlineId, const uint32_t robid) { + m_idMap_offrob.insert(std::make_pair(offlineId, robid)); // add offline identifier -> offline ROBId pair in m_idMap_offrob +} + +void PixelCablingCondData::add_entry_rodrob(int rodid, int robid) { + m_idMap_rodrob.insert(std::make_pair(rodid, robid)); // add RODId identifier -> offline ROBId pair in m_idMap_rodrob +} + +void PixelCablingCondData::add_entry_robrod(int robid, int rodid) { + m_idMap_robrod.insert(std::make_pair(robid, rodid)); +} + +void PixelCablingCondData::add_entry_offlineList(const uint32_t robid, const Identifier offlineId) { + m_offlineListVect[robid].push_back(offlineId); // add ROBid -> offline identifier pair in m_offlineListVect +} + +void PixelCablingCondData::add_entry_DCSoffline(std::string DCSname, const Identifier offlineId) { + m_idMapDCSoff.insert(std::make_pair(DCSname, offlineId)); +} + +void PixelCablingCondData::set_readout_map(std::map<uint32_t, bool> rodReadoutMap) { + m_rodReadoutMap = rodReadoutMap; +} + +Identifier PixelCablingCondData::find_entry_onoff(const uint64_t onlineId) const { + // Search m_idMap_onoff for the onlineId + uint64_t searchId = onlineId; + Identifier offlineId(0); + std::unordered_map<uint64_t, Identifier>::const_iterator iter(m_idMap_onoff.find(searchId)); + + // OnlineId has been found - get the offline identifier + if (iter != m_idMap_onoff.end()) offlineId = (*iter).second; + + // Is onlineId not found? Then check if this is a b-layer module; if it is read out at + // 80 Mbit, search again with link = 0, since FMT has enough info to identify the module + else { + uint32_t rodid = (onlineId & 0xFFFFFF); // last 24 bit are rodid + + if ((rodid & 0x130000) >> 16 == 0x13) { + std::map<uint32_t, bool>::const_iterator it = m_rodReadoutMap.find(rodid); + + if (it != m_rodReadoutMap.end()) { + if ((*it).second == true) { // true = is 80 MBit + + // Search again + searchId = onlineId & (0xF0FFFFFF); + iter = m_idMap_onoff.find(searchId); + + // Get identifier + if (iter != m_idMap_onoff.end()) offlineId = (*iter).second; + } + } + } + // If onlineId is still not found, the empty identifier is returned. + } + return offlineId; +} + +uint64_t PixelCablingCondData::find_entry_offon(const Identifier offlineId) const { + uint64_t onlineId; // declare online identifier + std::unordered_map<Identifier, uint64_t, idHasher>::const_iterator iter(m_idMap_offon.find(offlineId)); // find offline identifier in m_idMap_offon map + if (iter == m_idMap_offon.end()) { // if offline identifier not found in m_idMap_offon map -> ERROR + onlineId = 0; // fill online identifier with empty identifier + return onlineId; // return empty online identifier + } + onlineId = (*iter).second; // fill online identifier with found online identifier + return onlineId; // return found online identifier +} + +uint32_t PixelCablingCondData::find_entry_offrob(Identifier offlineId) const { + uint32_t robid; // declare ROBId + std::unordered_map<Identifier, uint32_t, idHasher>::const_iterator iter(m_idMap_offrob.find(offlineId)); // find offline identifier in m_idMap_offrob map + if (iter == m_idMap_offrob.end()) { // if offline identifier not found in m_idMap_offrob map -> ERROR + robid = 0; // fill ROBId with empty identifier + return robid; // return empty ROBId + } + robid = (*iter).second; // fill ROBId with found ROBId + return robid; // return found ROBId +} + +int PixelCablingCondData::find_entry_rodrob(const int rodid) const { + std::unordered_map<int, int>::const_iterator iter(m_idMap_rodrob.find(rodid)); + if (iter == m_idMap_rodrob.end()) { + return 0; + } + int robid = iter->second; + return robid; +} + +int PixelCablingCondData::find_entry_robrod(const int robid) const { + std::unordered_map<int,int>::const_iterator iter(m_idMap_robrod.find(robid)); + if (iter == m_idMap_robrod.end()) return 0; + return iter->second; +} + +std::deque<Identifier> PixelCablingCondData::find_entry_offlineList(uint32_t robid) const { + std::deque<Identifier> offlineId; // declare collection identifier list for the ROBId + std::deque<Identifier>::const_iterator it1 = m_offlineListVect.at(robid).begin(); // first offline identifier for the ROBId + std::deque<Identifier>::const_iterator it2 = m_offlineListVect.at(robid).end(); // last offline identifier for the ROBId + for (; it1 != it2; ++it1) { // loop thrue offline identifiers + offlineId.push_back(*it1); // fill offline identifier into offline identifier list + } + return offlineId; // return the offline identifier list for the ROBId +} + +Identifier PixelCablingCondData::find_entry_DCSoffline(std::string DCSname) const { + std::unordered_map<std::string, Identifier>::const_iterator iter(m_idMapDCSoff.find(DCSname)); + if (iter == m_idMapDCSoff.end()) { + Identifier offlineId(0); + return offlineId; + } + return iter->second; +} + +std::string PixelCablingCondData::find_entry_offlineDCS(const Identifier offlineId) const { + std::unordered_map<std::string, Identifier>::const_iterator iter = m_idMapDCSoff.begin(); + for (; iter != m_idMapDCSoff.end(); iter++) { + if (iter->second == offlineId) + return iter->first; + } + return ""; // not found +} + +std::vector<uint32_t>& PixelCablingCondData::get_allRods() const { + if (m_allRods->empty()) { // fill vector from map only once + for (std::unordered_map<int, int>::const_iterator rodrobmap_iterator = m_idMap_rodrob.begin(); rodrobmap_iterator != m_idMap_rodrob.end(); rodrobmap_iterator++) + m_allRods->push_back(rodrobmap_iterator->first); + } + return *m_allRods; +} + +std::vector<uint32_t>& PixelCablingCondData::get_allRobs() const { + if (m_allRobs->empty()) { + for (std::unordered_map<int,int>::const_iterator robrod_iter = m_idMap_robrod.begin(); robrod_iter != m_idMap_robrod.end(); robrod_iter++) { + m_allRobs->push_back(robrod_iter->first); + } + } + return *m_allRobs; +} + +//////////////////////// +// getOnlineIdFromRobId - returns the onlineId from the robId and the link number +// onlineId convention: onlineId is constructed as 0xAABBDDMMMM, where MMMM = robId, +// DD = subdetector id, AABB = link number. +// For pixels, there is only one link number per onlineId, so AA = 00. +//////////////////////// +uint64_t PixelCablingCondData::getOnlineIdFromRobId(uint32_t robid, uint32_t link) const { + uint32_t subDetId = (robid & 0xFFFFFF) >> 16; + + // Pixels: + if (subDetId < 0x14) return (robid & 0xFFFFFF) | (link << 24); + + // IBL / DBM: + else if (subDetId == 0x14 || subDetId == 0x15) { + + // Need to search the on-off map for the appropriate onlineId + uint32_t linknum_temp; + std::unordered_map<uint64_t, Identifier>::const_iterator itr = m_idMap_onoff.begin(); + for (; itr != m_idMap_onoff.end(); ++itr) { + if ((itr->first & 0xFFFFFF) == robid) { + linknum_temp = (itr->first >> 24); + // Check for linknum in both first and third nibble + if ((linknum_temp & 0xF) == link || ((linknum_temp >> 8) & 0xF) == link) return itr->first; + } + } + } + return 0; +} + +std::unordered_map<uint64_t, Identifier> PixelCablingCondData::get_idMap_onoff() const { + return m_idMap_onoff; +} + +std::unordered_map<Identifier, uint64_t, idHasher> PixelCablingCondData::get_idMap_offon() const { + return m_idMap_offon; +} + +std::unordered_map<Identifier, uint32_t, idHasher> PixelCablingCondData::get_idMap_offrob() const { + return m_idMap_offrob; +} + +std::unordered_map<int,int> PixelCablingCondData::get_idMap_rodrob() const { + return m_idMap_rodrob; +} + +std::unordered_map<int,int> PixelCablingCondData::get_idMap_robrod() const { + return m_idMap_robrod; +} + +std::unordered_map<std::string, Identifier> PixelCablingCondData::get_idMapDCSoff() const { + return m_idMapDCSoff; +} + +void PixelCablingCondData::clear() { + m_idMap_onoff.clear(); + m_idMap_offon.clear(); + m_idMap_offrob.clear(); + m_idMap_rodrob.clear(); + m_idMap_robrod.clear(); + m_offlineListVect.clear(); + m_idMapDCSoff.clear(); + m_rodReadoutMap.clear(); + m_allRods->clear(); + m_allRobs->clear(); +} + diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelHitDiscCnfgData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelHitDiscCnfgData.cxx new file mode 100755 index 0000000000000000000000000000000000000000..6634e8805b356a4e3032330c5e17b2bb94235927 --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelHitDiscCnfgData.cxx @@ -0,0 +1,17 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PixelConditionsData/PixelHitDiscCnfgData.h" + +PixelHitDiscCnfgData::PixelHitDiscCnfgData() +{ +} + +PixelHitDiscCnfgData::~PixelHitDiscCnfgData() { } + +void PixelHitDiscCnfgData::setHitDiscCnfgPL(int hitDiscCnfgPL) { m_hitDiscCnfgPL=hitDiscCnfgPL; } +void PixelHitDiscCnfgData::setHitDiscCnfg3D(int hitDiscCnfg3D) { m_hitDiscCnfg3D=hitDiscCnfg3D; } +int PixelHitDiscCnfgData::getHitDiscCnfgPL() const { return m_hitDiscCnfgPL; } +int PixelHitDiscCnfgData::getHitDiscCnfg3D() const { return m_hitDiscCnfg3D; } + diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelReadoutSpeedData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelReadoutSpeedData.cxx new file mode 100755 index 0000000000000000000000000000000000000000..afac4ca3a4c770eab2c35067a1a92ab42d007066 --- /dev/null +++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelReadoutSpeedData.cxx @@ -0,0 +1,17 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PixelConditionsData/PixelReadoutSpeedData.h" + +PixelReadoutSpeedData::PixelReadoutSpeedData(): + m_rodReadoutMap() +{ +} + +PixelReadoutSpeedData::~PixelReadoutSpeedData() { } + +void PixelReadoutSpeedData::clear() { + m_rodReadoutMap.clear(); +} + diff --git a/InnerDetector/InDetDetDescr/InDetRegionSelector/CMakeLists.txt b/InnerDetector/InDetDetDescr/InDetRegionSelector/CMakeLists.txt index dc73f8fd0e77ff4e1231e4796d00c641df9a25e8..a50d5d77681ca814ae508157938a8a50079cb7a1 100644 --- a/InnerDetector/InDetDetDescr/InDetRegionSelector/CMakeLists.txt +++ b/InnerDetector/InDetDetDescr/InDetRegionSelector/CMakeLists.txt @@ -10,7 +10,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps DetectorDescription/RegSelLUT GaudiKernel - InnerDetector/InDetDetDescr/PixelCabling + InnerDetector/InDetConditions/PixelConditionsData InnerDetector/InDetDetDescr/SCT_Cabling PRIVATE DetectorDescription/Identifier @@ -27,7 +27,7 @@ atlas_add_component( InDetRegionSelector src/*.cxx src/components/*.cxx INCLUDE_DIRS ${TDAQ-COMMON_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${TDAQ-COMMON_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps RegSelLUT GaudiKernel SCT_CablingLib Identifier InDetIdentifier InDetReadoutGeometry ) + LINK_LIBRARIES ${TDAQ-COMMON_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps RegSelLUT GaudiKernel PixelConditionsData SCT_CablingLib Identifier InDetIdentifier InDetReadoutGeometry ) # Install files from the package: atlas_install_headers( InDetRegionSelector ) diff --git a/InnerDetector/InDetDetDescr/InDetRegionSelector/InDetRegionSelector/SiRegionSelectorTable.h b/InnerDetector/InDetDetDescr/InDetRegionSelector/InDetRegionSelector/SiRegionSelectorTable.h index a56457bcc235f3eb4592b741ae951a6f6eaf76df..ab1d346ae0433ba9dd0ee2b9f78375b3ed27220c 100755 --- a/InnerDetector/InDetDetDescr/InDetRegionSelector/InDetRegionSelector/SiRegionSelectorTable.h +++ b/InnerDetector/InDetDetDescr/InDetRegionSelector/InDetRegionSelector/SiRegionSelectorTable.h @@ -8,11 +8,12 @@ #include "RegSelLUT/IRegionIDLUT_Creator.h" #include "AthenaBaseComps/AthAlgTool.h" -#include "PixelCabling/IPixelCablingSvc.h" #include "SCT_Cabling/ISCT_CablingTool.h" #include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/ServiceHandle.h" + +#include "PixelConditionsData/PixelCablingCondData.h" +#include "StoreGate/ReadCondHandleKey.h" #include <string> @@ -47,9 +48,11 @@ private: bool m_noDBM; // cablings - ServiceHandle<IPixelCablingSvc> m_pixIdMapping; ToolHandle<ISCT_CablingTool> m_sctCablingToolInc; // This class accesses SCT cabling during initialization. + SG::ReadCondHandleKey<PixelCablingCondData> m_condCablingKey + {this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"}; + }; #endif // InDetRegionSelector_SiRegionSelectorTable_h diff --git a/InnerDetector/InDetDetDescr/InDetRegionSelector/src/SiRegionSelectorTable.cxx b/InnerDetector/InDetDetDescr/InDetRegionSelector/src/SiRegionSelectorTable.cxx index c465d725fc5e583abb19a687cbaa884e89edcf97..8665f221c815e23897067c76b5269b374be6e51b 100755 --- a/InnerDetector/InDetDetDescr/InDetRegionSelector/src/SiRegionSelectorTable.cxx +++ b/InnerDetector/InDetDetDescr/InDetRegionSelector/src/SiRegionSelectorTable.cxx @@ -39,7 +39,6 @@ SiRegionSelectorTable::SiRegionSelectorTable(const std::string& type, m_printHashId(true), m_printTable(false), m_noDBM(true), - m_pixIdMapping("PixelCablingSvc", name), m_sctCablingToolInc("SCT_CablingToolInc") { declareInterface<IRegionIDLUT_Creator>(this); @@ -75,10 +74,12 @@ SiRegionSelectorTable::initialize(){ return StatusCode::FAILURE; } - StatusCode sc; + ATH_CHECK(m_condCablingKey.initialize()); - sc = createTable(); - return sc; + ATH_MSG_WARNING("So far, this prevents the conditions migration!! The createTable() should NOT be used in the initilization step..."); + ATH_CHECK(createTable()); + + return StatusCode::SUCCESS; } @@ -120,12 +121,7 @@ SiRegionSelectorTable::createTable() if ( msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << "Manager found" << endmsg; } - if (manager->isPixel()) { - if (m_pixIdMapping.retrieve().isFailure()) { - msg(MSG::ERROR) << "Can't get the Pixel Mapping tool." << endmsg; - return StatusCode::FAILURE; - } - } else { // SCT + if (!manager->isPixel()) { // SCT if (m_sctCablingToolInc.retrieve().isFailure()) { msg(MSG::ERROR) << "Can't get the SCT_CablingToolInc." << endmsg; return StatusCode::FAILURE; @@ -141,6 +137,8 @@ SiRegionSelectorTable::createTable() else rd = new RegSelSiLUT(RegSelSiLUT::SCT); + SG::ReadCondHandle<PixelCablingCondData> pixCabling(m_condCablingKey); + SiDetectorElementCollection::const_iterator iter; for (iter = manager->getDetectorElementBegin(); iter != manager->getDetectorElementEnd(); ++iter){ @@ -176,7 +174,7 @@ SiRegionSelectorTable::createTable() if ( m_noDBM && std::fabs(barrelEC)>3 ) continue; // skip DBM modules layerDisk = pixelId->layer_disk(element->identify()); - robId=m_pixIdMapping->getRobID(element->identify()); + robId=pixCabling->find_entry_offrob(element->identify()); } else { msg(MSG::ERROR) << " could not get PixelID for " << element->getIdHelper() << endmsg; diff --git a/InnerDetector/InDetDetDescr/PixelCabling/CMakeLists.txt b/InnerDetector/InDetDetDescr/PixelCabling/CMakeLists.txt index 82ad87731a51e3bd506d42fb1da7f1e9c19332b3..93567dd19195c6137af2423ba34ee4ce0fb1ceaa 100644 --- a/InnerDetector/InDetDetDescr/PixelCabling/CMakeLists.txt +++ b/InnerDetector/InDetDetDescr/PixelCabling/CMakeLists.txt @@ -17,11 +17,12 @@ atlas_depends_on_subdirs( DetectorDescription/Identifier InnerDetector/InDetDetDescr/InDetReadoutGeometry InnerDetector/InDetDetDescr/InDetIdentifier + InnerDetector/InDetConditions/PixelConditionsData Tools/PathResolver ) # External dependencies: find_package( Boost ) -find_package( CORAL COMPONENTS CoralBase ) +find_package( COMPONENTS ) find_package( tdaq-common ) # Component(s) in the package: @@ -33,11 +34,11 @@ atlas_add_library( PixelCablingLib atlas_add_component( PixelCabling src/*.h src/*.cxx src/components/*.cxx - INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${TDAQ-COMMON_INCLUDE_DIRS} - LINK_LIBRARIES ${CORAL_LIBRARIES} ${Boost_LIBRARIES} - ${TDAQ-COMMON_LIBRARIES} GaudiKernel AthenaBaseComps AthenaKernel StoreGateLib - AthenaPoolUtilities Identifier InDetIdentifier InDetReadoutGeometry PathResolver PixelCablingLib ) + LINK_LIBRARIES ${Boost_LIBRARIES} + ${TDAQ-COMMON_LIBRARIES} GaudiKernel AthenaBaseComps SGTools StoreGateLib + AthenaPoolUtilities Identifier InDetIdentifier InDetReadoutGeometry PixelConditionsData PathResolver PixelCablingLib ) atlas_add_test( PixelCablingConfigNew_test SCRIPT test/PixelCablingConfigNew_test.py diff --git a/InnerDetector/InDetDetDescr/PixelCabling/PixelCabling/IPixelCablingSvc.h b/InnerDetector/InDetDetDescr/PixelCabling/PixelCabling/IPixelCablingSvc.h index 4ea5208222be48c8fe6599ccb3c4bb637ecafd81..17e5a6f9b554ef34f0d5b5530c36e9b1a8ceb136 100644 --- a/InnerDetector/InDetDetDescr/PixelCabling/PixelCabling/IPixelCablingSvc.h +++ b/InnerDetector/InDetDetDescr/PixelCabling/PixelCabling/IPixelCablingSvc.h @@ -1,104 +1,35 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ - -/////////////////////////////////////////////////////////////////// -// Interface for cabling service -/////////////////////////////////////////////////////////////////// -// Florian Hirsch -/////////////////////////////////////////////////////////////////// - #ifndef IPIXELCABLINGSVC_H #define IPIXELCABLINGSVC_H #include "GaudiKernel/IInterface.h" -#include "AthenaKernel/IOVSvcDefs.h" - -#include <deque> -#include <vector> -#include <map> - -// forward declarations -class IdentifierHash; -class Identifier; +#include "Identifier/Identifier.h" +#include "InDetIdentifier/PixelID.h" -/** Interface class for PixelCablingSvc - * See PixelCablingSvc.h for further documentation - */ class IPixelCablingSvc: virtual public IInterface { public: - - // destructor virtual ~IPixelCablingSvc(){}; - - // InterfaceID static const InterfaceID& interfaceID( ) ; - // callback function - virtual StatusCode IOVCallBack(IOVSVC_CALLBACK_ARGS) = 0; - - // Get a list of offlineIds from a RobId. - virtual void getOfflineList(std::vector<IdentifierHash>& offlineIdHashList, int robid) = 0; - // Get offlineId from a certain onlineId - virtual Identifier getOfflineId(uint64_t onlineId) = 0; - virtual IdentifierHash getOfflineIdHash(uint64_t onlineId) = 0; - virtual Identifier getOfflineIdFromDCS(std::string) = 0; - - // Get RobId from a certain offlineId - virtual uint32_t getRobId(Identifier offlineId) = 0; - - // For backward compatibility - virtual uint32_t getRobID(Identifier offlineId) = 0; - - // Get RobId from a RodId - virtual int getRobId(const int rodId) = 0; - - // Get RODId from a ROBId - virtual int getRodId(const int robId) = 0; - - // get onlineId from a offlineId - virtual uint64_t getOnlineId(Identifier offlineId) = 0; - virtual Identifier getPixelIdfromHash(IdentifierHash offlineIdHash, uint32_t FE, uint32_t row, uint32_t column) = 0; virtual Identifier getPixelId(Identifier offlineId, uint32_t FE, uint32_t row, uint32_t column) = 0; virtual uint32_t getFE(Identifier * pixelId, Identifier offlineId) = 0; - virtual uint32_t getFEwrtSlink(Identifier *pixelId) = 0; virtual uint32_t getColumn(Identifier * pixelId, Identifier offlineId) = 0; virtual uint32_t getRow(Identifier * pixelId, Identifier offlineId) = 0; - virtual uint64_t getOnlineIdFromRobId(const uint32_t robId, const uint32_t link_module) = 0; virtual unsigned int getLocalFEI4(const uint32_t fe, const uint64_t onlineId) = 0; - virtual bool isIBL(const uint32_t robId) = 0; - virtual bool isIBL(const Identifier& pixelId) = 0; - virtual bool isDBM(const uint32_t robId) = 0; - virtual bool isDBM(const Identifier& pixelId) = 0; - - virtual std::vector<uint32_t>& getAllRods() = 0; - virtual std::vector<uint32_t>& getAllRobs() = 0; - - enum moduletype {DBM, IBL, PIX_BARREL, PIX_ENDCAP, NONE}; + enum moduletype {DBM, IBL_PLANAR, IBL_3D, PIX_BARREL, PIX_ENDCAP, NONE}; virtual moduletype getModuleType(const Identifier& id) = 0; enum pixeltype {NORMAL, LONG, GANGED}; virtual pixeltype getPixelType(const Identifier& id) = 0; - virtual int getHitDiscCnfg(const uint32_t robId, const int link) = 0; - virtual int getHitDiscCnfg(Identifier* pixelId) = 0; - virtual int getIBLOverflowToT(Identifier* pixelId) = 0; - - // Wrappers to PixelCablingData -- get maps - virtual std::map< uint64_t, Identifier > get_idMap_onoff() = 0; - virtual std::map< Identifier, uint64_t> get_idMap_offon() = 0; - virtual std::map< Identifier, uint32_t> get_idMap_offrob() = 0; - virtual std::map< int,int> get_idMap_rodrob() = 0; - virtual std::map< int,int> get_idMap_robrod() = 0; - virtual std::map< std::string, Identifier> get_idMapDCSoff() = 0; - - }; inline const InterfaceID& IPixelCablingSvc::interfaceID(){ @@ -106,5 +37,4 @@ inline const InterfaceID& IPixelCablingSvc::interfaceID(){ return IID; } - -#endif // IPIXELCABLINGSVC_H +#endif diff --git a/InnerDetector/InDetDetDescr/PixelCabling/python/PixelCablingConfig.py b/InnerDetector/InDetDetDescr/PixelCabling/python/PixelCablingConfig.py index c71edb40e42d1ea6c026af59007521ae05a2b65a..b2f51e86f6c218156abafec14ab09b3793989a5e 100644 --- a/InnerDetector/InDetDetDescr/PixelCabling/python/PixelCablingConfig.py +++ b/InnerDetector/InDetDetDescr/PixelCabling/python/PixelCablingConfig.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration from AthenaCommon import CfgMgr @@ -10,42 +10,51 @@ def getPixelCablingSvc(name="PixelCablingSvc", **kwargs): from AtlasGeoModel.CommonGMJobProperties import CommonGeometryFlags as commonGeoFlags from AtlasGeoModel.InDetGMJobProperties import InDetGeometryFlags as geoFlags from AthenaCommon.AthenaCommonFlags import athenaCommonFlags + + from AthenaCommon.AlgSequence import AthSequencer + condSeq = AthSequencer("AthCondSeq") + if not conddb.folderRequested("/PIXEL/ReadoutSpeed"): - #FIXME is this only needed for RECO? if not (globalflags.DataSource() == 'geant4'): - conddb.addFolder("PIXEL","/PIXEL/ReadoutSpeed") + conddb.addFolder("PIXEL", "/PIXEL/ReadoutSpeed", className="AthenaAttributeList") else: - conddb.addFolderSplitMC("PIXEL","/PIXEL/ReadoutSpeed","/PIXEL/ReadoutSpeed") - # Add the HitDiscCnfg folder if it has not been requested yet - if (conddb.dbdata == "CONDBR2" or (conddb.dbmc == "OFLP200" and geoFlags.isIBL() == True)) and not conddb.folderRequested("/PIXEL/HitDiscCnfg"): - conddb.addFolderSplitMC("PIXEL","/PIXEL/HitDiscCnfg","/PIXEL/HitDiscCnfg") + conddb.addFolderSplitMC("PIXEL","/PIXEL/ReadoutSpeed","/PIXEL/ReadoutSpeed", className="AthenaAttributeList") + + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelReadoutSpeedAlg + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelCablingCondAlg + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_2016.dat" + PixelCablingCondAlg.RodIDForSingleLink40=0 + PixelCablingCondAlg.DumpMapToFile=False + + if (conddb.dbdata=="CONDBR2" or (conddb.dbmc=="OFLP200" and geoFlags.isIBL()==True)) and not conddb.folderRequested("/PIXEL/HitDiscCnfg"): + conddb.addFolderSplitMC("PIXEL","/PIXEL/HitDiscCnfg","/PIXEL/HitDiscCnfg", className="AthenaAttributeList") + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelHitDiscCnfgAlg + condSeq += PixelHitDiscCnfgAlg(name="PixelHitDiscCnfgAlg") + # Online mode if (athenaCommonFlags.isOnline == True): logger.debug("Running in online mode") - - # Request the CablingMap folder - # (COOL is the default mapping type) - if (conddb.dbdata == "CONDBR2"): + if (conddb.dbdata=="CONDBR2"): if not conddb.folderRequested("/PIXEL/CablingMap"): - conddb.addFolderSplitOnline("PIXEL", "/PIXEL/Onl/CablingMap","/PIXEL/CablingMap") + conddb.addFolderSplitOnline("PIXEL", "/PIXEL/Onl/CablingMap","/PIXEL/CablingMap", className="AthenaAttributeList") logger.debug("Requested CablingMap folder") - else: - kwargs.setdefault("MappingType", "Final") - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_May08.dat") + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_344494.dat" + PixelCablingCondAlg.RodIDForSingleLink40=1300000 # Offline mode else: - logger.debug("Running in offline mode") # SIMULATION if (globalflags.DataSource() == 'geant4'): logger.debug("Running on simulation") - # Set cabling svc to get map from file - kwargs.setdefault("MappingType", "Final") - + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.RodIDForSingleLink40=0 + # ITk: if geoFlags.isSLHC(): IdMappingDat = "ITk_Atlas_IdMapping.dat" @@ -58,12 +67,12 @@ def getPixelCablingSvc(name="PixelCablingSvc", **kwargs): elif "BrlExt3.2_ref" == commonGeoFlags.GeoType(): IdMappingDat = "ITk_Atlas_IdMapping_ExtBrl32.dat" logger.info("Using ITk pixel mapping: %s" % IdMappingDat) - kwargs.setdefault("MappingFile", IdMappingDat) + PixelCablingCondAlg.MappingFile=IdMappingDat # No IBL elif (geoFlags.isIBL() == False): - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping.dat" else: # Planar IBL @@ -71,14 +80,13 @@ def getPixelCablingSvc(name="PixelCablingSvc", **kwargs): # DBM or not if (geoFlags.isDBM() == True): - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_inclIBL_DBM.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_inclIBL_DBM.dat" else: - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_inclIBL.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_inclIBL.dat" # Hybrid IBL plus DBM elif (geoFlags.IBLLayout() == "3D"): - #kwargs.setdefault("MappingFile", "Pixels_Atlas_IdMapping_inclIBL3D_DBM.dat") - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_Run2.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_Run2.dat" elif (geoFlags.IBLLayout() == "UNDEFINED"): logger.warning("Got GeometryFlags.isIBL = True, but IBLLayout is UNDEFINED") @@ -87,37 +95,42 @@ def getPixelCablingSvc(name="PixelCablingSvc", **kwargs): # DATA elif (globalflags.DataSource == 'data'): + + if not conddb.folderRequested("/PIXEL/CablingMap"): + conddb.addFolder("PIXEL_OFL", "/PIXEL/CablingMap", className="AthenaAttributeList") + from RecExConfig.AutoConfiguration import GetRunNumber runNum = GetRunNumber() logger.debug("Running on data, run number %d" % runNum) # For data older than run number 222222, use the appropriate text file if (runNum < 222222): - kwargs.setdefault("MappingType", "Final") - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_May08.dat") + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_May08.dat" + PixelCablingCondAlg.RodIDForSingleLink40=1300000 # For Run-2 onwards, get cabling map from database else: - kwargs.setdefault("MappingType", "COOL") - kwargs.setdefault("KeyCabling", "/PIXEL/CablingMap") - - # Request the CablingMap folder - if not conddb.folderRequested("/PIXEL/CablingMap"): - conddb.addFolderSplitOnline("PIXEL", "/PIXEL/Onl/CablingMap","/PIXEL/CablingMap") - logger.debug("Requested CablingMap folder") + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.RodIDForSingleLink40=1300000 # Even though we are reading from COOL, set the correct fallback map. - if (runNum >= 289350): # 2016 - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_2016.dat") + if (runNum >= 344494): + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_344494.dat" + elif (runNum >= 314940 and runNum < 344494): + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_314940.dat" + elif (runNum >= 289350 and runNum < 314940): # 2016 + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_2016.dat" elif (runNum >= 222222 and runNum < 289350): # 2015 - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_Run2.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_Run2.dat" else: - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_May08.dat") - + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_May08.dat" # Unknown input else: logger.warning("Unknown input source. Pixel cabling map cannot be set at this point") + condSeq += PixelReadoutSpeedAlg(name="PixelReadoutSpeedAlg") + condSeq += PixelCablingCondAlg(name="PixelCablingCondAlg") return CfgMgr.PixelCablingSvc(name, **kwargs) diff --git a/InnerDetector/InDetDetDescr/PixelCabling/python/PixelCablingConfigNew.py b/InnerDetector/InDetDetDescr/PixelCabling/python/PixelCablingConfigNew.py index 1d631ad0ac627b768e6fb69785f71ca9050cac91..48d3f2960e06845bdf7ff7025bca52fa62b57cfc 100644 --- a/InnerDetector/InDetDetDescr/PixelCabling/python/PixelCablingConfigNew.py +++ b/InnerDetector/InDetDetDescr/PixelCabling/python/PixelCablingConfigNew.py @@ -13,32 +13,51 @@ def PixelCablingSvcCfg(flags, name="PixelCablingSvc", **kwargs): """Return a ComponentAccumulator with configured PixelCablingSvc""" acc = ComponentAccumulator() logger = logging.getLogger("PixelCablingSvc") + + from AthenaCommon.AlgSequence import AthSequencer + condSeq = AthSequencer("AthCondSeq") + if flags.Input.isMC: - acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/ReadoutSpeed", "/PIXEL/ReadoutSpeed")) + acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/ReadoutSpeed", "/PIXEL/ReadoutSpeed", className="AthenaAttributeList")) else: - acc.merge(addFolders(flags, "/PIXEL/ReadoutSpeed", "PIXEL")) + acc.merge(addFolders(flags, "/PIXEL/ReadoutSpeed", "PIXEL", className="AthenaAttributeList")) + + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelReadoutSpeedAlg + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelCablingCondAlg + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_2016.dat" + PixelCablingCondAlg.RodIDForSingleLink40=0 + PixelCablingCondAlg.DumpMapToFile=False + # Add the HitDiscCnfg folder - if (conddb.dbdata == "CONDBR2" or (conddb.dbmc == "OFLP200" and flags.GeoModel.Run == "RUN2")): - acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/HitDiscCnfg", "/PIXEL/HitDiscCnfg")) + if (conddb.dbdata=="CONDBR2" or (conddb.dbmc=="OFLP200" and flags.GeoModel.Run=="RUN2")) and not conddb.folderRequested("/PIXEL/HitDiscCnfg"): + acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/HitDiscCnfg", "/PIXEL/HitDiscCnfg", className="AthenaAttributeList")) + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelHitDiscCnfgAlg + condSeq += PixelHitDiscCnfgAlg(name="PixelHitDiscCnfgAlg") + # Online mode if flags.Common.isOnline: logger.debug("Running in online mode") # Request the CablingMap folder # (COOL is the default mapping type) if (conddb.dbdata == "CONDBR2"): - acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/Onl/CablingMap","/PIXEL/CablingMap")) + acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/Onl/CablingMap","/PIXEL/CablingMap", className="AthenaAttributeList")) logger.debug("Requested CablingMap folder") - else: - kwargs.setdefault("MappingType", "Final") - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_May08.dat") + + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_344494.dat" + PixelCablingCondAlg.RodIDForSingleLink40=1300000 + # Offline mode else: logger.debug("Running in offline mode") # SIMULATION if flags.Input.isMC: logger.debug("Running on simulation") - # Set cabling svc to get map from file - kwargs.setdefault("MappingType", "Final") + + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.RodIDForSingleLink40=0 + # ITk: if flags.GeoModel.Run == "RUN4": IdMappingDat = "ITk_Atlas_IdMapping.dat" @@ -51,50 +70,63 @@ def PixelCablingSvcCfg(flags, name="PixelCablingSvc", **kwargs): elif flags.GeoModel.Type == "BrlExt3.2_ref": IdMappingDat = "ITk_Atlas_IdMapping_ExtBrl32.dat" logger.info("Using ITk pixel mapping: %s" % IdMappingDat) - kwargs.setdefault("MappingFile", IdMappingDat) + PixelCablingCondAlg.MappingFile=IdMappingDat # IBL elif flags.GeoModel.Run == "RUN2" or flags.GeoModel.Run == "RUN3": # Planar IBL if flags.GeoModel.IBLLayout == "planar": # DBM or not if flags.GeoModel.Run == "RUN2": - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_inclIBL_DBM.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_inclIBL_DBM.dat" else: - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_inclIBL.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_inclIBL.dat" # Hybrid IBL plus DBM elif flags.GeoModel.IBLLayout == "3D": - #kwargs.setdefault("MappingFile", "Pixels_Atlas_IdMapping_inclIBL3D_DBM.dat") - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_Run2.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_Run2.dat" elif flags.GeoModel.IBLLayout == "UNDEFINED": logger.warning("IBL is required, but flags.GeoModel.IBLLayout is \"UNDEFINED\"") logger.warning("Pixel cabling map cannot be set at this point") # No IBL else: - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping.dat" # DATA elif not flags.Input.isMC: runNum = GetRunNumber() logger.debug("Running on data, run number %d" % runNum) + + # For data older than run number 222222, use the appropriate text file if runNum < 222222: - kwargs.setdefault("MappingType", "Final") - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_May08.dat") + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_May08.dat" + PixelCablingCondAlg.RodIDForSingleLink40=1300000 # For Run-2 onwards, get cabling map from database else: - kwargs.setdefault("MappingType", "COOL") - kwargs.setdefault("KeyCabling", "/PIXEL/CablingMap") + PixelCablingCondAlg.UseConditions=False + PixelCablingCondAlg.RodIDForSingleLink40=1300000 + # Request the CablingMap folder - acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/Onl/CablingMap","/PIXEL/CablingMap")) - logger.debug("Requested CablingMap folder") + if not conddb.folderRequested("/PIXEL/CablingMap"): + acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/Onl/CablingMap","/PIXEL/CablingMap", className="AthenaAttributeList")) + logger.debug("Requested CablingMap folder") + # Even though we are reading from COOL, set the correct fallback map. - if runNum >= 289350: # 2016 - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_2016.dat") - elif runNum >= 222222 and runNum < 289350: # 2015 - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_Run2.dat") + if (runNum >= 344494): + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_344494.dat" + elif (runNum >= 314940 and runNum < 344494): + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_314940.dat" + elif (runNum >= 289350 and runNum < 314940): # 2016 + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_2016.dat" + elif (runNum >= 222222 and runNum < 289350): # 2015 + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_Run2.dat" else: - kwargs.setdefault("MappingFile", "PixelCabling/Pixels_Atlas_IdMapping_May08.dat") + PixelCablingCondAlg.MappingFile="PixelCabling/Pixels_Atlas_IdMapping_May08.dat" # Unknown input else: logger.warning("Unknown input source. Pixel cabling map cannot be set at this point") + + condSeq += PixelReadoutSpeedAlg(name="PixelReadoutSpeedAlg") + condSeq += PixelCablingCondAlg(name="PixelCablingCondAlg") + acc.addService(PixelCablingSvc(name, **kwargs)) return acc diff --git a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingData.cxx b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingData.cxx deleted file mode 100755 index 555028c13662c0b11d53fe68d23876f6d6a42948..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingData.cxx +++ /dev/null @@ -1,450 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelCablingData.cxx -// Implementation file for class PixelCablingData -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -// Class used to add and search entries in the maps: -// - add_entry_onoff() - add entries to m_idMap_onoff -// - add_entry_offon() - add entries in m_idMap_offon -// - add_entry_offrob() - add entries in m_idMap_offrob -// - add_entry_rodrob() - add entries in map m_idMap_rodrob -// - find_entry_onoff() - search entry in the map m_idMap_onoff - get the offlineId from the onlineId -// - find_entry_offon() - search entry in the map m_idMap_offon - get the onlineId from the offlineId -// - find_entry_offrob() - search entry in the map m_idMap_offrob - get the ROBId from the offlineId -// - find_entry_rodrob() - search entry in the map m_idMap_rodrob - get the ROBId from the RODId -// and to the list vector: -// - add_entry_offlineList() - add entries in m_offlineListVect -// - find_entry_offlineList() - return entries from m_offlineListVect for a ROBId -// - get_allRobs - returns the list of all ROBs in the mapping -// - getOnlineIdFromRobId - returns the onlineId from the robId and the link_module -/////////////////////////////////////////////////////////////////// -// Version 00-03-26 15/01/2007 Daniel Dobos -/////////////////////////////////////////////////////////////////// - -#include "PixelCablingData.h" -#include "Identifier/Identifier.h" -#include <iostream> -#include <fstream> -#include <sstream> - - -// Hashing function for Identifiers -std::size_t hash_value(Identifier const& id) { - //boost::hash<int> hasher; - boost::hash<Identifier::value_type> hasher; - return hasher(id.get_compact()); -} - - -//////////////////////// -// constructor -//////////////////////// -PixelCablingData::PixelCablingData() : - m_commonHitDiscCnfg(3) -{ - m_allRods = new std::vector<uint32_t>; - m_allRobs = new std::vector<uint32_t>; - - //m_commonHitDiscCnfg = 3; -} - - -//////////////////////// -// destructor -//////////////////////// -PixelCablingData::~PixelCablingData() { - delete m_allRods; - delete m_allRobs; -} - -//////////////////////// -// add_entry_onoff - add entries to m_idMap_onoff -//////////////////////// -void PixelCablingData::add_entry_onoff(const uint64_t onlineId, const Identifier offlineId) { - m_idMap_onoff.insert(std::make_pair(onlineId, offlineId)); // add online identifier -> offline identifier pair in m_idMap_onoff -} - -//////////////////////// -// add_entry_offon - add entries in m_idMap_offon -//////////////////////// -void PixelCablingData::add_entry_offon(const Identifier offlineId, const uint64_t onlineId) { - m_idMap_offon.insert(std::make_pair(offlineId, onlineId)); // add offline identifier -> online identifier pair in m_idMap_offon -} - -//////////////////////// -// add_entry_offrob - add entries in m_idMap_offrob -//////////////////////// -void PixelCablingData::add_entry_offrob(const Identifier offlineId, const uint32_t robid) { - m_idMap_offrob.insert(std::make_pair(offlineId, robid)); // add offline identifier -> offline ROBId pair in m_idMap_offrob -} - -//////////////////////// -// add_entry_rodrob - add entries in map m_idMap_rodrob -//////////////////////// -void PixelCablingData::add_entry_rodrob(int rodid, int robid) { - m_idMap_rodrob.insert(std::make_pair(rodid, robid)); // add RODId identifier -> offline ROBId pair in m_idMap_rodrob -} - -//////////////////////// -// add_entry_robrod - add entries in map m_idMap_robrod -//////////////////////// -void PixelCablingData::add_entry_robrod(int robid, int rodid) { - m_idMap_robrod.insert(std::make_pair(robid, rodid)); -} - -//////////////////////// -// add_entry_offlineList - add entries in m_offlineListVect -//////////////////////// -void PixelCablingData::add_entry_offlineList(const uint32_t robid, const Identifier offlineId) { - m_offlineListVect[robid].push_back(offlineId); // add ROBid -> offline identifier pair in m_offlineListVect -} - -//////////////////////// -// add_entry_DCSoffline - add DCS ID offline Identifer mapping -//////////////////////// -void PixelCablingData::add_entry_DCSoffline(std::string DCSname, const Identifier offlineId) { - m_idMapDCSoff.insert(std::make_pair(DCSname, offlineId)); -} - -//////////////////////// -// set_readout_map - set map containing readout speed for each ROD -//////////////////////// -void PixelCablingData::set_readout_map(std::map<uint32_t, bool> rodReadoutMap) { - m_rodReadoutMap = rodReadoutMap; -} - -//////////////////////// -// find_entry_onoff - search entry in the map m_idMap_onoff - get the offlineId from the onlineId -//////////////////////// -Identifier PixelCablingData::find_entry_onoff(const uint64_t onlineId) const { - - // Search m_idMap_onoff for the onlineId - uint64_t searchId = onlineId; - Identifier offlineId(0); - boost::unordered_map<uint64_t, Identifier>::const_iterator iter(m_idMap_onoff.find(searchId)); - - // OnlineId has been found - get the offline identifier - if (iter != m_idMap_onoff.end()) offlineId = (*iter).second; - - // Is onlineId not found? Then check if this is a b-layer module; if it is read out at - // 80 Mbit, search again with link = 0, since FMT has enough info to identify the module - else { - uint32_t rodid = (onlineId & 0xFFFFFF); // last 24 bit are rodid - - if ((rodid & 0x130000) >> 16 == 0x13) { - std::map<uint32_t, bool>::const_iterator it = m_rodReadoutMap.find(rodid); - - if (it != m_rodReadoutMap.end()) { - if ((*it).second == true) { // true = is 80 MBit - - // Search again - searchId = onlineId & (0xF0FFFFFF); - iter = m_idMap_onoff.find(searchId); - - // Get identifier - if (iter != m_idMap_onoff.end()) offlineId = (*iter).second; - } - } - } - - // If onlineId is still not found, the empty identifier is returned. - } - - return offlineId; - - -} - -//////////////////////// -// find_entry_offon - search entry in the map m_idMap_offon - get the onlineId from the offlineId -//////////////////////// -uint64_t PixelCablingData::find_entry_offon(const Identifier offlineId) const { - uint64_t onlineId; // declare online identifier - boost::unordered_map<Identifier, uint64_t>::const_iterator iter(m_idMap_offon.find(offlineId)); // find offline identifier in m_idMap_offon map - if (iter == m_idMap_offon.end()) { // if offline identifier not found in m_idMap_offon map -> ERROR - onlineId = 0; // fill online identifier with empty identifier - return onlineId; // return empty online identifier - } - onlineId = (*iter).second; // fill online identifier with found online identifier - return onlineId; // return found online identifier -} - -//////////////////////// -// find_entry_offrob - search entry in the map m_idMap_offrob - get the ROBId from the offlineId -//////////////////////// -uint32_t PixelCablingData::find_entry_offrob(const Identifier offlineId) const { - uint32_t robid; // declare ROBId - boost::unordered_map<Identifier, uint32_t>::const_iterator iter(m_idMap_offrob.find(offlineId)); // find offline identifier in m_idMap_offrob map - if (iter == m_idMap_offrob.end()) { // if offline identifier not found in m_idMap_offrob map -> ERROR - robid = 0; // fill ROBId with empty identifier - return robid; // return empty ROBId - } - robid = (*iter).second; // fill ROBId with found ROBId - return robid; // return found ROBId -} - -//////////////////////// -// find_entry_rodrob - search entry in the map m_idMap_rodrob - get the ROBId from the RODId -//////////////////////// -int PixelCablingData::find_entry_rodrob(const int rodid) { - boost::unordered_map<int, int>::const_iterator iter(m_idMap_rodrob.find(rodid)); - if (iter == m_idMap_rodrob.end()) { - return 0; - } - int robid = iter->second; - return robid; -} - - -//////////////////////// -// find_entry_robrod - search entry in the map m_idMap_robrod - get the RODId from the ROBId -//////////////////////// -int PixelCablingData::find_entry_robrod(const int robid) { - boost::unordered_map<int,int>::const_iterator iter(m_idMap_robrod.find(robid)); - if (iter == m_idMap_robrod.end()) return 0; - return iter->second; -} - - - -//////////////////////// -// find_entry_offlineList - return entries from m_offlineListVect for a ROBId -//////////////////////// -std::deque<Identifier> PixelCablingData::find_entry_offlineList(uint32_t robid) { - std::deque<Identifier> offlineId; // declare collection identifier list for the ROBId - std::deque<Identifier>::const_iterator it1 = m_offlineListVect[robid].begin(); // first offline identifier for the ROBId - std::deque<Identifier>::const_iterator it2 = m_offlineListVect[robid].end(); // last offline identifier for the ROBId - for (; it1 != it2; ++it1) { // loop thrue offline identifiers - offlineId.push_back(*it1); // fill offline identifier into offline identifier list - } - return offlineId; // return the offline identifier list for the ROBId -} - -//////////////////////// -// find_entry_DCSoffline - return offline Id for a DCS name -//////////////////////// -Identifier PixelCablingData::find_entry_DCSoffline(std::string DCSname) { - boost::unordered_map<std::string, Identifier>::const_iterator iter(m_idMapDCSoff.find(DCSname)); - if (iter == m_idMapDCSoff.end()) { - Identifier offlineId(0); - return offlineId; - } - return iter->second; -} - -//////////////////////// -// find_entry_DCSoffline - return DCS name for an offline ID -//////////////////////// -std::string PixelCablingData::find_entry_offlineDCS(const Identifier offlineId) { - boost::unordered_map<std::string, Identifier>::const_iterator iter = m_idMapDCSoff.begin(); - for (; iter != m_idMapDCSoff.end(); iter++) { - if (iter->second == offlineId) - return iter->first; - } - return ""; // not found -} - -//////////////////////// -// get_allRods - returns the list of all Rods in the Mapping -//////////////////////// -std::vector<uint32_t>& PixelCablingData::get_allRods() { - if (m_allRods->empty()) { // fill vector from map only once - for (boost::unordered_map<int, int>::iterator rodrobmap_iterator = m_idMap_rodrob.begin(); rodrobmap_iterator != m_idMap_rodrob.end(); rodrobmap_iterator++) - m_allRods->push_back(rodrobmap_iterator->first); - } - return *m_allRods; -} - - -//////////////////////// -// get_allRobs - returns the list of all ROBs in the mapping -//////////////////////// -std::vector<uint32_t>& PixelCablingData::get_allRobs() { - if (m_allRobs->empty()) { - for (boost::unordered_map<int,int>::const_iterator robrod_iter = m_idMap_robrod.begin(); robrod_iter != m_idMap_robrod.end(); robrod_iter++) { - m_allRobs->push_back(robrod_iter->first); - } - } - return *m_allRobs; -} - - -//////////////////////// -// getOnlineIdFromRobId - returns the onlineId from the robId and the link number -// onlineId convention: onlineId is constructed as 0xAABBDDMMMM, where MMMM = robId, -// DD = subdetector id, AABB = link number. -// For pixels, there is only one link number per onlineId, so AA = 00. -//////////////////////// -uint64_t PixelCablingData::getOnlineIdFromRobId(const uint32_t robid, const uint32_t link) { - - uint32_t subDetId = (robid & 0xFFFFFF) >> 16; - - // Pixels: - if (subDetId < 0x14) return (robid & 0xFFFFFF) | (link << 24); - - // IBL / DBM: - else if (subDetId == 0x14 || subDetId == 0x15) { - - // Need to search the on-off map for the appropriate onlineId - uint32_t linknum_temp; - boost::unordered_map<uint64_t, Identifier>::const_iterator itr = m_idMap_onoff.begin(); - for (; itr != m_idMap_onoff.end(); ++itr) { - if ((itr->first & 0xFFFFFF) == robid) { - linknum_temp = (itr->first >> 24); - // Check for linknum in both first and third nibble - if ((linknum_temp & 0xF) == link || ((linknum_temp >> 8) & 0xF) == link) return itr->first; - } - } - } - - return 0; -} - - - - - -//////////////////////// -// add_entryHitDiscCngf - insert or modify entry in map -//////////////////////// -void PixelCablingData::add_entry_HitDiscCnfg(const uint32_t frontendId, const int hitdisccnfg) { - - // Insert new key-value pair - if (m_HitDiscCnfgMap.find(frontendId) == m_HitDiscCnfgMap.end()) { - m_HitDiscCnfgMap.insert(std::make_pair(frontendId, hitdisccnfg)); - } - // Modify an existing entry - else { - m_HitDiscCnfgMap[frontendId] = hitdisccnfg; - } -} - - - -//////////////////////// -// getHitDiscCnfg - get HitDiscCnfg mode for given FE-I4 -//////////////////////// -int PixelCablingData::getHitDiscCnfg(const uint32_t frontendId) { - - // Search the map for given frontend id - // If not found, return the common HitDiscCnfg setting. - boost::unordered_map<uint32_t,int>::const_iterator iter(m_HitDiscCnfgMap.find(frontendId)); - if (iter != m_HitDiscCnfgMap.end()) return iter->second; - else return m_commonHitDiscCnfg; - -} - - -//////////////////////// -// printHitDiscCnfg - print the contents of the HitDiscCnfg map -//////////////////////// -void PixelCablingData::printHitDiscCnfg() { - - std::cout << "Common HitDiscCnfg value: " << m_commonHitDiscCnfg << std::endl; - std::cout << "Contents of HitDiscCnfg map: " << std::endl; - boost::unordered_map<uint32_t,int>::const_iterator iter = m_HitDiscCnfgMap.begin(); - for (; iter != m_HitDiscCnfgMap.end(); iter++) { - std::cout << " FE ID: 0x" << std::hex << iter->first << " - HDC = " << std::dec << iter->second << std::endl; - } -} - - - -// void PixelCablingData::copy_offonMap (std::map< Identifier, uint64_t> &outputMap){ -// outputMap = m_idMap_offon; -// } - - -// void PixelCablingData::copy_DCSoffMap (std::map< std::string, Identifier> &outputMap){ -// outputMap = m_idMapDCSoff; -// } - -// void PixelCablingData::copy_offrobMap(std::map< Identifier, uint32_t> &outputMap){ -// outputMap = m_idMap_offrob; -// } - - -// Give access to the maps (return a std::map copy) -std::map<uint64_t, Identifier> PixelCablingData::get_idMap_onoff() { - - std::map<uint64_t, Identifier> copy; - for (boost::unordered_map<uint64_t, Identifier>::const_iterator itr = m_idMap_onoff.begin(); - itr != m_idMap_onoff.end(); ++itr) { - copy.insert(*itr); - } - return copy; -} - -std::map<Identifier, uint64_t> PixelCablingData::get_idMap_offon(){ - - std::map<Identifier, uint64_t> copy; - for (boost::unordered_map<Identifier, uint64_t>::const_iterator itr = m_idMap_offon.begin(); - itr != m_idMap_offon.end(); ++itr) { - copy.insert(*itr); - } - return copy; -} - -std::map<Identifier, uint32_t> PixelCablingData::get_idMap_offrob(){ - - std::map<Identifier, uint32_t> copy; - for (boost::unordered_map<Identifier, uint32_t>::const_iterator itr = m_idMap_offrob.begin(); - itr != m_idMap_offrob.end(); ++itr) { - copy.insert(*itr); - } - return copy; -} - -std::map<int,int> PixelCablingData::get_idMap_rodrob(){ - - std::map<int,int> copy; - for (boost::unordered_map<int,int>::const_iterator itr = m_idMap_rodrob.begin(); - itr != m_idMap_rodrob.end(); ++itr) { - copy.insert(*itr); - } - return copy; -} - -std::map<int,int> PixelCablingData::get_idMap_robrod(){ - - std::map<int,int> copy; - for (boost::unordered_map<int,int>::const_iterator itr = m_idMap_robrod.begin(); - itr != m_idMap_robrod.end(); ++itr) { - copy.insert(*itr); - } - return copy; -} - -std::map<std::string, Identifier> PixelCablingData::get_idMapDCSoff(){ - - std::map<std::string, Identifier> copy; - for (boost::unordered_map<std::string, Identifier>::const_iterator itr = m_idMapDCSoff.begin(); - itr != m_idMapDCSoff.end(); ++itr) { - copy.insert(*itr); - } - return copy; -} - - -//////////////////////// -// clear the maps -//////////////////////// -void PixelCablingData::clear_all_maps() { - m_idMap_onoff.clear(); - m_idMap_offon.clear(); - m_idMap_offrob.clear(); - m_idMap_rodrob.clear(); - m_idMap_robrod.clear(); - m_offlineListVect.clear(); - m_idMapDCSoff.clear(); - m_rodReadoutMap.clear(); - m_HitDiscCnfgMap.clear(); - m_allRods->clear(); - m_allRobs->clear(); -} - diff --git a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingData.h b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingData.h deleted file mode 100755 index e1c7257ad8aca29e9967ef97dcbe0594dbc3b227..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingData.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelCablingData.h -// Header file for class PixelCablingData -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -// Class used to add and search entries in the maps: -// - add_entry_onoff() - add entries to m_idMap_onoff -// - add_entry_offon() - add entries in m_idMap_offon -// - add_entry_offrob() - add entries in m_idMap_offrob -// - add_entry_rodrob() - add entries in map m_idMap_rodrob -// - find_entry_onoff() - search entry in the map m_idMap_onoff - get the offlineId from the onlineId -// - find_entry_offon() - search entry in the map m_idMap_offon - get the onlineId from the offlineId -// - find_entry_offrob() - search entry in the map m_idMap_offrob - get the ROBId from the offlineId -// - find_entry_rodrob() - search entry in the map m_idMap_rodrob - get the ROBId from the RODId -// and to the list vector: -// - add_entry_offlineList() - add entries in m_offlineListVect -// - find_entry_offlineList() - return entries from m_offlineListVect for a ROBId -/////////////////////////////////////////////////////////////////// -// Version 00-03-26 15/01/2007 Daniel Dobos -/////////////////////////////////////////////////////////////////// - -#ifndef PIXELCABLINGDATA_H -#define PIXELCABLINGDATA_H - - -//#define PIXEL_DEBUG -#include "AthenaKernel/CLASS_DEF.h" -#include "Identifier/Identifier.h" -#include <map> -#include <deque> -#include <stdint.h> -#include <utility> -#include <string> -#include <boost/unordered_map.hpp> - - -// Provide hash_value function for unordered maps -std::size_t hash_value(Identifier const& id); - - - -/** Class containing maps with the relationships between online-to-offline - * identifiers, ROD-to-ROB etc. - */ -class PixelCablingData -{ - - public: - - // constructor - PixelCablingData(); - - // destructor - virtual ~PixelCablingData(); - - // avoid default copy ctor / assignment operator - PixelCablingData(const PixelCablingData &other) = delete; - PixelCablingData& operator= (const PixelCablingData &other) = delete; - - /** @name Functions to add entries to the maps */ - ///@{ - void add_entry_onoff(const uint64_t, const Identifier); // add entries to m_idMap_onoff - void add_entry_offon(const Identifier, const uint64_t); // add entries in m_idMap_offon - void add_entry_offrob(const Identifier, const uint32_t); // add entries in m_idMap_offrob - void add_entry_rodrob(int rodid, int robid); // add entries in m_idMap_rodrob - void add_entry_robrod(int robid, int rodid); - void add_entry_offlineList(const uint32_t, const Identifier); // add entries in m_offlineListVect - void add_entry_DCSoffline(std::string, const Identifier); // add entries in m_offlineListVect - ///@} - - /** @name Functions to search for entry in the maps */ - ///@{ - Identifier find_entry_onoff(const uint64_t) const; // search entry in the map m_idMap_onoff - get the offlineId from the onlineId - uint64_t find_entry_offon(const Identifier) const; // search entry in the map m_idMap_offon - get the onlineId from the offlineId - uint32_t find_entry_offrob(const Identifier) const; // search entry in the map m_idMap_offrob - get the ROBId from the offlineId - int find_entry_rodrob(const int rodId); - int find_entry_robrod(const int robId); - std::deque<Identifier> find_entry_offlineList(uint32_t); // return entries from m_offlineListVect for a ROBId - Identifier find_entry_DCSoffline(std::string); - std::string find_entry_offlineDCS(const Identifier); - uint64_t getOnlineIdFromRobId(const uint32_t robid, const uint32_t link); - ///@} - - /** Clear all the maps **/ - void clear_all_maps(); - - /** @name FE-I4 HitDiscCnfg functions */ - ///@{ - void setCommonHitDiscCngf(int hitdisccnfg) {m_commonHitDiscCnfg = hitdisccnfg;} - void add_entry_HitDiscCnfg(const uint32_t, const int); - int getHitDiscCnfg(const uint32_t frontendId); - void printHitDiscCnfg(); // for debugging - ///@} - - /** Return vector containing all RODs */ - std::vector<uint32_t>& get_allRods(); - /** Return vector containing all ROBs **/ - std::vector<uint32_t>& get_allRobs(); - - /** Get the size og the on-off map */ - unsigned int get_size_onoff() {return m_idMap_onoff.size();} - - /** Set the readoutspeed map equal an input map */ - void set_readout_map( std::map<uint32_t,bool> rodReadoutMap); - - /** Functions providing access to the cabling maps. These - * should onlt be accessed by the corresponding wrapper - * functions in PixelCablingSvc. - * (return std::map rather than the boost ones) - */ - ///@{ - std::map<uint64_t, Identifier> get_idMap_onoff(); - std::map<Identifier, uint64_t> get_idMap_offon(); - std::map<Identifier, uint32_t> get_idMap_offrob(); - std::map<int,int> get_idMap_rodrob(); - std::map<int,int> get_idMap_robrod(); - std::map<std::string, Identifier> get_idMapDCSoff(); - ///@} - - - - private: - - /** @name These are all the maps */ - ///@{ - boost::unordered_map<uint64_t, Identifier> m_idMap_onoff; ///< offline identifier -> online identifier map - boost::unordered_map<Identifier, uint64_t> m_idMap_offon; ///< online identifier -> offline identifier map - boost::unordered_map<Identifier, uint32_t> m_idMap_offrob; ///< offline identifier -> ROBId map - boost::unordered_map<int,int> m_idMap_rodrob; ///< RODId -> ROBId map - boost::unordered_map<int,int> m_idMap_robrod; ///< ROBId -> RODId map (reverse of m_idMap_rodrob) - std::map<uint32_t, std::deque<Identifier> > m_offlineListVect; ///< ROBId -> offline identifier list - boost::unordered_map<std::string, Identifier> m_idMapDCSoff; ///< DCS name -> offline identifier - std::map<uint32_t,bool> m_rodReadoutMap; ///< Readout speed for each ROD. false=40MBit, true=80MBit - ///@} - - - /** Map of HitDiscCnfg values for each IBL FE - * Format: [0xLDDRRR, H], where L = link, DD = subdet id, RRRR = rob id, H = HitDiscCnfg - */ - boost::unordered_map<uint32_t, int> m_HitDiscCnfgMap; - - /** The most common HDC setting */ - int m_commonHitDiscCnfg; - - - std::vector<uint32_t>* m_allRods; // vector containing all RODs in the m_idMap_rodrob - std::vector<uint32_t>* m_allRobs; // vector containing all ROBs - -}; - -CLASS_DEF( PixelCablingData , 107266278 , 1 ) // class definition with CLID - -#endif // PIXELCABLINGDATA_H diff --git a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingSvc.cxx b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingSvc.cxx index 9e917f293ee556a63469fbbc4adbc38e95e209d1..b30cbf1fa6991fa7f6605a95c7824effa9f1b501 100644 --- a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingSvc.cxx +++ b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingSvc.cxx @@ -1,77 +1,25 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "PixelCablingSvc.h" -#include <iostream> -#include <fstream> -#include <sstream> -#include <exception> - #include "GaudiKernel/ServiceHandle.h" #include "StoreGate/StoreGateSvc.h" -// Classes -#include "Identifier/Identifier.h" -#include "PixelCablingData.h" -#include "InDetIdentifier/PixelID.h" -#include "eformat/SourceIdentifier.h" -#include "GaudiKernel/StatusCode.h" - -#include "PixelFillCablingData.h" - -// for callback -#include "AthenaPoolUtilities/CondAttrListCollection.h" -#include "AthenaPoolUtilities/AthenaAttributeList.h" - -// COOL includes -#include "CoralBase/Blob.h" - #include "InDetReadoutGeometry/SiDetectorElement.h" #include "InDetReadoutGeometry/PixelModuleDesign.h" #include "InDetReadoutGeometry/PixelDetectorManager.h" //#define PIXEL_DEBUG -//////////////////////// -// constructor -//////////////////////// - PixelCablingSvc::PixelCablingSvc(const std::string& name, ISvcLocator*svc): AthService(name,svc), - m_cablingTool("PixelFillCablingData"), m_detStore("DetectorStore", name), m_detManager(0), - m_idHelper(0), - m_cabling(new PixelCablingData), - m_dataString(""), - m_key("/PIXEL/ReadoutSpeed"), - m_keyFEI4("/PIXEL/HitDiscCnfg"), - m_keyCabling("/PIXEL/CablingMap"), - m_dump_map_to_file(false) + m_idHelper(0) { - // "Final": use text file, "COOL": read from COOL - declareProperty("MappingType", m_mappingType = "COOL"); - // Name of mapping file to use, if mappingType == Final - declareProperty("MappingFile", m_final_mapping_file = "PixelCabling/Pixels_Atlas_IdMapping_2016.dat"); - // NOT USED - declareProperty("Bandwidth", m_bandwidth = 0); - // NOT USED - declareProperty("Coral_Connectionstring", m_coraldbconnstring = "oracle://ATLAS_COOLPROD/ATLAS_COOLONL_PIXEL"); // used to configure CORAL based tool - // NOT USED - declareProperty("DictionaryTag", m_dictTag="PIXEL"); - // NOT USED - declareProperty("ConnectivityTag", m_connTag="PIT-ALL-V39"); - // Folder name for FE-I4 hit discriminator configuration - declareProperty("KeyFEI4", m_keyFEI4 = "/PIXEL/HitDiscCnfg"); - // Folder name for readout speed - declareProperty("Key", m_key, "Key=/PIXEL/ReadoutSpeed"); - // Folder name for cabling map - declareProperty("KeyCabling", m_keyCabling, "Key=/PIXEL/CablingMap"); - // Write out the cabling map to a text file - declareProperty("DumpMapToFile", m_dump_map_to_file = false); } PixelCablingSvc::~PixelCablingSvc() { } @@ -79,72 +27,12 @@ PixelCablingSvc::~PixelCablingSvc() { } StatusCode PixelCablingSvc::initialize() { ATH_MSG_INFO("PixelCablingSvc::initialize()"); - CHECK(m_detStore.retrieve()); + ATH_CHECK(m_detStore.retrieve()); - CHECK(m_detStore->retrieve(m_detManager,"Pixel")); - - CHECK(m_detStore->retrieve(m_idHelper,"PixelID")); - - // Get ToolSvc - IToolSvc* toolSvc; - CHECK(service("ToolSvc",toolSvc)); - - // Print out all values -#ifdef PIXEL_DEBUG - ATH_MSG_DEBUG("-- PixelCablingSvc ------------------------------"); - ATH_MSG_DEBUG("m_final_mapping_file = " << m_final_mapping_file); - ATH_MSG_DEBUG("useMapFromOptions = " << useMapFromOptions); - ATH_MSG_DEBUG("-------------------------------------------------"); -#endif + ATH_CHECK(m_detStore->retrieve(m_detManager,"Pixel")); - // Get the cabling tool - CHECK(m_cablingTool.retrieve()); - - if ((m_mappingType!="COOL") && (m_mappingType!="Final")) { - ATH_MSG_FATAL("Unknown PixelCablingSvc configuration: " << m_mappingType); - return StatusCode::FAILURE; - } - - if (m_mappingType!="COOL") { - if (!m_cablingTool->fillMapFromFile(m_final_mapping_file,m_cabling.get())) { - ATH_MSG_ERROR("Filling pixel cabling from file \"" << m_final_mapping_file << "\" failed"); - return StatusCode::FAILURE; - } - } - - m_context = m_idHelper->wafer_context(); - - // Register readout speed callback - const DataHandle<AthenaAttributeList> attrlist; - if (m_detStore->contains<AthenaAttributeList>(m_key)) { - CHECK(m_detStore->regFcn(&IPixelCablingSvc::IOVCallBack,dynamic_cast<IPixelCablingSvc*>(this),attrlist,m_key)); - } - else { - ATH_MSG_WARNING("Folder " << m_key << " not found, using default readoutspeed" << " values (all modules at SINGLE_40)"); - } + ATH_CHECK(m_detStore->retrieve(m_idHelper,"PixelID")); - // Register cabling map callback - if (m_mappingType=="COOL") { - const DataHandle<AthenaAttributeList> attrlist_cabling; - if (m_detStore->contains<AthenaAttributeList>(m_keyCabling)) { - CHECK(m_detStore->regFcn(&IPixelCablingSvc::IOVCallBack,dynamic_cast<IPixelCablingSvc*>(this),attrlist_cabling,m_keyCabling)); - } - else { - ATH_MSG_WARNING("Folder " << m_keyCabling << " not found, exiting"); - return StatusCode::FAILURE; - } - } - - // Register hitdisccnfg callback - if (m_idHelper->wafer_hash_max()==2048) { - const DataHandle<AthenaAttributeList> attrlist_hdc; - if (m_detStore->contains<AthenaAttributeList>(m_keyFEI4)) { - CHECK(m_detStore->regFcn(&IPixelCablingSvc::IOVCallBack,dynamic_cast<IPixelCablingSvc*>(this),attrlist_hdc,m_keyFEI4)); - } - else { - ATH_MSG_WARNING("Folder " << m_keyFEI4 << " not found, using default HitDiscCnfg" << " values (all FEs at HitDiscCnfg = 3)"); - } - } return StatusCode::SUCCESS; } @@ -165,57 +53,8 @@ StatusCode PixelCablingSvc::queryInterface(const InterfaceID &riid, void** ppvIn return StatusCode::SUCCESS; } -void PixelCablingSvc::getOfflineList(std::vector<IdentifierHash>& offlineIdHashList, int robid) { - std::deque<Identifier> offlineIdList = m_cabling->find_entry_offlineList(robid); - std::deque<Identifier>::iterator it1 = offlineIdList.begin(); - std::deque<Identifier>::iterator it2 = offlineIdList.end(); - for (; it1!=it2;++it1) { - offlineIdHashList.push_back(getOfflineIdHashFromOfflineId(*it1)); - } -} - -Identifier PixelCablingSvc::getOfflineId(uint64_t onlineId) { - return m_cabling->find_entry_onoff(onlineId); -} - -IdentifierHash PixelCablingSvc::getOfflineIdHash(uint64_t onlineId) { - Identifier offlineId = m_cabling->find_entry_onoff(onlineId); - return getOfflineIdHashFromOfflineId(offlineId); -} - -IdentifierHash PixelCablingSvc::getOfflineIdHashFromOfflineId(Identifier offlineId) { - if (offlineId==0) { - return 0xffffffff; //was -1, but Identifier hash is unsigned, so I return the unsigned equivalent (2^32 -1, assuming int is 32 bit) (shaun, 15 may 2008) - } - return m_idHelper->wafer_hash(offlineId); // ->InDetDetDescr/InDetIdentifier:PixelID - get hash identifier -} - -Identifier PixelCablingSvc::getOfflineIdFromDCS(std::string DCSname) { - return m_cabling->find_entry_DCSoffline(DCSname); -} - -uint32_t PixelCablingSvc::getRobId(Identifier offlineId) { - return m_cabling->find_entry_offrob(offlineId); -} - -uint32_t PixelCablingSvc::getRobID(Identifier offlineId) { - return m_cabling->find_entry_offrob(offlineId); -} - -int PixelCablingSvc::getRobId(const int rodid) { - return m_cabling->find_entry_rodrob(rodid); -} - -int PixelCablingSvc::getRodId(const int robid) { - return m_cabling->find_entry_robrod(robid); -} - -uint64_t PixelCablingSvc::getOnlineId(Identifier offlineId) { - return m_cabling->find_entry_offon(offlineId); -} - Identifier PixelCablingSvc::getPixelIdfromHash(IdentifierHash offlineIdHash, uint32_t FE, uint32_t row, uint32_t column) { - return PixelCablingSvc::getPixelId(m_idHelper->wafer_id(offlineIdHash), FE, row, column); + return getPixelId(m_idHelper->wafer_id(offlineIdHash), FE, row, column); } Identifier PixelCablingSvc::getPixelId(Identifier offlineId, uint32_t FE, uint32_t row, uint32_t column) { @@ -245,9 +84,9 @@ Identifier PixelCablingSvc::getPixelId(Identifier offlineId, uint32_t FE, uint32 row = row + column_row_offset; column = column + column_row_offset; - if (row>=rowsPerFE || column>=columnsPerFE || FE>=((thisModule==IBL || thisModule==DBM) ? FEsPerHalfModule:2*FEsPerHalfModule)) { + if (row>=rowsPerFE || column>=columnsPerFE || FE>=((thisModule==IBL_PLANAR || thisModule==IBL_3D || thisModule==DBM) ? FEsPerHalfModule:2*FEsPerHalfModule)) { ATH_MSG_DEBUG("Illegal pixel requested OfflineID: " << std::hex << offlineId << std::dec << " FE: " << FE << " row: " << row << " column: " << column); - ATH_MSG_DEBUG("Limits are: FE < " << ((thisModule == IBL || thisModule == DBM) ? FEsPerHalfModule : 2*FEsPerHalfModule) << ", row < " << rowsPerFE << ", column < " << columnsPerFE); + ATH_MSG_DEBUG("Limits are: FE < " << ((thisModule==IBL_PLANAR || thisModule==IBL_3D || thisModule == DBM) ? FEsPerHalfModule : 2*FEsPerHalfModule) << ", row < " << rowsPerFE << ", column < " << columnsPerFE); return Identifier(); // illegal Identifier, standardized for PixelRodDecoder } @@ -266,7 +105,12 @@ Identifier PixelCablingSvc::getPixelId(Identifier offlineId, uint32_t FE, uint32 } break; - case IBL: + case IBL_PLANAR: + phi_index = rowsPerFE-1-row; + eta_index = FE*columnsPerFE+column; + break; + + case IBL_3D: phi_index = rowsPerFE-1-row; eta_index = FE*columnsPerFE+column; break; @@ -351,7 +195,6 @@ uint32_t PixelCablingSvc::getFE(Identifier *pixelId, Identifier offlineId) { } break; - case IBL: default: // PIX_BARREL + IBL break; } @@ -369,7 +212,7 @@ uint32_t PixelCablingSvc::getFE(Identifier *pixelId, Identifier offlineId) { // For IBL, the above returns FE number in range [2,3] (planar), or [1] (3D sensors). // Change that to be [0,1] (planar) and [0] (3D) for consistency - if (thisModule==IBL) FE = FE - FEsPerHalfModule; + if (thisModule==IBL_PLANAR || thisModule==IBL_3D) { FE = FE - FEsPerHalfModule; } return FE; } @@ -410,7 +253,6 @@ uint32_t PixelCablingSvc::getColumn(Identifier *pixelId, Identifier offlineId) { } break; - case IBL: default: // PIX_BARREL + IBL break; } @@ -484,7 +326,6 @@ uint32_t PixelCablingSvc::getRow(Identifier *pixelId, Identifier offlineId) { } break; - case IBL: default: // PIX_BARREL + IBL break; } @@ -501,7 +342,11 @@ uint32_t PixelCablingSvc::getRow(Identifier *pixelId, Identifier offlineId) { row = rowsPerFE-m_idHelper->eta_index(*pixelId)-1; break; - case IBL: + case IBL_PLANAR: + row = rowsPerFE-1-phi_index; + break; + + case IBL_3D: row = rowsPerFE-1-phi_index; break; @@ -525,196 +370,6 @@ uint32_t PixelCablingSvc::getRow(Identifier *pixelId, Identifier offlineId) { return row + row_offset; } -//////////////////////// -// getFEwrtSlink -// Function to get the number of an FE-I4 within an Slink, -// i.e. pos. value in the range [0,7], corresponding to -// the 'nnn' bits of a fragment header. To get the number -// of an FE within a module, use getFE. -//////////////////////// -uint32_t PixelCablingSvc::getFEwrtSlink(Identifier *pixelId) { - unsigned int nnn = 99; - Identifier offlineId = m_idHelper->wafer_id(*pixelId); - uint64_t onlineId = getOnlineId(offlineId); - uint32_t linkNum = (onlineId>>24) & 0xFFFF; - unsigned int localFE = getFE(pixelId, offlineId); // FE number within module, [0,1]. Increases with increasing eta_index - - if(localFE>1) { - ATH_MSG_FATAL("Unexpected FE: "<<localFE<<" PixelCablingSvc::getFEwrtSlink()"); - throw std::runtime_error("Unexpected FE"); - } - else { - nnn = (linkNum>>(localFE*8)) & 0xF; - } - - // Check for errors - if (nnn>7) { - ATH_MSG_ERROR("Error in the identification of the FE-I4 w.r.t. Slink"); - } - return nnn; -} - -std::vector<uint32_t>& PixelCablingSvc::getAllRods() { - return m_cabling->get_allRods(); -} - -std::vector<uint32_t>& PixelCablingSvc::getAllRobs() { - return m_cabling->get_allRobs(); -} - -StatusCode PixelCablingSvc::IOVCallBack(IOVSVC_CALLBACK_ARGS_P(I, keys)) { - - for (std::list<std::string>::const_iterator key=keys.begin(); key != keys.end(); ++key) { - ATH_MSG_INFO("IOVCALLBACK for key " << *key << " number " << I); - } - - // Clear all the existing map content - m_cabling->clear_all_maps(); - - // First do readout speed - const AthenaAttributeList* attrlist = 0; - - CHECK(m_detStore->retrieve(attrlist,m_key)); - - if (msgLvl(MSG::DEBUG)) { - ATH_MSG_DEBUG("AthenaAttributeList for " << m_key << ":"); - attrlist->print(std::cout); - ATH_MSG_DEBUG(""); - } - - const coral::Blob& blob=(*attrlist)["readoutspeed_per_ROD"].data<coral::Blob>(); - const char* p = static_cast<const char*>(blob.startingAddress()); - unsigned int len = blob.size(); - m_dataString.resize(len); - for (unsigned int i = 0; i!=len; ++i) m_dataString[i] = *p++; - - int pos=0; - while (m_dataString.find(",",pos)!=std::string::npos) { - std::istringstream iss(m_dataString.substr(pos,m_dataString.find(",",pos))); - uint32_t rod; - iss >> std::hex >> rod; - - const std::string speed = m_dataString.substr(m_dataString.find(",",pos)+1,m_dataString.find("\n",pos)-m_dataString.find(",",pos)-1); - if (m_cablingTool->rodReadoutMap.find(rod)==m_cablingTool->rodReadoutMap.end()) { - if (speed!="SINGLE_40") { - m_cablingTool->rodReadoutMap.insert(std::make_pair(rod,true)); - } - } - else { - if (speed!="SINGLE_40") { - m_cablingTool->rodReadoutMap[rod]=true; - } - else { - m_cablingTool->rodReadoutMap[rod]=false; - } - } - pos = m_dataString.find("\n",pos)+1; - } - ATH_MSG_INFO("DONE Callback for " << m_key); - - // Now do cabling map - if (m_mappingType!="COOL") { - if (!m_cablingTool->fillMapFromFile(m_final_mapping_file,m_cabling.get())) { - ATH_MSG_ERROR("Refilling pixel cabling from file \"" << m_final_mapping_file << "\" failed"); - return StatusCode::FAILURE; - } - ATH_MSG_INFO("Refilled pixel cabling from file \"" << m_final_mapping_file << "\""); - } - else { - attrlist = 0; - - CHECK(m_detStore->retrieve(attrlist,m_keyCabling)); - - if (msgLvl(MSG::DEBUG)) { - ATH_MSG_DEBUG("AthenaAttributeList for " << m_keyCabling << ":"); - attrlist->print(std::cout); - ATH_MSG_DEBUG(""); - } - - const coral::Blob& blob_cabling=(*attrlist)["CablingMapData"].data<coral::Blob>(); - const char* p_cabling = static_cast<const char*>(blob_cabling.startingAddress()); - - unsigned int len_cabling = blob_cabling.size()/sizeof(char); - ATH_MSG_DEBUG("blob_cabling.size() = " << blob_cabling.size() << ", len_cabling = " << len_cabling); - - bool stat = m_cablingTool->fillMapFromCool(p_cabling, blob_cabling.size(), m_cabling.get(), m_dump_map_to_file); - - if (!stat) { - ATH_MSG_ERROR("Callback to CablingMap failed, map was not filled"); - return StatusCode::FAILURE; - } - else { - ATH_MSG_INFO("Refilled cabling map"); - } - } - - // Now do HDC - if (m_idHelper->wafer_hash_max()==2048) { - attrlist = 0; - - CHECK(m_detStore->retrieve(attrlist,m_keyFEI4)); - - if (msgLvl(MSG::DEBUG)) { - ATH_MSG_DEBUG("AthenaAttributeList for " << m_keyFEI4 << ":"); - attrlist->print(std::cout); - ATH_MSG_DEBUG(""); - } - - const coral::Blob& blob_hdc=(*attrlist)["HitDiscCnfgData"].data<coral::Blob>(); - const uint32_t* p_hdc = static_cast<const uint32_t*>(blob_hdc.startingAddress()); - - uint32_t cooldata; - unsigned int len_hdc = blob_hdc.size()/sizeof(uint32_t); - ATH_MSG_DEBUG("blob_hdc.size() = " << blob_hdc.size() << ", len_hdc = " << len_hdc); - - - for (unsigned int i = 0; i < len_hdc; ++i) { - cooldata = *p_hdc++; - ATH_MSG_DEBUG("Got hitdisccnfgData[" << i << "] = 0x" << std::hex << cooldata << std::dec); - - // The implementation below uses one common value, one common 3D value, - // and an exception list of individual FEs, in order to save DB space. - // Here we convert this into only one common value and an exception list, i.e. - // if the 3D FEs have a different common value they are all added to the exception list - - // Update the most common value, identified by 0xH0000000, where H = 00HH - if ((cooldata & 0x8FFFFFFF) == 0x0) { - ATH_MSG_DEBUG("Setting common HitDiscCnfg value to " << ((cooldata&0x30000000) >> 28)); - m_cabling->setCommonHitDiscCngf((cooldata&0x30000000) >> 28); - } - - // Update all 3D sensors with a common value, identified by 0xZ0000000, where Z = 10hh - else if ((cooldata & 0x8FFFFFFF) == 0x80000000) { - ATH_MSG_DEBUG("Setting common 3D HitDiscCnfg value to " << ((cooldata&0x30000000) >> 28)); - - // Loop over list of robs, find the 3D sensors and insert them in HitDiscCnfg map - for (auto robid : m_cabling->get_allRobs()) { - // Skip non-IBL ROBs (DBM is not affected by the common 3D value) - if (!isIBL(robid)) { continue; } - - for (int link = 0 ; link < 8 ; ++link) { - if (((robid&0xF)==1 && link > 3) || (((robid&0xF)==2) && link < 4)) { - m_cabling->add_entry_HitDiscCnfg((robid | (link >> 24)), (cooldata & 0x30000000) >> 28); - } - } - } - } - - // Update a single link, 0xHLDDRRRR - else { - ATH_MSG_DEBUG("Setting HitDiscCnfg value to " << ((cooldata&0x30000000) >> 28) << " for ROB 0x" << std::hex << (cooldata & 0xFFFFFF) << ", link " << std::dec << ((cooldata & 0xF000000) >> 24)); - m_cabling->add_entry_HitDiscCnfg((cooldata & 0xFFFFFFF), (cooldata & 0x30000000) >> 28); - } - } - ATH_MSG_INFO("Refilled HitDiscCnfg values"); - } - return StatusCode::SUCCESS; -} - -uint64_t PixelCablingSvc::getOnlineIdFromRobId(const uint32_t robId, const uint32_t link_module) { - return m_cabling->getOnlineIdFromRobId(robId, link_module); -} - unsigned int PixelCablingSvc::getLocalFEI4(const uint32_t fe, const uint64_t onlineId) { unsigned int linknum40 = (onlineId>>24) & 0xFF; unsigned int linknum80 = (onlineId>>32) & 0xFF; @@ -731,54 +386,26 @@ unsigned int PixelCablingSvc::getLocalFEI4(const uint32_t fe, const uint64_t onl return 0xF; } -bool PixelCablingSvc::isIBL(const uint32_t robId) { - // IBL subdetector ID is 0x14 - if (((robId>>16) & 0xFF)==0x14) { - return true; - } - else { - return false; - } -} - -bool PixelCablingSvc::isIBL(const Identifier& id) { - // If IBL is present, an IBL pixelId will have barrel_ec = layer_disk = 0 - if (m_idHelper->wafer_hash_max()==2048 && m_idHelper->barrel_ec(id)==0 && m_idHelper->layer_disk(id)==0) { - return true; - } - else { - return false; - } -} - -bool PixelCablingSvc::isDBM(const uint32_t robId) { - // DBM subdetector ID is 0x15 - if (((robId>>16) & 0xFF)==0x15) { - return true; - } - else { - return false; - } -} - -bool PixelCablingSvc::isDBM(const Identifier& id) { - return m_idHelper->is_dbm(id); -} - PixelCablingSvc::moduletype PixelCablingSvc::getModuleType(const Identifier& id) { moduletype isType = NONE; - if (isIBL(id)) { - isType = IBL; + const Identifier wafer_id = m_idHelper->wafer_id(id); + const InDetDD::SiDetectorElement *element = m_detManager->getDetectorElement(wafer_id); + const InDetDD::PixelModuleDesign *p_design = static_cast<const InDetDD::PixelModuleDesign*>(&element->design()); + + if (p_design->getReadoutTechnology()==InDetDD::PixelModuleDesign::FEI4) { + if (p_design->numberOfCircuits()==2) { isType = IBL_PLANAR; } + else { isType = IBL_3D; } + + if (m_idHelper->is_dbm(id)) { isType = DBM; } } - else if (m_idHelper->is_dbm(id)) { - isType = DBM; + else if (p_design->getReadoutTechnology()==InDetDD::PixelModuleDesign::FEI3) { + if (abs(m_idHelper->barrel_ec(id))==0) { isType = PIX_BARREL; } + else if (abs(m_idHelper->barrel_ec(id))==2) { isType = PIX_ENDCAP; } + else { isType = NONE; } } else { - if (abs(m_idHelper->barrel_ec(id))==2) { - isType = PIX_ENDCAP; - } - else isType = PIX_BARREL; + isType = NONE; } return isType; } @@ -841,27 +468,3 @@ PixelCablingSvc::pixeltype PixelCablingSvc::getPixelType(const Identifier& id) { return isType; } -int PixelCablingSvc::getHitDiscCnfg(const uint32_t robId, const int link) { - return m_cabling->getHitDiscCnfg((link<<24) | robId); -} - -int PixelCablingSvc::getHitDiscCnfg(Identifier* pixelId) { - uint32_t robId = getRobId(m_idHelper->wafer_id(*pixelId)); - int link = -999; - try { - link = getFEwrtSlink(pixelId); - } - catch(std::exception& ex) { - ATH_MSG_FATAL("Exception caught in PixelCablingSvc::getFEwrtSlink(): "<<ex.what()); - } - return getHitDiscCnfg(robId, link); -} - -int PixelCablingSvc::getIBLOverflowToT(Identifier* pixelId) { - int HitDiscCnfg = getHitDiscCnfg(pixelId); - if (HitDiscCnfg==0) { return 14; } - if (HitDiscCnfg==1) { return 15; } - if (HitDiscCnfg==2) { return 16; } - return 16; -} - diff --git a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingSvc.h b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingSvc.h index b4d1bb789b63fe36d0c4d5791e670be15eddcf37..dd58a290c474575d89c8ce6503d3e52e9c5fe104 100644 --- a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingSvc.h +++ b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelCablingSvc.h @@ -1,87 +1,12 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -/////////////////////////////////////////////////////////////////// -// PixelCablingSvc.h -// Header file for class PixelCablingSvc -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -// Class used to get offlineIDs from their onlineIDs -// - getOfflineList() - get list of offlineIds from the RobId -// - getOfflineId() - get the offlineId from the onlineId -// - getRobId() - get RobId from offlineId -// - getRobId() - get RobId from RodId -// - getOnlineId() - get onlineId from offlineId -// - getPixelId() - get the pixelId from the offlineId, FE, row and column -// - getFE() - get the FE from the pixelId and offlineId -// - getColumn() - get the column number from the pixelId and offlineId -// - getRow() - get the row number from the pixelId and offlineId -/////////////////////////////////////////////////////////////////// -// Florian Hirsch -/////////////////////////////////////////////////////////////////// - #ifndef PIXELCABLINGSVC_H #define PIXELCABLINGSVC_H #include "PixelCabling/IPixelCablingSvc.h" #include "AthenaBaseComps/AthService.h" -#include "GaudiKernel/ServiceHandle.h" -#include "Identifier/IdContext.h" -#include "GaudiKernel/ToolHandle.h" -#include "PixelCablingData.h" -#include <map> -#include <deque> -#include <stdint.h> -#include <string> -#include <vector> -#include <memory> - -class StatusCode; -class ISvcLocator; -class PixelID; -class PixelCablingData; -class Identifier; -class IdentifierHash; -class StoreGateSvc; -class PixelFillCablingData; - -/** - * The PixelCablingSvc class keeps track of the cabling map for pixels, - * IBL and DBM, and does the conversion between online and offline identifiers - * In the context of the pixel bytestream converter, an online identifier is - * a 64-bit unsigned integer, formatted as 0xAABBDDMMMM, where MMMM = robId, - * DD = subdetector id, AABB = link number. For pixels, there is only one link - * number per onlineId, so AA = 00. See PixelCablingData::getOnlineIdFromRobId. - * The offline id is the standard Identifier class. - * - * Technically, the cabling map is contained in the PixelCablingData class, - * and its contents is filled by the PixelFillCablingData class. However - * everything should be interface through PixelCablingSvc and not accessed - * directly. - * - * The setProperty configurables of the class are: - * - MappingType: Two choices available: - * - "COOL": Read cabling map from COOL (recommended) - * - "Final": Read map from text file in /share (for MC and Run-1) - * - MappingFile: Name of the file in /share that will be used if the - * mapping type is "Final". If reading from COOL, the database is not - * available at time of initialization, therefore a text file is always - * read. However the mapping is overwritten once COOL is connected. - * - Key: Name of readoutspeed folder - * - KeyFEI4: Name of the HitDiscCnfg folder - * - KeyCabling: Name of the cabling map folder - * - * The following are not used anymore (setting them does nothing): - * Bandwidth, Coral_Connectionstring, DictionaryTag, ConnectivityTag - * - * Developers in the period 2014-2016 are - * Mapo Giordani - * Steffen Maeland - * Laura Franconi - * - */ namespace InDetDD { class PixelDetectorManager; @@ -89,138 +14,31 @@ namespace InDetDD { class PixelCablingSvc: virtual public IPixelCablingSvc, public AthService { -public: - - /** Constructor */ - PixelCablingSvc(const std::string& name, ISvcLocator* svc ) ; - - /** Copy constructor */ - //PixelCablingSvc(const PixelCablingSvc &other, const std::string& name, ISvcLocator*svc); - - /** Assignment operator */ - //PixelCablingSvc& operator= (const PixelCablingSvc &other); - - /** Destructor */ - ~PixelCablingSvc(); - - /** Initialize the tool, fill cabling map */ - StatusCode initialize(); - - /** Finialize */ - StatusCode finalize(); - - /** Callback to update maps */ - StatusCode IOVCallBack(IOVSVC_CALLBACK_ARGS); - - StatusCode queryInterface(const InterfaceID & riid, void** ppvInterface ); - - /** Get a list of offlineIds from a RobId. */ - void getOfflineList(std::vector<IdentifierHash>& offlineIdHashList, int robid); - - /** @name Functions to get the offline identifier */ - ///@{ - Identifier getOfflineId(uint64_t onlineId); - IdentifierHash getOfflineIdHash(uint64_t onlineId); - IdentifierHash getOfflineIdHashFromOfflineId(Identifier offlineId); - Identifier getOfflineIdFromDCS(std::string DCSname); - ///@} - - /** Get RobId from a certain offlineId */ - uint32_t getRobId(Identifier offlineId); - - /** For backward compatibility, don't use */ - uint32_t getRobID(Identifier offlineId); - - /** Get ROB Id from a ROD Id */ - int getRobId(const int rodId); - - /** Get ROD Id from a ROB Id */ - int getRodId(const int robId); - - /** Get onlineId from a offlineId */ - uint64_t getOnlineId(Identifier offlineId); - - /** Get onlineId from rodId + link or module number */ - uint64_t getOnlineIdFromRobId(const uint32_t robId, const uint32_t link_module); - - Identifier getPixelIdfromHash(IdentifierHash offlineIdHash, uint32_t FE, uint32_t row, uint32_t column); - Identifier getPixelId(Identifier offlineId, uint32_t FE, uint32_t row, uint32_t column); - - /** @name Functions to get various properties for given pixelId - * (the offlineId is redundant info here, so these functions - * could technically be simplified.) - */ - ///@{ - uint32_t getFE(Identifier* pixelId, Identifier offlineId); - uint32_t getColumn(Identifier* pixelId, Identifier offlineId); - uint32_t getRow(Identifier* pixelId, Identifier offlineId); - uint32_t getFEwrtSlink(Identifier*pixelId); - unsigned int getLocalFEI4(const uint32_t fe, const uint64_t onlineId); - ///@} + public: + PixelCablingSvc(const std::string& name, ISvcLocator* svc ) ; - /** @name Functions to retrieve the FE-I4 HitDiscCnfg setting */ - ///@{ - int getHitDiscCnfg(const uint32_t robId, const int link); - int getHitDiscCnfg(Identifier* pixelId); - int getIBLOverflowToT(Identifier* pixelId); - ///@} - /// - /** @name Functions to check the type of subdetector for a - * given ROB id or for a given Identifier - */ - ///@{ - bool isIBL(const uint32_t robId); - bool isIBL(const Identifier& id); - bool isDBM(const uint32_t robId); - bool isDBM(const Identifier& id); + ~PixelCablingSvc(); + StatusCode initialize(); + StatusCode finalize(); - /** Get type of module - * @param id The offline identifier of the module - * @return Enumerator moduletype, see IPixelCablingSvc.h - */ - moduletype getModuleType(const Identifier& id); - pixeltype getPixelType(const Identifier& id); + StatusCode queryInterface(const InterfaceID & riid, void** ppvInterface ); - ///@} + Identifier getPixelIdfromHash(IdentifierHash offlineIdHash, uint32_t FE, uint32_t row, uint32_t column); + Identifier getPixelId(Identifier offlineId, uint32_t FE, uint32_t row, uint32_t column); - /** Return a vector containing all RODs in the cabling map */ - std::vector<uint32_t>& getAllRods(); - /** Return a vector containing all ROBs in the cabling map */ - std::vector<uint32_t>& getAllRobs(); + uint32_t getFE(Identifier* pixelId, Identifier offlineId); + uint32_t getColumn(Identifier* pixelId, Identifier offlineId); + uint32_t getRow(Identifier* pixelId, Identifier offlineId); + unsigned int getLocalFEI4(const uint32_t fe, const uint64_t onlineId); - /** @name Wrappers to PixelCablingData. Returns the std::map of interest. */ - ///@{ - std::map< uint64_t, Identifier > get_idMap_onoff() {return m_cabling->get_idMap_onoff();} - std::map< Identifier, uint64_t> get_idMap_offon() {return m_cabling->get_idMap_offon();} - std::map< Identifier, uint32_t> get_idMap_offrob() {return m_cabling->get_idMap_offrob();} - std::map< int,int> get_idMap_rodrob() {return m_cabling->get_idMap_rodrob();} - std::map< int,int> get_idMap_robrod() {return m_cabling->get_idMap_robrod();} - std::map< std::string, Identifier> get_idMapDCSoff() {return m_cabling->get_idMapDCSoff();} - ///@} - -private: - ToolHandle<PixelFillCablingData> m_cablingTool; - ServiceHandle< StoreGateSvc > m_detStore; - const InDetDD::PixelDetectorManager *m_detManager; - const PixelID* m_idHelper; - std::unique_ptr<PixelCablingData> m_cabling; + moduletype getModuleType(const Identifier& id); + pixeltype getPixelType(const Identifier& id); - IdContext m_context; + private: + ServiceHandle< StoreGateSvc > m_detStore; + const InDetDD::PixelDetectorManager *m_detManager; + const PixelID* m_idHelper; - /** @name The setProperty configurables */ - ///@{ - std::string m_dataString ; - std::string m_key; - std::string m_keyFEI4; - std::string m_keyCabling; - std::string m_mappingType; - std::string m_final_mapping_file; - int m_bandwidth; - std::string m_coraldbconnstring; - std::string m_dictTag; - std::string m_connTag; - bool m_dump_map_to_file; - ///@} }; -#endif // PIXELCABLINGSVC_H +#endif diff --git a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelConstants.h b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelConstants.h deleted file mode 100755 index c2c678b087e0cc4d499f6fcaeb643292cda4ccdd..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelConstants.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////////// -// Constants -//===================================================================== -// Description: A file defining some constants needed by the -// SiTracker Digit byte stream converter package. -//--------------------------------------------------------------------- -// K. Karr, 03.02.2002 -//--------------------------------------------------------------------- -// Changes: J. Schieck, 27.05.2002 -// -Added SCT information -/////////////////////////////////////////////////////////////////////// - -#ifndef SITRACKER_DIGIT_BYTESTREAMCONVERTER_CONSTANTS_H -#define SITRACKER_DIGIT_BYTESTREAMCONVERTER_CONSTANTS_H - -// SiTracker detector subsystem identifier numbers used by ATLAS -// raw event format. -const int PIXEL_SDET_ID = 0x10; -const int SCT_SDET_BARREL_ID = 0x20; -const int SCT_SDET_ECL_ID = 0x21; -const int SCT_SDET_ECR_ID = 0x22; - -// PixelMUR2TEMapper detector description constants. -const int PIXEL_BARREL_ID = 0; -const int PIXEL_BARREL_HALF_ID_MIN = 0; -const int PIXEL_BARREL_HALF_ID_MAX = 1; -const int PIXEL_BARREL_NUM_PHI_PER_MUR = 1; -const int PIXEL_ENDCAP_ID = 2; -const int PIXEL_ENDCAP_NUM_PHI_PER_MUR = 6; - -// Pixel wafer TEID overflow check. -const unsigned int PIXEL_BARREL_TEID_MAX = 0x1000; -const unsigned int PIXEL_ENDCAP_TEID_MAX = 0x4000; - -// Pixel wafer REID overflow check. -const unsigned int PIXEL_BARREL_REID_MAX = 0x1000; -const unsigned int PIXEL_ENDCAP_REID_MAX = 0x1000; - -// Pixel ROBID overflow check. -const int PIXEL_ROBID_MAX = 0x1000; - -// Pixel wafer StoreGate key overflow check. -const int PIXEL_WAFER_KEY_OFFSET = 0; -const int PIXEL_WAFER_KEY_MAX = 3218 + PIXEL_WAFER_KEY_OFFSET; - -// SCTMUR2TEMapper detector description constants. -const int SCT_BARREL_ID = 0; -const int SCT_BARREL_HALF_ID_MIN = 0; -const int SCT_BARREL_HALF_ID_MAX = 1; -const int SCT_BARREL_NUM_PHI_PER_MUR = 1; -const int SCT_ENDCAP_ID = 2; -const int SCT_ENDCAP_MUR_OFFSET_OUTRING = 13; -const int SCT_ENDCAP_NUM_PHI_PER_MUR_OUTRING = 6; -const int SCT_ENDCAP_NUM_PHI_PER_MUR_INRINGS = 5; - -// SCT wafer TEID overflow check. -const unsigned int SCT_BARREL_TEID_MAX = 0x2000; -const unsigned int SCT_ENDCAP_TEID_MAX = 0x8000; - -// SCT wafer REID overflow check. -const unsigned int SCT_BARREL_REID_MAX = 0x4000; -const unsigned int SCT_ENDCAP_REID_MAX = 0x400000; - -// SCT ROBID overflow check. -const int SCT_ROBID_MAX = 0x1000; - -// SCT wafer StoreGate key overflow check. -const int SCT_WAFER_KEY_OFFSET = 5000; -const int SCT_WAFER_KEY_MAX = 9328 + SCT_WAFER_KEY_OFFSET; - -// Maximum REID value. -const unsigned int REID_MAX = 0x400000; - -#endif // SITRACKER_DIGIT_BYTESTREAMCONVERTER_CONSTANTS_H diff --git a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelFillCablingData.cxx b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelFillCablingData.cxx deleted file mode 100644 index 633a40257b692ad8e0d996426e6e739bbd7183da..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelFillCablingData.cxx +++ /dev/null @@ -1,264 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelFillCablingData.h -// Header file for class PixelFillCablingData -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -// A replacement for the classes PixelFillCablingData_Final and -// PixelFillCablingData_CoralDB. -// This class reads the mapping info either from Cool (for Run2) -// or from a text file (MC and Run1) -/////////////////////////////////////////////////////////////////// - - -#include "PixelFillCablingData.h" - -#include <iostream> -#include <fstream> -#include <sstream> - -#include "PathResolver/PathResolver.h" -#include "Identifier/Identifier.h" -#include "eformat/SourceIdentifier.h" - -// Classes -#include "PixelCablingData.h" -#include "InDetIdentifier/PixelID.h" - - -using eformat::helper::SourceIdentifier; -static const InterfaceID IID_IPixelFillCablingData("PixelFillCablingData", 1, 0); - - -//////////////////////// -// constructor -//////////////////////// -PixelFillCablingData::PixelFillCablingData( const std::string& type, const std::string& name,const IInterface* parent) - : AthAlgTool(type, name, parent), m_idHelper(0) -{ - declareInterface< PixelFillCablingData >( this ); -} - -//////////////////////// -// destructor -//////////////////////// -PixelFillCablingData::~PixelFillCablingData() -{ } - -//////////////////////// -// interfaceID -//////////////////////// -const InterfaceID& PixelFillCablingData::interfaceID() -{ - return IID_IPixelFillCablingData; -} - - -//////////////////////// -// initialize -//////////////////////// -StatusCode PixelFillCablingData::initialize() -{ - StatusCode sc; - ATH_MSG_DEBUG("PixelFillCablingData::initialize"); - - // Get the PixelID Helper - CHECK(detStore()->retrieve(m_idHelper,"PixelID")); - m_cntxpixel = m_idHelper->wafer_context(); - - - return sc; -} - - - -//////////////////////// -// fill from text file -//////////////////////// -bool PixelFillCablingData::fillMapFromFile(const std::string infilename, PixelCablingData* cabling) -{ - std::string filename = PathResolverFindCalibFile(infilename); - if (filename.size() == 0) { - ATH_MSG_FATAL("Mapping File: " << infilename << " not found!"); - return false; - } - - std::ifstream fin(filename.c_str()); - if (!fin) return false; - - return parseAndFill(fin,cabling); -} - - - -//////////////////////// -// fill from COOL -//////////////////////// -bool PixelFillCablingData::fillMapFromCool(const char* data, unsigned int size, PixelCablingData* cabling, bool dump_map_to_file) //FIXME: use std::string -{ - if (!data) return false; - std::stringstream instr; - - //The detour via std::string make the code resiliant against missing c-string termination - instr.str(std::string(data,size)); - - return parseAndFill(instr, cabling, dump_map_to_file); -} - - - -//////////////////////// -// fill map from stream -//////////////////////// -bool PixelFillCablingData::parseAndFill(std::istream &instr, PixelCablingData* cabling, bool dump_map_to_file) -{ - - // Signed values - int barrel_ec, eta_module; - - // Unsigned 32 bit values - uint32_t layer_disk, phi_module; - uint32_t robid, rodid; - uint32_t sl_40_fmt, sl_40_link, sl_80_fmt, sl_80_link; - - // Unsigned 64-bit values - uint64_t onlineId = 0; - uint64_t linknumber = 0; - - // Strings - std::string DCSname; - std::string line; - - // For debugging purposes - std::ofstream output_mapping_file_raw; - if (dump_map_to_file) output_mapping_file_raw.open("pixel_cabling_map_raw.txt"); - std::ofstream output_mapping_file_interpreted; - if (dump_map_to_file) output_mapping_file_interpreted.open("pixel_cabling_map_interpreted.txt"); - - // Each entry in the mapping is sepated by a newline. - // Loop over all lines and parse the values - - while (instr.good() && getline(instr, line)) { - - if (dump_map_to_file) output_mapping_file_raw << line << std::endl; - - // Skip empty lines and comments (i.e. starting with a hash or a space) - if (line.size() == 0) continue; - if (line.substr(0,1) == " " || line.substr(0,1) == "#") continue; - - // There are 11 columns, so there must be at least 21 characters in a valid line. - if (line.length() < 21) continue; - - // If reading from COOL, skip the datestamp - if (line.substr(line.length()-3, line.length()) == "GMT") continue; - - std::istringstream parse(line); - parse >> barrel_ec >> layer_disk >> phi_module >> eta_module >> std::hex - >> robid >> rodid >> sl_40_fmt >> sl_40_link >> sl_80_fmt - >> sl_80_link >> DCSname; - - // Debug - if (dump_map_to_file) { - output_mapping_file_interpreted << barrel_ec << "\t" << layer_disk << "\t" << phi_module << "\t" - << eta_module << "\t" << std::hex << robid << "\t" << rodid << "\t" - << sl_40_fmt << "\t" << sl_40_link << "\t" << sl_80_fmt << "\t" - << sl_80_link << "\t" << DCSname << std::dec << std::endl; - } - - - // Get the offline ID for this module - Identifier offlineId = m_idHelper->wafer_id(barrel_ec, layer_disk, phi_module, eta_module); - - // Set linknumber for IBL / DBM entries - if ((robid & 0xFFFFFF) >= 0x140000) { - linknumber = sl_40_link | (sl_40_fmt << 4) | (sl_80_link << 8) | (sl_80_fmt << 12); - } - // Set linknumber for pixel entries - else { - bool readoutSpeed = false; - if (rodReadoutMap.find(rodid) != rodReadoutMap.end()) - readoutSpeed = rodReadoutMap[rodid]; - - if (readoutSpeed == false) linknumber = (sl_40_link & 0xF) | ((sl_40_fmt & 0xF) << 4); - else linknumber = (sl_80_link & 0xF) | ((sl_80_fmt & 0xF) << 4); - } - - - // Compute onlineId - onlineId = (robid & 0xFFFFFF) | (linknumber << 24); - - IdentifierHash hashId; - - // Do checks to verify consistency - if (m_idHelper->get_hash(offlineId, hashId, &m_cntxpixel)) ATH_MSG_WARNING("Could not get hash from offlineId"); - if (hashId > m_idHelper->wafer_hash_max()) { - - ATH_MSG_ERROR("IdHash overflow! HashId is 0x" << std::hex << hashId); - ATH_MSG_ERROR("not mapped OfflineID: " << std::hex << offlineId << std::dec << " barrel_ec: " << barrel_ec - << " layer_disk: " << layer_disk << " phi_module: " << phi_module << " eta_module: " << eta_module); - ATH_MSG_ERROR("to OnlineID: 0x" << std::hex << onlineId << " robid: 0x" << robid << " rodid: 0x" << rodid << std::dec - << " link: 0x" << std::hex /*<< link*/ << " -> Linknumber: 0x" << linknumber << " HashId: 0x" - << hashId << std::dec); - - // Check if offlineId fail was caused by exceeding eta_module range - if (eta_module > m_idHelper->eta_module_max(offlineId) || eta_module < m_idHelper->eta_module_min(offlineId)) { - // eta_module_max == -999 indicates the module does not exist - if (m_idHelper->eta_module_max(offlineId) == -999 && m_idHelper->eta_module_min(offlineId) == -999) { - ATH_MSG_ERROR("Module does not exist in geometry"); - } - else { - ATH_MSG_ERROR("eta_module range exceeded: Got eta_module = " << eta_module - << ", but allowed range is [" << m_idHelper->eta_module_min(offlineId) - << "," << m_idHelper->eta_module_max(offlineId) << "]"); - ATH_MSG_ERROR("Input geometry tag may not be compatible with mapping file"); - } - } - - return false; - } - - // Fill the maps - cabling->add_entry_onoff(onlineId, offlineId); - cabling->add_entry_offon(offlineId, onlineId); - cabling->add_entry_offlineList(robid,offlineId); - cabling->add_entry_offrob(offlineId, robid); - cabling->add_entry_rodrob(rodid, robid); - cabling->add_entry_robrod(robid, rodid); - cabling->add_entry_DCSoffline(DCSname, offlineId); - - - // Debug messages - ATH_MSG_DEBUG("Mapped offlineID: " << std::hex << offlineId << " to onlineID: 0x" << onlineId - << ", robID: 0x" << robid << ", barrel_ec: " << std::dec << barrel_ec << ", layer_disk: " << layer_disk - << ", eta_module: " << eta_module << ", phi_module: " << phi_module << ", linknumber: 0x" << std::hex << linknumber); - - - } - - if (dump_map_to_file) { - output_mapping_file_raw.close(); - output_mapping_file_interpreted.close(); - } - - ATH_MSG_DEBUG("Size of ROD readoutspeed map: " << rodReadoutMap.size()); - cabling->set_readout_map(rodReadoutMap); - return true; - -} - - - - - -//////////////////////// -// finalize -//////////////////////// -StatusCode PixelFillCablingData::finalize() -{ - StatusCode sc = AlgTool::finalize(); - return sc; -} diff --git a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelFillCablingData.h b/InnerDetector/InDetDetDescr/PixelCabling/src/PixelFillCablingData.h deleted file mode 100644 index 04140ca57a2d43cd458bcd513c46f2da7255d2df..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetDetDescr/PixelCabling/src/PixelFillCablingData.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelFillCablingData.h -// Header file for class PixelFillCablingData -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef PIXELFILLCABLINGDATA_H -#define PIXELFILLCABLINGDATA_H - -#include "AthenaBaseComps/AthAlgTool.h" -#include "Identifier/IdContext.h" - -#include <map> -#include <stdint.h> -#include <string> -#include <istream> - -class PixelCablingData; -class PixelID; - -/** - * Class to fill the maps in PixelCablingData, either from a text file or from - * the COOL database. - * - * The old classes PixelFillCablingData_Final and PixelFillCablingData_CoralDB - * have been replaced by this one. - */ -class PixelFillCablingData : public AthAlgTool -{ - - public: - - /** Constructor */ - PixelFillCablingData( const std::string& type, const std::string& name, const IInterface* parent); - - /** Destructor */ - virtual ~PixelFillCablingData(); - - /** AlgTool InterfaceID */ - static const InterfaceID& interfaceID(); - - virtual StatusCode initialize(); - virtual StatusCode finalize(); - - /** Fill cabling map from text file (mainly for MC and Run-1) - * @param filename The text file to be read, must be located - * in the PixelCabling/share/ directory - * @return Pointer to filled instance of PixelCablingData - */ - bool fillMapFromFile(const std::string filename, PixelCablingData* cabling); - - /** Fill cabling map from COOL database (for Run-2 onwards, - * where the CablingMap folder is available) - * @param data Pointer to the starting address of the - * coral::Blob to be read - * @param dump_map_to_file Option to write the mapping info - * read from COOL into a text file for debugging - * @return Pointer to filled instance of PixelCablingData - */ - bool fillMapFromCool(const char* data, unsigned int size, PixelCablingData* cabling, bool dump_map_to_file = false); - - /** Function to fill the map by parsing input istream */ - bool parseAndFill(std::istream& instr, PixelCablingData* cabling ,bool dump_map_to_file = false); - - - /** Set the mapping file to read from */ - inline void setMappingFile(std::string file) {m_mapping_file = file;} - - std::map<uint32_t,bool> rodReadoutMap; // save readout speed for each ROD. Is set to 40 MBit (false) by default - - private: - - IdContext m_cntxpixel; - std::string m_mapping_file; - const PixelID* m_idHelper; - - -}; - -#endif // PIXELFILLCABLINGDATA_H diff --git a/InnerDetector/InDetDetDescr/PixelCabling/src/components/PixelCabling_entries.cxx b/InnerDetector/InDetDetDescr/PixelCabling/src/components/PixelCabling_entries.cxx index 5650c1a402bdd7c1f8aceb0af6538f9b1e0d1d62..447efb793a95f409d58d1747afcd71948dceb575 100644 --- a/InnerDetector/InDetDetDescr/PixelCabling/src/components/PixelCabling_entries.cxx +++ b/InnerDetector/InDetDetDescr/PixelCabling/src/components/PixelCabling_entries.cxx @@ -1,7 +1,4 @@ -#include "../PixelFillCablingData.h" #include "../PixelCablingSvc.h" - -DECLARE_COMPONENT( PixelFillCablingData ) DECLARE_COMPONENT( PixelCablingSvc ) diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/CMakeLists.txt b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/CMakeLists.txt index bc7dcdaf0527d461377564c83835220318ae064e..37bfe11771e2c2e1b180b380916f1d4bf880bf84 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/CMakeLists.txt +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/CMakeLists.txt @@ -23,6 +23,7 @@ atlas_depends_on_subdirs( InnerDetector/InDetDetDescr/InDetIdentifier InnerDetector/InDetDetDescr/InDetReadoutGeometry InnerDetector/InDetDetDescr/PixelCabling + InnerDetector/InDetConditions/PixelConditionsData Event/xAOD/xAODEventInfo Trigger/TrigEvent/TrigSteeringEvent ) @@ -42,5 +43,5 @@ atlas_add_component( PixelRawDataByteStreamCnv LINK_LIBRARIES ${TDAQ-COMMON_LIBRARIES} ByteStreamData GaudiKernel InDetRawData AthenaBaseComps AthContainers StoreGateLib ByteStreamCnvSvcBaseLib InDetIdentifier InDetReadoutGeometry IRegionSelector - xAODEventInfo TrigSteeringEvent PixelRawDataByteStreamCnvLib ) + xAODEventInfo TrigSteeringEvent PixelConditionsData PixelRawDataByteStreamCnvLib ) diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamCnv.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamCnv.cxx index 060f913598d9a8788a732f1f0c350c065f7d6a50..8929df71b1f2e3ee832d573d47d9356c025891cb 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamCnv.cxx +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamCnv.cxx @@ -18,7 +18,6 @@ #include "PixelRawContByteStreamCnv.h" #include "ByteStreamCnvSvcBase/ByteStreamAddress.h" -#include "PixelCabling/IPixelCablingSvc.h" #include "PixelRawContByteStreamTool.h" #include "ByteStreamCnvSvcBase/ByteStreamCnvSvcBase.h" #include "InDetRawData/PixelRDORawData.h" diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamTool.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamTool.cxx index 7d9636db244e8e8a7422a6245c7377e80ef5cc53..417bce947e034589bca45dfed8487d3c6761479c 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamTool.cxx +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -14,13 +14,8 @@ #include "PixelRawContByteStreamTool.h" -#include "PixelCabling/IPixelCablingSvc.h" -#include "InDetIdentifier/PixelID.h" -#include "ByteStreamCnvSvcBase/SrcIdMap.h" -#include "PixelRodEncoder.h" - -#include <map> - +//#define PIXEL_DEBUG ; +//#define PLOTS ; //////////////////////// // constructor @@ -46,35 +41,23 @@ PixelRawContByteStreamTool::~PixelRawContByteStreamTool() { //////////////////////// StatusCode PixelRawContByteStreamTool::initialize() { - StatusCode sc = AthAlgTool::initialize(); - - IToolSvc* toolSvc; - if(StatusCode::SUCCESS != service("ToolSvc",toolSvc)) { - m_log << MSG::ERROR << "Can't get ToolSvc" << endmsg; - return StatusCode::FAILURE; - } - - std::string toolType ; + ATH_CHECK(m_pixelCabling.retrieve()); - if (m_pixelCabling.retrieve().isFailure()) { - m_log << MSG::ERROR << "Can't get PixelCablingSvc" << endmsg; - return StatusCode::FAILURE; - } - - // Get PixelID ATH_CHECK(detStore()->retrieve(m_PixelID, "PixelID")); ATH_CHECK(detStore()->retrieve(m_pixelManager, "Pixel")); + + ATH_CHECK(m_condCablingKey.initialize()); + ATH_CHECK(m_condHitDiscCnfgKey.initialize()); - return sc; + return StatusCode::SUCCESS; } //////////////////////// // finalize //////////////////////// StatusCode PixelRawContByteStreamTool::finalize() { - StatusCode sc = AthAlgTool::finalize(); - return sc; + return StatusCode::SUCCESS; } //////////////////////// @@ -86,20 +69,14 @@ StatusCode PixelRawContByteStreamTool::convert(PixelRDO_Container* cont,RawEvent // set ROD Minor version m_fea.setRodMinorVersion(m_RodBlockVersion); -#ifdef _DEBUG - m_log << MSG::DEBUG << "Setting ROD Minor Version Number to: " << m_RodBlockVersion << endmsg; -#endif + ATH_MSG_DEBUG("Setting ROD Minor Version Number to: " << m_RodBlockVersion); - // a map for ROD ID onto Encoder - std::map<uint32_t, PixelRodEncoder> mapEncoder; - //loop over the Pixel modules PixelRDO_Container::const_iterator it_coll = cont->begin(); PixelRDO_Container::const_iterator it_coll_end = cont->end(); -#ifdef _DEBUG - m_log << MSG::DEBUG << "Found " << cont->size() << " Pixel modules" << endmsg ; -#endif + ATH_MSG_DEBUG("Found " << cont->size() << " Pixel modules"); + SG::ReadCondHandle<PixelCablingCondData> pixCabling(m_condCablingKey); for( ; it_coll!=it_coll_end;++it_coll) { const InDetRawDataCollection<PixelRDORawData>* coll = (*it_coll) ; @@ -107,41 +84,26 @@ StatusCode PixelRawContByteStreamTool::convert(PixelRDO_Container* cont,RawEvent // get OfflineId and RODID if (coll != NULL){ Identifier offlineId = coll->identify(); - uint32_t rodId = m_pixelCabling->getRobId(offlineId); //FIXME - if ( rodId < 1) { - m_log << MSG::ERROR << "Didn't found ROBID for OfflineID: 0x" << std::hex << offlineId << std::dec << endmsg; + uint32_t rodId = pixCabling->find_entry_offrob(offlineId); + if (rodId<1) { + ATH_MSG_ERROR("Didn't found ROBID for OfflineID: 0x" << std::hex << offlineId << std::dec); } - //=======================================================================================================================// - // Set the properties in the encoder // - //=======================================================================================================================// - mapEncoder[rodId].set_pixelCabling(m_pixelCabling); - mapEncoder[rodId].set_PixelID(m_PixelID); - mapEncoder[rodId].setRodMinorVersion(m_RodBlockVersion); - mapEncoder[rodId].setPixelDetectorManager(m_pixelManager); - // loop over the HITS InDetRawDataCollection<PixelRDORawData>::const_iterator it_b = coll->begin(); InDetRawDataCollection<PixelRDORawData>::const_iterator it_e = coll->end(); - - for(; it_b!=it_e; ++it_b){ - const PixelRDORawData* d = *it_b; - mapEncoder[rodId].addRdo(d); - } + + std::vector<const PixelRDORawData*> RDOs; + for(; it_b!=it_e; ++it_b){ RDOs.push_back((*it_b)); } + + theROD = m_fea.getRodData(rodId); + fillROD( *theROD, RDOs, m_BCs_per_LVL1ID); + + } + else { + ATH_MSG_WARNING("IDC contains NULLpointer to collection, skipping collection"); } - else - m_log << MSG::WARNING << "IDC contains NULLpointer to collection, skipping collection" << endmsg; } - - //=======================================================================================================================// - // Fill the ROD Data into Full Event loop over Encoder map and fill all ROD Data Blocks // - //=======================================================================================================================// - std::map<uint32_t,PixelRodEncoder>::iterator it_map = mapEncoder.begin() ; - std::map<uint32_t,PixelRodEncoder>::iterator it_map_end = mapEncoder.end(); - for (; it_map != it_map_end; ++it_map) { - theROD = m_fea.getRodData((*it_map).first); - ((*it_map).second).fillROD( *theROD, m_log, m_BCs_per_LVL1ID); - } m_fea.fill(re,m_log); return StatusCode::SUCCESS; } @@ -151,3 +113,702 @@ static const InterfaceID IID_IPixelRawContByteStreamTool("PixelRawContByteStream const InterfaceID& PixelRawContByteStreamTool::interfaceID() { return IID_IPixelRawContByteStreamTool; } + + +//////////////////////// +// fillROD() - convert Pixel RDO to a vector of 32bit words +//////////////////////// +void PixelRawContByteStreamTool::fillROD(std::vector<uint32_t>& v32rod, std::vector<const PixelRDORawData*> RDOs, int BCs_per_LVL1ID) { + ATH_MSG_DEBUG("#####################################################################################"); + ATH_MSG_DEBUG("Entering PixelRodEncoder"); + + // Loop over the Hits in a ROD + std::vector<const PixelRDORawData*>::iterator rdo_it = RDOs.begin(); + std::vector<const PixelRDORawData*>::iterator rdo_it_end = RDOs.end(); + + bool is_ibl_present = false; + + const InDetDD::SiNumerology& pixSiNum = m_pixelManager->numerology(); + is_ibl_present = (pixSiNum.numLayers() == 4); + ATH_MSG_DEBUG("is_ibl_present = " << is_ibl_present); + ATH_MSG_DEBUG("pixSiNum.numLayers() = " << pixSiNum.numLayers()); + + bool is_ibl_module = false; + bool is_dbm_module = false; + ATH_MSG_DEBUG("in fillROD with " << BCs_per_LVL1ID << " LVL1As"); + ATH_MSG_DEBUG("Dimension of the RDO vector: " << RDOs.size()); + + int hitDiscCnfg = 2; + + SG::ReadCondHandle<PixelCablingCondData> pixCabling(m_condCablingKey); + SG::ReadCondHandle<PixelHitDiscCnfgData> pixHitDiscCnfg(m_condHitDiscCnfgKey); + + // ordering of the elements of the RDOs vector by offlineId, n5 + if (rdo_it != rdo_it_end) { + OrderInitialRdos orderInitialRdos(m_pixelCabling, m_PixelID, pixCabling); + std::sort(rdo_it, rdo_it_end, orderInitialRdos); + } + // end of ordering of the elements of the RDOs vector by offlineId, n5 + // NOW the RDOs should be ordered following (1) the offlineId, (2) the FE number + + rdo_it = RDOs.begin(); + if (rdo_it!=rdo_it_end) { + const PixelRDORawData* rawdata; + Identifier offlineId; + Identifier prev_offlineId(0x0); + Identifier pixelId; + bool timing_error = false; + bool condensedMode = false; + bool linkMasked = false; + uint32_t linknumber(0); + uint32_t FE(0); + uint32_t sLink(0); + uint32_t n5(0); + uint32_t prev_n5(0); + + int last_BCID = 0; // needed for encoding of timing information + while (rdo_it!=rdo_it_end) { + ATH_MSG_DEBUG("Inside cycle on the rdo_it"); + + rawdata = (*rdo_it); + pixelId = rawdata->identify(); + offlineId = m_PixelID->wafer_id(pixelId); + + uint32_t robId = pixCabling->find_entry_offrob(offlineId); + uint64_t onlineId = pixCabling->find_entry_offon(offlineId); // (32bit) working on modules, not on single pixels + + linknumber = (onlineId >> 24) & 0xFFFF; + + // All these functions below are methods of the class PixelRDORawData, InnerDetector/InDetRawEvent/InDetRawData + int TOT = rawdata->getToT(); // it returns a 8 bits "word" + int BCID = rawdata->getBCID(); + int LVL1ID = rawdata->getLVL1ID(); + int LVL1A = rawdata->getLVL1A(); + + if (m_pixelCabling->getModuleType(offlineId)==IPixelCablingSvc::IBL_PLANAR || m_pixelCabling->getModuleType(offlineId)==IPixelCablingSvc::IBL_3D) { + is_ibl_module = true; + } + if (m_pixelCabling->getModuleType(offlineId)==IPixelCablingSvc::DBM) { + is_dbm_module = true; + } + + ATH_MSG_DEBUG(" ********************* robId retrieved: 0x" << std::hex << robId << std::dec); + ATH_MSG_DEBUG("offlineId retrieved: " << offlineId); + ATH_MSG_DEBUG("onlineId retrieved: 0x" << std::hex << onlineId << ", linknumber retrieved: 0x" << linknumber << std::dec + << ", ToT: " << TOT << ", BCID: " << BCID << ", LVL1ID: " << LVL1ID << ", LVL1A: " << LVL1A); + ATH_MSG_DEBUG("Is IBL = " << is_ibl_module << " or is DBM = " << is_dbm_module); + + //************************************************************************************************* + // ************************************* PIXEL CASE ***************************************** + //************************************************************************************************* + if (!(is_ibl_module||is_dbm_module)) { + ATH_MSG_DEBUG("This is the PixelCase of the PixelRodEncoder"); + //---------------------------------------------------------------------------------------------- + //- Fill the data + //---------------------------------------------------------------------------------------------- + if (prev_offlineId!=offlineId) { + int fake_BCID; + timing_error = false; + if (BCs_per_LVL1ID<LVL1A) { // That must not happen, if LVL1A > BCs_per_LVL1ID, BCs_perLVL1ID is wrongly set in the joboptions + ATH_MSG_DEBUG("LVL1A > BCs_per_LVL1ID, timing corrupt, ignoring timing." << " Set BCs per LVL1ID: " << BCs_per_LVL1ID); + timing_error = true; + } + if (prev_offlineId!=0x0) { + v32rod.push_back(packLinkTrailer(0x0)); + ATH_MSG_DEBUG("Pixel module trailer"); + ATH_MSG_DEBUG(" ------------------------------------------------------------------------------------------"); + + //------------------------------------------------------------------------------------ + //- Write empty Header/Trailer pairs after the level1 accept + //------------------------------------------------------------------------------------ + fake_BCID = last_BCID; + int max_BCID = fake_BCID+BCs_per_LVL1ID-LVL1A-1; + + while ((fake_BCID<max_BCID) && !timing_error) { + fake_BCID++; + v32rod.push_back(packLinkHeader(linknumber, fake_BCID, LVL1ID, (LVL1ID>>4), 0x0)); + v32rod.push_back(packLinkTrailer(0x0)); + ATH_MSG_DEBUG("(after) empty Pixel Module header/trailer pair written for BCID " << fake_BCID); + } // end while cycle "while ((fake_BCID < max_BCID) && !timing_error)" + } // end if "if (prev_offlineId != 0x0) " + + //-------------------------------------------------------------------------------------- + //- Write empty Header/Trailer pairs before the level1 accept + //-------------------------------------------------------------------------------------- + fake_BCID = BCID-LVL1A; + + while ((fake_BCID<BCID) && !timing_error) { + v32rod.push_back(packLinkHeader(linknumber, fake_BCID, LVL1ID, (LVL1ID>>4), 0x0)); + v32rod.push_back(packLinkTrailer(0x0)); + ATH_MSG_DEBUG("(before) empty Pixel Module header/trailer pair written for BCID " << fake_BCID); + fake_BCID++; + } // end while cycle "while ((fake_BCID < BCID) && !timing_error)" + + v32rod.push_back(packLinkHeader(linknumber, BCID, LVL1ID, (LVL1ID>>4), 0x0)); + ATH_MSG_DEBUG("Pixel module header"); + } // end if "if (prev_offlineId != offlineId) " + + //-------------------------------------------------------------------------------------- + //- Write RawDataWord + //-------------------------------------------------------------------------------------- + FE = m_pixelCabling->getFE(&pixelId,offlineId); + uint32_t row = m_pixelCabling->getRow(&pixelId,offlineId); + uint32_t column = m_pixelCabling->getColumn(&pixelId,offlineId); + v32rod.push_back(packRawDataWord(FE, row, column, TOT)); + + // The following was used for running a validation scrip and making validation plots +#ifdef PLOTS + int eta_i = m_PixelID->eta_index(pixelId); + int phi_i = m_PixelID->phi_index(pixelId); + std::cout << "[PlotB]: " << robId << " " << eta_i << " " << phi_i << " " << TOT << std::endl; + std::cout << "[PlotC]: " << robId << " " << column << " " << row << " " << TOT << std::endl; + + std::cout << "[VAL] " << std::hex << pixelId << " 0x" << robId << " 0x" << onlineId // << " " << offlineId + << std::dec << " " << m_PixelID->eta_module(pixelId) << " " << m_PixelID->phi_module(pixelId) + << " " << m_PixelID->eta_index(pixelId) << " " << m_PixelID->phi_index(pixelId) << std::endl; +#endif + + ++rdo_it; + last_BCID = BCID; + + ATH_MSG_DEBUG("Found hit in PIXEL with PixelID: 0x" << std::hex << pixelId << std::dec << " FE: " << FE << " Row: " << row << " Column: " << column + << " TOT: " << TOT << " BCID: " << BCID << " LVL1ID: " << LVL1ID << " LVL1A: " << LVL1A); + ATH_MSG_DEBUG("Encoded Pixel OfflineID: 0x" << std::hex << offlineId << " OnlineID: 0x" << onlineId << " -> Linknumber: 0x" << linknumber << std::dec); + + prev_offlineId = offlineId; + } // end Pixel Case + //************************************************************************************************* + // ************************************* IBL CASE ***************************************** + //************************************************************************************************* + else { + ATH_MSG_DEBUG("Inside the IBL/DBM case of the PixelRodEncoder"); + + uint32_t linkNum = (onlineId>>24) & 0xFFFF; + unsigned int localFE = m_pixelCabling->getFE(&pixelId, m_PixelID->wafer_id(pixelId)); + FE = (linkNum>>(localFE*8)) & 0xF; + + sLink = onlineId & 0xF; // extract the LSB 4 bits from the onlineId + if (sLink > 0x3) { + ATH_MSG_WARNING("The SLink is not in the correct range [0,3]. This is due to the non-correct onlineId/ROBID definition. Skipping this RDO"); + continue; // skipping this rdo, because it gives wrong onlineID (and, possibly, other pieces of information are wrong too) + } + n5 = ((sLink & 0x3)<<3) | (FE & 0x7); // this variable contains the 5 "nnnnn" bits, the 2 MSB ones representing the copy of the S-Link number (0 to 3) and the 2 LSBs representing the FE number over the S-Link + ATH_MSG_DEBUG("FE (w.r.t. SLink) = 0x" << std::hex << FE << " sLink: 0x" << sLink << " => n5: 0x" << n5 << std::dec); + + if (m_pixelCabling->getModuleType(offlineId)==IPixelCablingSvc::IBL_PLANAR || m_pixelCabling->getModuleType(offlineId)==IPixelCablingSvc::DBM) { + hitDiscCnfg = pixHitDiscCnfg->getHitDiscCnfgPL(); + } + else if (m_pixelCabling->getModuleType(offlineId)==IPixelCablingSvc::IBL_3D) { + hitDiscCnfg = pixHitDiscCnfg->getHitDiscCnfg3D(); + } + + //---------------------------------------------------------------------------------------------- + //- Fill the data + //---------------------------------------------------------------------------------------------- + ATH_MSG_DEBUG("(prev_offlineId != offlineId) = " << (prev_offlineId != offlineId) << " (prev_n5 != n5) = " << (prev_n5 != n5) << " "); + ATH_MSG_DEBUG("prev_offlineId = " << prev_offlineId); + + if ((prev_offlineId!=offlineId) || (prev_n5!=n5)) { + int fake_BCID; + timing_error = false; + if (BCs_per_LVL1ID < LVL1A) { // That must not happen, if LVL1A > BCs_per_LVL1ID, BCs_perLVL1ID is wrongly set in the joboptions + ATH_MSG_DEBUG("LVL1A > BCs_per_LVL1ID, timing corrupt, ignoring timing." << " Set BCs per LVL1ID: " << BCs_per_LVL1ID); + timing_error = true; + } + + if (prev_offlineId != 0x0) { + v32rod.push_back(packLinkTrailer_IBL(prev_n5, timing_error, condensedMode, linkMasked)); // Trailer for IBL + condensedMode = false; + ATH_MSG_DEBUG("IBL Module trailer (because prev_offlineId != 0x0)"); + + //------------------------------------------------------------------------------------ + //- Write empty Header/Trailer pairs after the level1 accept + //------------------------------------------------------------------------------------ + fake_BCID = last_BCID; + int max_BCID = fake_BCID+BCs_per_LVL1ID-LVL1A-1; + + while ((fake_BCID < max_BCID) && !timing_error) { + fake_BCID++; + v32rod.push_back(packLinkHeader_IBL(n5, fake_BCID, LVL1ID, 0x0)); // Header for IBL + v32rod.push_back(packLinkTrailer_IBL(n5, timing_error, condensedMode, linkMasked)); // Trailer for IBL + + ATH_MSG_DEBUG("(after) empty IBL Module header/trailer pair written for BCID " << fake_BCID); + } // end while cycle "while ((fake_BCID < max_BCID) && !timing_error)" + } // end if "if (prev_offlineId != 0x0) " + + //-------------------------------------------------------------------------------------- + //- Write empty Header/Trailer pairs before the level1 accept + //-------------------------------------------------------------------------------------- + fake_BCID = BCID-LVL1A; + + while ((fake_BCID<BCID) && !timing_error) { + v32rod.push_back(packLinkHeader_IBL(n5, fake_BCID, LVL1ID, 0x0)); // Header for IBL + v32rod.push_back(packLinkTrailer_IBL(n5, timing_error, condensedMode, linkMasked)); // Trailer for IBL + ATH_MSG_DEBUG("(before) empty IBL Module header/trailer pair written for BCID " << fake_BCID); + fake_BCID++; + } // end while cycle "while ((fake_BCID < BCID) && !timing_error)" + + v32rod.push_back(packLinkHeader_IBL(n5, BCID, LVL1ID, 0x0)); // Header for IBL + ATH_MSG_DEBUG("IBL Module header"); + } // end if "if (prev_offlineId != offlineId) " + + //-------------------------------------------------------------------------------------- + //- Write RawData word + //-------------------------------------------------------------------------------------- + std::vector<const PixelRDORawData*> rdos_sameIBL_offlineId; // vector containing all the rdos with the same offlineId => belonging to the same IBL FE-I4 chip + + // This loop fills the rdo_sameIBL_offlineId vector with all the RDOs that have the same offlineId and same FEw.r.t.SLink => all RDOs coming from the same FE + for (; (rdo_it!=rdo_it_end) && ((((m_pixelCabling->getModuleType((*rdo_it)->identify())==IPixelCablingSvc::IBL_PLANAR) + || (m_pixelCabling->getModuleType((*rdo_it)->identify())==IPixelCablingSvc::IBL_3D)) && is_ibl_module) + || (m_pixelCabling->getModuleType((*rdo_it)->identify())==IPixelCablingSvc::DBM && is_dbm_module)); ++rdo_it) { + + Identifier pixelId_probe = (*rdo_it)->identify(); + Identifier offlineId_probe = m_PixelID->wafer_id(pixelId_probe); + + uint32_t linkNum = (onlineId>>24) & 0xFFFF; + unsigned int localFE = m_pixelCabling->getFE(&pixelId_probe, offlineId_probe); + uint32_t fe_probe = (linkNum>>(localFE*8)) & 0xF; + + + ATH_MSG_DEBUG("offlineId: " << offlineId << " offlineId_probe: " << offlineId_probe << ", fe: " << FE << " fe_probe: " << fe_probe); + + if ((offlineId_probe == offlineId) && (FE == fe_probe)) { + ATH_MSG_DEBUG("=======> IN "); + rdos_sameIBL_offlineId.push_back((*rdo_it)); + } + else { + ATH_MSG_DEBUG("=======> OUT."); + break; + } + } + + std::vector<const PixelRDORawData*>::iterator rdo_same_it = rdos_sameIBL_offlineId.begin(); + std::vector<const PixelRDORawData*>::iterator rdo_same_it_end = rdos_sameIBL_offlineId.end(); + +#ifdef PIXEL_DEBUG + //check: list of all the rdos with same offlineId, listing also the column, the row and the Tot + for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) { + Identifier pixelId_probe = (*rdo_same_it)->identify(); + uint32_t col = m_pixelCabling->getColumn(&pixelId_probe, offlineId); // offlineId of rdos in rdos_sameIBL_offlineId vector are, of course, all equal + uint32_t row = m_pixelCabling->getRow(&pixelId_probe, offlineId); + int tot = (*rdo_same_it)->getToT(); + ATH_MSG_DEBUG("col: " << col << " (0x" << std::hex << col << std::dec << ")\trow: "<< row << " (0x" << std::hex << row << std::dec << ")\ttot: " << tot << "(0x" <<std::hex << tot << std::dec << ")"); + } + + rdo_same_it = rdos_sameIBL_offlineId.begin(); + rdo_same_it_end = rdos_sameIBL_offlineId.end(); +#endif + + // Order the RDOs within the vector rdos_sameIBL_offlineId, following the ordering rules of orderRdos + OrderRdos orderRdos(offlineId,m_pixelCabling); + std::sort(rdo_same_it, rdo_same_it_end, orderRdos); + + //check: +#ifdef PIXEL_DEBUG + rdo_same_it = rdos_sameIBL_offlineId.begin(); + rdo_same_it_end = rdos_sameIBL_offlineId.end(); + + ATH_MSG_DEBUG("Re-ordered RDOs with Same offlineId:"); + for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) { + Identifier pixelId_probe = (*rdo_same_it)->identify(); + uint32_t col = m_pixelCabling->getColumn(&pixelId_probe, offlineId); + uint32_t row = m_pixelCabling->getRow(&pixelId_probe, offlineId); + int tot = (*rdo_same_it)->getToT(); + int eta_i = m_PixelID->eta_index(pixelId_probe); + int phi_i = m_PixelID->phi_index(pixelId_probe); + int eta_m = m_PixelID->eta_module(pixelId_probe); + int phi_m = m_PixelID->phi_module(pixelId_probe); + ATH_MSG_DEBUG("pixelId: " << pixelId_probe << ", eta_i: " << eta_i << ", phi_i: " << phi_i << ", eta_m: " << eta_m << ", phi_m: "); + ATH_MSG_DEBUG("col: 0x" << std::hex << col << std::dec << ", row: 0x" <<std::hex << row << std::dec << ", tot = 0x" << std::hex << tot << std::dec); + } + ATH_MSG_DEBUG("rdos_sameIBL_offlineId.size() = " << rdos_sameIBL_offlineId.size()); +#endif +#ifdef PLOTS + rdo_same_it = rdos_sameIBL_offlineId.begin(); + rdo_same_it_end = rdos_sameIBL_offlineId.end(); + for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) { + Identifier pixelId_probe = (*rdo_same_it)->identify(); + uint32_t col = m_pixelCabling->getColumn(&pixelId_probe, offlineId); + uint32_t row = m_pixelCabling->getRow(&pixelId_probe, offlineId); + int tot = (*rdo_same_it)->getToT(); + int eta_i = m_PixelID->eta_index(pixelId_probe); + int phi_i = m_PixelID->phi_index(pixelId_probe); + std::cout << "[Plot2]: " << robId << " " << eta_i << " " << phi_i << " " << tot << std::endl; + std::cout << "[Plot3]: " << robId << " " << col << " " << row << " " << tot << std::endl; + } +#endif + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // look for adjacent cell that can allow the "compression" of the two hit info in one: + // instead of having two hits (= 2 columns, 2 rows and 2 tots), in fact, + // if two adjacent pixels ([col, row] and [col, row+1]) have fired (respectively tot([col, row]) and tot([col, (row+1)]) + // then + // the row in the hit will be the row with lower number, the column in the hit will be the common column number + // and the tot will be = (tot [(col, row)] << 4) | tot[(col, row+1)] + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + std::vector <uint32_t> vRows; + std::vector <uint32_t> vCols; + std::vector <int> vTots; + bool doubleHit = false; + static const uint32_t rowsPerFE = 336;// FIXME: this is a hardcoded variable, would be better to get it from somewhere + + rdo_same_it = rdos_sameIBL_offlineId.begin(); + rdo_same_it_end = rdos_sameIBL_offlineId.end(); + + std::vector<const PixelRDORawData*>::iterator rdo_test_it = rdos_sameIBL_offlineId.begin(); + ATH_MSG_DEBUG("Looking for adjacent pixels and saving col, row and tot information."); + + for (; rdo_same_it!=rdo_same_it_end; ++rdo_same_it) { + doubleHit = false; + Identifier pixelId_probe = (*rdo_same_it)->identify(); + uint32_t col0 = m_pixelCabling->getColumn(&pixelId_probe, offlineId); + uint32_t row0 = m_pixelCabling->getRow(&pixelId_probe, offlineId); + int totInHitWord (0); +#ifdef PLOTS + std::cout << "[VAL] " << std::hex << pixelId_probe << " 0x" << robId << " 0x" << onlineId // << " " << offlineId + << std::dec << " " << m_PixelID->eta_module(pixelId_probe) << " " << m_PixelID->phi_module(pixelId_probe) + << " " << m_PixelID->eta_index(pixelId_probe) << " " << m_PixelID->phi_index(pixelId_probe) << std::endl; +#endif + + if (row0==rowsPerFE) { + ATH_MSG_DEBUG("Hit in the last row (== 336) of the IBL FE."); + } + else { + if ((rdo_same_it+1)!=rdo_same_it_end) { + rdo_test_it = rdo_same_it + 1; + Identifier pixelId_probe = (*rdo_test_it)->identify(); + uint32_t col1 = m_pixelCabling->getColumn(&pixelId_probe, offlineId); + uint32_t row1 = m_pixelCabling->getRow(&pixelId_probe, offlineId); +#ifdef PLOTS + std::cout << "[VAL] " << std::hex << pixelId_probe << " 0x" << robId << " 0x" << onlineId // << " " << offlineId + << std::dec << " " << m_PixelID->eta_module(pixelId_probe) << " " << m_PixelID->phi_module(pixelId_probe) + << " " << m_PixelID->eta_index(pixelId_probe) << " " << m_PixelID->phi_index(pixelId_probe) << std::endl; +#endif + + ATH_MSG_DEBUG("Comparing rdo[i] = " << (*rdo_same_it) << " with rdo[i+1] = " << (*rdo_test_it)); + ATH_MSG_DEBUG(" col0 = 0x" << std::hex << col0 << " col1 = 0x" << col1 << " row0 = 0x" << row0 << "\t row1 = 0x" << row1 << std::dec); + + if ((col1==col0) && (row1==(row0+1))) { + doubleHit = true; + ATH_MSG_DEBUG("Two adjacent hits found"); + + int tot0 = (*rdo_same_it)->getToT(); + int tot1 = (*rdo_test_it)->getToT(); + + // Adjust ToT according to hitdisccnfg setting + if (hitDiscCnfg==2 && tot0==16) { tot0=2; } + if (hitDiscCnfg==2 && tot1==16) { tot1=2; } + + int overflow = 14; + if (hitDiscCnfg==1) { overflow=15; } + if (hitDiscCnfg==2) { overflow=16; } + + if (tot0>overflow) { tot0=overflow; } + if (tot1>overflow) { tot1=overflow; } + + totInHitWord = (tot0<<4) | tot1; + + ATH_MSG_DEBUG("doubleHit = " << std::boolalpha << doubleHit << std::noboolalpha << " ===> (col0 == col1) : 0x" << std::hex << col0 << " = 0x" << col1 + << "; (row0 = row1 - 1) : 0x" << row0 << " => 0x" << row1 <<"; (tot0) : 0x" << tot0 << ", (tot1) : 0x" << tot1 << " => totInHitWord: 0x" << totInHitWord << std::dec); + rdo_same_it++; + } // end if "(col1==col0) && (row1 == (row0+1))" + } // end if "(rdo_same_it + 1) != rdo_same_it_end" + else { + ATH_MSG_DEBUG("last rdo with same Offline Id"); + } // end if it's the last rdo with same offlineId + } // end if "row0 == rowsPerFE" (== 336) + + if (!doubleHit) { + int tot0 = (*rdo_same_it)->getToT(); + + // Adjust ToT according to hitdisccnfg setting + if (hitDiscCnfg==2 && tot0==16) { tot0=2; } + + int overflow = 14; + if (hitDiscCnfg==1) { overflow=15; } + if (hitDiscCnfg==2) { overflow=16; } + if (tot0>overflow) { tot0=overflow; } + + totInHitWord = (tot0<<4) | 0x0; + + ATH_MSG_DEBUG("doubleHit = " << std::boolalpha << doubleHit << std::noboolalpha << " ===> col0: 0x" << std::hex << col0 << std::dec << "; row0: 0x" << std::hex << row0 << std::dec << " totInHitWord: 0x" << std::hex << totInHitWord << std::dec); + } + vCols.push_back(col0); + vRows.push_back(row0); + vTots.push_back(totInHitWord); + } // end loop over the rdos with the same offlineId + + //check: +#ifdef PIXEL_DEBUG + ATH_MSG_DEBUG("CHECKs over the vectors storing columns, rows, ToTs of IBL/DBM hits:"); + ATH_MSG_DEBUG(" vCols: "); + std::vector<uint32_t>::iterator vCols_it = vCols.begin(); + std::vector<uint32_t>::iterator vCols_it_end = vCols.end(); + for (; vCols_it != vCols_it_end; ++vCols_it) { + ATH_MSG_DEBUG("0x" << std::hex << *vCols_it << std::dec << " "); + } + ATH_MSG_DEBUG("vRows: "); + std::vector<uint32_t>::iterator vRows_it = vRows.begin(); + std::vector<uint32_t>::iterator vRows_it_end = vRows.end(); + for (; vRows_it != vRows_it_end; ++vRows_it) { + ATH_MSG_DEBUG("0x" << std::hex << *vRows_it << std::dec <<" "); + } + ATH_MSG_DEBUG("vTots: "); + std::vector<int>::iterator vTots_it = vTots.begin(); + std::vector<int>::iterator vTots_it_end = vTots.end(); + for (; vTots_it != vTots_it_end; ++vTots_it) { + ATH_MSG_DEBUG("0x" << std::hex << *vTots_it << std::dec << " "); + } + ATH_MSG_DEBUG("rdos_sameIBL_offlineId.size() = " << rdos_sameIBL_offlineId.size() << " vRows.size() = " << vRows.size() << " vCols.size() = " << vCols.size() << " vTots.size() = " << vTots.size()); +#endif + + //Packing of the IBL hits + if (vRows.size() >= 5) { + ATH_MSG_DEBUG("5 (or more) IBL hits have been consequently found. They can be written as condensed hits"); + while (vRows.size()>=5) { + packIBLcondensed(v32rod, vRows, vCols, vTots); + condensedMode= true; + } + } + if (vRows.size()!=0) { // packing remaining non-condensed IBL hit words + // int cycleCounter(0); + for (; vRows.size() != 0; ) { + v32rod.push_back(packRawDataWord_IBL(vRows.at(0), vCols.at(0), vTots.at(0), n5)); + vRows.erase(vRows.begin()); + vCols.erase(vCols.begin()); + vTots.erase(vTots.begin()); + } + } + last_BCID = BCID; + + ATH_MSG_DEBUG("Encoded IBL OfflineID: " << std::hex << offlineId << " OnlineID: 0x" << onlineId << std::dec); + + prev_offlineId = offlineId; + prev_n5 = n5; + // prev_FE = FE; + } // end of the IBL case + } // end WHILE cycle " while (rdo_it!=rdo_it_end) " + + if (is_ibl_module || is_dbm_module) { + v32rod.push_back(packLinkTrailer_IBL(n5, timing_error, condensedMode, linkMasked)); + condensedMode = false; + ATH_MSG_DEBUG("Module IBL/DBM trailer (at end of the loop)"); + } + else { + v32rod.push_back(packLinkTrailer(0x0)); + ATH_MSG_DEBUG("Pixel module trailer"); + } + } // end if "if (rdo_it != rdo_it_end)" + else { + ATH_MSG_DEBUG("rdo_it == rdo_it_end"); + } + return; +} + +//////////////////////// +// encode module Header for Pixels +// Pixel Header: 001PtlbxxnnnnnnnMMMMLLLLBBBBBBBB, +//////////////////////// +uint32_t PixelRawContByteStreamTool::packLinkHeader(uint32_t module, uint32_t bcid, uint32_t lvl1id, uint32_t lvl1idskip, uint32_t errors) { + lvl1idskip = 0; // FIXME LVL1IDskip hardcoded as 0 + uint32_t result = 0; + result = PRB_LINKHEADER | ((bcid & PRB_BCIDmask) << PRB_BCIDskip) | ((lvl1id & PRB_L1IDmask) << PRB_L1IDskip) | ((lvl1idskip & PRB_L1IDSKIPmask) << PRB_L1IDSKIPskip) | ((module & PRB_MODULEmask) << PRB_MODULEskip) | ((errors & PRB_HEADERERRORSmask) << PRB_HEADERERRORSskip); +#ifdef PLOTS + std::cout << "[PlotA]:0x " << std::hex << result << std::dec << std::endl; + std::cout << "[PlotA]:(dec) " << result << std::endl; +#endif + return result; +} + + +//////////////////////// +// encode module Header for IBL +// IBL Header: 001nnnnnFLLLLLLLLLLLLLBBBBBBBBBB +//////////////////////// +uint32_t PixelRawContByteStreamTool::packLinkHeader_IBL(uint32_t module, uint32_t bcid, uint32_t lvl1id, uint32_t feFlag) { + uint32_t result = 0; + result = PRB_LINKHEADER | ((bcid & PRB_BCIDmask_IBL) << PRB_BCIDskip_IBL) | ((lvl1id & PRB_L1IDmask_IBL) << PRB_L1IDskip_IBL) | ((module & PRB_MODULEmask_IBL) << PRB_MODULEskip_IBL) | ((feFlag & PRB_FeI4BFLAGmask_IBL) << PRB_FeI4BFLAGskip_IBL); +#ifdef PIXEL_DEBUG + // std::cout << "IBL HEADER: linkNum (=n): 0x" << std::hex << module << std::dec << ", bcid: " << bcid << ", lvl1id: " << lvl1id << ", feFlag: " << feFlag << "====> Result: 0x" << std::hex << result << std::dec << std::endl; +#endif +#ifdef PLOTS + std::cout << "[Plot1]:0x " << std::hex << result << std::dec << std::endl; + std::cout << "[Plot1]:(dec) " << result << std::endl; +#endif + return result; +} + + +//////////////////////// +// encode IBL non-condensed hit word: 0-8: row,9-15: column, 16-23:TOT, 24-28: nLink ----> 100xxnnnTTTTTTTTCCCCCCCRRRRRRRRR +//////////////////////// +uint32_t PixelRawContByteStreamTool::packRawDataWord_IBL(uint32_t row, uint32_t column, int ToT, uint32_t nLink) { + uint32_t result = 0; + result = PRB_DATAWORD | ((row & PRB_ROWmask_IBL) << PRB_ROWskip_IBL) | ((column & PRB_COLUMNmask_IBL) << PRB_COLUMNskip_IBL) | ((ToT & PRB_TOTmask) << PRB_TOTskip) | ((nLink & PRB_LINKNUMHITmask_IBL) << PRB_LINKNUMHITskip_IBL); +#ifdef PIXEL_DEBUG + // std::cout << "IBL NON-CONDENSED HIT: nLink: 0x" << std::hex << nLink << ", row: 0x" << row << ", col: 0x" << column << ", tot: 0x" << ToT << " ===> encoded IBL word: 0x" << result << std::dec << std::endl; +#endif +#ifdef PLOTS + std::cout << "[Plot1]:0x " << std::hex << result << std::dec << std::endl; + std::cout << "[Plot1]:(dec) " << result << std::endl; +#endif + return result; +} + +//////////////////////// +// encode PIXEL hit word: bits 0-7:row,8-12:column,16-23:TOT,24-27:FE ----> 100xFFFFTTTTTTTTxxxCCCCCRRRRRRRR +//////////////////////// +uint32_t PixelRawContByteStreamTool::packRawDataWord(uint32_t FE, uint32_t row, uint32_t column, uint32_t ToT) { + + uint32_t result = 0; + result = PRB_DATAWORD | ((row & PRB_ROWmask) << PRB_ROWskip) | ((column & PRB_COLUMNmask) << PRB_COLUMNskip) | ((ToT & PRB_TOTmask) << PRB_TOTskip) | ((FE & PRB_FEmask) << PRB_FEskip); +#ifdef PLOTS + std::cout << "[PlotA]:0x " << std::hex << result << std::dec << std::endl; + std::cout << "[PlotA]:(dec) " << result << std::endl; +#endif + return result; +} + + +//////////////////////// +// encode PIXEL module trailer (bits 26-28:trailer errors) +//////////////////////// +uint32_t PixelRawContByteStreamTool::packLinkTrailer(uint32_t errors) { + uint32_t result = PRB_LINKTRAILER | ((errors & PRB_TRAILERERRORSmask) << PRB_TRAILERERRORSskip); +#ifdef PLOTS + std::cout << "[PlotA]:0x " << std::hex << result << std::dec << std::endl; + std::cout << "[PlotA]:(dec) " << result << std::endl; +#endif + return result; +} + + +//////////////////////// +// encode IBL module trailer (bits 26-28:trailer errors) +//////////////////////// +uint32_t PixelRawContByteStreamTool::packLinkTrailer_IBL(uint32_t linknum, bool timeOutErrorBit, bool condensedModeBit, bool linkMasked) { + // return PRB_LINKTRAILER |((timeOutErrorBit & PRB_TIMEOUTERRORmask_IBL) << PRB_TIMEOUTERRORskip_IBL) | ((condensedModeBit & PRB_CONDENSEDMODEmask_IBL) << PRB_CONDENSEDMODEskip_IBL) | ((linkMasked & PRB_LINKMASKEDmask_IBL) << PRB_LINKMASKEDskip_IBL) | ((linknum & PRB_LINKNUMTRAILERmask_IBL) << PRB_LINKNUMTRAILERskip_IBL); + uint32_t result; + result = PRB_LINKTRAILER | (timeOutErrorBit << PRB_TIMEOUTERRORskip_IBL) | (condensedModeBit << PRB_CONDENSEDMODEskip_IBL) | (linkMasked << PRB_LINKMASKEDskip_IBL) | ((linknum & PRB_LINKNUMTRAILERmask_IBL) << PRB_LINKNUMTRAILERskip_IBL); +#ifdef PIXEL_DEBUG + // std::cout << "IBL TRAILER: linknum = 0x" << std::hex << linknum << ", timeOutErrorBit: 0x" << timeOutErrorBit << ", condensedModeBit: 0x" << condensedModeBit << ", linkMasked: 0x" << linkMasked << ", ===> Result: 0x" << result << std::dec << std::endl; +#endif +#ifdef PLOTS + std::cout << "[Plot1]:0x " << std::hex << result << std::dec << std::endl; + std::cout << "[Plot1]:(dec) " << result << std::endl; +#endif + return result; +} + + +//////////////////////// +// Encode IBL Condensed hit words: +// for IBL condensed word: (R = row, C = column, T = TOT) +// 1st word: 101 RRRRRTTTTTTTTCCCCCCCRRRRRRRRR +// 2nd word: 1 CCCRRRRRRRRRTTTTTTTTCCCCCCCRRRR +// 3rd word: 1 TTTCCCCCCCRRRRRRRRRTTTTTTTTCCCC +// 4th word: 111 TTTTTTTTCCCCCCCRRRRRRRRRTTTTT +//////////////////////// + +void PixelRawContByteStreamTool::packIBLcondensed(std::vector <uint32_t> & v32rod, std::vector <uint32_t> & vRows, std::vector <uint32_t> & vCols, std::vector<int> & vTots) { + unsigned int condWord[nCondensedWords]; + condWord[0] = PRB_FIRSTHITCONDENSEDWORD | vRows[0] | (vCols[0] << skipRow) | (vTots[0] << (skipRow + skipCol) | ((vRows[1] & mask5) << (skipRow + skipCol + skipTOT))); + + condWord[1] = PRB_MIDDLEHITCONDENSEDWORD | (vRows[1] >> skip5) | (vCols[1] << skip4) | (vTots[1] << (skip4 + skipCol)) | (vRows[2] << (skip4+skipCol+skipTOT)) | ((vCols[2] & mask3) << (skip4+skipCol+skipTOT+skipRow)); + + condWord[2] = PRB_MIDDLEHITCONDENSEDWORD | (vCols[2] >> skip3) | (vTots[2] << skip4) | (vRows[3] << (skip4+skipTOT)) | (vCols[3] << (skip4+skipTOT+skipRow)) | ((vTots[3] & mask3) << (skip4+skipTOT+skipRow+skipCol)); + + condWord[3] = PRB_DATAMASK | (vTots[3] >> skip3) | (vRows[4] << skip5) | (vCols[4] << (skip5+skipRow)) | (vTots[4] << (skip5+skipRow+skipCol)); + + for (int j(0); j < 4; ++j) { + v32rod.push_back(condWord[j]); // Filling the ROD vector here +#ifdef PLOTS + std::cout << "[Plot1]:0x " << std::hex << condWord[j] << std::dec << std::endl; + std::cout << "[Plot1]:(dec) " << condWord[j] << std::endl; +#endif + } + + vRows.erase (vRows.begin(), vRows.begin() + 5); + vCols.erase (vCols.begin(), vCols.begin() + 5); + vTots.erase (vTots.begin(), vTots.begin() + 5); + return; +} + +//////////////////////// +// function used by std::sort to order the RDO vector that contains RDOs with the same offlineId +// It orders the rdos_sameIBL_offlineId by //column (ascending order), row (ascending order, once the column is the same) +// example: coordinates (col, row): (1,1), (3,6), (1,2), (4,82), (4,81) become: (1,1), (1,2), (3,6), (4,81), (4,82). +//////////////////////// +bool OrderRdos::operator () (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1) //, const Identifier & offlineId +{ + // const uint32_t halfCols = 40; // this is the number of the FE-I4 columns / 2, because the two tokens in the FE-I4 run from the double column 0 to 19, and then from 39 to 20. + // This corresponds to column 1 to 40, and 79-80, 77-78, ... to 41-42. + Identifier pixelId0 = rdo0->identify(); + uint32_t col0 = m_pixelCabling->getColumn(&pixelId0, m_offlineId); + uint32_t row0 = m_pixelCabling->getRow(&pixelId0, m_offlineId); + Identifier pixelId1 = rdo1->identify(); + uint32_t col1 = m_pixelCabling->getColumn(&pixelId1, m_offlineId); + uint32_t row1 = m_pixelCabling->getRow(&pixelId1, m_offlineId); + + // Decide if (col0, row0) should be inserted in front of (col1, row1): + + // Check if both hits are in same column + if (col0 == col1) return (row0 < row1); + + // If not, check if they are in same double column + else if (((col0 == col1-1) && (col1%2 == 0)) || ((col1 == col0-1) && (col0%2 == 0))) { + + // If rows are equal, sort by ascending column + if (row0 == row1) return (col0 < col1); + // If rows are unequal, sort by ascending row + else return (row0 < row1); + } + + // Not in same double column: Separate between FE halfs + else { + + // If both hits are in second FE half: Sort by descending col + if (col0 > 40 && col1 > 40) return (col0 > col1); + + // Otherwise, sort by ascending col + else return (col0 < col1); + } +} + +bool OrderInitialRdos::operator() (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1) +{ + Identifier pixelId0 = rdo0->identify(); + Identifier offlineId0 = m_PixelID->wafer_id(pixelId0); + Identifier pixelId1 = rdo1->identify(); + Identifier offlineId1 = m_PixelID->wafer_id(pixelId1); + if (offlineId0 < offlineId1) { + return true; + } + if (offlineId0 == offlineId1) { + if ( m_pixelCabling->getModuleType(pixelId0)==IPixelCablingSvc::IBL_PLANAR + || m_pixelCabling->getModuleType(pixelId0)==IPixelCablingSvc::IBL_3D + || m_pixelCabling->getModuleType(pixelId0)==IPixelCablingSvc::DBM) { // IBL and DBM + + uint64_t onlineId0 = m_pixCabling->find_entry_offon(offlineId0); + uint32_t linkNum0 = (onlineId0>>24) & 0xFFFF; + unsigned int localFE0 = m_pixelCabling->getFE(&pixelId0, offlineId0); + uint32_t fe0= (linkNum0>>(localFE0*8)) & 0xF; + + uint64_t onlineId1 = m_pixCabling->find_entry_offon(offlineId1); + uint32_t linkNum1 = (onlineId1>>24) & 0xFFFF; + unsigned int localFE1 = m_pixelCabling->getFE(&pixelId1, offlineId1); + uint32_t fe1= (linkNum1>>(localFE1*8)) & 0xF; + + return (fe0 < fe1); + } + else { // PixelCase + uint32_t fe0 = m_pixelCabling->getFE(&pixelId0, offlineId0); + uint32_t fe1 = m_pixelCabling->getFE(&pixelId1, offlineId1); + return (fe0 < fe1); + + // return false; + } + } + else {return false; } +} diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamTool.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamTool.h index cf5c33d328fb0674c86b344aed4ba365f11bfa76..50658db67b7fd154a51c5c532ee25e5fb4255bf2 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamTool.h +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawContByteStreamTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -30,41 +30,106 @@ #include "ByteStreamCnvSvcBase/FullEventAssembler.h" // needed, template class -//#include "GaudiKernel/IToolSvc.h" +#include "PixelByteStreamModuleMask.h" +#include "PixelCabling/IPixelCablingSvc.h" +#include "InDetIdentifier/PixelID.h" +#include "ByteStreamCnvSvcBase/SrcIdMap.h" -class IPixelCablingSvc; -class PixelID; -class SrcIdMap; -class PixelRodEncoder; +#include "PixelConditionsData/PixelCablingCondData.h" +#include "PixelConditionsData/PixelHitDiscCnfgData.h" +#include "StoreGate/ReadCondHandleKey.h" class PixelRawContByteStreamTool: public AthAlgTool { -public: + public: + // constructor + PixelRawContByteStreamTool(const std::string& type,const std::string& name,const IInterface* parent); - // constructor - PixelRawContByteStreamTool(const std::string& type,const std::string& name,const IInterface* parent); + // destructor + virtual ~PixelRawContByteStreamTool(); - // destructor - virtual ~PixelRawContByteStreamTool(); + // AlgTool InterfaceID + static const InterfaceID& interfaceID(); - // AlgTool InterfaceID - static const InterfaceID& interfaceID(); + virtual StatusCode initialize(); + virtual StatusCode finalize(); + StatusCode convert(PixelRDO_Container* cont,RawEventWrite* re); - virtual StatusCode initialize(); - virtual StatusCode finalize(); - StatusCode convert(PixelRDO_Container* cont,RawEventWrite* re); - -private: + void fillROD(std::vector<uint32_t>& v32rod, std::vector<const PixelRDORawData*> RDOs, int BCs_per_LVL1ID); - ServiceHandle<IPixelCablingSvc> m_pixelCabling; - const PixelID* m_PixelID; + void packIBLcondensed(std::vector <uint32_t > & v32rod, std::vector <uint32_t > & vRows, std::vector <uint32_t > & vCols, std::vector<int> & vTots); + void packIBLCondensed(std::vector <uint32_t > & v32rod, const std::vector<const PixelRDORawData*> &rdos_sameIBL_offlineId); + uint32_t packLinkHeader(uint32_t module, uint32_t bcid, uint32_t lvl1id, uint32_t lvl1idskip, uint32_t errors); + uint32_t packLinkHeader_IBL(uint32_t module, uint32_t bcid, uint32_t lvl1id, uint32_t feFlag); + uint32_t packRawDataWord(uint32_t FE, uint32_t row, uint32_t column, uint32_t ToT); + uint32_t packRawDataWord_IBL(uint32_t row, uint32_t column, int ToT, uint32_t nLink); + uint32_t packLinkTrailer(uint32_t errors); // for Pixel + uint32_t packLinkTrailer_IBL(uint32_t FEonSLink, bool timeOutErrorBit, bool condensedModeBit, bool linkMasked); // for IBL - const InDetDD::PixelDetectorManager* m_pixelManager; - - FullEventAssembler<SrcIdMap> m_fea; - unsigned short m_RodBlockVersion; - int m_BCs_per_LVL1ID; + private: + ServiceHandle<IPixelCablingSvc> m_pixelCabling; + const PixelID* m_PixelID; - MsgStream m_log; + const InDetDD::PixelDetectorManager* m_pixelManager; + + FullEventAssembler<SrcIdMap> m_fea; + unsigned short m_RodBlockVersion; + int m_BCs_per_LVL1ID; + + MsgStream m_log; + + SG::ReadCondHandleKey<PixelCablingCondData> m_condCablingKey + {this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"}; + + SG::ReadCondHandleKey<PixelHitDiscCnfgData> m_condHitDiscCnfgKey + {this, "PixelHitDiscCnfgData", "PixelHitDiscCnfgData", "Pixel FEI4 HitDiscConfig key"}; }; + +class OrderRdos { + + private: + ServiceHandle<IPixelCablingSvc> m_pixelCabling; + Identifier m_offlineId; + + public: + OrderRdos(Identifier offlineId, const ServiceHandle<IPixelCablingSvc>& pixelCabling): + m_pixelCabling("dummy","dummy"),m_offlineId(offlineId) { m_pixelCabling=pixelCabling; } + + // copy constructor + OrderRdos(const OrderRdos & orderFunct): + m_pixelCabling("dummy","dummy"),m_offlineId(orderFunct.m_offlineId) { m_pixelCabling=orderFunct.m_pixelCabling; } + + // assignment operator + OrderRdos& operator= (const OrderRdos &other) { + m_pixelCabling = other.m_pixelCabling; + return *this; + } + + bool operator() (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1); +}; + +class OrderInitialRdos { + + private: + ServiceHandle<IPixelCablingSvc> m_pixelCabling; + const PixelID * m_PixelID; + SG::ReadCondHandle<PixelCablingCondData> m_pixCabling; + + public: + OrderInitialRdos(const ServiceHandle<IPixelCablingSvc>& pixelCabling, const PixelID *pixelID, SG::ReadCondHandle<PixelCablingCondData> &pixCabling): + m_pixelCabling("dummy","dummy"),m_PixelID(pixelID),m_pixCabling(pixCabling) { m_pixelCabling=pixelCabling; } + + // copy constructor + OrderInitialRdos(const OrderInitialRdos & orderFunct): + m_pixelCabling("dummy","dummy"),m_PixelID(orderFunct.m_PixelID),m_pixCabling(orderFunct.m_pixCabling) { m_pixelCabling=orderFunct.m_pixelCabling; } + + // assignment operator + OrderInitialRdos& operator= (const OrderInitialRdos &other) { + m_pixelCabling = other.m_pixelCabling; + return *this; + } + + bool operator() (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1); +}; + #endif // PIXELRAWDATABYTESTREAMCNV_PIXELRAWCONTRAWEVENTTOOL_H diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx index aca728fac40aede75337c2d2f9f72f8c208f5eee..cafbe73e56216be563123ae340afa46b78f4faf9 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "PixelRawDataProvider.h" @@ -9,7 +9,6 @@ #include "InDetIdentifier/PixelID.h" #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" #include "IRegionSelector/IRegSelSvc.h" -#include "PixelCabling/IPixelCablingSvc.h" #include "EventContainers/IdentifiableContTemp.h" using OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment; @@ -21,7 +20,6 @@ PixelRawDataProvider::PixelRawDataProvider(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator), m_regionSelector ("RegSelSvc", name), - m_pixelCabling ("PixelCablingSvc",name), m_robDataProvider ("ROBDataProviderSvc",name), m_rawDataTool ("PixelRawDataProviderTool", this), //make private m_pixel_id (nullptr), @@ -65,13 +63,6 @@ StatusCode PixelRawDataProvider::initialize() { ATH_CHECK(detStore()->retrieve(m_pixel_id, "PixelID")); - // Get the cabling service - if (m_pixelCabling.retrieve().isFailure()) { - ATH_MSG_FATAL("Failed to retrieve service " << m_pixelCabling); - return StatusCode::FAILURE; - } else - ATH_MSG_INFO("Retrieved tool " << m_pixelCabling); - ATH_CHECK( m_rdoContainerKey.initialize() ); ATH_CHECK( m_rdoCacheKey.initialize(!m_rdoCacheKey.key().empty()) ); @@ -79,10 +70,9 @@ StatusCode PixelRawDataProvider::initialize() { ATH_CHECK( m_roiCollectionKey.initialize() ); ATH_CHECK(m_regionSelector.retrieve()); } - else {//Only need pixel cabling if not using RoIs - ATH_CHECK(m_pixelCabling.retrieve()); - } - + + ATH_CHECK(m_condCablingKey.initialize()); + return StatusCode::SUCCESS; } @@ -121,10 +111,9 @@ StatusCode PixelRawDataProvider::execute() { // ask ROBDataProviderSvc for the vector of ROBFragment for all Pixel ROBIDs std::vector<uint32_t> listOfRobs; - if (!m_roiSeeded) { ATH_MSG_DEBUG("No RoI seed, fetching all ROBs"); - listOfRobs = m_pixelCabling->getAllRobs(); // need ROB id (not ROD) + listOfRobs = SG::ReadCondHandle<PixelCablingCondData>(m_condCablingKey)->get_allRobs(); // need ROB id (not ROD) } else {//Enter RoI-seeded mode ATH_MSG_DEBUG("RoI seed, fetching regions infromation"); @@ -144,8 +133,8 @@ StatusCode PixelRawDataProvider::execute() { listOfRobs); } std::vector<const ROBFragment*> listOfRobf; - m_robDataProvider->getROBData( listOfRobs, listOfRobf); + m_robDataProvider->getROBData( listOfRobs, listOfRobf); #ifdef PIXEL_DEBUG ATH_MSG_DEBUG("Number of ROB fragments " << listOfRobf.size() diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h index aa62cdf16b316903e3dbf8cdeef38cef9b877aee..491ef89447c218ccc6b58e8bdb2d13cd7921861d 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -19,12 +19,14 @@ #include "TrigSteeringEvent/TrigRoiDescriptorCollection.h" #include <string> +#include "PixelConditionsData/PixelCablingCondData.h" +#include "StoreGate/ReadCondHandleKey.h" + // Forward declarations class IPixelRawDataProviderTool; class PixelID; class IROBDataProviderSvc; class IRegSelSvc; -class IPixelCablingSvc; class PixelRawDataProvider : public AthAlgorithm { @@ -46,7 +48,6 @@ class PixelRawDataProvider : public AthAlgorithm { private: ServiceHandle<IRegSelSvc> m_regionSelector; - ServiceHandle<IPixelCablingSvc> m_pixelCabling; ServiceHandle<IROBDataProviderSvc> m_robDataProvider; ToolHandle<IPixelRawDataProviderTool> m_rawDataTool; const PixelID* m_pixel_id; @@ -54,6 +55,10 @@ private: SG::ReadHandleKey<TrigRoiDescriptorCollection> m_roiCollectionKey; SG::WriteHandleKey<PixelRDO_Container> m_rdoContainerKey; SG::UpdateHandleKey<PixelRDO_Cache> m_rdoCacheKey; + + SG::ReadCondHandleKey<PixelCablingCondData> m_condCablingKey + {this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"}; + }; #endif diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.cxx index 51a634252e17dddde929759524e734f681ba4d7a..05ffe2a73a35fb6799fffbf8fb96a685408ff4b3 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.cxx +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "PixelRodDecoder.h" @@ -53,7 +53,6 @@ PixelRodDecoder::PixelRodDecoder m_pixelCabling("PixelCablingSvc",name), m_pixel_id(nullptr), m_det(eformat::SubDetector()), - m_cablingData(nullptr), m_errors("PixelByteStreamErrorsSvc",name) { declareInterface< IPixelRodDecoder >( this ); @@ -70,17 +69,9 @@ PixelRodDecoder::~PixelRodDecoder() { StatusCode PixelRodDecoder::initialize() { - ATH_MSG_INFO(" initialize "); - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) return sc; + ATH_MSG_INFO("PixelRodDecoder::initialize()"); - - // Retrieve id mapping - if (m_pixelCabling.retrieve().isFailure()) { - ATH_MSG_FATAL( "Failed to retrieve service " << m_pixelCabling); - return StatusCode::FAILURE; - } else - ATH_MSG_INFO("Retrieved service " << m_pixelCabling); + ATH_CHECK(m_pixelCabling.retrieve()); ATH_CHECK(detStore()->retrieve(m_pixel_id, "PixelID")); @@ -108,6 +99,9 @@ StatusCode PixelRodDecoder::initialize() { m_numBCIDWarnings = 0; m_maxNumBCIDWarnings = 50; + ATH_CHECK(m_condCablingKey.initialize()); + ATH_CHECK(m_condHitDiscCnfgKey.initialize()); + return StatusCode::SUCCESS; } @@ -147,10 +141,13 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD uint32_t rodId = robFrag->rod_source_id(); // get source ID => method of ROBFragment, Returns the source identifier of the ROD fragment uint32_t robId = robFrag->rob_source_id(); // get source ID => returns the Identifier of the ROB fragment. More correct to use w.r.t. rodId. uint32_t robBCID = robFrag->rod_bc_id(); - if (m_pixelCabling->isIBL(robId) && (robId != rodId)) { + if (((robId>>16) & 0xFF)==0x14 && (robId != rodId)) { // isIBL(robId) generalwarning("Discrepancy in IBL SourceId: ROBID 0x" << std::hex << robId << " unequal to RODID 0x" << rodId); } + SG::ReadCondHandle<PixelCablingCondData> pixCabling(m_condCablingKey); + SG::ReadCondHandle<PixelHitDiscCnfgData> pixHitDiscCnfg(m_condHitDiscCnfgKey); + // check the ROD status for truncation if (robFrag->nstatus() != 0) { const uint32_t* rob_status; @@ -247,7 +244,7 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD // Do a check on IBL Slink ID eformat::helper::SourceIdentifier sid_rob(robId); sLinkSourceId = (sid_rob.module_id()) & 0x000F; // retrieve S-Link number from the source Identifier (0xRRRL, L = Slink number) - if (m_pixelCabling->isIBL(robId) && sLinkSourceId > 0x3) { // Check if SLink number for the IBL is correct! + if (((robId>>16) & 0xFF)==0x14 && sLinkSourceId>0x3) { // Check if SLink number for the IBL is correct! generalwarning("In ROB 0x" << std::hex << robId << ": IBL/DBM SLink number not in correct range (0-3): SLink = " << std::dec << sLinkSourceId); } @@ -312,8 +309,8 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD nwords_in_module_fragment = 1; if (m_is_ibl_present) { - m_is_ibl_module = m_pixelCabling->isIBL(robId); - m_is_dbm_module = m_pixelCabling->isDBM(robId); + if (((robId>>16) & 0xFF)==0x14) { m_is_ibl_module=true; } + if (((robId>>16) & 0xFF)==0x15) { m_is_dbm_module=true; } } errorcode = 0; // reset errorcode @@ -343,12 +340,6 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD mLink = fe_IBLheader; // this is used to retrieve the onlineId. It contains only the 3 LSBs of the nnnnn, indicating the number of FE w.r.t. the SLink sLinkHeader = extractSLinkfromLinkNum(linkNum_IBLheader); // this is used to check that the (redundant) info is correctly transmitted - - // Get the hit discrimination configuration setting for this FE - hitDiscCnfg = m_pixelCabling->getHitDiscCnfg(robId, mLink); - //ATH_MSG_DEBUG("HitDiscCngf = " << hitDiscCnfg << " for ROB 0x" << std::hex - // << robId << ", link 0x" << mLink << std::dec); - if (sLinkHeader != sLinkSourceId) { generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink << ": SLink discrepancy: Slink number from SourceId = 0x" << std::hex << sLinkSourceId @@ -447,7 +438,8 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD // Get onlineId - onlineId = m_pixelCabling->getOnlineIdFromRobId(robId, mLink); + onlineId = pixCabling->getOnlineIdFromRobId(robId, mLink); + if (onlineId == 0) { generalwarning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << ": Got invalid onlineId (= 0) in FE header - dataword = 0x" << rawDataWord); @@ -457,7 +449,7 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD ATH_MSG_VERBOSE("In decoder: got onlineId 0x" << std::hex << onlineId ); #endif - offlineIdHash = m_pixelCabling->getOfflineIdHash(onlineId); + offlineIdHash = m_pixel_id->wafer_hash(pixCabling->find_entry_onoff(onlineId)); if (offlineIdHash != previous_offlineIdHash) { m_errors->addRead(offlineIdHash); @@ -728,6 +720,14 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD ATH_MSG_VERBOSE("Starting from tot = 0x" << std::hex << tot[i] << " IBLtot[0] = 0x" << std::hex << IBLtot[0] << " IBLtot[1] = 0x" << IBLtot[1] << std::dec ); #endif + // Get the hit discrimination configuration setting for this FE + if (m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::IBL_PLANAR || m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::DBM) { + hitDiscCnfg = pixHitDiscCnfg->getHitDiscCnfgPL(); + } + else if (m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::IBL_3D) { + hitDiscCnfg = pixHitDiscCnfg->getHitDiscCnfg3D(); + } + // Now do some interpreting of the ToT values if (hitDiscCnfg == 2 && IBLtot[0] == 2) IBLtot[0] = 16; if (hitDiscCnfg == 2 && IBLtot[1] == 2) IBLtot[1] = 16; @@ -1603,7 +1603,14 @@ uint32_t PixelRodDecoder::getDataType(unsigned int rawDataWord, bool link_start) void PixelRodDecoder::addRODError(uint32_t robid, uint32_t robStatus) { std::vector<IdentifierHash> idHashes; - m_pixelCabling->getOfflineList(idHashes,robid); + + const std::deque<Identifier> offlineIdList =SG::ReadCondHandle<PixelCablingCondData>(m_condCablingKey)->find_entry_offlineList(robid); + std::deque<Identifier>::const_iterator it1 = offlineIdList.begin(); + std::deque<Identifier>::const_iterator it2 = offlineIdList.end(); + for (; it1!=it2;++it1) { + idHashes.push_back(m_pixel_id->wafer_hash(*it1)); + } + std::vector<IdentifierHash>::iterator hashIt = idHashes.begin(); std::vector<IdentifierHash>::iterator hashEnd = idHashes.end(); for (; hashIt != hashEnd; ++hashIt) { diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.h index 9f9320d4e968d128a00b00786b40662ada768d90..0c0756fdee2a9b209388672ce1f1f61bade424a4 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.h +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef PIXELRAWDATABYTESTREAM_PIXEL_RODDECODER_H @@ -12,132 +12,139 @@ #include "eformat/SourceIdentifier.h" +#include "PixelConditionsData/PixelCablingCondData.h" +#include "PixelConditionsData/PixelHitDiscCnfgData.h" +#include "StoreGate/ReadCondHandleKey.h" + class IPixelCablingSvc; class PixelID; class IPixelByteStreamErrorsSvc; -class PixelCablingData; -class PixelRodDecoder : virtual public IPixelRodDecoder, public AthAlgTool -{ +class PixelRodDecoder : virtual public IPixelRodDecoder, public AthAlgTool { + + public: + + // Collection type + typedef Pixel1RawData RDO; + typedef InDetRawDataCollection< PixelRDORawData > PixelRawCollection; + + // constructor + PixelRodDecoder(const std::string& type, const std::string& name, + const IInterface* parent ) ; + + // destructor + ~PixelRodDecoder(); + + StatusCode initialize() override; + StatusCode finalize() override; + + StatusCode fillCollection (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, IPixelRDO_Container* rdoIdc, + std::vector<IdentifierHash>* vecHash = NULL) override; + + inline void setDet( const eformat::SubDetector det ); + bool m_is_ibl_present; + bool m_is_ibl_module; + bool m_is_dbm_module; + + uint32_t getDataType(unsigned int rawDataWord, bool link_start); // determine module word type + + ////// decode IBL module header word + uint32_t decodeBCID_IBL(const uint32_t word); // decode IBL BCID from header word + uint32_t decodeL1ID_IBL(const uint32_t word); // decode IBL L1ID from header word + uint32_t decodeFeI4Bflag_IBL(const uint32_t word); // decode IBL FeI4 flag bit + uint32_t decodeModule_IBL(const uint32_t word); // decode IBL module link number from header word + + ////// decode Pixel module header word + uint32_t decodeBCID(const uint32_t word); // decode BCID from header word + uint32_t decodeL1ID(const uint32_t word); // decode L1ID from header word + uint32_t decodeL1IDskip(const uint32_t word); // decode L1ID skips from header word + uint32_t decodeModule(const uint32_t word); // decode module link number from header word + uint32_t decodeHeaderErrors(const uint32_t word); // decode header errors from header word + // uint32_t decodeHeaderBitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty + + + ////// decode Pixel and IBL module hit word + uint32_t decodeRow(const uint32_t word); // decode row number from hit word + uint32_t decodeColumn(const uint32_t word); // decode column number from hit word + uint32_t decodeToT(const uint32_t word); // decode TimeOverThreshold value from hit word + + + ////// decode IBL-only module (not-condensed) hit word + uint32_t decodeLinkNumHit_IBL(const uint32_t word); // decode Link Number in the IBL not-condensed Hit word // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) + // uint32_t decodeHitBitflips_IBL(const uint32_t word); // search for bitflips in wordparts supposed to be empty + + + ////// decode Pixel-only module hit word + uint32_t decodeFE(const uint32_t word); // decode FE number from hit word + // uint32_t decodeFE2(const uint32_t word); // decode FE number from flag type 1 word + // uint32_t decodeHitBitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty + + + ////// decode IBL module trailer word + uint32_t decodeSkippedTrigTrailer_IBL(const uint32_t word); // decode the skipped trigger counter in the IBL trailer + uint32_t decodeTrailerErrors_IBL (const uint32_t word); // decode IBL trailer errors, all together + uint32_t decodeLinkNumTrailer_IBL(const uint32_t word); // decode the link number in the IBL trailer // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) + // uint32_t decodeTimeOutErrorBit_IBL(const uint32_t word); // decode the Time out error bit in the IBL trailer + uint32_t decodeCondensedModeBit_IBL(const uint32_t word); // decode the Condensed mode bit in the IBL trailer + // uint32_t decodeTrailerBitflips_IBL(const uint32_t word); // decode IBL bitflips in the trailer word // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) + + + ////// decode Pixel module trailer word + uint32_t decodeTrailerErrors(const uint32_t word); // decode trailer errors from trailer word + uint32_t decodeTrailerBitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty + uint32_t decodeBcidTrailer_IBL(const uint32_t word); + + + ////// decode Pixel module FE flags + uint32_t decodeFEFlags2(const uint32_t word); // decode FE flags from flag type 2 word + uint32_t decodeMCCFlags(const uint32_t word); // decode MCC flags from flag type 2 word + // uint32_t decodeFEFlags1(const uint32_t word); // decode FE flags from flag type 1 word + // uint32_t decodeFEFlags1Bitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty + // uint32_t decodeFEFlags2Bitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty + + + ////// decode IBL module FE flags + uint32_t decodeServiceCodeCounter_IBL(const uint32_t word); // decode the Service Code Counter from the "non-short" IBL FE flag word + uint32_t decodeServiceCode_IBL(const uint32_t word); // decode the Service code from the "non-short" IBL FE Flag word + uint32_t decodeLinkNumFEFlag_IBL(const uint32_t word); // decode the Link Number present in the IBL FE Flag word // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) + // uint32_t decodeFEFlagBitFlips_IBL(const uint32_t word); // search for bitflips in word partes supposed to be empty // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) + + + ////// decode Pixel RawData word + uint32_t decodeRawData(const uint32_t word); // decode raw data word for IBL and Pixel + + uint32_t extractFefromLinkNum (const uint32_t linkNum); + uint32_t extractSLinkfromLinkNum (const uint32_t linkNum); + + void addRODError(uint32_t rodid, uint32_t robStatus); + + bool CheckLinkStart(const bool Link_start, const int rodId, const unsigned int mLink, const unsigned int mBCID, const unsigned int mLVL1ID, const int LVL1A); + + uint32_t treatmentFEFlagInfo(unsigned int serviceCode, unsigned int serviceCodeCounter); + void addToFlaggedErrorCounter(const unsigned int & serviceCodeCounter); + + private: + int m_masked_errors; + + int m_numGenWarnings; + int m_maxNumGenWarnings; // Maximum number of general warnings to print + int m_numBCIDWarnings; + int m_maxNumBCIDWarnings; // Maximum number of BCID and LVL1ID warnings to print + + + ServiceHandle<IPixelCablingSvc> m_pixelCabling; + + const PixelID* m_pixel_id; + eformat::SubDetector m_det; + + ServiceHandle<IPixelByteStreamErrorsSvc> m_errors; + + SG::ReadCondHandleKey<PixelCablingCondData> m_condCablingKey + {this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"}; + + SG::ReadCondHandleKey<PixelHitDiscCnfgData> m_condHitDiscCnfgKey + {this, "PixelHitDiscCnfgData", "PixelHitDiscCnfgData", "Pixel FEI4 HitDiscConfig key"}; -public: - - // Collection type - typedef Pixel1RawData RDO; - typedef InDetRawDataCollection< PixelRDORawData > PixelRawCollection; - - // constructor - PixelRodDecoder(const std::string& type, const std::string& name, - const IInterface* parent ) ; - - // destructor - ~PixelRodDecoder(); - - StatusCode initialize() override; - StatusCode finalize() override; - - StatusCode fillCollection (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, IPixelRDO_Container* rdoIdc, - std::vector<IdentifierHash>* vecHash = NULL) override; - - inline void setDet( const eformat::SubDetector det ); - bool m_is_ibl_present; - bool m_is_ibl_module; - bool m_is_dbm_module; - - uint32_t getDataType(unsigned int rawDataWord, bool link_start); // determine module word type - - ////// decode IBL module header word - uint32_t decodeBCID_IBL(const uint32_t word); // decode IBL BCID from header word - uint32_t decodeL1ID_IBL(const uint32_t word); // decode IBL L1ID from header word - uint32_t decodeFeI4Bflag_IBL(const uint32_t word); // decode IBL FeI4 flag bit - uint32_t decodeModule_IBL(const uint32_t word); // decode IBL module link number from header word - - ////// decode Pixel module header word - uint32_t decodeBCID(const uint32_t word); // decode BCID from header word - uint32_t decodeL1ID(const uint32_t word); // decode L1ID from header word - uint32_t decodeL1IDskip(const uint32_t word); // decode L1ID skips from header word - uint32_t decodeModule(const uint32_t word); // decode module link number from header word - uint32_t decodeHeaderErrors(const uint32_t word); // decode header errors from header word - // uint32_t decodeHeaderBitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty - - - ////// decode Pixel and IBL module hit word - uint32_t decodeRow(const uint32_t word); // decode row number from hit word - uint32_t decodeColumn(const uint32_t word); // decode column number from hit word - uint32_t decodeToT(const uint32_t word); // decode TimeOverThreshold value from hit word - - - ////// decode IBL-only module (not-condensed) hit word - uint32_t decodeLinkNumHit_IBL(const uint32_t word); // decode Link Number in the IBL not-condensed Hit word // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) - // uint32_t decodeHitBitflips_IBL(const uint32_t word); // search for bitflips in wordparts supposed to be empty - - - ////// decode Pixel-only module hit word - uint32_t decodeFE(const uint32_t word); // decode FE number from hit word - // uint32_t decodeFE2(const uint32_t word); // decode FE number from flag type 1 word - // uint32_t decodeHitBitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty - - - ////// decode IBL module trailer word - uint32_t decodeSkippedTrigTrailer_IBL(const uint32_t word); // decode the skipped trigger counter in the IBL trailer - uint32_t decodeTrailerErrors_IBL (const uint32_t word); // decode IBL trailer errors, all together - uint32_t decodeLinkNumTrailer_IBL(const uint32_t word); // decode the link number in the IBL trailer // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) - // uint32_t decodeTimeOutErrorBit_IBL(const uint32_t word); // decode the Time out error bit in the IBL trailer - uint32_t decodeCondensedModeBit_IBL(const uint32_t word); // decode the Condensed mode bit in the IBL trailer - // uint32_t decodeTrailerBitflips_IBL(const uint32_t word); // decode IBL bitflips in the trailer word // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) - - - ////// decode Pixel module trailer word - uint32_t decodeTrailerErrors(const uint32_t word); // decode trailer errors from trailer word - uint32_t decodeTrailerBitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty - uint32_t decodeBcidTrailer_IBL(const uint32_t word); - - - ////// decode Pixel module FE flags - uint32_t decodeFEFlags2(const uint32_t word); // decode FE flags from flag type 2 word - uint32_t decodeMCCFlags(const uint32_t word); // decode MCC flags from flag type 2 word - // uint32_t decodeFEFlags1(const uint32_t word); // decode FE flags from flag type 1 word - // uint32_t decodeFEFlags1Bitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty - // uint32_t decodeFEFlags2Bitflips(const uint32_t word); // search for bitflips in wordparts supposed to be empty - - - ////// decode IBL module FE flags - uint32_t decodeServiceCodeCounter_IBL(const uint32_t word); // decode the Service Code Counter from the "non-short" IBL FE flag word - uint32_t decodeServiceCode_IBL(const uint32_t word); // decode the Service code from the "non-short" IBL FE Flag word - uint32_t decodeLinkNumFEFlag_IBL(const uint32_t word); // decode the Link Number present in the IBL FE Flag word // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) - // uint32_t decodeFEFlagBitFlips_IBL(const uint32_t word); // search for bitflips in word partes supposed to be empty // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014) - - - ////// decode Pixel RawData word - uint32_t decodeRawData(const uint32_t word); // decode raw data word for IBL and Pixel - - uint32_t extractFefromLinkNum (const uint32_t linkNum); - uint32_t extractSLinkfromLinkNum (const uint32_t linkNum); - - void addRODError(uint32_t rodid, uint32_t robStatus); - - bool CheckLinkStart(const bool Link_start, const int rodId, const unsigned int mLink, const unsigned int mBCID, const unsigned int mLVL1ID, const int LVL1A); - - uint32_t treatmentFEFlagInfo(unsigned int serviceCode, unsigned int serviceCodeCounter); - void addToFlaggedErrorCounter(const unsigned int & serviceCodeCounter); - - private: - int m_masked_errors; - - int m_numGenWarnings; - int m_maxNumGenWarnings; // Maximum number of general warnings to print - int m_numBCIDWarnings; - int m_maxNumBCIDWarnings; // Maximum number of BCID and LVL1ID warnings to print - - - ServiceHandle<IPixelCablingSvc> m_pixelCabling; - - const PixelID* m_pixel_id; - eformat::SubDetector m_det; - PixelCablingData* m_cablingData; - - ServiceHandle<IPixelByteStreamErrorsSvc> m_errors; - }; inline void PixelRodDecoder::setDet( const eformat::SubDetector det ) diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodEncoder.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodEncoder.cxx deleted file mode 100644 index 35937a670197f2f6037034d4374f8c1e979a4385..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodEncoder.cxx +++ /dev/null @@ -1,926 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelRodEncoder.cxx -// Implementation file for class PixelRodEncoder -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////// -// Version 00-00-00 06/03/2007 Daniel Dobos -/////////////////////////////////////////////////////////////////// - -#include "PixelRodEncoder.h" -#include "InDetReadoutGeometry/SiNumerology.h" -#include <algorithm> - -//using namespace std; - -//#define PIXEL_DEBUG ; -//#define PLOTS ; - -//////////////////////// -// constructor -//////////////////////// -PixelRodEncoder::PixelRodEncoder() : - m_PixelID(NULL), - m_pixelCabling("dummy","dummy"), // the cabling tool is set in PixelRawContByteStreamTool - m_PixelDetectorManager(NULL), - m_RodBlockVersion(0), - m_is_ibl_present(0), - m_is_ibl_module(0), - m_is_dbm_module(0) -{ -} - -//////////////////////// -// destructor -//////////////////////// -PixelRodEncoder::~PixelRodEncoder() -{ -} - - -//////////////////////// -// fillROD() - convert Pixel RDO to a vector of 32bit words -//////////////////////// -void PixelRodEncoder::fillROD(std::vector<uint32_t>& v32rod, MsgStream& log, int BCs_per_LVL1ID) -{ -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << " #####################################################################################" << endmsg; - log << MSG::DEBUG << "Entering PixelRodEncoder" << endmsg; -#endif - - // Loop over the Hits in a ROD - VRDO::iterator rdo_it = m_RDOs.begin(); - VRDO::iterator rdo_it_end = m_RDOs.end(); - - m_is_ibl_present = false; - - const InDetDD::SiNumerology& pixSiNum = m_PixelDetectorManager->numerology(); - m_is_ibl_present = (pixSiNum.numLayers() == 4); -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "m_is_ibl_present = " << m_is_ibl_present << endmsg; - log << MSG::DEBUG << "pixSiNum.numLayers() = " << pixSiNum.numLayers() << endmsg; -#endif - - m_is_ibl_module = false; - m_is_dbm_module = false; -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "in fillROD with " << BCs_per_LVL1ID << " LVL1As" << endmsg; - log << MSG::VERBOSE << "Dimension of the RDO vector: " << m_RDOs.size() << endmsg; -#endif - - int hitDiscCnfg = 2; - - // ordering of the elements of the RDOs vector by offlineId, n5 - if (rdo_it != rdo_it_end) { - OrderInitialRdos orderInitialRdos(m_pixelCabling, m_PixelID); - std::sort (rdo_it, rdo_it_end, orderInitialRdos); -/* -#ifdef PIXEL_DEBUG - rdo_it = m_RDOs.begin(); - int i(0); - uint32_t fe; - Identifier offlineId_last; - for (;rdo_it != rdo_it_end; ++rdo_it) { - if (rdo_it == m_RDOs.begin()) { - offlineId_last = m_PixelID->wafer_id((*rdo_it)->identify()); - } - if (m_PixelID->wafer_id((*rdo_it)->identify()) != offlineId_last) { - log << MSG::VERBOSE << endmsg; - } - ++i; - if ( (m_pixelCabling->isIBL((*rdo_it)->identify())) || - (m_pixelCabling->isDBM((*rdo_it)->identify())) ) { // IBL and DBM - fe = m_pixelCabling->getFEwrtSlink(&((*rdo_it)->identify())); - log << MSG::VERBOSE << "IBL/DBM \t"; - } - else { - fe = m_pixelCabling->getFE(&((*rdo_it)->identify()), m_PixelID->wafer_id((*rdo_it)->identify()) ); - log << MSG::VERBOSE << "Pixels \t"; - } - log << MSG::VERBOSE << "offlineId: " << std::hex << m_PixelID->wafer_id((*rdo_it)->identify()) << "\t FE n.: " << fe << endmsg; - offlineId_last = m_PixelID->wafer_id((*rdo_it)->identify()); - //log << MSG::VERBOSE << "offlineId: " << std::hex << m_PixelID->wafer_id((*rdo_it)->identify()) << "\t FE n.: " << fe << endmsg; - } -#endif -*/ - } - // end of ordering of the elements of the RDOs vector by offlineId, n5 - // NOW the RDOs should be ordered following (1) the offlineId, (2) the FE number - - rdo_it = m_RDOs.begin(); - if (rdo_it!=rdo_it_end) { - - const RDO * rawdata; - Identifier offlineId; - Identifier prev_offlineId(0x0); - Identifier pixelId; - bool timing_error = false; - bool condensedMode = false; - bool linkMasked = false; - uint32_t linknumber(0); - uint32_t FE(0); - uint32_t sLink (0); - uint32_t n5(0); - uint32_t prev_n5(0); -// uint32_t prev_FE(0); - - int last_BCID = 0; // needed for encoding of timing information - while (rdo_it != rdo_it_end) { -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "Inside cycle on the rdo_it" << endmsg; - #endif - rawdata = (*rdo_it); - pixelId = rawdata->identify(); - offlineId = m_PixelID->wafer_id(pixelId); - - uint32_t robId = m_pixelCabling->getRobId(offlineId); - uint64_t onlineId = m_pixelCabling->getOnlineId(offlineId); // (32bit) working on modules, not on single pixels - linknumber = (onlineId >> 24) & 0xFFFF; - - // All these functions below are methods of the class PixelRDORawData, InnerDetector/InDetRawEvent/InDetRawData - int TOT = rawdata->getToT(); // it returns a 8 bits "word" - int BCID = rawdata->getBCID(); - int LVL1ID = rawdata->getLVL1ID(); - int LVL1A = rawdata->getLVL1A(); - - m_is_ibl_module = m_pixelCabling->isIBL(robId); - m_is_dbm_module = m_pixelCabling->isDBM(robId); - -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << " ********************* robId retrieved: 0x" << std::hex << robId << std::dec << endmsg; - log << MSG::DEBUG << "offlineId retrieved: " << offlineId << endmsg; - log << MSG::DEBUG << "onlineId retrieved: 0x" << std::hex << onlineId << ", linknumber retrieved: 0x" << linknumber << std::dec - << ", ToT: " << TOT << ", BCID: " << BCID << ", LVL1ID: " << LVL1ID << ", LVL1A: " << LVL1A << endmsg; - log << MSG::DEBUG << "Is IBL = " << m_is_ibl_module << " or is DBM = " << m_is_dbm_module << endmsg; -#endif - - -//************************************************************************************************* -// ************************************* PIXEL CASE ***************************************** -//************************************************************************************************* - if (!(m_is_ibl_module || m_is_dbm_module)) { - -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "This is the PixelCase of the PixelRodEncoder" << endmsg; -#endif - -//---------------------------------------------------------------------------------------------- -//- Fill the data -//---------------------------------------------------------------------------------------------- - if (prev_offlineId != offlineId) { - int fake_BCID; - timing_error = false; - if (BCs_per_LVL1ID < LVL1A) { // That must not happen, if LVL1A > BCs_per_LVL1ID, BCs_perLVL1ID is wrongly set in the joboptions -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "LVL1A > BCs_per_LVL1ID, timing corrupt, ignoring timing." << " Set BCs per LVL1ID: " << BCs_per_LVL1ID << endmsg; -#endif - timing_error = true; - } - if (prev_offlineId != 0x0) { - v32rod.push_back(packLinkTrailer(0x0)); -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "Pixel module trailer" << endmsg; - log << MSG::VERBOSE << " ------------------------------------------------------------------------------------------" << endmsg; -#endif - //------------------------------------------------------------------------------------ - //- Write empty Header/Trailer pairs after the level1 accept - //------------------------------------------------------------------------------------ - fake_BCID = last_BCID; - int max_BCID = fake_BCID + BCs_per_LVL1ID - LVL1A - 1; - - while ((fake_BCID < max_BCID) && !timing_error) { - fake_BCID++; - v32rod.push_back(packLinkHeader(linknumber, fake_BCID, LVL1ID, (LVL1ID >> 4), 0x0)); - v32rod.push_back(packLinkTrailer(0x0)); -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "(after) empty Pixel Module header/trailer pair written for BCID " << fake_BCID << endmsg; -#endif - } // end while cycle "while ((fake_BCID < max_BCID) && !timing_error)" - } // end if "if (prev_offlineId != 0x0) " - - //-------------------------------------------------------------------------------------- - //- Write empty Header/Trailer pairs before the level1 accept - //-------------------------------------------------------------------------------------- - fake_BCID = BCID - LVL1A; - - while ((fake_BCID < BCID) && !timing_error) { - v32rod.push_back(packLinkHeader(linknumber, fake_BCID, LVL1ID, (LVL1ID >> 4), 0x0)); - v32rod.push_back(packLinkTrailer(0x0)); -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "(before) empty Pixel Module header/trailer pair written for BCID " << fake_BCID << endmsg; -#endif - fake_BCID++; - } // end while cycle "while ((fake_BCID < BCID) && !timing_error)" - - v32rod.push_back(packLinkHeader(linknumber, BCID, LVL1ID, (LVL1ID >> 4), 0x0)); -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "Pixel module header" << endmsg; -#endif - } // end if "if (prev_offlineId != offlineId) " - - //-------------------------------------------------------------------------------------- - //- Write RawDataWord - //-------------------------------------------------------------------------------------- - - FE = m_pixelCabling->getFE(&pixelId,offlineId); - uint32_t row = m_pixelCabling->getRow(&pixelId,offlineId); - uint32_t column = m_pixelCabling->getColumn(&pixelId,offlineId); - v32rod.push_back(packRawDataWord(FE, row, column, TOT)); - - - // The following was used for running a validation scrip and making validation plots -#ifdef PLOTS - int eta_i = m_PixelID->eta_index(pixelId); - int phi_i = m_PixelID->phi_index(pixelId); - std::cout << "[PlotB]: " << robId << " " << eta_i << " " << phi_i << " " << TOT << std::endl; - std::cout << "[PlotC]: " << robId << " " << column << " " << row << " " << TOT << std::endl; - - std::cout << "[VAL] " << std::hex << pixelId << " 0x" << robId << " 0x" << onlineId // << " " << offlineId - << std::dec << " " << m_PixelID->eta_module(pixelId) << " " << m_PixelID->phi_module(pixelId) - << " " << m_PixelID->eta_index(pixelId) << " " << m_PixelID->phi_index(pixelId) << std::endl; -#endif - - ++rdo_it; - last_BCID = BCID; - -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "Found hit in PIXEL with PixelID: 0x" << std::hex << pixelId << std::dec << " FE: " << FE << " Row: " << row << " Column: " << column << " TOT: " << TOT << " BCID: " << BCID << " LVL1ID: " << LVL1ID << " LVL1A: " << LVL1A << endmsg; -#endif - -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "Encoded Pixel OfflineID: 0x" << std::hex << offlineId << " OnlineID: 0x" << onlineId << " -> Linknumber: 0x" << linknumber << std::dec << endmsg; -#endif - prev_offlineId = offlineId; - } // end Pixel Case - - - - -//************************************************************************************************* -// ************************************* IBL CASE ***************************************** -//************************************************************************************************* - else { - -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "Inside the IBL/DBM case of the PixelRodEncoder" << endmsg; -#endif - - FE = m_pixelCabling->getFEwrtSlink(&pixelId); - sLink = onlineId & 0xF; // extract the LSB 4 bits from the onlineId - if (sLink > 0x3) { - log << MSG::WARNING << "The SLink is not in the correct range [0,3]. This is due to the non-correct onlineId/ROBID definition. Skipping this RDO" << endmsg; - continue; // skipping this rdo, because it gives wrong onlineID (and, possibly, other pieces of information are wrong too) - } - n5 = ((sLink & 0x3) << 3) | (FE & 0x7); // this variable contains the 5 "nnnnn" bits, the 2 MSB ones representing the copy of the S-Link number (0 to 3) and the 2 LSBs representing the FE number over the S-Link -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "FE (w.r.t. SLink) = 0x" << std::hex << FE << " sLink: 0x" << sLink << " => n5: 0x" << n5 << std::dec << endmsg; -#endif - - hitDiscCnfg = m_pixelCabling->getHitDiscCnfg(robId, FE); - -//---------------------------------------------------------------------------------------------- -//- Fill the data -//---------------------------------------------------------------------------------------------- -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "(prev_offlineId != offlineId) = " << (prev_offlineId != offlineId) << " (prev_n5 != n5) = " << (prev_n5 != n5) << " " << endmsg; - log << MSG::VERBOSE << "prev_offlineId = " << prev_offlineId << endmsg; -#endif - if ((prev_offlineId != offlineId) || (prev_n5 != n5)) { - int fake_BCID; - timing_error = false; - if (BCs_per_LVL1ID < LVL1A) { // That must not happen, if LVL1A > BCs_per_LVL1ID, BCs_perLVL1ID is wrongly set in the joboptions -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "LVL1A > BCs_per_LVL1ID, timing corrupt, ignoring timing." << " Set BCs per LVL1ID: " << BCs_per_LVL1ID << endmsg; -#endif - timing_error = true; - } - - if (prev_offlineId != 0x0) { - v32rod.push_back(packLinkTrailer_IBL(prev_n5, timing_error, condensedMode, linkMasked)); // Trailer for IBL - condensedMode = false; -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "IBL Module trailer (because prev_offlineId != 0x0)" << endmsg; -#endif - - //------------------------------------------------------------------------------------ - //- Write empty Header/Trailer pairs after the level1 accept - //------------------------------------------------------------------------------------ - fake_BCID = last_BCID; - int max_BCID = fake_BCID + BCs_per_LVL1ID - LVL1A - 1; - - while ((fake_BCID < max_BCID) && !timing_error) { - fake_BCID++; - v32rod.push_back(packLinkHeader_IBL(n5, fake_BCID, LVL1ID, 0x0)); // Header for IBL - v32rod.push_back(packLinkTrailer_IBL(n5, timing_error, condensedMode, linkMasked)); // Trailer for IBL - -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "(after) empty IBL Module header/trailer pair written for BCID " << fake_BCID << endmsg; -#endif - } // end while cycle "while ((fake_BCID < max_BCID) && !timing_error)" - } // end if "if (prev_offlineId != 0x0) " - - //-------------------------------------------------------------------------------------- - //- Write empty Header/Trailer pairs before the level1 accept - //-------------------------------------------------------------------------------------- - fake_BCID = BCID - LVL1A; - - while ((fake_BCID < BCID) && !timing_error) { - v32rod.push_back(packLinkHeader_IBL(n5, fake_BCID, LVL1ID, 0x0)); // Header for IBL - v32rod.push_back(packLinkTrailer_IBL(n5, timing_error, condensedMode, linkMasked)); // Trailer for IBL -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "(before) empty IBL Module header/trailer pair written for BCID " << fake_BCID << endmsg; -#endif - fake_BCID++; - } // end while cycle "while ((fake_BCID < BCID) && !timing_error)" - - v32rod.push_back(packLinkHeader_IBL(n5, BCID, LVL1ID, 0x0)); // Header for IBL -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "IBL Module header" << endmsg; -#endif - } // end if "if (prev_offlineId != offlineId) " - - //-------------------------------------------------------------------------------------- - //- Write RawData word - //-------------------------------------------------------------------------------------- - VRDO rdos_sameIBL_offlineId; // vector containing all the rdos with the same offlineId => belonging to the same IBL FE-I4 chip - - // This loop fills the rdo_sameIBL_offlineId vector with all the RDOs that have the same offlineId and same FEw.r.t.SLink => all RDOs coming from the same FE - for (; (rdo_it != rdo_it_end) && (((m_pixelCabling->isIBL((*rdo_it)->identify())) && (m_is_ibl_module)) || ((m_pixelCabling->isDBM((*rdo_it)->identify())) && m_is_dbm_module)); ++rdo_it) { - Identifier pixelId_probe = (*rdo_it)->identify(); - Identifier offlineId_probe = m_PixelID->wafer_id(pixelId_probe); - uint32_t fe_probe = m_pixelCabling->getFEwrtSlink(&pixelId_probe); - -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "offlineId: " << offlineId << " offlineId_probe: " << offlineId_probe << ", fe: " << FE << " fe_probe: " << fe_probe << endmsg; -#endif - - if ((offlineId_probe == offlineId) && (FE == fe_probe)) { -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "=======> IN " << endmsg; -#endif - rdos_sameIBL_offlineId.push_back((*rdo_it)); - } - else { -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "=======> OUT." << endmsg; // It has been checked that no RDO is being missed when running inside the following loop. -#endif - break; - } - } - - VRDO::iterator rdo_same_it = rdos_sameIBL_offlineId.begin(); - VRDO::iterator rdo_same_it_end = rdos_sameIBL_offlineId.end(); - -#ifdef PIXEL_DEBUG - //check: list of all the rdos with same offlineId, listing also the column, the row and the Tot - for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) { - // log << MSG::DEBUG << "Dump rdo : " << (*rdo_same_it) << "\t"; - Identifier pixelId_probe = (*rdo_same_it)->identify(); - uint32_t col = m_pixelCabling->getColumn(&pixelId_probe, offlineId); // offlineId of rdos in rdos_sameIBL_offlineId vector are, of course, all equal - uint32_t row = m_pixelCabling->getRow(&pixelId_probe, offlineId); - int tot = (*rdo_same_it)->getToT(); - log << MSG::VERBOSE << "col: " << col << " (0x" << std::hex << col << std::dec << ")\trow: "<< row << " (0x" << std::hex << row << std::dec << ")\ttot: " << tot << "(0x" <<std::hex << tot << std::dec << ")" << endmsg; - } - - rdo_same_it = rdos_sameIBL_offlineId.begin(); - rdo_same_it_end = rdos_sameIBL_offlineId.end(); -#endif - - // Order the RDOs within the vector rdos_sameIBL_offlineId, following the ordering rules of orderRdos - OrderRdos orderRdos(offlineId,m_pixelCabling); - std::sort (rdo_same_it, rdo_same_it_end, orderRdos); - - //check: -#ifdef PIXEL_DEBUG - rdo_same_it = rdos_sameIBL_offlineId.begin(); - rdo_same_it_end = rdos_sameIBL_offlineId.end(); - - log << MSG::DEBUG << "Re-ordered RDOs with Same offlineId:" << endmsg; - for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) { - Identifier pixelId_probe = (*rdo_same_it)->identify(); - uint32_t col = m_pixelCabling->getColumn(&pixelId_probe, offlineId); - uint32_t row = m_pixelCabling->getRow(&pixelId_probe, offlineId); - int tot = (*rdo_same_it)->getToT(); - int eta_i = m_PixelID->eta_index(pixelId_probe); - int phi_i = m_PixelID->phi_index(pixelId_probe); - int eta_m = m_PixelID->eta_module(pixelId_probe); - int phi_m = m_PixelID->phi_module(pixelId_probe); - log << MSG::VERBOSE << "pixelId: " << pixelId_probe << ", eta_i: " << eta_i << ", phi_i: " << phi_i << ", eta_m: " << eta_m << ", phi_m: " << phi_m << endmsg; - log << MSG::VERBOSE << "col: 0x" << std::hex << col << std::dec << ", row: 0x" <<std::hex << row << std::dec << ", tot = 0x" << std::hex << tot << std::dec << endmsg; - } - log << MSG::DEBUG << "rdos_sameIBL_offlineId.size() = " << rdos_sameIBL_offlineId.size() << endmsg; -#endif -#ifdef PLOTS - rdo_same_it = rdos_sameIBL_offlineId.begin(); - rdo_same_it_end = rdos_sameIBL_offlineId.end(); - for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) { - Identifier pixelId_probe = (*rdo_same_it)->identify(); - uint32_t col = m_pixelCabling->getColumn(&pixelId_probe, offlineId); - uint32_t row = m_pixelCabling->getRow(&pixelId_probe, offlineId); - int tot = (*rdo_same_it)->getToT(); - int eta_i = m_PixelID->eta_index(pixelId_probe); - int phi_i = m_PixelID->phi_index(pixelId_probe); - std::cout << "[Plot2]: " << robId << " " << eta_i << " " << phi_i << " " << tot << std::endl; - std::cout << "[Plot3]: " << robId << " " << col << " " << row << " " << tot << std::endl; - } -#endif - -////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// look for adjacent cell that can allow the "compression" of the two hit info in one: -// instead of having two hits (= 2 columns, 2 rows and 2 tots), in fact, -// if two adjacent pixels ([col, row] and [col, row+1]) have fired (respectively tot([col, row]) and tot([col, (row+1)]) -// then -// the row in the hit will be the row with lower number, the column in the hit will be the common column number -// and the tot will be = (tot [(col, row)] << 4) | tot[(col, row+1)] -////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - std::vector <uint32_t> vRows; - std::vector <uint32_t> vCols; - std::vector <int> vTots; - bool doubleHit = false; - static const uint32_t rowsPerFE = 336;// FIXME: this is a hardcoded variable, would be better to get it from somewhere - - rdo_same_it = rdos_sameIBL_offlineId.begin(); - rdo_same_it_end = rdos_sameIBL_offlineId.end(); - - VRDO::iterator rdo_test_it = rdos_sameIBL_offlineId.begin(); -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "Looking for adjacent pixels and saving col, row and tot information." << endmsg; -#endif - - for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) { - doubleHit = false; - Identifier pixelId_probe = (*rdo_same_it)->identify(); - uint32_t col0 = m_pixelCabling->getColumn(&pixelId_probe, offlineId); - uint32_t row0 = m_pixelCabling->getRow(&pixelId_probe, offlineId); - int totInHitWord (0); -#ifdef PLOTS - std::cout << "[VAL] " << std::hex << pixelId_probe << " 0x" << robId << " 0x" << onlineId // << " " << offlineId - << std::dec << " " << m_PixelID->eta_module(pixelId_probe) << " " << m_PixelID->phi_module(pixelId_probe) - << " " << m_PixelID->eta_index(pixelId_probe) << " " << m_PixelID->phi_index(pixelId_probe) << std::endl; -#endif - - if (row0 == rowsPerFE) { -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "Hit in the last row (== 336) of the IBL FE." << endmsg; -#endif - } - else { - if ((rdo_same_it + 1) != rdo_same_it_end) { - rdo_test_it = rdo_same_it + 1; - Identifier pixelId_probe = (*rdo_test_it)->identify(); - uint32_t col1 = m_pixelCabling->getColumn(&pixelId_probe, offlineId); - uint32_t row1 = m_pixelCabling->getRow(&pixelId_probe, offlineId); -#ifdef PLOTS - std::cout << "[VAL] " << std::hex << pixelId_probe << " 0x" << robId << " 0x" << onlineId // << " " << offlineId - << std::dec << " " << m_PixelID->eta_module(pixelId_probe) << " " << m_PixelID->phi_module(pixelId_probe) - << " " << m_PixelID->eta_index(pixelId_probe) << " " << m_PixelID->phi_index(pixelId_probe) << std::endl; -#endif - -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "Comparing rdo[i] = " << (*rdo_same_it) << " with rdo[i+1] = " << (*rdo_test_it) << endmsg; - log << MSG::VERBOSE << " col0 = 0x" << std::hex << col0 << " col1 = 0x" << col1 << " row0 = 0x" << row0 << "\t row1 = 0x" << row1 << std::dec << endmsg; -#endif - - if ((col1 == col0) && (row1 == (row0 + 1))) { - doubleHit = true; -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "Two adjacent hits found" << endmsg; -#endif - int tot0 = (*rdo_same_it)->getToT(); - int tot1 = (*rdo_test_it)->getToT(); - - // Adjust ToT according to hitdisccnfg setting - if (hitDiscCnfg == 2 && tot0 == 16) tot0 = 2; - if (hitDiscCnfg == 2 && tot1 == 16) tot1 = 2; - - int overflow = 14; - if (hitDiscCnfg == 1) overflow = 15; - if (hitDiscCnfg == 2) overflow = 16; - - if (tot0 > overflow) tot0 = overflow; - if (tot1 > overflow) tot1 = overflow; - - totInHitWord = (tot0 << 4) | tot1; - -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "doubleHit = " << std::boolalpha << doubleHit << std::noboolalpha << " ===> (col0 == col1) : 0x" << std::hex << col0 << " = 0x" << col1 << "; (row0 = row1 - 1) : 0x" << row0 << " => 0x" << row1 <<"; (tot0) : 0x" << tot0 << ", (tot1) : 0x" << tot1 << " => totInHitWord: 0x" << totInHitWord << std::dec << endmsg; -#endif - rdo_same_it++; - } // end if "(col1==col0) && (row1 == (row0+1))" - } // end if "(rdo_same_it + 1) != rdo_same_it_end" - - else { -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "last rdo with same Offline Id" << endmsg; -#endif - } // end if it's the last rdo with same offlineId - } // end if "row0 == rowsPerFE" (== 336) - - if (!doubleHit) { - - int tot0 = (*rdo_same_it)->getToT(); - - // Adjust ToT according to hitdisccnfg setting - if (hitDiscCnfg == 2 && tot0 == 16) tot0 = 2; - - int overflow = 14; - if (hitDiscCnfg == 1) overflow = 15; - if (hitDiscCnfg == 2) overflow = 16; - if (tot0 > overflow) tot0 = overflow; - - totInHitWord = (tot0 << 4) | 0x0; - -#ifdef PIXEL_DEBUG - log << MSG::VERBOSE << "doubleHit = " << std::boolalpha << doubleHit << std::noboolalpha << " ===> col0: 0x" << std::hex << col0 << std::dec << "; row0: 0x" << std::hex << row0 << std::dec << " totInHitWord: 0x" << std::hex << totInHitWord << std::dec << endmsg; -#endif - } - vCols.push_back(col0); - vRows.push_back(row0); - vTots.push_back(totInHitWord); - } // end loop over the rdos with the same offlineId - - //check: -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "CHECKs over the vectors storing columns, rows, ToTs of IBL/DBM hits:" << endmsg; - log << MSG::VERBOSE << " vCols: " << endmsg; - std::vector<uint32_t>::iterator vCols_it = vCols.begin(); - std::vector<uint32_t>::iterator vCols_it_end = vCols.end(); - for (; vCols_it != vCols_it_end; ++vCols_it) { - log << MSG::VERBOSE << "0x" << std::hex << *vCols_it << std::dec << " "; - } - log << MSG::VERBOSE << endmsg; - log << MSG::VERBOSE << "vRows: " << endmsg; - std::vector<uint32_t>::iterator vRows_it = vRows.begin(); - std::vector<uint32_t>::iterator vRows_it_end = vRows.end(); - for (; vRows_it != vRows_it_end; ++vRows_it) { - log << MSG::VERBOSE << "0x" << std::hex << *vRows_it << std::dec <<" "; - } - log << MSG::VERBOSE << endmsg; - log << MSG::VERBOSE << "vTots: " << endmsg; - std::vector<int>::iterator vTots_it = vTots.begin(); - std::vector<int>::iterator vTots_it_end = vTots.end(); - for (; vTots_it != vTots_it_end; ++vTots_it) { - log << MSG::VERBOSE << "0x" << std::hex << *vTots_it << std::dec << " "; - } - log << MSG::VERBOSE << endmsg; - log << MSG::DEBUG << "rdos_sameIBL_offlineId.size() = " << rdos_sameIBL_offlineId.size() << " vRows.size() = " << vRows.size() << " vCols.size() = " << vCols.size() << " vTots.size() = " << vTots.size() << endmsg; -#endif - - //Packing of the IBL hits - if (vRows.size() >= 5) { -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "5 (or more) IBL hits have been consequently found. They can be written as condensed hits" << endmsg; -#endif - while (vRows.size() >= 5) { - packIBLcondensed(v32rod, vRows, vCols, vTots); - condensedMode= true; - - } - } - if (vRows.size() != 0) { // packing remaining non-condensed IBL hit words - // int cycleCounter(0); - for (; vRows.size() != 0; ) { - v32rod.push_back(packRawDataWord_IBL(vRows.at(0), vCols.at(0), vTots.at(0), n5)); - - vRows.erase(vRows.begin()); - vCols.erase(vCols.begin()); - vTots.erase(vTots.begin()); - } - } - - last_BCID = BCID; - -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "Encoded IBL OfflineID: " << std::hex << offlineId << " OnlineID: 0x" << onlineId << std::dec << endmsg; -#endif - - prev_offlineId = offlineId; - prev_n5 = n5; -// prev_FE = FE; - } // end of the IBL case - } // end WHILE cycle " while (rdo_it!=rdo_it_end) " - - if (m_is_ibl_module || m_is_dbm_module) { - v32rod.push_back(packLinkTrailer_IBL(n5, timing_error, condensedMode, linkMasked)); - condensedMode = false; -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "Module IBL/DBM trailer (at end of the loop)" << endmsg; -#endif - } - else { - v32rod.push_back(packLinkTrailer(0x0)); -#ifdef PIXEL_DEBUG - log << MSG::DEBUG << "Pixel module trailer" << endmsg; -#endif - } - } // end if "if (rdo_it != rdo_it_end)" -#ifdef PIXEL_DEBUG - else { - log << MSG::DEBUG << "rdo_it == rdo_it_end" << endmsg; - } -#endif - return; -} - - - -//////////////////////// -// encode module Header for Pixels -// Pixel Header: 001PtlbxxnnnnnnnMMMMLLLLBBBBBBBB, -//////////////////////// -uint32_t PixelRodEncoder::packLinkHeader(uint32_t module, uint32_t bcid, uint32_t lvl1id, uint32_t lvl1idskip, uint32_t errors) { - lvl1idskip = 0; // FIXME LVL1IDskip hardcoded as 0 - uint32_t result = 0; - result = PRB_LINKHEADER | ((bcid & PRB_BCIDmask) << PRB_BCIDskip) | ((lvl1id & PRB_L1IDmask) << PRB_L1IDskip) | ((lvl1idskip & PRB_L1IDSKIPmask) << PRB_L1IDSKIPskip) | ((module & PRB_MODULEmask) << PRB_MODULEskip) | ((errors & PRB_HEADERERRORSmask) << PRB_HEADERERRORSskip); -#ifdef PLOTS - std::cout << "[PlotA]:0x " << std::hex << result << std::dec << std::endl; - std::cout << "[PlotA]:(dec) " << result << std::endl; -#endif - return result; -} - - -//////////////////////// -// encode module Header for IBL -// IBL Header: 001nnnnnFLLLLLLLLLLLLLBBBBBBBBBB -//////////////////////// -uint32_t PixelRodEncoder::packLinkHeader_IBL(uint32_t module, uint32_t bcid, uint32_t lvl1id, uint32_t feFlag) { - uint32_t result = 0; - result = PRB_LINKHEADER | ((bcid & PRB_BCIDmask_IBL) << PRB_BCIDskip_IBL) | ((lvl1id & PRB_L1IDmask_IBL) << PRB_L1IDskip_IBL) | ((module & PRB_MODULEmask_IBL) << PRB_MODULEskip_IBL) | ((feFlag & PRB_FeI4BFLAGmask_IBL) << PRB_FeI4BFLAGskip_IBL); -#ifdef PIXEL_DEBUG - // std::cout << "IBL HEADER: linkNum (=n): 0x" << std::hex << module << std::dec << ", bcid: " << bcid << ", lvl1id: " << lvl1id << ", feFlag: " << feFlag << "====> Result: 0x" << std::hex << result << std::dec << std::endl; -#endif -#ifdef PLOTS - std::cout << "[Plot1]:0x " << std::hex << result << std::dec << std::endl; - std::cout << "[Plot1]:(dec) " << result << std::endl; -#endif - return result; -} - - -//////////////////////// -// encode IBL non-condensed hit word: 0-8: row,9-15: column, 16-23:TOT, 24-28: nLink ----> 100xxnnnTTTTTTTTCCCCCCCRRRRRRRRR -//////////////////////// -uint32_t PixelRodEncoder::packRawDataWord_IBL(uint32_t row, uint32_t column, int ToT, uint32_t nLink) { - uint32_t result = 0; - result = PRB_DATAWORD | ((row & PRB_ROWmask_IBL) << PRB_ROWskip_IBL) | ((column & PRB_COLUMNmask_IBL) << PRB_COLUMNskip_IBL) | ((ToT & PRB_TOTmask) << PRB_TOTskip) | ((nLink & PRB_LINKNUMHITmask_IBL) << PRB_LINKNUMHITskip_IBL); -#ifdef PIXEL_DEBUG - // std::cout << "IBL NON-CONDENSED HIT: nLink: 0x" << std::hex << nLink << ", row: 0x" << row << ", col: 0x" << column << ", tot: 0x" << ToT << " ===> encoded IBL word: 0x" << result << std::dec << std::endl; -#endif -#ifdef PLOTS - std::cout << "[Plot1]:0x " << std::hex << result << std::dec << std::endl; - std::cout << "[Plot1]:(dec) " << result << std::endl; -#endif - return result; -} - -//////////////////////// -// encode PIXEL hit word: bits 0-7:row,8-12:column,16-23:TOT,24-27:FE ----> 100xFFFFTTTTTTTTxxxCCCCCRRRRRRRR -//////////////////////// -uint32_t PixelRodEncoder::packRawDataWord(uint32_t FE, uint32_t row, uint32_t column, uint32_t ToT) { - - uint32_t result = 0; - result = PRB_DATAWORD | ((row & PRB_ROWmask) << PRB_ROWskip) | ((column & PRB_COLUMNmask) << PRB_COLUMNskip) | ((ToT & PRB_TOTmask) << PRB_TOTskip) | ((FE & PRB_FEmask) << PRB_FEskip); -#ifdef PLOTS - std::cout << "[PlotA]:0x " << std::hex << result << std::dec << std::endl; - std::cout << "[PlotA]:(dec) " << result << std::endl; -#endif - return result; -} - - -//////////////////////// -// encode PIXEL module trailer (bits 26-28:trailer errors) -//////////////////////// -uint32_t PixelRodEncoder::packLinkTrailer(uint32_t errors) { - uint32_t result = PRB_LINKTRAILER | ((errors & PRB_TRAILERERRORSmask) << PRB_TRAILERERRORSskip); -#ifdef PLOTS - std::cout << "[PlotA]:0x " << std::hex << result << std::dec << std::endl; - std::cout << "[PlotA]:(dec) " << result << std::endl; -#endif - return result; -} - - -//////////////////////// -// encode IBL module trailer (bits 26-28:trailer errors) -//////////////////////// -uint32_t PixelRodEncoder::packLinkTrailer_IBL(uint32_t linknum, bool timeOutErrorBit, bool condensedModeBit, bool linkMasked) { - // return PRB_LINKTRAILER |((timeOutErrorBit & PRB_TIMEOUTERRORmask_IBL) << PRB_TIMEOUTERRORskip_IBL) | ((condensedModeBit & PRB_CONDENSEDMODEmask_IBL) << PRB_CONDENSEDMODEskip_IBL) | ((linkMasked & PRB_LINKMASKEDmask_IBL) << PRB_LINKMASKEDskip_IBL) | ((linknum & PRB_LINKNUMTRAILERmask_IBL) << PRB_LINKNUMTRAILERskip_IBL); - uint32_t result; - result = PRB_LINKTRAILER | (timeOutErrorBit << PRB_TIMEOUTERRORskip_IBL) | (condensedModeBit << PRB_CONDENSEDMODEskip_IBL) | (linkMasked << PRB_LINKMASKEDskip_IBL) | ((linknum & PRB_LINKNUMTRAILERmask_IBL) << PRB_LINKNUMTRAILERskip_IBL); -#ifdef PIXEL_DEBUG - // std::cout << "IBL TRAILER: linknum = 0x" << std::hex << linknum << ", timeOutErrorBit: 0x" << timeOutErrorBit << ", condensedModeBit: 0x" << condensedModeBit << ", linkMasked: 0x" << linkMasked << ", ===> Result: 0x" << result << std::dec << std::endl; -#endif -#ifdef PLOTS - std::cout << "[Plot1]:0x " << std::hex << result << std::dec << std::endl; - std::cout << "[Plot1]:(dec) " << result << std::endl; -#endif - return result; -} - - -//////////////////////// -// Encode IBL Condensed hit words: -// for IBL condensed word: (R = row, C = column, T = TOT) -// 1st word: 101 RRRRRTTTTTTTTCCCCCCCRRRRRRRRR -// 2nd word: 1 CCCRRRRRRRRRTTTTTTTTCCCCCCCRRRR -// 3rd word: 1 TTTCCCCCCCRRRRRRRRRTTTTTTTTCCCC -// 4th word: 111 TTTTTTTTCCCCCCCRRRRRRRRRTTTTT -//////////////////////// - -void PixelRodEncoder::packIBLcondensed(std::vector <uint32_t> & v32rod, std::vector <uint32_t> & vRows, std::vector <uint32_t> & vCols, std::vector<int> & vTots) -{ -#ifdef PIXEL_DEBUG -// std::cout << "Inside packIBLcondensed function\n"; -#endif - - unsigned int condWord[nCondensedWords]; - condWord[0] = PRB_FIRSTHITCONDENSEDWORD | vRows[0] | (vCols[0] << skipRow) | (vTots[0] << (skipRow + skipCol) | ((vRows[1] & mask5) << (skipRow + skipCol + skipTOT))); - - condWord[1] = PRB_MIDDLEHITCONDENSEDWORD | (vRows[1] >> skip5) | (vCols[1] << skip4) | (vTots[1] << (skip4 + skipCol)) | (vRows[2] << (skip4+skipCol+skipTOT)) | ((vCols[2] & mask3) << (skip4+skipCol+skipTOT+skipRow)); - - condWord[2] = PRB_MIDDLEHITCONDENSEDWORD | (vCols[2] >> skip3) | (vTots[2] << skip4) | (vRows[3] << (skip4+skipTOT)) | (vCols[3] << (skip4+skipTOT+skipRow)) | ((vTots[3] & mask3) << (skip4+skipTOT+skipRow+skipCol)); - - condWord[3] = PRB_DATAMASK | (vTots[3] >> skip3) | (vRows[4] << skip5) | (vCols[4] << (skip5+skipRow)) | (vTots[4] << (skip5+skipRow+skipCol)); - - for (int j(0); j < 4; ++j) { - v32rod.push_back(condWord[j]); // Filling the ROD vector here -#ifdef PIXEL_DEBUG - // std::cout << "condensedWord: 0x" << std::hex << condWord[j] << std::dec << std::endl; -#endif -#ifdef PLOTS - std::cout << "[Plot1]:0x " << std::hex << condWord[j] << std::dec << std::endl; - std::cout << "[Plot1]:(dec) " << condWord[j] << std::endl; -#endif - } - - vRows.erase (vRows.begin(), vRows.begin() + 5); - vCols.erase (vCols.begin(), vCols.begin() + 5); - vTots.erase (vTots.begin(), vTots.begin() + 5); -#ifdef PIXEL_DEBUG -// std::cout << "\tvRows.size() = " << vRows.size() << "\tvCols.size() = " << vCols.size() << "\tvTots.size() = " << vTots.size() << std::endl; -#endif - return; -} - - -//////////////////////// -// function used by std::sort to order the RDO vector that contains RDOs with the same offlineId -// It orders the rdos_sameIBL_offlineId by //column (ascending order), row (ascending order, once the column is the same) -// example: coordinates (col, row): (1,1), (3,6), (1,2), (4,82), (4,81) become: (1,1), (1,2), (3,6), (4,81), (4,82). -//////////////////////// -/* -bool OrderRdos::operator () (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1) //, const Identifier & offlineId -{ - - Identifier pixelId0 = rdo0->identify(); - uint32_t col0 = m_pixelCabling->getColumn(&pixelId0, m_offlineId); - Identifier pixelId1 = rdo1->identify(); - uint32_t col1 = m_pixelCabling->getColumn(&pixelId1, m_offlineId); - if (col0 < col1) {return true;} - if (col0 == col1) { - uint32_t row0 = m_pixelCabling->getRow(&pixelId0, m_offlineId); - uint32_t row1 = m_pixelCabling->getRow(&pixelId1, m_offlineId); - return (row0<row1); - } - else {return false;} -} -*/ - -bool OrderRdos::operator () (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1) //, const Identifier & offlineId -{ - // const uint32_t halfCols = 40; // this is the number of the FE-I4 columns / 2, because the two tokens in the FE-I4 run from the double column 0 to 19, and then from 39 to 20. - // This corresponds to column 1 to 40, and 79-80, 77-78, ... to 41-42. - Identifier pixelId0 = rdo0->identify(); - uint32_t col0 = m_pixelCabling->getColumn(&pixelId0, m_offlineId); - uint32_t row0 = m_pixelCabling->getRow(&pixelId0, m_offlineId); - Identifier pixelId1 = rdo1->identify(); - uint32_t col1 = m_pixelCabling->getColumn(&pixelId1, m_offlineId); - uint32_t row1 = m_pixelCabling->getRow(&pixelId1, m_offlineId); - - - // Decide if (col0, row0) should be inserted in front of (col1, row1): - - // Check if both hits are in same column - if (col0 == col1) return (row0 < row1); - - // If not, check if they are in same double column - else if (((col0 == col1-1) && (col1%2 == 0)) || ((col1 == col0-1) && (col0%2 == 0))) { - - // If rows are equal, sort by ascending column - if (row0 == row1) return (col0 < col1); - // If rows are unequal, sort by ascending row - else return (row0 < row1); - } - - // Not in same double column: Separate between FE halfs - else { - - // If both hits are in second FE half: Sort by descending col - if (col0 > 40 && col1 > 40) return (col0 > col1); - - // Otherwise, sort by ascending col - else return (col0 < col1); - } - - - - /* - // First FE half - if (col0 <= 40 && col1 <= 40) { - - // Check if both hits are in the same double column - if (col1 == col0 || ((col1 == col0+1) && (col1%2 == 0))) { - - // If yes, sort by lowest row. - // Unless rows are equal, in which case sort on lowest column. - if (row0 != row1) return row0 < row1; - else return col0 < col1; - } - - // If no, sort by lowest column - else return col0 < col1; - } - - // Second FE half - else if (col0 > 40 && col1 > 40) { - - // Check if both hits are in the same double column - if (col1 == col0 || ((col1 == col0+1) && (col1%2 == 0))) { - - // If yes, sort by lowest row. - // Unless rows are equal, in which case sort on lowest column. - if (row0 != row1) return row0 < row1; - else return col0 < col1; - } - - // If no, sort by highest column - else return col0 > col1; - - } - - // Hits are on separate halfs - else return col0 < col1; - */ - -} - - /* - // all this is done to take into account the token running on the two halves of the FE-I4 and the double column. - if (col0 == col1) { - //uint32_t row0 = m_pixelCabling->getRow(&pixelId0, m_offlineId); - //uint32_t row1 = m_pixelCabling->getRow(&pixelId1, m_offlineId); - return (row0<row1); - } - // first half FE-I4 (columns 1 to 40) normal ordering - if (col1 <= 40) {return (col0 < col1);} - - // second half FE-I4 (columns 41 to 80): decreasing order of pairs of columns - else { // (col1 > 40) - if (col0 <= 40) {return true;} - else { // both col0 and col1 > 40 - if (abs(col0 - col1) > 1) {return (col0 > col1);} // they differ more than 1, so they're simply ordered in decreasing order - else { // their difference is == 1 - if (((col0 % 2) == 1)) {return true; } // col0 is odd: has to go first - else {return false;} // col0 is even: has to go afterwards - } - } - } - return false; -} -*/ - - - - bool OrderInitialRdos::operator() (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1) -{ - Identifier pixelId0 = rdo0->identify(); - Identifier offlineId0 = m_PixelID->wafer_id(pixelId0); - Identifier pixelId1 = rdo1->identify(); - Identifier offlineId1 = m_PixelID->wafer_id(pixelId1); - if (offlineId0 < offlineId1) { - return true; - } - if (offlineId0 == offlineId1) { - if ( (m_pixelCabling->isIBL(pixelId0)) || (m_pixelCabling->isDBM(pixelId0)) ) { // IBL and DBM - uint32_t fe0 = m_pixelCabling->getFEwrtSlink(&pixelId0); - uint32_t fe1 = m_pixelCabling->getFEwrtSlink(&pixelId1); - return (fe0 < fe1); - } - else { // PixelCase - uint32_t fe0 = m_pixelCabling->getFE(&pixelId0, offlineId0); - uint32_t fe1 = m_pixelCabling->getFE(&pixelId1, offlineId1); - return (fe0 < fe1); - - // return false; - } - } - else {return false; } -} diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodEncoder.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodEncoder.h deleted file mode 100644 index 4646141cf211726d3e84f3e1ed91c69b4ab41d63..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodEncoder.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelRodEncoder.h -// Header file for class PixelRodEncoder -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////// -// Version 00-00-00 06/03/2007 Daniel Dobos -/////////////////////////////////////////////////////////////////// - -#ifndef PIXELRAWDATABYTESTREAMCNV_PIXELRODENCODER_H -#define PIXELRAWDATABYTESTREAMCNV_PIXELRODENCODER_H - -// #define _DEBUG - -#include <inttypes.h> - -#include "ByteStreamData/RawEvent.h" -#include "InDetIdentifier/PixelID.h" -#include "InDetRawData/InDetRawDataCLASS_DEF.h" - -#include "InDetReadoutGeometry/SiDetectorElement.h" -#include "InDetReadoutGeometry/PixelDetectorManager.h" -#include "PixelByteStreamModuleMask.h" - -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/IMessageSvc.h" - -#include "GaudiKernel/ServiceHandle.h" -#include "PixelCabling/IPixelCablingSvc.h" - - -class PixelRodEncoder -{ -public: - - typedef PixelRDORawData RDO; - typedef PixelRDO_Container PixelRawContainer; - typedef std::vector<const RDO*> VRDO ; - - //constructor - PixelRodEncoder(); - - // destructor - ~PixelRodEncoder(); - - // addRdo - void addRdo(const RDO * rdo) { - m_RDOs.push_back(rdo); - } - - // set Pixel Id Helper - void set_PixelID(const PixelID * pixelid) { - m_PixelID = pixelid; - } - - // setCablingSvc - void set_pixelCabling(const ServiceHandle<IPixelCablingSvc>& pixelCabling) { - m_pixelCabling = pixelCabling; - } - - // setRodMinorVersion - void setRodMinorVersion (unsigned short RodBlockVersion) { - m_RodBlockVersion = RodBlockVersion; - } - - void setPixelDetectorManager(const InDetDD::PixelDetectorManager *m) { - m_PixelDetectorManager=m; - } - - // fill the Rod - void fillROD(std::vector<uint32_t>& v, MsgStream& log, int BCs_per_LVL1ID); - - bool IsIBL(const Identifier & pixelId); - void packIBLcondensed(std::vector <uint32_t > & v32rod, std::vector <uint32_t > & vRows, std::vector <uint32_t > & vCols, std::vector<int> & vTots); - void packIBLCondensed(std::vector <uint32_t > & v32rod, const VRDO &rdos_sameIBL_offlineId); - uint32_t packLinkHeader(uint32_t module, uint32_t bcid, uint32_t lvl1id, uint32_t lvl1idskip, uint32_t errors); - uint32_t packLinkHeader_IBL(uint32_t module, uint32_t bcid, uint32_t lvl1id, uint32_t feFlag); - uint32_t packRawDataWord(uint32_t FE, uint32_t row, uint32_t column, uint32_t ToT); - uint32_t packRawDataWord_IBL(uint32_t row, uint32_t column, int ToT, uint32_t nLink); - uint32_t packLinkTrailer(uint32_t errors); // for Pixel - uint32_t packLinkTrailer_IBL(uint32_t FEonSLink, bool timeOutErrorBit, bool condensedModeBit, bool linkMasked); // for IBL - - - -private: - - const PixelID * m_PixelID; - ServiceHandle<IPixelCablingSvc> m_pixelCabling; - const InDetDD::PixelDetectorManager* m_PixelDetectorManager; - - unsigned short m_RodBlockVersion ; - VRDO m_RDOs; - bool m_is_ibl_present; - bool m_is_ibl_module; - bool m_is_dbm_module; - -}; - -class OrderRdos { - - private : - - ServiceHandle<IPixelCablingSvc> m_pixelCabling; - Identifier m_offlineId; - - public : - - OrderRdos(Identifier offlineId, const ServiceHandle<IPixelCablingSvc>& pixelCabling): - m_pixelCabling("dummy","dummy") , m_offlineId(offlineId) - { m_pixelCabling = pixelCabling; } - - OrderRdos(const OrderRdos & orderFunct): // copy constructor - m_pixelCabling("dummy","dummy") , m_offlineId(orderFunct.m_offlineId) - { m_pixelCabling = orderFunct.m_pixelCabling; } - - OrderRdos& operator= (const OrderRdos &other) { // assignment operator - m_pixelCabling = other.m_pixelCabling; - return *this; - } - - bool operator () (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1); - -}; - -class OrderInitialRdos { - - private : - - ServiceHandle<IPixelCablingSvc> m_pixelCabling; - // Identifier m_offlineId; - const PixelID * m_PixelID; - - public : - - // OrderInitialRdos(Identifier offlineId, ServiceHandle<IPixelCablingSvc> pixelCabling, const PixelID * pixelID): - // m_pixelCabling("dummy","dummy") , m_offlineId(offlineId) , m_PixelID(pixelID) - OrderInitialRdos(const ServiceHandle<IPixelCablingSvc>& pixelCabling, const PixelID * pixelID): - m_pixelCabling("dummy","dummy") , m_PixelID(pixelID) - { m_pixelCabling = pixelCabling; } - - OrderInitialRdos(const OrderInitialRdos & orderFunct): // copy constructor - // m_pixelCabling("dummy","dummy") , m_offlineId(orderFunct.m_offlineId) , m_PixelID() - m_pixelCabling("dummy","dummy") , m_PixelID(orderFunct.m_PixelID) - { m_pixelCabling = orderFunct.m_pixelCabling; } - - OrderInitialRdos& operator= (const OrderInitialRdos &other) { // assignment operator - m_pixelCabling = other.m_pixelCabling; - return *this; - } - - bool operator () (const PixelRDORawData* rdo0, const PixelRDORawData* rdo1); - -}; - -#endif diff --git a/InnerDetector/InDetMonitoring/PixelMonitoring/src/Clusters.cxx b/InnerDetector/InDetMonitoring/PixelMonitoring/src/Clusters.cxx index 6858418c000c949b12d6122bd57a908ca14169dd..d02a1beaf1253b4fd6e27635d783a43d0caec9ae 100644 --- a/InnerDetector/InDetMonitoring/PixelMonitoring/src/Clusters.cxx +++ b/InnerDetector/InDetMonitoring/PixelMonitoring/src/Clusters.cxx @@ -29,8 +29,6 @@ #include "PixelMonitoring/PixelMon2DProfilesLW.h" #include "PixelMonitoring/PixelMonModules.h" -#include "PixelCabling/IPixelCablingSvc.h" - /////////////////////////////////////////////////////////////////////////////// //////////////////////booking methods////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/InDetTrigRawDataProvider/TrigPixRawDataProvider.h b/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/InDetTrigRawDataProvider/TrigPixRawDataProvider.h index 8f54f4435801faf39083488ca86b4e0b07b224f6..d3361030d80953ee0c3eda5b9f89c77a3eb0aa26 100644 --- a/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/InDetTrigRawDataProvider/TrigPixRawDataProvider.h +++ b/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/InDetTrigRawDataProvider/TrigPixRawDataProvider.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ ///////////////////////////////////////////////////////////////////////////// @@ -31,7 +31,6 @@ class StoreGateSvc; class IRoiDescriptor; class PixelID; -class IPixelCablingSvc; class IROBDataProviderSvc; class IRegSelSvc; class IPixelRawDataProviderTool; @@ -62,7 +61,6 @@ namespace InDet { ToolHandle<IPixelRawDataProviderTool> m_rawDataTool; ServiceHandle<StoreGateSvc> m_storeGate; ServiceHandle<StoreGateSvc> m_detStore; - ServiceHandle<IPixelCablingSvc> m_IdMapping; const PixelID* m_id; PixelRDO_Container* m_container; diff --git a/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx b/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx index 0918194d632e47298171a72535eadf4765ece4a9..e5f987ffb71fe5edfb6cbacf0e7ebb016e82d4dd 100644 --- a/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx +++ b/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx @@ -1,11 +1,10 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetTrigRawDataProvider/TrigPixRawDataProvider.h" #include "StoreGate/StoreGateSvc.h" #include "InDetIdentifier/PixelID.h" -#include "PixelCabling/IPixelCablingSvc.h" #include "TrigSteeringEvent/TrigRoiDescriptor.h" #include "AthenaKernel/getMessageSvc.h" #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" @@ -33,7 +32,6 @@ namespace InDet { m_rawDataTool ("PixelRawDataProviderTool"), m_storeGate ("StoreGateSvc",name), m_detStore ("DetectorStore",name), - m_IdMapping ("PixelCablingSvc",name), m_id(0), m_container(0) { @@ -93,13 +91,6 @@ namespace InDet { } else msg(MSG::INFO) << "Retrieved service " << m_storeGate << endmsg; - // Retrieve id mapping - if (m_IdMapping.retrieve().isFailure()) { - msg(MSG::FATAL) << "Failed to retrieve tool " << m_IdMapping << endmsg; - return StatusCode::FAILURE; - } else - msg(MSG::INFO) << "Retrieved tool " << m_IdMapping << endmsg; - //RDO container m_container = new PixelRDO_Container(m_id->wafer_hash_max()); m_container ->addRef(); // make sure it is never deleted @@ -155,7 +146,6 @@ namespace InDet { } else { msg(MSG::ERROR) << name() << " invoked without an RoI data " << endmsg; return StatusCode::FAILURE; - //robIDlist = m_IdMapping->getAllRods(); } StatusCode sg = initContainer(); diff --git a/Trigger/TrigFTK/FastTrackSimWrap/CMakeLists.txt b/Trigger/TrigFTK/FastTrackSimWrap/CMakeLists.txt index 77f718a488a6a3a5f698dda44078e2c29a5df981..42aaa45fd01a5807e20ab40f787f0567496a3ac0 100644 --- a/Trigger/TrigFTK/FastTrackSimWrap/CMakeLists.txt +++ b/Trigger/TrigFTK/FastTrackSimWrap/CMakeLists.txt @@ -11,6 +11,7 @@ atlas_depends_on_subdirs( PUBLIC Generators/GeneratorObjects InnerDetector/InDetConditions/InDetConditionsSummaryService InnerDetector/InDetConditions/InDetCondTools + InnerDetector/InDetConditions/PixelConditionsData InnerDetector/InDetDetDescr/InDetIdentifier InnerDetector/InDetRecEvent/InDetPrepRawData InnerDetector/InDetRecEvent/InDetRIO_OnTrack @@ -58,12 +59,12 @@ atlas_add_library( FastTrackSimWrapLib INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${HEPPDT_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AthenaBaseComps GeneratorObjects InDetCondTools InDetIdentifier InDetPrepRawData TrkTrack TrkTruthData TrkToolInterfaces TrigCaloEvent TrigDecisionToolLib TrigFTKSimLib StoreGateLib SGtests SCT_CablingLib - PRIVATE_LINK_LIBRARIES ${HEPPDT_LIBRARIES} ${HEPMC_LIBRARIES} AtlasDetDescr IdDict IdDictDetDescr Identifier EventInfo EventPrimitives GaudiKernel InDetReadoutGeometry InDetRawData InDetSimData TileIdentifier TrkRIO_OnTrack TrkSpacePoint VxVertex TrkFitterInterfaces PixelCablingLib InDetRIO_OnTrack ) + PRIVATE_LINK_LIBRARIES ${HEPPDT_LIBRARIES} ${HEPMC_LIBRARIES} AtlasDetDescr IdDict IdDictDetDescr Identifier EventInfo EventPrimitives GaudiKernel InDetReadoutGeometry InDetRawData InDetSimData TileIdentifier TrkRIO_OnTrack TrkSpacePoint VxVertex TrkFitterInterfaces PixelConditionsData PixelCablingLib InDetRIO_OnTrack ) atlas_add_component( FastTrackSimWrap src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${HEPPDT_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${HEPPDT_LIBRARIES} ${HEPMC_LIBRARIES} AthenaBaseComps GeneratorObjects InDetCondTools InDetIdentifier InDetPrepRawData TrkTrack TrkTruthData TrkToolInterfaces TrigDecisionToolLib TrigCaloEvent TrigFTKSimLib StoreGateLib SGtests AtlasDetDescr IdDict IdDictDetDescr Identifier EventInfo EventPrimitives GaudiKernel InDetReadoutGeometry SCT_CablingLib InDetRawData InDetSimData TileIdentifier TrkRIO_OnTrack TrkSpacePoint VxVertex FastTrackSimWrapLib TrkFitterInterfaces ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${HEPPDT_LIBRARIES} ${HEPMC_LIBRARIES} AthenaBaseComps GeneratorObjects InDetCondTools PixelConditionsData InDetIdentifier InDetPrepRawData TrkTrack TrkTruthData TrkToolInterfaces TrigDecisionToolLib TrigCaloEvent TrigFTKSimLib StoreGateLib SGtests AtlasDetDescr IdDict IdDictDetDescr Identifier EventInfo EventPrimitives GaudiKernel InDetReadoutGeometry SCT_CablingLib InDetRawData InDetSimData TileIdentifier TrkRIO_OnTrack TrkSpacePoint VxVertex FastTrackSimWrapLib TrkFitterInterfaces ) # Install files from the package: atlas_install_joboptions( share/*jobOptions*.py ) diff --git a/Trigger/TrigFTK/FastTrackSimWrap/FastTrackSimWrap/FTKRegionalWrapper.h b/Trigger/TrigFTK/FastTrackSimWrap/FastTrackSimWrap/FTKRegionalWrapper.h index 0e14b3e251aa748bffff3a9b0adc5252256fb0cc..7bbe446774ad315f28faa483ec3de1d851685079 100644 --- a/Trigger/TrigFTK/FastTrackSimWrap/FastTrackSimWrap/FTKRegionalWrapper.h +++ b/Trigger/TrigFTK/FastTrackSimWrap/FastTrackSimWrap/FTKRegionalWrapper.h @@ -13,6 +13,8 @@ #include "InDetPrepRawData/PixelClusterContainer.h" #include "InDetPrepRawData/SCT_ClusterContainer.h" +#include "PixelConditionsData/PixelCablingCondData.h" + #include "InDetReadoutGeometry/SiDetectorElementCollection.h" #include "SCT_Cabling/ISCT_CablingTool.h" #include "StoreGate/ReadCondHandleKey.h" @@ -32,7 +34,6 @@ #include <stdint.h> -class IPixelCablingSvc; class StoreGateSvc; class PixelID; class AtlasDetector; @@ -58,7 +59,6 @@ private: ToolHandle<FTK_SGHitInputI> m_hitInputTool; // input handler ToolHandle<ITrigFTKClusterConverterTool> m_clusterConverterTool; /** Tool to convert FTKHits to IDClusters */ - ServiceHandle<IPixelCablingSvc> m_pix_cabling_svc; ToolHandle<ISCT_CablingTool> m_sct_cablingToolInc; // This class accesses SCT cabling during initialization. // Needed to retrieve m_pixelId in order to get the barrel_ec, phi/eta_modules etc. @@ -72,6 +72,9 @@ private: const AtlasDetectorID* m_idHelper; const InDetDD::PixelDetectorManager* m_PIX_mgr; + SG::ReadCondHandleKey<PixelCablingCondData> m_condCablingKey + {this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"}; + SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; std::unique_ptr<FTKClusteringEngine> m_clusteringEngine = nullptr; diff --git a/Trigger/TrigFTK/FastTrackSimWrap/src/FTKRegionalWrapper.cxx b/Trigger/TrigFTK/FastTrackSimWrap/src/FTKRegionalWrapper.cxx index 9a978a8bf87ffd3300437ce03479d12f1571225c..ebf95eff39c5364b2ba682af204096595b442db7 100644 --- a/Trigger/TrigFTK/FastTrackSimWrap/src/FTKRegionalWrapper.cxx +++ b/Trigger/TrigFTK/FastTrackSimWrap/src/FTKRegionalWrapper.cxx @@ -11,7 +11,6 @@ #include "TrigFTKTrackConverter/TrigFTKClusterConverterTool.h" #include "TrigFTKToolInterfaces/ITrigFTKClusterConverterTool.h" -#include "PixelCabling/IPixelCablingSvc.h" #include "SCT_Cabling/SCT_OnlineId.h" #include "InDetRIO_OnTrack/SiClusterOnTrack.h" #include "InDetReadoutGeometry/PixelDetectorManager.h" @@ -42,7 +41,6 @@ FTKRegionalWrapper::FTKRegionalWrapper (const std::string& name, ISvcLocator* pS AthAlgorithm(name, pSvcLocator), m_hitInputTool("FTK_SGHitInput/FTK_SGHitInput"), m_clusterConverterTool("TrigFTKClusterConverterTool"), - m_pix_cabling_svc("PixelCablingSvc", name), m_sct_cablingToolInc("SCT_CablingToolInc"), m_storeGate(0), m_detStore( 0 ), @@ -133,7 +131,6 @@ FTKRegionalWrapper::FTKRegionalWrapper (const std::string& name, ISvcLocator* pS m_offline_phi(nullptr), m_offline_cluster_tree(nullptr) { - declareProperty("TrigFTKClusterConverterTool", m_clusterConverterTool); declareProperty("RMapPath",m_rmap_path); declareProperty("PMapPath",m_pmap_path); @@ -142,7 +139,6 @@ FTKRegionalWrapper::FTKRegionalWrapper (const std::string& name, ISvcLocator* pS declareProperty("IBLMode",m_IBLMode); declareProperty("FixEndcapL0", m_fixEndcapL0); declareProperty("ITkMode",m_ITkMode); - declareProperty("PixelCablingSvc", m_pix_cabling_svc); declareProperty("SCT_CablingTool",m_sct_cablingToolInc); // hit type options @@ -241,11 +237,6 @@ StatusCode FTKRegionalWrapper::initialize() ATH_MSG_FATAL("PixelCabling not initialized so m_DumpTestVectors and m_EmulateDF must both be set to false!"); return StatusCode::FAILURE; } - } else if (m_pix_cabling_svc.retrieve().isFailure()) { - ATH_MSG_FATAL("Failed to retrieve tool " << m_pix_cabling_svc); - return StatusCode::FAILURE; - } else { - ATH_MSG_VERBOSE("Retrieved tool " << m_pix_cabling_svc); } // Retrieve sct cabling service @@ -300,6 +291,7 @@ StatusCode FTKRegionalWrapper::initialize() if (m_getOffline) { ATH_CHECK(m_SCTDetEleCollKey.initialize()); } + ATH_CHECK(m_condCablingKey.initialize()); // Write clusters in InDetCluster format to ESD for use in Pseudotracking @@ -380,8 +372,8 @@ StatusCode FTKRegionalWrapper::initialize() //Dump to the log output the RODs used in the emulation if(m_EmulateDF){ - ATH_MSG_DEBUG("Printing full map via m_pix_cabling_svc->get_idMap_offrob(); "); - std::map< Identifier, uint32_t> offmap = m_pix_cabling_svc->get_idMap_offrob(); + // Shouldn't access conditions in the initilization step (in athenaMT). + std::map< Identifier, uint32_t> offmap; for (auto mit = offmap.begin(); mit != offmap.end(); mit++){ //uint id = mit->first; ATH_MSG_DEBUG("Pixel offline map hashID to RobId "<<MSG::dec<<mit->first<<" "<<MSG::hex<<mit->second<<MSG::dec); @@ -391,14 +383,14 @@ StatusCode FTKRegionalWrapper::initialize() m_sct_cablingToolInc->getAllRods(sctVector); ATH_MSG_DEBUG("Printing full SCT map via m_sct_cablingToolInc->getAllRods() "<<sctVector.size()<<" rods "); - + for(auto mit = sctVector.begin(); mit != sctVector.end(); mit++){ - // Retrive hashlist - m_sct_cablingToolInc->getHashesForRod(m_identifierHashList,*mit ); - ATH_MSG_DEBUG("Retrieved "<<m_identifierHashList.size()<<" hashes "); + // Retrive hashlist + m_sct_cablingToolInc->getHashesForRod(m_identifierHashList,*mit ); + ATH_MSG_DEBUG("Retrieved "<<m_identifierHashList.size()<<" hashes "); - for (auto mhit = m_identifierHashList.begin(); mhit != m_identifierHashList.end(); mhit++) - ATH_MSG_DEBUG("SCT offline map hashID to RobId "<<MSG::dec<<*mhit<<" "<<MSG::hex<<(*mit)<<MSG::dec); + for (auto mhit = m_identifierHashList.begin(); mhit != m_identifierHashList.end(); mhit++) + ATH_MSG_DEBUG("SCT offline map hashID to RobId "<<MSG::dec<<*mhit<<" "<<MSG::hex<<(*mit)<<MSG::dec); } m_pix_rodIdlist.clear(); @@ -411,24 +403,27 @@ StatusCode FTKRegionalWrapper::initialize() m_pix_rodIdlist.push_back(val); - ATH_MSG_DEBUG("Going to test against the following Pix RODIDs "<< MSG::hex - << val <<MSG::dec); - - std::vector<IdentifierHash> offlineIdHashList; - m_pix_cabling_svc->getOfflineList(offlineIdHashList, m_pix_cabling_svc->getRobId(val)); - ATH_MSG_DEBUG("Trying m_pix_cabling_svc->getOfflineList(offlineIdHashList, m_pix_cabling_svc->getRobId("<<MSG::hex<<val<<MSG::dec<<"));"); - for (auto oit = offlineIdHashList.begin(); oit != offlineIdHashList.end(); oit++){ - - Identifier id = m_pixelId->wafer_id( *oit ); - int barrel_ec = m_pixelId->barrel_ec(id); - int layer_disk = m_pixelId->layer_disk(id); - int phi_module = m_pixelId->phi_module(id); - int eta_module = m_pixelId->eta_module(id); - - ATH_MSG_DEBUG("hashId "<<*oit<<"for rodID "<<MSG::hex<<val<<MSG::dec - << "corresponds to b/ec lay_disk phi eta "<<barrel_ec - << " "<<layer_disk<<" "<<phi_module<<" "<<eta_module); - } + // Shouldn't access conditions in the initilization step (in athenaMT). + // The following logic breaks the conditions access. + // Since this is just for debugging purpose, just comment. +// ATH_MSG_DEBUG("Going to test against the following Pix RODIDs "<< MSG::hex +// << val <<MSG::dec); +// +// std::vector<IdentifierHash> offlineIdHashList; +// m_pix_cabling_svc->getOfflineList(offlineIdHashList, m_pix_cabling_svc->getRobId(val)); +// ATH_MSG_DEBUG("Trying m_pix_cabling_svc->getOfflineList(offlineIdHashList, m_pix_cabling_svc->getRobId("<<MSG::hex<<val<<MSG::dec<<"));"); +// for (auto oit = offlineIdHashList.begin(); oit != offlineIdHashList.end(); oit++){ +// +// Identifier id = m_pixelId->wafer_id( *oit ); +// int barrel_ec = m_pixelId->barrel_ec(id); +// int layer_disk = m_pixelId->layer_disk(id); +// int phi_module = m_pixelId->phi_module(id); +// int eta_module = m_pixelId->eta_module(id); +// +// ATH_MSG_DEBUG("hashId "<<*oit<<"for rodID "<<MSG::hex<<val<<MSG::dec +// << "corresponds to b/ec lay_disk phi eta "<<barrel_ec +// << " "<<layer_disk<<" "<<phi_module<<" "<<eta_module); +// } } m_sct_rodIdlist.clear(); @@ -440,7 +435,7 @@ StatusCode FTKRegionalWrapper::initialize() m_sct_rodIdlist.push_back(val); ATH_MSG_DEBUG("Going to test against the following SCT RODIDs "<< MSG::hex - << val <<MSG::dec); + << val <<MSG::dec); } } @@ -578,8 +573,8 @@ StatusCode FTKRegionalWrapper::execute() if (m_SavePerPlane) { for (int iplane=0;iplane!=m_nplanes;++iplane) { // planes loop - if (m_SaveRawHits) m_original_hits_per_plane[ireg][iplane].clear(); - if (m_SaveHits) m_logical_hits_per_plane[ireg][iplane].clear(); + if (m_SaveRawHits) m_original_hits_per_plane[ireg][iplane].clear(); + if (m_SaveHits) m_logical_hits_per_plane[ireg][iplane].clear(); } } } @@ -631,6 +626,8 @@ StatusCode FTKRegionalWrapper::execute() vector<FTKRawHit>::const_iterator ihit = templist.begin(); vector<FTKRawHit>::const_iterator ihitE = templist.end(); + SG::ReadCondHandle<PixelCablingCondData> pixCabling(m_condCablingKey); + for (;ihit!=ihitE;++ihit) { // hit loop const FTKRawHit &currawhit = *ihit; @@ -672,7 +669,7 @@ StatusCode FTKRegionalWrapper::execute() Identifier dehashedId = m_pixelId->wafer_id(modHash); //then get the corresponding RobId - uint32_t robid = m_pix_cabling_svc->getRobId(dehashedId); + uint32_t robid = pixCabling->find_entry_offrob(dehashedId); //then try to find in rob list auto it = find(m_pix_rodIdlist.begin(), m_pix_rodIdlist.end(), robid); @@ -688,9 +685,9 @@ StatusCode FTKRegionalWrapper::execute() } }else{ - //this shouldn't happen, so throw error - ATH_MSG_ERROR("Hit is neither Pixel or SCT!!"); - return StatusCode::FAILURE; + //this shouldn't happen, so throw error + ATH_MSG_ERROR("Hit is neither Pixel or SCT!!"); + return StatusCode::FAILURE; } //save the hit if it has the correct RodID ATH_MSG_DEBUG("Found hit to keep"); @@ -988,6 +985,9 @@ bool FTKRegionalWrapper::dumpFTKTestVectors(const FTKPlaneMap *pmap, const FTKRe // Note PIXEL RODs are input vector<uint32_t>::iterator rodit = m_pix_rodIdlist.begin(); vector<uint32_t>::iterator rodit_e = m_pix_rodIdlist.end(); + + SG::ReadCondHandle<PixelCablingCondData> pixCabling(m_condCablingKey); + hitTyp = 1; // pixel for (; rodit!=rodit_e; rodit++){ @@ -1003,43 +1003,44 @@ bool FTKRegionalWrapper::dumpFTKTestVectors(const FTKPlaneMap *pmap, const FTKRe if ( myfile.is_open() ) { for (int link = 0; link < 128;link++){ // Loop over all modules - // Retrieve onlineId = link+ROD - onlineId = m_pix_cabling_svc->getOnlineIdFromRobId((*rodit),link) ; - hashId = m_pix_cabling_svc->getOfflineIdHash(onlineId); - - if (hashId <=999999){ // Adjust for correct output format incase of invalid hashId // TODO: add a proper cutoff! - - id = m_pixelId->wafer_id( hashId ); - int barrel_ec = m_pixelId->barrel_ec(id); - int layer_disk = m_pixelId->layer_disk(id); - int phi_module = m_pixelId->phi_module(id); - int eta_module = m_pixelId->eta_module(id); - int eta_module_min = m_pixelId->eta_module_min(id); - int eta_module_max = m_pixelId->eta_module_max(id); - int eta_index = m_pixelId->eta_index(id); - int eta_index_max = m_pixelId->eta_index_max(id); - - // Get Plane information - FTKPlaneSection &pinfo = pmap->getMap(hitTyp,!(barrel_ec==0),layer_disk); - - // Get tower information - FTKRawHit dummy; - - dummy.setBarrelEC(barrel_ec); - dummy.setLayer(layer_disk); - dummy.setPhiModule(phi_module); - dummy.setEtaModule(eta_module); - - stringstream towerList; - FTKHit hitref = dummy.getFTKHit(pmap); - int nTowers = 0; - int towerId; - for (towerId = 0; towerId<64;towerId++){ // Loop over all 64 eta-phi towers - if (rmap->isHitInRegion(hitref,towerId)){ - towerList << towerId << ", "; - nTowers++; - } - } + // Retrieve onlineId = link+ROD + onlineId = pixCabling->getOnlineIdFromRobId((*rodit),link) ; + hashId = m_pixelId->wafer_hash(pixCabling->find_entry_onoff(onlineId)); + + + if (hashId <=999999){ // Adjust for correct output format incase of invalid hashId // TODO: add a proper cutoff! + + id = m_pixelId->wafer_id( hashId ); + int barrel_ec = m_pixelId->barrel_ec(id); + int layer_disk = m_pixelId->layer_disk(id); + int phi_module = m_pixelId->phi_module(id); + int eta_module = m_pixelId->eta_module(id); + int eta_module_min = m_pixelId->eta_module_min(id); + int eta_module_max = m_pixelId->eta_module_max(id); + int eta_index = m_pixelId->eta_index(id); + int eta_index_max = m_pixelId->eta_index_max(id); + + // Get Plane information + FTKPlaneSection &pinfo = pmap->getMap(hitTyp,!(barrel_ec==0),layer_disk); + + // Get tower information + FTKRawHit dummy; + + dummy.setBarrelEC(barrel_ec); + dummy.setLayer(layer_disk); + dummy.setPhiModule(phi_module); + dummy.setEtaModule(eta_module); + + stringstream towerList; + FTKHit hitref = dummy.getFTKHit(pmap); + int nTowers = 0; + int towerId; + for (towerId = 0; towerId<64;towerId++){ // Loop over all 64 eta-phi towers + if (rmap->isHitInRegion(hitref,towerId)){ + towerList << towerId << ", "; + nTowers++; + } + } // Dump data to file: diff --git a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.cxx b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.cxx index 76a0c7cdd1bf787390351e17af0e2d43135da134..6ffa2fdfb9c09c19e837f6e81d11d387ae5e3024 100644 --- a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.cxx +++ b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.cxx @@ -33,7 +33,6 @@ PixelClusterCacheTool::PixelClusterCacheTool( const std::string& type, const std::string& name, const IInterface* parent ) : AthAlgTool(type, name, parent), - m_IdMapping("PixelCablingSvc",name), m_offlineDecoder("PixelRodDecoder",this), m_bsErrorSvc("PixelByteStreamErrorsSvc",name), m_clusteringTool("InDet::MergedPixelsTool/InDetTrigMergedPixelsTool") @@ -86,12 +85,6 @@ StatusCode PixelClusterCacheTool::initialize() { if(m_doBS) { - sc = m_IdMapping.retrieve(); - if(sc.isFailure()) { - ATH_MSG_ERROR("cannot retrieve PixelCablingService "); - return sc; - } - if(StatusCode::SUCCESS !=m_offlineDecoder.retrieve()) { ATH_MSG_ERROR("initialize(): Can't get PixelRodDecoder "); return StatusCode::FAILURE; diff --git a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.h b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.h index 5a7f2a5eb89391d1e11a7b7a581406cf2d718b92..d519efe0679990524f85bb3e106e1d67507a4b34 100644 --- a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.h +++ b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.h @@ -7,7 +7,6 @@ #include "ByteStreamData/RawEvent.h" #include "AthenaBaseComps/AthAlgTool.h" -#include "PixelCabling/IPixelCablingSvc.h" #include "InDetReadoutGeometry/PixelDetectorManager.h" #include "IPixelClusterCacheTool.h" #include "InDetPrepRawData/PixelClusterCollection.h" @@ -46,7 +45,6 @@ private: std::string m_containerName; FastPixelClusterization m_clusterization; //PixelIdMapping *m_IdMapping; - ServiceHandle<IPixelCablingSvc> m_IdMapping; const InDetDD::PixelDetectorManager* p_indet_mgr; const PixelID* m_pixel_id; IdContext m_cntx_pix; diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/InDetConfig.py b/Trigger/TrigValidation/TrigUpgradeTest/python/InDetConfig.py index 14ec3702f1a7ac41248ebac661a6203bacf26c84..1bca5a32caad09f5568464bac46f4acbb488d18f 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/InDetConfig.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/InDetConfig.py @@ -115,6 +115,18 @@ def TrigInDetCondConfig( flags ): acc.merge(addFoldersSplitOnline(flags, "TRT","/TRT/Onl/Calib/ToTCalib","/TRT/Calib/ToTCalib",className="CondAttrListCollection")) acc.merge(addFoldersSplitOnline(flags, "TRT","/TRT/Onl/Calib/HTCalib","/TRT/Calib/HTCalib",className="CondAttrListCollection")) + acc.merge(addFolders(flags, "/PIXEL/ReadoutSpeed", "PIXEL", className="AthenaAttributeList")) + acc.merge(addFoldersSplitOnline(flags, "PIXEL", "/PIXEL/Onl/CablingMap","/PIXEL/CablingMap", className="AthenaAttributeList")) + acc.merge(addFolders(flags, "/PIXEL/HitDiscCnfg", "PIXEL", className="AthenaAttributeList")) + + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelReadoutSpeedAlg + acc.addCondAlgo(PixelReadoutSpeedAlg(name="PixelReadoutSpeedAlg")) + + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelCablingCondAlg + acc.addCondAlgo(PixelCablingCondAlg(name="PixelCablingCondAlg")) + + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelHitDiscCnfgAlg + acc.addCondAlgo(PixelHitDiscCnfgAlg(name="PixelHitDiscCnfgAlg")) from AthenaCommon.CfgGetter import getService PixelCablingSvc = getService("PixelCablingSvc")