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 std::vector< Alignable * > &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 21 of file AlignmentParameterStore.h.

Member Typedef Documentation

Definition at line 27 of file AlignmentParameterStore.h.

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

Definition at line 28 of file AlignmentParameterStore.h.

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

a single alignable parameter of an Alignable

Definition at line 134 of file AlignmentParameterStore.h.

Definition at line 26 of file AlignmentParameterStore.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

constructor

Definition at line 26 of file AlignmentParameterStore.cc.

References APPROX_AVERAGING_CONSTRAINTS, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), HIERARCHY_CONSTRAINTS, NONE, AlCaHLTBitMon_QueryRunRegistry::string, theAlignables, theCorrelationsStore, and theTypeOfConstraints.

27  :
28  theAlignables(alis)
29 {
30  if (config.getUntrackedParameter<bool>("UseExtendedCorrelations")) {
32  (config.getParameter<edm::ParameterSet>("ExtendedCorrelationsConfig"));
33  } else {
35  }
36 
37  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterStore"
38  << "Created with " << theAlignables.size() << " alignables.";
39 
40  // set hierarchy vs averaging constraints
42  const std::string cfgStrTypeOfConstraints(config.getParameter<std::string>("TypeOfConstraints"));
43  if( cfgStrTypeOfConstraints == "hierarchy" ) {
45  } else if( cfgStrTypeOfConstraints == "approximate_averaging" ) {
47  edm::LogWarning("Alignment") << "@SUB=AlignmentParameterStore"
48  << "\n\n\n******* WARNING ******************************************\n"
49  << "Using approximate implementation of averaging constraints."
50  << "This is not recommended."
51  << "Consider to use 'hierarchy' constraints:"
52  << " AlignmentProducer.ParameterStore.TypeOfConstraints = cms.string('hierarchy')\n\n\n";
53  } else {
54  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore"
55  << "Unknown type of hierarchy constraints '" << cfgStrTypeOfConstraints << "'";
56  }
57 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
TypeOfConstraints theTypeOfConstraints
type of constraints
align::Alignables theAlignables
alignables
AlignmentCorrelationsStore * theCorrelationsStore
AlignmentParameterStore::~AlignmentParameterStore ( )
virtual

destructor

Definition at line 60 of file AlignmentParameterStore.cc.

References theCorrelationsStore.

61 {
62  delete theCorrelationsStore;
63 }
AlignmentCorrelationsStore * theCorrelationsStore

Member Function Documentation

void AlignmentParameterStore::acquireRelativeParameters ( void  )

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

Definition at line 378 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().

379 {
380 
381  unsigned int nAlignables = theAlignables.size();
382 
383  for (unsigned int i = 0; i < nAlignables; ++i)
384  {
385  Alignable* ali = theAlignables[i];
386 
388  dynamic_cast<RigidBodyAlignmentParameters*>( ali->alignmentParameters() );
389 
390  if ( !ap )
391  throw cms::Exception("BadAlignable")
392  << "acquireRelativeParameters: "
393  << "provided alignable does not have rigid body alignment parameters";
394 
395  AlgebraicVector par( ap->size(),0 );
396  AlgebraicSymMatrix cov( ap->size(), 0 );
397 
398  // Get displacement and transform global->local
399  align::LocalVector dloc = ali->surface().toLocal( ali->displacement() );
400  par[0]=dloc.x();
401  par[1]=dloc.y();
402  par[2]=dloc.z();
403 
404  // Transform to local euler angles
405  align::EulerAngles euloc = align::toAngles( ali->surface().toLocal( ali->rotation() ) );
406  par[3]=euloc(1);
407  par[4]=euloc(2);
408  par[5]=euloc(3);
409 
410  // Clone parameters
411  RigidBodyAlignmentParameters* apnew = ap->clone(par,cov);
412 
413  ali->setAlignmentParameters(apnew);
414  }
415 }
T y() const
Cartesian y coordinate.
virtual RigidBodyAlignmentParameters * clone(const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const
Clone all parameters (for update of parameters)
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:144
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
Basic3DVector< T > x() const
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:147
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:129
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:9
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
int size(void) const
Get number of parameters.
align::Alignables theAlignables
alignables
CLHEP::HepSymMatrix AlgebraicSymMatrix
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 271 of file AlignmentParameterStore.cc.

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

Referenced by selectParameters().

272 {
273  AlignableDetOrUnitPtr alignableDet = _alignableDet;
274  Alignable *mother = alignableDet;
275  while (mother) {
276  if (mother->alignmentParameters()) return mother;
277  mother = mother->mother();
278  }
279 
280  return 0;
281 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:94
const align::Alignables& AlignmentParameterStore::alignables ( void  ) const
inline
void AlignmentParameterStore::applyAlignableAbsolutePositions ( const align::Alignables alis,
const AlignablePositions newpos,
int &  ierr 
)

apply absolute positions to alignables

Definition at line 431 of file AlignmentParameterStore.cc.

References Alignable::alignableObjectId(), applyAlignableRelativePositions(), runEdmFileComparison::found, Alignable::globalPosition(), Alignable::globalRotation(), Alignable::id(), LogDebug, Alignable::move(), TkRotation< T >::multiplyInverse(), align::rectify(), TkRotation< T >::rot, and Alignable::rotateInGlobalFrame().

Referenced by HIPAlignmentAlgorithm::startNewLoop(), and typeAndLayer().

434 {
435  unsigned int nappl=0;
436  ierr=0;
437 
438  // Iterate over list of alignables
439  for (align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali) {
440  Alignable* ali = *iali;
441  align::ID id = ali->id();
442  align::StructureType typeId = ali->alignableObjectId();
443 
444  // Find corresponding entry in AlignablePositions
445  bool found=false;
446  for (AlignablePositions::const_iterator ipos = newpos.begin(); ipos != newpos.end(); ++ipos) {
447  if (id == ipos->id() && typeId == ipos->objId()) {
448  if (found) {
449  edm::LogError("DuplicatePosition")
450  << "New positions for alignable found more than once!";
451  } else {
452  // New position/rotation
453  const align::PositionType& pnew = ipos->pos();
454  const align::RotationType& rnew = ipos->rot();
455  // Current position / rotation
456  const align::PositionType& pold = ali->globalPosition();
457  const align::RotationType& rold = ali->globalRotation();
458 
459  // shift needed to move from current to new position
460  align::GlobalVector posDiff = pnew - pold;
461  align::RotationType rotDiff = rold.multiplyInverse(rnew);
462  align::rectify(rotDiff); // correct for rounding errors
463  ali->move( posDiff );
464  ali->rotateInGlobalFrame( rotDiff );
465  LogDebug("NewPosition") << "moving by:" << posDiff;
466  LogDebug("NewRotation") << "rotating by:\n" << rotDiff;
467 
468  // add position error
469  // AlignmentPositionError ape(shift.x(),shift.y(),shift.z());
470  // (*iali)->addAlignmentPositionError(ape);
471  // (*iali)->addAlignmentPositionErrorFromRotation(rot);
472 
473  found=true;
474  ++nappl;
475  }
476  }
477  }
478  }
479 
480  if ( nappl< newpos.size() )
481  edm::LogError("Mismatch") << "Applied only " << nappl << " new positions"
482  << " out of " << newpos.size();
483 
484  LogDebug("NewPositions") << "Applied new positions for " << nappl
485  << " out of " << alivec.size() <<" alignables.";
486 
487 }
#define LogDebug(id)
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
uint32_t ID
Definition: Definitions.h:26
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:141
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Definition: Utilities.cc:198
Rot3< T > rot
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:138
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
void AlignmentParameterStore::applyAlignableRelativePositions ( const align::Alignables alivec,
const AlignableShifts shifts,
int &  ierr 
)

apply relative shifts to alignables

Definition at line 492 of file AlignmentParameterStore.cc.

References Alignable::alignableObjectId(), runEdmFileComparison::found, mps_fire::i, Alignable::id(), LogDebug, Alignable::move(), and Alignable::rotateInGlobalFrame().

Referenced by applyAlignableAbsolutePositions().

493 {
494 
495  ierr=0;
496  unsigned int nappl=0;
497  unsigned int nAlignables = alivec.size();
498 
499  for (unsigned int i = 0; i < nAlignables; ++i) {
500  Alignable* ali = alivec[i];
501 
502  align::ID id = ali->id();
503  align::StructureType typeId = ali->alignableObjectId();
504 
505  // Find corresponding entry in AlignableShifts
506  bool found = false;
507  for (AlignableShifts::const_iterator ipos = shifts.begin(); ipos != shifts.end(); ++ipos) {
508  if (id == ipos->id() && typeId == ipos->objId()) {
509  if (found) {
510  edm::LogError("DuplicatePosition")
511  << "New positions for alignable found more than once!";
512  } else {
513  ali->move( ipos->pos() );
514  ali->rotateInGlobalFrame( ipos->rot() );
515 
516  // Add position error
517  //AlignmentPositionError ape(pnew.x(),pnew.y(),pnew.z());
518  //ali->addAlignmentPositionError(ape);
519  //ali->addAlignmentPositionErrorFromRotation(rnew);
520 
521  found=true;
522  ++nappl;
523  }
524  }
525  }
526  }
527 
528  if ( nappl < shifts.size() )
529  edm::LogError("Mismatch") << "Applied only " << nappl << " new positions"
530  << " out of " << shifts.size();
531 
532  LogDebug("NewPositions") << "Applied new positions for " << nappl << " alignables.";
533 }
#define LogDebug(id)
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
uint32_t ID
Definition: Definitions.h:26
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
void AlignmentParameterStore::applyParameters ( void  )

Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.

apply all valid parameters to their alignables

Definition at line 284 of file AlignmentParameterStore.cc.

References theAlignables.

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

285 {
286  align::Alignables::const_iterator iali;
287  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
288  applyParameters( *iali );
289 }
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
align::Alignables theAlignables
alignables
void AlignmentParameterStore::applyParameters ( Alignable alignable)

apply parameters of a given alignable

Definition at line 293 of file AlignmentParameterStore.cc.

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

294 {
295 
296  AlignmentParameters *pars = (alignable ? alignable->alignmentParameters() : 0);
297  if (!pars) {
298  throw cms::Exception("BadAlignable")
299  << "applyParameters: provided alignable does not have alignment parameters";
300  }
301  pars->apply();
302 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
virtual void apply()=0
apply parameters to alignable
void AlignmentParameterStore::attachAlignmentParameters ( const align::Alignables alivec,
const Parameters parvec,
int &  ierr 
)

Attach alignment parameters to given alignables.

Definition at line 546 of file AlignmentParameterStore.cc.

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

Referenced by attachAlignmentParameters().

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

Attach alignment parameters to alignables.

Definition at line 538 of file AlignmentParameterStore.cc.

References attachAlignmentParameters(), and theAlignables.

539 {
541 }
align::Alignables theAlignables
alignables
void attachAlignmentParameters(const align::Alignables &alivec, const Parameters &parvec, int &ierr)
Attach alignment parameters to given alignables.
void AlignmentParameterStore::attachCorrelations ( const align::Alignables alivec,
const Correlations cormap,
bool  overwrite,
int &  ierr 
)

Attach correlations to given alignables.

Definition at line 594 of file AlignmentParameterStore.cc.

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

Referenced by attachCorrelations().

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

Attach correlations to alignables.

Definition at line 586 of file AlignmentParameterStore.cc.

References attachCorrelations(), and theAlignables.

588 {
589  attachCorrelations( theAlignables, cormap, overwrite, ierr );
590 }
void attachCorrelations(const align::Alignables &alivec, const Correlations &cormap, bool overwrite, int &ierr)
Attach correlations to given alignables.
align::Alignables theAlignables
alignables
void AlignmentParameterStore::attachUserVariables ( const align::Alignables alivec,
const std::vector< AlignmentUserVariables * > &  uvarvec,
int &  ierr 
)

Attach User Variables to given alignables.

Definition at line 631 of file AlignmentParameterStore.cc.

References LogDebug, and AlignmentParameters::setUserVariables().

Referenced by attachCorrelations(), and HIPAlignmentAlgorithm::collector().

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

cache the current position, rotation and other parameters

Definition at line 346 of file AlignmentParameterStore.cc.

References theAlignables.

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

347 {
348  align::Alignables::const_iterator iali;
349  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
350  (*iali)->cacheTransformation();
351 }
align::Alignables theAlignables
alignables
void AlignmentParameterStore::cacheTransformations ( const align::RunNumber run)

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

Definition at line 355 of file AlignmentParameterStore.cc.

References theAlignables.

356 {
357  for (const auto& iali: theAlignables) iali->cacheTransformation(run);
358 }
align::Alignables theAlignables
alignables
AlignmentCorrelationsStore* AlignmentParameterStore::correlationsStore ( void  ) const
inline

get full correlation map

Definition at line 60 of file AlignmentParameterStore.h.

60 { return theCorrelationsStore; }
AlignmentCorrelationsStore * theCorrelationsStore
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 684 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), APPROX_AVERAGING_CONSTRAINTS, Exception, HIERARCHY_CONSTRAINTS, ParametersToParametersDerivatives::isOK(), AlignmentParameters::selector(), and theTypeOfConstraints.

Referenced by PedeSteerer::hierarchyConstraint(), and setAlignmentPositionError().

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

get number of correlations between alignables

Definition at line 63 of file AlignmentParameterStore.h.

63 { return theCorrelationsStore->size(); }
virtual unsigned int size(void) const
Get number of stored correlations.
AlignmentCorrelationsStore * theCorrelationsStore
int AlignmentParameterStore::numObjects ( void  ) const
inline

returns number of alignables

Definition at line 57 of file AlignmentParameterStore.h.

57 { return theAlignables.size(); }
align::Alignables theAlignables
alignables
void AlignmentParameterStore::resetParameters ( void  )

reset parameters, correlations, user variables

Definition at line 306 of file AlignmentParameterStore.cc.

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

Referenced by MillePedeAlignmentAlgorithm::setParametersForRunRange().

307 {
308  // Erase contents of correlation map
310 
311  // Iterate over alignables in the store and reset parameters
312  align::Alignables::const_iterator iali;
313  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali )
314  resetParameters( *iali );
315 }
void resetParameters(void)
reset parameters, correlations, user variables
virtual void resetCorrelations(void)
Reset correlations.
align::Alignables theAlignables
alignables
AlignmentCorrelationsStore * theCorrelationsStore
void AlignmentParameterStore::resetParameters ( Alignable ali)

reset parameters of a given alignable

Definition at line 319 of file AlignmentParameterStore.cc.

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

320 {
321  if ( ali )
322  {
323  // Get alignment parameters for this alignable
325  if ( ap )
326  {
327  int npar=ap->numSelected();
328 
329  AlgebraicVector par(npar,0);
330  AlgebraicSymMatrix cov(npar,0);
331  AlignmentParameters* apnew = ap->cloneFromSelected(par,cov);
332  ali->setAlignmentParameters(apnew);
333  apnew->setValid(false);
334  }
335  else
336  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore::resetParameters"
337  << "alignable has no alignment parameter";
338  }
339  else
340  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore::resetParameters"
341  << "argument is NULL";
342 }
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:129
void setValid(bool v)
Set validity flag.
int numSelected(void) const
Get number of selected parameters.
CLHEP::HepVector AlgebraicVector
CLHEP::HepSymMatrix AlgebraicSymMatrix
void AlignmentParameterStore::restoreCachedTransformations ( void  )

restore the previously cached position, rotation and other parameters

Definition at line 362 of file AlignmentParameterStore.cc.

References theAlignables.

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

363 {
364  align::Alignables::const_iterator iali;
365  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
366  (*iali)->restoreCachedTransformation();
367 }
align::Alignables theAlignables
alignables
void AlignmentParameterStore::restoreCachedTransformations ( const align::RunNumber run)

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

Definition at line 371 of file AlignmentParameterStore.cc.

References theAlignables.

372 {
373  for (const auto& iali: theAlignables) iali->restoreCachedTransformation(run);
374 }
align::Alignables theAlignables
alignables
CompositeAlignmentParameters AlignmentParameterStore::selectParameters ( const std::vector< AlignableDet * > &  alignabledets) const

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

Definition at line 67 of file AlignmentParameterStore.cc.

Referenced by MuonMillepedeAlgorithm::run(), HIPAlignmentAlgorithm::run(), and selectParameters().

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

select parameters

Definition at line 81 of file AlignmentParameterStore.cc.

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

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

select parameters

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

Set Alignment position error.

Definition at line 651 of file AlignmentParameterStore.cc.

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

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

653 {
654  unsigned int nAlignables = alivec.size();
655 
656  for (unsigned int i = 0; i < nAlignables; ++i)
657  {
658  Alignable* ali = alivec[i];
659 
660  // First reset APE
661  AlignmentPositionError nulApe(0,0,0);
662  ali->setAlignmentPositionError(nulApe, true);
663 
664  // Set APE from displacement
665  AlignmentPositionError ape(valshift,valshift,valshift);
666  if ( valshift > 0. ) ali->addAlignmentPositionError(ape, true);
667  else ali->setAlignmentPositionError(ape, true);
668  // GF: Resetting and setting as above does not really make sense to me,
669  // and adding to zero or setting is the same! I'd just do
670  //ali->setAlignmentPositionError(AlignmentPositionError ape(valshift,valshift,valshift),true);
671 
672  // Set APE from rotation
674  r(1)=valrot; r(2)=valrot; r(3)=valrot;
676  }
677 
678  LogDebug("StoreAPE") << "Store APE from shift: " << valshift
679  << "\nStore APE from rotation: " << valrot;
680 }
#define LogDebug(id)
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:36
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:42
std::pair< int, int > AlignmentParameterStore::typeAndLayer ( const Alignable ali,
const TrackerTopology tTopo 
) const

Obtain type and layer from Alignable.

Definition at line 423 of file AlignmentParameterStore.cc.

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

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

424 {
425  return TrackerAlignableId().typeAndLayerFromDetId( ali->id(), tTopo );
426 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const
void AlignmentParameterStore::updateParameters ( const CompositeAlignmentParameters aap,
bool  updateCorrelations = true 
)

update parameters

Definition at line 219 of file AlignmentParameterStore.cc.

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

220 {
221 
223  const AlgebraicVector& parameters = aap.parameters();
224  const AlgebraicSymMatrix& covariance = aap.covariance();
225 
226  int ipos = 1; // NOTE: .sub indices start from 1
227 
228  // Loop over alignables
229  for( align::Alignables::const_iterator it=alignables.begin(); it != alignables.end(); ++it )
230  {
231  // Update parameters and local covariance
232  AlignmentParameters* ap = (*it)->alignmentParameters();
233  int nsel = ap->numSelected();
234  AlgebraicVector subvec = parameters.sub( ipos, ipos+nsel-1 );
235  AlgebraicSymMatrix subcov = covariance.sub( ipos, ipos+nsel-1 );
236  AlignmentParameters* apnew = ap->cloneFromSelected( subvec, subcov );
237  (*it)->setAlignmentParameters( apnew );
238 
239  // Now update correlations between detectors
240  if ( updateCorrelations )
241  {
242  int jpos = 1;
243  for( align::Alignables::const_iterator it2 = alignables.begin(); it2 != it; ++it2 )
244  {
245  theCorrelationsStore->setCorrelations( *it, *it2, covariance, ipos-1, jpos-1 );
246  jpos += (*it2)->alignmentParameters()->numSelected();
247  }
248  }
249 
250  ipos+=nsel;
251  }
252 
253 }
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
const AlgebraicVector & parameters() const
Get alignment parameters.
virtual void setCorrelations(Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
Components components() const
Get vector of alignable components.
const AlgebraicSymMatrix & covariance() const
Get parameter covariance matrix.
int numSelected(void) const
Get number of selected parameters.
CLHEP::HepVector AlgebraicVector
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
AlignmentCorrelationsStore * theCorrelationsStore
CLHEP::HepSymMatrix AlgebraicSymMatrix
const align::Alignables & alignables(void) const
get all alignables
align::Alignables AlignmentParameterStore::validAlignables ( void  ) const

get all alignables with valid parameters

Definition at line 257 of file AlignmentParameterStore.cc.

References LogDebug, mps_fire::result, and theAlignables.

258 {
260  for (align::Alignables::const_iterator iali = theAlignables.begin();
261  iali != theAlignables.end(); ++iali)
262  if ( (*iali)->alignmentParameters()->isValid() ) result.push_back(*iali);
263 
264  LogDebug("Alignment") << "@SUB=AlignmentParameterStore::validAlignables"
265  << "Valid alignables: " << result.size()
266  << "out of " << theAlignables.size();
267  return result;
268 }
#define LogDebug(id)
align::Alignables theAlignables
alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31

Member Data Documentation

align::Alignables AlignmentParameterStore::theAlignables
private
AlignmentCorrelationsStore* AlignmentParameterStore::theCorrelationsStore
protected
TypeOfConstraints AlignmentParameterStore::theTypeOfConstraints
private

type of constraints

Definition at line 169 of file AlignmentParameterStore.h.

Referenced by AlignmentParameterStore(), and hierarchyConstraints().