11#include "nlohmann/json.hpp"
19 return StatusCode::SUCCESS;
27 <<
". In theory this should not be called, but may happen"
28 <<
" if multiple concurrent events are being processed out of order.");
29 return StatusCode::SUCCESS;
33 nlohmann::json blob{};
36 if (!in_json.good()) {
38 return StatusCode::FAILURE;
46 return StatusCode::FAILURE;
49 for (
const auto& itr : **readHandle) {
50 const coral::AttributeList& atr = itr.second;
51 blob = nlohmann::json::parse(*(
static_cast<const std::string*
>((atr[
"data"]).addressOfData())));
56 auto condObj = std::make_unique<TwinTubeMap>(
m_idHelperSvc.get());
60 std::unordered_map<unsigned int, HedgehogBoardPtr> hedgeHogBoards{};
62 for (
const auto& boardMapping : blob[
"HedgehogBoards"].items()) {
63 nlohmann::json payLoad = boardMapping.value();
65 const unsigned boardId = payLoad[
"boardId"];
66 const Mapping mapping = payLoad[
"hedgeHogPins"];
67 const unsigned tubeLayers = payLoad[
"nTubeLayers"];
68 auto newBoard = std::make_unique<HedgehogBoard>(mapping, tubeLayers, boardId);
69 if (payLoad.find(
"hvDelayTime") != payLoad.end()) {
70 newBoard->setHVDelayTime(payLoad[
"hvDelayTime"]);
74 ATH_MSG_FATAL(
"There's already a board registered under "<<storeMe->boardId()<<
".");
75 return StatusCode::FAILURE;
77 storeMe = std::move(newBoard);
79 for (
const auto& twinMapping : blob[
"TwinTubeMapping"].items()) {
80 nlohmann::json payLoad = twinMapping.value();
83 const int eta = payLoad[
"eta"];
84 const int phi = payLoad[
"phi"];
85 const int ml = payLoad[
"ml"];
89 ATH_MSG_FATAL(
"Failed to build valid identifier from "<<payLoad);
90 return StatusCode::FAILURE;
92 const std::vector<unsigned int> boardMounting = payLoad[
"mountedBoards"];
93 for (
unsigned int place = 0; place < boardMounting.size(); ++place) {
94 ATH_CHECK(condObj->addHedgeHogBoard(detElId, hedgeHogBoards[boardMounting[place]], place));
98 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#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.
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
int stationNameIndex(const std::string &name) const
std::shared_ptr< const HedgehogBoard > HedgehogBoardPtr
std::array< uint8_t, nChPerBoard > Mapping
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode execute(const EventContext &ctx) const override final
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
SG::WriteCondHandleKey< TwinTubeMap > m_writeKey
StatusCode initialize() override final
Gaudi::Property< std::string > m_extJSONFile
Gaudi::Property< double > m_hvDelay
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
HedgehogBoard::HedgehogBoardPtr HedgehogBoardPtr