CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignmentParameters.cc
Go to the documentation of this file.
3 
5 
7 
8 
9 //__________________________________________________________________________________________________
11  theAlignable( 0),
12  theUserVariables( 0),
13  bValid(true)
14 {}
15 
16 
17 //__________________________________________________________________________________________________
19  const AlgebraicSymMatrix& cov) :
20  theAlignable(object),
21  theData( DataContainer( new AlignmentParametersData(par,cov) ) ),
22  theUserVariables(0),
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) ) ),
36  theUserVariables(0),
37  bValid(true)
38 {
39  // is the data consistent?
40  theData->checkConsistency();
41 }
42 
43 
44 //__________________________________________________________________________________________________
47  theAlignable(object),
48  theData(data),
49  theUserVariables(0),
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  std::vector<Alignable*> comps;
162  if (comps.empty()) return 0;
163 
164  unsigned int maxLevelOfComp = 0;
165  for (std::vector<Alignable*>::const_iterator iAli = comps.begin(), iAliEnd = comps.end();
166  iAli != iAliEnd; ++iAli) {// firstCompsWithParams guaranties that alignmentParameters() != 0:
167  const unsigned int compResult = (*iAli)->alignmentParameters()->hierarchyLevel();
168  // levels might be different for components, get largest:
169  if (maxLevelOfComp < compResult) maxLevelOfComp = compResult;
170  }
171 
172  return maxLevelOfComp + 1;
173 }
174 
175 
176 //__________________________________________________________________________________________________
178 {
179  return theData->parameters().num_row();
180 }
181 
182 
183 //__________________________________________________________________________________________________
185 {
186  return bValid;
187 }
188 
189 
190 //__________________________________________________________________________________________________
192 {
193  bValid=v;
194 }
195 
196 
197 //__________________________________________________________________________________________________
200  const std::vector<bool>& sel ) const
201 {
202 
203  int nRows = m.num_row();
204  int size = sel.size();
205 
206  // Check size matching
207  if ( nRows != size )
208  throw cms::Exception("LogicError") << "Size mismatch in parameters";
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 
238  // If OK, continue
239  std::vector<int> rowvec;
240  for ( int i=0; i<nRows; i++ )
241  if ( sel[i] ) rowvec.push_back(i);
242 
243  int nSelectedRows=rowvec.size();
244  AlgebraicVector result( nSelectedRows, 0 );
245  for ( int i=0; i<nSelectedRows; i++ )
246  result[i] = m[ (int)rowvec[i] ];
247 
248  return result;
249 
250 }
251 
252 
253 //__________________________________________________________________________________________________
255  const std::vector<bool>& sel) const
256 {
257 
258  int nRows = m.num_row();
259  int size = sel.size();
260 
261  std::vector<int> rowvec;
262  for ( int i=0; i<size; i++ )
263  if ( sel[i] ) rowvec.push_back(i);
264 
265  // Check size matching
266  if( nRows != static_cast<int>(rowvec.size()) )
267  throw cms::Exception("LogicError") << "Size mismatch in parameters";
268 
269  // If OK, continue
270  AlgebraicSymMatrix result(size,0);
271  for ( int i=0; i<nRows; i++ )
272  for (int j=0; j<nRows; j++)
273  result[ rowvec[i] ][ rowvec[j] ] = m[i][j];
274 
275  return result;
276 }
277 
278 
279 //__________________________________________________________________________________________________
281  const std::vector<bool>& sel) const
282 {
283 
284  int nRows = m.num_row();
285  int size = sel.size();
286 
287  std::vector<int> rowvec;
288  for ( int i=0; i<size; i++ )
289  if (sel[i]==true) rowvec.push_back(i);
290 
291  // Check size matching
292  if( nRows != static_cast<int>(rowvec.size()) )
293  throw cms::Exception("LogicError") << "Size mismatch in parameters";
294 
295  // If OK, continue
296  AlgebraicVector result(size,0);
297  for (int i=0; i<nRows; i++) result[ rowvec[i] ] = m[i];
298  return result;
299 
300 }
int i
Definition: DBlmapReader.cc:9
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.
const AlgebraicVector & parameters(void) const
Get alignment parameters.
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
Get derivatives of selected parameters.
CLHEP::HepMatrix AlgebraicMatrix
void setValid(bool v)
Set validity flag.
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
bool firstCompsWithParams(Alignables &paramComps) const
Definition: Alignable.cc:50
(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.
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 selectedDerivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const