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...
 
const 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.

21 {
22 
23  theDRand48Engine = new CLHEP::DRand48Engine();
24 
25 }
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
AlignableModifier::~AlignableModifier ( )

Destructor.

Definition at line 29 of file AlignableModifier.cc.

References theDRand48Engine.

30 {
31 
32  delete theDRand48Engine;
33 
34 }
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 535 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionError(), and LogDebug.

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

537 {
538 
539  LogDebug("PrintArgs") << "Adding an AlignmentPositionError of size "
540  << dx << " " << dy << " " << dz;
541 
542  AlignmentPositionError ape(dx,dy,dz);
543  alignable->addAlignmentPositionError( ape, true );
544 
545 }
#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 591 of file AlignableModifier.cc.

Referenced by modify().

594 {
595 
596  align::RotationType rotx( Basic3DVector<float>(1.0, 0.0, 0.0), phiX );
597  align::RotationType roty( Basic3DVector<float>(0.0, 1.0, 0.0), phiY );
598  align::RotationType rotz( Basic3DVector<float>(0.0, 0.0, 1.0), phiZ );
599  align::RotationType rot = rotz * roty * rotx;
600 
601  this->addAlignmentPositionErrorFromLocalRotation( alignable, rot );
602 
603 }
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 620 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionErrorFromLocalRotation(), and LogDebug.

622 {
623 
624  LogDebug("PrintArgs") << "Adding an AlignmentPositionError from Local Rotation" << std::endl
625  << rotation;
626 
627  // true: propagate down to components
628  alignable->addAlignmentPositionErrorFromLocalRotation(rotation, true);
629 
630 }
#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 575 of file AlignableModifier.cc.

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

578 {
579 
580  align::RotationType rotx( Basic3DVector<float>(1.0, 0.0, 0.0), phiX );
581  align::RotationType roty( Basic3DVector<float>(0.0, 1.0, 0.0), phiY );
582  align::RotationType rotz( Basic3DVector<float>(0.0, 0.0, 1.0), phiZ );
583  align::RotationType rot = rotz * roty * rotx;
584 
585  this->addAlignmentPositionErrorFromRotation( alignable, rot );
586 
587 }
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 607 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionErrorFromRotation(), and LogDebug.

609 {
610 
611  LogDebug("PrintArgs") << "Adding an AlignmentPositionError from Rotation" << std::endl
612  << rotation;
613 
614  alignable->addAlignmentPositionErrorFromRotation(rotation, true); // propagate down to components
615 
616 }
#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 549 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().

551 {
552 
553  LogDebug("PrintArgs") << "Adding a local AlignmentPositionError of size "
554  << dx << " " << dy << " " << dz;
555 
556  AlgebraicSymMatrix as(3,0); //3x3, zeroed
557  as[0][0] = dx*dx; as[1][1] = dy*dy; as[2][2] = dz*dz; //diagonals
558  align::RotationType rt = alignable->globalRotation(); //get rotation
559  AlgebraicMatrix am(3,3);
560  am[0][0]=rt.xx(); am[0][1]=rt.xy(); am[0][2]=rt.xz();
561  am[1][0]=rt.yx(); am[1][1]=rt.yy(); am[1][2]=rt.yz();
562  am[2][0]=rt.zx(); am[2][1]=rt.zy(); am[2][2]=rt.zz();
563  as=as.similarityT(am); //rotate error matrix
564 
565  GlobalError ge( as );
566  AlignmentPositionError ape( ge );
567 
568  alignable->addAlignmentPositionError( ape, true ); // propagate down to components
569 
570 }
#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 341 of file AlignableModifier.cc.

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

Referenced by modify().

