40 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentParameterStore" 46 if( cfgStrTypeOfConstraints ==
"hierarchy" ) {
48 }
else if( cfgStrTypeOfConstraints ==
"approximate_averaging" ) {
51 <<
"\n\n\n******* WARNING ******************************************\n" 52 <<
"Using approximate implementation of averaging constraints." 53 <<
"This is not recommended." 54 <<
"Consider to use 'hierarchy' constraints:" 55 <<
" AlignmentProducer.ParameterStore.TypeOfConstraints = cms.string('hierarchy')\n\n\n";
57 edm::LogError(
"BadArgument") <<
"@SUB=AlignmentParameterStore" 58 <<
"Unknown type of hierarchy constraints '" << cfgStrTypeOfConstraints <<
"'";
72 std::vector<AlignableDetOrUnitPtr> detOrUnits;
73 detOrUnits.reserve(alignabledets.size());
75 std::vector<AlignableDet*>::const_iterator it, iEnd;
76 for ( it = alignabledets.begin(), iEnd = alignabledets.end(); it != iEnd; ++it)
88 std::map <AlignableDetOrUnitPtr,Alignable*> alidettoalimap;
89 std::map <Alignable*,int> aliposmap;
90 std::map <Alignable*,int> alilenmap;
94 for( std::vector<AlignableDetOrUnitPtr>::const_iterator iad = alignabledets.begin();
95 iad != alignabledets.end(); ++iad )
100 alidettoalimap[ *iad ] = ali;
102 if (
find(alignables.begin(),alignables.end(),ali) == alignables.end() )
104 alignables.push_back(ali);
116 align::Alignables::const_iterator it1;
117 for( it1 = alignables.begin(); it1 != alignables.end(); ++it1 )
123 aliposmap[*it1]=ipos;
124 alilenmap[*it1]=npar;
132 for( it1 = alignables.begin(); it1 != alignables.end(); ++it1 )
137 align::Alignables::const_iterator it2;
138 for( it2 = alignables.begin(); it2 != it1; ++it2 )
141 jpos += (*it2)->alignmentParameters()->numSelected();
144 ipos += (*it1)->alignmentParameters()->numSelected();
160 std::map <AlignableDetOrUnitPtr,Alignable*> alidettoalimap;
161 std::map <Alignable*,int> aliposmap;
162 std::map <Alignable*,int> alilenmap;
166 align::Alignables::const_iterator ita;
167 for ( ita = alignables.begin(); ita != alignables.end(); ++ita )
170 if (
find(selectedAlignables.begin(), selectedAlignables.end(), *ita) == selectedAlignables.end() )
172 selectedAlignables.push_back( *ita );
183 align::Alignables::const_iterator it1;
184 for( it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1 )
190 aliposmap[*it1]=ipos;
191 alilenmap[*it1]=npar;
199 for( it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1 )
204 align::Alignables::const_iterator it2;
205 for( it2 = selectedAlignables.begin(); it2 != it1; ++it2 )
208 jpos += (*it2)->alignmentParameters()->numSelected();
211 ipos += (*it1)->alignmentParameters()->numSelected();
232 for( align::Alignables::const_iterator it=alignables.begin(); it != alignables.end(); ++it )
240 (*it)->setAlignmentParameters( apnew );
243 if ( updateCorrelations )
246 for( align::Alignables::const_iterator it2 = alignables.begin(); it2 != it; ++it2 )
249 jpos += (*it2)->alignmentParameters()->numSelected();
263 for (align::Alignables::const_iterator iali =
theAlignables.begin();
265 if ( (*iali)->alignmentParameters()->isValid() ) result.push_back(*iali);
267 LogDebug(
"Alignment") <<
"@SUB=AlignmentParameterStore::validAlignables" 268 <<
"Valid alignables: " << result.size()
280 mother = mother->
mother();
289 align::Alignables::const_iterator iali;
302 <<
"applyParameters: provided alignable does not have alignment parameters";
315 align::Alignables::const_iterator iali;
339 edm::LogError(
"BadArgument") <<
"@SUB=AlignmentParameterStore::resetParameters" 340 <<
"alignable has no alignment parameter";
343 edm::LogError(
"BadArgument") <<
"@SUB=AlignmentParameterStore::resetParameters" 344 <<
"argument is NULL";
351 align::Alignables::const_iterator iali;
353 (*iali)->cacheTransformation();
360 for (
const auto& iali:
theAlignables) iali->cacheTransformation(run);
367 align::Alignables::const_iterator iali;
369 (*iali)->restoreCachedTransformation();
376 for (
const auto& iali:
theAlignables) iali->restoreCachedTransformation(run);
386 for (
unsigned int i = 0;
i < nAlignables; ++
i)
395 <<
"acquireRelativeParameters: " 396 <<
"provided alignable does not have rigid body alignment parameters";
436 unsigned int nappl=0;
440 for (align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali) {
447 for (AlignablePositions::const_iterator ipos = newpos.begin(); ipos != newpos.end(); ++ipos) {
448 if (
id == ipos->id() && typeId == ipos->objId()) {
451 <<
"New positions for alignable found more than once!";
457 const std::vector<double>& dnew = ipos->deformationParameters();
462 std::vector<std::pair<int, SurfaceDeformation*> > dold_id_pairs;
465 std::vector<double> dold;
467 dold_obj = dold_id_pairs[0].second;
478 LogDebug(
"NewPosition") <<
"moving by:" << posDiff;
479 LogDebug(
"NewRotation") <<
"rotating by:\n" << rotDiff;
484 std::vector<double> defDiff; defDiff.reserve(dold.size());
485 for (
unsigned int i = 0;
i < dold.size();
i++) defDiff.push_back(dnew[
i] - dold[
i]);
487 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentParameterStore::applyAlignableAbsolutePositions" 489 <<
", size " << defDiff.size() <<
" and first element " << defDiff.at(0)
490 <<
" to alignable with id / type: " <<
id <<
" / " << typeId;
495 else if (!dnew.empty()){
497 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentParameterStore::applyAlignableAbsolutePositions" 499 <<
", size " << dnew.size() <<
" and first element " << dnew.at(0)
500 <<
" to alignable with id / type: " <<
id <<
" / " << typeId;
518 if (nappl< newpos.size())
519 edm::LogError(
"Mismatch") <<
"Applied only " << nappl <<
" new positions" 520 <<
" out of " << newpos.size();
522 LogDebug(
"NewPositions") <<
"Applied new positions for " << nappl
523 <<
" out of " << alivec.size() <<
" alignables.";
533 unsigned int nappl=0;
534 unsigned int nAlignables = alivec.size();
536 for (
unsigned int i = 0;
i < nAlignables; ++
i) {
544 for (AlignableShifts::const_iterator ipos = shifts.begin(); ipos != shifts.end(); ++ipos) {
545 if (
id == ipos->id() && typeId == ipos->objId()) {
548 <<
"New positions for alignable found more than once!";
552 std::vector<std::pair<int, SurfaceDeformation*> > dold_id_pairs;
555 std::vector<double> dold;
557 dold_obj = dold_id_pairs[0].second;
562 ali->
move(ipos->pos());
565 const std::vector<double>& defDiff = ipos->deformationParameters();
569 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentParameterStore::applyAlignableRelativePositions" 571 <<
", size " << defDiff.size() <<
" and first element " << defDiff.at(0)
572 <<
" to alignable with id / type: " <<
id <<
" / " << typeId;
577 else if (!defDiff.empty()){
579 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentParameterStore::applyAlignableRelativePositions" 581 <<
", size " << defDiff.size() <<
" and first element " << defDiff.at(0)
582 <<
" to alignable with id / type: " <<
id <<
" / " << typeId;
600 if (nappl < shifts.size())
601 edm::LogError(
"Mismatch") <<
"Applied only " << nappl <<
" new positions" 602 <<
" out of " << shifts.size();
604 LogDebug(
"NewPositions") <<
"Applied new positions for " << nappl <<
" alignables.";
626 for ( align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali )
630 for ( Parameters::const_iterator ipar = parvec.begin(); ipar != parvec.end(); ++ipar)
640 (*iali)->setAlignmentParameters(ap);
644 else edm::LogError(
"Alignment") <<
"@SUB=AlignmentParameterStore::attachAlignmentParameters" 645 <<
"More than one parameters for Alignable.";
650 if (ifail>0) ierr=-1;
652 LogDebug(
"attachAlignmentParameters") <<
" Parameters, Alignables: " << parvec.size() <<
"," 653 << alivec.size() <<
"\n pass,fail: " << ipass <<
","<< ifail;
659 bool overwrite,
int& ierr )
668 bool overwrite,
int& ierr )
674 for ( Correlations::const_iterator icor = cormap.begin(); icor!=cormap.end(); ++icor )
681 if (
find( alivec.begin(), alivec.end(), ali1 ) != alivec.end() &&
682 find( alivec.begin(), alivec.end(), ali2 ) != alivec.end() )
690 else edm::LogInfo(
"AlreadyExists") <<
"Correlation existing and not overwritten";
692 else edm::LogInfo(
"IgnoreCorrelation") <<
"Ignoring correlation with no alignables!";
695 LogDebug(
"attachCorrelations" ) <<
" Alignables,Correlations: " << alivec.size() <<
","<< cormap.size()
696 <<
"\n applied: " << icount ;
704 const std::vector<AlignmentUserVariables*>& uvarvec,
int& ierr )
708 LogDebug(
"DumpArguments") <<
"size of alivec: " << alivec.size()
709 <<
"\nsize of uvarvec: " << uvarvec.size();
711 std::vector<AlignmentUserVariables*>::const_iterator iuvar=uvarvec.begin();
713 for ( align::Alignables::const_iterator iali=alivec.begin(); iali!=alivec.end(); ++iali, ++iuvar )
724 double valshift,
double valrot )
726 unsigned int nAlignables = alivec.size();
728 for (
unsigned int i = 0;
i < nAlignables; ++
i)
746 r(1)=valrot;
r(2)=valrot;
r(3)=valrot;
750 LogDebug(
"StoreAPE") <<
"Store APE from shift: " << valshift
751 <<
"\nStore APE from rotation: " << valrot;
757 std::vector<std::vector<ParameterId> > ¶mIdsVecOut,
758 std::vector<std::vector<double> > &factorsVecOut,
767 paramIdsVecOut.clear();
768 factorsVecOut.clear();
770 bool firstComp =
true;
771 for (align::Alignables::const_iterator iComp = aliComps.begin(), iCompE = aliComps.end();
772 iComp != iCompE; ++iComp) {
775 if (!p2pDerivs.
isOK()) {
779 <<
"AlignmentParameterStore::hierarchyConstraints" 780 <<
" Bad match of types of AlignmentParameters classes.\n";
783 const std::vector<bool> &aliCompSel = (*iComp)->alignmentParameters()->selector();
784 for (
unsigned int iParMast = 0, iParMastUsed = 0; iParMast < aliSel.size(); ++iParMast) {
785 if (!all && !aliSel[iParMast])
continue;
787 paramIdsVecOut.push_back(std::vector<ParameterId>());
788 factorsVecOut.push_back(std::vector<double>());
790 for (
unsigned int iParComp = 0; iParComp < aliCompSel.size(); ++iParComp) {
791 if (aliCompSel[iParComp]) {
795 factor = p2pDerivs(iParMast, iParComp);
798 factor = p2pDerivs(iParMast, iParComp);
799 if (iParMast < 3 && (iParComp % 9) >= 3) factor = 0.;
801 if (fabs(factor) > epsilon) {
802 paramIdsVecOut[iParMastUsed].push_back(
ParameterId(*iComp, iParComp));
803 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.
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const =0
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const
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.
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
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.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
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.
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)=0
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
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
char data[epos_bytes_allocation]
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.
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
RigidBodyAlignmentParameters * clone(const AlgebraicVector ¶meters, const AlgebraicSymMatrix &covMatrix) const override
Clone all parameters (for update of parameters)
cond::RealTimeType< cond::runnumber >::type RunNumber