CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
AlignableModifier Class Reference

#include <AlignableModifier.h>

Public Member Functions

void addAlignmentPositionError (Alignable *alignable, float dx, float dy, float dz)
 Add the AlignmentPositionError (in global frame) to Alignable. More...
 
void addAlignmentPositionErrorFromLocalRotation (Alignable *alignable, float phiX, float phiY, float phiZ)
 Add alignment position error resulting from rotation in local frame. More...
 
void addAlignmentPositionErrorFromLocalRotation (Alignable *alignable, align::RotationType &)
 Add alignment position error resulting from rotation in local frame. More...
 
void addAlignmentPositionErrorFromRotation (Alignable *alignable, float phiX, float phiY, float phiZ)
 Add alignment position error resulting from rotation in global frame. More...
 
void addAlignmentPositionErrorFromRotation (Alignable *alignable, align::RotationType &)
 Add alignment position error resulting from rotation in global frame. More...
 
void addAlignmentPositionErrorLocal (Alignable *alignable, float dx, float dy, float dz)
 Add the AlignmentPositionError (in local frame) to Alignable. More...
 
 AlignableModifier ()
 Constructor. More...
 
const std::vector< float > flatRandomVector (float sigmaX, float sigmaY, float sigmaZ) const
 Return a vector of random numbers (flat distribution) More...
 
const std::vector< float > gaussianRandomVector (float sigmaX, float sigmaY, float sigmaZ) const
 Return a vector of random numbers (gaussian distribution) More...
 
bool isPropagated (const std::string &parameterName) const
 Check if given parameter should be propagated. More...
 
bool modify (Alignable *alignable, const edm::ParameterSet &pSet)
 Modify given set of alignables according to parameters. More...
 
void moveAlignable (Alignable *alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ)
 Move alignable in global space according to parameters. More...
 
void moveAlignableLocal (Alignable *alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ)
 Move alignable in local space according to parameters. More...
 
void randomise (std::vector< double > &rnd, bool gaussian) const
 
void rotateAlignable (Alignable *alignable, bool random, bool gaussian, float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ)
 Rotate alignable in global space according to parameters. More...
 
void rotateAlignableLocal (Alignable *alignable, bool random, bool gaussian, float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ)
 Rotate alignable in local space according to parameters. More...
 
void setDistribution (const std::string &distr)
 Decodes string and sets distribution accordingly ('fixed', 'flat' or 'gaussian'). More...
 
void setSeed (long seed)
 Resets the generator seed according to the argument. More...
 
 ~AlignableModifier ()
 Destructor. More...
 

Private Types

typedef std::pair< std::string,
std::vector< double > > 
DeformationMemberType
 

Private Member Functions

void addDeformation (Alignable *alignable, const DeformationMemberType &deformation, bool random, bool gaussian, double scale)
 
void init_ ()
 Initialisation of all parameters. More...
 

Private Attributes

DeformationMemberType deformation_
 
std::string distribution_
 
double dX_
 
double dXlocal_
 
double dY_
 
double dYlocal_
 
double dZ_
 
double dZlocal_
 
bool gaussian_
 
int m_modified
 
double phiX_
 
double phiXlocal_
 
double phiY_
 
double phiYlocal_
 
double phiZ_
 
double phiZlocal_
 
bool random_
 
double scale_
 
double scaleError_
 
long seed_
 
bool setError_
 
bool setRotations_
 
bool setTranslations_
 
double shear_
 
CLHEP::DRand48Engine * theDRand48Engine
 Unique random number generator. More...
 
double twist_
 

Detailed Description

Definition at line 19 of file AlignableModifier.h.

Member Typedef Documentation

typedef std::pair<std::string,std::vector<double> > AlignableModifier::DeformationMemberType
private

Definition at line 92 of file AlignableModifier.h.

Constructor & Destructor Documentation

AlignableModifier::AlignableModifier ( void  )

Constructor.

Definition at line 20 of file AlignableModifier.cc.

References theDRand48Engine.

20  :
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 }
std::string distribution_
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
AlignableModifier::~AlignableModifier ( )

Destructor.

Definition at line 39 of file AlignableModifier.cc.

