CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
IdealResult Class Reference

Calculates the ideal result of the StraightTrackAlignment. More...

#include <IdealResult.h>

Inheritance diagram for IdealResult:
AlignmentAlgorithm

Public Member Functions

void analyze () override
 analyzes the data collected More...
 
void begin (const CTPPSGeometry *geometryReal, const CTPPSGeometry *geometryMisaligned) override
 prepare for processing More...
 
void end () override
 cleans up after processing More...
 
void feed (const HitCollection &, const LocalTrackFit &) override
 process one track More...
 
std::string getName () override
 
bool hasErrorEstimate () override
 returns whether this algorithm is capable of estimating result uncertainties More...
 
 IdealResult ()
 dummy constructor (not to be used) More...
 
 IdealResult (const edm::ParameterSet &ps, AlignmentTask *_t)
 normal constructor More...
 
void saveDiagnostics (TDirectory *) override
 saves diagnostic histograms/plots More...
 
unsigned int solve (const std::vector< AlignmentConstraint > &, std::map< unsigned int, AlignmentResult > &result, TDirectory *dir) override
 
 ~IdealResult () override
 
- Public Member Functions inherited from AlignmentAlgorithm
 AlignmentAlgorithm ()
 dummy constructor (not to be used) More...
 
 AlignmentAlgorithm (const edm::ParameterSet &ps, AlignmentTask *_t)
 normal constructor More...
 
virtual ~AlignmentAlgorithm ()
 

Protected Attributes

edm::ESHandle< CTPPSGeometrygMisaligned
 
edm::ESHandle< CTPPSGeometrygReal
 
- Protected Attributes inherited from AlignmentAlgorithm
double singularLimit
 eigenvalues in (-singularLimit, singularLimit) are treated as singular More...
 
AlignmentTasktask
 the tasked to be completed More...
 
unsigned int verbosity
 

Detailed Description

Calculates the ideal result of the StraightTrackAlignment.

Definition at line 24 of file IdealResult.h.

Constructor & Destructor Documentation

◆ IdealResult() [1/2]

IdealResult::IdealResult ( )
inline

dummy constructor (not to be used)

Definition at line 30 of file IdealResult.h.

30 {}

◆ IdealResult() [2/2]

IdealResult::IdealResult ( const edm::ParameterSet ps,
AlignmentTask _t 
)

normal constructor

Definition at line 20 of file IdealResult.cc.

20 : AlignmentAlgorithm(gps, _t) {}

◆ ~IdealResult()

IdealResult::~IdealResult ( )
inlineoverride

Definition at line 35 of file IdealResult.h.

35 {}

Member Function Documentation

◆ analyze()

void IdealResult::analyze ( )
inlineoverridevirtual

analyzes the data collected

Implements AlignmentAlgorithm.

Definition at line 47 of file IdealResult.h.

47 {}

◆ begin()

void IdealResult::begin ( const CTPPSGeometry geometryReal,
const CTPPSGeometry geometryMisaligned 
)
overridevirtual

prepare for processing

Implements AlignmentAlgorithm.

Definition at line 24 of file IdealResult.cc.

24  {
25  gReal = geometryReal;
26  gMisaligned = geometryMisaligned;
27 }

References gMisaligned, and gReal.

◆ end()

void IdealResult::end ( )
inlineoverridevirtual

cleans up after processing

Implements AlignmentAlgorithm.

Definition at line 53 of file IdealResult.h.

53 {}

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

◆ feed()

void IdealResult::feed ( const HitCollection ,
const LocalTrackFit  
)
inlineoverridevirtual

process one track

Implements AlignmentAlgorithm.

Definition at line 43 of file IdealResult.h.

43 {}

Referenced by Page1Parser.Page1Parser::_Parse().

◆ getName()

std::string IdealResult::getName ( )
inlineoverridevirtual

Reimplemented from AlignmentAlgorithm.

Definition at line 37 of file IdealResult.h.

37 { return "Ideal"; }

Referenced by plotting.Plot::draw().

◆ hasErrorEstimate()

bool IdealResult::hasErrorEstimate ( )
inlineoverridevirtual

returns whether this algorithm is capable of estimating result uncertainties

Implements AlignmentAlgorithm.

Definition at line 39 of file IdealResult.h.

39 { return false; }

◆ saveDiagnostics()

void IdealResult::saveDiagnostics ( TDirectory *  )
inlineoverridevirtual

