CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
AlignmentTask Class Reference

Represents an alignment task. More...

#include <AlignmentTask.h>

Classes

struct  DetIdDirIdxPair
 

Public Types

enum  QuantityClass { qcShR1, qcShR2, qcShZ, qcRotZ }
 quantity classes More...
 

Public Member Functions

 AlignmentTask ()
 dummy constructor (not to be used) More...
 
 AlignmentTask (const edm::ParameterSet &ps)
 normal constructor More...
 
void buildEqualMeanUMeanVRotZConstraints (std::vector< AlignmentConstraint > &constraints) const
 adds constraints such that only mean-U and mean-V RotZ are equal for each strip RP More...
 
void buildFixedDetectorsConstraints (std::vector< AlignmentConstraint > &) const
 builds a set of fixed-detector constraints More...
 
void buildIndexMaps ()
 builds "mapMatrixIndeces" from "geometry" More...
 
void buildOneRotZPerPotConstraints (std::vector< AlignmentConstraint > &) const
 adds constraints such that only 1 rot_z per RP is left More...
 
void buildStandardConstraints (std::vector< AlignmentConstraint > &) const
 builds the standard constraints More...
 
signed int getMeasurementIndex (QuantityClass cl, unsigned int detId, unsigned int dirIdx) const
 returns measurement index (if non-existent, returns -1) More...
 
signed int getQuantityIndex (QuantityClass cl, unsigned int detId) const
 returns measurement index (if non-existent, returns -1) More...
 
unsigned int measurementsOfClass (QuantityClass) const
 returns the number of quantities of the given class More...
 
unsigned int quantitiesOfClass (QuantityClass) const
 returns the number of quantities of the given class More...
 
std::string quantityClassTag (QuantityClass) const
 returns a string tag for the given quantity class More...
 

Static Public Member Functions

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 More...
 

Public Attributes

edm::ParameterSet fixedDetectorsConstraints
 fixed detectors constraints from config file More...
 
AlignmentGeometry geometry
 the geometry for this task More...
 
std::map< QuantityClass, std::map< DetIdDirIdxPair, unsigned int > > mapMeasurementIndeces
 for each quantity class contains mapping (detector id, direction) –> measurement index More...
 
std::map< QuantityClass, std::map< unsigned int, unsigned int > > mapQuantityIndeces
 for each quantity class contains mapping detector id –> quantity index More...
 
bool oneRotZPerPot
 whether to resolve only 1 rot_z per RP More...
 
std::vector< QuantityClassquantityClasses
 list of quantity classes to be optimized More...
 
bool resolveRotZ
 whether to resolve detector rotations around z More...
 
bool resolveShR
 whether to resolve detector shifts in readout direction(s) More...
 
bool resolveShZ
 whether to resolve detector shifts in z More...
 
edm::ParameterSet standardConstraints
 settings of "standard" constraints from config file More...
 
bool useEqualMeanUMeanVRotZConstraints
 whether to apply the constraint mean U = mean V RotZ for strips ("standard" set of constraints only) More...
 

Detailed Description

Represents an alignment task.

Definition at line 20 of file AlignmentTask.h.

Member Enumeration Documentation

◆ QuantityClass

quantity classes

Enumerator
qcShR1 

detector shifts in first readout direction

qcShR2 

detector shifts in second readout direction

qcShZ 

detector shifts in z

qcRotZ 

detector rotations around z

Definition at line 60 of file AlignmentTask.h.

60  {
61  qcShR1,
62  qcShR2,
63  qcShZ,
64  qcRotZ,
65  };
detector shifts in first readout direction
Definition: AlignmentTask.h:61
detector shifts in second readout direction
Definition: AlignmentTask.h:62
detector rotations around z
Definition: AlignmentTask.h:64
detector shifts in z
Definition: AlignmentTask.h:63

Constructor & Destructor Documentation

◆ AlignmentTask() [1/2]

AlignmentTask::AlignmentTask ( )
inline

dummy constructor (not to be used)

Definition at line 127 of file AlignmentTask.h.

127 {}

◆ AlignmentTask() [2/2]

AlignmentTask::AlignmentTask ( const edm::ParameterSet ps)

normal constructor

Definition at line 23 of file AlignmentTask.cc.

References qcRotZ, qcShR1, qcShR2, qcShZ, quantityClasses, resolveRotZ, resolveShR, and resolveShZ.