344 {
345  const SurfaceDeformationFactory::Type deformType
347 
348  // Scale and randomize
349  // (need a little hack since ySplit must not be treated)!
350  const bool rndNotLast = (deformType == SurfaceDeformationFactory::kTwoBowedSurfaces);
351  std::vector<double> rndDeformation(deformation.second.begin(),
352  deformation.second.end() - (rndNotLast ? 1 : 0));
353  for (unsigned int i = 0; i < rndDeformation.size(); ++i) {
354  rndDeformation[i] *= scale;
355  }
356  if (random) {
357  this->randomise(rndDeformation, gaussian);
358  }
359  if (rndNotLast) { // put back ySplit at the end
360  rndDeformation.push_back(deformation.second.back());
361  }
362 
363  // auto_ptr has exception safe delete (in contrast to bare pointer)
364  const std::auto_ptr<SurfaceDeformation> surfDef
365  (SurfaceDeformationFactory::create(deformType, rndDeformation));
366 
367  alignable->addSurfaceDeformation(surfDef.get(), true); // true to propagate down
368  ++m_modified;
369 }
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 485 of file AlignableModifier.cc.

References abs, and theDRand48Engine.

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

486 {
487 
488  // Get absolute value if negative arguments
489  if ( sigmaX < 0 ) {
490  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_x";
491  sigmaX = std::abs(sigmaX);
492  }
493  if ( sigmaY < 0 ) {
494  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_y";
495  sigmaY = std::abs(sigmaY);
496  }
497  if ( sigmaZ < 0 ) {
498  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_z";
499  sigmaZ = std::abs(sigmaZ);
500  }
501 
502  CLHEP::RandFlat aFlatObjX( *theDRand48Engine, -sigmaX, sigmaX );
503  CLHEP::RandFlat aFlatObjY( *theDRand48Engine, -sigmaY, sigmaY );
504  CLHEP::RandFlat aFlatObjZ( *theDRand48Engine, -sigmaZ, sigmaZ );
505 
506  std::vector<float> randomVector;
507  randomVector.push_back( aFlatObjX.fire() );
508  randomVector.push_back( aFlatObjY.fire() );
509  randomVector.push_back( aFlatObjZ.fire() );
510 
511  return randomVector;
512 
513 }
#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 451 of file AlignableModifier.cc.

References abs, and theDRand48Engine.

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

452 {
453 
454  // Get absolute value if negative arguments
455  if ( sigmaX < 0 ) {
456  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_x";
457  sigmaX = std::abs(sigmaX);
458  }
459  if ( sigmaY < 0 ) {
460  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_y";
461  sigmaY = std::abs(sigmaY);
462  }
463  if ( sigmaZ < 0 ) {
464  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_z";
465  sigmaZ = std::abs(sigmaZ);
466  }
467 
468  // Pass by reference, otherwise pointer is deleted!
469  CLHEP::RandGauss aGaussObjX( *theDRand48Engine, 0., sigmaX );
470  CLHEP::RandGauss aGaussObjY( *theDRand48Engine, 0., sigmaY );
471  CLHEP::RandGauss aGaussObjZ( *theDRand48Engine, 0., sigmaZ );
472 
473  std::vector<float> randomVector;
474  randomVector.push_back( aGaussObjX.fire() );
475  randomVector.push_back( aGaussObjY.fire() );
476  randomVector.push_back( aGaussObjZ.fire() );
477 
478  return randomVector;
479 
480 }
#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 37 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().

