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,
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());
87 geometry.
insert(it->first, dg);
104 unsigned int idxMeas = 0;
105 unsigned int idxQuan = 0;
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++) {
276 for (
auto &qcit : quantityClasses) {
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.;
294 ac.
val = values[
j] * 1E-3;
297 constraints.push_back(ac);
311 map<unsigned int, unsigned int> planesPerPot;
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);
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;
403 constraints.push_back(ac_X);
404 constraints.push_back(ac_Y);
410 for (
const auto &decUnitId : decUnitIds) {
420 sprintf(buf,
"RotZ: unit %u, Mean=0", decUnitId);
427 unsigned int senDecUnit = senId.
arm() * 100 + senId.
station() * 10;
431 if (senDecUnit != decUnitId)
435 const double weight = 1. / planesPerPot[senId.
rpId()];
442 constraints.push_back(ac);
457 map<unsigned int, vector<unsigned int>>
m;
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();
490 constraints.push_back(ac);
502 map<unsigned int, pair<vector<unsigned int>, vector<unsigned int>>>
m;
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 (
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) {
545 constraints.push_back(ac);
Detector ID class for TOTEM Si strip detectors.
const edm::EventSetup & c
void buildFixedDetectorsConstraints(std::vector< AlignmentConstraint > &) const
builds a set of fixed-detector constraints
A structure to hold relevant geometrical information about one detector/sensor.
void buildStandardConstraints(std::vector< AlignmentConstraint > &) const
builds the standard constraints
std::map< QuantityClass, std::map< DetIdDirIdxPair, unsigned int > > mapMeasurementIndeces
for each quantity class contains mapping (detector id, direction) –> measurement index ...
bool resolveShZ
whether to resolve detector shifts in z
void buildOneRotZPerPotConstraints(std::vector< AlignmentConstraint > &) const
adds constraints such that only 1 rot_z per RP is left
ParameterSet const & getParameterSet(ParameterSetID const &id)
AlignmentTask()
dummy constructor (not to be used)
void setDirection(unsigned int idx, double dx, double dy, double dz)
mapType::const_iterator beginSensor() const
begin iterator over sensors
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
void buildIndexMaps()
builds "mapMatrixIndeces" from "geometry"
signed int getMeasurementIndex(QuantityClass cl, unsigned int detId, unsigned int dirIdx) const
returns measurement index (if non-existent, returns -1)
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
Vector localToGlobal(const DetGeomDesc *, const Vector &) const
static std::string const input
edm::ParameterSet fixedDetectorsConstraints
fixed detectors constraints from config file
bool resolveRotZ
whether to resolve detector rotations around z
void buildEqualMeanUMeanVRotZConstraints(std::vector< AlignmentConstraint > &constraints) const
adds constraints such that only mean-U and mean-V RotZ are equal for each strip RP ...
detector shifts in first readout direction
AlignmentGeometry geometry
the geometry for this task
unsigned int quantitiesOfClass(QuantityClass) const
returns the number of quantities of the given class
unsigned int measurementsOfClass(QuantityClass) const
returns the number of quantities of the given class
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::string quantityClassTag(QuantityClass) const
returns a string tag for the given quantity class
bool oneRotZPerPot
whether to resolve only 1 rot_z per RP
The manager class for TOTEM RP geometry.
detector shifts in second readout direction
const std::map< unsigned int, DetGeometry > & getSensorMap() const
QuantityClass
quantity classes
double val
constraint value
std::map< unsigned int, TVectorD > coef
map: AlignmentAlgorithm::QuantityClass -> constraint coefficients
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)
ParameterSet const & getParameterSet(std::string const &) const
detector rotations around z
T getParameter(std::string const &) const
mapType::const_iterator endSensor() const
end iterator over sensors
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.
signed int getQuantityIndex(QuantityClass cl, unsigned int detId) const
returns measurement index (if non-existent, returns -1)
std::string name
label of the constraint
void insert(unsigned int id, const DetGeometry &g)
puts an element to the map
double z0
a characteristic z in mm
static constexpr float d1
edm::ParameterSet standardConstraints
settings of "standard" constraints from config file
tuple size
Write out results.