24  : resolveShR(ps.getParameter<bool>("resolveShR")),
25  resolveShZ(ps.getParameter<bool>("resolveShZ")),
26  resolveRotZ(ps.getParameter<bool>("resolveRotZ")),
27 
28  oneRotZPerPot(ps.getParameter<bool>("oneRotZPerPot")),
29  useEqualMeanUMeanVRotZConstraints(ps.getParameter<bool>("useEqualMeanUMeanVRotZConstraints")),
30 
31  fixedDetectorsConstraints(ps.getParameterSet("fixedDetectorsConstraints")),
32  standardConstraints(ps.getParameterSet("standardConstraints")) {
33  if (resolveShR) {
34  quantityClasses.push_back(qcShR1);
35  quantityClasses.push_back(qcShR2);
36  }
37 
38  if (resolveShZ) {
39  quantityClasses.push_back(qcShZ);
40  }
41 
42  if (resolveRotZ) {
43  quantityClasses.push_back(qcRotZ);
44  }
45 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool resolveShZ
whether to resolve detector shifts in z
Definition: AlignmentTask.h:28
ParameterSet const & getParameterSet(std::string const &) const
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
Definition: AlignmentTask.h:68
edm::ParameterSet fixedDetectorsConstraints
fixed detectors constraints from config file
Definition: AlignmentTask.h:40
bool resolveRotZ
whether to resolve detector rotations around z
Definition: AlignmentTask.h:31
detector shifts in first readout direction
Definition: AlignmentTask.h:61
bool oneRotZPerPot
whether to resolve only 1 rot_z per RP
Definition: AlignmentTask.h:34
detector shifts in second readout direction
Definition: AlignmentTask.h:62
bool useEqualMeanUMeanVRotZConstraints
whether to apply the constraint mean U = mean V RotZ for strips ("standard" set of constraints only) ...
Definition: AlignmentTask.h:37
bool resolveShR
whether to resolve detector shifts in readout direction(s)
Definition: AlignmentTask.h:25
detector rotations around z
Definition: AlignmentTask.h:64
detector shifts in z
Definition: AlignmentTask.h:63
edm::ParameterSet standardConstraints
settings of "standard" constraints from config file
Definition: AlignmentTask.h:43

Member Function Documentation

◆ buildEqualMeanUMeanVRotZConstraints()

void AlignmentTask::buildEqualMeanUMeanVRotZConstraints ( std::vector< AlignmentConstraint > &  constraints) const

adds constraints such that only mean-U and mean-V RotZ are equal for each strip RP

Definition at line 500 of file AlignmentTask.cc.

References CTPPSDetId::arm(), visDQMUpload::buf, HltBtagPostValidation_cff::c, AlignmentConstraint::coef, createBeamHaloJobs::constraints, protons_cff::decRPId, hcalRecHitTable_cff::detId, getQuantityIndex(), visualization-live-secondInstance_cfg::m, AlignmentConstraint::name, AlCaHLTBitMon_ParallelJobs::p, amptDefault_cfi::proj, qcRotZ, quantitiesOfClass(), quantityClasses, CTPPSDetId::rp(), CTPPSDetId::sdTrackingStrip, CTPPSDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, and AlignmentConstraint::val.

Referenced by buildStandardConstraints().

500  {
501  // build map strip rp id --> pair( vector of U planes, vector of V planes )
502  map<unsigned int, pair<vector<unsigned int>, vector<unsigned int>>> m;
503  for (const auto &p : geometry.getSensorMap()) {
504  CTPPSDetId detId(p.first);
505 
506  if (detId.subdetId() != CTPPSDetId::sdTrackingStrip)
507  continue;
508 
509  CTPPSDetId rpId = detId.rpId();
510  unsigned int decRPId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
511 
512  if (p.second.isU)
513  m[decRPId].first.push_back(p.first);
514  else
515  m[decRPId].second.push_back(p.first);
516  }
517 
518  // loop over RPs
519  for (const auto &p : m) {
521 
522  char buf[100];
523  sprintf(buf, "RotZ: RP %u, MeanU = MeanV", p.first);
524  ac.name = buf;
525 
526  ac.val = 0;
527 
528  for (auto &qcit : quantityClasses) {
529  ac.coef[qcit].ResizeTo(quantitiesOfClass(qcit));
530  ac.coef[qcit].Zero();
531  }
532 
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();
536 
537  for (const auto &plane : planes) {
538  signed int qIdx = getQuantityIndex(qcRotZ, plane);
539  ac.coef[qcRotZ][qIdx] = c;
540 
541  TotemRPDetId plId(plane);
542  }
543  }
544 
545  constraints.push_back(ac);
546  }
547 }
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
uint32_t arm() const
Definition: CTPPSDetId.h:57
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
Definition: AlignmentTask.h:68
An alignment constraint.
double val
constraint value
std::map< unsigned int, TVectorD > coef
map: AlignmentAlgorithm::QuantityClass -> constraint coefficients
uint32_t rp() const
Definition: CTPPSDetId.h:71
signed int getQuantityIndex(QuantityClass cl, unsigned int detId) const
returns measurement index (if non-existent, returns -1)
detector rotations around z
Definition: AlignmentTask.h:64
uint32_t station() const
Definition: CTPPSDetId.h:64
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
std::string name
label of the constraint
unsigned int quantitiesOfClass(QuantityClass) const
returns the number of quantities of the given class

◆ buildFixedDetectorsConstraints()

void AlignmentTask::buildFixedDetectorsConstraints ( std::vector< AlignmentConstraint > &  constraints) const

builds a set of fixed-detector constraints

Definition at line 250 of file AlignmentTask.cc.

