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