38 {
39 
40  // Initialize all known parameters (according to ORCA's MisalignmentScenario.cc)
41  distribution_ = ""; // Switch for distributions ("fixed","flat","gaussian")
42  setError_ = false; // Apply alignment errors
43  setRotations_ = true; // Apply rotations
44  setTranslations_ = true; // Apply translations
45  scale_ = 1.; // Scale to apply to all movements
46  scaleError_ = 1.; // Scale to apply to alignment errors
47  phiX_ = 0.; // Rotation angle around X [rad]
48  phiY_ = 0.; // Rotation angle around Y [rad]
49  phiZ_ = 0.; // Rotation angle around Z [rad]
50  phiXlocal_ = 0.; // Local rotation angle around X [rad]
51  phiYlocal_ = 0.; // Local rotation angle around Y [rad]
52  phiZlocal_ = 0.; // Local rotation angle around Z [rad]
53  dX_ = 0.; // X displacement [cm]
54  dY_ = 0.; // Y displacement [cm]
55  dZ_ = 0.; // Z displacement [cm]
56  dXlocal_ = 0.; // Local X displacement [cm]
57  dYlocal_ = 0.; // Local Y displacement [cm]
58  dZlocal_ = 0.; // Local Z displacement [cm]
59  deformation_.first.clear();// SurfaceDeformation: type
60  deformation_.second.clear();//SurfaceDeformation: parameter vector
61  twist_ = 0.; // Twist angle [rad]
62  shear_ = 0.; // Shear angle [rad]
63 
64  // These are set through 'distribution'
65  random_ = true; // Use random distributions
66  gaussian_ = true; // Use gaussian distribution (otherwise flat)
67 
68 }
std::string distribution_
DeformationMemberType deformation_
const bool AlignableModifier::isPropagated ( const std::string &  parameterName) const

Check if given parameter should be propagated.

Definition at line 72 of file AlignableModifier.cc.

Referenced by MisalignmentScenarioBuilder::propagateParameters_().

73 {
74 
75  if ( parameterName == "distribution" ||
76  parameterName == "setError" ||
77  parameterName == "scaleError" ||
78  parameterName == "setRotations" ||
79  parameterName == "setTranslations" ||
80  parameterName == "scale"
81  ) return true;
82 
83  return false;
84 
85 }
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 90 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_().

