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