CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes | Private Types | Private Attributes
AlignmentParameterStore Class Reference

#include <AlignmentParameterStore.h>

Public Types

typedef std::map< std::pair< Alignable *, Alignable * >, AlgebraicMatrixCorrelations
 
typedef std::vector< unsigned int > DetIds
 
typedef std::pair< Alignable *, unsigned int > ParameterId
 a single alignable parameter of an Alignable More...
 
typedef std::vector< AlignmentParameters * > Parameters
 

Public Member Functions

void acquireRelativeParameters (void)
 
AlignablealignableFromAlignableDet (const AlignableDetOrUnitPtr &alignableDet) const
 Obsolete: Use AlignableNavigator::alignableDetFromGeomDet and alignableFromAlignableDet. More...
 
const align::Alignablesalignables (void) const
 get all alignables More...
 
 AlignmentParameterStore (const align::Alignables &alis, const edm::ParameterSet &config)
 constructor More...
 
void applyAlignableAbsolutePositions (const align::Alignables &alis, const AlignablePositions &newpos, int &ierr)
 apply absolute positions to alignables More...
 
void applyAlignableRelativePositions (const align::Alignables &alivec, const AlignableShifts &shifts, int &ierr)
 apply relative shifts to alignables More...
 
void applyParameters (void)
 Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet. More...
 
void applyParameters (Alignable *alignable)
 apply parameters of a given alignable More...
 
void attachAlignmentParameters (const align::Alignables &alivec, const Parameters &parvec, int &ierr)
 Attach alignment parameters to given alignables. More...
 
void attachAlignmentParameters (const Parameters &parvec, int &ierr)
 Attach alignment parameters to alignables. More...
 
void attachCorrelations (const align::Alignables &alivec, const Correlations &cormap, bool overwrite, int &ierr)
 Attach correlations to given alignables. More...
 
void attachCorrelations (const Correlations &cormap, bool overwrite, int &ierr)
 Attach correlations to alignables. More...
 
void attachUserVariables (const align::Alignables &alivec, const std::vector< AlignmentUserVariables *> &uvarvec, int &ierr)
 Attach User Variables to given alignables. More...
 
void cacheTransformations (void)
 cache the current position, rotation and other parameters More...
 
void cacheTransformations (const align::RunNumber &)
 cache for the given run the current position, rotation and other parameters More...
 
AlignmentCorrelationsStorecorrelationsStore (void) const
 get full correlation map More...
 
bool hierarchyConstraints (const Alignable *aliMaster, const align::Alignables &aliComps, std::vector< std::vector< ParameterId > > &paramIdsVecOut, std::vector< std::vector< double > > &factorsVecOut, bool all, double epsilon) const
 
const unsigned int numCorrelations (void) const
 get number of correlations between alignables More...
 
int numObjects (void) const
 returns number of alignables More...
 
void resetParameters (void)
 reset parameters, correlations, user variables More...
 
void resetParameters (Alignable *ali)
 reset parameters of a given alignable More...
 
void restoreCachedTransformations (void)
 restore the previously cached position, rotation and other parameters More...
 
void restoreCachedTransformations (const align::RunNumber &)
 restore for the given run the previously cached position, rotation and other parameters More...
 
CompositeAlignmentParameters selectParameters (const std::vector< AlignableDet *> &alignabledets) const
 
CompositeAlignmentParameters selectParameters (const std::vector< AlignableDetOrUnitPtr > &alignabledets) const
 select parameters More...
 
CompositeAlignmentParameters selectParameters (const align::Alignables &) const
 select parameters More...
 
void setAlignmentPositionError (const align::Alignables &alivec, double valshift, double valrot)
 Set Alignment position error. More...
 
std::pair< int, int > typeAndLayer (const Alignable *ali, const TrackerTopology *tTopo) const
 Obtain type and layer from Alignable. More...
 
void updateParameters (const CompositeAlignmentParameters &aap, bool updateCorrelations=true)
 update parameters More...
 
align::Alignables validAlignables (void) const
 get all alignables with valid parameters More...
 
virtual ~AlignmentParameterStore ()
 destructor More...
 

Protected Attributes

AlignmentCorrelationsStoretheCorrelationsStore
 

Private Types

enum  TypeOfConstraints { NONE, HIERARCHY_CONSTRAINTS, APPROX_AVERAGING_CONSTRAINTS }
 

Private Attributes

align::Alignables theAlignables
 alignables More...
 
TypeOfConstraints theTypeOfConstraints
 type of constraints More...
 

Detailed Description

Basic class for management of alignment parameters and correlations

Date
2011/05/23 20:50:31
Revision
1.19

(last update by

Author
mussgill

)

Definition at line 23 of file AlignmentParameterStore.h.

Member Typedef Documentation

◆ Correlations

Definition at line 26 of file AlignmentParameterStore.h.

◆ DetIds

typedef std::vector<unsigned int> AlignmentParameterStore::DetIds

Definition at line 27 of file AlignmentParameterStore.h.

◆ ParameterId

typedef std::pair<Alignable*, unsigned int> AlignmentParameterStore::ParameterId

a single alignable parameter of an Alignable

Definition at line 128 of file AlignmentParameterStore.h.

◆ Parameters

Definition at line 25 of file AlignmentParameterStore.h.

Member Enumeration Documentation

◆ TypeOfConstraints

Constructor & Destructor Documentation

◆ AlignmentParameterStore()

AlignmentParameterStore::AlignmentParameterStore ( const align::Alignables alis,
const edm::ParameterSet config 
)

constructor

Definition at line 29 of file AlignmentParameterStore.cc.

References APPROX_AVERAGING_CONSTRAINTS, HIERARCHY_CONSTRAINTS, NONE, AlCaHLTBitMon_QueryRunRegistry::string, theAlignables, theCorrelationsStore, and theTypeOfConstraints.

