diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/FillFromStringUtility.h b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/FillFromStringUtility.h new file mode 100644 index 0000000000000000000000000000000000000000..6e445fcc875e87dde1b298f5d1f2f5fa4bc3b387 --- /dev/null +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/FillFromStringUtility.h @@ -0,0 +1,63 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FillFromStringUtility_h +#define FillFromStringUtility_h + +// Include STL stuff +#include <limits> +#include <string> + +// Include boost stuff +#include "boost/tokenizer.hpp" +#include "boost/lexical_cast.hpp" + +namespace { + template <typename C> + bool fillArrayFromString(const std::string& source, C& userContainer) { + if (source.empty()) return false; + typedef typename C::value_type V_t; + V_t errVal{std::numeric_limits<V_t>::has_quiet_NaN ? (std::numeric_limits<V_t>::quiet_NaN()) : 0}; + boost::char_separator<char> sep{" "}; + typedef boost::tokenizer<boost::char_separator<char> > Tokenizer; + Tokenizer tok{source, sep}; + bool noNan{true}; + const Tokenizer::iterator end{tok.end()}; + int j{0}; + for (Tokenizer::iterator i{tok.begin()}; i!=end; ++i) { + try { + userContainer[j]=boost::lexical_cast<V_t>(*i); + } catch (const boost::bad_lexical_cast&) { + userContainer[j]=errVal; + noNan=false; + } + ++j; + } + return noNan; + } + template <typename C> + bool fillEmptyVectorFromString(const std::string& source, C& userContainer) { + if (source.empty()) return false; + typedef typename C::value_type V_t; + V_t errVal{std::numeric_limits<V_t>::has_quiet_NaN ? (std::numeric_limits<V_t>::quiet_NaN()) : 0}; + boost::char_separator<char> sep{" "}; + typedef boost::tokenizer<boost::char_separator<char> > Tokenizer; + Tokenizer tok{source, sep}; + bool noNan{true}; + const Tokenizer::iterator end{tok.end()}; + for (Tokenizer::iterator i{tok.begin()}; i!=end; ++i) { + try { + userContainer.push_back(boost::lexical_cast<V_t>(*i)); + } catch (const boost::bad_lexical_cast&) { + userContainer.push_back(errVal); + noNan=false; + } + } + return noNan; + } +} // end of anonymous namespace + +#endif // FillFromStringUtility_h diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibChipGainCondAlg.cxx b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibChipGainCondAlg.cxx index 7e07294bc35086ed4be5ae54edab9665f3e830d0..fc9751e48e25303270458b86d9e2cd7c062569c4 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibChipGainCondAlg.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibChipGainCondAlg.cxx @@ -4,15 +4,17 @@ #include "SCT_ReadCalibChipGainCondAlg.h" +#include "FillFromStringUtility.h" + #include "Identifier/IdentifierHash.h" #include "InDetIdentifier/SCT_ID.h" #include "SCT_ConditionsData/SCT_ConditionsParameters.h" -#include "SCT_ConditionsTools/SCT_ReadCalibChipUtilities.h" +#include "SCT_ConditionsTools/SCT_ReadCalibChipDefs.h" #include <memory> using namespace SCT_ConditionsData; -using namespace SCT_ReadCalibChipUtilities; +using namespace SCT_ReadCalibChipDefs; SCT_ReadCalibChipGainCondAlg::SCT_ReadCalibChipGainCondAlg(const std::string& name, ISvcLocator* pSvcLocator) : ::AthReentrantAlgorithm(name, pSvcLocator) @@ -116,6 +118,6 @@ SCT_ReadCalibChipGainCondAlg::insertNptGainFolderData(SCT_ModuleGainCalibData& t for (int i{0}; i!=N_NPTGAIN; ++i) { SCT_ModuleCalibParameter& datavec{theseCalibData[i]}; const std::string &dbData{((folderData)[nPtGainDbParameterNames[i]]).data<std::string>()}; - fillFromString(dbData, datavec); + fillArrayFromString(dbData, datavec); } } diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibChipNoiseCondAlg.cxx b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibChipNoiseCondAlg.cxx index 2bd04aa4293586b2d8a2663f443d590066f5536c..1cf9a3525a100aa098567629b20b81ef60b8379f 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibChipNoiseCondAlg.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibChipNoiseCondAlg.cxx @@ -4,16 +4,18 @@ #include "SCT_ReadCalibChipNoiseCondAlg.h" +#include "FillFromStringUtility.h" + #include "Identifier/IdentifierHash.h" #include "InDetIdentifier/SCT_ID.h" #include "SCT_ConditionsData/SCT_ConditionsParameters.h" -#include "SCT_ConditionsTools/SCT_ReadCalibChipUtilities.h" +#include "SCT_ConditionsTools/SCT_ReadCalibChipDefs.h" #include <limits> #include <memory> using namespace SCT_ConditionsData; -using namespace SCT_ReadCalibChipUtilities; +using namespace SCT_ReadCalibChipDefs; SCT_ReadCalibChipNoiseCondAlg::SCT_ReadCalibChipNoiseCondAlg(const std::string& name, ISvcLocator* pSvcLocator) : ::AthReentrantAlgorithm(name, pSvcLocator) @@ -117,6 +119,6 @@ SCT_ReadCalibChipNoiseCondAlg::insertNoiseOccFolderData(SCT_ModuleNoiseCalibData for (int i{0}; i!=N_NOISEOCC; ++i) { SCT_ModuleCalibParameter& datavec{theseCalibData[i]}; std::string dbData{((folderData)[noiseOccDbParameterNames[i]]).data<std::string>()}; - fillFromString(dbData, datavec); + fillArrayFromString(dbData, datavec); } } diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibDataCondAlg.cxx b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibDataCondAlg.cxx index 5e950f6851a3ba2d87d4fc37066adf5869669c25..a3939169869abf9625b7f5c17b978b62f3b34fdd 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibDataCondAlg.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_ReadCalibDataCondAlg.cxx @@ -4,15 +4,13 @@ #include "SCT_ReadCalibDataCondAlg.h" +#include "FillFromStringUtility.h" + #include "Identifier/IdentifierHash.h" #include "InDetIdentifier/SCT_ID.h" #include "InDetReadoutGeometry/SiDetectorElement.h" #include "SCT_ConditionsData/SCT_ConditionsParameters.h" -// Include boost stuff -#include "boost/lexical_cast.hpp" -#include "boost/tokenizer.hpp" - // Include STL stuff #include <limits> #include <memory> @@ -21,24 +19,6 @@ using namespace SCT_ConditionsData; // Utility functions namespace { - template <typename C> - bool fillFromString(const std::string& source, C& userContainer) { - typedef typename C::value_type V_t; - V_t errVal{0}; - boost::char_separator<char> sep{" "}; - typedef boost::tokenizer<boost::char_separator<char> > Tokenizer; - Tokenizer tok{source, sep}; - bool noNan{true}; - for (Tokenizer::iterator i{tok.begin()}; i!=tok.end(); ++i) { - try { - userContainer.push_back(boost::lexical_cast<V_t>(*i)); - } catch (const boost::bad_lexical_cast&) { - userContainer.push_back(errVal); - noNan=false; - } - } - return noNan; - } float coerceToFloatRange(const double value) { const float maxfloat{std::numeric_limits<float>::max()}; if (value>maxfloat) return maxfloat; @@ -236,13 +216,13 @@ StatusCode SCT_ReadCalibDataCondAlg::execute(const EventContext& ctx) const { // Convert the defect strings to vectors std::vector<unsigned int> gaindefectbvec; - fillFromString(gaindefectb, gaindefectbvec); + fillEmptyVectorFromString(gaindefectb, gaindefectbvec); std::vector<unsigned int> gaindefectevec; - fillFromString(gaindefecte, gaindefectevec); + fillEmptyVectorFromString(gaindefecte, gaindefectevec); std::vector<unsigned int> defectTypevec; - fillFromString(defectType, defectTypevec); + fillEmptyVectorFromString(defectType, defectTypevec); std::vector<double> parValuevec; - fillFromString(parValue, parValuevec); + fillEmptyVectorFromString(parValue, parValuevec); // Fill the Calib defect objects long unsigned int gainvec_size{gaindefectbvec.size()}; diff --git a/InnerDetector/InDetConditions/SCT_ConditionsTools/SCT_ConditionsTools/SCT_ReadCalibChipDefs.h b/InnerDetector/InDetConditions/SCT_ConditionsTools/SCT_ConditionsTools/SCT_ReadCalibChipDefs.h new file mode 100644 index 0000000000000000000000000000000000000000..4d42232c271297bd6f7f56dd65ae219c22dd658b --- /dev/null +++ b/InnerDetector/InDetConditions/SCT_ConditionsTools/SCT_ConditionsTools/SCT_ReadCalibChipDefs.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCT_ReadCalibDataDefs_h +#define SCT_ReadCalibDataDefs_h + +// Include STL stuff +#include <array> +#include <string> + +#include "SCT_ConditionsData/SCT_ConditionsParameters.h" + +namespace SCT_ReadCalibChipDefs { + const std::array<std::string, SCT_ConditionsData::N_NPTGAIN> nPtGainDbParameterNames{ + {"gainByChip", "gainRMSByChip", "offsetByChip", "offsetRMSByChip", "noiseByChip", "noiseRMSByChip"} + }; + const std::array<std::string, SCT_ConditionsData::N_NPTGAIN> nPtGainParameterNames{ + {"GainByChip", "GainRMSByChip", "OffsetByChip", "OffsetRMSByChip", "NoiseByChip", "NoiseRMSByChip"} + }; + const std::array<std::string, SCT_ConditionsData::N_NOISEOCC> noiseOccDbParameterNames{ + {"occupancyByChip", "occupancyRMSByChip", "offsetByChip", "noiseByChip"} + }; + const std::array<std::string, SCT_ConditionsData::N_NOISEOCC> noiseOccParameterNames{ + {"OccupancyByChip", "OccupancyRMSByChip", "OffsetByChip", "NoiseByChip"} + }; +} // end of namespace + +#endif // SCT_ReadCalibDataDefs_h diff --git a/InnerDetector/InDetConditions/SCT_ConditionsTools/SCT_ConditionsTools/SCT_ReadCalibChipUtilities.h b/InnerDetector/InDetConditions/SCT_ConditionsTools/SCT_ConditionsTools/SCT_ReadCalibChipUtilities.h deleted file mode 100644 index 53ec3262bbc6f555f30543cd5cb2dfc545046ebe..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetConditions/SCT_ConditionsTools/SCT_ConditionsTools/SCT_ReadCalibChipUtilities.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef SCT_ReadCalibDataUtilities_h -#define SCT_ReadCalibDataUtilities_h - -// Include STL stuff -#include <array> -#include <string> - -// Include boost stuff -#include "boost/tokenizer.hpp" -#include "boost/lexical_cast.hpp" - -#include "SCT_ConditionsData/SCT_ConditionsParameters.h" - -namespace SCT_ReadCalibChipUtilities { - template <typename C> - bool fillFromString(const std::string& source, C& userContainer) { - if (source.empty()) return false; - typedef typename C::value_type V_t; - V_t errVal{std::numeric_limits<V_t>::has_quiet_NaN ? (std::numeric_limits<V_t>::quiet_NaN()) : 0}; - boost::char_separator<char> sep{" "}; - typedef boost::tokenizer<boost::char_separator<char> > Tokenizer; - Tokenizer tok{source, sep}; - bool noNan{true}; - const Tokenizer::iterator end{tok.end()}; - int j{0}; - for (Tokenizer::iterator i{tok.begin()}; i!=end; ++i) { - try { - userContainer[j]=boost::lexical_cast<V_t>(*i); - } catch (const boost::bad_lexical_cast&) { - userContainer[j]=errVal; - noNan=false; - } - ++j; - } - return noNan; - } - - const std::array<std::string, SCT_ConditionsData::N_NPTGAIN> nPtGainDbParameterNames{ - {"gainByChip", "gainRMSByChip", "offsetByChip", "offsetRMSByChip", "noiseByChip", "noiseRMSByChip"} - }; - const std::array<std::string, SCT_ConditionsData::N_NPTGAIN> nPtGainParameterNames{ - {"GainByChip", "GainRMSByChip", "OffsetByChip", "OffsetRMSByChip", "NoiseByChip", "NoiseRMSByChip"} - }; - const std::array<std::string, SCT_ConditionsData::N_NOISEOCC> noiseOccDbParameterNames{ - {"occupancyByChip", "occupancyRMSByChip", "offsetByChip", "noiseByChip"} - }; - const std::array<std::string, SCT_ConditionsData::N_NOISEOCC> noiseOccParameterNames{ - {"OccupancyByChip", "OccupancyRMSByChip", "OffsetByChip", "NoiseByChip"} - }; - - const std::string nPtGainFolder{"/SCT/DAQ/Calibration/ChipGain"}; - const std::string noiseOccFolder{"/SCT/DAQ/Calibration/ChipNoise"}; - -}//end of anon namespace - -#endif // SCT_ReadCalibDataUtilities_h diff --git a/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ReadCalibChipDataTool.cxx b/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ReadCalibChipDataTool.cxx index 54060b99a7686886492f29fe06bd0462682b87b9..c29d5466e69db2aa37d31a1b99d698e4283f5d08 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ReadCalibChipDataTool.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ReadCalibChipDataTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** @file SCT_ReadCalibChipDataTool.cxx Implementation file for SCT_ReadCalibChipDataTool. @@ -14,10 +14,10 @@ #include "SCT_ConditionsData/SCT_ModuleCalibParameter.h" #include "SCT_ConditionsData/SCT_ModuleGainCalibData.h" #include "SCT_ConditionsData/SCT_ModuleNoiseCalibData.h" -#include "SCT_ConditionsTools/SCT_ReadCalibChipUtilities.h" +#include "SCT_ConditionsTools/SCT_ReadCalibChipDefs.h" using namespace SCT_ConditionsData; -using namespace SCT_ReadCalibChipUtilities; +using namespace SCT_ReadCalibChipDefs; //---------------------------------------------------------------------- SCT_ReadCalibChipDataTool::SCT_ReadCalibChipDataTool (const std::string& type, const std::string& name, const IInterface* parent) :