diff --git a/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml b/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml index 9cebc2e82b233d6191d7671cf6d9d6997cad23f9..1eff574f4c8756311fd412f5cc082a04bdd1d9f0 100644 --- a/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml +++ b/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml @@ -21,10 +21,14 @@ <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> </logicalservice> -<logicalservice name="COOLOFL_TDAQ"> - <service name="sqlite_file:data/sqlite200/CABP200.db" accessMode="read" /> - <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/CABP200.db" accessMode="read" /> -</logicalservice> + <logicalservice name="COOLOFL_TDAQ"> + <service name="sqlite_file:data/sqlite200/CABP200.db" accessMode="read" /> + <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/CABP200.db" accessMode="read" /> + </logicalservice> + + <logicalservice name="COOLOFL_INDET"> + <service name="sqlite_file:/home/tboeckh/tracking/run/noisy_strips.db" accessMode="read" /> + </logicalservice> <logicalservice name="COOLOFL_TRIGGER"> <service name="sqlite_file:data/sqlite200/waveform_reco.db" accessMode="read" /> 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_ConditionsSummaryTool.h b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_ConditionsSummaryTool.h new file mode 100644 index 0000000000000000000000000000000000000000..8fdc8ebc3ce9214db846e19651041909b6439dbf --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_ConditionsSummaryTool.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ISCT_CONDITIONSSUMMARYTOOL_H +#define ISCT_CONDITIONSSUMMARYTOOL_H + +#include "GaudiKernel/IInterface.h" +#include "Identifier/IdContext.h" + +#include "InDetConditionsSummaryService/InDetHierarchy.h" + +class Identifier; +class IdentifierHash; + +/** + * @class ISCT_ConditionsSummaryTool + * Interface class for service providing summary of status of a detector element +**/ + +class ISCT_ConditionsSummaryTool: virtual public IInterface, virtual public IAlgTool { +public: + virtual ~ISCT_ConditionsSummaryTool() = default; + /// Creates the InterfaceID and interfaceID() method + DeclareInterfaceID(ISCT_ConditionsSummaryTool, 1, 0); + + virtual bool isGood(const Identifier& elementId, const InDetConditions::Hierarchy h) const =0; + virtual bool isGood(const Identifier& elementId, const EventContext& ctx, const InDetConditions::Hierarchy h) const =0; + virtual bool isGood(const IdentifierHash& elementHash) const =0; + virtual bool isGood(const IdentifierHash& elementHash, const EventContext& ctx) const =0; +}; + +#endif //ISCT_CONDITIONSSUMMARYTOOL_H 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..07248a130d49726b724b42198317e14542e687af --- /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", "INDET_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", "INDET_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/python/FaserSCT_NoisyStripsConfig.py b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_NoisyStripsConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..c7bd2106f85fb75cae7e0069a248580cc6945272 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_NoisyStripsConfig.py @@ -0,0 +1,23 @@ +"""Define methods to configure FaserSCT_NoisyStrips + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from IOVDbSvc.IOVDbSvcConfig import addFolders +FaserSCT_NoisyStripsTool=CompFactory.FaserSCT_NoisyStripTool + +def FaserSCT_NoisyStripsToolCfg(flags, name="NoisyStripsTool", **kwargs): + """Return a configured FaserSCT_NoisyStripsTool""" + return FaserSCT_NoisyStripsTool(name, **kwargs) + +def FaserSCT_NoisyStripsCfg(flags, **kwargs): + """Return configured ComponentAccumulator and tool for FaserSCT_NoisyStrips + NoisyStripsTool may be provided in kwargs + """ + acc = ComponentAccumulator() + dbInstance = kwargs.get("dbInstance", "TDAQ_OFL") + dbFolder = kwargs.get("dbFolder", "/SCT/DAQ/NoisyStrips") + acc.merge(addFolders(flags, dbFolder, dbInstance, className="CondAttrListCollection")) + # acc.addPublicTool(tool) + return acc diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConditionsSummaryTool.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConditionsSummaryTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..afa408534cb14480c4664d5f3055af1b94e1126a --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConditionsSummaryTool.cxx @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "FaserSCT_ConditionsSummaryTool.h" +#include "FaserSCT_ConditionsTools/ISCT_ConditionsTool.h" + + +FaserSCT_ConditionsSummaryTool::FaserSCT_ConditionsSummaryTool(const std::string& type, const std::string& name, const IInterface* parent) : + base_class(type, name, parent), m_toolHandles{this} { + declareProperty("ConditionsTools", m_toolHandles); +} + +StatusCode FaserSCT_ConditionsSummaryTool::initialize() { + ATH_CHECK(m_toolHandles.retrieve()); + m_noReports = m_toolHandles.empty(); + return StatusCode::SUCCESS; +} + +bool FaserSCT_ConditionsSummaryTool::isGood(const Identifier& elementId, const EventContext& ctx, const InDetConditions::Hierarchy h) const { + if (not m_noReports) { + for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) { + if (tool->canReportAbout(h) and (not tool->isGood(elementId, ctx, h))) return false; + } + } + return true; +} + +bool FaserSCT_ConditionsSummaryTool::isGood(const Identifier& elementId, const InDetConditions::Hierarchy h) const { + return isGood(elementId, Gaudi::Hive::currentContext(), h); +} + +bool FaserSCT_ConditionsSummaryTool::isGood(const IdentifierHash& elementHash, const EventContext& ctx) const { + if (not m_noReports) { + for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) { + if ((tool->canReportAbout(InDetConditions::SCT_SIDE) or + tool->canReportAbout(InDetConditions::SCT_MODULE)) and + (not tool->isGood(elementHash, ctx))) { + return false; + } + } + } + return true; +} + +bool FaserSCT_ConditionsSummaryTool::isGood(const IdentifierHash& elementHash) const { + return isGood(elementHash, Gaudi::Hive::currentContext()); +} diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConditionsSummaryTool.h b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConditionsSummaryTool.h new file mode 100644 index 0000000000000000000000000000000000000000..681ac2be455a5ab243f61165c99022a169f8ee3e --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_ConditionsSummaryTool.h @@ -0,0 +1,38 @@ +#ifndef FASERSCT_CONDITIONSSUMMARYTOOL_H +#define FASERSCT_CONDITIONSSUMMARYTOOL_H + +#include "AthenaBaseComps/AthAlgTool.h" +#include "InDetConditionsSummaryService/InDetHierarchy.h" +#include "FaserSCT_ConditionsTools/ISCT_ConditionsSummaryTool.h" + +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/EventContext.h" + +#include <string> +#include <vector> + +class ISCT_ConditionsTool; + +/** + * @class FaserSCT_ConditionsSummaryTool + * Interface class for tool providing summary of status of an SCT detector element +**/ +class FaserSCT_ConditionsSummaryTool: public extends<AthAlgTool, ISCT_ConditionsSummaryTool> { +public: + FaserSCT_ConditionsSummaryTool(const std::string& type, const std::string& name, const IInterface* parent); //!< Tool constructor + virtual ~FaserSCT_ConditionsSummaryTool() = default; + virtual StatusCode initialize() override; + + virtual bool isGood(const Identifier& elementId, const InDetConditions::Hierarchy h) const override; + virtual bool isGood(const Identifier& elementId, const EventContext& ctx, const InDetConditions::Hierarchy h) const override; + virtual bool isGood(const IdentifierHash& elementHash) const override; + virtual bool isGood(const IdentifierHash& elementHash, const EventContext& ctx) const override; + +private: + StringArrayProperty m_reportingTools; //!< list of tools to be used + ToolHandleArray<ISCT_ConditionsTool> m_toolHandles; + bool m_noReports{true}; +}; + + +#endif // FASERSCT_CONDITIONSSUMMARYTOOL_H 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 0e2b5c444a8839e0421a073fd79b0737a89ed635..0000000000000000000000000000000000000000 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_NoisyStripTool.cxx +++ /dev/null @@ -1,113 +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() { - return StatusCode::SUCCESS; -} - - -StatusCode FaserSCT_NoisyStripTool::finalize() { - return StatusCode::SUCCESS; -} - - -std::map<std::pair<int, int>, double> -FaserSCT_NoisyStripTool::getNoisyStrips(const EventContext& /*ctx*/) const { - // TODO fix hard-coded definition of noisy strip and read from NoisyPixels.xml database - std::map<std::pair<int, int>, double> noisyStrips {}; - // noisyStrips.insert({std::make_pair(10, 150), 0.25279282895176935}); - // noisyStrips.insert({std::make_pair(20, 155), 0.9950721341449819}); - // noisyStrips.insert({std::make_pair(38, 41), 1.0}); - // noisyStrips.insert({std::make_pair(48, 643), 0.6209110977322898}); - // noisyStrips.insert({std::make_pair(49, 69), 1.0}); - // noisyStrips.insert({std::make_pair(49, 508), 0.1250027872544429}); - // noisyStrips.insert({std::make_pair(49, 660), 1.0}); - // noisyStrips.insert({std::make_pair(61, 350), 0.3669587709322809}); - // noisyStrips.insert({std::make_pair(61, 351), 0.32956496532655477}); - // noisyStrips.insert({std::make_pair(64, 287), 1.0}); - // noisyStrips.insert({std::make_pair(65, 323), 0.5987691484380226}); - // noisyStrips.insert({std::make_pair(67, 147), 1.0}); - // noisyStrips.insert({std::make_pair(67, 207), 1.0}); - // noisyStrips.insert({std::make_pair(67, 346), 0.6463977523580173}); - // noisyStrips.insert({std::make_pair(83, 114), 0.9968113809173412}); - // noisyStrips.insert({std::make_pair(86, 544), 0.46609583695676415}); - // noisyStrips.insert({std::make_pair(96, 79), 1.0}); - // noisyStrips.insert({std::make_pair(96, 183), 1.0}); - // noisyStrips.insert({std::make_pair(97, 550), 1.0}); - // noisyStrips.insert({std::make_pair(100, 215), 1.0}); - // noisyStrips.insert({std::make_pair(100, 610), 1.0}); - // noisyStrips.insert({std::make_pair(130, 722), 1.0}); - // noisyStrips.insert({std::make_pair(132, 297), 0.8765803732691151}); - // noisyStrips.insert({std::make_pair(144, 597), 1.0}); - // noisyStrips.insert({std::make_pair(144, 665), 1.0}); - // noisyStrips.insert({std::make_pair(145, 9), 1.0}); - // noisyStrips.insert({std::make_pair(145, 492), 1.0}); - // noisyStrips.insert({std::make_pair(145, 566), 1.0}); - // noisyStrips.insert({std::make_pair(146, 267), 1.0}); - // noisyStrips.insert({std::make_pair(147, 393), 0.4758623765246282}); - // noisyStrips.insert({std::make_pair(147, 394), 0.5172252324570206}); - // noisyStrips.insert({std::make_pair(147, 395), 0.5058532343300556}); - // noisyStrips.insert({std::make_pair(147, 396), 0.5272816464869445}); - // noisyStrips.insert({std::make_pair(147, 397), 0.4782036702566504}); - // noisyStrips.insert({std::make_pair(147, 398), 0.5092202376970589}); - // noisyStrips.insert({std::make_pair(147, 399), 0.4811247129127924}); - // noisyStrips.insert({std::make_pair(147, 600), 1.0}); - // noisyStrips.insert({std::make_pair(151, 417), 0.6434767097018753}); - // noisyStrips.insert({std::make_pair(152, 698), 0.2651013445715433}); - // noisyStrips.insert({std::make_pair(152, 699), 0.3080250629919504}); - // noisyStrips.insert({std::make_pair(153, 396), 0.4862532610876982}); - // noisyStrips.insert({std::make_pair(153, 397), 0.44509108747519344}); - // noisyStrips.insert({std::make_pair(154, 620), 0.4075634936562089}); - // noisyStrips.insert({std::make_pair(154, 621), 0.5001449372310299}); - // noisyStrips.insert({std::make_pair(155, 146), 0.4566637679220461}); - // noisyStrips.insert({std::make_pair(155, 147), 0.4941021695988584}); - // noisyStrips.insert({std::make_pair(158, 737), 0.5486208665016612}); - // noisyStrips.insert({std::make_pair(158, 738), 0.5591901353490758}); - // noisyStrips.insert({std::make_pair(158, 739), 0.5590786451713604}); - // noisyStrips.insert({std::make_pair(160, 7), 1.0}); - // noisyStrips.insert({std::make_pair(161, 763), 1.0}); - // noisyStrips.insert({std::make_pair(164, 613), 1.0}); - // noisyStrips.insert({std::make_pair(167, 175), 1.0}); - // noisyStrips.insert({std::make_pair(170, 90), 0.48484848484848486}); - // noisyStrips.insert({std::make_pair(170, 91), 0.4570874305973644}); - // noisyStrips.insert({std::make_pair(173, 18), 1.0}); - // noisyStrips.insert({std::make_pair(173, 484), 1.0}); - // noisyStrips.insert({std::make_pair(174, 230), 1.0}); - // noisyStrips.insert({std::make_pair(174, 530), 1.0}); - // noisyStrips.insert({std::make_pair(175, 683), 1.0}); - // noisyStrips.insert({std::make_pair(176, 418), 1.0}); - // noisyStrips.insert({std::make_pair(177, 149), 1.0}); - // noisyStrips.insert({std::make_pair(177, 345), 1.0}); - // noisyStrips.insert({std::make_pair(178, 214), 1.0}); - // noisyStrips.insert({std::make_pair(178, 508), 0.5192097576203537}); - // noisyStrips.insert({std::make_pair(178, 673), 0.6028496889424042}); - // noisyStrips.insert({std::make_pair(179, 651), 0.999977701964457}); - // noisyStrips.insert({std::make_pair(182, 525), 0.5044707561263853}); - // noisyStrips.insert({std::make_pair(182, 526), 0.5083506143108792}); - // noisyStrips.insert({std::make_pair(185, 493), 0.42738644725399694}); - // noisyStrips.insert({std::make_pair(185, 494), 0.43757664949717934}); - // noisyStrips.insert({std::make_pair(187, 427), 0.9203737150757019}); - // noisyStrips.insert({std::make_pair(188, 696), 0.6201752625593685}); - // noisyStrips.insert({std::make_pair(188, 752), 1.0}); - // noisyStrips.insert({std::make_pair(189, 249), 0.1250027872544429}); - // noisyStrips.insert({std::make_pair(189, 338), 0.25925925925925924}); - // noisyStrips.insert({std::make_pair(191, 170), 1.0}); - // noisyStrips.insert({std::make_pair(191, 406), 1.0}); - 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 c554620885b0cf28beb5c3d93c6d6fa31377e3a4..0000000000000000000000000000000000000000 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_NoisyStripTool.h +++ /dev/null @@ -1,25 +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 "FaserSCT_ConditionsTools/ISCT_NoisyStripTool.h" -#include "GaudiKernel/ICondSvc.h" -#include "GaudiKernel/EventContext.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; -}; - -#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 adad7ee37337a3d347bedc9c1f5b28cf731fb837..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,7 +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 ) @@ -44,4 +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 612978a068a931bf4a85b267537d89b626ba53e5..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() && 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 3bc337276a3f8eaba28fa51d90f7eb4f903592c7..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.1, "Mask strips with an occupancy larger than the OccupancyCut"}; // Gaudi::Property<uint32_t> m_trb0Station { this, "Trb0StationNumber", 1, "Station number for TRB #0" }; }; diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/README.md b/Tracker/TrackerRecAlgs/NoisyStripFinder/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b5160d73192745354a96c2df9f6da7f56c592744 --- /dev/null +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/README.md @@ -0,0 +1,10 @@ +Mask noisy strips: + +1) Run the NoisyStripFinderDbg.py on raw data files + +2) Run makeNoisyStripDB.py on the NoisyStripFinderHist.root produced by the NoisyStripFinderDbg.py script + +3) Edit the path for the COOLOFL_INDET database in Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml to point to the noisy_strips.db produced by the makeNoisyStripDB.py script + +4) Set the checkBadChannels flag to True for the FaserSCT_ClusterizationCfg, e.g. like this + acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, checkBadChannels=True, DataObjectName="SCT_EDGEMODE_RDOs", ClusterToolTimingPattern="01X")) diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderHist_Analysis.py b/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderHist_Analysis.py index 349316b31446434c1ad41f58ba2c269e4ce0a93a..f882e8f303929f4cf34858b852698308aa2ae993 100644 --- a/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderHist_Analysis.py +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderHist_Analysis.py @@ -71,7 +71,7 @@ for dictkey in HistDict: sensorhash.text = dictkey bini = 1 while bini <= 768: - if HistDict[dictkey].GetBinContent(bini) >= 0.1 : + if HistDict[dictkey].GetBinContent(bini) >= 0.01: strip = ET.SubElement(sensorhash, "Strip") strip.text = str(bini - 1) # strip number is offset by histogram bin number by 1 because of underflow bin occupancy = ET.SubElement(strip, "Occupancy") diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/share/makeNoisyStripDB.py b/Tracker/TrackerRecAlgs/NoisyStripFinder/share/makeNoisyStripDB.py new file mode 100644 index 0000000000000000000000000000000000000000..db03286cab1eb9a017a8297fb8305d0f796c2e3f --- /dev/null +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/share/makeNoisyStripDB.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +import ROOT +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("file", nargs="+", help="full path to input file") +parser.add_argument("-t", "--threshold", type=float, default=0.01, help="add strips with an occupancy larger this threshold to the database") +args = parser.parse_args() + +def GetKeyNames(self): + return [key.GetName() for key in f.GetListOfKeys()] + +ROOT.TFile.GetKeyNames = GetKeyNames + +numEvents = 0 +nfiles = 0 +HistDict = {} + +ROOT.TH1.AddDirectory(0) # This is necessary in order to have the histogram data after closing the file + +for inputfile in args.file: + f = ROOT.TFile.Open(inputfile, "r") + numEvents += f.Get("numEvents").GetVal() + if nfiles == 0: + trigger = f.Get("trigger").GetVal() + for rootkey in f.GetKeyNames(): + if rootkey == 'numEvents' or rootkey == 'trigger': + continue # skip over the root objects TParameters that store the trigger and number of events data + if rootkey in HistDict: # if sensor histogram has already been stored, then add to it + HistDict[rootkey].Add(f.Get(rootkey),1.0) + else: # if sensor histogram has not already been stored, then store this histogram + HistDict[rootkey] = f.Get(rootkey).Clone() + nfiles += 1 + f.Close() + +print("Total # of root files analyzed = ", nfiles) +print("Trigger mask = ", trigger) +print("Total number of events = ", numEvents) + +from PyCool import cool + +dbSvc = cool.DatabaseSvcFactory.databaseService() +connectString = 'sqlite://;schema=noisy_strips.db;dbname=OFLP200' + +print('Recreating database') + +dbSvc.dropDatabase(connectString) +db = dbSvc.createDatabase(connectString) + +noisyStripsSpec = cool.RecordSpecification() +noisyStripsSpec.extend('sensor', cool.StorageType.Int32) +noisyStripsSpec.extend('strip', cool.StorageType.Int32) +noisyStripsSpec.extend('occupancy', cool.StorageType.Float) + +description = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header clid="1238547719" service_type="71" /></addrHeader><typeName>CondAttrListCollection</typeName>' +noisyStripsFolderSpec = cool.FolderSpecification(cool.FolderVersioning.SINGLE_VERSION, noisyStripsSpec) +noisyStripsFolder = db.createFolder('/SCT/DAQ/NoisyStrips', noisyStripsFolderSpec, description, True) + +firstValid = 429 << 32 +lastValid = cool.ValidityKeyMax + +numNoisyStrips = 0 +for dictkey in HistDict: + HistDict[dictkey].Scale(1.0/float(numEvents)) + for bini in range(768): + if HistDict[dictkey].GetBinContent(bini+1) >= args.threshold: + noisyStripsRecord = cool.Record(noisyStripsSpec) + noisyStripsRecord['sensor'] = int(dictkey) + noisyStripsRecord['strip'] = int(bini) + noisyStripsRecord['occupancy'] = HistDict[dictkey].GetBinContent(bini+1) + noisyStripsFolder.storeObject(firstValid, lastValid, noisyStripsRecord, numNoisyStrips) + numNoisyStrips += 1 +db.closeDatabase() + +print('Database completed') +print(f"Added {numNoisyStrips} strips to database") diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.cxx b/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.cxx index 71598696beb29fa13256f18193738eaee2b38ee5..7cedc520613ea374b08eb4fe76111ce368609201 100644 --- a/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.cxx +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.cxx @@ -126,7 +126,7 @@ StatusCode NoisyStripFinder::finalize() ATH_MSG_INFO( "---------- hot strip occupancy >= 0.1 for Tracker Sensor hash = "<< it->first <<" ----------" ); int i = 1; while (i <= 768){ - if ( it->second->GetBinContent(i)/(double)m_numberOfEvents >= 0.1 ){ + if ( it->second->GetBinContent(i)/(double)m_numberOfEvents >= 0.01 ){ ATH_MSG_INFO( "hot strip # = " << i-1 << ", hit occupancy = " << it->second->GetBinContent(i)/(double)m_numberOfEvents ); // print out hot strips } i++; diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/test/NoisyStripFinderDbg.py b/Tracker/TrackerRecAlgs/NoisyStripFinder/test/NoisyStripFinderDbg.py index b3c0697cfcef6539190aeeebf26e16b4e0d3b100..f1d2ef1434110fa4a87a4567055e8f3d112f30c0 100644 --- a/Tracker/TrackerRecAlgs/NoisyStripFinder/test/NoisyStripFinderDbg.py +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/test/NoisyStripFinderDbg.py @@ -13,18 +13,22 @@ from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg from FaserByteStreamCnvSvc.FaserByteStreamCnvSvcConfig import FaserByteStreamCnvSvcCfg from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg from NoisyStripFinder.NoisyStripFinderConfig import NoisyStripFinderCfg +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() log.setLevel(DEBUG) Configurable.configurableRun3Behavior = True -run = 1792 -ConfigFlags.Input.Files = [f"/home/tboeckh/Documents/data/TI12/Faser-Physics-00{run}-00000.raw"] -ConfigFlags.Output.ESDFileName = f"run00{run}-00000.ESD.pool.root" -ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" +ConfigFlags.Input.Files = args.file +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" ConfigFlags.Input.ProjectName = "data21" ConfigFlags.Input.isMC = False -ConfigFlags.GeoModel.FaserVersion = "FASER-01" +ConfigFlags.GeoModel.FaserVersion = "FASERNU-03" ConfigFlags.Common.isOnline = False ConfigFlags.GeoModel.Align.Dynamic = False ConfigFlags.Beam.NumberOfCollisions = 0. @@ -33,12 +37,11 @@ ConfigFlags.lock() acc = MainServicesCfg(ConfigFlags) acc.merge(PoolWriteCfg(ConfigFlags)) -acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) +acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags, OccupancyCut=-1)) acc.merge(FaserSCT_ClusterizationCfg( ConfigFlags, - name="LevelClustering", - DataObjectName="SCT_LEVELMODE_RDOs", - ClusterToolTimingPattern="X1X")) + DataObjectName="SCT_RDOs", + ClusterToolTimingPattern="XXX")) acc.merge(NoisyStripFinderCfg(ConfigFlags)) # Hack to avoid problem with our use of MC databases when isMC = False @@ -48,5 +51,5 @@ replicaSvc.UseCOOLSQLite = True replicaSvc.UseCOOLFrontier = False replicaSvc.UseGeomSQLite = True -sc = acc.run(maxEvents=-1) +sc = acc.run(maxEvents=args.nevents) sys.exit(not sc.isSuccess()) 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/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 { diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/TI12CKF2Config.py b/Tracking/Acts/FaserActsKalmanFilter/python/TI12CKF2Config.py index 28b0aa9d1c4d98024f5b1e295c2e0256e2086c6c..acb88356cfa3222e26c861a8c3a4daaaf6e45bc1 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/python/TI12CKF2Config.py +++ b/Tracking/Acts/FaserActsKalmanFilter/python/TI12CKF2Config.py @@ -54,8 +54,6 @@ def TI12CKF2Cfg(flags, **kwargs): track_seed_tool.covTheta = initial_variance_inflation[3] * sigma_theta * sigma_theta track_seed_tool.covQOverP = initial_variance_inflation[4] * sigma_qop * sigma_qop track_seed_tool.std_cluster = 0.0231 - origin = -1900 - track_seed_tool.origin = origin track_seed_tool.TrackCollection = "Segments" trajectory_states_writer_tool = CompFactory.RootTrajectoryStatesWriterTool() @@ -88,9 +86,18 @@ def TI12CKF2Cfg(flags, **kwargs): kalman_fitter1.SeedCovarianceScale = 10 kalman_fitter1.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool1 kalman_fitter1.RootTrajectorySummaryWriterTool = trajectory_summary_writer_tool1 - kalman_fitter1.origin = origin ckf.KalmanFitterTool1 = kalman_fitter1 + kalman_fitter2 = CompFactory.KalmanFitterTool(name="fitterTool2", **kwargs) + kalman_fitter2.noDiagnostics = kwargs["noDiagnostics"] + kalman_fitter2.ActsLogging = "INFO" + kalman_fitter2.SummaryWriter = True + kalman_fitter2.StatesWriter = True + kalman_fitter2.SeedCovarianceScale = 1 + kalman_fitter2.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool2 + kalman_fitter2.RootTrajectorySummaryWriterTool = trajectory_summary_writer_tool2 + ckf.KalmanFitterTool2 = kalman_fitter2 + ckf.TrackSeed = track_seed_tool ckf.ActsLogging = "INFO" ckf.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool @@ -99,7 +106,6 @@ def TI12CKF2Cfg(flags, **kwargs): ckf.StatesWriter = True ckf.PerformanceWriter = False # ckf.PerformanceWriterTool = trajectory_performance_writer_tool - ckf.origin = origin ckf.nMax = 10 ckf.chi2Max = 100000 diff --git a/Tracking/Acts/FaserActsKalmanFilter/test/TI12CKF2.py b/Tracking/Acts/FaserActsKalmanFilter/test/TI12CKF2.py index fffb07177a028816aa47fea33d0521692c6cc2f3..d59ab98406e6871d9a520ea2f6cc2545376d4a98 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/test/TI12CKF2.py +++ b/Tracking/Acts/FaserActsKalmanFilter/test/TI12CKF2.py @@ -16,34 +16,41 @@ from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerS from TrackerSegmentFit.TrackerSegmentFitConfig import SegmentFitAlgCfg from FaserActsKalmanFilter.GhostBustersConfig import GhostBustersCfg from FaserActsKalmanFilter.TI12CKF2Config import TI12CKF2Cfg +from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg +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() log.setLevel(DEBUG) Configurable.configurableRun3Behavior = True -ConfigFlags.Input.Files = ['threeStationRun6833.raw'] +ConfigFlags.Input.Files = args.file ConfigFlags.Output.ESDFileName = "CKF.ESD.pool.root" ConfigFlags.addFlag("Output.xAODFileName", f"CKF.xAOD.root") ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" ConfigFlags.Input.ProjectName = "data22" ConfigFlags.Input.isMC = False -ConfigFlags.GeoModel.FaserVersion = "FASER-02" +ConfigFlags.GeoModel.FaserVersion = "FASERNU-03" ConfigFlags.Common.isOnline = False ConfigFlags.GeoModel.Align.Dynamic = False ConfigFlags.Beam.NumberOfCollisions = 0. ConfigFlags.Detector.GeometryFaserSCT = True -ConfigFlags.TrackingGeometry.MaterialSource = "geometry-maps.json" +# ConfigFlags.TrackingGeometry.MaterialSource = "geometry-maps.json" ConfigFlags.lock() acc = MainServicesCfg(ConfigFlags) acc.merge(FaserGeometryCfg(ConfigFlags)) acc.merge(PoolWriteCfg(ConfigFlags)) -acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) -acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, DataObjectName="SCT_LEVELMODE_RDOs", ClusterToolTimingPattern="X1X")) +acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags, OccupancyCut=0.015)) +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, DataObjectName="SCT_EDGEMODE_RDOs", ClusterToolTimingPattern="01X")) acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) acc.merge(SegmentFitAlgCfg(ConfigFlags, SharedHitFraction=0.61, MinClustersPerFit=5, TanThetaXZCut=0.083)) acc.merge(GhostBustersCfg(ConfigFlags)) -acc.merge(TI12CKF2Cfg(ConfigFlags, noDiagnostics=False)) +acc.merge(TI12CKF2Cfg(ConfigFlags, noDiagnostics=True)) acc.getEventAlgo("CKF2").OutputLevel = DEBUG # logging.getLogger('forcomps').setLevel(VERBOSE) @@ -61,5 +68,5 @@ replicaSvc.UseCOOLSQLite = True replicaSvc.UseCOOLFrontier = False replicaSvc.UseGeomSQLite = True -sc = acc.run(maxEvents=-1) +sc = acc.run(maxEvents=args.nevents) sys.exit(not sc.isSuccess())