saves diagnostic histograms/plots

Implements AlignmentAlgorithm.

Definition at line 45 of file IdealResult.h.

45 {}

◆ solve()

unsigned int IdealResult::solve ( const std::vector< AlignmentConstraint > &  ,
std::map< unsigned int, AlignmentResult > &  results,
TDirectory *  dir 
)
overridevirtual

solves the alignment problem with the given constraints

Parameters
dira directory (in StraightTrackAlignment::taskDataFileName) where intermediate results can be stored

Implements AlignmentAlgorithm.

Definition at line 30 of file IdealResult.cc.

32  {
33  /*
34  STRATEGY:
35 
36  1) Determine true misalignment as misalign_geometry - real_geometry.
37 
38  2) Represent the true misalignment as the "chi" vector (cf. Jan algorithm), denoted chi_tr.
39 
40  3) Find the expected result of track-based alignment, subject to the given constraints. Formally this corresponds to finding
41  chi_exp = chi_tr + I * Lambda
42  where the I matrix contains the "inaccessible alignment modes" as columns and Lambda is a vector of parameters. The constraints are given by
43  C^T * chi_exp = V
44  Since the problem may be generally overconstrained, it is better to formulate it as search for Lambda which minimises
45  |C^ * chi_exp - V|^2
46  This gives
47  Lambda = (A^T * A)^-1 * A^T * b, A = C^T * I, b = V - C^T * chi_tr
48  */
49 
50  results.clear();
51 
52  // determine dimension and offsets
53  unsigned int dim = 0;
54  vector<unsigned int> offsets;
55  map<unsigned int, unsigned int> offset_map;
56  for (unsigned int qci = 0; qci < task->quantityClasses.size(); qci++) {
57  offsets.push_back(dim);
58  offset_map[task->quantityClasses[qci]] = dim;
60  }
61 
62  // collect true misalignments
63  TVectorD chi_tr(dim);
64 
65  for (const auto &dit : task->geometry.getSensorMap()) {
66  unsigned int detId = dit.first;
67 
68  const DetGeomDesc *real = gReal->sensor(detId);
69  const DetGeomDesc *misal = gMisaligned->sensor(detId);
70 
71  // extract shift
72  const auto shift = misal->translation() - real->translation();
73 
74  // extract rotation around z
75  const auto rotation = misal->rotation() * real->rotation().Inverse();
76 
77  double r_xx, r_xy, r_xz;
78  double r_yx, r_yy, r_yz;
79  double r_zx, r_zy, r_zz;
80  rotation.GetComponents(r_xx, r_xy, r_xz, r_yx, r_yy, r_yz, r_zx, r_zy, r_zz);
81 
82  if (std::abs(r_zz - 1.) > 1E-5)
83  throw cms::Exception("PPS") << "IdealResult::Solve: only rotations about z are supported.";
84 
85  double rot_z = atan2(r_yx, r_xx);
86 
87  const auto &geom = task->geometry.get(detId);
88 
89  for (unsigned int qci = 0; qci < task->quantityClasses.size(); ++qci) {
90  const auto &qc = task->quantityClasses[qci];
91  signed int idx = task->getQuantityIndex(qc, detId);
92  if (idx < 0)
93  continue;
94 
95  double v = 0.;
96 
97  if (qc == AlignmentTask::qcShR1) {
98  const auto &d = geom.getDirectionData(1);
99  v = shift.x() * d.dx + shift.y() * d.dy + shift.z() * d.dz;
100  }
101 
102  if (qc == AlignmentTask::qcShR2) {
103  const auto &d = geom.getDirectionData(2);
104  v = shift.x() * d.dx + shift.y() * d.dy + shift.z() * d.dz;
105  }
106 
107  if (qc == AlignmentTask::qcRotZ)
108  v = rot_z;
109 
110  chi_tr(offsets[qci] + idx) = v;
111  }
112  }
113 
114  // build list of "inaccessible" modes
115  vector<TVectorD> inaccessibleModes;
116 
117  if (task->resolveShR) {
118  TVectorD fm_ShX_gl(dim);
119  fm_ShX_gl.Zero();
120  TVectorD fm_ShX_lp(dim);
121  fm_ShX_lp.Zero();
122  TVectorD fm_ShY_gl(dim);
123  fm_ShY_gl.Zero();
124  TVectorD fm_ShY_lp(dim);
125  fm_ShY_lp.Zero();
126 
127  for (const auto &sp : task->geometry.getSensorMap()) {
128  CTPPSDetId senId(sp.first);
129  const auto &geom = sp.second;
130 
131  if (senId.subdetId() == CTPPSDetId::sdTrackingStrip) {
132  signed int qIndex = task->getQuantityIndex(AlignmentTask::qcShR2, senId);
133 
134  const double d2x = geom.getDirectionData(2).dx;
135  const double d2y = geom.getDirectionData(2).dy;
136 
137  const auto &offset2 = offset_map[AlignmentTask::qcShR2];
138  fm_ShX_gl(offset2 + qIndex) = d2x;
139  fm_ShX_lp(offset2 + qIndex) = d2x * geom.z;
140  fm_ShY_gl(offset2 + qIndex) = d2y;
141  fm_ShY_lp(offset2 + qIndex) = d2y * geom.z;
142  }
143 
144  if (senId.subdetId() == CTPPSDetId::sdTrackingPixel) {
145  const signed int qIndex1 = task->getQuantityIndex(AlignmentTask::qcShR1, senId);
146  const signed int qIndex2 = task->getQuantityIndex(AlignmentTask::qcShR2, senId);
147 
148  const double d1x = geom.getDirectionData(1).dx;
149  const double d1y = geom.getDirectionData(1).dy;
150  const double d2x = geom.getDirectionData(2).dx;
151  const double d2y = geom.getDirectionData(2).dy;
152 
153  const auto &offset1 = offset_map[AlignmentTask::qcShR1];
154  fm_ShX_gl(offset1 + qIndex1) = d1x;
155  fm_ShX_lp(offset1 + qIndex1) = d1x * geom.z;
156  fm_ShY_gl(offset1 + qIndex1) = d1y;
157  fm_ShY_lp(offset1 + qIndex1) = d1y * geom.z;
158 
159  const auto &offset2 = offset_map[AlignmentTask::qcShR2];
160  fm_ShX_gl(offset2 + qIndex2) = d2x;
161  fm_ShX_lp(offset2 + qIndex2) = d2x * geom.z;
162  fm_ShY_gl(offset2 + qIndex2) = d2y;
163  fm_ShY_lp(offset2 + qIndex2) = d2y * geom.z;
164  }
165  }
166 
167  inaccessibleModes.push_back(fm_ShX_gl);
168  inaccessibleModes.push_back(fm_ShX_lp);
169  inaccessibleModes.push_back(fm_ShY_gl);
170  inaccessibleModes.push_back(fm_ShY_lp);
171  }
172 
173  if (task->resolveRotZ) {
174  TVectorD fm_RotZ_gl(dim);
175  fm_RotZ_gl.Zero();
176  TVectorD fm_RotZ_lp(dim);
177  fm_RotZ_lp.Zero();
178 
179  for (const auto &sp : task->geometry.getSensorMap()) {
180  CTPPSDetId senId(sp.first);
181  const auto &geom = sp.second;
182 
183  for (int m = 0; m < 2; ++m) {
184  double rho = 0.;
185  TVectorD *fmp = nullptr;
186  if (m == 0) {
187  rho = 1.;
188  fmp = &fm_RotZ_gl;
189  }
190  if (m == 1) {
191  rho = geom.z;
192  fmp = &fm_RotZ_lp;
193  }
194  TVectorD &fm = *fmp;
195 
196  const signed int qIndex = task->getQuantityIndex(AlignmentTask::qcRotZ, senId);
197  const auto &offset = offset_map[AlignmentTask::qcRotZ];
198  fm(offset + qIndex) = rho;
199 
200  const double as_x = -rho * geom.sy;
201  const double as_y = +rho * geom.sx;
202 
203  if (senId.subdetId() == CTPPSDetId::sdTrackingStrip) {
204  const double d2x = geom.getDirectionData(2).dx;
205  const double d2y = geom.getDirectionData(2).dy;
206 
207  const signed int qIndex2 = task->getQuantityIndex(AlignmentTask::qcShR2, senId);
208  const auto &offset2 = offset_map[AlignmentTask::qcShR2];
209  fm(offset2 + qIndex2) = d2x * as_x + d2y * as_y;
210  }
211 
212  if (senId.subdetId() == CTPPSDetId::sdTrackingPixel) {
213  const double d1x = geom.getDirectionData(1).dx;
214  const double d1y = geom.getDirectionData(1).dy;
215  const double d2x = geom.getDirectionData(2).dx;
216  const double d2y = geom.getDirectionData(2).dy;
217 
218  const signed int qIndex1 = task->getQuantityIndex(AlignmentTask::qcShR1, senId);
219  const auto &offset1 = offset_map[AlignmentTask::qcShR1];
220  fm(offset1 + qIndex1) = d1x * as_x + d1y * as_y;
221 
222  const signed int qIndex2 = task->getQuantityIndex(AlignmentTask::qcShR2, senId);
223  const auto &offset2 = offset_map[AlignmentTask::qcShR2];
224  fm(offset2 + qIndex2) = d2x * as_x + d2y * as_y;
225  }
226  }
227  }
228 
229  inaccessibleModes.push_back(fm_RotZ_gl);
230  inaccessibleModes.push_back(fm_RotZ_lp);
231  }
232 
233  // build matrices and vectors
234  TMatrixD C(dim, constraints.size());
235  TVectorD V(constraints.size());
236  for (unsigned int i = 0; i < constraints.size(); i++) {
237  V(i) = constraints[i].val;
238 
239  unsigned int offset = 0;
240  for (auto &quantityClass : task->quantityClasses) {
241  const TVectorD &cv = constraints[i].coef.find(quantityClass)->second;
242  for (int k = 0; k < cv.GetNrows(); k++) {
243  C[offset][i] = cv[k];
244  offset++;
245  }
246  }
247  }
248 
249  TMatrixD I(dim, inaccessibleModes.size());
250  for (unsigned int i = 0; i < inaccessibleModes.size(); ++i) {
251  for (int j = 0; j < inaccessibleModes[i].GetNrows(); ++j)
252  I(j, i) = inaccessibleModes[i](j);
253  }
254 
255  // determine expected track-based alignment result
256  TMatrixD CT(TMatrixD::kTransposed, C);
257  TMatrixD CTI(CT * I);
258 
259  const TMatrixD &A = CTI;
260  TMatrixD AT(TMatrixD::kTransposed, A);
261  TMatrixD ATA(AT * A);
262  TMatrixD ATA_inv(TMatrixD::kInverted, ATA);
263 
264  TVectorD b = V - CT * chi_tr;
265 
266  TVectorD La(ATA_inv * AT * b);
267 
268  TVectorD chi_exp(chi_tr + I * La);
269 
270  // save result
271  for (const auto &dit : task->geometry.getSensorMap()) {
273 
274  for (unsigned int qci = 0; qci < task->quantityClasses.size(); ++qci) {
275  const auto &qc = task->quantityClasses[qci];
276  const auto idx = task->getQuantityIndex(qc, dit.first);
277  if (idx < 0)
278  continue;
279 
280  const auto &v = chi_exp(offsets[qci] + idx);
281 
282  switch (qc) {
284  r.setShR1(v);
285  break;
287  r.setShR2(v);
288  break;
290  r.setShZ(v);
291  break;
293  r.setRotZ(v);
294  break;
295  }
296  }
297 
298  results[dit.first] = r;
299  }
300 
301  return 0;
302 }