30  : theAlignables(alis) {
31  if (config.getUntrackedParameter<bool>("UseExtendedCorrelations")) {
33  new AlignmentExtendedCorrelationsStore(config.getParameter<edm::ParameterSet>("ExtendedCorrelationsConfig"));
34  } else {
36  }
37 
38  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterStore"
39  << "Created with " << theAlignables.size() << " alignables.";
40 
41  // set hierarchy vs averaging constraints
43  const std::string cfgStrTypeOfConstraints(config.getParameter<std::string>("TypeOfConstraints"));
44  if (cfgStrTypeOfConstraints == "hierarchy") {
46  } else if (cfgStrTypeOfConstraints == "approximate_averaging") {
48  edm::LogWarning("Alignment")
49  << "@SUB=AlignmentParameterStore"
50  << "\n\n\n******* WARNING ******************************************\n"
51  << "Using approximate implementation of averaging constraints."
52  << "This is not recommended."
53  << "Consider to use 'hierarchy' constraints:"
54  << " AlignmentProducer.ParameterStore.TypeOfConstraints = cms.string('hierarchy')\n\n\n";
55  } else {
56  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore"
57  << "Unknown type of hierarchy constraints '" << cfgStrTypeOfConstraints << "'";
58  }
59 }
Definition: config.py:1
Log< level::Error, false > LogError
TypeOfConstraints theTypeOfConstraints
type of constraints
Log< level::Info, false > LogInfo
align::Alignables theAlignables
alignables
AlignmentCorrelationsStore * theCorrelationsStore
Log< level::Warning, false > LogWarning

◆ ~AlignmentParameterStore()

AlignmentParameterStore::~AlignmentParameterStore ( )
virtual

destructor

Definition at line 62 of file AlignmentParameterStore.cc.

References theCorrelationsStore.

62 { delete theCorrelationsStore; }
AlignmentCorrelationsStore * theCorrelationsStore

Member Function Documentation

◆ acquireRelativeParameters()

void AlignmentParameterStore::acquireRelativeParameters ( void  )

acquire shifts/rotations from alignables of the store and copy into alignment parameters (local frame)

Definition at line 329 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), RigidBodyAlignmentParameters::clone(), Alignable::displacement(), Exception, mps_fire::i, Alignable::rotation(), Alignable::setAlignmentParameters(), AlignmentParameters::size(), Alignable::surface(), theAlignables, align::toAngles(), AlignableSurface::toLocal(), TkRotation< T >::x(), and Basic3DVector< T >::y().

329  {
330  unsigned int nAlignables = theAlignables.size();
331 
332  for (unsigned int i = 0; i < nAlignables; ++i) {
333  Alignable* ali = theAlignables[i];
334 
336 
337  if (!ap)
338  throw cms::Exception("BadAlignable") << "acquireRelativeParameters: "
339  << "provided alignable does not have rigid body alignment parameters";
340 
341  AlgebraicVector par(ap->size(), 0);
342  AlgebraicSymMatrix cov(ap->size(), 0);
343 
344  // Get displacement and transform global->local
345  align::LocalVector dloc = ali->surface().toLocal(ali->displacement());
346  par[0] = dloc.x();
347  par[1] = dloc.y();
348  par[2] = dloc.z();
349 
350  // Transform to local euler angles
352  par[3] = euloc(1);
353  par[4] = euloc(2);
354  par[5] = euloc(3);
355 
356  // Clone parameters
357  RigidBodyAlignmentParameters* apnew = ap->clone(par, cov);
358 
359  ali->setAlignmentParameters(apnew);
360  }
361 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
T y() const
Cartesian y coordinate.
Basic3DVector< T > x() const
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:123
int size(void) const
Get number of parameters.
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:8
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:34
align::Alignables theAlignables
alignables
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:141
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
CLHEP::HepSymMatrix AlgebraicSymMatrix
RigidBodyAlignmentParameters * clone(const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const override
Clone all parameters (for update of parameters)
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:144

◆ alignableFromAlignableDet()

Alignable * AlignmentParameterStore::alignableFromAlignableDet ( const AlignableDetOrUnitPtr alignableDet) const

Obsolete: Use AlignableNavigator::alignableDetFromGeomDet and alignableFromAlignableDet.

get Alignable corresponding to given AlignableDet (non-const ref. argument since might be returned)

Definition at line 242 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), and Alignable::mother().

Referenced by selectParameters().

242  {
243  AlignableDetOrUnitPtr alignableDet = _alignableDet;
244  Alignable* mother = alignableDet;
245  while (mother) {
246  if (mother->alignmentParameters())
247  return mother;
248  mother = mother->mother();
249  }
250 
251  return nullptr;
252 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:91

◆ alignables()

const align::Alignables& AlignmentParameterStore::alignables ( void  ) const
inline

◆ applyAlignableAbsolutePositions()

void AlignmentParameterStore::applyAlignableAbsolutePositions ( const align::Alignables alis,
const AlignablePositions newpos,
int &  ierr 
)

apply absolute positions to alignables

Definition at line 373 of file AlignmentParameterStore.cc.

References Alignable::addSurfaceDeformation(), Alignable::alignableObjectId(), SurfaceDeformationFactory::create(), isotrackApplyRegressor::dtype, newFWLiteAna::found, Alignable::globalPosition(), Alignable::globalRotation(), mps_fire::i, Alignable::id(), SurfaceDeformationFactory::kNoDeformations, LogDebug, Alignable::move(), TkRotation< T >::multiplyInverse(), SurfaceDeformation::parameters(), align::rectify(), TkRotation< T >::rot, Alignable::rotateInGlobalFrame(), Alignable::surfaceDeformationIdPairs(), SurfaceDeformationFactory::surfaceDeformationTypeName(), and SurfaceDeformation::type().

Referenced by HIPAlignmentAlgorithm::startNewLoop().

375  {
376  unsigned int nappl = 0;
377  ierr = 0;
378 
379  // Iterate over list of alignables
380  for (align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali) {
381  Alignable* ali = *iali;
382  align::ID id = ali->id();
383  align::StructureType typeId = ali->alignableObjectId();
384 
385  // Find corresponding entry in AlignablePositions
386  bool found = false;
387  for (AlignablePositions::const_iterator ipos = newpos.begin(); ipos != newpos.end(); ++ipos) {
388  if (id == ipos->id() && typeId == ipos->objId()) {
389  if (found) {
390  edm::LogError("DuplicatePosition") << "New positions for alignable found more than once!";
391  } else {
392  // New position/rotation
393  const align::PositionType& pnew = ipos->pos();
394  const align::RotationType& rnew = ipos->rot();
395  const std::vector<double>& dnew = ipos->deformationParameters();
396  // Current position / rotation
397  const align::PositionType& pold = ali->globalPosition();
398  const align::RotationType& rold = ali->globalRotation();
399  // Current surf. deformation
400  std::vector<std::pair<int, SurfaceDeformation*> > dold_id_pairs;
401  SurfaceDeformation* dold_obj = nullptr;
403  std::vector<double> dold;
404  if (1 == ali->surfaceDeformationIdPairs(dold_id_pairs)) { // might not have any...
405  dold_obj = dold_id_pairs[0].second;
406  dold = dold_obj->parameters();
408  }
409 
410  // shift needed to move from current to new position
411  align::GlobalVector posDiff = pnew - pold;
412  align::RotationType rotDiff = rold.multiplyInverse(rnew);
413  align::rectify(rotDiff); // correct for rounding errors
414  ali->move(posDiff);
415  ali->rotateInGlobalFrame(rotDiff);
416  LogDebug("NewPosition") << "moving by:" << posDiff;
417  LogDebug("NewRotation") << "rotating by:\n" << rotDiff;
418 
419  // add the surface deformations
420  // If an old surface deformation record exists, ensure that the added deformation has the same type and size.
421  if (!dold.empty() && dtype != SurfaceDeformationFactory::kNoDeformations && dnew.size() == dold.size()) {
422  std::vector<double> defDiff;
423  defDiff.reserve(dold.size());
424  for (unsigned int i = 0; i < dold.size(); i++)
425  defDiff.push_back(dnew[i] - dold[i]);
426  auto deform = SurfaceDeformationFactory::create(dtype, defDiff);
427  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterStore::applyAlignableAbsolutePositions"
428  << "Adding surface deformation of type "
430  (SurfaceDeformationFactory::Type)deform->type())
431  << ", size " << defDiff.size() << " and first element " << defDiff.at(0)
432  << " to alignable with id / type: " << id << " / " << typeId;
433  ali->addSurfaceDeformation(deform, true);
434  delete deform;
435  }
436  // In case no old surface deformation record exists, only ensure that the new surface deformation record has size>0. Size check is done elsewhere.
437  else if (!dnew.empty()) {
438  auto deform = SurfaceDeformationFactory::create(dnew);
439  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterStore::applyAlignableAbsolutePositions"
440  << "Setting surface deformation of type "
442  (SurfaceDeformationFactory::Type)deform->type())
443  << ", size " << dnew.size() << " and first element " << dnew.at(0)
444  << " to alignable with id / type: " << id << " / " << typeId;
445  ali->addSurfaceDeformation(deform, true); // Equivalent to setSurfaceDeformation in this case
446  delete deform;
447  }
448  // If there is no new surface deformation record, do nothing.
449 
450  // add position error
451  // AlignmentPositionError ape(shift.x(),shift.y(),shift.z());
452  // (*iali)->addAlignmentPositionError(ape);
453  // (*iali)->addAlignmentPositionErrorFromRotation(rot);
454 
455  found = true;
456  ++nappl;
457  }
458  }
459  }
460  }
461 
462  if (nappl < newpos.size())
463  edm::LogError("Mismatch") << "Applied only " << nappl << " new positions"
464  << " out of " << newpos.size();
465 
466  LogDebug("NewPositions") << "Applied new positions for " << nappl << " out of " << alivec.size() << " alignables.";
467 }
uint32_t ID
Definition: Definitions.h:24
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
Log< level::Error, false > LogError
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Definition: Utilities.cc:185
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)=0
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
virtual std::vector< double > parameters() const =0
parameters - interpretation left to the concrete implementation
Log< level::Info, false > LogInfo
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
virtual int type() const =0
specific type, i.e. SurfaceDeformationFactory::Type
std::string surfaceDeformationTypeName(const Type &type)
Rot3< T > rot
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation *> > &) const =0
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
SurfaceDeformation * create(int type, const std::vector< double > &params)
#define LogDebug(id)