91 {
92 
93  // Initialize parameters
94  this->init_();
95  int rotX_=0, rotY_=0, rotZ_=0; // To check correct backward compatibility
96 
97 
98  // Reset counter
99  m_modified = 0;
100 
101  // Retrieve parameters
102  std::ostringstream error;
103  std::vector<std::string> parameterNames = pSet.getParameterNames();
104  for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
105  iParam != parameterNames.end(); iParam++ ) {
106  if ( (*iParam) == "distribution" ) distribution_ = pSet.getParameter<std::string>( *iParam );
107  else if ( (*iParam) == "setError" ) setError_ = pSet.getParameter<bool>( *iParam );
108  else if ( (*iParam) == "setRotations") setRotations_ = pSet.getParameter<bool>( *iParam );
109  else if ( (*iParam) == "setTranslations") setTranslations_ = pSet.getParameter<bool>( *iParam );
110  else if ( (*iParam) == "scale" ) scale_ = pSet.getParameter<double>( *iParam );
111  else if ( (*iParam) == "scaleError" ) scaleError_ = pSet.getParameter<double>( *iParam );
112  else if ( (*iParam) == "phiX" ) phiX_ = pSet.getParameter<double>( *iParam );
113  else if ( (*iParam) == "phiY" ) phiY_ = pSet.getParameter<double>( *iParam );
114  else if ( (*iParam) == "phiZ" ) phiZ_ = pSet.getParameter<double>( *iParam );
115  else if ( (*iParam) == "dX" ) dX_ = pSet.getParameter<double>( *iParam );
116  else if ( (*iParam) == "dY" ) dY_ = pSet.getParameter<double>( *iParam );
117  else if ( (*iParam) == "dZ" ) dZ_ = pSet.getParameter<double>( *iParam );
118  else if ( (*iParam) == "dXlocal" ) dXlocal_ = pSet.getParameter<double>( *iParam );
119  else if ( (*iParam) == "dYlocal" ) dYlocal_ = pSet.getParameter<double>( *iParam );
120  else if ( (*iParam) == "dZlocal" ) dZlocal_ = pSet.getParameter<double>( *iParam );
121  else if ( (*iParam) == "twist" ) twist_ = pSet.getParameter<double>( *iParam );
122  else if ( (*iParam) == "shear" ) shear_ = pSet.getParameter<double>( *iParam );
123  else if ( (*iParam) == "localX" ) { phiXlocal_=pSet.getParameter<double>( *iParam ); rotX_++; }
124  else if ( (*iParam) == "localY" ) { phiYlocal_=pSet.getParameter<double>( *iParam ); rotY_++; }
125  else if ( (*iParam) == "localZ" ) { phiZlocal_=pSet.getParameter<double>( *iParam ); rotZ_++; }
126  else if ( (*iParam) == "phiXlocal" ) { phiXlocal_=pSet.getParameter<double>( *iParam ); rotX_++; }
127  else if ( (*iParam) == "phiYlocal" ) { phiYlocal_=pSet.getParameter<double>( *iParam ); rotY_++; }
128  else if ( (*iParam) == "phiZlocal" ) { phiZlocal_=pSet.getParameter<double>( *iParam ); rotZ_++; }
129  else if ( (*iParam) == "deformation" ) {
130  const edm::ParameterSet deform(pSet.getParameter<edm::ParameterSet>( *iParam ));
131  deformation_.first = deform.getParameter<std::string>("type");
132  deformation_.second = deform.getParameter<std::vector<double> >("parameters");
133  // a non-complete check of simple mistyping of "deformation"
134  // i.e. should detect at least a single wrong character... HACK
135  } else if (pSet.existsAs<edm::ParameterSet>(*iParam)
136  && ((*iParam).find("deform") != std::string::npos ||
137  (*iParam).find("ation") != std::string::npos)) {
138  throw cms::Exception("BadConfig") << "Probable mistyping in config: '" << (*iParam)
139  << "' should probably mean 'deformation'\n";
140  } else if ( !pSet.existsAs<edm::ParameterSet>(*iParam) ) { // other PSets are OK to ignore
141  if ( !error.str().length() ) error << "Unknown parameter name(s): ";
142  error << " " << *iParam;
143  }
144  }
145 
146  // Check if both 'localN' and 'phiNlocal' have been used
147  if ( rotX_==2 ) throw cms::Exception("BadConfig") << "Found both localX and phiXlocal";
148  if ( rotY_==2 ) throw cms::Exception("BadConfig") << "Found both localY and phiYlocal";
149  if ( rotZ_==2 ) throw cms::Exception("BadConfig") << "Found both localZ and phiZlocal";
150 
151  // Check error
152  if ( error.str().length() )
153  throw cms::Exception("BadConfig") << error.str();
154 
155  // Decode distribution
157 
158  //if (scale_) { NO! Different random sequence if only parts scale to zero!
159 
160  // Apply displacements
161  if ( std::abs(dX_) + std::abs(dY_) + std::abs(dZ_) > 0 && setTranslations_ )
162  this->moveAlignable( alignable, random_, gaussian_, scale_*dX_, scale_*dY_, scale_*dZ_ );
163 
164  // Apply local displacements
166  this->moveAlignableLocal( alignable, random_, gaussian_,
168 
169  // Apply rotations
171  this->rotateAlignable( alignable, random_, gaussian_,
173 
174  // Apply local rotations
176  this->rotateAlignableLocal( alignable, random_, gaussian_,
178 
179  // Apply twist
180  if ( std::abs(twist_) > 0 )
181  edm::LogError("NotImplemented") << "Twist is not implemented yet";
182 
183  // Apply shear
184  if ( std::abs(shear_) > 0 )
185  edm::LogError("NotImplemented") << "Shear is not implemented yet";
186 
187  if (!deformation_.first.empty()) {
188  this->addDeformation(alignable, deformation_, random_, gaussian_, scale_);
189  }
190 
191  // Apply error - first add scale_ to error
192  scaleError_ *= scale_;
193  if ( setError_ && scaleError_ ) {
194  // Alignment Position Error for flat distribution: 1 sigma
195  if ( !gaussian_ ) scaleError_ *= 0.68;
196 
197 
198  // Error on displacement
199  if ( std::abs(dX_) + std::abs(dY_) + std::abs(dZ_) > 0 && setTranslations_ )
200  this->addAlignmentPositionError( alignable,
202 
203  // Error on local displacements
205  this->addAlignmentPositionErrorLocal( alignable,
208 
209  // Error on rotations
211  this->addAlignmentPositionErrorFromRotation( alignable,
213  scaleError_*phiZ_ );
214 
215  // Error on local rotations
217  && setRotations_ )
222  // Do we need to add any APE for deformations?
223  // Probably we would do so if there wouldn't be data, but only MC to play with... ;-)
224  }
225  // } // end if (scale_)
226 
227  return ( m_modified > 0 );
228 
229 }
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:181
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 270 of file AlignableModifier.cc.

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

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

272 {
273 
274 
275  std::ostringstream message;
276 
277  // Get movement vector according to arguments
278  GlobalVector moveV( sigmaX, sigmaY, sigmaZ ); // Default: fixed
279  if ( random ) {
280  std::vector<float> randomNumbers;
281  message << "random ";
282  if (gaussian) {
283  randomNumbers = this->gaussianRandomVector( sigmaX, sigmaY, sigmaZ );
284  message << "gaussian ";
285  } else {
286  randomNumbers = this->flatRandomVector( sigmaX, sigmaY, sigmaZ );
287  message << "flat ";
288  }
289  moveV = GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
290  }
291 
292  message << " move with sigma " << sigmaX << " " << sigmaY << " " << sigmaZ;
293 
294  LogDebug("PrintArgs") << message.str(); // Arguments
295 
296  LogDebug("PrintMovement") << "applied displacement: " << moveV; // Actual movements
297  alignable->move(moveV);
298  m_modified++;
299 
300 
301 }
#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)
string message
Definition: argparse.py:126
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 306 of file AlignableModifier.cc.

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

Referenced by modify().

308 {
309 
310 
311  std::ostringstream message;
312 
313  // Get movement vector according to arguments
314  align::LocalVector moveV( sigmaX, sigmaY, sigmaZ ); // Default: fixed
315  if ( random ) {
316  std::vector<float> randomNumbers;
317  message << "random ";
318  if (gaussian) {
319  randomNumbers = this->gaussianRandomVector( sigmaX, sigmaY, sigmaZ );
320  message << "gaussian ";
321  } else {
322  randomNumbers = this->flatRandomVector( sigmaX, sigmaY, sigmaZ );
323  message << "flat ";
324  }
325  moveV = align::LocalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
326  }
327 
328  message << " move with sigma " << sigmaX << " " << sigmaY << " " << sigmaZ;
329 
330  LogDebug("PrintArgs") << message.str(); // Arguments
331 
332  LogDebug("PrintMovement") << "applied local displacement: " << moveV; // Actual movements
333  alignable->move( alignable->surface().toGlobal(moveV) );
334  m_modified++;
335 
336 
337 }
#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
string message
Definition: argparse.py: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 516 of file AlignableModifier.cc.

References abs, i, and theDRand48Engine.

517 {
518  for (unsigned int i = 0; i < rnd.size(); ++i) {
519  if (rnd[i] < 0.) {
520  edm::LogWarning("BadConfig") << " taking absolute value to randomise " << i;
521  rnd[i] = std::abs(rnd[i]);
522  }
523 
524  if (gaussian) {
525  CLHEP::RandGauss aGaussObj( *theDRand48Engine, 0., rnd[i]);
526  rnd[i] = aGaussObj.fire();
527  } else {
528  CLHEP::RandFlat aFlatObj(*theDRand48Engine, -rnd[i], rnd[i]);
529  rnd[i] = aFlatObj.fire();
530  }
531  }
532 }
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 374 of file AlignableModifier.cc.

References abs, flatRandomVector(), gaussianRandomVector(), LogDebug, m_modified, 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().

376 {
377 
378 
379  std::ostringstream message;
380 
381  // Get rotation vector according to arguments
382  GlobalVector rotV( sigmaPhiX, sigmaPhiY, sigmaPhiZ ); // Default: fixed
383  if ( random ) {
384  std::vector<float> randomNumbers;
385  message << "random ";
386  if (gaussian) {
387  randomNumbers = this->gaussianRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
388  message << "gaussian ";
389  } else {
390  randomNumbers = flatRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
391  message << "flat ";
392  }
393  rotV = GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
394  }
395 
396  message << "global rotation by angles " << sigmaPhiX << " " << sigmaPhiY << " " << sigmaPhiZ;
397 
398  LogDebug("PrintArgs") << message.str(); // Arguments
399 
400  LogDebug("PrintMovement") << "applied rotation angles: " << rotV; // Actual movements
401  if ( std::abs(sigmaPhiX) ) alignable->rotateAroundGlobalX( rotV.x() );
402  if ( std::abs(sigmaPhiY) ) alignable->rotateAroundGlobalY( rotV.y() );
403  if ( std::abs(sigmaPhiZ) ) alignable->rotateAroundGlobalZ( rotV.z() );
404  m_modified++;
405 
406 
407 }
#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:172
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:120
virtual void rotateAroundGlobalY(Scalar radians)
Rotation around global y-axis.
Definition: Alignable.cc:146
string message
Definition: argparse.py:126
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 413 of file AlignableModifier.cc.

References abs, flatRandomVector(), gaussianRandomVector(), LogDebug, m_modified, 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().

415 {
416 
417 
418  std::ostringstream message;
419 
420  // Get rotation vector according to arguments
421  align::LocalVector rotV( sigmaPhiX, sigmaPhiY, sigmaPhiZ ); // Default: fixed
422  if ( random ) {
423  std::vector<float> randomNumbers;
424  message << "random ";
425  if (gaussian) {
426  randomNumbers = this->gaussianRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
427  message << "gaussian ";
428  } else {
429  randomNumbers = flatRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
430  message << "flat ";
431  }
432  rotV = align::LocalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
433  }
434 
435  message << "local rotation by angles " << sigmaPhiX << " " << sigmaPhiY << " " << sigmaPhiZ;
436 
437  LogDebug("PrintArgs") << message.str(); // Arguments
438 
439  LogDebug("PrintMovement") << "applied local rotation angles: " << rotV; // Actual movements
440  if ( std::abs(sigmaPhiX) ) alignable->rotateAroundLocalX( rotV.x() );
441  if ( std::abs(sigmaPhiY) ) alignable->rotateAroundLocalY( rotV.y() );
442  if ( std::abs(sigmaPhiZ) ) alignable->rotateAroundLocalZ( rotV.z() );
443  m_modified++;
444 
445 
446 }
#define LogDebug(id)
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
Definition: Alignable.cc:185
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:159
string message
Definition: argparse.py:126
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
Definition: Alignable.cc:133
void AlignableModifier::setDistribution ( const std::string &  distr)

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

Definition at line 233 of file AlignableModifier.cc.

References gaussian_, and random_.

Referenced by modify().

234 {
235 
236  if ( distr == "fixed" ) random_ = false;
237  else if ( distr == "flat" ) {
238  random_ = true;
239  gaussian_ = false;
240  } else if ( distr == "gaussian" ) {
241  random_ = true;
242  gaussian_ = true;
243  }
244 
245 }
void AlignableModifier::setSeed ( long  seed)

Resets the generator seed according to the argument.

If 'seed' is zero, asks RandomNumberGenerator service.

Definition at line 250 of file AlignableModifier.cc.

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

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

251 {
252 
253  long m_seed;
254 
255  if ( seed > 0 ) m_seed = seed;
256  else {
258  m_seed = rng->mySeed();
259  }
260 
261  LogDebug("PrintArgs") << "Setting generator seed to " << m_seed;
262 
263  theDRand48Engine->setSeed( m_seed );
264 
265 }
#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().