50 const vector<unsigned int> &excludedSensors,
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()) {
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()) {
519 for (
const auto &
p :
m) {
523 sprintf(
buf,
"RotZ: RP %u, MeanU = MeanV",
p.first);
530 ac.
coef[qcit].Zero();
533 for (
auto &&
proj : {
"U",
"V"}) {
534 const auto &planes = (
proj ==
string(
"U")) ?
p.second.first :
p.second.second;
535 const double c = ((
proj ==
string(
"U")) ? -1. : +1.) / planes.size();
537 for (
const auto &plane : planes) {
Detector ID class for TOTEM Si strip detectors.
useEqualMeanUMeanVRotZConstraints
T getParameter(std::string const &) const
A structure to hold relevant geometrical information about one detector/sensor.
void buildEqualMeanUMeanVRotZConstraints(std::vector< AlignmentConstraint > &constraints) const
adds constraints such that only mean-U and mean-V RotZ are equal for each strip RP ...
std::map< QuantityClass, std::map< DetIdDirIdxPair, unsigned int > > mapMeasurementIndeces
for each quantity class contains mapping (detector id, direction) –> measurement index ...
std::string quantityClassTag(QuantityClass) const
returns a string tag for the given quantity class
bool resolveShZ
whether to resolve detector shifts in z
void buildStandardConstraints(std::vector< AlignmentConstraint > &) const
builds the standard constraints
fixedDetectorsConstraints
ParameterSet const & getParameterSet(std::string const &) const
AlignmentTask()
dummy constructor (not to be used)
void setDirection(unsigned int idx, double dx, double dy, double dz)
void buildOneRotZPerPotConstraints(std::vector< AlignmentConstraint > &) const
adds constraints such that only 1 rot_z per RP is left
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
signed int getMeasurementIndex(QuantityClass cl, unsigned int detId, unsigned int dirIdx) const
returns measurement index (if non-existent, returns -1)
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
void buildIndexMaps()
builds "mapMatrixIndeces" from "geometry"
DetGeomDesc::Translation Vector
static void buildGeometry(const std::vector< unsigned int > &rpDecIds, const std::vector< unsigned int > &excludedSensors, const CTPPSGeometry *, double z0, AlignmentGeometry &geometry)
builds the alignment geometry
static std::string const input
edm::ParameterSet fixedDetectorsConstraints
fixed detectors constraints from config file
bool resolveRotZ
whether to resolve detector rotations around z
detector shifts in first readout direction
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool oneRotZPerPot
whether to resolve only 1 rot_z per RP
The manager class for TOTEM RP geometry.
detector shifts in second readout direction
QuantityClass
quantity classes
double val
constraint value
std::map< unsigned int, TVectorD > coef
map: AlignmentAlgorithm::QuantityClass -> constraint coefficients
unsigned int measurementsOfClass(QuantityClass) const
returns the number of quantities of the given class
signed int getQuantityIndex(QuantityClass cl, unsigned int detId) const
returns measurement index (if non-existent, returns -1)
DecomposeProduct< arg, typename Div::arg > D
bool useEqualMeanUMeanVRotZConstraints
whether to apply the constraint mean U = mean V RotZ for strips ("standard" set of constraints only) ...
bool resolveShR
whether to resolve detector shifts in readout direction(s)
detector rotations around z
std::map< QuantityClass, std::map< unsigned int, unsigned int > > mapQuantityIndeces
for each quantity class contains mapping detector id –> quantity index
Base class for CTPPS detector IDs.
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::string name
label of the constraint
unsigned int quantitiesOfClass(QuantityClass) const
returns the number of quantities of the given class
static constexpr float d1
edm::ParameterSet standardConstraints
settings of "standard" constraints from config file
void buildFixedDetectorsConstraints(std::vector< AlignmentConstraint > &) const
builds a set of fixed-detector constraints