CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CompositeAlignmentDerivativesExtractor Class Reference

#include <CompositeAlignmentDerivativesExtractor.h>

Public Member Functions

 CompositeAlignmentDerivativesExtractor (const align::Alignables &alignables, const std::vector< AlignableDet * > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
 
 CompositeAlignmentDerivativesExtractor (const align::Alignables &alignables, const std::vector< AlignableDetOrUnitPtr > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
 constructor More...
 
const AlgebraicVectorcorrectionTerm (void) const
 
const AlgebraicMatrixderivatives (void) const
 
 ~CompositeAlignmentDerivativesExtractor (void)
 destructor More...
 

Private Member Functions

void extractCurrentAlignment (const align::Alignables &alignables, const std::vector< AlignableDetOrUnitPtr > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
 
void extractWithMultipleHits (const std::vector< AlgebraicVector > &subCorrectionTerm, const std::vector< AlgebraicMatrix > &subDerivatives, const align::Alignables &alignables)
 
void extractWithoutMultipleHits (const std::vector< AlgebraicVector > &subCorrectionTerm, const std::vector< AlgebraicMatrix > &subDerivatives)
 

Private Attributes

AlgebraicVector theCorrectionTerm
 
AlgebraicMatrix theDerivatives
 

Detailed Description

A helper class to extract derivatives from composite alignable objects

Date
2007/05/02 21:01:52
Revision
1.7

(last update by

Author
fronga

)

Definition at line 20 of file CompositeAlignmentDerivativesExtractor.h.

Constructor & Destructor Documentation

CompositeAlignmentDerivativesExtractor::CompositeAlignmentDerivativesExtractor ( const align::Alignables alignables,
const std::vector< AlignableDet * > &  alignableDets,
const std::vector< TrajectoryStateOnSurface > &  tsos 
)

deprecated constructor for backward compatibility (use mor general AlignableDetOrUnitPtr)

Definition at line 11 of file CompositeAlignmentDerivativesExtractor.cc.

References extractCurrentAlignment().

14  {
15  std::vector<AlignableDetOrUnitPtr> detOrUnits;
16  detOrUnits.reserve(alignableDets.size());
17 
18  std::vector<AlignableDet *>::const_iterator it, itEnd;
19  for (it = alignableDets.begin(), itEnd = alignableDets.end(); it != itEnd; ++it)
20  detOrUnits.push_back(AlignableDetOrUnitPtr(*it));
21 
22  extractCurrentAlignment(alignables, detOrUnits, tsos);
23 }
void extractCurrentAlignment(const align::Alignables &alignables, const std::vector< AlignableDetOrUnitPtr > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
CompositeAlignmentDerivativesExtractor::CompositeAlignmentDerivativesExtractor ( const align::Alignables alignables,
const std::vector< AlignableDetOrUnitPtr > &  alignableDets,
const std::vector< TrajectoryStateOnSurface > &  tsos 
)

constructor

Definition at line 26 of file CompositeAlignmentDerivativesExtractor.cc.

References extractCurrentAlignment().

29  {
30  extractCurrentAlignment(alignables, alignableDets, tsos);
31 }
void extractCurrentAlignment(const align::Alignables &alignables, const std::vector< AlignableDetOrUnitPtr > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
CompositeAlignmentDerivativesExtractor::~CompositeAlignmentDerivativesExtractor ( void  )
inline

destructor

Definition at line 33 of file CompositeAlignmentDerivativesExtractor.h.

33 {};

Member Function Documentation

const AlgebraicVector& CompositeAlignmentDerivativesExtractor::correctionTerm ( void  ) const
inline
const AlgebraicMatrix& CompositeAlignmentDerivativesExtractor::derivatives ( void  ) const
inline
void CompositeAlignmentDerivativesExtractor::extractCurrentAlignment ( const align::Alignables alignables,
const std::vector< AlignableDetOrUnitPtr > &  alignableDets,
const std::vector< TrajectoryStateOnSurface > &  tsos 
)
private

Definition at line 35 of file CompositeAlignmentDerivativesExtractor.cc.

References KineDebug3::count(), extractWithMultipleHits(), extractWithoutMultipleHits(), theCorrectionTerm, and theDerivatives.

Referenced by CompositeAlignmentDerivativesExtractor(), and correctionTerm().

38  {
39  // sanity check
40  if (alignables.size() != alignableDets.size()) {
41  edm::LogError("CompositeAlignmentDerivativesExtractor")
42  << "Inconsistent length of arguments: alignables=" << alignables.size()
43  << ", alignableDets=" << alignableDets.size();
44  return;
45  }
46 
47  if (alignables.size() != tsos.size()) {
48  edm::LogError("CompositeAlignmentDerivativesExtractor")
49  << "Inconsistent length of arguments: alignables=" << alignables.size() << ", tsos=" << tsos.size();
50  return;
51  }
52 
53  align::Alignables::const_iterator itAlignable = alignables.begin();
54  std::vector<AlignableDetOrUnitPtr>::const_iterator itAlignableDet = alignableDets.begin();
55  std::vector<TrajectoryStateOnSurface>::const_iterator itTsos = tsos.begin();
56 
57  int nRow = 0;
58  int nCollumn = 0;
59  unsigned int nAlignables = 0;
60 
61  std::vector<AlgebraicMatrix> subDerivatives;
62  std::vector<AlgebraicVector> subCorrectionTerm;
63 
64  // get the individual derivatives and correction term and determine the
65  // dimension
66  while (itAlignable != alignables.end()) {
67  // Get the current estimate on the alignment parameters
68  AlgebraicVector subAlignmentParameters = (*itAlignable)->alignmentParameters()->selectedParameters();
69 
70  // Get the derivatives or the local coordinates w.r.t. the corresponding
71  // alignment parameters
72  AlgebraicMatrix subAlignmentDerivatives =
73  (*itAlignable)->alignmentParameters()->selectedDerivatives(*itTsos, *itAlignableDet);
74 
75  subDerivatives.push_back(subAlignmentDerivatives.T());
76  subCorrectionTerm.push_back(subAlignmentDerivatives.T() * subAlignmentParameters);
77 
78  nRow += 2;
79  // check if it is the first occurrence of this Alignable
80  if (count(alignables.begin(), itAlignable, *itAlignable) == 0) {
81  // matrix is transposed -> num_row() instead of num_col()
82  nCollumn += subAlignmentDerivatives.num_row();
83  nAlignables++;
84  }
85 
86  ++itAlignable;
87  ++itAlignableDet;
88  ++itTsos;
89  }
90 
91  // construct derivatives and correction term with the right dimension
92  theDerivatives = AlgebraicMatrix(nRow, nCollumn, 0);
94 
95  if (alignables.size() == nAlignables)
96  // One hit per alignable
97  extractWithoutMultipleHits(subCorrectionTerm, subDerivatives);
98  else
99  // At least one alignable has two hits
100  extractWithMultipleHits(subCorrectionTerm, subDerivatives, alignables);
101 
102  return;
103 }
void extractWithMultipleHits(const std::vector< AlgebraicVector > &subCorrectionTerm, const std::vector< AlgebraicMatrix > &subDerivatives, const align::Alignables &alignables)
CLHEP::HepMatrix AlgebraicMatrix
void extractWithoutMultipleHits(const std::vector< AlgebraicVector > &subCorrectionTerm, const std::vector< AlgebraicMatrix > &subDerivatives)
CLHEP::HepVector AlgebraicVector
void CompositeAlignmentDerivativesExtractor::extractWithMultipleHits ( const std::vector< AlgebraicVector > &  subCorrectionTerm,
const std::vector< AlgebraicMatrix > &  subDerivatives,
const align::Alignables alignables 
)
private

Definition at line 132 of file CompositeAlignmentDerivativesExtractor.cc.

References KineDebug3::count(), spr::find(), theCorrectionTerm, and theDerivatives.

Referenced by correctionTerm(), and extractCurrentAlignment().

135  {
136  std::vector<AlgebraicVector>::const_iterator itSubCorrectionTerm = subCorrectionTerm.begin();
137  std::vector<AlgebraicMatrix>::const_iterator itSubDerivatives = subDerivatives.begin();
138  align::Alignables::const_iterator itAlignables = alignables.begin();
139  align::Alignables::const_iterator itPosition;
140  align::Alignables::const_iterator itLastPosition;
141 
142  int iRow = 1;
143 
144  // Fill in the individual terms
145  while (itAlignables != alignables.end()) {
146  theCorrectionTerm.sub(iRow, *itSubCorrectionTerm);
147 
148  int iCollumn = 1;
149  int iAlignable = 0;
150 
151  itLastPosition = find(alignables.begin(), itAlignables, *itAlignables);
152 
153  for (itPosition = alignables.begin(); itPosition != itLastPosition; ++itPosition) {
154  if (count(alignables.begin(), itPosition, *itPosition) == 0)
155  iCollumn += subDerivatives[iAlignable].num_col();
156  iAlignable++;
157  }
158 
159  theDerivatives.sub(iRow, iCollumn, *itSubDerivatives);
160 
161  iRow += 2;
162 
163  ++itAlignables;
164  ++itSubCorrectionTerm;
165  ++itSubDerivatives;
166  }
167 
168  return;
169 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void CompositeAlignmentDerivativesExtractor::extractWithoutMultipleHits ( const std::vector< AlgebraicVector > &  subCorrectionTerm,
const std::vector< AlgebraicMatrix > &  subDerivatives 
)
private

Definition at line 107 of file CompositeAlignmentDerivativesExtractor.cc.

References theCorrectionTerm, and theDerivatives.

Referenced by correctionTerm(), and extractCurrentAlignment().

108  {
109  std::vector<AlgebraicVector>::const_iterator itSubCorrectionTerm = subCorrectionTerm.begin();
110  std::vector<AlgebraicMatrix>::const_iterator itSubDerivatives = subDerivatives.begin();
111 
112  int iRow = 1;
113  int iCollumn = 1;
114 
115  // Fill in the individual terms
116  while (itSubCorrectionTerm != subCorrectionTerm.end()) {
117  theCorrectionTerm.sub(iRow, *itSubCorrectionTerm);
118  theDerivatives.sub(iRow, iCollumn, *itSubDerivatives);
119 
120  iRow += 2;
121  iCollumn += (*itSubDerivatives).num_col();
122 
123  ++itSubCorrectionTerm;
124  ++itSubDerivatives;
125  }
126 
127  return;
128 }

Member Data Documentation

AlgebraicVector CompositeAlignmentDerivativesExtractor::theCorrectionTerm
private
AlgebraicMatrix CompositeAlignmentDerivativesExtractor::theDerivatives
private