CMS 3D CMS Logo

AlignmentParameters.cc
Go to the documentation of this file.
3 
5 
7 
8 
9 //__________________________________________________________________________________________________
11  theAlignable( nullptr),
12  theUserVariables( nullptr),
13  bValid(true)
14 {}
15 
16 
17 //__________________________________________________________________________________________________
19  const AlgebraicSymMatrix& cov) :
20  theAlignable(object),
23  bValid(true)
24 {
25  // is the data consistent?
26  theData->checkConsistency();
27 }
28 
29 
30 //__________________________________________________________________________________________________
32  const AlgebraicSymMatrix& cov,
33  const std::vector<bool>& sel) :
34  theAlignable(object),
35  theData( DataContainer( new AlignmentParametersData(par,cov,sel) ) ),
37  bValid(true)
38 {
39  // is the data consistent?
40  theData->checkConsistency();
41 }
42 
43 
44 //__________________________________________________________________________________________________
47  theAlignable(object),
48  theData(data),
50  bValid(true)
51 {
52  // is the data consistent?
53  theData->checkConsistency();
54 }
55 
56 
57 //__________________________________________________________________________________________________
59 {
60  if ( theUserVariables ) delete theUserVariables;
61 }
62 
63 
64 //__________________________________________________________________________________________________
65 const std::vector<bool>& AlignmentParameters::selector(void) const
66 {
67  return theData->selector();
68 }
69 
70 //__________________________________________________________________________________________________
72 {
73  return theData->numSelected();
74 }
75 
76 
77 //__________________________________________________________________________________________________
79 {
80  return collapseVector( theData->parameters(), theData->selector() );
81 }
82 
83 
84 //__________________________________________________________________________________________________
86 {
87  return collapseSymMatrix( theData->covariance(), theData->selector() );
88 }
89 
90 
91 //__________________________________________________________________________________________________
93 {
94  return theData->parameters();
95 }
96 
97 
98 //__________________________________________________________________________________________________
100 {
101  return theData->covariance();
102 }
103 
104 //__________________________________________________________________________________________________
107  const AlignableDetOrUnitPtr &alignableDet) const
108 {
109  const AlgebraicMatrix dev(this->derivatives(tsos, alignableDet));
110 
111  const int ncols = dev.num_col();
112  const int nrows = dev.num_row();
113  const int nsel = numSelected();
114 
115  AlgebraicMatrix seldev(nsel, ncols);
116 
117  int ir2 = 0;
118  for (int irow = 0; irow < nrows; ++irow) {
119  if (this->selector()[irow]) {
120  for (int icol = 0; icol < ncols; ++icol) {
121  seldev[ir2][icol] = dev[irow][icol];
122  }
123  ++ir2;
124  }
125  }
126 
127  return seldev;
128 }
129 
130 //__________________________________________________________________________________________________
132 {
133  if ( theUserVariables ) delete theUserVariables;
134  theUserVariables = auv;
135 }
136 
137 
138 //__________________________________________________________________________________________________
140 {
141  return theUserVariables;
142 }
143 
144 
145 //__________________________________________________________________________________________________
147 {
148  return theAlignable;
149 }
150 
151 //__________________________________________________________________________________________________
153 {
154  if (!theAlignable) {
155  edm::LogError("Alignment") << "@SUB=AlignmentParameters::hierarchyLevel"
156  << "Called for AlignmentParameters without pointer to Alignable";
157  return 0;
158  }
159 
160  align::Alignables comps;
162  if (comps.empty()) return 0;
163 
164  unsigned int maxLevelOfComp = 0;
165  for (const auto& iAli: comps) {// firstCompsWithParams guaranties that alignmentParameters() != 0:
166  const unsigned int compResult = iAli->alignmentParameters()->hierarchyLevel();
167  // levels might be different for components, get largest:
168  if (maxLevelOfComp < compResult) maxLevelOfComp = compResult;
169  }
170 
171  return maxLevelOfComp + 1;
172 }
173 
174 
175 //__________________________________________________________________________________________________
177 {
178  return theData->parameters().num_row();
179 }
180 
181 
182 //__________________________________________________________________________________________________
184 {
185  return bValid;
186 }
187 
188 
189 //__________________________________________________________________________________________________
191 {
192  bValid=v;
193 }
194 
195 
196 //__________________________________________________________________________________________________
199  const std::vector<bool>& sel ) const
200 {
201 
202  int nRows = m.num_row();
203  int size = sel.size();
204 
205  // Check size matching
206  if ( nRows != size )
207  throw cms::Exception("LogicError") << "Size mismatch in parameters"
208  << " (input symmatrix = " << nRows << ", selection: " << size << ")";
209 
210  // If OK, continue
211  std::vector<int> rowvec;
212  for ( int i=0; i<nRows; i++ )
213  if ( sel[i] ) rowvec.push_back(i);
214 
215  int nSelectedRows = rowvec.size();
216  AlgebraicSymMatrix result( nSelectedRows, 0 );
217  for (int i=0; i<nSelectedRows; i++)
218  for (int j=0; j<nSelectedRows; j++)
219  result[i][j] = m[ rowvec[i] ][ rowvec[j] ];
220 
221  return result;
222 
223 }
224 
225 
226 //__________________________________________________________________________________________________
228  const std::vector<bool>& sel ) const
229 {
230 
231  int nRows = m.num_row();
232  int size = sel.size();
233 
234  // Check size matching
235  if ( nRows != size )
236  throw cms::Exception("LogicError") << "Size mismatch in parameters"
237  << " (input vector = " << nRows << ", selection: " << size << ")";
238 
239  // If OK, continue
240  std::vector<int> rowvec;
241  for ( int i=0; i<nRows; i++ )
242  if ( sel[i] ) rowvec.push_back(i);
243 
244  int nSelectedRows=rowvec.size();
245  AlgebraicVector result( nSelectedRows, 0 );
246  for ( int i=0; i<nSelectedRows; i++ )
247  result[i] = m[ (int)rowvec[i] ];
248 
249  return result;
250 
251 }
252 
253 
254 //__________________________________________________________________________________________________
256  const std::vector<bool>& sel) const
257 {
258 
259  int nRows = m.num_row();
260  int size = sel.size();
261 
262  std::vector<int> rowvec;
263  for ( int i=0; i<size; i++ )
264  if ( sel[i] ) rowvec.push_back(i);
265 
266  // Check size matching
267  if( nRows != static_cast<int>(rowvec.size()) )
268  throw cms::Exception("LogicError") << "Size mismatch in parameters"
269  << " (input symmatrix = " << nRows << ", selection: " << size << ")";
270 
271  // If OK, continue
272  AlgebraicSymMatrix result(size,0);
273  for ( int i=0; i<nRows; i++ )
274  for (int j=0; j<nRows; j++)
275  result[ rowvec[i] ][ rowvec[j] ] = m[i][j];
276 
277  return result;
278 }
279 
280 
281 //__________________________________________________________________________________________________
283  const std::vector<bool>& sel) const
284 {
285 
286  int nRows = m.num_row();
287  int size = sel.size();
288 
289  std::vector<int> rowvec;
290  for ( int i=0; i<size; i++ )
291  if (sel[i]==true) rowvec.push_back(i);
292 
293  // Check size matching
294  if( nRows != static_cast<int>(rowvec.size()) )
295  throw cms::Exception("LogicError") << "Size mismatch in parameters"
296  << " (input vector = " << nRows << ", selection: " << size << ")";
297 
298  // If OK, continue
299  AlgebraicVector result(size,0);
300  for (int i=0; i<nRows; i++) result[ rowvec[i] ] = m[i];
301  return result;
302 
303 }
AlgebraicSymMatrix collapseSymMatrix(const AlgebraicSymMatrix &m, const std::vector< bool > &sel) const
AlgebraicVector selectedParameters(void) const
Get selected parameters.
AlgebraicSymMatrix expandSymMatrix(const AlgebraicSymMatrix &m, const std::vector< bool > &sel) const
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
#define nullptr
const AlgebraicVector & parameters(void) const
Get alignment parameters.
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
CLHEP::HepMatrix AlgebraicMatrix
void setValid(bool v)
Set validity flag.
bool firstCompsWithParams(Alignables &paramComps) const
Definition: Alignable.cc:69
(Abstract) Base class for alignment algorithm user variables
Alignable * alignable(void) const
Get pointer to corresponding alignable.
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.
int numSelected(void) const
Get number of selected parameters.
CLHEP::HepVector AlgebraicVector
AlgebraicVector expandVector(const AlgebraicVector &m, const std::vector< bool > &sel) const
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
int size(void) const
Get number of parameters.
std::vector< Alignable * > Alignables
Definition: Utilities.h:32
AlgebraicVector collapseVector(const AlgebraicVector &m, const std::vector< bool > &sel) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
virtual ~AlignmentParameters()
Destructor.
bool isValid(void) const
Get validity flag.
CLHEP::HepSymMatrix AlgebraicSymMatrix
AlignmentParameters()
Default constructor.
bool bValid
True if parameters are valid.
virtual unsigned int hierarchyLevel() const
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
AlignmentUserVariables * theUserVariables
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
Get derivatives of selected parameters.
virtual AlgebraicMatrix selectedDerivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const