10#include <CoralBase/Blob.h>
23 std::stringstream folderStr{};
25 folderStr<<
" **** "<<key.fullKey()<<std::endl;
27 ATH_MSG_INFO(
"Read the parametrized NSW uncertainties from COOL: "<<std::endl<<folderStr.str());
29 ATH_MSG_FATAL(
"Neither an extrenal JSON nor a COOL folder were defined. Please check");
30 return StatusCode::FAILURE;
34 return StatusCode::SUCCESS;
42 <<
". In theory this should not be called, but may happen"
43 <<
" if multiple concurrent events are being processed out of order.");
44 return StatusCode::SUCCESS;
47 std::unique_ptr<NswErrorCalibData> writeCdo = std::make_unique<NswErrorCalibData>(
m_idHelperSvc.get());
52 if (!inStream.good()) {
54 return StatusCode::FAILURE;
63 ATH_MSG_FATAL(
"Failed to load NSW error calibration folder from "<<key.fullKey());
64 return StatusCode::FAILURE;
67 itr != readHandle->end(); ++itr) {
68 const coral::AttributeList& atr = itr->second;
70 if (atr[
"data"].specification().
type() ==
typeid(coral::Blob)) {
74 return StatusCode::FAILURE;
77 data = *(
static_cast<const std::string*
>((atr[
"data"]).addressOfData()));
79 nlohmann::json lines = nlohmann::json::parse(
data);
85 return StatusCode::SUCCESS;
91 for (
auto& corr : lines.items()) {
92 nlohmann::json line = corr.value();
94 const std::string stationType = line[
"station"];
95 const int stationPhi = line[
"phi"];
96 const int stationEta = line[
"eta"];
97 const int multilayer = line[
"multilayer"];
98 const int gasGap = line[
"gasGap"];
101 if (stationType[0] ==
'M') {
103 errorCalibId =
m_idHelperSvc->mmIdHelper().channelID(stationType, stationEta, stationPhi,
104 multilayer, gasGap, 1
109 }
else if (stationType[0] ==
'S') {
111 errorCalibId =
m_idHelperSvc->stgcIdHelper().channelID (stationType, stationEta, stationPhi,
124 <<stationType<<
", "<<stationEta<<
", "<<stationPhi<<
", "
125 <<multilayer<<
", "<<gasGap);
126 return StatusCode::FAILURE;
129 const uint16_t minStrip = line[
"minStrip"];
130 const uint16_t maxStrip = line[
"maxStrip"];
131 const uint8_t author = line[
"clusterAuthor"];
132 const std::string modelName = line[
"modelName"];
133 std::vector<double> modelPars = line[
"modelPars"];
136 <<
"model name: "<<modelName<<
" author: "<<
static_cast<int>(author));
140 minStrip, maxStrip, std::move(modelPars)};
145 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
char data[hepevt_bytes_allocation_ATLAS]
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Base class for conditions algorithms.
ChanAttrListMap::const_iterator const_iterator
static EventIDRange infiniteTime()
Produces an EventIDRange that is inifinite in Time and invalid in RunLumi.
Helper struct to store different error calibrations for a certain channel range & also for seperate C...
StatusCode storeConstants(const Identifier &gasGapId, ErrorConstants &&newConstants)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode execute(const EventContext &) const override
StatusCode parseDataFromJSON(const nlohmann::json &lines, NswErrorCalibData &errorCalibData) const
Load the Jitter constants from the JSON format.
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_readKeysDb
SG::WriteCondHandleKey< NswErrorCalibData > m_writeKey
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_readFromJSON
Use an external JSON file to load the Jitter constants from.
NswUncertDbAlg(const std::string &name, ISvcLocator *svc)
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
bool readBlobAsString(const coral::Blob &, std::string &)