1 #include "CLHEP/Random/DRand48Engine.h"
2 #include "CLHEP/Random/RandGauss.h"
3 #include "CLHEP/Random/Randomize.h"
69 if ( parameterName ==
"distribution" ||
70 parameterName ==
"setError" ||
71 parameterName ==
"scaleError" ||
72 parameterName ==
"setRotations" ||
73 parameterName ==
"setTranslations" ||
74 parameterName ==
"scale"
89 int rotX_=0, rotY_=0, rotZ_=0;
96 std::ostringstream
error;
98 for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
99 iParam != parameterNames.end(); iParam++ ) {
109 else if ( (*iParam) ==
"dX" )
dX_ = pSet.
getParameter<
double>( *iParam );
110 else if ( (*iParam) ==
"dY" )
dY_ = pSet.
getParameter<
double>( *iParam );
111 else if ( (*iParam) ==
"dZ" )
dZ_ = pSet.
getParameter<
double>( *iParam );
124 if ( !error.str().length() ) error <<
"Unknown parameter name(s): ";
125 error <<
" " << *iParam;
130 if ( rotX_==2 )
throw cms::Exception(
"BadConfig") <<
"Found both localX and phiXlocal";
131 if ( rotY_==2 )
throw cms::Exception(
"BadConfig") <<
"Found both localY and phiYlocal";
132 if ( rotZ_==2 )
throw cms::Exception(
"BadConfig") <<
"Found both localZ and phiZlocal";
135 if ( error.str().length() )
164 edm::LogError(
"NotImplemented") <<
"Twist is not implemented yet";
168 edm::LogError(
"NotImplemented") <<
"Shear is not implemented yet";
213 if ( distr ==
"fixed" )
random_ =
false;
214 else if ( distr ==
"flat" ) {
217 }
else if ( distr ==
"gaussian" ) {
232 if ( seed > 0 ) m_seed = seed;
238 LogDebug(
"PrintArgs") <<
"Setting generator seed to " << m_seed;
248 float sigmaX,
float sigmaY,
float sigmaZ )
257 std::vector<float> randomNumbers;
258 message <<
"random ";
261 message <<
"gaussian ";
266 moveV =
GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
269 message <<
" move with sigma " << sigmaX <<
" " << sigmaY <<
" " << sigmaZ;
271 LogDebug(
"PrintArgs") << message.str();
273 LogDebug(
"PrintMovement") <<
"applied displacement: " << moveV;
274 alignable->
move(moveV);
284 float sigmaX,
float sigmaY,
float sigmaZ )
293 std::vector<float> randomNumbers;
294 message <<
"random ";
297 message <<
"gaussian ";
305 message <<
" move with sigma " << sigmaX <<
" " << sigmaY <<
" " << sigmaZ;
307 LogDebug(
"PrintArgs") << message.str();
309 LogDebug(
"PrintMovement") <<
"applied local displacement: " << moveV;
321 float sigmaPhiX,
float sigmaPhiY,
float sigmaPhiZ )
330 std::vector<float> randomNumbers;
331 message <<
"random ";
334 message <<
"gaussian ";
339 rotV =
GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
342 message <<
"global rotation by angles " << sigmaPhiX <<
" " << sigmaPhiY <<
" " << sigmaPhiZ;
344 LogDebug(
"PrintArgs") << message.str();
346 LogDebug(
"PrintMovement") <<
"applied rotation angles: " << rotV;
360 float sigmaPhiX,
float sigmaPhiY,
float sigmaPhiZ )
369 std::vector<float> randomNumbers;
370 message <<
"random ";
373 message <<
"gaussian ";
381 message <<
"local rotation by angles " << sigmaPhiX <<
" " << sigmaPhiY <<
" " << sigmaPhiZ;
383 LogDebug(
"PrintArgs") << message.str();
385 LogDebug(
"PrintMovement") <<
"applied local rotation angles: " << rotV;
396 const std::vector<float>
402 edm::LogWarning(
"BadConfig") <<
" taking absolute value for gaussian sigma_x";
406 edm::LogWarning(
"BadConfig") <<
" taking absolute value for gaussian sigma_y";
410 edm::LogWarning(
"BadConfig") <<
" taking absolute value for gaussian sigma_z";
419 std::vector<float> randomVector;
420 randomVector.push_back( aGaussObjX.fire() );
421 randomVector.push_back( aGaussObjY.fire() );
422 randomVector.push_back( aGaussObjZ.fire() );
430 const std::vector<float>
436 edm::LogWarning(
"BadConfig") <<
" taking absolute value for flat sigma_x";
440 edm::LogWarning(
"BadConfig") <<
" taking absolute value for flat sigma_y";
444 edm::LogWarning(
"BadConfig") <<
" taking absolute value for flat sigma_z";
452 std::vector<float> randomVector;
453 randomVector.push_back( aFlatObjX.fire() );
454 randomVector.push_back( aFlatObjY.fire() );
455 randomVector.push_back( aFlatObjZ.fire() );
465 float dx,
float dy,
float dz )
468 LogDebug(
"PrintArgs") <<
"Adding an AlignmentPositionError of size "
469 << dx <<
" " << dy <<
" " << dz;
479 float dx,
float dy,
float dz )
482 LogDebug(
"PrintArgs") <<
"Adding a local AlignmentPositionError of size "
483 << dx <<
" " << dy <<
" " << dz;
486 as[0][0] = dx*dx; as[1][1] = dy*dy; as[2][2] = dz*dz;
489 am[0][0]=rt.
xx(); am[0][1]=rt.
xy(); am[0][2]=rt.
xz();
490 am[1][0]=rt.
yx(); am[1][1]=rt.
yy(); am[1][2]=rt.
yz();
491 am[2][0]=rt.
zx(); am[2][1]=rt.
zy(); am[2][2]=rt.
zz();
492 as=as.similarityT(am);
505 float phiX,
float phiY,
521 float phiX,
float phiY,
540 LogDebug(
"PrintArgs") <<
"Adding an AlignmentPositionError from Rotation" << std::endl
553 LogDebug(
"PrintArgs") <<
"Adding an AlignmentPositionError from Local Rotation" << std::endl
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 ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
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)
void init_()
Initialisation of all parameters.
const RotationType & globalRotation() const
Return the global orientation of the object.
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
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_
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
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.
CLHEP::HepMatrix AlgebraicMatrix
void setDistribution(const std::string &distr)
Decodes string and sets distribution accordingly ('fixed', 'flat' or 'gaussian'). ...
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)
const bool isPropagated(const std::string ¶meterName) const
Check if given parameter should be propagated.
Vector3DBase< Scalar, LocalTag > LocalVector
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
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.
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.
virtual void rotateAroundGlobalY(Scalar radians)
Rotation around global y-axis.
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
CLHEP::HepSymMatrix AlgebraicSymMatrix
void moveAlignableLocal(Alignable *alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ)
Move alignable in local space according to parameters.
virtual uint32_t mySeed() const =0
Exists for backward compatibility.
Global3DVector GlobalVector