ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/Alignment/CommonAlignmentAlgorithm/src/AlignmentParameterStore.cc
Revision: 1.5
Committed: Tue Dec 19 10:59:22 2006 UTC (18 years, 4 months ago) by fronga
Content type: text/plain
Branch: MAIN
CVS Tags: V00-08-01
Changes since 1.4: +6 -1 lines
Log Message:
setAlignmentPositionError() now overwrites existing APE (as in ORCA).

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