3 #include "CLHEP/Random/DRand48Engine.h"
4 #include "CLHEP/Random/RandGauss.h"
5 #include "CLHEP/Random/Randomize.h"
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.)
85 if ( parameterName ==
"distribution" ||
86 parameterName ==
"setError" ||
87 parameterName ==
"scaleError" ||
88 parameterName ==
"setRotations" ||
89 parameterName ==
"setTranslations" ||
90 parameterName ==
"scale"
105 int rotX_=0, rotY_=0, rotZ_=0;
112 std::ostringstream
error;
114 for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
115 iParam != parameterNames.end(); 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 );
139 else if ( (*iParam) ==
"deformation" ) {
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";
151 if ( !error.str().length() ) error <<
"Unknown parameter name(s): ";
152 error <<
" " << *iParam;
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";
162 if ( error.str().length() )
191 edm::LogError(
"NotImplemented") <<
"Twist is not implemented yet";
195 edm::LogError(
"NotImplemented") <<
"Shear is not implemented yet";
246 if ( distr ==
"fixed" )
random_ =
false;
247 else if ( distr ==
"flat" ) {
250 }
else if ( distr ==
"gaussian" ) {
265 if ( seed > 0 ) m_seed = seed;
271 LogDebug(
"PrintArgs") <<
"Setting generator seed to " << m_seed;
281 float sigmaX,
float sigmaY,
float sigmaZ )
290 std::vector<float> randomNumbers;
291 message <<
"random ";
294 message <<
"gaussian ";
299 moveV =
GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
302 message <<
" move with sigma " << sigmaX <<
" " << sigmaY <<
" " << sigmaZ;
304 LogDebug(
"PrintArgs") << message.str();
306 LogDebug(
"PrintMovement") <<
"applied displacement: " << moveV;
307 alignable->
move(moveV);
317 float sigmaX,
float sigmaY,
float sigmaZ )
326 std::vector<float> randomNumbers;
327 message <<
"random ";
330 message <<
"gaussian ";
338 message <<
" move with sigma " << sigmaX <<
" " << sigmaY <<
" " << sigmaZ;
340 LogDebug(
"PrintArgs") << message.str();
342 LogDebug(
"PrintMovement") <<
"applied local displacement: " << moveV;
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;
367 this->randomise(rndDeformation, gaussian);
370 rndDeformation.push_back(deformation.second.back());
374 const std::auto_ptr<SurfaceDeformation> surfDef
385 float sigmaPhiX,
float sigmaPhiY,
float sigmaPhiZ )
394 std::vector<float> randomNumbers;
395 message <<
"random ";
398 message <<
"gaussian ";
403 rotV =
GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
406 message <<
"global rotation by angles " << sigmaPhiX <<
" " << sigmaPhiY <<
" " << sigmaPhiZ;
408 LogDebug(
"PrintArgs") << message.str();
410 LogDebug(
"PrintMovement") <<
"applied rotation angles: " << rotV;
424 float sigmaPhiX,
float sigmaPhiY,
float sigmaPhiZ )
433 std::vector<float> randomNumbers;
434 message <<
"random ";
437 message <<
"gaussian ";
445 message <<
"local rotation by angles " << sigmaPhiX <<
" " << sigmaPhiY <<
" " << sigmaPhiZ;
447 LogDebug(
"PrintArgs") << message.str();
449 LogDebug(
"PrintMovement") <<
"applied local rotation angles: " << rotV;
460 const std::vector<float>
466 edm::LogWarning(
"BadConfig") <<
" taking absolute value for gaussian sigma_x";
470 edm::LogWarning(
"BadConfig") <<
" taking absolute value for gaussian sigma_y";
474 edm::LogWarning(
"BadConfig") <<
" taking absolute value for gaussian sigma_z";
483 std::vector<float> randomVector;
484 randomVector.push_back( aGaussObjX.fire() );
485 randomVector.push_back( aGaussObjY.fire() );
486 randomVector.push_back( aGaussObjZ.fire() );
494 const std::vector<float>
500 edm::LogWarning(
"BadConfig") <<
" taking absolute value for flat sigma_x";
504 edm::LogWarning(
"BadConfig") <<
" taking absolute value for flat sigma_y";
508 edm::LogWarning(
"BadConfig") <<
" taking absolute value for flat sigma_z";
516 std::vector<float> randomVector;
517 randomVector.push_back( aFlatObjX.fire() );
518 randomVector.push_back( aFlatObjY.fire() );
519 randomVector.push_back( aFlatObjZ.fire() );
528 for (
unsigned int i = 0;
i < rnd.size(); ++
i) {
530 edm::LogWarning(
"BadConfig") <<
" taking absolute value to randomise " <<
i;
536 rnd[
i] = aGaussObj.fire();
539 rnd[
i] = aFlatObj.fire();
546 float dx,
float dy,
float dz )
549 LogDebug(
"PrintArgs") <<
"Adding an AlignmentPositionError of size "
550 << dx <<
" " << dy <<
" " << dz;
560 float dx,
float dy,
float dz )
563 LogDebug(
"PrintArgs") <<
"Adding a local AlignmentPositionError of size "
564 << dx <<
" " << dy <<
" " << dz;
567 as[0][0] = dx*dx; as[1][1] = dy*dy; as[2][2] = dz*dz;
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);
586 float phiX,
float phiY,
602 float phiX,
float phiY,
621 LogDebug(
"PrintArgs") <<
"Adding an AlignmentPositionError from Rotation" << std::endl
634 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_
void addDeformation(Alignable *alignable, const DeformationMemberType &deformation, bool random, bool gaussian, double scale)
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
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)=0
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)
void randomise(std::vector< double > &rnd, bool gaussian) const
Vector3DBase< Scalar, LocalTag > LocalVector
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
DeformationMemberType deformation_
void rotateAlignable(Alignable *alignable, bool random, bool gaussian, float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ)
Rotate alignable in global space according to parameters.
virtual void rotateAroundGlobalX(Scalar radians)
Rotation around global x-axis.
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.
std::pair< std::string, std::vector< double > > DeformationMemberType
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
bool isPropagated(const std::string ¶meterName) const
Check if given parameter should be propagated.
void moveAlignableLocal(Alignable *alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ)
Move alignable in local space according to parameters.
virtual uint32_t mySeed() const =0
Exists for backward compatibility.
Global3DVector GlobalVector