CMS 3D CMS Logo

AlignmentParameters.cc
Go to the documentation of this file.
3 
5 
7 
8 //__________________________________________________________________________________________________
9 AlignmentParameters::AlignmentParameters() : theAlignable(nullptr), theUserVariables(nullptr), bValid(true) {}
10 
11 //__________________________________________________________________________________________________
13  : theAlignable(object),
14  theData(DataContainer(new AlignmentParametersData(par, cov))),
15  theUserVariables(nullptr),
16  bValid(true) {
17  // is the data consistent?
18  theData->checkConsistency();
19 }
20 
21 //__________________________________________________________________________________________________
23  const AlgebraicVector& par,
24  const AlgebraicSymMatrix& cov,
25  const std::vector<bool>& sel)
26  : theAlignable(object),
27  theData(DataContainer(new AlignmentParametersData(par, cov, sel))),
28  theUserVariables(nullptr),
29  bValid(true) {
30  // is the data consistent?
31  theData->checkConsistency();
32 }
33 
34 //__________________________________________________________________________________________________
36  : theAlignable(object), theData(data), theUserVariables(nullptr), bValid(true) {
37  // is the data consistent?
38  theData->checkConsistency();
39 }
40 
41 //__________________________________________________________________________________________________
43  if (theUserVariables)
44  delete theUserVariables;
45 }
46 
47 //__________________________________________________________________________________________________
48 const std::vector<bool>& AlignmentParameters::selector(void) const { return theData->selector(); }
49 
50 //__________________________________________________________________________________________________
51 int AlignmentParameters::numSelected(void) const { return theData->numSelected(); }
52 
53 //__________________________________________________________________________________________________
55  return collapseVector(theData->parameters(), theData->selector());
56 }
57 
58 //__________________________________________________________________________________________________
60  return collapseSymMatrix(theData->covariance(), theData->selector());
61 }
62 
63 //__________________________________________________________________________________________________
64 const AlgebraicVector& AlignmentParameters::parameters(void) const { return theData->parameters(); }
65 
66 //__________________________________________________________________________________________________
67 const AlgebraicSymMatrix& AlignmentParameters::covariance(void) const { return theData->covariance(); }
68 
69 //__________________________________________________________________________________________________
71  const AlignableDetOrUnitPtr& alignableDet) const {
72  const AlgebraicMatrix dev(this->derivatives(tsos, alignableDet));
73 
74  const int ncols = dev.num_col();
75  const int nrows = dev.num_row();
76  const int nsel = numSelected();
77 
78  AlgebraicMatrix seldev(nsel, ncols);
79 
80  int ir2 = 0;
81  for (int irow = 0; irow < nrows; ++irow) {
82  if (this->selector()[irow]) {
83  for (int icol = 0; icol < ncols; ++icol) {
84  seldev[ir2][icol] = dev[irow][icol];
85  }
86  ++ir2;
87  }
88  }
89 
90  return seldev;
91 }
92 
93 //__________________________________________________________________________________________________
95  if (theUserVariables)
96  delete theUserVariables;
97  theUserVariables = auv;
98 }
99 
100 //__________________________________________________________________________________________________
102 
103 //__________________________________________________________________________________________________
105 
106 //__________________________________________________________________________________________________
108  if (!theAlignable) {
109  edm::LogError("Alignment") << "@SUB=AlignmentParameters::hierarchyLevel"
110  << "Called for AlignmentParameters without pointer to Alignable";
111  return 0;
112  }
113 
114  align::Alignables comps;
116  if (comps.empty())
117  return 0;
118 
119  unsigned int maxLevelOfComp = 0;
120  for (const auto& iAli : comps) { // firstCompsWithParams guaranties that alignmentParameters() != 0:
121  const unsigned int compResult = iAli->alignmentParameters()->hierarchyLevel();
122  // levels might be different for components, get largest:
123  if (maxLevelOfComp < compResult)
124  maxLevelOfComp = compResult;
125  }
126 
127  return maxLevelOfComp + 1;
128 }
129 
130 //__________________________________________________________________________________________________
131 int AlignmentParameters::size(void) const { return theData->parameters().num_row(); }
132 
133 //__________________________________________________________________________________________________
134 bool AlignmentParameters::isValid(void) const { return bValid; }
135 
136 //__________________________________________________________________________________________________
138 
139 //__________________________________________________________________________________________________
141  const std::vector<bool>& sel) const {
142  int nRows = m.num_row();
143  int size = sel.size();
144 
145  // Check size matching
146  if (nRows != size)
147  throw cms::Exception("LogicError") << "Size mismatch in parameters"
148  << " (input symmatrix = " << nRows << ", selection: " << size << ")";
149 
150  // If OK, continue
151  std::vector<int> rowvec;
152  for (int i = 0; i < nRows; i++)
153  if (sel[i])
154  rowvec.push_back(i);
155 
156  int nSelectedRows = rowvec.size();
157  AlgebraicSymMatrix result(nSelectedRows, 0);
158  for (int i = 0; i < nSelectedRows; i++)
159  for (int j = 0; j < nSelectedRows; j++)
160  result[i][j] = m[rowvec[i]][rowvec[j]];
161 
162  return result;
163 }
164 
165 //__________________________________________________________________________________________________
167  int nRows = m.num_row();
168  int size = sel.size();
169 
170  // Check size matching
171  if (nRows != size)
172  throw cms::Exception("LogicError") << "Size mismatch in parameters"
173  << " (input vector = " << nRows << ", selection: " << size << ")";
174 
175  // If OK, continue
176  std::vector<int> rowvec;
177  for (int i = 0; i < nRows; i++)
178  if (sel[i])
179  rowvec.push_back(i);
180 
181  int nSelectedRows = rowvec.size();
182  AlgebraicVector result(nSelectedRows, 0);
183  for (int i = 0; i < nSelectedRows; i++)
184  result[i] = m[(int)rowvec[i]];
185 
186  return result;
187 }
188 
189 //__________________________________________________________________________________________________
191  const std::vector<bool>& sel) const {
192  int nRows = m.num_row();
193  int size = sel.size();
194 
195  std::vector<int> rowvec;
196  for (int i = 0; i < size; i++)
197  if (sel[i])
198  rowvec.push_back(i);
199 
200  // Check size matching
201  if (nRows != static_cast<int>(rowvec.size()))
202  throw cms::Exception("LogicError") << "Size mismatch in parameters"
203  << " (input symmatrix = " << nRows << ", selection: " << size << ")";
204 
205  // If OK, continue
207  for (int i = 0; i < nRows; i++)
208  for (int j = 0; j < nRows; j++)
209  result[rowvec[i]][rowvec[j]] = m[i][j];
210 
211  return result;
212 }
213 
214 //__________________________________________________________________________________________________
215 AlgebraicVector AlignmentParameters::expandVector(const AlgebraicVector& m, const std::vector<bool>& sel) const {
216  int nRows = m.num_row();
217  int size = sel.size();
218 
219  std::vector<int> rowvec;
220  for (int i = 0; i < size; i++)
221  if (sel[i] == true)
222  rowvec.push_back(i);
223 
224  // Check size matching
225  if (nRows != static_cast<int>(rowvec.size()))
226  throw cms::Exception("LogicError") << "Size mismatch in parameters"
227  << " (input vector = " << nRows << ", selection: " << size << ")";
228 
229  // If OK, continue
231  for (int i = 0; i < nRows; i++)
232  result[rowvec[i]] = m[i];
233  return result;
234 }
AlignmentParameters::theAlignable
Alignable * theAlignable
Definition: AlignmentParameters.h:121
AlignmentParameters::expandVector
AlgebraicVector expandVector(const AlgebraicVector &m, const std::vector< bool > &sel) const
Definition: AlignmentParameters.cc:215
hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:105
Alignable::firstCompsWithParams
bool firstCompsWithParams(Alignables &paramComps) const
Definition: Alignable.cc:62
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
mps_fire.i
i
Definition: mps_fire.py:428
AlignmentParameters::theData
DataContainer theData
Definition: AlignmentParameters.h:123
MessageLogger.h
AlignmentUserVariables
(Abstract) Base class for alignment algorithm user variables
Definition: AlignmentUserVariables.h:6
AlignmentParameters::collapseVector
AlgebraicVector collapseVector(const AlgebraicVector &m, const std::vector< bool > &sel) const
Definition: AlignmentParameters.cc:166
Alignable
Definition: Alignable.h:27
AlignmentParameters::userVariables
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
Definition: AlignmentParameters.cc:101
AlignmentParameters::selectedDerivatives
virtual AlgebraicMatrix selectedDerivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const
Definition: AlignmentParameters.cc:70
ReferenceCountingPointer
Definition: ReferenceCounted.h:60
findQualityFiles.v
v
Definition: findQualityFiles.py:179
AlignableDetOrUnitPtr
Definition: AlignableDetOrUnitPtr.h:30
AlignmentParameters::isValid
bool isValid(void) const
Get validity flag.
Definition: AlignmentParameters.cc:134
AlignmentParameters.h
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
AlignmentParameters::selectedCovariance
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.
Definition: AlignmentParameters.cc:59
AlignmentParameters::~AlignmentParameters
virtual ~AlignmentParameters()
Destructor.
Definition: AlignmentParameters.cc:42
funct::true
true
Definition: Factorize.h:173
AlignmentParameters::AlignmentParameters
AlignmentParameters()
Default constructor.
Definition: AlignmentParameters.cc:9
AlignmentParameters::theUserVariables
AlignmentUserVariables * theUserVariables
Definition: AlignmentParameters.h:125
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
AlignmentParameters::collapseSymMatrix
AlgebraicSymMatrix collapseSymMatrix(const AlgebraicSymMatrix &m, const std::vector< bool > &sel) const
Definition: AlignmentParameters.cc:140
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlignmentParameters::selectedParameters
AlgebraicVector selectedParameters(void) const
Get selected parameters.
Definition: AlignmentParameters.cc:54
AlignmentParameters::expandSymMatrix
AlgebraicSymMatrix expandSymMatrix(const AlgebraicSymMatrix &m, const std::vector< bool > &sel) const
Definition: AlignmentParameters.cc:190
AlignmentParametersData
Definition: AlignmentParametersData.h:7
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
AlignmentParameters::derivatives
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
Get derivatives of selected parameters.
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
AlignmentParameters::covariance
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
Definition: AlignmentParameters.cc:67
AlignmentParameters::setValid
void setValid(bool v)
Set validity flag.
Definition: AlignmentParameters.cc:137
Exception
Definition: hltDiff.cc:246
AlignmentParameters::numSelected
int numSelected(void) const
Get number of selected parameters.
Definition: AlignmentParameters.cc:51
Alignable.h
AlignmentParameters::size
int size(void) const
Get number of parameters.
Definition: AlignmentParameters.cc:131
Exception.h
AlignmentParameters::alignable
Alignable * alignable(void) const
Get pointer to corresponding alignable.
Definition: AlignmentParameters.cc:104
AlignmentParameters::selector
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
Definition: AlignmentParameters.cc:48
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
mps_fire.result
result
Definition: mps_fire.py:311
EgammaValidation_Wenu_cff.sel
sel
Definition: EgammaValidation_Wenu_cff.py:33
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
AlignmentParameters::parameters
const AlgebraicVector & parameters(void) const
Get alignment parameters.
Definition: AlignmentParameters.cc:64
AlignmentParameters::bValid
bool bValid
True if parameters are valid.
Definition: AlignmentParameters.h:127
AlignmentParameters::hierarchyLevel
virtual unsigned int hierarchyLevel() const
Definition: AlignmentParameters.cc:107
AlignmentParameters::setUserVariables
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
Definition: AlignmentParameters.cc:94