8#include <nlohmann/json.hpp>
19 const nlohmann::json&
json;
25 int ipcb = (strip_id.
istrip-1)/1024 + 1;
36 auto strip = it->second.getStrip(iclass, strip_id.
istrip);
43 int ipcb = (strip_id.
istrip-1)/1024 + 1;
61 using json = nlohmann::json;
62 json jroot = json::parse(in);
63 for (
const json& jmodule : jroot.at(
"elementarray")) {
66 }
catch (std::exception& e) {
67 throw std::runtime_error(e.what());
77 std::unique_ptr<ElementModel> deformation_model;
78 std::string model = j.
json.at(
"model");
79 if (model ==
"nodefo") {
80 deformation_model = std::make_unique<ElementModelRigid>();
81 }
else if (model ==
"scalesag") {
84 const auto& jc = j.
json.at(
"model_constant_pars");
85 jc.at(
"len_x").get_to(lenX);
86 jc.at(
"len_y").get_to(lenY);
87 jc.at(
"defo0_x").get_to(defo0[0]);
88 jc.at(
"defo0_y").get_to(defo0[1]);
89 jc.at(
"defo0_z").get_to(defo0[2]);
90 deformation_model = std::make_unique<ElementModelScaleSag>(lenX, lenY, defo0);
92 throw std::runtime_error(
"Unknown model: "+model);
96 std::unique_ptr<Element> el = std::make_unique<Element>(std::move(deformation_model));
97 el->setAsapId(j.
json.at(
"id_asap"));
100 std::map<std::string, double> correctionPars, nominalPars;
101 j.
json.at(
"pars_correction").get_to(correctionPars);
102 j.
json.at(
"pars_nominal").get_to(nominalPars);
103 el->setParametersFromMap(ParameterClass::CORRECTION, correctionPars);
104 el->setParametersFromMap(ParameterClass::NOMINAL, nominalPars);
113 std::string stationName;
114 j.
json.at(
"station_name").get_to(stationName);
115 if (stationName ==
"MMS") {
117 }
else if (stationName ==
"MML") {
120 throw std::runtime_error(
"StripCalculator: stationName not implemented: "+stationName);
134 j.
json.at(
"iboard").get_to(ret.
ipcb);
141 auto getPoint = [](
const nlohmann::json& j) {
142 double xpos, ypos, xpitch, ypitch;
143 j.at(
"pos").at(
"x").get_to(xpos);
144 j.at(
"pos").at(
"y").get_to(ypos);
145 j.at(
"pitchvec").at(
"x").get_to(xpitch);
146 j.at(
"pitchvec").at(
"y").get_to(ypitch);
160 if (j.
json.contains(
"strip_configuration") && j.
json.contains(
"identifier")) {
170 using json = nlohmann::json;
172 json::const_iterator it;
173 json::const_iterator end;
176 if (!j.
json.contains(
"identifier")) {
184 const std::string KEY =
"zdaughters";
187 std::list<tree_t> jtree;
188 jtree.push_back({j.
json.at(KEY).begin(), j.
json.at(KEY).end()});
189 while (!jtree.empty()) {
190 auto& it = jtree.back().it;
191 if (it != jtree.back().end) {
194 Element* daugref = mom->addDaughter(std::move(daughter));
195 if (it->contains(KEY)) {
196 jtree.push_back({it->at(KEY).begin(), it->at(KEY).end()});
Element: a node in a hierarchy of alignment frames.
Helper class saving all the needed information to compute strips for a particular PCB.
void collectStrip(quadrupletIdentifier_t quad_id, Element &element, json_t j)
std::vector< std::unique_ptr< Element > > m_rootElements
std::unique_ptr< Element > buildElement(json_t j) const
PcbElement::stripConfiguration_t getStripConfiguration(json_t j) const
Element::ParameterClass ParameterClass
position_t getPositionAlongStrip(ParameterClass iclass, stripIdentifier_t strip_id, double sx, double sy) const
quadrupletIdentifier_t getQuadrupletIdentifier(json_t j) const
strip_t getStrip(ParameterClass iclass, stripIdentifier_t strip_id) const
void parseJSON(const std::string &in)
void parseRootElement(json_t j)
std::unordered_map< pcbIdentifier_t, PcbElement > m_pcbMap
pcbIdentifier_t getPcbIdentifier(quadrupletIdentifier_t quad_id, json_t j) const
Eigen::Matrix< double, 3, 1 > Vector3D
quadrupletIdentifier_t quadruplet
Athena indices for a MM quadruplet:
Athena indices of a MM strip.
quadrupletIdentifier_t quadruplet
json_t(const nlohmann::json &j)
const nlohmann::json & json