ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/Alignment/CommonAlignmentAlgorithm/src/AlignmentParameterStore.cc
Revision: 1.1
Committed: Fri Aug 4 16:15:14 2006 UTC (18 years, 9 months ago) by fronga
Content type: text/plain
Branch: MAIN
CVS Tags: CMSSW_1_0_0_pre1, V00-01-00
Log Message:
First version with EDLooper interface, and running in latest release.

File Contents

# User Rev Content
1 fronga 1.1 #include "FWCore/MessageLogger/interface/MessageLogger.h"
2     #include "FWCore/Utilities/interface/Exception.h"
3    
4     #include "Alignment/CommonAlignment/interface/AlignableDet.h"
5     #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
6     #include "Alignment/CommonAlignmentParametrization/interface/KarimakiAlignmentDerivatives.h"
7     #include "Alignment/CommonAlignmentParametrization/interface/AlignmentTransformations.h"
8    
9     #include <string>
10    
11     // This class's header
12     #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h"
13    
14    
15     //__________________________________________________________________________________________________
16     AlignmentParameterStore::AlignmentParameterStore( std::vector<Alignable*> alivec ) :
17     theAlignables(alivec)
18     {
19    
20    
21     theNavigator = new AlignableNavigator( alivec );
22     theTrackerAlignableId = new TrackerAlignableId;
23    
24     // Fill detId <-> Alignable map
25     for ( std::vector<Alignable*>::iterator it = alivec.begin();
26     it != alivec.end(); it++ )
27     theActiveAlignablesByDetId[ theTrackerAlignableId->alignableId(*it) ] = *it;
28    
29     edm::LogInfo("AlignmentParameterStore") << "Created navigator map with"
30     << theNavigator->size() << " elements";
31    
32    
33     }
34    
35    
36     //__________________________________________________________________________________________________
37     CompositeAlignmentParameters
38     AlignmentParameterStore::selectParameters( const std::vector<AlignableDet*>& alignabledets ) const
39     {
40    
41     std::vector<Alignable*> alignables;
42     std::map <AlignableDet*,Alignable*> alidettoalimap;
43     std::map <Alignable*,int> aliposmap;
44     std::map <Alignable*,int> alilenmap;
45     int nparam=0;
46    
47     // iterate over AlignableDet's
48     for(std::vector<AlignableDet*>::const_iterator
49     iad=alignabledets.begin(); iad!=alignabledets.end(); iad++ )
50     {
51    
52     unsigned int detId = (*iad)->geomDetId().rawId();
53     Alignable* ali = alignableFromDetId( detId );
54     if ( ali )
55     {
56     alidettoalimap[ *iad ]=ali; // Add to map
57     // Check if Alignable already there, insert into vector if not
58     if ( find(alignables.begin(),alignables.end(),ali) == alignables.end() )
59     {
60     alignables.push_back(ali);
61     AlignmentParameters* ap = ali->alignmentParameters();
62     nparam += ap->numSelected();
63     }
64     }
65     }
66    
67     AlgebraicVector selpar( nparam, 0 );
68     AlgebraicSymMatrix selcov( nparam, 0 );
69    
70     int ipos=1; // Position within selpar,selcov; starts from 1!
71    
72     // Now, run through again and fill parameters
73     for(std::vector<Alignable*>::const_iterator
74     it=alignables.begin(); it!=alignables.end(); it++)
75     {
76     AlignmentParameters* ap = (*it)->alignmentParameters();
77     AlgebraicVector thisselpar = ap->selectedParameters();
78     AlgebraicSymMatrix thisselcov = ap->selectedCovariance();
79     int npar = thisselpar.num_row();
80     selpar.sub(ipos,thisselpar);
81     selcov.sub(ipos,thisselcov);
82     // Look for correlations between alignables
83     int jpos=1;
84     for( std::vector<Alignable*>::const_iterator it2 = alignables.begin();
85     it2 != it; it2++ )
86     {
87     AlignmentParameters* ap2 = (*it2)->alignmentParameters();
88     int npar2=ap2->selectedParameters().num_row();
89     AlgebraicMatrix covmat = correlations(*it,*it2);
90     if (covmat.num_row()>0)
91     for (int i=0;i<npar;i++)
92     for (int j=0;j<npar2;j++)
93     selcov[(ipos-1)+i][(jpos-1)+j]=covmat[i][j];
94     jpos +=npar2;
95     }
96     aliposmap[*it]=ipos;
97     alilenmap[*it]=npar;
98     ipos +=npar;
99     }
100    
101     CompositeAlignmentParameters aap( selpar, selcov, alignables, alidettoalimap,
102     aliposmap, alilenmap );
103     return aap;
104    
105     }
106    
107    
108     //__________________________________________________________________________________________________
109     void AlignmentParameterStore::updateParameters( const CompositeAlignmentParameters& aap )
110     {
111    
112     std::vector<Alignable*> alignables = aap.components();
113     AlgebraicVector parameters = aap.parameters();
114     AlgebraicSymMatrix covariance = aap.covariance();
115    
116     int ipar=1; // NOTE: .sub indices start from 1
117    
118     // Loop over alignables
119     for( std::vector<Alignable*>::const_iterator it=alignables.begin();
120     it != alignables.end(); it++ )
121     {
122     AlignmentParameters* ap =(*it)->alignmentParameters();
123     int nsel=ap->numSelected();
124     // Update parameters and local covariance
125     AlgebraicVector subvec=parameters.sub(ipar,ipar+nsel-1);
126     AlgebraicSymMatrix subcov=covariance.sub(ipar,ipar+nsel-1);
127     AlignmentParameters* apnew = ap->cloneFromSelected(subvec,subcov);
128     (*it)->setAlignmentParameters(apnew);
129    
130     // Now update correlations between detectors
131     int ipar2=1;
132     for( std::vector<Alignable*>::const_iterator it2 = alignables.begin();
133     it2 != it; it2++ )
134     {
135     AlignmentParameters* ap2 =(*it2)->alignmentParameters();
136     int nsel2=ap2->numSelected();
137     AlgebraicMatrix suboffcov(nsel,nsel2);
138     for (int i=0;i<nsel;i++)
139     for (int j=0;j<nsel2;j++)
140     suboffcov[i][j]=covariance[(ipar-1)+i][(ipar2-1)+j];
141    
142     // Need to develop mechanism to control when to add correlation ...
143     if ( true )
144     setCorrelations(*it,*it2,suboffcov);
145    
146     ipar2 += nsel2;
147     }
148     ipar+=nsel;
149     }
150    
151     }
152    
153    
154     //__________________________________________________________________________________________________
155     std::vector<Alignable*> AlignmentParameterStore::validAlignables(void) const
156     {
157    
158     std::vector<Alignable*> result;
159     for (std::vector<Alignable*>::const_iterator iali = theAlignables.begin();
160     iali != theAlignables.end(); iali++)
161     if ( (*iali)->alignmentParameters()->isValid() ) result.push_back(*iali);
162    
163     edm::LogInfo("AlignmentParameterStore") << "Valid alignables: " << result.size()
164     << "out of " << theAlignables.size();
165     return result;
166    
167     }
168    
169    
170     //__________________________________________________________________________________________________
171     AlgebraicMatrix AlignmentParameterStore::correlations( Alignable* ap1, Alignable* ap2 ) const
172     {
173    
174     bool transpose = false;
175     if (ap2<ap1)
176     {
177     std::swap(ap1,ap2);
178     transpose = true;
179     }
180    
181     AlgebraicMatrix matrix;
182     Correlations::const_iterator ic = theCorrelations.find( std::make_pair(ap1,ap2) );
183     if (ic != theCorrelations.end())
184     if ( transpose ) matrix = (*ic).second.T();
185     else matrix = (*ic).second;
186    
187     return matrix;
188    
189     }
190    
191    
192     //__________________________________________________________________________________________________
193     void AlignmentParameterStore::setCorrelations(Alignable* ap1, Alignable* ap2,
194     const AlgebraicMatrix& mat )
195     {
196    
197     AlgebraicMatrix mat2;
198     if (ap2<ap1)
199     {
200     std::swap(ap1,ap2);
201     mat2=mat.T();
202     }
203     else
204     mat2=mat;
205    
206     theCorrelations[ std::make_pair(ap1,ap2) ] = mat2;
207    
208     }
209    
210    
211    
212     //__________________________________________________________________________________________________
213     Alignable* AlignmentParameterStore::alignableFromGeomDet( const GeomDet* geomDet ) const
214     {
215    
216     return theNavigator->alignableFromGeomDet( geomDet );
217    
218     }
219    
220    
221     //__________________________________________________________________________________________________
222     Alignable*
223     AlignmentParameterStore::alignableFromDetId( unsigned int& detId ) const
224     {
225     ActiveAlignablesByDetIdMap::const_iterator iali = theActiveAlignablesByDetId.find( detId );
226     if ( iali != theActiveAlignablesByDetId.end() )
227     return (*iali).second;
228     else return 0;
229     }
230    
231    
232     //__________________________________________________________________________________________________
233     std::vector<AlignableComposite*>
234     AlignmentParameterStore::findDets(AlignableComposite* alignable)
235     {
236     std::vector<AlignableComposite*> result;
237     AlignableDet* alidet = dynamic_cast<AlignableDet*> (alignable);
238     if (alidet !=0) result.push_back(alignable);
239     else {
240     std::vector<Alignable*> alivec = alignable->components();
241     for ( std::vector<Alignable*>::const_iterator ib=alivec.begin();
242     ib!=alivec.end(); ib++ ) {
243     AlignableComposite* alib=dynamic_cast<AlignableComposite*>(*ib);
244     AlignableDet* alidet = dynamic_cast<AlignableDet*> (alib);
245     if (alidet != 0) result.push_back(alib);
246     else {
247     std::vector<AlignableComposite*> dets = findDets(alib);
248     for ( std::vector<AlignableComposite*>::const_iterator ic=dets.begin();
249     ic!=dets.end(); ic++ ) result.push_back(*ic);
250     }
251     }
252     }
253     return result;
254     }
255    
256    
257     //__________________________________________________________________________________________________
258     std::vector<AlignableDet*>
259     AlignmentParameterStore::alignableDetsFromHits( const std::vector<TrackingRecHit>& hitvec )
260     {
261    
262     std::vector<AlignableDet*> alidetvec;
263     for ( std::vector<TrackingRecHit>::const_iterator ih=hitvec.begin();
264     ih!=hitvec.end(); ih++ )
265     {
266     AlignableDet* aliDet
267     = dynamic_cast<AlignableDet*>( theNavigator->alignableFromDetId(ih->geographicalId()) );
268     if ( aliDet )
269     alidetvec.push_back( aliDet );
270     else
271     throw cms::Exception("BadAssociation") << "Couldn't find AlignableDet"
272     << " associated to hit";
273     }
274     return alidetvec;
275    
276     }
277    
278    
279     //__________________________________________________________________________________________________
280     void AlignmentParameterStore::applyParameters(void)
281     {
282    
283     for (std::vector<Alignable*>::const_iterator iali = theAlignables.begin();
284     iali != theAlignables.end(); iali++)
285     applyParameters(*iali);
286    
287     }
288    
289    
290     //__________________________________________________________________________________________________
291     void AlignmentParameterStore::applyParameters(Alignable* alignable)
292     {
293    
294     // Get alignment parameters
295     RigidBodyAlignmentParameters* ap =
296     dynamic_cast<RigidBodyAlignmentParameters*>( alignable->alignmentParameters() );
297    
298     if ( !ap )
299     throw cms::Exception("BadAlignable")
300     << "applyParameters: provided alignable does not have rigid body alignment parameters";
301    
302     // Translation in local frame
303     AlgebraicVector shift = ap->translation();
304    
305     // Translation local->global
306     LocalPoint l0 = Local3DPoint( 0.0, 0.0, 0.0);
307     LocalPoint l1 = Local3DPoint(shift[0], shift[1], shift[2]);
308     GlobalPoint g0 = alignable->surface().toGlobal( l0 );
309     GlobalPoint g1 = alignable->surface().toGlobal( l1 );
310     GlobalVector dg = g1-g0;
311     alignable->move(dg);
312    
313     // Rotation in local frame
314     AlgebraicVector rota = ap->rotation();
315     if ( fabs(rota[0]) > 1e-5 || fabs(rota[1]) > 1e-5 || fabs(rota[2]) > 1e-5 )
316     {
317     AlignmentTransformations alignTransform;
318     Surface::RotationType rot = alignTransform.rotationType( alignTransform.rotMatrix3(rota) );
319     Surface::RotationType rot2 =
320     alignTransform.localToGlobalMatrix( rot,
321     alignable->globalRotation() );
322     alignable->rotateInGlobalFrame(rot2);
323     }
324    
325     }
326    
327    
328     //__________________________________________________________________________________________________
329     void AlignmentParameterStore::resetParameters(void)
330     {
331    
332     // Erase contents of correlation map
333     theCorrelations.erase(theCorrelations.begin(),theCorrelations.end());
334    
335     // Iterate over alignables in the store and reset parameters
336     for ( std::vector<Alignable*>::const_iterator iali = theAlignables.begin();
337     iali != theAlignables.end(); iali++ )
338     resetParameters(*iali);
339    
340     }
341    
342    
343     //__________________________________________________________________________________________________
344     void AlignmentParameterStore::resetParameters( Alignable* ali )
345     {
346     if ( ali )
347     {
348     // Get alignment parameters for this alignable
349     AlignmentParameters* ap = ali->alignmentParameters();
350     if ( ap )
351     {
352     int npar=ap->numSelected();
353    
354     AlgebraicVector par(npar,0);
355     AlgebraicSymMatrix cov(npar,0);
356     AlignmentParameters* apnew = ap->cloneFromSelected(par,cov);
357     ali->setAlignmentParameters(apnew);
358     apnew->setValid(false);
359     }
360     else
361     edm::LogError("BadArgument")
362     << "resetParameters: alignable has no alignment parameter";
363     }
364     else
365     edm::LogError("BadArgument") << "resetParameters argument is NULL";
366    
367     }
368    
369    
370     //__________________________________________________________________________________________________
371     void AlignmentParameterStore::acquireRelativeParameters(void)
372     {
373    
374     AlignmentTransformations alignTransform;
375     for ( std::vector<Alignable*>::const_iterator iali = theAlignables.begin();
376     iali != theAlignables.end(); iali++)
377     {
378     RigidBodyAlignmentParameters* ap =
379     dynamic_cast<RigidBodyAlignmentParameters*>( (*iali)->alignmentParameters() );
380     if ( !ap )
381     throw cms::Exception("BadAlignable")
382     << "acquireRelativeParameters: "
383     << "provided alignable does not have rigid body alignment parameters";
384    
385     AlgebraicVector par( ap->size(),0 );
386     AlgebraicSymMatrix cov( ap->size(), 0 );
387    
388     // Get displacement and transform global->local
389     LocalVector dloc = (*iali)->surface().toLocal( (*iali)->displacement() );
390     par[0]=dloc.x();
391     par[1]=dloc.y();
392     par[2]=dloc.z();
393    
394     // Global rel rotation
395     Surface::RotationType rot = (*iali)->rotation();
396     // Global abs rotation
397     Surface::RotationType detrot = (*iali)->surface().rotation();
398    
399     // Global euler angles
400     AlgebraicVector euglob = alignTransform.eulerAngles( rot,0 );
401    
402     // Transform to local euler angles
403     AlgebraicVector euloc = alignTransform.globalToLocalEulerAngles( euglob, detrot );
404     par[3]=euloc[0];
405     par[4]=euloc[1];
406     par[5]=euloc[2];
407    
408     // Clone parameters
409     RigidBodyAlignmentParameters* apnew = ap->clone(par,cov);
410    
411     (*iali)->setAlignmentParameters(apnew);
412     }
413    
414     }
415    
416    
417     //__________________________________________________________________________________________________
418     // Get type/layer from Alignable
419     // type: -6 -5 -4 -3 -2 -1 1 2 3 4 5 6
420     // TEC- TOB- TID- TIB- PxEC- PxBR- PxBr+ PxEC+ TIB+ TID+ TOB+ TEC+
421     // Layers start from zero
422     std::pair<int,int> AlignmentParameterStore::typeAndLayer(Alignable* ali)
423     {
424     return theTrackerAlignableId->typeAndLayerFromAlignable( ali );
425     }
426    
427    
428     //__________________________________________________________________________________________________
429     void AlignmentParameterStore::
430     applyAlignableAbsolutePositions( const Alignables& alivec,
431     const AlignablePositions& newpos,
432     int& ierr )
433     {
434     unsigned int nappl=0;
435     ierr=0;
436    
437     // Iterate over list of alignables
438     for ( Alignables::const_iterator iali = alivec.begin();
439     iali != alivec.end(); iali++ )
440     {
441     Alignable* ali = *iali;
442     unsigned int detId = theTrackerAlignableId->alignableId(ali);
443     int typeId = theTrackerAlignableId->alignableTypeId(ali);
444    
445     // Find corresponding entry in AlignablePositions
446     bool found=false;
447     for ( AlignablePositions::const_iterator ipos = newpos.begin();
448     ipos != newpos.end(); ipos++ )
449     if ( detId == ipos->id() && typeId == ipos->objId() )
450     if ( found )
451     edm::LogError("DuplicatePosition")
452     << "New positions for alignable found more than once!";
453     else
454     {
455     // New position/rotation
456     GlobalPoint pnew = ipos->pos();
457     Surface::RotationType rnew = ipos->rot();
458     // Current position / rotation
459     GlobalPoint pold = ali->surface().position();
460     Surface::RotationType rold = ali->surface().rotation();
461    
462     // shift needed to move from current to new position
463     GlobalVector shift = pnew - pold;
464     ali->move( shift );
465     edm::LogInfo("NewPosition") << "moving by" << shift;
466    
467     // Delta-rotation needed to rotate from current to new rotation
468     int ierr;
469     AlignmentTransformations alignTransform;
470     Surface::RotationType rot =
471     alignTransform.rotationType(alignTransform.algebraicMatrix(rold).inverse(ierr))
472     * rnew;
473     if ( ierr )
474     edm::LogError("InversionError") << "Matrix inversion failed: not rotating";
475     else
476     {
477     // 'Repair' matrix for rounding errors
478     Surface::RotationType rotfixed = alignTransform.rectify(rot);
479     ali->rotateInGlobalFrame(rotfixed);
480     AlgebraicMatrix mrot = alignTransform.algebraicMatrix( rotfixed );
481     edm::LogInfo("NewRotation") << "rotating by: " << mrot;
482     }
483    
484     // add position error
485     // AlignmentPositionError ape(shift.x(),shift.y(),shift.z());
486     // (*iali)->addAlignmentPositionError(ape);
487     // (*iali)->addAlignmentPositionErrorFromRotation(rot);
488    
489     found=true;
490     nappl++;
491     }
492     }
493    
494     if ( nappl< newpos.size() )
495     edm::LogError("Mismatch") << "Applied only " << nappl << " new positions"
496     << " out of " << newpos.size();
497    
498     edm::LogInfo("NewPositions") << "Applied new positions for " << nappl
499     << " out of " << alivec.size() <<" alignables.";
500    
501     }
502    
503    
504     //__________________________________________________________________________________________________
505     void AlignmentParameterStore::
506     applyAlignableRelativePositions( const Alignables& alivec,
507     const AlignableShifts& shifts, int& ierr )
508     {
509    
510     unsigned int nappl=0;
511     ierr=0;
512    
513     // Iterate over list of alignables
514     for ( Alignables::const_iterator iali = alivec.begin();
515     iali != alivec.end(); iali++)
516     {
517    
518     unsigned int detId = theTrackerAlignableId->alignableId( *iali );
519     int typeId=theTrackerAlignableId->alignableTypeId( *iali );
520    
521     // Find corresponding entry in AlignableShifts
522     bool found = false;
523     for ( AlignableShifts::const_iterator ipos = shifts.begin();
524     ipos != shifts.end(); ipos++ )
525     {
526     if ( detId == ipos->id() && typeId == ipos->objId() )
527     if ( found )
528     edm::LogError("DuplicatePosition")
529     << "New positions for alignable found more than once!";
530     else
531     {
532     // New position/rotation shift
533     GlobalVector pnew = ipos->pos();
534     Surface::RotationType rnew = ipos->rot();
535    
536     (*iali)->move(pnew);
537     (*iali)->rotateInGlobalFrame(rnew);
538    
539     // Add position error
540     //AlignmentPositionError ape(pnew.x(),pnew.y(),pnew.z());
541     //(*iali)->addAlignmentPositionError(ape);
542     //(*iali)->addAlignmentPositionErrorFromRotation(rnew);
543    
544     found=true;
545     nappl++;
546     }
547     }
548     }
549    
550     if ( nappl < shifts.size() )
551     edm::LogError("Mismatch") << "Applied only " << nappl << " new positions"
552     << " out of " << shifts.size();
553    
554     edm::LogInfo("NewPositions")
555     << "Applied new positions for " << nappl << " alignables.";
556    
557     }
558    
559    
560    
561     //__________________________________________________________________________________________________
562     void AlignmentParameterStore::attachAlignmentParameters( const Parameters& parvec, int& ierr )
563     {
564     attachAlignmentParameters( theAlignables, parvec, ierr);
565     }
566    
567    
568    
569     //__________________________________________________________________________________________________
570     void AlignmentParameterStore::attachAlignmentParameters( const Alignables& alivec,
571     const Parameters& parvec, int& ierr )
572     {
573    
574     int ipass = 0;
575     int ifail = 0;
576     ierr = 0;
577    
578     // Iterate over alignables
579     for ( Alignables::const_iterator iali = alivec.begin();
580     iali != alivec.end(); iali++ )
581     {
582     // Iterate over Parameters
583     bool found=false;
584     for ( Parameters::const_iterator ipar = parvec.begin();
585     ipar != parvec.end(); ipar++)
586     {
587     // Get new alignment parameters
588     RigidBodyAlignmentParameters* ap =
589     dynamic_cast<RigidBodyAlignmentParameters*>(*ipar);
590    
591     // Check if parameters belong to alignable
592     if ( ap->alignable() == (*iali) )
593     {
594     if (!found)
595     {
596     (*iali)->setAlignmentParameters(ap);
597     ipass++;
598     found=true;
599     }
600     else
601     edm::LogError("DuplicateParameters")
602     <<"More than one parameters for Alignable";
603     }
604     }
605     if (!found) ifail++;
606     }
607     if (ifail>0) ierr=-1;
608    
609     edm::LogInfo("attachAlignmentParameters")
610     << " Parameters, Alignables: "<< parvec.size() <<"," << alivec.size()
611     << "\n pass,fail: " << ipass <<","<< ifail;
612     }
613    
614    
615     //__________________________________________________________________________________________________
616     void AlignmentParameterStore::attachCorrelations( const Correlations& cormap,
617     bool overwrite, int& ierr )
618     {
619     attachCorrelations( theAlignables, cormap, overwrite, ierr );
620     }
621    
622    
623     //__________________________________________________________________________________________________
624     void AlignmentParameterStore::attachCorrelations( const Alignables& alivec,
625     const Correlations& cormap,
626     bool overwrite,int& ierr )
627     {
628    
629     ierr=0;
630     int icount=0;
631    
632     // Iterate over correlations
633     for ( Correlations::const_iterator icor = cormap.begin();
634     icor!=cormap.end(); icor++ )
635     {
636     AlgebraicMatrix mat=(*icor).second;
637     Alignable* ali1 = (*icor).first.first;
638     Alignable* ali2 = (*icor).first.second;
639    
640     // Check if alignables exist
641     if ( find(alivec.begin(),alivec.end(),ali1) != alivec.end() &&
642     find(alivec.begin(),alivec.end(),ali2) != alivec.end() )
643     // Check if correlations already existing between these alignables
644     if ( correlations(ali1,ali2).num_row() == 0 || (overwrite) )
645     {
646     setCorrelations(ali1,ali2,mat);
647     icount++;
648     }
649     else
650     edm::LogWarning("AlreadyExists")
651     << "Correlation existing and not overwritten";
652     else
653     edm::LogWarning("IgnoreCorrelation")
654     << "Ignoring correlation with no alignables!";
655     }
656    
657     edm::LogInfo("attachCorrelations")
658     << " Alignables,Correlations: " << alivec.size() <<","<< cormap.size()
659     << "\n applied: " << icount ;
660    
661     }
662    
663    
664     //__________________________________________________________________________________________________
665     void AlignmentParameterStore::
666     attachUserVariables( const Alignables& alivec,
667     const std::vector<AlignmentUserVariables*>& uvarvec, int& ierr )
668     {
669    
670     ierr=0;
671    
672     edm::LogInfo("DumpArguments") << "size of alivec: " << alivec.size()
673     << "\nsize of uvarvec: " << uvarvec.size();
674    
675     std::vector<AlignmentUserVariables*>::const_iterator iuvar=uvarvec.begin();
676    
677     for ( Alignables::const_iterator iali=alivec.begin(); iali!=alivec.end();
678     iali++, iuvar++ )
679     {
680     AlignmentParameters* ap = (*iali)->alignmentParameters();
681     AlignmentUserVariables* uvarnew = (*iuvar);
682     ap->setUserVariables(uvarnew);
683     }
684    
685     }
686    
687    
688     //__________________________________________________________________________________________________
689     void AlignmentParameterStore::setAlignmentPositionError( const Alignables& alivec,
690     double valshift, double valrot )
691     {
692    
693     bool first=true;
694     for ( Alignables::const_iterator iali = alivec.begin();
695     iali != alivec.end(); iali++ )
696     {
697     if (valshift>0) {
698     AlignmentPositionError ape(valshift,valshift,valshift);
699     (*iali)->addAlignmentPositionError(ape);
700     if (first)
701     edm::LogInfo("StoreAPE") << "Store APE from shift: " << valshift;
702     }
703     if (valrot>0) {
704     AlignmentTransformations alignTransform;
705     AlgebraicVector r(3);
706     r[0]=valrot; r[1]=valrot; r[2]=valrot;
707     Surface::RotationType aperot
708     = alignTransform.rotationType( alignTransform.rotMatrix3(r) );
709     (*iali)->addAlignmentPositionErrorFromRotation(aperot);
710     if (first)
711     edm::LogInfo("StoreAPE") << "Store APE from rotation: " << valrot;
712     }
713     first=false;
714     }
715     }