ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/Alignment/CommonAlignmentAlgorithm/src/AlignmentParameterStore.cc
Revision: 1.2
Committed: Thu Aug 10 13:51:09 2006 UTC (18 years, 8 months ago) by fronga
Content type: text/plain
Branch: MAIN
Changes since 1.1: +33 -24 lines
Log Message:
Fixed DetId <-> Alignable map.

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