References theDRand48Engine.

40 {
41 
42  delete theDRand48Engine;
43 
44 }
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.

Member Function Documentation

void AlignableModifier::addAlignmentPositionError ( Alignable alignable,
float  dx,
float  dy,
float  dz 
)

Add the AlignmentPositionError (in global frame) to Alignable.

Definition at line 545 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionError(), and LogDebug.

Referenced by modify(), MuonScenarioBuilder::moveChamberInSector(), and MuonScenarioBuilder::moveMuon().

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 }
#define LogDebug(id)
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)=0
void AlignableModifier::addAlignmentPositionErrorFromLocalRotation ( Alignable alignable,
float  phiX,
float  phiY,
float  phiZ 
)

Add alignment position error resulting from rotation in local frame.

Definition at line 601 of file AlignableModifier.cc.

References makeMuonMisalignmentScenario::rot.

Referenced by modify().

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 }
void addAlignmentPositionErrorFromLocalRotation(Alignable *alignable, float phiX, float phiY, float phiZ)
Add alignment position error resulting from rotation in local frame.
void AlignableModifier::addAlignmentPositionErrorFromLocalRotation ( Alignable alignable,
align::RotationType rotation 
)

Add alignment position error resulting from rotation in local frame.

Definition at line 630 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionErrorFromLocalRotation(), LogDebug, and idealTransformation::rotation.

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 }
#define LogDebug(id)
virtual void addAlignmentPositionErrorFromLocalRotation(const RotationType &rotation, bool propagateDown)=0
void AlignableModifier::addAlignmentPositionErrorFromRotation ( Alignable alignable,
float  phiX,
float  phiY,
float  phiZ 
)

Add alignment position error resulting from rotation in global frame.

Definition at line 585 of file AlignableModifier.cc.

References makeMuonMisalignmentScenario::rot.

Referenced by modify(), MuonScenarioBuilder::moveChamberInSector(), and MuonScenarioBuilder::moveMuon().

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 }
void addAlignmentPositionErrorFromRotation(Alignable *alignable, float phiX, float phiY, float phiZ)
Add alignment position error resulting from rotation in global frame.
void AlignableModifier::addAlignmentPositionErrorFromRotation ( Alignable alignable,
align::RotationType rotation 
)

Add alignment position error resulting from rotation in global frame.

Definition at line 617 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionErrorFromRotation(), LogDebug, and idealTransformation::rotation.

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 }
#define LogDebug(id)
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rotation, bool propagateDown)=0
void AlignableModifier::addAlignmentPositionErrorLocal ( Alignable alignable,
float  dx,
float  dy,
float  dz 
)

Add the AlignmentPositionError (in local frame) to Alignable.

Definition at line 559 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionError(), Alignable::globalRotation(), LogDebug, TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

Referenced by SurveyDataConverter::applyAPEs(), and modify().

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 }
#define LogDebug(id)
T xx() const
T yx() const
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:132
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)=0
T zx() const
T xy() const
T zz() const
CLHEP::HepMatrix AlgebraicMatrix
T zy() const
T yy() const
T xz() const
CLHEP::HepSymMatrix AlgebraicSymMatrix
T yz() const
void AlignableModifier::addDeformation ( Alignable alignable,
const DeformationMemberType deformation,
bool  random,
bool  gaussian,
double  scale 
)
private

Definition at line 351 of file AlignableModifier.cc.

References Alignable::addSurfaceDeformation(), SurfaceDeformationFactory::create(), i, SurfaceDeformationFactory::kTwoBowedSurfaces, pileupReCalc_HLTpaths::scale, and SurfaceDeformationFactory::surfaceDeformationType().

Referenced by modify().

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 }
int i
Definition: DBlmapReader.cc:9
TRandom random
Definition: MVATrainer.cc:138
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)=0
void randomise(std::vector< double > &rnd, bool gaussian) const
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)
const std::vector< float > AlignableModifier::flatRandomVector ( float  sigmaX,
float  sigmaY,
float  sigmaZ 
) const

Return a vector of random numbers (flat distribution)

Definition at line 495 of file AlignableModifier.cc.

References abs, and theDRand48Engine.