◆ applyAlignableRelativePositions()

void AlignmentParameterStore::applyAlignableRelativePositions ( const align::Alignables alivec,
const AlignableShifts shifts,
int &  ierr 
)

apply relative shifts to alignables

Definition at line 470 of file AlignmentParameterStore.cc.

References Alignable::addSurfaceDeformation(), Alignable::alignableObjectId(), SurfaceDeformationFactory::create(), isotrackApplyRegressor::dtype, newFWLiteAna::found, mps_fire::i, Alignable::id(), SurfaceDeformationFactory::kNoDeformations, LogDebug, Alignable::move(), SurfaceDeformation::parameters(), Alignable::rotateInGlobalFrame(), Alignable::surfaceDeformationIdPairs(), SurfaceDeformationFactory::surfaceDeformationTypeName(), and SurfaceDeformation::type().

472  {
473  ierr = 0;
474  unsigned int nappl = 0;
475  unsigned int nAlignables = alivec.size();
476 
477  for (unsigned int i = 0; i < nAlignables; ++i) {
478  Alignable* ali = alivec[i];
479 
480  align::ID id = ali->id();
481  align::StructureType typeId = ali->alignableObjectId();
482 
483  // Find corresponding entry in AlignableShifts
484  bool found = false;
485  for (AlignableShifts::const_iterator ipos = shifts.begin(); ipos != shifts.end(); ++ipos) {
486  if (id == ipos->id() && typeId == ipos->objId()) {
487  if (found) {
488  edm::LogError("DuplicatePosition") << "New positions for alignable found more than once!";
489  } else {
490  // Current surf. deformation
491  std::vector<std::pair<int, SurfaceDeformation*> > dold_id_pairs;
492  SurfaceDeformation* dold_obj = nullptr;
494  std::vector<double> dold;
495  if (1 == ali->surfaceDeformationIdPairs(dold_id_pairs)) { // might not have any...
496  dold_obj = dold_id_pairs[0].second;
497  dold = dold_obj->parameters();
499  }
500 
501  ali->move(ipos->pos());
502  ali->rotateInGlobalFrame(ipos->rot());
503 
504  const std::vector<double>& defDiff = ipos->deformationParameters();
505  // If an old surface deformation record exists, ensure that the added deformation has the same type and size.
506  if (!dold.empty() && dtype != SurfaceDeformationFactory::kNoDeformations && defDiff.size() == dold.size()) {
507  auto deform = SurfaceDeformationFactory::create(dtype, defDiff);
508  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterStore::applyAlignableRelativePositions"
509  << "Adding surface deformation of type "
511  (SurfaceDeformationFactory::Type)deform->type())
512  << ", size " << defDiff.size() << " and first element " << defDiff.at(0)
513  << " to alignable with id / type: " << id << " / " << typeId;
514  ali->addSurfaceDeformation(deform, true);
515  delete deform;
516  }
517  // In case no old surface deformation record exists, only ensure that the new surface deformation record has size>0. Size check is done elsewhere.
518  else if (!defDiff.empty()) {
519  auto deform = SurfaceDeformationFactory::create(defDiff);
520  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterStore::applyAlignableRelativePositions"
521  << "Setting surface deformation of type "
523  (SurfaceDeformationFactory::Type)deform->type())
524  << ", size " << defDiff.size() << " and first element " << defDiff.at(0)
525  << " to alignable with id / type: " << id << " / " << typeId;
526  ali->addSurfaceDeformation(deform, true); // Equivalent to setSurfaceDeformation in this case
527  delete deform;
528  }
529  // If there is no new surface deformation record, do nothing.
530 
531  // Add position error
532  //AlignmentPositionError ape(pnew.x(),pnew.y(),pnew.z());
533  //ali->addAlignmentPositionError(ape);
534  //ali->addAlignmentPositionErrorFromRotation(rnew);
535 
536  found = true;
537  ++nappl;
538  }
539  }
540  }
541  }
542 
543  if (nappl < shifts.size())
544  edm::LogError("Mismatch") << "Applied only " << nappl << " new positions"
545  << " out of " << shifts.size();
546 
547  LogDebug("NewPositions") << "Applied new positions for " << nappl << " alignables.";
548 }
uint32_t ID
Definition: Definitions.h:24
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
Log< level::Error, false > LogError
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)=0
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
virtual std::vector< double > parameters() const =0
parameters - interpretation left to the concrete implementation
Log< level::Info, false > LogInfo
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
virtual int type() const =0
specific type, i.e. SurfaceDeformationFactory::Type
std::string surfaceDeformationTypeName(const Type &type)
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation *> > &) const =0
SurfaceDeformation * create(int type, const std::vector< double > &params)
#define LogDebug(id)