References funct::abs(), b, gen::C, createBeamHaloJobs::constraints, cuy::cv, ztail::d, Exception, relativeConstraints::geom, AlignmentTask::geometry, AlignmentGeometry::get(), AlignmentTask::getQuantityIndex(), AlignmentGeometry::getSensorMap(), gMisaligned, gReal, Exhume::I, mps_fire::i, heavyIonCSV_trainingSettings::idx, dqmiolumiharvest::j, dqmdumpme::k, visualization-live-secondInstance_cfg::m, makeMuonMisalignmentScenario::misal, hltrates_dqm_sourceclient-live_cfg::offset, unpackBuffers-CaloStage1::offsets, AlignmentTask::qcRotZ, AlignmentTask::qcShR1, AlignmentTask::qcShR2, AlignmentTask::qcShZ, AlignmentTask::quantitiesOfClass(), AlignmentTask::quantityClasses, alignCSCRings::r, AlignmentTask::resolveRotZ, AlignmentTask::resolveShR, bookConverter::results, rho, idealTransformation::rotation, DetGeomDesc::rotation(), CTPPSDetId::sdTrackingPixel, CTPPSDetId::sdTrackingStrip, CTPPSGeometry::sensor(), edm::shift, DetId::subdetId(), AlignmentAlgorithm::task, DetGeomDesc::translation(), cms::cuda::V, and findQualityFiles::v.