Referenced by moveAlignable(), moveAlignableLocal(), MuonScenarioBuilder::moveCSCSectors(), MuonScenarioBuilder::moveDTSectors(), MuonScenarioBuilder::moveMuon(), rotateAlignable(), and rotateAlignableLocal().

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 }
#define abs(x)
Definition: mlp_lapack.h:159
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
const std::vector< float > AlignableModifier::gaussianRandomVector ( float  sigmaX,
float  sigmaY,
float  sigmaZ 
) const

Return a vector of random numbers (gaussian distribution)

Definition at line 461 of file AlignableModifier.cc.

References abs, and theDRand48Engine.

Referenced by moveAlignable(), moveAlignableLocal(), MuonScenarioBuilder::moveCSCSectors(), MuonScenarioBuilder::moveDTSectors(), MuonScenarioBuilder::moveMuon(), rotateAlignable(), and rotateAlignableLocal().

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 }
#define abs(x)
Definition: mlp_lapack.h:159
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
void AlignableModifier::init_ ( void  )
private

Initialisation of all parameters.

Definition at line 47 of file AlignableModifier.cc.

References deformation_, distribution_, dX_, dXlocal_, dY_, dYlocal_, dZ_, dZlocal_, gaussian_, phiX_, phiXlocal_, phiY_, phiYlocal_, phiZ_, phiZlocal_, random_, scale_, scaleError_, setError_, setRotations_, setTranslations_, shear_, and twist_.

Referenced by modify().

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 }
std::string distribution_
DeformationMemberType deformation_
bool AlignableModifier::isPropagated ( const std::string &  parameterName) const

Check if given parameter should be propagated.

Definition at line 82 of file AlignableModifier.cc.

Referenced by MisalignmentScenarioBuilder::propagateParameters_().

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 }
bool AlignableModifier::modify ( Alignable alignable,
const edm::ParameterSet pSet 
)

Modify given set of alignables according to parameters.

All known parameters and defaults are defined here! Returns true if modification actually applied.

Definition at line 100 of file AlignableModifier.cc.

References abs, addAlignmentPositionError(), addAlignmentPositionErrorFromLocalRotation(), addAlignmentPositionErrorFromRotation(), addAlignmentPositionErrorLocal(), addDeformation(), deformation_, distribution_, dX_, dXlocal_, dY_, dYlocal_, dZ_, dZlocal_, error, edm::hlt::Exception, edm::ParameterSet::existsAs(), gaussian_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), init_(), m_modified, moveAlignable(), moveAlignableLocal(), phiX_, phiXlocal_, phiY_, phiYlocal_, phiZ_, phiZlocal_, random_, rotateAlignable(), rotateAlignableLocal(), scale_, scaleError_, setDistribution(), setError_, setRotations_, setTranslations_, shear_, and twist_.

Referenced by MisalignmentScenarioBuilder::decodeMovements_().

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,
212 
213  // Error on local displacements
215  this->addAlignmentPositionErrorLocal( alignable,
218 
219  // Error on rotations
221  this->addAlignmentPositionErrorFromRotation( alignable,
223  scaleError_*phiZ_ );
224 
225  // Error on local rotations
227  && setRotations_ )
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 }
T getParameter(std::string const &) const
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
void addAlignmentPositionError(Alignable *alignable, float dx, float dy, float dz)
Add the AlignmentPositionError (in global frame) to Alignable.
#define abs(x)
Definition: mlp_lapack.h:159
void init_()
Initialisation of all parameters.
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)
void moveAlignable(Alignable *alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ)
Move alignable in global space according to parameters.
void setDistribution(const std::string &distr)
Decodes string and sets distribution accordingly (&#39;fixed&#39;, &#39;flat&#39; or &#39;gaussian&#39;). ...
std::vector< std::string > getParameterNames() const
DeformationMemberType deformation_
void rotateAlignable(Alignable *alignable, bool random, bool gaussian, float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ)
Rotate alignable in global space according to parameters.
void addAlignmentPositionErrorFromRotation(Alignable *alignable, float phiX, float phiY, float phiZ)
Add alignment position error resulting from rotation in global frame.
void moveAlignableLocal(Alignable *alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ)
Move alignable in local space according to parameters.
void AlignableModifier::moveAlignable ( Alignable alignable,
bool  random,
bool  gaussian,
float  sigmaX,
float  sigmaY,
float  sigmaZ 
)

Move alignable in global space according to parameters.

If 'random' is false, the given movements are strictly applied. Otherwise, a random number is generated according to a gaussian or a flat distribution depending on 'gaussian'.

Definition at line 280 of file AlignableModifier.cc.

References flatRandomVector(), gaussianRandomVector(), LogDebug, m_modified, python.rootplot.argparse::message, and Alignable::move().

Referenced by modify(), MuonScenarioBuilder::moveChamberInSector(), and MuonScenarioBuilder::moveMuon().

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 }
#define LogDebug(id)
const std::vector< float > gaussianRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (gaussian distribution)
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
TRandom random
Definition: MVATrainer.cc:138
const std::vector< float > flatRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (flat distribution)
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void AlignableModifier::moveAlignableLocal ( Alignable alignable,
bool  random,
bool  gaussian,
float  sigmaX,
float  sigmaY,
float  sigmaZ 
)