References visDQMUpload::buf, buildOneRotZPerPotConstraints(), AlignmentConstraint::coef, createBeamHaloJobs::constraints, Exception, fixedDetectorsConstraints, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), getQuantityIndex(), dqmiolumiharvest::j, AlignmentConstraint::name, oneRotZPerPot, qcRotZ, quantitiesOfClass(), quantityClasses, quantityClassTag(), findQualityFiles::size, makeGlobalPositionRcd_cfg::tag, AlignmentConstraint::val, and contentValuesCheck::values.

Referenced by StraightTrackAlignment::buildConstraints().

250  {
251  for (auto &quantityClass : quantityClasses) {
252  // get input
253  const string &tag = quantityClassTag(quantityClass);
254 
255  const ParameterSet &classSettings = fixedDetectorsConstraints.getParameterSet(tag.c_str());
256  vector<unsigned int> ids(classSettings.getParameter<vector<unsigned int>>("ids"));
257  vector<double> values(classSettings.getParameter<vector<double>>("values"));
258 
259  if (ids.size() != values.size())
260  throw cms::Exception("PPS") << "Different number of constraint ids and values for " << tag << ".";
261 
262  // determine number of constraints
263  unsigned int size = ids.size();
264 
265  // just one basic constraint
266  if (oneRotZPerPot && quantityClass == qcRotZ) {
267  if (size > 1)
268  size = 1;
269  }
270 
271  // build constraints
272  for (unsigned int j = 0; j < size; j++) {
273  // prepare empty constraint
275 
276  for (auto &qcit : quantityClasses) {
277  ac.coef[qcit].ResizeTo(quantitiesOfClass(qcit));
278  ac.coef[qcit].Zero();
279  }
280 
281  // set constraint name
282  char buf[40];
283  sprintf(buf, "%s: fixed plane %4u", tag.c_str(), ids[j]);
284  ac.name = buf;
285 
286  // get quantity index
287  signed int qIndex = getQuantityIndex(quantityClass, ids[j]);
288  if (qIndex < 0)
289  throw cms::Exception("AlignmentTask::BuildFixedDetectorsConstraints")
290  << "Quantity index for class " << quantityClass << " and id " << ids[j] << " is " << qIndex;
291 
292  // set constraint coefficient and value
293  ac.coef[quantityClass][qIndex] = 1.;
294  ac.val = values[j] * 1E-3;
295 
296  // save constraint
297  constraints.push_back(ac);
298  }
299 
300  if (oneRotZPerPot && quantityClass == qcRotZ)
302  }
303 }
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string quantityClassTag(QuantityClass) const
returns a string tag for the given quantity class
ParameterSet const & getParameterSet(std::string const &) const
void buildOneRotZPerPotConstraints(std::vector< AlignmentConstraint > &) const
adds constraints such that only 1 rot_z per RP is left
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
Definition: AlignmentTask.h:68
edm::ParameterSet fixedDetectorsConstraints
fixed detectors constraints from config file
Definition: AlignmentTask.h:40
An alignment constraint.
bool oneRotZPerPot
whether to resolve only 1 rot_z per RP
Definition: AlignmentTask.h:34
double val
constraint value
std::map< unsigned int, TVectorD > coef
map: AlignmentAlgorithm::QuantityClass -> constraint coefficients
signed int getQuantityIndex(QuantityClass cl, unsigned int detId) const
returns measurement index (if non-existent, returns -1)
detector rotations around z
Definition: AlignmentTask.h:64
std::string name
label of the constraint
unsigned int quantitiesOfClass(QuantityClass) const
returns the number of quantities of the given class

◆ buildGeometry()

void AlignmentTask::buildGeometry ( const std::vector< unsigned int > &  rpDecIds,
const std::vector< unsigned int > &  excludedSensors,
const CTPPSGeometry input,
double  z0,
AlignmentGeometry geometry 
)
static

builds the alignment geometry

Definition at line 49 of file AlignmentTask.cc.

References HltBtagPostValidation_cff::c, d1, hcalRecHitTable_cff::detId, spr::find(), input, TotemRPDetId::plane(), CTPPSDetId::rp(), CTPPSDetId::sdTrackingStrip, DetGeometry::setDirection(), and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by StraightTrackAlignment::begin(), and PPSModifySingularModes::beginRun().

