37 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentParameterStore"
43 if( cfgStrTypeOfConstraints ==
"hierarchy" ) {
45 }
else if( cfgStrTypeOfConstraints ==
"approximate_averaging" ) {
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";
54 edm::LogError(
"BadArgument") <<
"@SUB=AlignmentParameterStore"
55 <<
"Unknown type of hierarchy constraints '" << cfgStrTypeOfConstraints <<
"'";
69 std::vector<AlignableDetOrUnitPtr> detOrUnits;
70 detOrUnits.reserve(alignabledets.size());
72 std::vector<AlignableDet*>::const_iterator it, iEnd;
73 for ( it = alignabledets.begin(), iEnd = alignabledets.end(); it != iEnd; ++it)
85 std::map <AlignableDetOrUnitPtr,Alignable*> alidettoalimap;
86 std::map <Alignable*,int> aliposmap;
87 std::map <Alignable*,int> alilenmap;
91 for( std::vector<AlignableDetOrUnitPtr>::const_iterator iad = alignabledets.begin();
92 iad != alignabledets.end(); ++iad )
97 alidettoalimap[ *iad ] = ali;
99 if (
find(alignables.begin(),alignables.end(),ali) == alignables.end() )
101 alignables.push_back(ali);
113 align::Alignables::const_iterator it1;
114 for( it1 = alignables.begin(); it1 != alignables.end(); ++it1 )
120 aliposmap[*it1]=ipos;
121 alilenmap[*it1]=npar;
129 for( it1 = alignables.begin(); it1 != alignables.end(); ++it1 )
134 align::Alignables::const_iterator it2;
135 for( it2 = alignables.begin(); it2 != it1; ++it2 )
138 jpos += (*it2)->alignmentParameters()->numSelected();
141 ipos += (*it1)->alignmentParameters()->numSelected();
157 std::map <AlignableDetOrUnitPtr,Alignable*> alidettoalimap;
158 std::map <Alignable*,int> aliposmap;
159 std::map <Alignable*,int> alilenmap;
163 align::Alignables::const_iterator ita;
164 for ( ita = alignables.begin(); ita != alignables.end(); ++ita )
167 if (
find(selectedAlignables.begin(), selectedAlignables.end(), *ita) == selectedAlignables.end() )
169 selectedAlignables.push_back( *ita );
180 align::Alignables::const_iterator it1;
181 for( it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1 )
187 aliposmap[*it1]=ipos;
188 alilenmap[*it1]=npar;
196 for( it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1 )
201 align::Alignables::const_iterator it2;
202 for( it2 = selectedAlignables.begin(); it2 != it1; ++it2 )
205 jpos += (*it2)->alignmentParameters()->numSelected();
208 ipos += (*it1)->alignmentParameters()->numSelected();
229 for( align::Alignables::const_iterator it=alignables.begin(); it != alignables.end(); ++it )
237 (*it)->setAlignmentParameters( apnew );
240 if ( updateCorrelations )
243 for( align::Alignables::const_iterator it2 = alignables.begin(); it2 != it; ++it2 )
246 jpos += (*it2)->alignmentParameters()->numSelected();
260 for (align::Alignables::const_iterator iali =
theAlignables.begin();
262 if ( (*iali)->alignmentParameters()->isValid() ) result.push_back(*iali);
264 LogDebug(
"Alignment") <<
"@SUB=AlignmentParameterStore::validAlignables"
265 <<
"Valid alignables: " << result.size()
277 mother = mother->
mother();
286 align::Alignables::const_iterator iali;
299 <<
"applyParameters: provided alignable does not have alignment parameters";
312 align::Alignables::const_iterator iali;
336 edm::LogError(
"BadArgument") <<
"@SUB=AlignmentParameterStore::resetParameters"
337 <<
"alignable has no alignment parameter";
340 edm::LogError(
"BadArgument") <<
"@SUB=AlignmentParameterStore::resetParameters"
341 <<
"argument is NULL";
348 align::Alignables::const_iterator iali;
350 (*iali)->cacheTransformation();
357 align::Alignables::const_iterator iali;
359 (*iali)->restoreCachedTransformation();
368 for (
unsigned int i = 0;
i < nAlignables; ++
i)
377 <<
"acquireRelativeParameters: "
378 <<
"provided alignable does not have rigid body alignment parameters";
420 unsigned int nappl=0;
424 for (align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali) {
431 for (AlignablePositions::const_iterator ipos = newpos.begin(); ipos != newpos.end(); ++ipos) {
432 if (
id == ipos->id() && typeId == ipos->objId()) {
435 <<
"New positions for alignable found more than once!";
448 ali->
move( posDiff );
450 LogDebug(
"NewPosition") <<
"moving by:" << posDiff;
451 LogDebug(
"NewRotation") <<
"rotating by:\n" << rotDiff;
465 if ( nappl< newpos.size() )
466 edm::LogError(
"Mismatch") <<
"Applied only " << nappl <<
" new positions"
467 <<
" out of " << newpos.size();
469 LogDebug(
"NewPositions") <<
"Applied new positions for " << nappl
470 <<
" out of " << alivec.size() <<
" alignables.";
481 unsigned int nappl=0;
482 unsigned int nAlignables = alivec.size();
484 for (
unsigned int i = 0;
i < nAlignables; ++
i) {
492 for (AlignableShifts::const_iterator ipos = shifts.begin(); ipos != shifts.end(); ++ipos) {
493 if (
id == ipos->id() && typeId == ipos->objId()) {
496 <<
"New positions for alignable found more than once!";
498 ali->
move( ipos->pos() );
513 if ( nappl < shifts.size() )
514 edm::LogError(
"Mismatch") <<
"Applied only " << nappl <<
" new positions"
515 <<
" out of " << shifts.size();
517 LogDebug(
"NewPositions") <<
"Applied new positions for " << nappl <<
" alignables.";
539 for ( align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali )
543 for ( Parameters::const_iterator ipar = parvec.begin(); ipar != parvec.end(); ++ipar)
553 (*iali)->setAlignmentParameters(ap);
557 else edm::LogError(
"Alignment") <<
"@SUB=AlignmentParameterStore::attachAlignmentParameters"
558 <<
"More than one parameters for Alignable.";
563 if (ifail>0) ierr=-1;
565 LogDebug(
"attachAlignmentParameters") <<
" Parameters, Alignables: " << parvec.size() <<
","
566 << alivec.size() <<
"\n pass,fail: " << ipass <<
","<< ifail;
572 bool overwrite,
int& ierr )
581 bool overwrite,
int& ierr )
587 for ( Correlations::const_iterator icor = cormap.begin(); icor!=cormap.end(); ++icor )
594 if (
find( alivec.begin(), alivec.end(), ali1 ) != alivec.end() &&
595 find( alivec.begin(), alivec.end(), ali2 ) != alivec.end() )
603 else edm::LogInfo(
"AlreadyExists") <<
"Correlation existing and not overwritten";
605 else edm::LogInfo(
"IgnoreCorrelation") <<
"Ignoring correlation with no alignables!";
608 LogDebug(
"attachCorrelations" ) <<
" Alignables,Correlations: " << alivec.size() <<
","<< cormap.size()
609 <<
"\n applied: " << icount ;
617 const std::vector<AlignmentUserVariables*>& uvarvec,
int& ierr )
621 LogDebug(
"DumpArguments") <<
"size of alivec: " << alivec.size()
622 <<
"\nsize of uvarvec: " << uvarvec.size();
624 std::vector<AlignmentUserVariables*>::const_iterator iuvar=uvarvec.begin();
626 for ( align::Alignables::const_iterator iali=alivec.begin(); iali!=alivec.end(); ++iali, ++iuvar )
637 double valshift,
double valrot )
639 unsigned int nAlignables = alivec.size();
641 for (
unsigned int i = 0;
i < nAlignables; ++
i)
659 r(1)=valrot;
r(2)=valrot;
r(3)=valrot;
663 LogDebug(
"StoreAPE") <<
"Store APE from shift: " << valshift
664 <<
"\nStore APE from rotation: " << valrot;
670 std::vector<std::vector<ParameterId> > ¶mIdsVecOut,
671 std::vector<std::vector<double> > &factorsVecOut,
680 paramIdsVecOut.clear();
681 factorsVecOut.clear();
683 bool firstComp =
true;
684 for (align::Alignables::const_iterator iComp = aliComps.begin(), iCompE = aliComps.end();
685 iComp != iCompE; ++iComp) {
688 if (!p2pDerivs.
isOK()) {
690 <<
"AlignmentParameterStore::hierarchyConstraints"
691 <<
" Bad match of types of AlignmentParameters classes.\n";
694 const std::vector<bool> &aliCompSel = (*iComp)->alignmentParameters()->selector();
695 for (
unsigned int iParMast = 0, iParMastUsed = 0; iParMast < aliSel.size(); ++iParMast) {
696 if (!all && !aliSel[iParMast])
continue;
698 paramIdsVecOut.push_back(std::vector<ParameterId>());
699 factorsVecOut.push_back(std::vector<double>());
701 for (
unsigned int iParComp = 0; iParComp < aliCompSel.size(); ++iParComp) {
702 if (aliCompSel[iParComp]) {
704 if( theTypeOfConstraints == HIERARCHY_CONSTRAINTS ) {
706 factor = p2pDerivs(iParMast, iParComp);
707 }
else if( theTypeOfConstraints == APPROX_AVERAGING_CONSTRAINTS ) {
709 factor = p2pDerivs(iParMast, iParComp);
710 if (iParMast < 3 && (iParComp % 9) >= 3) factor = 0.;
712 if (fabs(factor) > epsilon) {
713 paramIdsVecOut[iParMastUsed].push_back(
ParameterId(*iComp, iParComp));
714 factorsVecOut[iParMastUsed].push_back(factor);
void attachUserVariables(const align::Alignables &alivec, const std::vector< AlignmentUserVariables * > &uvarvec, int &ierr)
Attach User Variables to given alignables.
T getParameter(std::string const &) const
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
T getUntrackedParameter(std::string const &, T const &) const
void resetParameters(void)
reset parameters, correlations, user variables
std::map< std::pair< Alignable *, Alignable * >, AlgebraicMatrix > Correlations
T y() const
Cartesian y coordinate.
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const
virtual RigidBodyAlignmentParameters * clone(const AlgebraicVector ¶meters, const AlgebraicSymMatrix &covMatrix) const
Clone all parameters (for update of parameters)
std::pair< int, int > typeAndLayer(const Alignable *ali, const TrackerTopology *tTopo) const
Obtain type and layer from Alignable.
std::pair< Alignable *, unsigned int > ParameterId
a single alignable parameter of an Alignable
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rotation, bool propagateDown)=0
AlgebraicVector selectedParameters(void) const
Get selected parameters.
void setAlignmentPositionError(const align::Alignables &alivec, double valshift, double valrot)
Set Alignment position error.
align::Alignables validAlignables(void) const
get all alignables with valid parameters
bool isOK() const
Indicate whether able to provide the derivatives.
void attachCorrelations(const align::Alignables &alivec, const Correlations &cormap, bool overwrite, int &ierr)
Attach correlations to given alignables.
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
void restoreCachedTransformations(void)
restore the previously cached position, rotation and other parameters
virtual ~AlignmentParameterStore()
destructor
const RotationType & globalRotation() const
Return the global orientation of the object.
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)=0
virtual bool correlationsAvailable(Alignable *ap1, Alignable *ap2) const
Check whether correlations are stored for a given pair of alignables.
void applyAlignableAbsolutePositions(const align::Alignables &alis, const AlignablePositions &newpos, int &ierr)
apply absolute positions to alignables
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
void updateParameters(const CompositeAlignmentParameters &aap, bool updateCorrelations=true)
update parameters
std::vector< AlignableRelData > AlignableShifts
Basic3DVector< T > x() const
const AlgebraicVector & parameters() const
Get alignment parameters.
const RotationType & rotation() const
Return change of orientation since the creation of the object.
virtual void setCorrelations(Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
std::vector< AlignmentParameters * > Parameters
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
CLHEP::HepMatrix AlgebraicMatrix
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
void setValid(bool v)
Set validity flag.
AlignmentParameterStore(const align::Alignables &alis, const edm::ParameterSet &config)
constructor
bool hierarchyConstraints(const Alignable *aliMaster, const align::Alignables &aliComps, std::vector< std::vector< ParameterId > > ¶mIdsVecOut, std::vector< std::vector< double > > &factorsVecOut, bool all, double epsilon) const
Components components() const
Get vector of alignable components.
void applyAlignableRelativePositions(const align::Alignables &alivec, const AlignableShifts &shifts, int &ierr)
apply relative shifts to alignables
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const AlgebraicSymMatrix & covariance() const
Get parameter covariance matrix.
virtual void resetCorrelations(void)
Reset correlations.
(Abstract) Base class for alignment algorithm user variables
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Alignable * alignable(void) const
Get pointer to corresponding alignable.
virtual void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)=0
Set the alignment position error - if (!propagateDown) do not affect daughters.
TypeOfConstraints theTypeOfConstraints
type of constraints
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.
Alignable * alignableFromAlignableDet(const AlignableDetOrUnitPtr &alignableDet) const
Obsolete: Use AlignableNavigator::alignableDetFromGeomDet and alignableFromAlignableDet.
void acquireRelativeParameters(void)
int numSelected(void) const
Get number of selected parameters.
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
virtual void correlations(Alignable *ap1, Alignable *ap2, AlgebraicSymMatrix &cov, int row, int col) const
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
int size(void) const
Get number of parameters.
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
align::Alignables theAlignables
alignables
CompositeAlignmentParameters selectParameters(const std::vector< AlignableDet * > &alignabledets) const
std::vector< Alignable * > Alignables
AlignmentCorrelationsStore * theCorrelationsStore
void cacheTransformations(void)
cache the current position, rotation and other parameters
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< AlignableAbsData > AlignablePositions
const PositionType & globalPosition() const
Return the global position of the object.
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
void attachAlignmentParameters(const align::Alignables &alivec, const Parameters &parvec, int &ierr)
Attach alignment parameters to given alignables.
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Alignable * mother() const
Return pointer to container alignable (if any)
virtual void apply()=0
apply parameters to alignable
const align::Alignables & alignables(void) const
get all alignables