24 : resolveShR(ps.getParameter<
bool>(
"resolveShR")),
25 resolveShZ(ps.getParameter<
bool>(
"resolveShZ")),
26 resolveRotZ(ps.getParameter<
bool>(
"resolveRotZ")),
28 oneRotZPerPot(ps.getParameter<
bool>(
"oneRotZPerPot")),
29 useEqualMeanUMeanVRotZConstraints(ps.getParameter<
bool>(
"useEqualMeanUMeanVRotZConstraints")),
31 fixedDetectorsConstraints(ps.
getParameterSet(
"fixedDetectorsConstraints")),
50 const vector<unsigned int> &excludedSensors,
57 for (
auto it =
input->beginSensor(); it !=
input->endSensor(); ++it) {
59 if (
find(excludedSensors.begin(), excludedSensors.end(), it->first) != excludedSensors.end())
64 const unsigned int rpDecId = 100 * detId.
arm() + 10 * detId.
station() + detId.
rp();
65 if (
find(rpDecIds.begin(), rpDecIds.end(), rpDecId) == rpDecIds.end())
77 unsigned int rpNum = stripDetId.
rp();
78 unsigned int plNum = stripDetId.
plane();
79 isU = (plNum % 2 != 0);
80 if (rpNum == 2 || rpNum == 3)
86 dg.setDirection(2, d2.x(), d2.y(), d2.z());
104 unsigned int idxMeas = 0;
105 unsigned int idxQuan = 0;
106 for (
const auto &git :
geometry.getSensorMap()) {
107 const unsigned int detId = git.first;
190 auto it = clit->second.find({detId, dirIdx});
191 if (it == clit->second.end())
204 auto it = clit->second.find(detId);
205 if (it == clit->second.end())
225 throw cms::Exception(
"PPS") <<
"Unknown quantity class " << qc <<
".";
235 return it->second.size();
245 return it->second.size();
256 vector<unsigned int> ids(classSettings.
getParameter<vector<unsigned int>>(
"ids"));
259 if (ids.size() !=
values.size())
260 throw cms::Exception(
"PPS") <<
"Different number of constraint ids and values for " <<
tag <<
".";
263 unsigned int size = ids.size();
272 for (
unsigned int j = 0;
j <
size;
j++) {
278 ac.
coef[qcit].Zero();
283 sprintf(
buf,
"%s: fixed plane %4u",
tag.c_str(), ids[
j]);
289 throw cms::Exception(
"AlignmentTask::BuildFixedDetectorsConstraints")
290 <<
"Quantity index for class " << quantityClass <<
" and id " << ids[
j] <<
" is " << qIndex;
293 ac.
coef[quantityClass][qIndex] = 1.;
311 map<unsigned int, unsigned int> planesPerPot;
312 for (
const auto &it :
geometry.getSensorMap()) {
314 planesPerPot[detId.
rpId()]++;
319 for (
const auto &decUnitId : decUnitIds) {
324 ac_X.
coef[qcit].Zero();
332 sprintf(
buf,
"ShR: unit %u, MeanX=0", decUnitId);
334 sprintf(
buf,
"ShR: unit %u, MeanY=0", decUnitId);
338 for (
const auto &git :
geometry.getSensorMap()) {
341 unsigned int senDecUnit = senId.
arm() * 100 + senId.
station() * 10;
345 if (senDecUnit != decUnitId)
353 <<
"Cannot get quantity index for class " <<
qcShR2 <<
" and sensor id " << git.first <<
".";
356 const double weight = 1. / planesPerPot[senId.
rpId()];
369 <<
"Cannot get quantity index for class " <<
qcShR1 <<
" and sensor id " << git.first <<
".";
374 <<
"Cannot get quantity index for class " <<
qcShR2 <<
" and sensor id " << git.first <<
".";
377 const double weight = 0.5 / planesPerPot[senId.
rpId()];
380 const double d1x = git.second.getDirectionData(1).dx;
381 const double d1y = git.second.getDirectionData(1).dy;
382 const double d2x = git.second.getDirectionData(2).dx;
383 const double d2y = git.second.getDirectionData(2).dy;
388 const double D = d1x * d2y - d1y * d2x;
389 const double coef_x_s1 = +d2y /
D;
390 const double coef_y_s1 = -d2x /
D;
391 const double coef_x_s2 = -d1y /
D;
392 const double coef_y_s2 = +d1x /
D;
410 for (
const auto &decUnitId : decUnitIds) {
420 sprintf(
buf,
"RotZ: unit %u, Mean=0", decUnitId);
424 for (
const auto &git :
geometry.getSensorMap()) {
427 unsigned int senDecUnit = senId.
arm() * 100 + senId.
station() * 10;
431 if (senDecUnit != decUnitId)
435 const double weight = 1. / planesPerPot[senId.
rpId()];
457 map<unsigned int, vector<unsigned int>>
m;
458 for (
const auto &
p :
geometry.getSensorMap()) {
461 unsigned int decRPId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
462 m[decRPId].push_back(
p.first);
466 for (
const auto &
p :
m) {
468 unsigned int prev_detId = 0;
469 for (
const auto &detId :
p.second) {
470 if (prev_detId != 0) {
474 sprintf(
buf,
"RotZ: RP %u, plane %u = plane %u",
p.first, prev_detId, detId);
481 ac.
coef[qcit].Zero();
502 map<unsigned int, pair<vector<unsigned int>, vector<unsigned int>>>
m;
503 for (
const auto &
p :
geometry.getSensorMap()) {
510 unsigned int decRPId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
513 m[decRPId].first.push_back(
p.first);
515 m[decRPId].second.push_back(
p.first);
519 for (
const auto &
p :
m) {
523 sprintf(
buf,
"RotZ: RP %u, MeanU = MeanV",
p.first);
530 ac.
coef[qcit].Zero();
533 for (
const string &
proj : {
"U",
"V"}) {
534 const auto &planes = (
proj ==
"U") ?
p.second.first :
p.second.second;
535 const double c = ((
proj ==
"U") ? -1. : +1.) / planes.size();
537 for (
const auto &plane : planes) {