53  {
54  geometry.z0 = z0;
55 
56  // traverse full known geometry
57  for (auto it = input->beginSensor(); it != input->endSensor(); ++it) {
58  // skip excluded sensors
59  if (find(excludedSensors.begin(), excludedSensors.end(), it->first) != excludedSensors.end())
60  continue;
61 
62  // is RP selected?
63  const CTPPSDetId detId(it->first);
64  const unsigned int rpDecId = 100 * detId.arm() + 10 * detId.station() + detId.rp();
65  if (find(rpDecIds.begin(), rpDecIds.end(), rpDecId) == rpDecIds.end())
66  continue;
67 
68  // extract geometry data
69  CTPPSGeometry::Vector c = input->localToGlobal(detId, CTPPSGeometry::Vector(0., 0., 0.));
70  CTPPSGeometry::Vector d1 = input->localToGlobal(detId, CTPPSGeometry::Vector(1., 0., 0.)) - c;
71  CTPPSGeometry::Vector d2 = input->localToGlobal(detId, CTPPSGeometry::Vector(0., 1., 0.)) - c;
72 
73  // for strips: is it U plane?
74  bool isU = false;
75  if (detId.subdetId() == CTPPSDetId::sdTrackingStrip) {
76  TotemRPDetId stripDetId(it->first);
77  unsigned int rpNum = stripDetId.rp();
78  unsigned int plNum = stripDetId.plane();
79  isU = (plNum % 2 != 0);
80  if (rpNum == 2 || rpNum == 3)
81  isU = !isU;
82  }
83 
84  DetGeometry dg(c.z() - z0, c.x(), c.y(), isU);
85  dg.setDirection(1, d1.x(), d1.y(), d1.z());
86  dg.setDirection(2, d2.x(), d2.y(), d2.z());
87  geometry.insert(it->first, dg);
88  }
89 }
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
A structure to hold relevant geometrical information about one detector/sensor.
void setDirection(unsigned int idx, double dx, double dy, double dz)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
DetGeomDesc::Translation Vector
Definition: CTPPSGeometry.h:36
static std::string const input
Definition: EdmProvDump.cc:50
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
static constexpr float d1

◆ buildIndexMaps()

void AlignmentTask::buildIndexMaps ( )

builds "mapMatrixIndeces" from "geometry"

Definition at line 93 of file AlignmentTask.cc.

References hcalRecHitTable_cff::detId, mapMeasurementIndeces, mapQuantityIndeces, qcRotZ, qcShR1, qcShR2, qcShZ, quantityClasses, CTPPSDetId::sdTimingDiamond, CTPPSDetId::sdTrackingPixel, CTPPSDetId::sdTrackingStrip, and DetId::subdetId().

Referenced by StraightTrackAlignment::begin().

93  {
94  // remove old mapping
95  mapMeasurementIndeces.clear();
96  mapQuantityIndeces.clear();
97 
98  // loop over all classes
99  for (const auto &qcl : quantityClasses) {
100  // create entry for this class
102 
103  // loop over all sensors
104  unsigned int idxMeas = 0;
105  unsigned int idxQuan = 0;
106  for (const auto &git : geometry.getSensorMap()) {
107  const unsigned int detId = git.first;
108  const unsigned int subdetId = CTPPSDetId(git.first).subdetId();
109 
110  // update measurement map
111  if (qcl == qcShR1) {
112  if (subdetId == CTPPSDetId::sdTimingDiamond)
113  mapMeasurementIndeces[qcl][{detId, 1}] = idxMeas++;
114  if (subdetId == CTPPSDetId::sdTrackingPixel)
115  mapMeasurementIndeces[qcl][{detId, 1}] = idxMeas++;
116  }
117 
118  if (qcl == qcShR2) {
119  if (subdetId == CTPPSDetId::sdTrackingStrip)
120  mapMeasurementIndeces[qcl][{detId, 2}] = idxMeas++;
121  if (subdetId == CTPPSDetId::sdTrackingPixel)
122  mapMeasurementIndeces[qcl][{detId, 2}] = idxMeas++;
123  }
124 
125  if (qcl == qcShZ) {
126  if (subdetId == CTPPSDetId::sdTrackingStrip)
127  mapMeasurementIndeces[qcl][{detId, 2}] = idxMeas++;
128  if (subdetId == CTPPSDetId::sdTrackingPixel)
129  mapMeasurementIndeces[qcl][{detId, 1}] = idxMeas++;
130  if (subdetId == CTPPSDetId::sdTrackingPixel)
131  mapMeasurementIndeces[qcl][{detId, 2}] = idxMeas++;
132  if (subdetId == CTPPSDetId::sdTimingDiamond)
133  mapMeasurementIndeces[qcl][{detId, 1}] = idxMeas++;
134  }
135 
136  if (qcl == qcRotZ) {
137  if (subdetId == CTPPSDetId::sdTrackingStrip)
138  mapMeasurementIndeces[qcl][{detId, 2}] = idxMeas++;
139  if (subdetId == CTPPSDetId::sdTrackingPixel)
140  mapMeasurementIndeces[qcl][{detId, 1}] = idxMeas++;
141  if (subdetId == CTPPSDetId::sdTrackingPixel)
142  mapMeasurementIndeces[qcl][{detId, 2}] = idxMeas++;
143  if (subdetId == CTPPSDetId::sdTimingDiamond)
144  mapMeasurementIndeces[qcl][{detId, 1}] = idxMeas++;
145  }
146 
147  // update quantity map
148  if (qcl == qcShR1) {
149  if (subdetId == CTPPSDetId::sdTimingDiamond)
150  mapQuantityIndeces[qcl][detId] = idxQuan++;
151  if (subdetId == CTPPSDetId::sdTrackingPixel)
152  mapQuantityIndeces[qcl][detId] = idxQuan++;
153  }
154 
155  if (qcl == qcShR2) {
156  if (subdetId == CTPPSDetId::sdTrackingStrip)
157  mapQuantityIndeces[qcl][detId] = idxQuan++;
158  if (subdetId == CTPPSDetId::sdTrackingPixel)
159  mapQuantityIndeces[qcl][detId] = idxQuan++;
160  }
161 
162  if (qcl == qcShZ) {
163  if (subdetId == CTPPSDetId::sdTrackingStrip)
164  mapQuantityIndeces[qcl][detId] = idxQuan++;
165  if (subdetId == CTPPSDetId::sdTimingDiamond)
166  mapQuantityIndeces[qcl][detId] = idxQuan++;
167  if (subdetId == CTPPSDetId::sdTrackingPixel)
168  mapQuantityIndeces[qcl][detId] = idxQuan++;
169  }
170 
171  if (qcl == qcRotZ) {
172  if (subdetId == CTPPSDetId::sdTrackingStrip)
173  mapQuantityIndeces[qcl][detId] = idxQuan++;
174  if (subdetId == CTPPSDetId::sdTimingDiamond)
175  mapQuantityIndeces[qcl][detId] = idxQuan++;
176  if (subdetId == CTPPSDetId::sdTrackingPixel)
177  mapQuantityIndeces[qcl][detId] = idxQuan++;
178  }
179  }
180  }
181 }
std::map< QuantityClass, std::map< DetIdDirIdxPair, unsigned int > > mapMeasurementIndeces
for each quantity class contains mapping (detector id, direction) –> measurement index ...
Definition: AlignmentTask.h:90
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
Definition: AlignmentTask.h:68
detector shifts in first readout direction
Definition: AlignmentTask.h:61
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
detector shifts in second readout direction
Definition: AlignmentTask.h:62
detector rotations around z
Definition: AlignmentTask.h:64
std::map< QuantityClass, std::map< unsigned int, unsigned int > > mapQuantityIndeces
for each quantity class contains mapping detector id –> quantity index
Definition: AlignmentTask.h:93
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
detector shifts in z
Definition: AlignmentTask.h:63

