CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignmentParameterStore.cc
Go to the documentation of this file.
1 
9 // This class's header should be first
11 
15 
19 
24 
25 //__________________________________________________________________________________________________
27  const edm::ParameterSet& config ) :
28  theAlignables(alis)
29 {
30  if (config.getUntrackedParameter<bool>("UseExtendedCorrelations")) {
32  (config.getParameter<edm::ParameterSet>("ExtendedCorrelationsConfig"));
33  } else {
35  }
36 
37  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterStore"
38  << "Created with " << theAlignables.size() << " alignables.";
39 
40  // set hierarchy vs averaging constraints
42  const std::string cfgStrTypeOfConstraints(config.getParameter<std::string>("TypeOfConstraints"));
43  if( cfgStrTypeOfConstraints == "hierarchy" ) {
45  } else if( cfgStrTypeOfConstraints == "approximate_averaging" ) {
47  edm::LogWarning("Alignment") << "@SUB=AlignmentParameterStore"
48  << "\n\n\n******* WARNING ******************************************\n"
49  << "Using approximate implementation of averaging constraints."
50  << "This is not recommended."
51  << "Consider to use 'hierarchy' constraints:"
52  << " AlignmentProducer.ParameterStore.TypeOfConstraints = cms.string('hierarchy')\n\n\n";
53  } else {
54  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore"
55  << "Unknown type of hierarchy constraints '" << cfgStrTypeOfConstraints << "'";
56  }
57 }
58 
59 //__________________________________________________________________________________________________
61 {
62  delete theCorrelationsStore;
63 }
64 
65 //__________________________________________________________________________________________________
67 AlignmentParameterStore::selectParameters( const std::vector<AlignableDet*>& alignabledets ) const
68 {
69  std::vector<AlignableDetOrUnitPtr> detOrUnits;
70  detOrUnits.reserve(alignabledets.size());
71 
72  std::vector<AlignableDet*>::const_iterator it, iEnd;
73  for ( it = alignabledets.begin(), iEnd = alignabledets.end(); it != iEnd; ++it)
74  detOrUnits.push_back(AlignableDetOrUnitPtr(*it));
75 
76  return this->selectParameters(detOrUnits);
77 }
78 
79 //__________________________________________________________________________________________________
81 AlignmentParameterStore::selectParameters( const std::vector<AlignableDetOrUnitPtr>& alignabledets ) const
82 {
83 
85  std::map <AlignableDetOrUnitPtr,Alignable*> alidettoalimap;
86  std::map <Alignable*,int> aliposmap;
87  std::map <Alignable*,int> alilenmap;
88  int nparam=0;
89 
90  // iterate over AlignableDet's
91  for( std::vector<AlignableDetOrUnitPtr>::const_iterator iad = alignabledets.begin();
92  iad != alignabledets.end(); ++iad )
93  {
94  Alignable* ali = alignableFromAlignableDet( *iad );
95  if ( ali )
96  {
97  alidettoalimap[ *iad ] = ali; // Add to map
98  // Check if Alignable already there, insert into vector if not
99  if ( find(alignables.begin(),alignables.end(),ali) == alignables.end() )
100  {
101  alignables.push_back(ali);
103  nparam += ap->numSelected();
104  }
105  }
106  }
107 
108  AlgebraicVector* selpar = new AlgebraicVector( nparam, 0 );
109  AlgebraicSymMatrix* selcov = new AlgebraicSymMatrix( nparam, 0 );
110 
111  // Fill in parameters and corresponding covariance matricess
112  int ipos = 1; // NOTE: .sub indices start from 1
113  align::Alignables::const_iterator it1;
114  for( it1 = alignables.begin(); it1 != alignables.end(); ++it1 )
115  {
116  AlignmentParameters* ap = (*it1)->alignmentParameters();
117  selpar->sub( ipos, ap->selectedParameters() );
118  selcov->sub( ipos, ap->selectedCovariance() );
119  int npar = ap->numSelected();
120  aliposmap[*it1]=ipos;
121  alilenmap[*it1]=npar;
122  ipos +=npar;
123  }
124 
125  // Fill in the correlations. Has to be an extra loop, because the
126  // AlignmentExtendedCorrelationsStore (if used) needs the
127  // alignables' covariance matrices already present.
128  ipos = 1;
129  for( it1 = alignables.begin(); it1 != alignables.end(); ++it1 )
130  {
131  int jpos=1;
132 
133  // Look for correlations between alignables
134  align::Alignables::const_iterator it2;
135  for( it2 = alignables.begin(); it2 != it1; ++it2 )
136  {
137  theCorrelationsStore->correlations( *it1, *it2, *selcov, ipos-1, jpos-1 );
138  jpos += (*it2)->alignmentParameters()->numSelected();
139  }
140 
141  ipos += (*it1)->alignmentParameters()->numSelected();
142  }
143 
145  CompositeAlignmentParameters aap( data, alignables, alidettoalimap, aliposmap, alilenmap );
146 
147  return aap;
148 }
149 
150 
151 //__________________________________________________________________________________________________
154 {
155 
156  align::Alignables selectedAlignables;
157  std::map <AlignableDetOrUnitPtr,Alignable*> alidettoalimap; // This map won't be filled!!!
158  std::map <Alignable*,int> aliposmap;
159  std::map <Alignable*,int> alilenmap;
160  int nparam=0;
161 
162  // iterate over Alignable's
163  align::Alignables::const_iterator ita;
164  for ( ita = alignables.begin(); ita != alignables.end(); ++ita )
165  {
166  // Check if Alignable already there, insert into vector if not
167  if ( find(selectedAlignables.begin(), selectedAlignables.end(), *ita) == selectedAlignables.end() )
168  {
169  selectedAlignables.push_back( *ita );
170  AlignmentParameters* ap = (*ita)->alignmentParameters();
171  nparam += ap->numSelected();
172  }
173  }
174 
175  AlgebraicVector* selpar = new AlgebraicVector( nparam, 0 );
176  AlgebraicSymMatrix* selcov = new AlgebraicSymMatrix( nparam, 0 );
177 
178  // Fill in parameters and corresponding covariance matrices
179  int ipos = 1; // NOTE: .sub indices start from 1
180  align::Alignables::const_iterator it1;
181  for( it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1 )
182  {
183  AlignmentParameters* ap = (*it1)->alignmentParameters();
184  selpar->sub( ipos, ap->selectedParameters() );
185  selcov->sub( ipos, ap->selectedCovariance() );
186  int npar = ap->numSelected();
187  aliposmap[*it1]=ipos;
188  alilenmap[*it1]=npar;
189  ipos +=npar;
190  }
191 
192  // Fill in the correlations. Has to be an extra loop, because the
193  // AlignmentExtendedCorrelationsStore (if used) needs the
194  // alignables' covariance matrices already present.
195  ipos = 1;
196  for( it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1 )
197  {
198  int jpos=1;
199 
200  // Look for correlations between alignables
201  align::Alignables::const_iterator it2;
202  for( it2 = selectedAlignables.begin(); it2 != it1; ++it2 )
203  {
204  theCorrelationsStore->correlations( *it1, *it2, *selcov, ipos-1, jpos-1 );
205  jpos += (*it2)->alignmentParameters()->numSelected();
206  }
207 
208  ipos += (*it1)->alignmentParameters()->numSelected();
209  }
210 
212  CompositeAlignmentParameters aap( data, selectedAlignables, alidettoalimap, aliposmap, alilenmap );
213 
214  return aap;
215 }
216 
217 
218 //__________________________________________________________________________________________________
220 {
221 
222  align::Alignables alignables = aap.components();
223  const AlgebraicVector& parameters = aap.parameters();
224  const AlgebraicSymMatrix& covariance = aap.covariance();
225 
226  int ipos = 1; // NOTE: .sub indices start from 1
227 
228  // Loop over alignables
229  for( align::Alignables::const_iterator it=alignables.begin(); it != alignables.end(); ++it )
230  {
231  // Update parameters and local covariance
232  AlignmentParameters* ap = (*it)->alignmentParameters();
233  int nsel = ap->numSelected();
234  AlgebraicVector subvec = parameters.sub( ipos, ipos+nsel-1 );
235  AlgebraicSymMatrix subcov = covariance.sub( ipos, ipos+nsel-1 );
236  AlignmentParameters* apnew = ap->cloneFromSelected( subvec, subcov );
237  (*it)->setAlignmentParameters( apnew );
238 
239  // Now update correlations between detectors
240  if ( updateCorrelations )
241  {
242  int jpos = 1;
243  for( align::Alignables::const_iterator it2 = alignables.begin(); it2 != it; ++it2 )
244  {
245  theCorrelationsStore->setCorrelations( *it, *it2, covariance, ipos-1, jpos-1 );
246  jpos += (*it2)->alignmentParameters()->numSelected();
247  }
248  }
249 
250  ipos+=nsel;
251  }
252 
253 }
254 
255 
256 //__________________________________________________________________________________________________
258 {
260  for (align::Alignables::const_iterator iali = theAlignables.begin();
261  iali != theAlignables.end(); ++iali)
262  if ( (*iali)->alignmentParameters()->isValid() ) result.push_back(*iali);
263 
264  LogDebug("Alignment") << "@SUB=AlignmentParameterStore::validAlignables"
265  << "Valid alignables: " << result.size()
266  << "out of " << theAlignables.size();
267  return result;
268 }
269 
270 //__________________________________________________________________________________________________
272 {
273  AlignableDetOrUnitPtr alignableDet = _alignableDet;
274  Alignable *mother = alignableDet;
275  while (mother) {
276  if (mother->alignmentParameters()) return mother;
277  mother = mother->mother();
278  }
279 
280  return 0;
281 }
282 
283 //__________________________________________________________________________________________________
285 {
286  align::Alignables::const_iterator iali;
287  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
288  applyParameters( *iali );
289 }
290 
291 
292 //__________________________________________________________________________________________________
294 {
295 
296  AlignmentParameters *pars = (alignable ? alignable->alignmentParameters() : 0);
297  if (!pars) {
298  throw cms::Exception("BadAlignable")
299  << "applyParameters: provided alignable does not have alignment parameters";
300  }
301  pars->apply();
302 }
303 
304 
305 //__________________________________________________________________________________________________
307 {
308  // Erase contents of correlation map
310 
311  // Iterate over alignables in the store and reset parameters
312  align::Alignables::const_iterator iali;
313  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali )
314  resetParameters( *iali );
315 }
316 
317 
318 //__________________________________________________________________________________________________
320 {
321  if ( ali )
322  {
323  // Get alignment parameters for this alignable
325  if ( ap )
326  {
327  int npar=ap->numSelected();
328 
329  AlgebraicVector par(npar,0);
330  AlgebraicSymMatrix cov(npar,0);
331  AlignmentParameters* apnew = ap->cloneFromSelected(par,cov);
332  ali->setAlignmentParameters(apnew);
333  apnew->setValid(false);
334  }
335  else
336  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore::resetParameters"
337  << "alignable has no alignment parameter";
338  }
339  else
340  edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore::resetParameters"
341  << "argument is NULL";
342 }
343 
344 
345 //__________________________________________________________________________________________________
347 {
348  align::Alignables::const_iterator iali;
349  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
350  (*iali)->cacheTransformation();
351 }
352 
353 
354 //__________________________________________________________________________________________________
356 {
357  align::Alignables::const_iterator iali;
358  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali)
359  (*iali)->restoreCachedTransformation();
360 }
361 
362 //__________________________________________________________________________________________________
364 {
365 
366  unsigned int nAlignables = theAlignables.size();
367 
368  for (unsigned int i = 0; i < nAlignables; ++i)
369  {
370  Alignable* ali = theAlignables[i];
371 
373  dynamic_cast<RigidBodyAlignmentParameters*>( ali->alignmentParameters() );
374 
375  if ( !ap )
376  throw cms::Exception("BadAlignable")
377  << "acquireRelativeParameters: "
378  << "provided alignable does not have rigid body alignment parameters";
379 
380  AlgebraicVector par( ap->size(),0 );
381  AlgebraicSymMatrix cov( ap->size(), 0 );
382 
383  // Get displacement and transform global->local
384  align::LocalVector dloc = ali->surface().toLocal( ali->displacement() );
385  par[0]=dloc.x();
386  par[1]=dloc.y();
387  par[2]=dloc.z();
388 
389  // Transform to local euler angles
390  align::EulerAngles euloc = align::toAngles( ali->surface().toLocal( ali->rotation() ) );
391  par[3]=euloc(1);
392  par[4]=euloc(2);
393  par[5]=euloc(3);
394 
395  // Clone parameters
396  RigidBodyAlignmentParameters* apnew = ap->clone(par,cov);
397 
398  ali->setAlignmentParameters(apnew);
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(const Alignable* ali, const TrackerTopology* tTopo) const
409 {
410  return TrackerAlignableId().typeAndLayerFromDetId( ali->id(), tTopo );
411 }
412 
413 
414 //__________________________________________________________________________________________________
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 (align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali) {
425  Alignable* ali = *iali;
426  align::ID id = ali->id();
427  align::StructureType typeId = ali->alignableObjectId();
428 
429  // Find corresponding entry in AlignablePositions
430  bool found=false;
431  for (AlignablePositions::const_iterator ipos = newpos.begin(); ipos != newpos.end(); ++ipos) {
432  if (id == ipos->id() && typeId == ipos->objId()) {
433  if (found) {
434  edm::LogError("DuplicatePosition")
435  << "New positions for alignable found more than once!";
436  } else {
437  // New position/rotation
438  const align::PositionType& pnew = ipos->pos();
439  const align::RotationType& rnew = ipos->rot();
440  // Current position / rotation
441  const align::PositionType& pold = ali->globalPosition();
442  const align::RotationType& rold = ali->globalRotation();
443 
444  // shift needed to move from current to new position
445  align::GlobalVector posDiff = pnew - pold;
446  align::RotationType rotDiff = rold.multiplyInverse(rnew);
447  align::rectify(rotDiff); // correct for rounding errors
448  ali->move( posDiff );
449  ali->rotateInGlobalFrame( rotDiff );
450  LogDebug("NewPosition") << "moving by:" << posDiff;
451  LogDebug("NewRotation") << "rotating by:\n" << rotDiff;
452 
453  // add position error
454  // AlignmentPositionError ape(shift.x(),shift.y(),shift.z());
455  // (*iali)->addAlignmentPositionError(ape);
456  // (*iali)->addAlignmentPositionErrorFromRotation(rot);
457 
458  found=true;
459  ++nappl;
460  }
461  }
462  }
463  }
464 
465  if ( nappl< newpos.size() )
466  edm::LogError("Mismatch") << "Applied only " << nappl << " new positions"
467  << " out of " << newpos.size();
468 
469  LogDebug("NewPositions") << "Applied new positions for " << nappl
470  << " out of " << alivec.size() <<" alignables.";
471 
472 }
473 
474 
475 //__________________________________________________________________________________________________
477 applyAlignableRelativePositions( const align::Alignables& alivec, const AlignableShifts& shifts, int& ierr )
478 {
479 
480  ierr=0;
481  unsigned int nappl=0;
482  unsigned int nAlignables = alivec.size();
483 
484  for (unsigned int i = 0; i < nAlignables; ++i) {
485  Alignable* ali = alivec[i];
486 
487  align::ID id = ali->id();
488  align::StructureType typeId = ali->alignableObjectId();
489 
490  // Find corresponding entry in AlignableShifts
491  bool found = false;
492  for (AlignableShifts::const_iterator ipos = shifts.begin(); ipos != shifts.end(); ++ipos) {
493  if (id == ipos->id() && typeId == ipos->objId()) {
494  if (found) {
495  edm::LogError("DuplicatePosition")
496  << "New positions for alignable found more than once!";
497  } else {
498  ali->move( ipos->pos() );
499  ali->rotateInGlobalFrame( ipos->rot() );
500 
501  // Add position error
502  //AlignmentPositionError ape(pnew.x(),pnew.y(),pnew.z());
503  //ali->addAlignmentPositionError(ape);
504  //ali->addAlignmentPositionErrorFromRotation(rnew);
505 
506  found=true;
507  ++nappl;
508  }
509  }
510  }
511  }
512 
513  if ( nappl < shifts.size() )
514  edm::LogError("Mismatch") << "Applied only " << nappl << " new positions"
515  << " out of " << shifts.size();
516 
517  LogDebug("NewPositions") << "Applied new positions for " << nappl << " alignables.";
518 }
519 
520 
521 
522 //__________________________________________________________________________________________________
524 {
526 }
527 
528 
529 
530 //__________________________________________________________________________________________________
532  const Parameters& parvec, int& ierr )
533 {
534  int ipass = 0;
535  int ifail = 0;
536  ierr = 0;
537 
538  // Iterate over alignables
539  for ( align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali )
540  {
541  // Iterate over Parameters
542  bool found=false;
543  for ( Parameters::const_iterator ipar = parvec.begin(); ipar != parvec.end(); ++ipar)
544  {
545  // Get new alignment parameters
546  AlignmentParameters* ap = *ipar;
547 
548  // Check if parameters belong to alignable
549  if ( ap->alignable() == (*iali) )
550  {
551  if (!found)
552  {
553  (*iali)->setAlignmentParameters(ap);
554  ++ipass;
555  found=true;
556  }
557  else edm::LogError("Alignment") << "@SUB=AlignmentParameterStore::attachAlignmentParameters"
558  << "More than one parameters for Alignable.";
559  }
560  }
561  if (!found) ++ifail;
562  }
563  if (ifail>0) ierr=-1;
564 
565  LogDebug("attachAlignmentParameters") << " Parameters, Alignables: " << parvec.size() << ","
566  << alivec.size() << "\n pass,fail: " << ipass << ","<< ifail;
567 }
568 
569 
570 //__________________________________________________________________________________________________
572  bool overwrite, int& ierr )
573 {
574  attachCorrelations( theAlignables, cormap, overwrite, ierr );
575 }
576 
577 
578 //__________________________________________________________________________________________________
580  const Correlations& cormap,
581  bool overwrite, int& ierr )
582 {
583  ierr=0;
584  int icount=0;
585 
586  // Iterate over correlations
587  for ( Correlations::const_iterator icor = cormap.begin(); icor!=cormap.end(); ++icor )
588  {
589  AlgebraicMatrix mat=(*icor).second;
590  Alignable* ali1 = (*icor).first.first;
591  Alignable* ali2 = (*icor).first.second;
592 
593  // Check if alignables exist
594  if ( find( alivec.begin(), alivec.end(), ali1 ) != alivec.end() &&
595  find( alivec.begin(), alivec.end(), ali2 ) != alivec.end() )
596  {
597  // Check if correlations already existing between these alignables
598  if ( !theCorrelationsStore->correlationsAvailable(ali1,ali2) || (overwrite) )
599  {
600  theCorrelationsStore->setCorrelations(ali1,ali2,mat);
601  ++icount;
602  }
603  else edm::LogInfo("AlreadyExists") << "Correlation existing and not overwritten";
604  }
605  else edm::LogInfo("IgnoreCorrelation") << "Ignoring correlation with no alignables!";
606  }
607 
608  LogDebug( "attachCorrelations" ) << " Alignables,Correlations: " << alivec.size() <<","<< cormap.size()
609  << "\n applied: " << icount ;
610 
611 }
612 
613 
614 //__________________________________________________________________________________________________
617  const std::vector<AlignmentUserVariables*>& uvarvec, int& ierr )
618 {
619  ierr=0;
620 
621  LogDebug("DumpArguments") << "size of alivec: " << alivec.size()
622  << "\nsize of uvarvec: " << uvarvec.size();
623 
624  std::vector<AlignmentUserVariables*>::const_iterator iuvar=uvarvec.begin();
625 
626  for ( align::Alignables::const_iterator iali=alivec.begin(); iali!=alivec.end(); ++iali, ++iuvar )
627  {
628  AlignmentParameters* ap = (*iali)->alignmentParameters();
629  AlignmentUserVariables* uvarnew = (*iuvar);
630  ap->setUserVariables(uvarnew);
631  }
632 }
633 
634 
635 //__________________________________________________________________________________________________
637  double valshift, double valrot )
638 {
639  unsigned int nAlignables = alivec.size();
640 
641  for (unsigned int i = 0; i < nAlignables; ++i)
642  {
643  Alignable* ali = alivec[i];
644 
645  // First reset APE
646  AlignmentPositionError nulApe(0,0,0);
647  ali->setAlignmentPositionError(nulApe, true);
648 
649  // Set APE from displacement
650  AlignmentPositionError ape(valshift,valshift,valshift);
651  if ( valshift > 0. ) ali->addAlignmentPositionError(ape, true);
652  else ali->setAlignmentPositionError(ape, true);
653  // GF: Resetting and setting as above does not really make sense to me,
654  // and adding to zero or setting is the same! I'd just do
655  //ali->setAlignmentPositionError(AlignmentPositionError ape(valshift,valshift,valshift),true);
656 
657  // Set APE from rotation
659  r(1)=valrot; r(2)=valrot; r(3)=valrot;
661  }
662 
663  LogDebug("StoreAPE") << "Store APE from shift: " << valshift
664  << "\nStore APE from rotation: " << valrot;
665 }
666 
667 //__________________________________________________________________________________________________
670  std::vector<std::vector<ParameterId> > &paramIdsVecOut,
671  std::vector<std::vector<double> > &factorsVecOut,
672  bool all, double epsilon) const
673 {
674  // Weak point if all = false:
675  // Ignores constraints between non-subsequent levels in case the parameter is not considered in
676  // the intermediate level, e.g. global z for dets and layers is aligned, but not for rods!
677  if (!ali || !ali->alignmentParameters()) return false;
678 
679  const std::vector<bool> &aliSel= ali->alignmentParameters()->selector();
680  paramIdsVecOut.clear();
681  factorsVecOut.clear();
682 
683  bool firstComp = true;
684  for (align::Alignables::const_iterator iComp = aliComps.begin(), iCompE = aliComps.end();
685  iComp != iCompE; ++iComp) {
686 
687  const ParametersToParametersDerivatives p2pDerivs(**iComp, *ali);
688  if (!p2pDerivs.isOK()) {
689  throw cms::Exception("BadConfig")
690  << "AlignmentParameterStore::hierarchyConstraints"
691  << " Bad match of types of AlignmentParameters classes.\n";
692  return false;
693  }
694  const std::vector<bool> &aliCompSel = (*iComp)->alignmentParameters()->selector();
695  for (unsigned int iParMast = 0, iParMastUsed = 0; iParMast < aliSel.size(); ++iParMast) {
696  if (!all && !aliSel[iParMast]) continue;// no higher level parameter & constraint deselected
697  if (firstComp) { // fill output with empty arrays
698  paramIdsVecOut.push_back(std::vector<ParameterId>());
699  factorsVecOut.push_back(std::vector<double>());
700  }
701  for (unsigned int iParComp = 0; iParComp < aliCompSel.size(); ++iParComp) {
702  if (aliCompSel[iParComp]) {
703  double factor = 0.;
704  if( theTypeOfConstraints == HIERARCHY_CONSTRAINTS ) {
705  // hierachy constraints
706  factor = p2pDerivs(iParMast, iParComp);
707  } else if( theTypeOfConstraints == APPROX_AVERAGING_CONSTRAINTS ) {
708  // CHK poor mans averaging constraints
709  factor = p2pDerivs(iParMast, iParComp);
710  if (iParMast < 3 && (iParComp % 9) >= 3) factor = 0.;
711  }
712  if (fabs(factor) > epsilon) {
713  paramIdsVecOut[iParMastUsed].push_back(ParameterId(*iComp, iParComp));
714  factorsVecOut[iParMastUsed].push_back(factor);
715  }
716  }
717  }
718  ++iParMastUsed;
719  }
720  firstComp = false;
721  } // end loop on components
722 
723  return true;
724 }
#define LogDebug(id)
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 &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
void resetParameters(void)
reset parameters, correlations, user variables
std::map< std::pair< Alignable *, Alignable * >, AlgebraicMatrix > Correlations
T y() const
Cartesian y coordinate.
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const
virtual RigidBodyAlignmentParameters * clone(const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const
Clone all parameters (for update of parameters)
std::pair< int, int > typeAndLayer(const Alignable *ali, const TrackerTopology *tTopo) const
Obtain type and layer from Alignable.
std::pair< Alignable *, unsigned int > ParameterId
a single alignable parameter of an Alignable
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rotation, bool propagateDown)=0
AlgebraicVector selectedParameters(void) const
Get selected parameters.
void setAlignmentPositionError(const align::Alignables &alivec, double valshift, double valrot)
Set Alignment position error.
align::Alignables validAlignables(void) const
get all alignables with valid parameters
uint32_t ID
Definition: Definitions.h:26
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.
Definition: Alignable.h:140
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.
Definition: Alignable.h:137
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)
Definition: FindCaloHit.cc:7
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.
Definition: Alignable.h:57
void updateParameters(const CompositeAlignmentParameters &aap, bool updateCorrelations=true)
update parameters
std::vector< AlignableRelData > AlignableShifts
Definition: AlignableData.h:52
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.
Definition: Alignable.h:143
virtual void setCorrelations(Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
std::vector< AlignmentParameters * > Parameters
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:110
CLHEP::HepMatrix AlgebraicMatrix
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Definition: Utilities.cc:196
void setValid(bool v)
Set validity flag.
AlignmentParameterStore(const align::Alignables &alis, const edm::ParameterSet &config)
constructor
Rot3< T > rot
bool hierarchyConstraints(const Alignable *aliMaster, const align::Alignables &aliComps, std::vector< std::vector< ParameterId > > &paramIdsVecOut, 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
tuple result
Definition: query.py:137
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const AlgebraicSymMatrix & covariance() const
Get parameter covariance matrix.
virtual void resetCorrelations(void)
Reset correlations.
(Abstract) Base class for alignment algorithm user variables
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:7
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.
Definition: Alignable.h:131
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.
Alignable * alignableFromAlignableDet(const AlignableDetOrUnitPtr &alignableDet) const
Obsolete: Use AlignableNavigator::alignableDetFromGeomDet and alignableFromAlignableDet.
int numSelected(void) const
Get number of selected parameters.
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
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
Definition: Utilities.h:28
AlignmentCorrelationsStore * theCorrelationsStore
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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.
Definition: Utilities.cc:40
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< AlignableAbsData > AlignablePositions
Definition: AlignableData.h:51
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:134
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
void attachAlignmentParameters(const align::Alignables &alivec, const Parameters &parvec, int &ierr)
Attach alignment parameters to given alignables.
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:90
virtual void apply()=0
apply parameters to alignable
const align::Alignables & alignables(void) const
get all alignables