◆ applyParameters() [1/2]

void AlignmentParameterStore::applyParameters ( void  )

Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.

apply all valid parameters to their alignables

Definition at line 255 of file AlignmentParameterStore.cc.

References theAlignables.

Referenced by CSCAlignmentCorrections::applyAlignment(), MuonAlignmentFromReference::fitAndAlign(), MillePedeAlignmentAlgorithm::initialize(), CSCChamberFitter::radiusCorrection(), MillePedeAlignmentAlgorithm::setParametersForRunRange(), and HIPAlignmentAlgorithm::terminate().

255  {
256  align::Alignables::const_iterator iali;
257  for (iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
258  applyParameters(*iali);
259 }
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
align::Alignables theAlignables
alignables

◆ applyParameters() [2/2]

void AlignmentParameterStore::applyParameters ( Alignable alignable)

apply parameters of a given alignable

Definition at line 262 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), AlignmentParameters::apply(), and Exception.

262  {
263  AlignmentParameters* pars = (alignable ? alignable->alignmentParameters() : nullptr);
264  if (!pars) {
265  throw cms::Exception("BadAlignable") << "applyParameters: provided alignable does not have alignment parameters";
266  }
267  pars->apply();
268 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
virtual void apply()=0
apply parameters to alignable

◆ attachAlignmentParameters() [1/2]

void AlignmentParameterStore::attachAlignmentParameters ( const align::Alignables alivec,
const Parameters parvec,
int &  ierr 
)

Attach alignment parameters to given alignables.

Definition at line 556 of file AlignmentParameterStore.cc.

References AlignmentParameters::alignable(), newFWLiteAna::found, and LogDebug.

Referenced by attachAlignmentParameters().

558  {
559  int ipass = 0;
560  int ifail = 0;
561  ierr = 0;
562 
563  // Iterate over alignables
564  for (align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali) {
565  // Iterate over Parameters
566  bool found = false;
567  for (Parameters::const_iterator ipar = parvec.begin(); ipar != parvec.end(); ++ipar) {
568  // Get new alignment parameters
569  AlignmentParameters* ap = *ipar;
570 
571  // Check if parameters belong to alignable
572  if (ap->alignable() == (*iali)) {
573  if (!found) {
574  (*iali)->setAlignmentParameters(ap);
575  ++ipass;
576  found = true;
577  } else
578  edm::LogError("Alignment") << "@SUB=AlignmentParameterStore::attachAlignmentParameters"
579  << "More than one parameters for Alignable.";
580  }
581  }
582  if (!found)
583  ++ifail;
584  }
585  if (ifail > 0)
586  ierr = -1;
587 
588  LogDebug("attachAlignmentParameters") << " Parameters, Alignables: " << parvec.size() << "," << alivec.size()
589  << "\n pass,fail: " << ipass << "," << ifail;
590 }
Alignable * alignable(void) const
Get pointer to corresponding alignable.
Log< level::Error, false > LogError
#define LogDebug(id)

◆ attachAlignmentParameters() [2/2]

void AlignmentParameterStore::attachAlignmentParameters ( const Parameters parvec,
int &  ierr 
)

Attach alignment parameters to alignables.

Definition at line 551 of file AlignmentParameterStore.cc.

References attachAlignmentParameters(), and theAlignables.

551  {
553 }
align::Alignables theAlignables
alignables
void attachAlignmentParameters(const align::Alignables &alivec, const Parameters &parvec, int &ierr)
Attach alignment parameters to given alignables.

◆ attachCorrelations() [1/2]

void AlignmentParameterStore::attachCorrelations ( const align::Alignables alivec,
const Correlations cormap,
bool  overwrite,
int &  ierr 
)

Attach correlations to given alignables.

Definition at line 598 of file AlignmentParameterStore.cc.

References AlignmentCorrelationsStore::correlationsAvailable(), spr::find(), LogDebug, AlignmentCorrelationsStore::setCorrelations(), and theCorrelationsStore.

Referenced by attachCorrelations().

601  {
602  ierr = 0;
603  int icount = 0;
604 
605  // Iterate over correlations
606  for (Correlations::const_iterator icor = cormap.begin(); icor != cormap.end(); ++icor) {
607  AlgebraicMatrix mat = (*icor).second;
608  Alignable* ali1 = (*icor).first.first;
609  Alignable* ali2 = (*icor).first.second;
610 
611  // Check if alignables exist
612  if (find(alivec.begin(), alivec.end(), ali1) != alivec.end() &&
613  find(alivec.begin(), alivec.end(), ali2) != alivec.end()) {
614  // Check if correlations already existing between these alignables
615  if (!theCorrelationsStore->correlationsAvailable(ali1, ali2) || (overwrite)) {
616  theCorrelationsStore->setCorrelations(ali1, ali2, mat);
617  ++icount;
618  } else
619  edm::LogInfo("AlreadyExists") << "Correlation existing and not overwritten";
620  } else
621  edm::LogInfo("IgnoreCorrelation") << "Ignoring correlation with no alignables!";
622  }
623 
624  LogDebug("attachCorrelations") << " Alignables,Correlations: " << alivec.size() << "," << cormap.size()
625  << "\n applied: " << icount;
626 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
virtual void setCorrelations(Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
CLHEP::HepMatrix AlgebraicMatrix
Log< level::Info, false > LogInfo
AlignmentCorrelationsStore * theCorrelationsStore
virtual bool correlationsAvailable(Alignable *ap1, Alignable *ap2) const
Check whether correlations are stored for a given pair of alignables.
#define LogDebug(id)

◆ attachCorrelations() [2/2]

void AlignmentParameterStore::attachCorrelations ( const Correlations cormap,
bool  overwrite,
int &  ierr 
)

Attach correlations to alignables.

Definition at line 593 of file AlignmentParameterStore.cc.

References attachCorrelations(), and theAlignables.

593  {
594  attachCorrelations(theAlignables, cormap, overwrite, ierr);
595 }
void attachCorrelations(const align::Alignables &alivec, const Correlations &cormap, bool overwrite, int &ierr)
Attach correlations to given alignables.
align::Alignables theAlignables
alignables

◆ attachUserVariables()

void AlignmentParameterStore::attachUserVariables ( const align::Alignables alivec,
const std::vector< AlignmentUserVariables *> &  uvarvec,
int &  ierr 
)

Attach User Variables to given alignables.

Definition at line 629 of file AlignmentParameterStore.cc.

References LogDebug, and AlignmentParameters::setUserVariables().

Referenced by HIPAlignmentAlgorithm::collector().

631  {
632  ierr = 0;
633 
634  LogDebug("DumpArguments") << "size of alivec: " << alivec.size() << "\nsize of uvarvec: " << uvarvec.size();
635 
636  std::vector<AlignmentUserVariables*>::const_iterator iuvar = uvarvec.begin();
637 
638  for (align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali, ++iuvar) {
639  AlignmentParameters* ap = (*iali)->alignmentParameters();
640  AlignmentUserVariables* uvarnew = (*iuvar);
641  ap->setUserVariables(uvarnew);
642  }
643 }
(Abstract) Base class for alignment algorithm user variables
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
#define LogDebug(id)

◆ cacheTransformations() [1/2]

void AlignmentParameterStore::cacheTransformations ( void  )

cache the current position, rotation and other parameters

Definition at line 303 of file AlignmentParameterStore.cc.

References theAlignables.

Referenced by MillePedeAlignmentAlgorithm::beginRun(), and MillePedeAlignmentAlgorithm::terminate().

303  {
304  align::Alignables::const_iterator iali;
305  for (iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
306  (*iali)->cacheTransformation();
307 }
align::Alignables theAlignables
alignables

◆ cacheTransformations() [2/2]

void AlignmentParameterStore::cacheTransformations ( const align::RunNumber run)

cache for the given run the current position, rotation and other parameters

Definition at line 310 of file AlignmentParameterStore.cc.

References writedatasetfile::run, and theAlignables.

310  {
311  for (const auto& iali : theAlignables)
312  iali->cacheTransformation(run);
313 }
align::Alignables theAlignables
alignables

◆ correlationsStore()

AlignmentCorrelationsStore* AlignmentParameterStore::correlationsStore ( void  ) const
inline

get full correlation map

Definition at line 56 of file AlignmentParameterStore.h.

References theCorrelationsStore.

56 { return theCorrelationsStore; }
AlignmentCorrelationsStore * theCorrelationsStore

◆ hierarchyConstraints()

bool AlignmentParameterStore::hierarchyConstraints ( const Alignable aliMaster,
const align::Alignables aliComps,
std::vector< std::vector< ParameterId > > &  paramIdsVecOut,
std::vector< std::vector< double > > &  factorsVecOut,
bool  all,
double  epsilon 
) const

Assuming aliMaster has (sub-)components aliComps with alignment parameters (cf. Alignable::firstParamComponents), paramIdsVecOut and factorsVecOut will be filled (in parallel) with constraints on the selected alignment parameters of aliMaster to get rid of the additionally introduced degrees of freedom: The 'vector product' of the parameters identified by ParameterId in std::vector<ParameterId> and the factors in std::vector<double> has to vanish (i.e. == 0.), |factor| < epsilon will be treated as 0. If all == false, skip constraint on aliMaster's degree of freedom 'i' if 'i'th alignment parameter of aliMaster is not selected, i.e. constrain only for otherwise doubled d.o.f. If all == true, produce one constraint for each of the aliMaster's parameters irrespective of whether they are selecte dor not. paramIdsVecOut and factorsVecOut contain exactly one std::vector per selected alignment parameter of aliMaster, but in principle these can be empty... Note that not all combinations of AlignmentParameters classes ar supported. If not there will be an exception (and false returned...)

Definition at line 680 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), python.cmstools::all(), APPROX_AVERAGING_CONSTRAINTS, geometryDiff::epsilon, Exception, HIERARCHY_CONSTRAINTS, ParametersToParametersDerivatives::isOK(), AlignmentParameters::selector(), and theTypeOfConstraints.

Referenced by PedeSteerer::hierarchyConstraint().

685  {
686  // Weak point if all = false:
687  // Ignores constraints between non-subsequent levels in case the parameter is not considered in
688  // the intermediate level, e.g. global z for dets and layers is aligned, but not for rods!
689  if (!ali || !ali->alignmentParameters())
690  return false;
691 
692  const std::vector<bool>& aliSel = ali->alignmentParameters()->selector();
693  paramIdsVecOut.clear();
694  factorsVecOut.clear();
695 
696  bool firstComp = true;
697  for (align::Alignables::const_iterator iComp = aliComps.begin(), iCompE = aliComps.end(); iComp != iCompE; ++iComp) {
698  const ParametersToParametersDerivatives p2pDerivs(**iComp, *ali);
699  if (!p2pDerivs.isOK()) {
700  // std::cerr << (*iComp)->alignmentParameters()->type() << " "
701  // << ali->alignmentParameters()->type() << std::endl;
702  throw cms::Exception("BadConfig") << "AlignmentParameterStore::hierarchyConstraints"
703  << " Bad match of types of AlignmentParameters classes.\n";
704  return false;
705  }
706  const std::vector<bool>& aliCompSel = (*iComp)->alignmentParameters()->selector();
707  for (unsigned int iParMast = 0, iParMastUsed = 0; iParMast < aliSel.size(); ++iParMast) {
708  if (!all && !aliSel[iParMast])
709  continue; // no higher level parameter & constraint deselected
710  if (firstComp) { // fill output with empty arrays
711  paramIdsVecOut.push_back(std::vector<ParameterId>());
712  factorsVecOut.push_back(std::vector<double>());
713  }
714  for (unsigned int iParComp = 0; iParComp < aliCompSel.size(); ++iParComp) {
715  if (aliCompSel[iParComp]) {
716  double factor = 0.;
718  // hierachy constraints
719  factor = p2pDerivs(iParMast, iParComp);
721  // CHK poor mans averaging constraints
722  factor = p2pDerivs(iParMast, iParComp);
723  if (iParMast < 3 && (iParComp % 9) >= 3)
724  factor = 0.;
725  }
726  if (fabs(factor) > epsilon) {
727  paramIdsVecOut[iParMastUsed].push_back(ParameterId(*iComp, iParComp));
728  factorsVecOut[iParMastUsed].push_back(factor);
729  }
730  }
731  }
732  ++iParMastUsed;
733  }
734  firstComp = false;
735  } // end loop on components
736 
737  return true;
738 }
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
std::pair< Alignable *, unsigned int > ParameterId
a single alignable parameter of an Alignable
TypeOfConstraints theTypeOfConstraints
type of constraints

◆ numCorrelations()

const unsigned int AlignmentParameterStore::numCorrelations ( void  ) const
inline

get number of correlations between alignables

Definition at line 59 of file AlignmentParameterStore.h.

References AlignmentCorrelationsStore::size(), and theCorrelationsStore.

59 { return theCorrelationsStore->size(); }
virtual unsigned int size(void) const
Get number of stored correlations.
AlignmentCorrelationsStore * theCorrelationsStore

◆ numObjects()

int AlignmentParameterStore::numObjects ( void  ) const
inline

returns number of alignables

Definition at line 53 of file AlignmentParameterStore.h.

References theAlignables.

53 { return theAlignables.size(); }
align::Alignables theAlignables
alignables

◆ resetParameters() [1/2]

void AlignmentParameterStore::resetParameters ( void  )

reset parameters, correlations, user variables

Definition at line 271 of file AlignmentParameterStore.cc.

References AlignmentCorrelationsStore::resetCorrelations(), theAlignables, and theCorrelationsStore.

Referenced by MillePedeAlignmentAlgorithm::initialize(), and MillePedeAlignmentAlgorithm::setParametersForRunRange().

271  {
272  // Erase contents of correlation map
274 
275  // Iterate over alignables in the store and reset parameters
276  align::Alignables::const_iterator iali;
277  for (iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
278  resetParameters(*iali);
279 }
void resetParameters(void)
reset parameters, correlations, user variables
virtual void resetCorrelations(void)
Reset correlations.
align::Alignables theAlignables
alignables
AlignmentCorrelationsStore * theCorrelationsStore

◆ resetParameters() [2/2]

void AlignmentParameterStore::resetParameters ( Alignable ali)

reset parameters of a given alignable

Definition at line 282 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), AlignmentParameters::cloneFromSelected(), AlignmentParameters::numSelected(), Alignable::setAlignmentParameters(), and AlignmentParameters::setValid().

282  {
283  if (ali) {
284  // Get alignment parameters for this alignable
286  if (ap) {
287  int npar = ap->numSelected();
288 
289  AlgebraicVector par(npar, 0);
290  AlgebraicSymMatrix cov(npar, 0);
291  AlignmentParameters* apnew = ap->cloneFromSelected(par, cov);
292  ali->setAlignmentParameters(apnew);
293  apnew->setValid(false);
294  } else
295  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore::resetParameters"
296  << "alignable has no alignment parameter";
297  } else
298  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore::resetParameters"
299  << "argument is NULL";
300 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
Log< level::Error, false > LogError
int numSelected(void) const
Get number of selected parameters.
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:123
void setValid(bool v)
Set validity flag.
CLHEP::HepVector AlgebraicVector
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0

◆ restoreCachedTransformations() [1/2]

void AlignmentParameterStore::restoreCachedTransformations ( void  )

restore the previously cached position, rotation and other parameters

Definition at line 316 of file AlignmentParameterStore.cc.

References theAlignables.

Referenced by MillePedeAlignmentAlgorithm::setParametersForRunRange(), and MillePedeAlignmentAlgorithm::terminate().

316  {
317  align::Alignables::const_iterator iali;
318  for (iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
319  (*iali)->restoreCachedTransformation();
320 }
align::Alignables theAlignables
alignables

◆ restoreCachedTransformations() [2/2]

void AlignmentParameterStore::restoreCachedTransformations ( const align::RunNumber run)

restore for the given run the previously cached position, rotation and other parameters

Definition at line 323 of file AlignmentParameterStore.cc.

References writedatasetfile::run, and theAlignables.

323  {
324  for (const auto& iali : theAlignables)
325  iali->restoreCachedTransformation(run);
326 }
align::Alignables theAlignables
alignables

◆ selectParameters() [1/3]

CompositeAlignmentParameters AlignmentParameterStore::selectParameters ( const std::vector< AlignableDet *> &  alignabledets) const

select parameters (for backward compatibility, use with vector<AlignableDetOrUnitPtr> as argument instead)

Definition at line 65 of file AlignmentParameterStore.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

Referenced by HIPAlignmentAlgorithm::run().

66  {
67  std::vector<AlignableDetOrUnitPtr> detOrUnits;
68  detOrUnits.reserve(alignabledets.size());
69 
70  std::vector<AlignableDet*>::const_iterator it, iEnd;
71  for (it = alignabledets.begin(), iEnd = alignabledets.end(); it != iEnd; ++it)
72  detOrUnits.push_back(AlignableDetOrUnitPtr(*it));
73 
74  return this->selectParameters(detOrUnits);
75 }
CompositeAlignmentParameters selectParameters(const std::vector< AlignableDet *> &alignabledets) const

◆ selectParameters() [2/3]

CompositeAlignmentParameters AlignmentParameterStore::selectParameters ( const std::vector< AlignableDetOrUnitPtr > &  alignabledets) const

select parameters

Definition at line 78 of file AlignmentParameterStore.cc.

References alignableFromAlignableDet(), alignables(), Alignable::alignmentParameters(), AlignmentCorrelationsStore::correlations(), data, spr::find(), AlignmentParameters::numSelected(), AlignmentParameters::selectedCovariance(), AlignmentParameters::selectedParameters(), and theCorrelationsStore.

79  {
81  std::map<AlignableDetOrUnitPtr, Alignable*> alidettoalimap;
82  std::map<Alignable*, int> aliposmap;
83  std::map<Alignable*, int> alilenmap;
84  int nparam = 0;
85 
86  // iterate over AlignableDet's
87  for (std::vector<AlignableDetOrUnitPtr>::const_iterator iad = alignabledets.begin(); iad != alignabledets.end();
88  ++iad) {
90  if (ali) {
91  alidettoalimap[*iad] = ali; // Add to map
92  // Check if Alignable already there, insert into vector if not
93  if (find(alignables.begin(), alignables.end(), ali) == alignables.end()) {
94  alignables.push_back(ali);
96  nparam += ap->numSelected();
97  }
98  }
99  }
100 
101  AlgebraicVector* selpar = new AlgebraicVector(nparam, 0);
102  AlgebraicSymMatrix* selcov = new AlgebraicSymMatrix(nparam, 0);
103 
104  // Fill in parameters and corresponding covariance matricess
105  int ipos = 1; // NOTE: .sub indices start from 1
106  align::Alignables::const_iterator it1;
107  for (it1 = alignables.begin(); it1 != alignables.end(); ++it1) {
108  AlignmentParameters* ap = (*it1)->alignmentParameters();
109  selpar->sub(ipos, ap->selectedParameters());
110  selcov->sub(ipos, ap->selectedCovariance());
111  int npar = ap->numSelected();
112  aliposmap[*it1] = ipos;
113  alilenmap[*it1] = npar;
114  ipos += npar;
115  }
116 
117  // Fill in the correlations. Has to be an extra loop, because the
118  // AlignmentExtendedCorrelationsStore (if used) needs the
119  // alignables' covariance matrices already present.
120  ipos = 1;
121  for (it1 = alignables.begin(); it1 != alignables.end(); ++it1) {
122  int jpos = 1;
123 
124  // Look for correlations between alignables
125  align::Alignables::const_iterator it2;
126  for (it2 = alignables.begin(); it2 != it1; ++it2) {
127  theCorrelationsStore->correlations(*it1, *it2, *selcov, ipos - 1, jpos - 1);
128  jpos += (*it2)->alignmentParameters()->numSelected();
129  }
130 
131  ipos += (*it1)->alignmentParameters()->numSelected();
132  }
133 
135  CompositeAlignmentParameters aap(data, alignables, alidettoalimap, aliposmap, alilenmap);
136 
137  return aap;
138 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
const align::Alignables & alignables(void) const
get all alignables
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int numSelected(void) const
Get number of selected parameters.
AlgebraicVector selectedParameters(void) const
Get selected parameters.
virtual void correlations(Alignable *ap1, Alignable *ap2, AlgebraicSymMatrix &cov, int row, int col) const
Alignable * alignableFromAlignableDet(const AlignableDetOrUnitPtr &alignableDet) const
Obsolete: Use AlignableNavigator::alignableDetFromGeomDet and alignableFromAlignableDet.
CLHEP::HepVector AlgebraicVector
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
AlignmentCorrelationsStore * theCorrelationsStore
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
CLHEP::HepSymMatrix AlgebraicSymMatrix
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.

◆ selectParameters() [3/3]

CompositeAlignmentParameters AlignmentParameterStore::selectParameters ( const align::Alignables alignables) const

select parameters

Definition at line 141 of file AlignmentParameterStore.cc.

References alignables(), AlignmentCorrelationsStore::correlations(), data, spr::find(), AlignmentParameters::numSelected(), AlignmentParameters::selectedCovariance(), AlignmentParameters::selectedParameters(), and theCorrelationsStore.

141  {
142  align::Alignables selectedAlignables;
143  std::map<AlignableDetOrUnitPtr, Alignable*> alidettoalimap; // This map won't be filled!!!
144  std::map<Alignable*, int> aliposmap;
145  std::map<Alignable*, int> alilenmap;
146  int nparam = 0;
147 
148  // iterate over Alignable's
149  align::Alignables::const_iterator ita;
150  for (ita = alignables.begin(); ita != alignables.end(); ++ita) {
151  // Check if Alignable already there, insert into vector if not
152  if (find(selectedAlignables.begin(), selectedAlignables.end(), *ita) == selectedAlignables.end()) {
153  selectedAlignables.push_back(*ita);
154  AlignmentParameters* ap = (*ita)->alignmentParameters();
155  nparam += ap->numSelected();
156  }
157  }
158 
159  AlgebraicVector* selpar = new AlgebraicVector(nparam, 0);
160  AlgebraicSymMatrix* selcov = new AlgebraicSymMatrix(nparam, 0);
161 
162  // Fill in parameters and corresponding covariance matrices
163  int ipos = 1; // NOTE: .sub indices start from 1
164  align::Alignables::const_iterator it1;
165  for (it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1) {
166  AlignmentParameters* ap = (*it1)->alignmentParameters();
167  selpar->sub(ipos, ap->selectedParameters());
168  selcov->sub(ipos, ap->selectedCovariance());
169  int npar = ap->numSelected();
170  aliposmap[*it1] = ipos;
171  alilenmap[*it1] = npar;
172  ipos += npar;
173  }
174 
175  // Fill in the correlations. Has to be an extra loop, because the
176  // AlignmentExtendedCorrelationsStore (if used) needs the
177  // alignables' covariance matrices already present.
178  ipos = 1;
179  for (it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1) {
180  int jpos = 1;
181 
182  // Look for correlations between alignables
183  align::Alignables::const_iterator it2;
184  for (it2 = selectedAlignables.begin(); it2 != it1; ++it2) {
185  theCorrelationsStore->correlations(*it1, *it2, *selcov, ipos - 1, jpos - 1);
186  jpos += (*it2)->alignmentParameters()->numSelected();
187  }
188 
189  ipos += (*it1)->alignmentParameters()->numSelected();
190  }
191 
193  CompositeAlignmentParameters aap(data, selectedAlignables, alidettoalimap, aliposmap, alilenmap);
194 
195  return aap;
196 }
const align::Alignables & alignables(void) const
get all alignables
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int numSelected(void) const
Get number of selected parameters.
AlgebraicVector selectedParameters(void) const
Get selected parameters.
virtual void correlations(Alignable *ap1, Alignable *ap2, AlgebraicSymMatrix &cov, int row, int col) const
CLHEP::HepVector AlgebraicVector
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
AlignmentCorrelationsStore * theCorrelationsStore
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
CLHEP::HepSymMatrix AlgebraicSymMatrix
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.

◆ setAlignmentPositionError()

void AlignmentParameterStore::setAlignmentPositionError ( const align::Alignables alivec,
double  valshift,
double  valrot 
)

Set Alignment position error.

Definition at line 646 of file AlignmentParameterStore.cc.

References Alignable::addAlignmentPositionError(), Alignable::addAlignmentPositionErrorFromRotation(), mps_fire::i, LogDebug, alignCSCRings::r, Alignable::setAlignmentPositionError(), and align::toMatrix().

Referenced by MuonAlignmentFromReference::fitAndAlign(), MuonAlignmentFromReference::initialize(), and HIPAlignmentAlgorithm::setAlignmentPositionError().

648  {
649  unsigned int nAlignables = alivec.size();
650 
651  for (unsigned int i = 0; i < nAlignables; ++i) {
652  Alignable* ali = alivec[i];
653 
654  // First reset APE
655  AlignmentPositionError nulApe(0, 0, 0);
656  ali->setAlignmentPositionError(nulApe, true);
657 
658  // Set APE from displacement
659  AlignmentPositionError ape(valshift, valshift, valshift);
660  if (valshift > 0.)
661  ali->addAlignmentPositionError(ape, true);
662  else
663  ali->setAlignmentPositionError(ape, true);
664  // GF: Resetting and setting as above does not really make sense to me,
665  // and adding to zero or setting is the same! I'd just do
666  //ali->setAlignmentPositionError(AlignmentPositionError ape(valshift,valshift,valshift),true);
667 
668  // Set APE from rotation
670  r(1) = valrot;
671  r(2) = valrot;
672  r(3) = valrot;
674  }
675 
676  LogDebug("StoreAPE") << "Store APE from shift: " << valshift << "\nStore APE from rotation: " << valrot;
677 }
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rotation, bool propagateDown)=0
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)=0
virtual void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)=0
Set the alignment position error - if (!propagateDown) do not affect daughters.
AlgebraicVector EulerAngles
Definition: Definitions.h:34
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:34
#define LogDebug(id)

◆ typeAndLayer()

std::pair< int, int > AlignmentParameterStore::typeAndLayer ( const Alignable ali,
const TrackerTopology tTopo 
) const

Obtain type and layer from Alignable.

Definition at line 368 of file AlignmentParameterStore.cc.

References Alignable::id(), and TrackerAlignableId::typeAndLayerFromDetId().

Referenced by HIPAlignmentAlgorithm::fillAlignablesMonitor(), and HIPAlignmentAlgorithm::terminate().

368  {
369  return TrackerAlignableId().typeAndLayerFromDetId(ali->id(), tTopo);
370 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const

◆ updateParameters()

void AlignmentParameterStore::updateParameters ( const CompositeAlignmentParameters aap,
bool  updateCorrelations = true 
)

update parameters

Definition at line 199 of file AlignmentParameterStore.cc.

References alignables(), AlignmentParameters::cloneFromSelected(), CompositeAlignmentParameters::components(), CompositeAlignmentParameters::covariance(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, AlignmentParameters::numSelected(), CompositeAlignmentParameters::parameters(), AlignmentCorrelationsStore::setCorrelations(), and theCorrelationsStore.

199  {
201  const AlgebraicVector& parameters = aap.parameters();
202  const AlgebraicSymMatrix& covariance = aap.covariance();
203 
204  int ipos = 1; // NOTE: .sub indices start from 1
205 
206  // Loop over alignables
207  for (align::Alignables::const_iterator it = alignables.begin(); it != alignables.end(); ++it) {
208  // Update parameters and local covariance
209  AlignmentParameters* ap = (*it)->alignmentParameters();
210  int nsel = ap->numSelected();
211  AlgebraicVector subvec = parameters.sub(ipos, ipos + nsel - 1);
212  AlgebraicSymMatrix subcov = covariance.sub(ipos, ipos + nsel - 1);
213  AlignmentParameters* apnew = ap->cloneFromSelected(subvec, subcov);
214  (*it)->setAlignmentParameters(apnew);
215 
216  // Now update correlations between detectors
217  if (updateCorrelations) {
218  int jpos = 1;
219  for (align::Alignables::const_iterator it2 = alignables.begin(); it2 != it; ++it2) {
220  theCorrelationsStore->setCorrelations(*it, *it2, covariance, ipos - 1, jpos - 1);
221  jpos += (*it2)->alignmentParameters()->numSelected();
222  }
223  }
224 
225  ipos += nsel;
226  }
227 }
const AlgebraicVector & parameters() const
Get alignment parameters.
const align::Alignables & alignables(void) const
get all alignables
int numSelected(void) const
Get number of selected parameters.
const AlgebraicSymMatrix & covariance() const
Get parameter covariance matrix.
virtual void setCorrelations(Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
CLHEP::HepVector AlgebraicVector
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
AlignmentCorrelationsStore * theCorrelationsStore
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Components components() const
Get vector of alignable components.

◆ validAlignables()

align::Alignables AlignmentParameterStore::validAlignables ( void  ) const

get all alignables with valid parameters

Definition at line 230 of file AlignmentParameterStore.cc.

References LogDebug, mps_fire::result, and theAlignables.

230  {
232  for (align::Alignables::const_iterator iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
233  if ((*iali)->alignmentParameters()->isValid())
234  result.push_back(*iali);
235 
236  LogDebug("Alignment") << "@SUB=AlignmentParameterStore::validAlignables"
237  << "Valid alignables: " << result.size() << "out of " << theAlignables.size();
238  return result;
239 }
align::Alignables theAlignables
alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
#define LogDebug(id)

Member Data Documentation

◆ theAlignables

align::Alignables AlignmentParameterStore::theAlignables
private

◆ theCorrelationsStore

AlignmentCorrelationsStore* AlignmentParameterStore::theCorrelationsStore
protected

◆ theTypeOfConstraints

TypeOfConstraints AlignmentParameterStore::theTypeOfConstraints
private

type of constraints

Definition at line 164 of file AlignmentParameterStore.h.

Referenced by AlignmentParameterStore(), and hierarchyConstraints().