Move alignable in local space according to parameters.

If 'random' is false, the given movements are strictly applied. Otherwise, a random number is generated according to a gaussian or a flat distribution depending on 'gaussian'.

Definition at line 316 of file AlignableModifier.cc.

References flatRandomVector(), gaussianRandomVector(), LogDebug, m_modified, python.rootplot.argparse::message, Alignable::move(), Alignable::surface(), and AlignableSurface::toGlobal().

Referenced by modify().

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 }
#define LogDebug(id)
const std::vector< float > gaussianRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (gaussian distribution)
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
TRandom random
Definition: MVATrainer.cc:138
const std::vector< float > flatRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (flat distribution)
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
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
void AlignableModifier::randomise ( std::vector< double > &  rnd,
bool  gaussian 
) const

Randomise all entries in 'rnd':

  • either from gaussian with width rnd[i]
  • or from flat distribution between -rnd[i] and rnd[i]

Definition at line 526 of file AlignableModifier.cc.

References abs, i, and theDRand48Engine.

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 }
int i
Definition: DBlmapReader.cc:9
#define abs(x)
Definition: mlp_lapack.h:159
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
void AlignableModifier::rotateAlignable ( Alignable alignable,
bool  random,
bool  gaussian,
float  sigmaPhiX,
float  sigmaPhiY,
float  sigmaPhiZ 
)

Rotate alignable in global space according to parameters.

If 'random' is false, the given rotations are strictly applied. Otherwise, a random number is generated according to a gaussian or a flat distribution depending on 'gaussian'.

Definition at line 384 of file AlignableModifier.cc.

References abs, flatRandomVector(), gaussianRandomVector(), LogDebug, m_modified, python.rootplot.argparse::message, Alignable::rotateAroundGlobalX(), Alignable::rotateAroundGlobalY(), Alignable::rotateAroundGlobalZ(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by modify(), MuonScenarioBuilder::moveChamberInSector(), and MuonScenarioBuilder::moveMuon().

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 }
#define LogDebug(id)
const std::vector< float > gaussianRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (gaussian distribution)
#define abs(x)
Definition: mlp_lapack.h:159
TRandom random
Definition: MVATrainer.cc:138
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
Definition: Alignable.cc:174
const std::vector< float > flatRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (flat distribution)
virtual void rotateAroundGlobalX(Scalar radians)
Rotation around global x-axis.
Definition: Alignable.cc:122
virtual void rotateAroundGlobalY(Scalar radians)
Rotation around global y-axis.
Definition: Alignable.cc:148
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void AlignableModifier::rotateAlignableLocal ( Alignable alignable,
bool  random,
bool  gaussian,
float  sigmaPhiX,
float  sigmaPhiY,
float  sigmaPhiZ 
)

Rotate alignable in local space according to parameters.

If 'random' is false, the given rotations are strictly applied. Otherwise, a random number is generated according to a gaussian or a flat distribution depending on 'gaussian'.

Definition at line 423 of file AlignableModifier.cc.