◆ buildOneRotZPerPotConstraints()

void AlignmentTask::buildOneRotZPerPotConstraints ( std::vector< AlignmentConstraint > &  constraints) const

adds constraints such that only 1 rot_z per RP is left

Definition at line 455 of file AlignmentTask.cc.

References CTPPSDetId::arm(), visDQMUpload::buf, AlignmentConstraint::coef, createBeamHaloJobs::constraints, protons_cff::decRPId, hcalRecHitTable_cff::detId, getQuantityIndex(), visualization-live-secondInstance_cfg::m, AlignmentConstraint::name, AlCaHLTBitMon_ParallelJobs::p, qcRotZ, quantitiesOfClass(), quantityClasses, CTPPSDetId::rp(), CTPPSDetId::station(), and AlignmentConstraint::val.

Referenced by buildFixedDetectorsConstraints(), and buildStandardConstraints().

455  {
456  // build map rp id --> sensor ids
457  map<unsigned int, vector<unsigned int>> m;
458  for (const auto &p : geometry.getSensorMap()) {
459  CTPPSDetId detId(p.first);
460  CTPPSDetId rpId = detId.rpId();
461  unsigned int decRPId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
462  m[decRPId].push_back(p.first);
463  }
464 
465  // traverse all RPs
466  for (const auto &p : m) {
467  // build n_planes-1 constraints
468  unsigned int prev_detId = 0;
469  for (const auto &detId : p.second) {
470  if (prev_detId != 0) {
472 
473  char buf[100];
474  sprintf(buf, "RotZ: RP %u, plane %u = plane %u", p.first, prev_detId, detId);
475  ac.name = buf;
476 
477  ac.val = 0;
478 
479  for (auto &qcit : quantityClasses) {
480  ac.coef[qcit].ResizeTo(quantitiesOfClass(qcit));
481  ac.coef[qcit].Zero();
482  }
483 
484  signed int qIdx1 = getQuantityIndex(qcRotZ, prev_detId);
485  signed int qIdx2 = getQuantityIndex(qcRotZ, detId);
486 
487  ac.coef[qcRotZ][qIdx1] = +1.;
488  ac.coef[qcRotZ][qIdx2] = -1.;
489 
490  constraints.push_back(ac);
491  }
492 
493  prev_detId = detId;
494  }
495  }
496 }
uint32_t arm() const
Definition: CTPPSDetId.h:57
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
Definition: AlignmentTask.h:68
An alignment constraint.
double val
constraint value
std::map< unsigned int, TVectorD > coef
map: AlignmentAlgorithm::QuantityClass -> constraint coefficients
uint32_t rp() const
Definition: CTPPSDetId.h:71
signed int getQuantityIndex(QuantityClass cl, unsigned int detId) const
returns measurement index (if non-existent, returns -1)
detector rotations around z
Definition: AlignmentTask.h:64
uint32_t station() const
Definition: CTPPSDetId.h:64
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
std::string name
label of the constraint
unsigned int quantitiesOfClass(QuantityClass) const
returns the number of quantities of the given class

◆ buildStandardConstraints()

void AlignmentTask::buildStandardConstraints ( std::vector< AlignmentConstraint > &  constraints) const

builds the standard constraints

Definition at line 307 of file AlignmentTask.cc.

