CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignableModifier.cc
Go to the documentation of this file.
1 #include <memory>
2 
3 #include "CLHEP/Random/DRand48Engine.h"
4 #include "CLHEP/Random/RandGauss.h"
5 #include "CLHEP/Random/Randomize.h"
6 
12 
15 
18 
19 //__________________________________________________________________________________________________
21  distribution_(""),
22  random_(false), gaussian_(false), setError_(false),
23  setRotations_(false),setTranslations_(false),
24  seed_(0),
25  scaleError_(0.), scale_(0.),
26  phiX_(0.), phiY_(0.), phiZ_(0.),
27  phiXlocal_(0.), phiYlocal_(0.), phiZlocal_(0.),
28  dX_(0.), dY_(0.), dZ_(0.),
29  dXlocal_(0.), dYlocal_(0.), dZlocal_(0.),
30  twist_(0.), shear_(0.)
31 {
32 
33  theDRand48Engine = new CLHEP::DRand48Engine();
34 
35 }
36 
37 
38 //__________________________________________________________________________________________________
40 {
41 
42  delete theDRand48Engine;
43 
44 }
45 
46 //__________________________________________________________________________________________________
48 {
49 
50  // Initialize all known parameters (according to ORCA's MisalignmentScenario.cc)
51  distribution_ = ""; // Switch for distributions ("fixed","flat","gaussian")
52  setError_ = false; // Apply alignment errors
53  setRotations_ = true; // Apply rotations
54  setTranslations_ = true; // Apply translations
55  scale_ = 1.; // Scale to apply to all movements
56  scaleError_ = 1.; // Scale to apply to alignment errors
57  phiX_ = 0.; // Rotation angle around X [rad]
58  phiY_ = 0.; // Rotation angle around Y [rad]
59  phiZ_ = 0.; // Rotation angle around Z [rad]
60  phiXlocal_ = 0.; // Local rotation angle around X [rad]
61  phiYlocal_ = 0.; // Local rotation angle around Y [rad]
62  phiZlocal_ = 0.; // Local rotation angle around Z [rad]
63  dX_ = 0.; // X displacement [cm]
64  dY_ = 0.; // Y displacement [cm]
65  dZ_ = 0.; // Z displacement [cm]
66  dXlocal_ = 0.; // Local X displacement [cm]
67  dYlocal_ = 0.; // Local Y displacement [cm]
68  dZlocal_ = 0.; // Local Z displacement [cm]
69  deformation_.first.clear();// SurfaceDeformation: type
70  deformation_.second.clear();//SurfaceDeformation: parameter vector
71  twist_ = 0.; // Twist angle [rad]
72  shear_ = 0.; // Shear angle [rad]
73 
74  // These are set through 'distribution'
75  random_ = true; // Use random distributions
76  gaussian_ = true; // Use gaussian distribution (otherwise flat)
77 
78 }
79 
80 //__________________________________________________________________________________________________
81 // Return true if given parameter name should be propagated down
82 bool AlignableModifier::isPropagated( const std::string& parameterName ) const
83 {
84 
85  if ( parameterName == "distribution" ||
86  parameterName == "setError" ||
87  parameterName == "scaleError" ||
88  parameterName == "setRotations" ||
89  parameterName == "setTranslations" ||
90  parameterName == "scale"
91  ) return true;
92 
93  return false;
94 
95 }
96 
97 
98 //__________________________________________________________________________________________________
101 {
102 
103  // Initialize parameters
104  this->init_();
105  int rotX_=0, rotY_=0, rotZ_=0; // To check correct backward compatibility
106 
107 
108  // Reset counter
109  m_modified = 0;
110 
111  // Retrieve parameters
112  std::ostringstream error;
113  std::vector<std::string> parameterNames = pSet.getParameterNames();
114  for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
115  iParam != parameterNames.end(); iParam++ ) {
116  if ( (*iParam) == "distribution" ) distribution_ = pSet.getParameter<std::string>( *iParam );
117  else if ( (*iParam) == "setError" ) setError_ = pSet.getParameter<bool>( *iParam );
118  else if ( (*iParam) == "setRotations") setRotations_ = pSet.getParameter<bool>( *iParam );
119  else if ( (*iParam) == "setTranslations") setTranslations_ = pSet.getParameter<bool>( *iParam );
120  else if ( (*iParam) == "scale" ) scale_ = pSet.getParameter<double>( *iParam );
121  else if ( (*iParam) == "scaleError" ) scaleError_ = pSet.getParameter<double>( *iParam );
122  else if ( (*iParam) == "phiX" ) phiX_ = pSet.getParameter<double>( *iParam );
123  else if ( (*iParam) == "phiY" ) phiY_ = pSet.getParameter<double>( *iParam );
124  else if ( (*iParam) == "phiZ" ) phiZ_ = pSet.getParameter<double>( *iParam );
125  else if ( (*iParam) == "dX" ) dX_ = pSet.getParameter<double>( *iParam );
126  else if ( (*iParam) == "dY" ) dY_ = pSet.getParameter<double>( *iParam );
127  else if ( (*iParam) == "dZ" ) dZ_ = pSet.getParameter<double>( *iParam );
128  else if ( (*iParam) == "dXlocal" ) dXlocal_ = pSet.getParameter<double>( *iParam );
129  else if ( (*iParam) == "dYlocal" ) dYlocal_ = pSet.getParameter<double>( *iParam );
130  else if ( (*iParam) == "dZlocal" ) dZlocal_ = pSet.getParameter<double>( *iParam );
131  else if ( (*iParam) == "twist" ) twist_ = pSet.getParameter<double>( *iParam );
132  else if ( (*iParam) == "shear" ) shear_ = pSet.getParameter<double>( *iParam );
133  else if ( (*iParam) == "localX" ) { phiXlocal_=pSet.getParameter<double>( *iParam ); rotX_++; }
134  else if ( (*iParam) == "localY" ) { phiYlocal_=pSet.getParameter<double>( *iParam ); rotY_++; }
135  else if ( (*iParam) == "localZ" ) { phiZlocal_=pSet.getParameter<double>( *iParam ); rotZ_++; }
136  else if ( (*iParam) == "phiXlocal" ) { phiXlocal_=pSet.getParameter<double>( *iParam ); rotX_++; }
137  else if ( (*iParam) == "phiYlocal" ) { phiYlocal_=pSet.getParameter<double>( *iParam ); rotY_++; }
138  else if ( (*iParam) == "phiZlocal" ) { phiZlocal_=pSet.getParameter<double>( *iParam ); rotZ_++; }
139  else if ( (*iParam) == "deformation" ) {
140  const edm::ParameterSet deform(pSet.getParameter<edm::ParameterSet>( *iParam ));
141  deformation_.first = deform.getParameter<std::string>("type");
142  deformation_.second = deform.getParameter<std::vector<double> >("parameters");
143  // a non-complete check of simple mistyping of "deformation"
144  // i.e. should detect at least a single wrong character... HACK
145  } else if (pSet.existsAs<edm::ParameterSet>(*iParam)
146  && ((*iParam).find("deform") != std::string::npos ||
147  (*iParam).find("ation") != std::string::npos)) {
148  throw cms::Exception("BadConfig") << "Probable mistyping in config: '" << (*iParam)
149  << "' should probably mean 'deformation'\n";
150  } else if ( !pSet.existsAs<edm::ParameterSet>(*iParam) ) { // other PSets are OK to ignore
151  if ( !error.str().length() ) error << "Unknown parameter name(s): ";
152  error << " " << *iParam;
153  }
154  }
155 
156  // Check if both 'localN' and 'phiNlocal' have been used
157  if ( rotX_==2 ) throw cms::Exception("BadConfig") << "Found both localX and phiXlocal";
158  if ( rotY_==2 ) throw cms::Exception("BadConfig") << "Found both localY and phiYlocal";
159  if ( rotZ_==2 ) throw cms::Exception("BadConfig") << "Found both localZ and phiZlocal";
160 
161  // Check error
162  if ( error.str().length() )
163  throw cms::Exception("BadConfig") << error.str();
164 
165  // Decode distribution
167 
168  //if (scale_) { NO! Different random sequence if only parts scale to zero!
169 
170  // Apply displacements
171  if ( std::abs(dX_) + std::abs(dY_) + std::abs(dZ_) > 0 && setTranslations_ )
172  this->moveAlignable( alignable, random_, gaussian_, scale_*dX_, scale_*dY_, scale_*dZ_ );
173 
174  // Apply local displacements
176  this->moveAlignableLocal( alignable, random_, gaussian_,
178 
179  // Apply rotations
181  this->rotateAlignable( alignable, random_, gaussian_,
183 
184  // Apply local rotations
186  this->rotateAlignableLocal( alignable, random_, gaussian_,
188 
189  // Apply twist
190  if ( std::abs(twist_) > 0 )
191  edm::LogError("NotImplemented") << "Twist is not implemented yet";
192 
193  // Apply shear
194  if ( std::abs(shear_) > 0 )
195  edm::LogError("NotImplemented") << "Shear is not implemented yet";
196 
197  if (!deformation_.first.empty()) {
198  this->addDeformation(alignable, deformation_, random_, gaussian_, scale_);
199  }
200 
201  // Apply error - first add scale_ to error
202  scaleError_ *= scale_;
203  if ( setError_ && scaleError_ ) {
204  // Alignment Position Error for flat distribution: 1 sigma
205  if ( !gaussian_ ) scaleError_ *= 0.68;
206 
207 
208  // Error on displacement
209  if ( std::abs(dX_) + std::abs(dY_) + std::abs(dZ_) > 0 && setTranslations_ )
210  this->addAlignmentPositionError( alignable,
211  scaleError_*dX_, scaleError_*dY_, scaleError_*dZ_ );
212 
213  // Error on local displacements
214  if ( std::abs(dXlocal_) + std::abs(dYlocal_) + std::abs(dZlocal_) > 0 && setTranslations_ )
215  this->addAlignmentPositionErrorLocal( alignable,
216  scaleError_*dXlocal_, scaleError_*dYlocal_,
217  scaleError_*dZlocal_ );
218 
219  // Error on rotations
220  if ( std::abs(phiX_) + std::abs(phiY_) + std::abs(phiZ_) > 0 && setRotations_ )
221  this->addAlignmentPositionErrorFromRotation( alignable,
222  scaleError_*phiX_, scaleError_*phiY_,
223  scaleError_*phiZ_ );
224 
225  // Error on local rotations
226  if ( std::abs(phiXlocal_) + std::abs(phiYlocal_) + std::abs(phiZlocal_) > 0
227  && setRotations_ )
229  scaleError_*phiXlocal_,
230  scaleError_*phiYlocal_,
231  scaleError_*phiZlocal_ );
232  // Do we need to add any APE for deformations?
233  // Probably we would do so if there wouldn't be data, but only MC to play with... ;-)
234  }
235  // } // end if (scale_)
236 
237  return ( m_modified > 0 );
238 
239 }
240 
241 
242 //__________________________________________________________________________________________________
243 void AlignableModifier::setDistribution( const std::string& distr )
244 {
245 
246  if ( distr == "fixed" ) random_ = false;
247  else if ( distr == "flat" ) {
248  random_ = true;
249  gaussian_ = false;
250  } else if ( distr == "gaussian" ) {
251  random_ = true;
252  gaussian_ = true;
253  }
254 
255 }
256 
257 
258 //__________________________________________________________________________________________________
260 void AlignableModifier::setSeed( const long seed )
261 {
262 
263  long m_seed;
264 
265  if ( seed > 0 ) m_seed = seed;
266  else {
268  m_seed = rng->mySeed();
269  }
270 
271  LogDebug("PrintArgs") << "Setting generator seed to " << m_seed;
272 
273  theDRand48Engine->setSeed( m_seed );
274 
275 }
276 
277 //__________________________________________________________________________________________________
280 void AlignableModifier::moveAlignable( Alignable* alignable, bool random, bool gaussian,
281  float sigmaX, float sigmaY, float sigmaZ )
282 {
283 
284 
285  std::ostringstream message;
286 
287  // Get movement vector according to arguments
288  GlobalVector moveV( sigmaX, sigmaY, sigmaZ ); // Default: fixed
289  if ( random ) {
290  std::vector<float> randomNumbers;
291  message << "random ";
292  if (gaussian) {
293  randomNumbers = this->gaussianRandomVector( sigmaX, sigmaY, sigmaZ );
294  message << "gaussian ";
295  } else {
296  randomNumbers = this->flatRandomVector( sigmaX, sigmaY, sigmaZ );
297  message << "flat ";
298  }
299  moveV = GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
300  }
301 
302  message << " move with sigma " << sigmaX << " " << sigmaY << " " << sigmaZ;
303 
304  LogDebug("PrintArgs") << message.str(); // Arguments
305 
306  LogDebug("PrintMovement") << "applied displacement: " << moveV; // Actual movements
307  alignable->move(moveV);
308  m_modified++;
309 
310 
311 }
312 
313 //__________________________________________________________________________________________________
316 void AlignableModifier::moveAlignableLocal( Alignable* alignable, bool random, bool gaussian,
317  float sigmaX, float sigmaY, float sigmaZ )
318 {
319 
320 
321  std::ostringstream message;
322 
323  // Get movement vector according to arguments
324  align::LocalVector moveV( sigmaX, sigmaY, sigmaZ ); // Default: fixed
325  if ( random ) {
326  std::vector<float> randomNumbers;
327  message << "random ";
328  if (gaussian) {
329  randomNumbers = this->gaussianRandomVector( sigmaX, sigmaY, sigmaZ );
330  message << "gaussian ";
331  } else {
332  randomNumbers = this->flatRandomVector( sigmaX, sigmaY, sigmaZ );
333  message << "flat ";
334  }
335  moveV = align::LocalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
336  }
337 
338  message << " move with sigma " << sigmaX << " " << sigmaY << " " << sigmaZ;
339 
340  LogDebug("PrintArgs") << message.str(); // Arguments
341 
342  LogDebug("PrintMovement") << "applied local displacement: " << moveV; // Actual movements
343  alignable->move( alignable->surface().toGlobal(moveV) );
344  m_modified++;
345 
346 
347 }
348 
349 //__________________________________________________________________________________________________
352  const AlignableModifier::DeformationMemberType &deformation,
353  bool random, bool gaussian, double scale)
354 {
355  const SurfaceDeformationFactory::Type deformType
357 
358  // Scale and randomize
359  // (need a little hack since ySplit must not be treated)!
360  const bool rndNotLast = (deformType == SurfaceDeformationFactory::kTwoBowedSurfaces);
361  std::vector<double> rndDeformation(deformation.second.begin(),
362  deformation.second.end() - (rndNotLast ? 1 : 0));
363  for (unsigned int i = 0; i < rndDeformation.size(); ++i) {
364  rndDeformation[i] *= scale;
365  }
366  if (random) {
367  this->randomise(rndDeformation, gaussian);
368  }
369  if (rndNotLast) { // put back ySplit at the end
370  rndDeformation.push_back(deformation.second.back());
371  }
372 
373  // auto_ptr has exception safe delete (in contrast to bare pointer)
374  const std::auto_ptr<SurfaceDeformation> surfDef
375  (SurfaceDeformationFactory::create(deformType, rndDeformation));
376 
377  alignable->addSurfaceDeformation(surfDef.get(), true); // true to propagate down
378  ++m_modified;
379 }
380 
381 //__________________________________________________________________________________________________
384 void AlignableModifier::rotateAlignable( Alignable* alignable, bool random, bool gaussian,
385  float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ )
386 {
387 
388 
389  std::ostringstream message;
390 
391  // Get rotation vector according to arguments
392  GlobalVector rotV( sigmaPhiX, sigmaPhiY, sigmaPhiZ ); // Default: fixed
393  if ( random ) {
394  std::vector<float> randomNumbers;
395  message << "random ";
396  if (gaussian) {
397  randomNumbers = this->gaussianRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
398  message << "gaussian ";
399  } else {
400  randomNumbers = flatRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
401  message << "flat ";
402  }
403  rotV = GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
404  }
405 
406  message << "global rotation by angles " << sigmaPhiX << " " << sigmaPhiY << " " << sigmaPhiZ;
407 
408  LogDebug("PrintArgs") << message.str(); // Arguments
409 
410  LogDebug("PrintMovement") << "applied rotation angles: " << rotV; // Actual movements
411  if ( std::abs(sigmaPhiX) ) alignable->rotateAroundGlobalX( rotV.x() );
412  if ( std::abs(sigmaPhiY) ) alignable->rotateAroundGlobalY( rotV.y() );
413  if ( std::abs(sigmaPhiZ) ) alignable->rotateAroundGlobalZ( rotV.z() );
414  m_modified++;
415 
416 
417 }
418 
419 //__________________________________________________________________________________________________
422 void
424  float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ )
425 {
426 
427 
428  std::ostringstream message;
429 
430  // Get rotation vector according to arguments
431  align::LocalVector rotV( sigmaPhiX, sigmaPhiY, sigmaPhiZ ); // Default: fixed
432  if ( random ) {
433  std::vector<float> randomNumbers;
434  message << "random ";
435  if (gaussian) {
436  randomNumbers = this->gaussianRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
437  message << "gaussian ";
438  } else {
439  randomNumbers = flatRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
440  message << "flat ";
441  }
442  rotV = align::LocalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
443  }
444 
445  message << "local rotation by angles " << sigmaPhiX << " " << sigmaPhiY << " " << sigmaPhiZ;
446 
447  LogDebug("PrintArgs") << message.str(); // Arguments
448 
449  LogDebug("PrintMovement") << "applied local rotation angles: " << rotV; // Actual movements
450  if ( std::abs(sigmaPhiX) ) alignable->rotateAroundLocalX( rotV.x() );
451  if ( std::abs(sigmaPhiY) ) alignable->rotateAroundLocalY( rotV.y() );
452  if ( std::abs(sigmaPhiZ) ) alignable->rotateAroundLocalZ( rotV.z() );
453  m_modified++;
454 
455 
456 }
457 
458 
459 //__________________________________________________________________________________________________
460 const std::vector<float>
461 AlignableModifier::gaussianRandomVector( float sigmaX, float sigmaY, float sigmaZ ) const
462 {
463 
464  // Get absolute value if negative arguments
465  if ( sigmaX < 0 ) {
466  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_x";
467  sigmaX = std::abs(sigmaX);
468  }
469  if ( sigmaY < 0 ) {
470  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_y";
471  sigmaY = std::abs(sigmaY);
472  }
473  if ( sigmaZ < 0 ) {
474  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_z";
475  sigmaZ = std::abs(sigmaZ);
476  }
477 
478  // Pass by reference, otherwise pointer is deleted!
479  CLHEP::RandGauss aGaussObjX( *theDRand48Engine, 0., sigmaX );
480  CLHEP::RandGauss aGaussObjY( *theDRand48Engine, 0., sigmaY );
481  CLHEP::RandGauss aGaussObjZ( *theDRand48Engine, 0., sigmaZ );
482 
483  std::vector<float> randomVector;
484  randomVector.push_back( aGaussObjX.fire() );
485  randomVector.push_back( aGaussObjY.fire() );
486  randomVector.push_back( aGaussObjZ.fire() );
487 
488  return randomVector;
489 
490 }
491 
492 
493 //__________________________________________________________________________________________________
494 const std::vector<float>
495 AlignableModifier::flatRandomVector( float sigmaX,float sigmaY, float sigmaZ ) const
496 {
497 
498  // Get absolute value if negative arguments
499  if ( sigmaX < 0 ) {
500  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_x";
501  sigmaX = std::abs(sigmaX);
502  }
503  if ( sigmaY < 0 ) {
504  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_y";
505  sigmaY = std::abs(sigmaY);
506  }
507  if ( sigmaZ < 0 ) {
508  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_z";
509  sigmaZ = std::abs(sigmaZ);
510  }
511 
512  CLHEP::RandFlat aFlatObjX( *theDRand48Engine, -sigmaX, sigmaX );
513  CLHEP::RandFlat aFlatObjY( *theDRand48Engine, -sigmaY, sigmaY );
514  CLHEP::RandFlat aFlatObjZ( *theDRand48Engine, -sigmaZ, sigmaZ );
515 
516  std::vector<float> randomVector;
517  randomVector.push_back( aFlatObjX.fire() );
518  randomVector.push_back( aFlatObjY.fire() );
519  randomVector.push_back( aFlatObjZ.fire() );
520 
521  return randomVector;
522 
523 }
524 
525 //__________________________________________________________________________________________________
526 void AlignableModifier::randomise(std::vector<double> &rnd, bool gaussian) const
527 {
528  for (unsigned int i = 0; i < rnd.size(); ++i) {
529  if (rnd[i] < 0.) {
530  edm::LogWarning("BadConfig") << " taking absolute value to randomise " << i;
531  rnd[i] = std::abs(rnd[i]);
532  }
533 
534  if (gaussian) {
535  CLHEP::RandGauss aGaussObj( *theDRand48Engine, 0., rnd[i]);
536  rnd[i] = aGaussObj.fire();
537  } else {
538  CLHEP::RandFlat aFlatObj(*theDRand48Engine, -rnd[i], rnd[i]);
539  rnd[i] = aFlatObj.fire();
540  }
541  }
542 }
543 
544 //__________________________________________________________________________________________________
546  float dx, float dy, float dz )
547 {
548 
549  LogDebug("PrintArgs") << "Adding an AlignmentPositionError of size "
550  << dx << " " << dy << " " << dz;
551 
552  AlignmentPositionError ape(dx,dy,dz);
553  alignable->addAlignmentPositionError( ape, true );
554 
555 }
556 
557 
558 //__________________________________________________________________________________________________
560  float dx, float dy, float dz )
561 {
562 
563  LogDebug("PrintArgs") << "Adding a local AlignmentPositionError of size "
564  << dx << " " << dy << " " << dz;
565 
566  AlgebraicSymMatrix as(3,0); //3x3, zeroed
567  as[0][0] = dx*dx; as[1][1] = dy*dy; as[2][2] = dz*dz; //diagonals
568  align::RotationType rt = alignable->globalRotation(); //get rotation
569  AlgebraicMatrix am(3,3);
570  am[0][0]=rt.xx(); am[0][1]=rt.xy(); am[0][2]=rt.xz();
571  am[1][0]=rt.yx(); am[1][1]=rt.yy(); am[1][2]=rt.yz();
572  am[2][0]=rt.zx(); am[2][1]=rt.zy(); am[2][2]=rt.zz();
573  as=as.similarityT(am); //rotate error matrix
574 
575  GlobalError ge( asSMatrix<3>(as) );
576  AlignmentPositionError ape( ge );
577 
578  alignable->addAlignmentPositionError( ape, true ); // propagate down to components
579 
580 }
581 
582 
583 
584 //__________________________________________________________________________________________________
586  float phiX, float phiY,
587  float phiZ )
588 {
589 
590  align::RotationType rotx( Basic3DVector<float>(1.0, 0.0, 0.0), phiX );
591  align::RotationType roty( Basic3DVector<float>(0.0, 1.0, 0.0), phiY );
592  align::RotationType rotz( Basic3DVector<float>(0.0, 0.0, 1.0), phiZ );
593  align::RotationType rot = rotz * roty * rotx;
594 
595  this->addAlignmentPositionErrorFromRotation( alignable, rot );
596 
597 }
598 
599 
600 //__________________________________________________________________________________________________
602  float phiX, float phiY,
603  float phiZ )
604 {
605 
606  align::RotationType rotx( Basic3DVector<float>(1.0, 0.0, 0.0), phiX );
607  align::RotationType roty( Basic3DVector<float>(0.0, 1.0, 0.0), phiY );
608  align::RotationType rotz( Basic3DVector<float>(0.0, 0.0, 1.0), phiZ );
609  align::RotationType rot = rotz * roty * rotx;
610 
611  this->addAlignmentPositionErrorFromLocalRotation( alignable, rot );
612 
613 }
614 
615 
616 //__________________________________________________________________________________________________
619 {
620 
621  LogDebug("PrintArgs") << "Adding an AlignmentPositionError from Rotation" << std::endl
622  << rotation;
623 
624  alignable->addAlignmentPositionErrorFromRotation(rotation, true); // propagate down to components
625 
626 }
627 
628 
629 //__________________________________________________________________________________________________
632 {
633 
634  LogDebug("PrintArgs") << "Adding an AlignmentPositionError from Local Rotation" << std::endl
635  << rotation;
636 
637  // true: propagate down to components
638  alignable->addAlignmentPositionErrorFromLocalRotation(rotation, true);
639 
640 }
641 
#define LogDebug(id)
T xx() const
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void addAlignmentPositionErrorFromLocalRotation(Alignable *alignable, float phiX, float phiY, float phiZ)
Add alignment position error resulting from rotation in local frame.
void rotateAlignableLocal(Alignable *alignable, bool random, bool gaussian, float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ)
Rotate alignable in local space according to parameters.
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
Definition: Alignable.cc:187
void setSeed(long seed)
Resets the generator seed according to the argument.
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rotation, bool propagateDown)=0
void addAlignmentPositionError(Alignable *alignable, float dx, float dy, float dz)
Add the AlignmentPositionError (in global frame) to Alignable.
~AlignableModifier()
Destructor.
const std::vector< float > gaussianRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (gaussian distribution)
T y() const
Definition: PV3DBase.h:62
T yx() const
#define abs(x)
Definition: mlp_lapack.h:159
void init_()
Initialisation of all parameters.
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:132
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
TRandom random
Definition: MVATrainer.cc:138
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)=0
void addAlignmentPositionErrorLocal(Alignable *alignable, float dx, float dy, float dz)
Add the AlignmentPositionError (in local frame) to Alignable.
std::string distribution_
void addDeformation(Alignable *alignable, const DeformationMemberType &deformation, bool random, bool gaussian, double scale)
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
Definition: Alignable.cc:174
T zx() const
T xy() const
virtual void addAlignmentPositionErrorFromLocalRotation(const RotationType &rotation, bool propagateDown)=0
void moveAlignable(Alignable *alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ)
Move alignable in global space according to parameters.
AlignableModifier()
Constructor.
T zz() const
CLHEP::HepMatrix AlgebraicMatrix
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)=0
void setDistribution(const std::string &distr)
Decodes string and sets distribution accordingly (&#39;fixed&#39;, &#39;flat&#39; or &#39;gaussian&#39;). ...
T z() const
Definition: PV3DBase.h:63
T zy() const
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
std::vector< std::string > getParameterNames() const
const std::vector< float > flatRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (flat distribution)
T yy() const
void randomise(std::vector< double > &rnd, bool gaussian) const
Vector3DBase< Scalar, LocalTag > LocalVector
Definition: Definitions.h:34
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
DeformationMemberType deformation_
void rotateAlignable(Alignable *alignable, bool random, bool gaussian, float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ)
Rotate alignable in global space according to parameters.
virtual void rotateAroundGlobalX(Scalar radians)
Rotation around global x-axis.
Definition: Alignable.cc:122
bool modify(Alignable *alignable, const edm::ParameterSet &pSet)
Modify given set of alignables according to parameters.
void addAlignmentPositionErrorFromRotation(Alignable *alignable, float phiX, float phiY, float phiZ)
Add alignment position error resulting from rotation in global frame.
virtual void rotateAroundLocalY(Scalar radians)
Rotation around local y-axis.
Definition: Alignable.cc:161
virtual void rotateAroundGlobalY(Scalar radians)
Rotation around global y-axis.
Definition: Alignable.cc:148
std::pair< std::string, std::vector< double > > DeformationMemberType
T xz() const
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
Definition: Alignable.cc:135
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
CLHEP::HepSymMatrix AlgebraicSymMatrix
bool isPropagated(const std::string &parameterName) const
Check if given parameter should be propagated.
void moveAlignableLocal(Alignable *alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ)
Move alignable in local space according to parameters.
T x() const
Definition: PV3DBase.h:61
Type surfaceDeformationType(const std::string &typeString)
convert string to &#39;Type&#39; - exception if string is not known
virtual uint32_t mySeed() const =0
Exists for backward compatibility.
SurfaceDeformation * create(int type, const std::vector< double > &params)
T yz() const
Global3DVector GlobalVector
Definition: GlobalVector.h:10