11 #include <alignment/Hierarchy.h>
13 #include <alignment/GlobalLabel.h>
15 #include <boost/crc.hpp>
29 auto parent = parent_childs.first;
30 auto childs = parent_childs.second;
40 boost::crc_32_type crc32;
43 for (
unsigned int iCon = 0; iCon < parentLabels.size(); iCon++) {
44 auto constraint = Constraint();
50 if (parentLabels[iCon] == 0)
continue;
52 for (
unsigned int j = 0; j < childs.size(); j++) {
53 auto child = childs[j];
56 for (
unsigned int iPar = 0; iPar < childLabels.size(); iPar++) {
58 if (fabs(coefficient) > 1.0e-14) {
59 auto childLabel = childLabels[iPar];
60 constraint.push_back(std::make_pair(childLabel, coefficient));
66 crc32.process_bytes(&childLabel,
sizeof(childLabel));
72 constraints.insert(std::make_pair(crc32.checksum(), constraint));
79 Belle2::alignment::DetectorLevelElement child)
83 if (loc2glo.first == std::make_pair((
unsigned short)0, (
unsigned short)0))
84 return std::make_pair(std::vector<int>(), TMatrixD());
87 TMatrixD glo2loc(loc2glo.second.Invert());
88 TMatrixD drdparent = matrixChain * glo2loc;
91 GlobalDerivativeSet retVal = std::make_pair(
getElementLabels(loc2glo.first), drdparent);
98 Belle2::alignment::GlobalDerivativeSet additional)
100 if (additional.first.empty())
105 TMatrixD allDerivatives(
main.second.GetNrows(),
main.second.GetNcols() + additional.second.GetNcols());
106 allDerivatives.Zero();
107 allDerivatives.SetSub(0, 0,
main.second);
108 allDerivatives.SetSub(0,
main.second.GetNcols(), additional.second);
111 main.first.insert(
main.first.end(), additional.first.begin(), additional.first.end());
113 main.second.ResizeTo(allDerivatives);
114 main.second = allDerivatives;
121 std::cout <<
"Child : " << entry.first.second << std::endl;
122 std::cout <<
"Mother :" << entry.second.first.second << std::endl;
123 entry.second.second.Print();
128 Belle2::alignment::DetectorLevelElement child)
132 return std::make_pair(std::make_pair(0, 0), TMatrixD());
134 return entry->second;
141 std::vector<int> labels;
143 label.construct(element.first, element.second, 0);
145 labels.push_back(label.setParameterId(20));
154 TMatrixD derGlobal(2, 1);
163 localForce.setPosMom(sop->getPos(), F_dir);
164 B2Vector3D lorentzLocal(localForce.getState()[3], localForce.getState()[4], 0);
166 derGlobal(0, 0) = lorentzLocal(0);
167 derGlobal(1, 0) = lorentzLocal(1);
176 std::vector<int> labels;
178 label.construct(element.first, element.second, 0);
180 labels.push_back(label.setParameterId(1));
181 labels.push_back(label.setParameterId(2));
182 labels.push_back(label.setParameterId(3));
183 labels.push_back(label.setParameterId(4));
184 labels.push_back(label.setParameterId(5));
185 labels.push_back(label.setParameterId(6));
207 TMatrixD derGlobal(2, 6);
210 double uSlope = sop->getState()[1];
212 double vSlope = sop->getState()[2];
214 double uPos = sop->getState()[3];
216 double vPos = sop->getState()[4];
220 derGlobal(0, 0) = 1.0;
221 derGlobal(0, 1) = 0.0;
222 derGlobal(0, 2) = - uSlope;
223 derGlobal(0, 3) = vPos * uSlope;
224 derGlobal(0, 4) = -uPos * uSlope;
225 derGlobal(0, 5) = vPos;
227 derGlobal(1, 0) = 0.0;
228 derGlobal(1, 1) = 1.0;
229 derGlobal(1, 2) = - vSlope;
230 derGlobal(1, 3) = vPos * vSlope;
231 derGlobal(1, 4) = -uPos * vSlope;
232 derGlobal(1, 5) = -uPos;
239 TMatrixD rotationT(3, 3);
240 TMatrixD offset(3, 3);
241 for (
int i = 0; i < 3; i++) {
242 for (
int j = 0; j < 3; j++) {
243 rotationT(i, j) = g4transform.getRotation()(i, j);
247 double xDet = g4transform.getTranslation()(0);
248 double yDet = g4transform.getTranslation()(1);
249 double zDet = g4transform.getTranslation()(2);
251 offset(0, 1) = - zDet;
254 offset(1, 2) = - xDet;
255 offset(2, 0) = - yDet;
258 TMatrixD loc2glo(6, 6);
260 loc2glo.SetSub(0, 0, rotationT);
261 loc2glo.SetSub(0, 3, -1. * offset * rotationT);
262 loc2glo.SetSub(3, 3, rotationT);
269 TMatrixD rotationT(3, 3);
270 TMatrixD offset(3, 3);
271 for (
int i = 0; i < 3; i++) {
272 for (
int j = 0; j < 3; j++) {
273 rotationT(i, j) = tgeo.GetRotationMatrix()[i * 3 + j];
277 double xDet = tgeo.GetTranslation()[0];
278 double yDet = tgeo.GetTranslation()[1];
279 double zDet = tgeo.GetTranslation()[2];
281 offset(0, 1) = - zDet;
284 offset(1, 2) = - xDet;
285 offset(2, 0) = - yDet;
288 TMatrixD loc2glo(6, 6);
290 loc2glo.SetSub(0, 0, rotationT);
291 loc2glo.SetSub(0, 3, -1. * offset * rotationT);
292 loc2glo.SetSub(3, 3, rotationT);