References CTPPSDetId::arm(), visDQMUpload::buf, buildEqualMeanUMeanVRotZConstraints(), buildOneRotZPerPotConstraints(), AlignmentConstraint::coef, createBeamHaloJobs::constraints, hcalRecHitTable_cff::detId, Exception, edm::ParameterSet::getParameter(), getQuantityIndex(), mps_fire::i, AlignmentConstraint::name, oneRotZPerPot, qcRotZ, qcShR1, qcShR2, quantitiesOfClass(), quantityClasses, resolveRotZ, resolveShR, CTPPSDetId::rp(), CTPPSDetId::rpId(), CTPPSDetId::sdTrackingPixel, CTPPSDetId::sdTrackingStrip, standardConstraints, CTPPSDetId::station(), DetId::subdetId(), useEqualMeanUMeanVRotZConstraints, AlignmentConstraint::val, and mps_merge::weight.

Referenced by StraightTrackAlignment::buildConstraints().

307  {
308  const vector<unsigned int> &decUnitIds = standardConstraints.getParameter<vector<unsigned int>>("units");
309 
310  // count planes in RPs
311  map<unsigned int, unsigned int> planesPerPot;
312  for (const auto &it : geometry.getSensorMap()) {
313  CTPPSDetId detId(it.first);
314  planesPerPot[detId.rpId()]++;
315  }
316 
317  // ShR constraints
318  if (resolveShR) {
319  for (const auto &decUnitId : decUnitIds) {
320  // prepare empty constraints
321  AlignmentConstraint ac_X;
322  for (auto &qcit : quantityClasses) {
323  ac_X.coef[qcit].ResizeTo(quantitiesOfClass(qcit));
324  ac_X.coef[qcit].Zero();
325  }
326  ac_X.val = 0;
327 
328  AlignmentConstraint ac_Y(ac_X);
329 
330  // set constraint names
331  char buf[50];
332  sprintf(buf, "ShR: unit %u, MeanX=0", decUnitId);
333  ac_X.name = buf;
334  sprintf(buf, "ShR: unit %u, MeanY=0", decUnitId);
335  ac_Y.name = buf;
336 
337  // traverse geometry
338  for (const auto &git : geometry.getSensorMap()) {
339  // stop is sensor not in the selected arm
340  CTPPSDetId senId(git.first);
341  unsigned int senDecUnit = senId.arm() * 100 + senId.station() * 10;
342  if (senId.rp() > 2)
343  senDecUnit += 1;
344 
345  if (senDecUnit != decUnitId)
346  continue;
347 
348  // fill constraint for strip sensors
349  if (senId.subdetId() == CTPPSDetId::sdTrackingStrip) {
350  signed int qIndex = getQuantityIndex(qcShR2, git.first);
351  if (qIndex < 0)
352  throw cms::Exception("AlignmentTask::BuildStandardConstraints")
353  << "Cannot get quantity index for class " << qcShR2 << " and sensor id " << git.first << ".";
354 
355  // determine weight
356  const double weight = 1. / planesPerPot[senId.rpId()];
357 
358  // set constraint coefficients
359  ac_X.coef[qcShR2][qIndex] = git.second.getDirectionData(2).dx * weight;
360  ac_Y.coef[qcShR2][qIndex] = git.second.getDirectionData(2).dy * weight;
361  }
362 
363  // fill constraint for pixel sensors
364  if (senId.subdetId() == CTPPSDetId::sdTrackingPixel) {
365  // get quantity indeces
366  const signed int qIndex1 = getQuantityIndex(qcShR1, git.first);
367  if (qIndex1 < 0)
368  throw cms::Exception("AlignmentTask::BuildStandardConstraints")
369  << "Cannot get quantity index for class " << qcShR1 << " and sensor id " << git.first << ".";
370 
371  const signed int qIndex2 = getQuantityIndex(qcShR2, git.first);
372  if (qIndex2 < 0)
373  throw cms::Exception("AlignmentTask::BuildStandardConstraints")
374  << "Cannot get quantity index for class " << qcShR2 << " and sensor id " << git.first << ".";
375 
376  // determine weight (two constraints per plane)
377  const double weight = 0.5 / planesPerPot[senId.rpId()];
378 
379  // get geometry
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;
384 
385  // calculate coefficients, by inversion of this matrix relation
386  // [ s1 ] = [ d1x d1y ] * [ de x ]
387  // [ s2 ] [ d2x d2y ] [ de y ]
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;
393 
394  // set constraint coefficients
395  ac_X.coef[qcShR1][qIndex1] = coef_x_s1 * weight;
396  ac_Y.coef[qcShR1][qIndex1] = coef_y_s1 * weight;
397  ac_X.coef[qcShR2][qIndex2] = coef_x_s2 * weight;
398  ac_Y.coef[qcShR2][qIndex2] = coef_y_s2 * weight;
399  }
400  }
401 
402  // add constraints
403  constraints.push_back(ac_X);
404  constraints.push_back(ac_Y);
405  }
406  }
407 
408  // RotZ constraints
409  if (resolveRotZ) {
410  for (const auto &decUnitId : decUnitIds) {
411  // prepare empty constraints
413  for (unsigned int i = 0; i < quantityClasses.size(); i++) {
415  ac.coef[quantityClasses[i]].Zero();
416  }
417  ac.val = 0;
418 
419  char buf[50];
420  sprintf(buf, "RotZ: unit %u, Mean=0", decUnitId);
421  ac.name = buf;
422 
423  // traverse geometry
424  for (const auto &git : geometry.getSensorMap()) {
425  // stop is sensor not in the selected arm
426  CTPPSDetId senId(git.first);
427  unsigned int senDecUnit = senId.arm() * 100 + senId.station() * 10;
428  if (senId.rp() > 2)
429  senDecUnit += 1;
430 
431  if (senDecUnit != decUnitId)
432  continue;
433 
434  // determine weight
435  const double weight = 1. / planesPerPot[senId.rpId()];
436 
437  // set coefficient
438  signed int qIndex = getQuantityIndex(qcRotZ, git.first);
439  ac.coef[qcRotZ][qIndex] = weight;
440  }
441 
442  constraints.push_back(ac);
443  }
444  }
445 
446  if (resolveRotZ && oneRotZPerPot)
448 
451 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void buildEqualMeanUMeanVRotZConstraints(std::vector< AlignmentConstraint > &constraints) const
adds constraints such that only mean-U and mean-V RotZ are equal for each strip RP ...
Definition: weight.py:1
void buildOneRotZPerPotConstraints(std::vector< AlignmentConstraint > &) const
adds constraints such that only 1 rot_z per RP is left
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
Definition: AlignmentTask.h:68
bool resolveRotZ
whether to resolve detector rotations around z
Definition: AlignmentTask.h:31
detector shifts in first readout direction
Definition: AlignmentTask.h:61
An alignment constraint.
bool oneRotZPerPot
whether to resolve only 1 rot_z per RP
Definition: AlignmentTask.h:34
detector shifts in second readout direction
Definition: AlignmentTask.h:62
double val
constraint value
std::map< unsigned int, TVectorD > coef
map: AlignmentAlgorithm::QuantityClass -> constraint coefficients
signed int getQuantityIndex(QuantityClass cl, unsigned int detId) const
returns measurement index (if non-existent, returns -1)
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
bool useEqualMeanUMeanVRotZConstraints
whether to apply the constraint mean U = mean V RotZ for strips ("standard" set of constraints only) ...
Definition: AlignmentTask.h:37
bool resolveShR
whether to resolve detector shifts in readout direction(s)
Definition: AlignmentTask.h:25
detector rotations around z
Definition: AlignmentTask.h:64
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
std::string name
label of the constraint
unsigned int quantitiesOfClass(QuantityClass) const
returns the number of quantities of the given class
edm::ParameterSet standardConstraints
settings of "standard" constraints from config file
Definition: AlignmentTask.h:43

◆ getMeasurementIndex()

signed int AlignmentTask::getMeasurementIndex ( QuantityClass  cl,
unsigned int  detId,
unsigned int  dirIdx 
) const

returns measurement index (if non-existent, returns -1)

Definition at line 185 of file AlignmentTask.cc.

References haddnano::cl, hcalRecHitTable_cff::detId, and mapMeasurementIndeces.

Referenced by JanAlignmentAlgorithm::feed().

185  {
186  auto clit = mapMeasurementIndeces.find(cl);
187  if (clit == mapMeasurementIndeces.end())
188  return -1;
189 
190  auto it = clit->second.find({detId, dirIdx});
191  if (it == clit->second.end())
192  return -1;
193 
194  return it->second;
195 }
std::map< QuantityClass, std::map< DetIdDirIdxPair, unsigned int > > mapMeasurementIndeces
for each quantity class contains mapping (detector id, direction) –> measurement index ...
Definition: AlignmentTask.h:90

◆ getQuantityIndex()

signed int AlignmentTask::getQuantityIndex ( QuantityClass  cl,
unsigned int  detId 
) const

returns measurement index (if non-existent, returns -1)

Definition at line 199 of file AlignmentTask.cc.

References haddnano::cl, hcalRecHitTable_cff::detId, and mapQuantityIndeces.

Referenced by buildEqualMeanUMeanVRotZConstraints(), buildFixedDetectorsConstraints(), buildOneRotZPerPotConstraints(), buildStandardConstraints(), JanAlignmentAlgorithm::feed(), IdealResult::solve(), and JanAlignmentAlgorithm::solve().

199  {
200  auto clit = mapQuantityIndeces.find(cl);
201  if (clit == mapQuantityIndeces.end())
202  return -1;
203 
204  auto it = clit->second.find(detId);
205  if (it == clit->second.end())
206  return -1;
207 
208  return it->second;
209 }
std::map< QuantityClass, std::map< unsigned int, unsigned int > > mapQuantityIndeces
for each quantity class contains mapping detector id –> quantity index
Definition: AlignmentTask.h:93

◆ measurementsOfClass()

unsigned int AlignmentTask::measurementsOfClass ( QuantityClass  qc) const

returns the number of quantities of the given class

Definition at line 230 of file AlignmentTask.cc.

References mapMeasurementIndeces.

230  {
231  auto it = mapMeasurementIndeces.find(qc);
232  if (it == mapMeasurementIndeces.end())
233  return 0;
234  else
235  return it->second.size();
236 }
std::map< QuantityClass, std::map< DetIdDirIdxPair, unsigned int > > mapMeasurementIndeces
for each quantity class contains mapping (detector id, direction) –> measurement index ...
Definition: AlignmentTask.h:90

◆ quantitiesOfClass()

unsigned int AlignmentTask::quantitiesOfClass ( QuantityClass  qc) const

returns the number of quantities of the given class

Definition at line 240 of file AlignmentTask.cc.

References mapQuantityIndeces.

Referenced by JanAlignmentAlgorithm::begin(), buildEqualMeanUMeanVRotZConstraints(), buildFixedDetectorsConstraints(), buildOneRotZPerPotConstraints(), buildStandardConstraints(), and IdealResult::solve().

240  {
241  auto it = mapQuantityIndeces.find(qc);
242  if (it == mapQuantityIndeces.end())
243  return 0;
244  else
245  return it->second.size();
246 }
std::map< QuantityClass, std::map< unsigned int, unsigned int > > mapQuantityIndeces
for each quantity class contains mapping detector id –> quantity index
Definition: AlignmentTask.h:93

◆ quantityClassTag()

string AlignmentTask::quantityClassTag ( QuantityClass  qc) const

returns a string tag for the given quantity class

Definition at line 213 of file AlignmentTask.cc.

References Exception, qcRotZ, qcShR1, qcShR2, and qcShZ.

Referenced by JanAlignmentAlgorithm::begin(), buildFixedDetectorsConstraints(), and StraightTrackAlignment::printQuantitiesLine().

213  {
214  switch (qc) {
215  case qcShR1:
216  return "ShR1";
217  case qcShR2:
218  return "ShR2";
219  case qcShZ:
220  return "ShZ";
221  case qcRotZ:
222  return "RotZ";
223  }
224 
225  throw cms::Exception("PPS") << "Unknown quantity class " << qc << ".";
226 }
detector shifts in first readout direction
Definition: AlignmentTask.h:61
detector shifts in second readout direction
Definition: AlignmentTask.h:62
detector rotations around z
Definition: AlignmentTask.h:64
detector shifts in z
Definition: AlignmentTask.h:63

Member Data Documentation

◆ fixedDetectorsConstraints

edm::ParameterSet AlignmentTask::fixedDetectorsConstraints

fixed detectors constraints from config file

Definition at line 40 of file AlignmentTask.h.

Referenced by buildFixedDetectorsConstraints().

◆ geometry

AlignmentGeometry AlignmentTask::geometry

◆ mapMeasurementIndeces

std::map<QuantityClass, std::map<DetIdDirIdxPair, unsigned int> > AlignmentTask::mapMeasurementIndeces

for each quantity class contains mapping (detector id, direction) –> measurement index

Definition at line 90 of file AlignmentTask.h.

Referenced by buildIndexMaps(), getMeasurementIndex(), and measurementsOfClass().

◆ mapQuantityIndeces

std::map<QuantityClass, std::map<unsigned int, unsigned int> > AlignmentTask::mapQuantityIndeces

for each quantity class contains mapping detector id –> quantity index

Definition at line 93 of file AlignmentTask.h.

Referenced by buildIndexMaps(), getQuantityIndex(), and quantitiesOfClass().

◆ oneRotZPerPot

bool AlignmentTask::oneRotZPerPot

whether to resolve only 1 rot_z per RP

Definition at line 34 of file AlignmentTask.h.

Referenced by buildFixedDetectorsConstraints(), and buildStandardConstraints().

◆ quantityClasses

std::vector<QuantityClass> AlignmentTask::quantityClasses

◆ resolveRotZ

bool AlignmentTask::resolveRotZ

whether to resolve detector rotations around z

Definition at line 31 of file AlignmentTask.h.

Referenced by AlignmentTask(), buildStandardConstraints(), and IdealResult::solve().

◆ resolveShR

bool AlignmentTask::resolveShR

whether to resolve detector shifts in readout direction(s)

Definition at line 25 of file AlignmentTask.h.

Referenced by AlignmentTask(), buildStandardConstraints(), and IdealResult::solve().

◆ resolveShZ

bool AlignmentTask::resolveShZ

whether to resolve detector shifts in z

Definition at line 28 of file AlignmentTask.h.

Referenced by AlignmentTask().

◆ standardConstraints

edm::ParameterSet AlignmentTask::standardConstraints

settings of "standard" constraints from config file

Definition at line 43 of file AlignmentTask.h.

Referenced by buildStandardConstraints().

◆ useEqualMeanUMeanVRotZConstraints

bool AlignmentTask::useEqualMeanUMeanVRotZConstraints

whether to apply the constraint mean U = mean V RotZ for strips ("standard" set of constraints only)

Definition at line 37 of file AlignmentTask.h.

Referenced by buildStandardConstraints().