diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/CMakeLists.txt b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/CMakeLists.txt index c2a3d1b2056e307e861b27ea0bef0411f754db7b..af29f45685a723d97b25c290c39ae2d52fe69e91 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/CMakeLists.txt +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/CMakeLists.txt @@ -10,6 +10,7 @@ find_package( Boost COMPONENTS filesystem thread system ) # Component(s) in the package: atlas_add_component( FaserSCT_ConditionsAlgorithms + src/*.h src/*.cxx src/components/*.cxx INCLUDE_DIRS ${Boost_INCLUDE_DIRS} diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FaserSCT_ConfigurationCondAlg.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FaserSCT_ConfigurationCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..113b68c4964e09c7e567e24a1bb297844fcdac82 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FaserSCT_ConfigurationCondAlg.cxx @@ -0,0 +1,126 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FaserSCT_ConfigurationCondAlg.h" + +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +#include <memory> + + +FaserSCT_ConfigurationCondAlg::FaserSCT_ConfigurationCondAlg(const std::string& name, ISvcLocator* pSvcLocator) : + ::AthReentrantAlgorithm(name, pSvcLocator) {} + +StatusCode FaserSCT_ConfigurationCondAlg::initialize() { + ATH_MSG_DEBUG("initialize " << name()); + + // CondSvc + ATH_CHECK(m_condSvc.retrieve()); + + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + + // Read Cond Handle + ATH_CHECK(m_readKey.initialize()); + + // Write Cond Handle + 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 FaserSCT_ConfigurationCondAlg::execute(const EventContext& ctx) const { + ATH_MSG_DEBUG("execute " << name()); + + // Write Cond Handle + SG::WriteCondHandle<FaserSCT_ConfigurationCondData> writeHandle{m_writeKey, ctx}; + // Do we have a valid Write Cond Handle for current time? + 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<FaserSCT_ConfigurationCondData> writeCdo{std::make_unique<FaserSCT_ConfigurationCondData>()}; + // clear structures before filling + writeCdo->clear(); + + if (writeCdo == nullptr) { + ATH_MSG_FATAL("Pointer of derived conditions object is null"); + return StatusCode::FAILURE; + } + + // Get read handle + SG::ReadCondHandle<CondAttrListCollection> readHandle{m_readKey, ctx}; + const CondAttrListCollection* readCdo {*readHandle}; + if (readCdo==nullptr) { + ATH_MSG_FATAL("Null pointer to the read conditions object"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("Size of " << m_readKey.key() << " is " << readCdo->size()); + + // Get the validity range + EventIDRange rangeW; + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size()); + ATH_MSG_DEBUG("Range of input is " << rangeW); + + writeHandle.addDependency(readHandle); + + std::string sensorParam{"sensor"}; + std::string stripParam{"strip"}; + std::string occupancyParam{"occupancy"}; + CondAttrListCollection::const_iterator itr{readCdo->begin()}; + CondAttrListCollection::const_iterator end{readCdo->end()}; + // CondAttrListCollection doesn't support C++11 type loops, no generic 'begin' + for (; itr != end; ++itr) { + // A CondAttrListCollection is a map of ChanNum and AttributeList + CondAttrListCollection::ChanNum channelNumber{itr->first}; + const CondAttrListCollection::AttributeList &payload{itr->second}; + if (payload.exists(sensorParam) and not payload[sensorParam].isNull() and + payload.exists(stripParam) and not payload[stripParam].isNull() and + payload.exists(occupancyParam) and not payload[occupancyParam].isNull()) + { + auto sensorVal {payload[sensorParam].data<int>()}; + auto stripVal {payload[stripParam].data<int>()}; + float occupancyVal {payload[occupancyParam].data<float>()}; + Identifier waferId = m_idHelper->wafer_id(sensorVal); + Identifier stripId = m_idHelper->strip_id(waferId, stripVal); + if (stripId.is_valid() and occupancyVal > m_occupancyThreshold) + writeCdo->setBadStripId(stripId, sensorVal, stripVal); + ATH_MSG_VERBOSE(m_idHelper->station(stripId) << "/" << m_idHelper->layer(stripId) << "/" + << m_idHelper->phi_module(stripId) << "/" << m_idHelper->phi_module(stripId) << "/" + << m_idHelper->side(stripId) << "/" << m_idHelper->strip(stripId) << " : " + << occupancyVal); + } else { + ATH_MSG_WARNING(sensorParam << " and/or " << stripParam << " and/or " << occupancyParam << " does not exist."); + } + } + + if (writeHandle.record(std::move(writeCdo)).isFailure()) { + ATH_MSG_FATAL("Could not record SCT_ConfigurationCondData " << writeHandle.key() + << " with EventRange " << writeHandle.getRange() + << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store"); + + return StatusCode::SUCCESS; +} + +StatusCode FaserSCT_ConfigurationCondAlg::finalize() { + ATH_MSG_DEBUG("finalize " << name()); + return StatusCode::SUCCESS; +} diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FaserSCT_ConfigurationCondAlg.h b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FaserSCT_ConfigurationCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..fe9d8de4a52ab51f7881ff89e244b3ded6c30f09 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FaserSCT_ConfigurationCondAlg.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CONFIGURATIONCONDALG_H +#define FASERSCT_CONFIGURATIONCONDALG_H + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" + +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/WriteCondHandleKey.h" + +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/ServiceHandle.h" + +// TODO use instead SCT_ConfigurationCondData? +// #include "SCT_ConditionsData/SCT_ConfigurationCondData.h" +#include "FaserSCT_ConditionsData/FaserSCT_ConfigurationCondData.h" + + +class FaserSCT_ID; + +class FaserSCT_ConfigurationCondAlg : public AthReentrantAlgorithm { + public: + FaserSCT_ConfigurationCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~FaserSCT_ConfigurationCondAlg() = default; + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + virtual bool isClonable() const override { return true; }; + + private: + SG::ReadCondHandleKey<CondAttrListCollection> m_readKey {this, "ReadKey", "/SCT/DAQ/NoisyStrips", "Key of input noisy strips folder"}; + SG::WriteCondHandleKey<FaserSCT_ConfigurationCondData> m_writeKey{this, "WriteKey", "FaserSCT_ConfigurationCondData", "Key of output (derived) conditions data"}; + ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"}; + const FaserSCT_ID* m_idHelper{nullptr}; + Gaudi::Property<double> m_occupancyThreshold {this, "OccupancyThreshold", 0.015, "Mask strips with an occupancy larger than the OccupancyCut"}; +}; + + + +#endif //FASERSCT_CONFIGURATIONCONDALG_H diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/components/FaserSCT_ConditionsAlgorithms_entries.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/components/FaserSCT_ConditionsAlgorithms_entries.cxx index f8b127e85d0a477d87019556c48cc0873a19eee8..465ffd956838ce71cb17495156804176be756ebc 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/components/FaserSCT_ConditionsAlgorithms_entries.cxx +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/components/FaserSCT_ConditionsAlgorithms_entries.cxx @@ -34,6 +34,7 @@ // #include "../SCT_StripVetoTestAlg.h" // #include "../SCT_TdaqEnabledCondAlg.h" // #include "../SCT_TdaqEnabledTestAlg.h" +#include "../FaserSCT_ConfigurationCondAlg.h" DECLARE_COMPONENT( FaserSCT_AlignCondAlg ) // DECLARE_COMPONENT( SCT_ByteStreamErrorsTestAlg ) @@ -71,3 +72,4 @@ DECLARE_COMPONENT( FaserSCT_SiliconTempCondAlg ) // DECLARE_COMPONENT( SCT_StripVetoTestAlg ) // DECLARE_COMPONENT( SCT_TdaqEnabledCondAlg ) // DECLARE_COMPONENT( SCT_TdaqEnabledTestAlg ) +DECLARE_COMPONENT( FaserSCT_ConfigurationCondAlg ) diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt b/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt index f13ae3272499c4b66d5dab008bff2a1b92081f88..16fcf75c2d6c9caff8ea4c3a18e143f6d7010436 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt @@ -8,6 +8,7 @@ atlas_subdir( FaserSCT_ConditionsData ) # Component(s) in the package: atlas_add_library( FaserSCT_ConditionsData + FaserSCT_ConditionsData/*.h src/*.cxx PUBLIC_HEADERS FaserSCT_ConditionsData LINK_LIBRARIES AthenaPoolUtilities Identifier ) diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsData/FaserSCT_ConditionsData/FaserSCT_ConfigurationCondData.h b/Tracker/TrackerConditions/FaserSCT_ConditionsData/FaserSCT_ConditionsData/FaserSCT_ConfigurationCondData.h new file mode 100644 index 0000000000000000000000000000000000000000..0ff7a294584d2cf7d318cfce8ab39a044dd7da5c --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsData/FaserSCT_ConditionsData/FaserSCT_ConfigurationCondData.h @@ -0,0 +1,98 @@ +#ifndef FASERSCT_CONFIGURATIONCONDDATA_H +#define FASERSCT_CONFIGURATIONCONDDATA_H + +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include <array> +#include <bitset> +#include <map> +#include <set> + +// Include Athena stuff +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" + +/** + * @class FaserSCT_ConfigurationCondData + * @brief Class for data object used in SCT_ConfigurationCondAlg and SCT_ConfigurationConditionsTool. + **/ +class FaserSCT_ConfigurationCondData { +public: + + /// Constructor + FaserSCT_ConfigurationCondData(); + + /// Destructor + virtual ~FaserSCT_ConfigurationCondData() = default; + + /// Set a bad strip identifier + void setBadStripId(const Identifier& badStripId, const IdentifierHash& hash, const int strip); + /// Get all bad strip identifiers + const std::set<Identifier>* getBadStripIds() const; + /// Clear all bad strip identifiers + void clearBadStripIds(); + /// Check if a strip identifier is bad one + bool isBadStrip(const IdentifierHash& hash, const int strip) const; + + /// Set a bad wafer identifier + void setBadWaferId(const Identifier& badWaferId); + /// Get all bad wafer identifiers + const std::set<Identifier>* getBadWaferIds() const; + /// Clear all bad wafer identifiers + void clearBadWaferIds(); + /// Check if a wafer identifier is bad one + bool isBadWaferId(const Identifier& waferId) const; + + /// Set a bad module identifier + void setBadModuleId(const Identifier& badModuleId); + /// Get all bad module identifiers + const std::set<Identifier>* getBadModuleIds() const; + /// Clear all bad module identifiers + void clearBadModuleIds(); + /// Check if a module identifier is bad one + bool isBadModuleId(const Identifier& moduleId) const; + + /// Set bad links for a module + void setBadLinks(const IdentifierHash& hash, const bool isBadLink0, const bool isBadLink1); + /// Get all bad links + const std::map<IdentifierHash, std::pair<bool, bool>>* getBadLinks() const; + /// Clear all bad links + void clearBadLinks(); + /// Check if a module has bad links + std::pair<bool, bool> areBadLinks(const IdentifierHash& hash) const; + + /// Set bad chips for a module + void setBadChips(const Identifier& moduleId, const unsigned int chipStatus); + /// Get bad chips for a module + unsigned int getBadChips(const Identifier& moduleId) const; + /// Get all bad chips + const std::map<Identifier, unsigned int>* getBadChips() const; + /// Clear all bad chips + void clearBadChips(); + + /// Clear all bad information + void clear(); + +private: + enum {N_MODULES=4088, N_STRIPS=768, N_SIDES=2}; + + std::set<Identifier> m_badStripIds; + std::array<std::bitset<N_STRIPS>, N_MODULES*N_SIDES> m_badStripArray; + std::set<Identifier> m_badWaferIds; + std::set<Identifier> m_badModuleIds; + std::map<IdentifierHash, std::pair<bool, bool>> m_badLinks; + std::array<std::pair<bool, bool>, N_MODULES> m_badLinksArray; + std::map<Identifier, unsigned int> m_badChips; +}; + +// Class definition for StoreGate +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF( FaserSCT_ConfigurationCondData , 81691222 , 1 ) + +// Condition container definition for CondInputLoader +#include "AthenaKernel/CondCont.h" +CONDCONT_DEF( FaserSCT_ConfigurationCondData, 230890898 ); + +#endif // FASERSCT_CONFIGURATIONCONDDATA_H diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsData/src/FaserSCT_ConfigurationCondData.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsData/src/FaserSCT_ConfigurationCondData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c630fc082a6ff16a7f696696cdc3d58abd689578 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsData/src/FaserSCT_ConfigurationCondData.cxx @@ -0,0 +1,165 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "FaserSCT_ConditionsData/FaserSCT_ConfigurationCondData.h" + +#include <algorithm> +#include <iterator> + +//---------------------------------------------------------------------- +// Constructor +FaserSCT_ConfigurationCondData::FaserSCT_ConfigurationCondData(): + m_badStripIds{}, + m_badStripArray{}, + m_badWaferIds{}, + m_badModuleIds{}, + m_badChips{} +{ + clearBadLinks(); +} + +//---------------------------------------------------------------------- +// Set a bad strip identifier +void FaserSCT_ConfigurationCondData::setBadStripId(const Identifier& badStripId, const IdentifierHash& hash, const int strip) { + m_badStripIds.insert(badStripId); + m_badStripArray[hash].set(strip); +} + +//---------------------------------------------------------------------- +// Get all bad strip identifiers +const std::set<Identifier>* FaserSCT_ConfigurationCondData::getBadStripIds() const { + return &m_badStripIds; +} + +//---------------------------------------------------------------------- +// Clear all bad strip identifiers +void FaserSCT_ConfigurationCondData::clearBadStripIds() { + m_badStripIds.clear(); + m_badStripArray.fill(std::bitset<N_STRIPS>()); +} + +//---------------------------------------------------------------------- +// Check if a strip identifier is bad one +bool FaserSCT_ConfigurationCondData::isBadStrip(const IdentifierHash& hash, const int strip) const { + return m_badStripArray[hash][strip]; +} + +//---------------------------------------------------------------------- +// Set a bad wafer identifier +void FaserSCT_ConfigurationCondData::setBadWaferId(const Identifier& badWaferId) { + m_badWaferIds.insert(badWaferId); +} + +//---------------------------------------------------------------------- +// Get all bad wafer identifiers +const std::set<Identifier>* FaserSCT_ConfigurationCondData::getBadWaferIds() const { + return &m_badWaferIds; +} + +//---------------------------------------------------------------------- +// Clear all bad wafer identifiers +void FaserSCT_ConfigurationCondData::clearBadWaferIds() { + m_badWaferIds.clear(); +} + +//---------------------------------------------------------------------- +// Check if a wafer identifier is bad one +bool FaserSCT_ConfigurationCondData::isBadWaferId(const Identifier& waferId) const { + return (m_badWaferIds.find(waferId)!=m_badWaferIds.end()); +} + +//---------------------------------------------------------------------- +// Set a bad module identifier +void FaserSCT_ConfigurationCondData::setBadModuleId(const Identifier& badModuleId) { + m_badModuleIds.insert(badModuleId); +} + +//---------------------------------------------------------------------- +// Get all bad module identifiers +const std::set<Identifier>* FaserSCT_ConfigurationCondData::getBadModuleIds() const { + return &m_badModuleIds; +} + +//---------------------------------------------------------------------- +// Clear all bad module identifiers +void FaserSCT_ConfigurationCondData::clearBadModuleIds() { + m_badModuleIds.clear(); +} + +//---------------------------------------------------------------------- +// Check if a module identifier is bad one +bool FaserSCT_ConfigurationCondData::isBadModuleId(const Identifier& moduleId) const { + return (m_badModuleIds.find(moduleId)!=m_badModuleIds.end()); +} + +//---------------------------------------------------------------------- +// Set bad links for a module +void FaserSCT_ConfigurationCondData::setBadLinks(const IdentifierHash& hash, const bool isBadLink0, const bool isBadLink1) { + unsigned int iHash{hash}; + iHash = (iHash/2)*2; // Make iHash even + if (m_badLinks.count(iHash)==0) { + m_badLinks.insert(std::pair<IdentifierHash, std::pair<bool, bool>>(iHash, std::pair<bool, bool>(isBadLink0, isBadLink1))); + } else { + m_badLinks[iHash].first &= isBadLink0; + m_badLinks[iHash].second &= isBadLink1; + } + m_badLinksArray[iHash/2].first &= isBadLink0; + m_badLinksArray[iHash/2].second &= isBadLink1; +} + +//---------------------------------------------------------------------- +// Get all bad links +const std::map<IdentifierHash, std::pair<bool, bool>>* FaserSCT_ConfigurationCondData::getBadLinks() const { + return &m_badLinks; +} + +//---------------------------------------------------------------------- +// Clear all bad links +void FaserSCT_ConfigurationCondData::clearBadLinks() { + m_badLinks.clear(); + m_badLinksArray.fill(std::make_pair(true, true)); +} + +//---------------------------------------------------------------------- +// Check if a module has bad links +std::pair<bool, bool> FaserSCT_ConfigurationCondData::areBadLinks(const IdentifierHash& hash) const { + // Bad convetion is used. true is for good link and false is for bad link... + return m_badLinksArray[hash/2]; +} + +//---------------------------------------------------------------------- +// Set bad chips for a module +void FaserSCT_ConfigurationCondData::setBadChips(const Identifier& moduleId, const unsigned int chipStatus) { + if (chipStatus!=0) m_badChips[moduleId] = chipStatus; +} + +//---------------------------------------------------------------------- +// bad chips for a module +unsigned int FaserSCT_ConfigurationCondData::getBadChips(const Identifier& moduleId) const { + std::map<Identifier, unsigned int>::const_iterator it{m_badChips.find(moduleId)}; + return (it!=m_badChips.end()) ? (*it).second : 0; +} + +//---------------------------------------------------------------------- +// Get all bad chips +const std::map<Identifier, unsigned int>* FaserSCT_ConfigurationCondData::getBadChips() const { + return &m_badChips; +} + +//---------------------------------------------------------------------- +// Clear all bad chips +void FaserSCT_ConfigurationCondData::clearBadChips() { + m_badChips.clear(); +} + +//---------------------------------------------------------------------- +// Clear all bad information +void FaserSCT_ConfigurationCondData::clear() { + clearBadStripIds(); + clearBadWaferIds(); + clearBadModuleIds(); + clearBadLinks(); + clearBadChips(); +} diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/CMakeLists.txt b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/CMakeLists.txt index 1450b0a07133ff3ea8a5517244cbdb9a54b0262a..a89fc207ed29dfc53e48e3182d7dad88d3a0bfb9 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/CMakeLists.txt +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/CMakeLists.txt @@ -13,6 +13,7 @@ find_package( GMock ) # Component(s) in the package: atlas_add_component ( FaserSCT_ConditionsTools + FaserSCT_ConditionsTools/*.h src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaKernel FaserSCT_ConditionsToolsLib Identifier GeoModelUtilities GeoModelFaserUtilities GaudiKernel AthenaBaseComps StoreGateLib SGtests xAODEventInfo FaserSCT_ConditionsData InDetByteStreamErrors TrackerIdentifier TrackerReadoutGeometry FaserSiPropertiesToolLib InDetConditionsSummaryService ) diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_ConfigurationConditionsTool.h b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_ConfigurationConditionsTool.h index 597047503e59fdbf179b02eb95ddc4cc4b777358..c4d4ca0eeaead8ad6cbbe72e5d7a8979d938a528 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_ConfigurationConditionsTool.h +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_ConfigurationConditionsTool.h @@ -15,7 +15,7 @@ #include <map> #include "InDetConditionsSummaryService/InDetHierarchy.h" -#include "FaserSCT_ConditionsTools/ISCT_ConditionsTool.h" +#include "ISCT_ConditionsTool.h" class Identifier; class IdentifierHash; diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_NoisyStripTool.h b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_NoisyStripTool.h deleted file mode 100644 index 9fcf6b9a54f891e52edcedb729a3ff8510af319a..0000000000000000000000000000000000000000 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_NoisyStripTool.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS and FAsER collaborations -*/ - -#ifndef ISCT_NOISY_STRIP_TOOL -#define ISCT_NOISY_STRIP_TOOL - -#include "GaudiKernel/IAlgTool.h" -#include "GaudiKernel/EventContext.h" -#include <vector> - - -class ISCT_NoisyStripTool: virtual public IAlgTool { -public: - virtual ~ISCT_NoisyStripTool() = default; - - DeclareInterfaceID(ISCT_NoisyStripTool, 1, 0); - - virtual std::map<std::pair<int,int>, double> getNoisyStrips(const EventContext& ctx) const = 0; - virtual std::map<std::pair<int,int>, double> getNoisyStrips(void) const = 0; -}; - -#endif // ISCT_NOISY_STRIP_TOOL diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_ConditionsSummaryToolConfig.py b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_ConditionsSummaryToolConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..29328f76725805b0003ee2e223510a5a16853bab --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_ConditionsSummaryToolConfig.py @@ -0,0 +1,38 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from IOVDbSvc.IOVDbSvcConfig import addFolders +from SCT_GeoModel.SCT_GeoModelConfig import SCT_ReadoutGeometryCfg + +FaserSCT_ConfigurationCondAlg = CompFactory.FaserSCT_ConfigurationCondAlg +FaserSCT_ConfigurationConditionsTool = CompFactory.FaserSCT_ConfigurationConditionsTool + +def FaserSCT_ConfigurationCondAlgCfg(flags, name="FaserSCT_ConfigurationCondAlg", **kwargs): + acc = ComponentAccumulator() + dbInstance = kwargs.get("dbInstance", "TDAQ_OFL") + dbFolder = kwargs.get("dbFolder", "/SCT/DAQ/NoisyStrips") + acc.merge(addFolders(flags, folderstrings=dbFolder, detDb=dbInstance, className="CondAttrListCollection")) + acc.addCondAlgo(FaserSCT_ConfigurationCondAlg(name, **kwargs)) + return acc + + +def FaserSCT_ConfigurationConditionsToolCfg(flags, name="FaserSCT_ConfigurationCondAlg", **kwargs): + acc = ComponentAccumulator() + # tool = kwargs.get("ConditionsTools", FaserSCT_ConfigurationConditionsToolCfg(flags)) + # folder arguments + dbInstance = kwargs.get("dbInstance", "TDAQ_OFL") + dbFolder = kwargs.get("dbFolder", "/SCT/DAQ/NoisyStrips") + acc.merge(FaserSCT_ConfigurationCondAlgCfg(flags, name="FaserSCT_ConfigurationCondAlg", **kwargs)) + # acc.setPrivateTools(tool) + acc.setPrivateTools(FaserSCT_ConfigurationConditionsTool(name, **kwargs)) + return acc + + +def FaserSCT_ConditionsSummaryToolCfg(flags, name="FaserSCT_ConditionsSummaryTool", **kwargs): + acc = ComponentAccumulator() + ConditionsTools = [] + SCT_ConfigurationConditionsTool = acc.popToolsAndMerge(FaserSCT_ConfigurationConditionsToolCfg(flags)) + ConditionsTools += [ SCT_ConfigurationConditionsTool ] + kwargs.setdefault("ConditionsTools", ConditionsTools) + acc.setPrivateTools(CompFactory.FaserSCT_ConditionsSummaryTool(name=name, **kwargs)) + return acc diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConfigurationConditionsTool.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConfigurationConditionsTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..cb444a12f271273cc0cc4f7679b505df713f100e --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConfigurationConditionsTool.cxx @@ -0,0 +1,327 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FaserSCT_ConfigurationConditionsTool.h" + +// Athena includes +#include "TrackerIdentifier/FaserSCT_ID.h" +// #include "InDetReadoutGeometry/SiDetectorElement.h" +#include "StoreGate/ReadCondHandle.h" + +// Constructor +FaserSCT_ConfigurationConditionsTool::FaserSCT_ConfigurationConditionsTool(const std::string& type, const std::string& name, const IInterface* parent) : + base_class(type, name, parent) +{ +} + +// Initialize +StatusCode FaserSCT_ConfigurationConditionsTool::initialize() { + ATH_MSG_DEBUG("Initializing configuration"); + + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + + // Read Cond Handle Key + ATH_CHECK(m_condKey.initialize()); + // ATH_CHECK(m_SCTDetEleCollKey.initialize()); + + return StatusCode::SUCCESS; +} + +// What level of element can this service report about +bool FaserSCT_ConfigurationConditionsTool::canReportAbout(InDetConditions::Hierarchy h) const { + return (h == InDetConditions::SCT_STRIP or + h == InDetConditions::SCT_CHIP or + h == InDetConditions::SCT_SIDE or + h == InDetConditions::SCT_MODULE or + h == InDetConditions::DEFAULT); +} + +// Is an element with this Identifier and hierarchy good? +bool FaserSCT_ConfigurationConditionsTool::isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const { + if (not canReportAbout(h)) return true; + + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In isGood, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return false; + } + + bool result{true}; + if (h == InDetConditions::SCT_STRIP) { + result = (not condData->isBadStrip(m_idHelper->wafer_hash(m_idHelper->wafer_id(elementId)), + m_idHelper->strip(elementId))); + // If strip itself is not bad, check if it's in a bad module + if (result and m_checkStripsInsideModules) result = (not isStripInBadModule(elementId, condData)); + } else if (h == InDetConditions::SCT_MODULE) { + result = (not condData->isBadModuleId(elementId)); + } else if (h == InDetConditions::SCT_SIDE or h == InDetConditions::DEFAULT) { + result = (not condData->isBadWaferId(elementId)); + } else if (h == InDetConditions::SCT_CHIP) { + result = isGoodChip(elementId, ctx); + } + return result; +} + +bool FaserSCT_ConfigurationConditionsTool::isGood(const Identifier& elementId, InDetConditions::Hierarchy h) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + + return isGood(elementId, ctx, h); +} + +// Is a wafer with this IdentifierHash good? +bool FaserSCT_ConfigurationConditionsTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const { + const Identifier elementId{m_idHelper->wafer_id(hashId)}; + return isGood(elementId, ctx, InDetConditions::SCT_SIDE); +} + +bool FaserSCT_ConfigurationConditionsTool::isGood(const IdentifierHash& hashId) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return isGood(hashId, ctx); +} + +// Is a chip with this Identifier good? +bool FaserSCT_ConfigurationConditionsTool::isGoodChip(const Identifier& stripId, const EventContext& ctx) const { + // This check assumes present SCT. + // Get module number + const Identifier moduleId{m_idHelper->module_id(stripId)}; + if (not moduleId.is_valid()) { + ATH_MSG_WARNING("moduleId obtained from stripId " << stripId << " is invalid."); + return false; + } + + // badChips word for the module + const unsigned int v_badChips{badChips(moduleId, ctx)}; + // badChips holds 12 bits. + // bit 0 (LSB) is chip 0 for side 0. + // bit 5 is chip 5 for side 0. + // bit 6 is chip 6 for side 1. + // bit 11 is chip 11 for side 1. + + // If there is no bad chip, this check is done. + if (v_badChips==0) return true; + + const int side{m_idHelper->side(stripId)}; + // Check the six chips on the side + // 0x3F = 0000 0011 1111 + // 0xFC0 = 1111 1100 0000 + // If there is no bad chip on the side, this check is done. + if ((side==0 and (v_badChips & 0x3F)==0) or (side==1 and (v_badChips & 0xFC0)==0)) return true; + + int chip{getChip(stripId, ctx)}; + if (chip<0 or chip>=12) { + ATH_MSG_WARNING("chip number is invalid: " << chip); + return false; + } + + // Check if the chip is bad + const bool badChip{static_cast<bool>(v_badChips & (1<<chip))}; + + return (not badChip); +} + +// Check if a strip is within a bad module +bool FaserSCT_ConfigurationConditionsTool::isStripInBadModule(const Identifier& stripId, const FaserSCT_ConfigurationCondData* condData) const { + if (condData==nullptr) { + ATH_MSG_ERROR("In isStripInBadModule, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return true; + } + + const Identifier moduleId(m_idHelper->module_id(m_idHelper->wafer_id(stripId))); + return condData->isBadModuleId(moduleId); +} + +// Check if a wafer is within a bad module +bool FaserSCT_ConfigurationConditionsTool::isWaferInBadModule(const Identifier& waferId, const EventContext& ctx) const { + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In isWaferInBadModule, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return true; + } + + const Identifier moduleId{m_idHelper->module_id(waferId)}; + return condData->isBadModuleId(moduleId); +} + +// Find the chip number containing a particular strip Identifier +int FaserSCT_ConfigurationConditionsTool::getChip(const Identifier& stripId, const EventContext& ctx) const { + // Find side and strip number + const int side{m_idHelper->side(stripId)}; + int strip{m_idHelper->strip(stripId)}; + + // Check for swapped readout direction + const IdentifierHash waferHash{m_idHelper->wafer_hash(m_idHelper->wafer_id(stripId))}; + const TrackerDD::SiDetectorElement* pElement{getDetectorElement(waferHash, ctx)}; + if (pElement==nullptr) { + ATH_MSG_FATAL("Element pointer is nullptr in 'badStrips' method"); + return invalidChipNumber; + } + strip = (pElement->swapPhiReadoutDirection()) ? lastStrip - strip: strip; + + // Find chip number + return (side==0 ? strip/stripsPerChip : strip/stripsPerChip + 6); +} + +int FaserSCT_ConfigurationConditionsTool::getChip(const Identifier& stripId) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return getChip(stripId, ctx); +} + +const std::set<Identifier>* FaserSCT_ConfigurationConditionsTool::badModules(const EventContext& ctx) const { + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In badModules, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return nullptr; + } + + return condData->getBadModuleIds(); +} + +const std::set<Identifier>* FaserSCT_ConfigurationConditionsTool::badModules() const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return badModules(ctx); +} + +void FaserSCT_ConfigurationConditionsTool::badStrips(const Identifier& moduleId, std::set<Identifier>& strips, const EventContext& ctx, bool ignoreBadModules, bool ignoreBadChips) const { + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In badStrips, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return; + } + + // Bad strips for a given module + if (ignoreBadModules) { + // Ignore strips in bad modules + if (condData->isBadModuleId(moduleId)) return; + } + + for (const Identifier& badStripId: *(condData->getBadStripIds())) { + if (ignoreBadChips) { + // Ignore strips in bad chips + const int chip{getChip(badStripId)}; + if (chip!=invalidChipNumber) { + unsigned int chipStatusWord{condData->getBadChips(moduleId)}; + if ((chipStatusWord & (1 << chip)) != 0) continue; + } + } + if (m_idHelper->module_id(m_idHelper->wafer_id(badStripId)) == moduleId) strips.insert(badStripId); + } +} + +void FaserSCT_ConfigurationConditionsTool::badStrips(const Identifier& moduleId, std::set<Identifier>& strips, bool ignoreBadModules, bool ignoreBadChips) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return badStrips(moduleId, strips, ctx, ignoreBadModules, ignoreBadChips); +} + +std::pair<bool, bool> FaserSCT_ConfigurationConditionsTool::badLinks(const IdentifierHash& hash, const EventContext& ctx) const { + // Bad links for a given module + // Bad convetion is used. true is for good link and false is for bad link... + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In badLinks, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return std::pair<bool, bool>{false, false}; + } + + return condData->areBadLinks(hash); +} + +std::pair<bool, bool> FaserSCT_ConfigurationConditionsTool::badLinks(const IdentifierHash& hash) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return badLinks(hash, ctx); +} + +const std::map<IdentifierHash, std::pair<bool, bool>>* FaserSCT_ConfigurationConditionsTool::badLinks(const EventContext& ctx) const { + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In badLinks, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return nullptr; + } + + return condData->getBadLinks(); +} + +const std::map<IdentifierHash, std::pair<bool, bool>>* FaserSCT_ConfigurationConditionsTool::badLinks() const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return badLinks(ctx); +} + +const std::map<Identifier, unsigned int>* FaserSCT_ConfigurationConditionsTool::badChips(const EventContext& ctx) const { + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In badChips, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return nullptr; + } + + return condData->getBadChips(); +} + +const std::map<Identifier, unsigned int>* FaserSCT_ConfigurationConditionsTool::badChips() const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return badChips(ctx); +} + +unsigned int FaserSCT_ConfigurationConditionsTool::badChips(const Identifier& moduleId, const EventContext& ctx) const { + // Bad chips for a given module + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In badChips, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return 0xFFF; // 12 bad chips + } + + return condData->getBadChips(moduleId); +} + +unsigned int FaserSCT_ConfigurationConditionsTool::badChips(const Identifier& moduleId) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return badChips(moduleId, ctx); +} +void +FaserSCT_ConfigurationConditionsTool::badStrips(std::set<Identifier>& strips, const EventContext& ctx, bool ignoreBadModules, bool ignoreBadChips) const { + const FaserSCT_ConfigurationCondData* condData{getCondData(ctx)}; + if (condData==nullptr) { + ATH_MSG_ERROR("In badStrips, FaserSCT_ConfigurationCondData pointer cannot be retrieved"); + return; + } + + if (!ignoreBadModules and !ignoreBadChips) { + std::copy(condData->getBadStripIds()->begin(), condData->getBadStripIds()->end(), std::inserter(strips,strips.begin())); + return; + } + for (const Identifier& badStripId: *(condData->getBadStripIds())) { + const Identifier moduleId{m_idHelper->module_id(m_idHelper->wafer_id(badStripId))}; + // Ignore strips in bad modules + if (ignoreBadModules) { + if (condData->isBadModuleId(moduleId)) continue; + } + // Ignore strips in bad chips + if (ignoreBadChips) { + const int chip{getChip(badStripId)}; + if (chip!=invalidChipNumber) { + unsigned int chipStatusWord{condData->getBadChips(moduleId)}; + if ((chipStatusWord & (1 << chip)) != 0) continue; + } + } + strips.insert(badStripId); + } +} + +void +FaserSCT_ConfigurationConditionsTool::badStrips(std::set<Identifier>& strips, bool ignoreBadModules, bool ignoreBadChips) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + badStrips(strips, ctx, ignoreBadModules, ignoreBadChips); +} + +const FaserSCT_ConfigurationCondData* +FaserSCT_ConfigurationConditionsTool::getCondData(const EventContext& ctx) const { + SG::ReadCondHandle<FaserSCT_ConfigurationCondData> condData{m_condKey, ctx}; + if (!condData.isValid()) { + ATH_MSG_ERROR("can't retrieve condData"); + } + return condData.retrieve(); +} + +const TrackerDD::SiDetectorElement* FaserSCT_ConfigurationConditionsTool::getDetectorElement(const IdentifierHash& waferHash, const EventContext& ctx) const { + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> condData{m_SCTDetEleCollKey, ctx}; + if (not condData.isValid()) return nullptr; + return condData->getDetectorElement(waferHash); +} diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConfigurationConditionsTool.h b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConfigurationConditionsTool.h new file mode 100644 index 0000000000000000000000000000000000000000..eef808511f576b6c71d7dbb4d0ac51982dc51a85 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConfigurationConditionsTool.h @@ -0,0 +1,109 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file FaserSCT_ConfigurationConditionsTool.h + * header file for tool which reads SCT configuration from database + * @author shaun.roe@cern.ch, gwilliam@mail.cern.ch +**/ + + +#ifndef FASERSCT_CONFIGURATIONCONDITIONSTOOL_H +#define FASERSCT_CONFIGURATIONCONDITIONSTOOL_H + +// Athena includes +#include "AthenaBaseComps/AthAlgTool.h" +#include "FaserSCT_ConditionsTools/ISCT_ConfigurationConditionsTool.h" + +#include "TrackerReadoutGeometry/SiDetectorElement.h" +#include "FaserSCT_ConditionsData/FaserSCT_ConfigurationCondData.h" +#include "StoreGate/ReadCondHandleKey.h" + +// Gaudi includes +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/EventContext.h" +#include "GaudiKernel/ContextSpecificPtr.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" + +// STL includes +#include <string> + +// Forward declarations +class FaserSCT_ID; + +/** + * @class FaserSCT_ConfigurationConditionsTool + * Tool which reads FaserSCT_Configuration from the database + * Deals with bad modules, bad links, strips out of the readout and bad strips +**/ + +class FaserSCT_ConfigurationConditionsTool: public extends<AthAlgTool, ISCT_ConfigurationConditionsTool> { + public: + + //@name Tool methods + //@{ + FaserSCT_ConfigurationConditionsTool(const std::string& type, const std::string& name, const IInterface* parent); + virtual ~FaserSCT_ConfigurationConditionsTool() = default; + virtual StatusCode initialize() override; + //@} + + /**Can the tool report about the given component? (chip, module...)*/ + virtual bool canReportAbout(InDetConditions::Hierarchy h) const override; + + /**Is the detector element good?*/ + virtual bool isGood(const Identifier& elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override; + virtual bool isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override; + + /**Is it good?, using wafer hash*/ + virtual bool isGood(const IdentifierHash& hashId) const override; + virtual bool isGood(const IdentifierHash& hashId, const EventContext& ctx) const override; + + /**List of bad modules*/ + virtual const std::set<Identifier>* badModules(const EventContext& ctx) const override; + virtual const std::set<Identifier>* badModules() const override; + /**List of bad strips*/ + virtual void badStrips(std::set<Identifier>& strips, const EventContext& ctx, bool ignoreBadModules=false, bool ignoreBadChips=false) const override; + virtual void badStrips(std::set<Identifier>& strips, bool ignoreBadModules=false, bool ignoreBadChips=false) const override; + /**List of bad strips for a given module*/ + virtual void badStrips(const Identifier& moduleId, std::set<Identifier>& strips, const EventContext& ctx, bool ignoreBadModules=false, bool ignoreBadChips=false) const override; + virtual void badStrips(const Identifier& moduleId, std::set<Identifier>& strips, bool ignoreBadModules=false, bool ignoreBadChips=false) const override; + /**List of bad links*/ + virtual std::pair<bool, bool> badLinks(const IdentifierHash& hash, const EventContext& ctx) const override; + virtual std::pair<bool, bool> badLinks(const IdentifierHash& hash) const override; + /**Bad links for a given module*/ + virtual const std::map<IdentifierHash, std::pair<bool, bool>>* badLinks(const EventContext& ctx) const override; + virtual const std::map<IdentifierHash, std::pair<bool, bool>>* badLinks() const override; + /**List of bad chips*/ + virtual const std::map<Identifier, unsigned int>* badChips(const EventContext& ctx) const override; + virtual const std::map<Identifier, unsigned int>* badChips() const override; + /**Bad chips for a given module*/ + virtual unsigned int badChips(const Identifier& moduleId, const EventContext& ctx) const override; + virtual unsigned int badChips(const Identifier& moduleId) const override; + /** Get the chip number containing a particular strip*/ + virtual int getChip(const Identifier& stripId, const EventContext& ctx) const override; + virtual int getChip(const Identifier& stripId) const override; + + private: + SG::ReadCondHandleKey<FaserSCT_ConfigurationCondData> m_condKey{this, "CondKeyConfig", "FaserSCT_ConfigurationCondData", "SCT DAQ configuration"}; + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + + const FaserSCT_ID* m_idHelper{nullptr}; + BooleanProperty m_checkStripsInsideModules{this, "checkStripsInsideModule", true, " Do we want to check if a strip is bad because it is inside a bad module"}; + + /** Is a strip within a bad module*/ + bool isStripInBadModule(const Identifier& stripId, const FaserSCT_ConfigurationCondData*) const; + /** Is a wafer in a bad module*/ + bool isWaferInBadModule(const Identifier& waferId, const EventContext& ctx) const; + + /**Is a chip with this Identifier good?*/ + bool isGoodChip(const Identifier& stripId, const EventContext& ctx) const; + + /** enum for constants*/ + enum {stripsPerChip=128, lastStrip=767, invalidChipNumber=-1}; + + const FaserSCT_ConfigurationCondData* getCondData(const EventContext& ctx) const; + const TrackerDD::SiDetectorElement* getDetectorElement(const IdentifierHash& waferHash, const EventContext& ctx) const; +}; + +#endif //FASERSCT_CONFIGURATIONCONDITIONSTOOL_H diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_NoisyStripTool.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_NoisyStripTool.cxx deleted file mode 100644 index 60f63b191b6dc4fd8484374ddbe918abc5882cbd..0000000000000000000000000000000000000000 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_NoisyStripTool.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and FASER collaborations -*/ - -#include "FaserSCT_NoisyStripTool.h" - - -FaserSCT_NoisyStripTool::FaserSCT_NoisyStripTool (const std::string& type, - const std::string& name, const IInterface* parent) : - base_class(type, name, parent) {} - - -StatusCode FaserSCT_NoisyStripTool::initialize() { - ATH_CHECK(m_readKey.initialize()); - return StatusCode::SUCCESS; -} - - -StatusCode FaserSCT_NoisyStripTool::finalize() { - return StatusCode::SUCCESS; -} - - -std::map<std::pair<int, int>, double> -FaserSCT_NoisyStripTool::getNoisyStrips(const EventContext& ctx) const { - std::map<std::pair<int, int>, double> noisyStrips {}; - SG::ReadCondHandle<CondAttrListCollection> readHandle{m_readKey, ctx}; - const CondAttrListCollection* readCdo {*readHandle}; - if (readCdo==nullptr) { - ATH_MSG_FATAL("Null pointer to the read conditions object"); - return noisyStrips; - } - // Get the validitiy range - EventIDRange rangeW; - if (not readHandle.range(rangeW)) { - ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); - return noisyStrips; - } - ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size()); - ATH_MSG_DEBUG("Range of input is " << rangeW); - - // Read mapping info - std::string sensorParam{"sensor"}; - std::string stripParam{"strip"}; - std::string occupancyParam{"occupancy"}; - CondAttrListCollection::const_iterator attrList{readCdo->begin()}; - CondAttrListCollection::const_iterator end{readCdo->end()}; - // CondAttrListCollection doesn't support C++11 type loops, no generic 'begin' - for (; attrList!=end; ++attrList) { - // A CondAttrListCollection is a map of ChanNum and AttributeList - CondAttrListCollection::ChanNum channelNumber{attrList->first}; - const CondAttrListCollection::AttributeList &payload{attrList->second}; - if (payload.exists(sensorParam) and not payload[sensorParam].isNull() and - payload.exists(stripParam) and not payload[stripParam].isNull() and - payload.exists(occupancyParam) and not payload[occupancyParam].isNull()) - { - int sensorVal {payload[sensorParam].data<int>()}; - int stripVal {payload[stripParam].data<int>()}; - float occupancyVal {payload[occupancyParam].data<float>()}; - if (sensorVal < 0 || stripVal < 0) continue; // Don't include invalid entries - ATH_MSG_VERBOSE(channelNumber << ": " << sensorVal << ", " << stripVal << ": " << occupancyVal); - noisyStrips.emplace(std::make_pair(sensorVal, stripVal), occupancyVal); - } else { - ATH_MSG_WARNING(sensorParam << " and/or " << stripParam << " and/or " << occupancyParam << " does not exist."); - } - } - return noisyStrips; -} - - -std::map<std::pair<int, int>, double> -FaserSCT_NoisyStripTool::getNoisyStrips() const { - const EventContext& ctx{Gaudi::Hive::currentContext()}; - return getNoisyStrips(ctx); -} diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_NoisyStripTool.h b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_NoisyStripTool.h deleted file mode 100644 index 6e1570f16cdb8a235ac90c8176555b9cec89d206..0000000000000000000000000000000000000000 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_NoisyStripTool.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS and CERN collaborations -*/ - -#ifndef FASERSCT_NOISY_STRIP_TOOL -#define FASERSCT_NOISY_STRIP_TOOL - -#include "AthenaBaseComps/AthAlgTool.h" -#include "AthenaPoolUtilities/CondAttrListCollection.h" -#include "FaserSCT_ConditionsTools/ISCT_NoisyStripTool.h" -#include "GaudiKernel/ICondSvc.h" -#include "GaudiKernel/EventContext.h" -#include "StoreGate/ReadCondHandleKey.h" - - -class FaserSCT_NoisyStripTool: public extends<AthAlgTool, ISCT_NoisyStripTool> { -public: - FaserSCT_NoisyStripTool(const std::string& type, const std::string& name, const IInterface* parent); - virtual ~FaserSCT_NoisyStripTool() = default; - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; - - virtual std::map<std::pair<int, int>, double> getNoisyStrips(const EventContext& ctx) const override; - virtual std::map<std::pair<int, int>, double> getNoisyStrips() const override; - -private: - SG::ReadCondHandleKey<CondAttrListCollection> m_readKey {this, "ReadKey", "/SCT/DAQ/NoisyStrips", "Key of input noisy strips folder"}; - ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"}; -}; - -#endif // FASERSCT_NOISY_STRIP_TOOL diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/components/FaserSCT_ConditionsTools_entries.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/components/FaserSCT_ConditionsTools_entries.cxx index 2d1e511188e5b1c136d04c62943b56cb271dc900..ae50a450b23170de19a520750fac0c9893f29ec6 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/components/FaserSCT_ConditionsTools_entries.cxx +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/components/FaserSCT_ConditionsTools_entries.cxx @@ -20,8 +20,8 @@ // #include "../SCT_StripVetoTool.h" // #include "../SCT_TdaqEnabledTool.h" #include "../FaserSCT_CableMappingTool.h" -#include "../FaserSCT_NoisyStripTool.h" #include "../FaserSCT_ConditionsSummaryTool.h" +#include "../FaserSCT_ConfigurationConditionsTool.h" // DECLARE_COMPONENT( SCT_ByteStreamErrorsTool ) // DECLARE_COMPONENT( SCT_ChargeTrappingTool ) @@ -45,5 +45,5 @@ DECLARE_COMPONENT( FaserSCT_SiliconConditionsTool ) // DECLARE_COMPONENT( SCT_StripVetoTool ) // DECLARE_COMPONENT( SCT_TdaqEnabledTool ) DECLARE_COMPONENT( FaserSCT_CableMappingTool ) -DECLARE_COMPONENT( FaserSCT_NoisyStripTool ) DECLARE_COMPONENT( FaserSCT_ConditionsSummaryTool ) +DECLARE_COMPONENT( FaserSCT_ConfigurationConditionsTool ) diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.cxx b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.cxx index 87bb2437c36c0d0c4f2cbe0cbfb4f3a1270c1e1a..4d7b497ce61ad48c1ab20e8b32c87a6eaa6d7851 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.cxx +++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.cxx @@ -28,7 +28,6 @@ TrackerByteStreamCnv::TrackerByteStreamCnv(ISvcLocator* svcloc) , m_tool("TrackerDataDecoderTool") , m_mappingTool("FaserSCT_CableMappingTool") , m_rdpSvc("FaserROBDataProviderSvc", "TrackerByteStreamCnv") - , m_noisyStripTool("FaserSCT_NoisyStripTool") , m_detStoreSvc("StoreGateSvc/DetectorStore", "TrackerByteStreamCnv") { } @@ -49,7 +48,6 @@ StatusCode TrackerByteStreamCnv::initialize() CHECK(m_rdpSvc.retrieve()); CHECK(m_tool.retrieve()); CHECK(m_mappingTool.retrieve()); - CHECK(m_noisyStripTool.retrieve()); ATH_CHECK(m_detStoreSvc.retrieve()); ATH_CHECK(m_detStoreSvc->retrieve(m_sctID, "FaserSCT_ID")); @@ -101,12 +99,9 @@ StatusCode TrackerByteStreamCnv::createObj(IOpaqueAddress* pAddr, DataObject*& p auto mapping = m_mappingTool->getCableMapping(); ATH_MSG_DEBUG("Cable mapping contains " << mapping.size() << " entries"); - auto noisyStrips = m_noisyStripTool->getNoisyStrips(); - ATH_MSG_DEBUG(noisyStrips.size() << " noisy strips"); - // Convert raw data into this container - CHECK( m_tool->convert(re, cont, key, mapping, noisyStrips) ); + CHECK( m_tool->convert(re, cont, key, mapping) ); pObj = SG::asStorable(cont); diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.h b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.h index 86262fbc244530aecac352d968a13d54d0943728..161bcd9740c6cb0d3c4f04e1bc03dfce7e613493 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.h +++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.h @@ -15,7 +15,6 @@ #include "AthenaBaseComps/AthMessaging.h" #include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" #include "FaserSCT_ConditionsTools/ISCT_CableMappingTool.h" -#include "FaserSCT_ConditionsTools/ISCT_NoisyStripTool.h" class TrackerDataDecoderTool; class IFaserROBDataProviderSvc; @@ -45,7 +44,6 @@ private: ServiceHandle<StoreGateSvc> m_detStoreSvc; ToolHandle<TrackerDataDecoderTool> m_tool; ToolHandle<ISCT_CableMappingTool> m_mappingTool; - ToolHandle<ISCT_NoisyStripTool> m_noisyStripTool; const FaserSCT_ID* m_sctID{nullptr}; }; diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx index fd31e7986cd436b9f852e859d1500fb456cf15c7..f8ec8ce1de921bb86ae9ef704a0dce1084a33947 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx +++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx @@ -81,8 +81,7 @@ StatusCode TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re, FaserSCT_RDO_Container* container, std::string key, - const std::map<int, std::pair<int, int> >& cableMapping, - const std::map<std::pair<int, int>, double>& noisyStrips) + const std::map<int, std::pair<int, int> >& cableMapping) { ATH_MSG_DEBUG("TrackerDataDecoderTool::convert()"); @@ -233,12 +232,6 @@ TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re, ATH_MSG_ERROR("Invalid strip number on side: " << stripOnSide); continue; } - // check if strip is noisy - auto it = noisyStrips.find(std::make_pair(waferHash, stripOnSide)); - if (it != noisyStrips.end() && m_occupancyCut > 0 && it->second >= m_occupancyCut) { - ATH_MSG_VERBOSE("Mask wafer " << waferHash << ", strip " << stripOnSide << " with an occupancy of " << it->second); - continue; - } Identifier digitID {m_sctID->strip_id(id, stripOnSide)}; int errors{0}; int groupSize{1}; diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.h b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.h index ddeacf543f00f6bde1d628714064b39bb379978f..fbe14e215a19ecf9f009197270161c5f68ae9e87 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.h +++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.h @@ -32,8 +32,7 @@ class TrackerDataDecoderTool : public AthAlgTool { virtual StatusCode finalize(); StatusCode convert(const DAQFormats::EventFull* re, FaserSCT_RDO_Container* cont, std::string key, - const std::map<int, std::pair<int, int> >& cableMapping, - const std::map<std::pair<int, int>, double>& noisyStrips); + const std::map<int, std::pair<int, int> >& cableMapping); private: const FaserSCT_ID* m_sctID{nullptr}; @@ -43,7 +42,6 @@ private: "ModuleMap", {7, 2, 5, 0, 3, 6, 1, 4}, "Mapping from online to offline module numbers" }; - Gaudi::Property<double> m_occupancyCut {this, "OccupancyCut", 0.015, "Mask strips with an occupancy larger than the OccupancyCut, for a value of -1 no strips will be masked"}; // Gaudi::Property<uint32_t> m_trb0Station { this, "Trb0StationNumber", 1, "Station number for TRB #0" }; }; diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py index 820cc73c5976089bea53e5fe2def1f87967837a9..a94a20eeea879b7e959a6b5da5825671d9291276 100644 --- a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py @@ -8,8 +8,8 @@ PileUpXingFolder=CompFactory.PileUpXingFolder from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg - from FaserSiLorentzAngleTool.FaserSCT_LorentzAngleConfig import FaserSCT_LorentzAngleCfg +from FaserSCT_ConditionsTools.FaserSCT_ConditionsSummaryToolConfig import FaserSCT_ConditionsSummaryToolCfg def FaserSCT_ClusterizationCommonCfg(flags, name="FaserSCT_ClusterizationToolCommon", **kwargs): @@ -20,7 +20,13 @@ def FaserSCT_ClusterizationCommonCfg(flags, name="FaserSCT_ClusterizationToolCom trackerClusterMakerTool = Tracker__TrackerClusterMakerTool(name = "TrackerClusterMakerTool") faserSCT_LorentzAngleTool=acc.popToolsAndMerge(FaserSCT_LorentzAngleCfg(flags)) kwargs.setdefault("timeBins", "01X") - clusteringTool = Tracker__FaserSCT_ClusteringTool(name, globalPosAlg = trackerClusterMakerTool, FaserSiLorentzAngleTool=faserSCT_LorentzAngleTool, **kwargs) + + FaserSCT_ConditionsSummaryTool = acc.popToolsAndMerge(FaserSCT_ConditionsSummaryToolCfg(flags)) + clusteringTool = Tracker__FaserSCT_ClusteringTool(name, + globalPosAlg=trackerClusterMakerTool, + FaserSiLorentzAngleTool=faserSCT_LorentzAngleTool, + conditionsTool=FaserSCT_ConditionsSummaryTool, + **kwargs) # clusteringTool.timeBins = "01X" # attach ToolHandles acc.setPrivateTools(clusteringTool) @@ -36,16 +42,20 @@ def FaserSCT_ClusterizationToolCfg(flags, name="FaserSCT_ClusterizationTool", ** def FaserSCT_ClusterizationBasicCfg(flags, **kwargs): """Return ComponentAccumulator for FaserSCT Clusterization""" acc = ComponentAccumulator() - pattern = kwargs.pop("ClusterToolTimingPattern","") + pattern = kwargs.pop("ClusterToolTimingPattern", "") + checkBadChannels = kwargs.pop("checkBadChannels", "False") # print("ClusterToolTimingPattern = ", pattern) if len(pattern) > 0 : - clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags, timeBins = pattern )) + clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags, timeBins=pattern, checkBadChannels=checkBadChannels)) else: - clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags)) + clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags, checkBadChannels=checkBadChannels)) + + FaserSCT_ConditionsSummaryTool = acc.popToolsAndMerge(FaserSCT_ConditionsSummaryToolCfg(flags)) kwargs.setdefault("SCT_ClusteringTool", clusterTool) kwargs.setdefault("DataObjectName", "SCT_RDOs") kwargs.setdefault("ClustersName", "SCT_ClusterContainer") + kwargs.setdefault("conditionsTool", FaserSCT_ConditionsSummaryTool) # kwargs.setdefault("SCT_FlaggedCondData", "SCT_Flags") Tracker__FaserSCT_Clusterization=CompFactory.Tracker.FaserSCT_Clusterization acc.addEventAlgo(Tracker__FaserSCT_Clusterization(**kwargs)) diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx index 640ba15148970d76ad415f4a6f127f167afe9d62..aa28620812293c71f962602105ee31888baf79de 100644 --- a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx @@ -41,9 +41,9 @@ StatusCode FaserSCT_Clusterization::initialize() { // later and declare everything to be 'good' if it is NULL) if (m_checkBadModules.value()) { ATH_MSG_INFO("Clusterization has been asked to look at bad module info"); - // ATH_CHECK(m_pSummaryTool.retrieve()); + ATH_CHECK(m_pSummaryTool.retrieve()); } else { - // m_pSummaryTool.disable(); + m_pSummaryTool.disable(); } // m_clusterContainerLinkKey = m_clusterContainerKey.key(); diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbg.py b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbg.py index 26f6dfc5b1709c135fa61dab1ac619c0eb98ee0d..36e1ded90c29372cddc26f6b65cc3354012ef3e8 100644 --- a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbg.py +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbg.py @@ -10,52 +10,65 @@ from AthenaCommon.Configurable import Configurable from CalypsoConfiguration.AllConfigFlags import ConfigFlags from AthenaConfiguration.TestDefaults import defaultTestFiles from CalypsoConfiguration.MainServicesConfig import MainServicesCfg +from FaserByteStreamCnvSvc.FaserByteStreamCnvSvcConfig import FaserByteStreamCnvSvcCfg from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg -from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg -#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg -#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("file", nargs="+", help="full path to input file") +parser.add_argument("--nevents", "-n", default=-1, type=int, help="Number of events to process") +args = parser.parse_args() # Set up logging and new style config log.setLevel(DEBUG) Configurable.configurableRun3Behavior = True # Configure -ConfigFlags.Input.Files = ['my.RDO.pool.root'] +ConfigFlags.Input.Files = args.file ConfigFlags.Output.ESDFileName = "myClusters.ESD.pool.root" -ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" +ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" +ConfigFlags.Input.ProjectName = "data22" +ConfigFlags.Input.isMC = False +ConfigFlags.GeoModel.FaserVersion = "FASERNU-03" +ConfigFlags.Common.isOnline = False ConfigFlags.GeoModel.Align.Dynamic = False ConfigFlags.Beam.NumberOfCollisions = 0. - +ConfigFlags.Detector.GeometryFaserSCT = True ConfigFlags.lock() # Core components acc = MainServicesCfg(ConfigFlags) -acc.merge(PoolReadCfg(ConfigFlags)) +# acc.merge(PoolReadCfg(ConfigFlags)) acc.merge(PoolWriteCfg(ConfigFlags)) - -#acc.merge(writeDigitizationMetadata(ConfigFlags)) - -# Inner Detector -acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) +acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, checkBadChannels=True, DataObjectName="SCT_RDOs", ClusterToolTimingPattern="XXX")) -# Timing -#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) +itemList = [ + "FaserSCT_RDO_Container#*", + "Tracker::FaserSCT_ClusterContainer#*" +] +acc.merge(OutputStreamCfg(ConfigFlags, "ESD", itemList)) # Dump config -# logging.getLogger('forcomps').setLevel(VERBOSE) -# acc.foreach_component("*").OutputLevel = VERBOSE -# acc.foreach_component("*ClassID*").OutputLevel = INFO -# acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE -# acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE -# acc.getService("StoreGateSvc").Dump = True -# acc.getService("ConditionStore").Dump = True -# acc.printConfig(withDetails=True) -# ConfigFlags.dump() - -# Execute and finish -sc = acc.run(maxEvents=-1) - -# Success should be 0 +logging.getLogger('forcomps').setLevel(VERBOSE) +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +acc.getService("StoreGateSvc").Dump = True +acc.getService("ConditionStore").Dump = True +acc.printConfig(withDetails=True) +ConfigFlags.dump() + +replicaSvc = acc.getService("DBReplicaSvc") +replicaSvc.COOLSQLiteVetoPattern = "" +replicaSvc.UseCOOLSQLite = True +replicaSvc.UseCOOLFrontier = False +replicaSvc.UseGeomSQLite = True + +sc = acc.run(maxEvents=args.nevents) sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/CMakeLists.txt b/Tracker/TrackerRecTools/FaserSiClusterizationTool/CMakeLists.txt index 3e22c8a99050cf977d76fc3c7dd21c482188fc41..00988a7c35f348a6bc624b5faa248ea917d8c161 100644 --- a/Tracker/TrackerRecTools/FaserSiClusterizationTool/CMakeLists.txt +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/CMakeLists.txt @@ -19,7 +19,7 @@ atlas_add_library( FaserSiClusterizationToolLib LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives Identifier EventPrimitives GaudiKernel TrackerSimData TrackerIdentifier TrackerReadoutGeometry TrackerRawData TrackerPrepRawData - TrkParameters CxxUtils + TrkParameters CxxUtils FaserSCT_ConditionsToolsLib PRIVATE_LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaPoolUtilities FileCatalog FaserDetDescr TrkSurfaces TrkEventPrimitives ) diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.cxx b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.cxx index 2963d98dfdb966c92bf9541052bfe9d0e256b654..d034c3c15d008def9a2bb954674f532e329da74a 100644 --- a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.cxx +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.cxx @@ -123,13 +123,13 @@ namespace Tracker ATH_CHECK(m_clusterMaker.retrieve()); -// if (m_checkBadChannels) { -// ATH_MSG_INFO("Clustering has been asked to look at bad channel info"); -// ATH_CHECK(m_conditionsTool.retrieve()); -// } else { -// m_conditionsTool.disable(); -// } - + if (m_checkBadChannels) { + ATH_MSG_INFO("Clustering has been asked to look at bad channel info"); + ATH_CHECK(m_conditionsTool.retrieve()); + } else { + m_conditionsTool.disable(); + } + if (m_doNewClustering and not m_lorentzAngleTool.empty()) { ATH_CHECK(m_lorentzAngleTool.retrieve()); } else { @@ -522,12 +522,12 @@ namespace Tracker unsigned int nBadStrips(0); for (unsigned int sn=thisStrip; sn!=thisStrip+nStrips; ++sn) { Identifier stripId = m_useRowInformation ? idHelper.strip_id(waferId,thisRow,sn) : idHelper.strip_id(waferId,sn); -// if (m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP)) { + if (m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP)) { currentVector.push_back(stripId); -// } else { -// currentVector.push_back(badId); -// ++nBadStrips; -// } + } else { + currentVector.push_back(badId); + ++nBadStrips; + } if (stripCount < 16) { hitsInThirdTimeBin = hitsInThirdTimeBin | (timePattern.test(0) << stripCount); } diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.h b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.h index 94a307a69bb6b79d1dbbe898039febf61f3150c0..0c56c468d21251e1b71b237c0591685244ff7b38 100644 --- a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.h +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.h @@ -13,6 +13,7 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "Identifier/Identifier.h" //#include "FaserSCT_ConditionsTools/ISCT_DCSConditionsTool.h" +#include "FaserSCT_ConditionsTools/ISCT_ConditionsSummaryTool.h" #include "InDetCondTools/ISiLorentzAngleTool.h" #include "TrackerReadoutGeometry/SiDetectorElementCollection.h" #include "FaserSiClusterizationTool/IFaserSCT_ClusteringTool.h" @@ -70,6 +71,7 @@ namespace Tracker // ToolHandle<ISCT_DCSConditionsTool> m_conditionsTool{this, "FaserSCT_DCSConditionsTool", "FaserSCT_ConditionsTools", "Tool to retrieve SCT Conditions summary"}; const FaserSCT_ID* m_pHelper; //!< ID helper for FaserSCT + ToolHandle<ISCT_ConditionsSummaryTool> m_conditionsTool{this, "conditionsTool", "FaserSCT_ConditionsTools/FaserSCT_ConditionsSummaryTool", "Tool to retrieve SCT Conditions summary"}; ToolHandle< TrackerClusterMakerTool > m_clusterMaker{this, "globalPosAlg", "TrackerClusterMakerTool"}; ToolHandle<ISiLorentzAngleTool> m_lorentzAngleTool {this, "FaserSiLorentzAngleTool", "FaserSiLorentzAngleTool", "Tool to retreive Lorentz angle of SCT"}; @@ -130,9 +132,8 @@ namespace Tracker // Inline methods /////////////////////////////////////////////////////////////////// - inline bool FaserSCT_ClusteringTool::isBad(const Identifier& ) const { - return false; - // return (not m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP)); + inline bool FaserSCT_ClusteringTool::isBad(const Identifier& stripId) const { + return (not m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP)); } inline bool FaserSCT_ClusteringTool::testTimeBinsN(const std::bitset<3>& timePattern) const {