33 throw std::runtime_error(
"Wrong detection element Id");
36 std::string volPathName = geo.GetTopVolume()->GetName();
38 int nCh = detElemId / 100;
40 if (nCh <= 4 && geo.GetVolume(
"YOUT1")) {
41 volPathName +=
"/YOUT1_1/";
42 }
else if ((nCh == 5 || nCh == 6) && geo.GetVolume(
"DDIP")) {
43 volPathName +=
"/DDIP_1/";
44 }
else if (nCh >= 7 && geo.GetVolume(
"YOUT2")) {
45 volPathName +=
"/YOUT2_1/";
52 TGeoNavigator* navig = gGeoManager->GetCurrentNavigator();
54 if (!navig->cd(volPathName.c_str())) {
55 throw std::runtime_error(
"could not get to volPathName=" + volPathName);
64 rapidjson::IStreamWrapper isw(in);
66 rapidjson::Document d;
69 rapidjson::Value& alignables = d[
"alignables"];
70 assert(alignables.IsArray());
72 std::map<int, std::tuple<double, double, double>> angles;
73 std::map<int, std::tuple<double, double, double>> translations;
79 constexpr double deg2rad = 3.14159265358979323846 / 180.0;
81 for (
auto& al : alignables.GetArray()) {
82 auto itr = al.FindMember(
"deid");
83 if (itr != al.MemberEnd()) {
84 int deid = itr->value.GetInt();
85 auto t = al[
"transform"].GetObject();
88 deg2rad * t[
"pitch"].GetDouble(),
89 deg2rad * t[
"roll"].GetDouble()};
90 translations[deid] = {
99 throw std::runtime_error(
"Wrong detection element Id");
101 auto [yaw, pitch, roll] = angles.at(detElemId);
102 auto [tx, ty, tz] = translations.at(detElemId);
103 double tr[3] = {tx, ty, tz};
108 m.SetRotation(&rot[0]);
109 m.SetTranslation(tr);
116 std::array<double, 9> rot;
118 double sinpsi = std::sin(roll);
119 double cospsi = std::cos(roll);
120 double sinthe = std::sin(pitch);
121 double costhe = std::cos(pitch);
122 double sinphi = std::sin(yaw);
123 double cosphi = std::cos(yaw);
124 rot[0] = costhe * cosphi;
125 rot[1] = -costhe * sinphi;
127 rot[3] = sinpsi * sinthe * cosphi + cospsi * sinphi;
128 rot[4] = -sinpsi * sinthe * sinphi + cospsi * cosphi;
129 rot[5] = -costhe * sinpsi;
130 rot[6] = -cospsi * sinthe * cosphi + sinpsi * sinphi;
131 rot[7] = cospsi * sinthe * sinphi + sinpsi * cosphi;
132 rot[8] = costhe * cospsi;
138 double roll = std::atan2(-rot[5], rot[8]);
139 double pitch = std::asin(rot[2]);
140 double yaw = std::atan2(-rot[1], rot[0]);
141 return std::make_tuple(yaw,