Member Data Documentation

◆ gMisaligned

edm::ESHandle<CTPPSGeometry> IdealResult::gMisaligned
protected

Definition at line 26 of file IdealResult.h.

Referenced by begin(), and solve().

◆ gReal

edm::ESHandle<CTPPSGeometry> IdealResult::gReal
protected

Definition at line 26 of file IdealResult.h.

Referenced by begin(), and solve().

mps_fire.i
i
Definition: mps_fire.py:428
AlignmentTask::getQuantityIndex
signed int getQuantityIndex(QuantityClass cl, unsigned int detId) const
returns measurement index (if non-existent, returns -1)
Definition: AlignmentTask.cc:199
AlignmentTask::qcShR1
detector shifts in first readout direction
Definition: AlignmentTask.h:60
AlignmentAlgorithm::AlignmentAlgorithm
AlignmentAlgorithm()
dummy constructor (not to be used)
Definition: AlignmentAlgorithm.h:43
DetGeomDesc::translation
const Translation & translation() const
Definition: DetGeomDesc.h:79
AlignmentTask::qcShZ
detector shifts in z
Definition: AlignmentTask.h:62
cuy.cv
cv
Definition: cuy.py:363
bookConverter.results
results
Definition: bookConverter.py:144
AlignmentTask::qcRotZ
detector rotations around z
Definition: AlignmentTask.h:63
findQualityFiles.v
v
Definition: findQualityFiles.py:179
makeMuonMisalignmentScenario.misal
dictionary misal
Definition: makeMuonMisalignmentScenario.py:156
IdealResult::gMisaligned
edm::ESHandle< CTPPSGeometry > gMisaligned
Definition: IdealResult.h:26
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
CTPPSDetId::sdTrackingStrip
Definition: CTPPSDetId.h:44
Exhume::I
const std::complex< double > I
Definition: I.h:8
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
dqmdumpme.k
k
Definition: dqmdumpme.py:60
CTPPSDetId::sdTrackingPixel
Definition: CTPPSDetId.h:44
b
double b
Definition: hdecay.h:118
DDAxes::rho
AlignmentGeometry::getSensorMap
const std::map< unsigned int, DetGeometry > & getSensorMap() const
Definition: AlignmentGeometry.h:69
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
AlignmentTask::resolveShR
bool resolveShR
whether to resolve detector shifts in readout direction(s)
Definition: AlignmentTask.h:24
cms::cuda::V
uint32_t const T *__restrict__ const uint32_t *__restrict__ int32_t int Histo::index_type cudaStream_t V
Definition: HistoContainer.h:51
AlignmentAlgorithm::task
AlignmentTask * task
the tasked to be completed
Definition: AlignmentAlgorithm.h:36
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
DetGeomDesc
Definition: DetGeomDesc.h:50
AlignmentTask::quantitiesOfClass
unsigned int quantitiesOfClass(QuantityClass) const
returns the number of quantities of the given class
Definition: AlignmentTask.cc:240
AlignmentGeometry::get
const DetGeometry & get(unsigned int id) const
retrieves sensor geometry
Definition: AlignmentGeometry.cc:16
AlignmentResult
Result of CTPPS track-based alignment.
Definition: AlignmentResult.h:9
createBeamHaloJobs.constraints
string constraints
Definition: createBeamHaloJobs.py:229
alignCSCRings.r
r
Definition: alignCSCRings.py:93
AlignmentTask::resolveRotZ
bool resolveRotZ
whether to resolve detector rotations around z
Definition: AlignmentTask.h:30
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
gen::C
C
Definition: PomwigHadronizer.cc:78
Exception
Definition: hltDiff.cc:245
IdealResult::gReal
edm::ESHandle< CTPPSGeometry > gReal
Definition: IdealResult.h:26
AlignmentTask::quantityClasses
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
Definition: AlignmentTask.h:67
AlignmentTask::geometry
AlignmentGeometry geometry
the geometry for this task
Definition: AlignmentTask.h:47
unpackBuffers-CaloStage1.offsets
offsets
Definition: unpackBuffers-CaloStage1.py:127
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
DetGeomDesc::rotation
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:80
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
A
AlignmentTask::qcShR2
detector shifts in second readout direction
Definition: AlignmentTask.h:61
CTPPSGeometry::sensor
const DetGeomDesc * sensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
Definition: CTPPSGeometry.cc:91