References abs, flatRandomVector(), gaussianRandomVector(), LogDebug, m_modified, python.rootplot.argparse::message, Alignable::rotateAroundLocalX(), Alignable::rotateAroundLocalY(), Alignable::rotateAroundLocalZ(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by modify().

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 }
#define LogDebug(id)
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
Definition: Alignable.cc:187
const std::vector< float > gaussianRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (gaussian distribution)
#define abs(x)
Definition: mlp_lapack.h:159
TRandom random
Definition: MVATrainer.cc:138
const std::vector< float > flatRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (flat distribution)
Vector3DBase< Scalar, LocalTag > LocalVector
Definition: Definitions.h:34
virtual void rotateAroundLocalY(Scalar radians)
Rotation around local y-axis.
Definition: Alignable.cc:161
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
Definition: Alignable.cc:135
void AlignableModifier::setDistribution ( const std::string &  distr)

Decodes string and sets distribution accordingly ('fixed', 'flat' or 'gaussian').

Definition at line 243 of file AlignableModifier.cc.

References gaussian_, and random_.

Referenced by modify().

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 }
void AlignableModifier::setSeed ( long  seed)

Resets the generator seed according to the argument.

If 'seed' is zero, asks RandomNumberGenerator service.

Definition at line 260 of file AlignableModifier.cc.

References LogDebug, edm::RandomNumberGenerator::mySeed(), and theDRand48Engine.

Referenced by MuonScenarioBuilder::applyScenario(), and TrackerScenarioBuilder::applyScenario().

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 }
#define LogDebug(id)
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
virtual uint32_t mySeed() const =0
Exists for backward compatibility.

Member Data Documentation

DeformationMemberType AlignableModifier::deformation_
private

Definition at line 114 of file AlignableModifier.h.

Referenced by init_(), and modify().

std::string AlignableModifier::distribution_
private

Definition at line 105 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::dX_
private

Definition at line 112 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::dXlocal_
private

Definition at line 113 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::dY_
private

Definition at line 112 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::dYlocal_
private

Definition at line 113 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::dZ_
private

Definition at line 112 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::dZlocal_
private

Definition at line 113 of file AlignableModifier.h.

Referenced by init_(), and modify().

bool AlignableModifier::gaussian_
private

Definition at line 106 of file AlignableModifier.h.

Referenced by init_(), modify(), and setDistribution().

int AlignableModifier::m_modified
private
double AlignableModifier::phiX_
private

Definition at line 110 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::phiXlocal_
private

Definition at line 111 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::phiY_
private

Definition at line 110 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::phiYlocal_
private

Definition at line 111 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::phiZ_
private

Definition at line 110 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::phiZlocal_
private

Definition at line 111 of file AlignableModifier.h.

Referenced by init_(), and modify().

bool AlignableModifier::random_
private

Definition at line 106 of file AlignableModifier.h.

Referenced by init_(), modify(), and setDistribution().

double AlignableModifier::scale_
private

Definition at line 109 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::scaleError_
private

Definition at line 109 of file AlignableModifier.h.

Referenced by init_(), and modify().

long AlignableModifier::seed_
private

Definition at line 108 of file AlignableModifier.h.

bool AlignableModifier::setError_
private

Definition at line 106 of file AlignableModifier.h.

Referenced by init_(), and modify().

bool AlignableModifier::setRotations_
private

Definition at line 107 of file AlignableModifier.h.

Referenced by init_(), and modify().

bool AlignableModifier::setTranslations_
private

Definition at line 107 of file AlignableModifier.h.

Referenced by init_(), and modify().

double AlignableModifier::shear_
private

Definition at line 115 of file AlignableModifier.h.

Referenced by init_(), and modify().

CLHEP::DRand48Engine* AlignableModifier::theDRand48Engine
private

Unique random number generator.

Definition at line 97 of file AlignableModifier.h.

Referenced by AlignableModifier(), flatRandomVector(), gaussianRandomVector(), randomise(), setSeed(), and ~AlignableModifier().

double AlignableModifier::twist_
private

Definition at line 115 of file AlignableModifier.h.

Referenced by init_(), and modify().