CMS 3D CMS Logo

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 21 of file AlignableModifier.cc.

References theDRand48Engine.

21  :
22  distribution_(""),
23  random_(false), gaussian_(false), setError_(false),
24  setRotations_(false),setTranslations_(false),
25  seed_(0),
26  scaleError_(0.), scale_(0.),
27  phiX_(0.), phiY_(0.), phiZ_(0.),
28  phiXlocal_(0.), phiYlocal_(0.), phiZlocal_(0.),
29  dX_(0.), dY_(0.), dZ_(0.),
30  dXlocal_(0.), dYlocal_(0.), dZlocal_(0.),
31  twist_(0.), shear_(0.)
32 {
33 
34  theDRand48Engine = new CLHEP::DRand48Engine();
35 
36 }
std::string distribution_
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
AlignableModifier::~AlignableModifier ( )

Destructor.

Definition at line 40 of file AlignableModifier.cc.

References theDRand48Engine.

41 {
42 
43  delete theDRand48Engine;
44 
45 }
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 553 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionError(), PVValHelper::dz, and LogDebug.

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

555 {
556 
557  LogDebug("PrintArgs") << "Adding an AlignmentPositionError of size "
558  << dx << " " << dy << " " << dz;
559 
560  AlignmentPositionError ape(dx,dy,dz);
561  alignable->addAlignmentPositionError( ape, true );
562 
563 }
#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 610 of file AlignableModifier.cc.

References makeMuonMisalignmentScenario::rot.

Referenced by modify().

613 {
614 
615  align::RotationType rotx( Basic3DVector<float>(1.0, 0.0, 0.0), phiX );
616  align::RotationType roty( Basic3DVector<float>(0.0, 1.0, 0.0), phiY );
617  align::RotationType rotz( Basic3DVector<float>(0.0, 0.0, 1.0), phiZ );
618  align::RotationType rot = rotz * roty * rotx;
619 
620  this->addAlignmentPositionErrorFromLocalRotation( alignable, rot );
621 
622 }
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 639 of file AlignableModifier.cc.

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

641 {
642 
643  LogDebug("PrintArgs") << "Adding an AlignmentPositionError from Local Rotation" << std::endl
644  << rotation;
645 
646  // true: propagate down to components
647  alignable->addAlignmentPositionErrorFromLocalRotation(rotation, true);
648 
649 }
#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 594 of file AlignableModifier.cc.

References makeMuonMisalignmentScenario::rot.

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

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

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

628 {
629 
630  LogDebug("PrintArgs") << "Adding an AlignmentPositionError from Rotation" << std::endl
631  << rotation;
632 
633  alignable->addAlignmentPositionErrorFromRotation(rotation, true); // propagate down to components
634 
635 }
#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 567 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionError(), GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::cyx(), GlobalErrorBase< T, ErrorWeightType >::cyy(), GlobalErrorBase< T, ErrorWeightType >::czx(), GlobalErrorBase< T, ErrorWeightType >::czy(), GlobalErrorBase< T, ErrorWeightType >::czz(), PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, 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 modify().

569 {
570 
571  LogDebug("PrintArgs") << "Adding a local AlignmentPositionError of size "
572  << dx << " " << dy << " " << dz;
573 
574  AlgebraicSymMatrix as(3,0); //3x3, zeroed
575  as[0][0] = dx*dx; as[1][1] = dy*dy; as[2][2] = dz*dz; //diagonals
576  align::RotationType rt = alignable->globalRotation(); //get rotation
577  AlgebraicMatrix am(3,3);
578  am[0][0]=rt.xx(); am[0][1]=rt.xy(); am[0][2]=rt.xz();
579  am[1][0]=rt.yx(); am[1][1]=rt.yy(); am[1][2]=rt.yz();
580  am[2][0]=rt.zx(); am[2][1]=rt.zy(); am[2][2]=rt.zz();
581  as=as.similarityT(am); //rotate error matrix
582 
583  GlobalError ge( asSMatrix<3>(as) );
584  GlobalErrorExtended gee(ge.cxx(),ge.cyx(),ge.czx(),0.,0.,0.,ge.cyy(),ge.czy(),0.,0.,0.,ge.czz(),0.,0.,0.,0.,0.,0.,0.,0.,0.);
585  AlignmentPositionError ape(gee);
586 
587  alignable->addAlignmentPositionError( ape, true ); // propagate down to components
588 
589 }
#define LogDebug(id)
T xx() const
T yx() const
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:141
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 359 of file AlignableModifier.cc.

References Alignable::addSurfaceDeformation(), SurfaceDeformationFactory::create(), mps_fire::i, SurfaceDeformationFactory::kTwoBowedSurfaces, m_modified, randomise(), Scenarios_cff::scale, and SurfaceDeformationFactory::surfaceDeformationType().

Referenced by modify(), and moveAlignableLocal().

362 {
363  const SurfaceDeformationFactory::Type deformType
365 
366  // Scale and randomize
367  // (need a little hack since ySplit must not be treated)!
368  const bool rndNotLast = (deformType == SurfaceDeformationFactory::kTwoBowedSurfaces);
369  std::vector<double> rndDeformation(deformation.second.begin(),
370  deformation.second.end() - (rndNotLast ? 1 : 0));
371  for (unsigned int i = 0; i < rndDeformation.size(); ++i) {
372  rndDeformation[i] *= scale;
373  }
374  if (random) {
375  this->randomise(rndDeformation, gaussian);
376  }
377  if (rndNotLast) { // put back ySplit at the end
378  rndDeformation.push_back(deformation.second.back());
379  }
380 
381  // auto_ptr has exception safe delete (in contrast to bare pointer)
382  const std::auto_ptr<SurfaceDeformation> surfDef
383  (SurfaceDeformationFactory::create(deformType, rndDeformation));
384 
385  alignable->addSurfaceDeformation(surfDef.get(), true); // true to propagate down
386  ++m_modified;
387 }
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 503 of file AlignableModifier.cc.

References funct::abs(), and theDRand48Engine.

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

504 {
505 
506  // Get absolute value if negative arguments
507  if ( sigmaX < 0 ) {
508  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_x";
510  }
511  if ( sigmaY < 0 ) {
512  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_y";
514  }
515  if ( sigmaZ < 0 ) {
516  edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_z";
518  }
519 
520  CLHEP::RandFlat aFlatObjX( *theDRand48Engine, -sigmaX, sigmaX );
521  CLHEP::RandFlat aFlatObjY( *theDRand48Engine, -sigmaY, sigmaY );
522  CLHEP::RandFlat aFlatObjZ( *theDRand48Engine, -sigmaZ, sigmaZ );
523 
524  std::vector<float> randomVector;
525  randomVector.push_back( aFlatObjX.fire() );
526  randomVector.push_back( aFlatObjY.fire() );
527  randomVector.push_back( aFlatObjZ.fire() );
528 
529  return randomVector;
530 
531 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 469 of file AlignableModifier.cc.

References funct::abs(), and theDRand48Engine.

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

470 {
471 
472  // Get absolute value if negative arguments
473  if ( sigmaX < 0 ) {
474  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_x";
476  }
477  if ( sigmaY < 0 ) {
478  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_y";
480  }
481  if ( sigmaZ < 0 ) {
482  edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_z";
484  }
485 
486  // Pass by reference, otherwise pointer is deleted!
487  CLHEP::RandGauss aGaussObjX( *theDRand48Engine, 0., sigmaX );
488  CLHEP::RandGauss aGaussObjY( *theDRand48Engine, 0., sigmaY );
489  CLHEP::RandGauss aGaussObjZ( *theDRand48Engine, 0., sigmaZ );
490 
491  std::vector<float> randomVector;
492  randomVector.push_back( aGaussObjX.fire() );
493  randomVector.push_back( aGaussObjY.fire() );
494  randomVector.push_back( aGaussObjZ.fire() );
495 
496  return randomVector;
497 
498 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
void AlignableModifier::init_ ( void  )
private

Initialisation of all parameters.

Definition at line 48 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().

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

Check if given parameter should be propagated.

Definition at line 83 of file AlignableModifier.cc.

Referenced by MisalignmentScenarioBuilder::propagateParameters_().

84 {
85 
86  if ( parameterName == "distribution" ||
87  parameterName == "setError" ||
88  parameterName == "scaleError" ||
89  parameterName == "setRotations" ||
90  parameterName == "setTranslations" ||
91  parameterName == "scale"
92  ) return true;
93 
94  return false;
95 
96 }
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 101 of file AlignableModifier.cc.

References funct::abs(), addAlignmentPositionError(), addAlignmentPositionErrorFromLocalRotation(), addAlignmentPositionErrorFromRotation(), addAlignmentPositionErrorLocal(), addDeformation(), deformation_, distribution_, dX_, dXlocal_, dY_, dYlocal_, dZ_, dZlocal_, relativeConstraints::error, 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_, AlCaHLTBitMon_QueryRunRegistry::string, and twist_.

Referenced by MisalignmentScenarioBuilder::decodeMovements_().

102 {
103 
104  // Initialize parameters
105  this->init_();
106  int rotX_=0, rotY_=0, rotZ_=0; // To check correct backward compatibility
107 
108 
109  // Reset counter
110  m_modified = 0;
111 
112  // Retrieve parameters
113  std::ostringstream error;
114  std::vector<std::string> parameterNames = pSet.getParameterNames();
115  for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
116  iParam != parameterNames.end(); ++iParam ) {
117  if ( (*iParam) == "distribution" ) distribution_ = pSet.getParameter<std::string>( *iParam );
118  else if ( (*iParam) == "setError" ) setError_ = pSet.getParameter<bool>( *iParam );
119  else if ( (*iParam) == "setRotations") setRotations_ = pSet.getParameter<bool>( *iParam );
120  else if ( (*iParam) == "setTranslations") setTranslations_ = pSet.getParameter<bool>( *iParam );
121  else if ( (*iParam) == "scale" ) scale_ = pSet.getParameter<double>( *iParam );
122  else if ( (*iParam) == "scaleError" ) scaleError_ = pSet.getParameter<double>( *iParam );
123  else if ( (*iParam) == "phiX" ) phiX_ = pSet.getParameter<double>( *iParam );
124  else if ( (*iParam) == "phiY" ) phiY_ = pSet.getParameter<double>( *iParam );
125  else if ( (*iParam) == "phiZ" ) phiZ_ = pSet.getParameter<double>( *iParam );
126  else if ( (*iParam) == "dX" ) dX_ = pSet.getParameter<double>( *iParam );
127  else if ( (*iParam) == "dY" ) dY_ = pSet.getParameter<double>( *iParam );
128  else if ( (*iParam) == "dZ" ) dZ_ = pSet.getParameter<double>( *iParam );
129  else if ( (*iParam) == "dXlocal" ) dXlocal_ = pSet.getParameter<double>( *iParam );
130  else if ( (*iParam) == "dYlocal" ) dYlocal_ = pSet.getParameter<double>( *iParam );
131  else if ( (*iParam) == "dZlocal" ) dZlocal_ = pSet.getParameter<double>( *iParam );
132  else if ( (*iParam) == "twist" ) twist_ = pSet.getParameter<double>( *iParam );
133  else if ( (*iParam) == "shear" ) shear_ = pSet.getParameter<double>( *iParam );
134  else if ( (*iParam) == "localX" ) { phiXlocal_=pSet.getParameter<double>( *iParam ); rotX_++; }
135  else if ( (*iParam) == "localY" ) { phiYlocal_=pSet.getParameter<double>( *iParam ); rotY_++; }
136  else if ( (*iParam) == "localZ" ) { phiZlocal_=pSet.getParameter<double>( *iParam ); rotZ_++; }
137  else if ( (*iParam) == "phiXlocal" ) { phiXlocal_=pSet.getParameter<double>( *iParam ); rotX_++; }
138  else if ( (*iParam) == "phiYlocal" ) { phiYlocal_=pSet.getParameter<double>( *iParam ); rotY_++; }
139  else if ( (*iParam) == "phiZlocal" ) { phiZlocal_=pSet.getParameter<double>( *iParam ); rotZ_++; }
140  else if ( (*iParam) == "deformation" ) {
141  const edm::ParameterSet deform(pSet.getParameter<edm::ParameterSet>( *iParam ));
142  deformation_.first = deform.getParameter<std::string>("type");
143  deformation_.second = deform.getParameter<std::vector<double> >("parameters");
144  } else if ( pSet.existsAs<edm::ParameterSet>(*iParam) ) {
145  // Other PSets than 'deformation' must refer to hierarchy structures, i.e. their name
146  // is a level name followed by 's' or ending with a digit (see
147  // MisalignmentScenarioBuilder::getParameterSet_). Pitfall is to forget the trailing 's'!
148  // 'Muon' is an especially allowed case used in MuonScenarioBuilder::moveMuon(..),
149  // also check that we do not have any mistyping like 'deformations' or 'deformation2'
150  const auto lastCharacter = (iParam->empty() ? '_' : (*iParam)[iParam->size()-1]);
151  if ( (lastCharacter != 's' && !isdigit(lastCharacter) && (*iParam) != "Muon")
152  || iParam->find("deformation") != std::string::npos) {
153  throw cms::Exception("BadConfig") << "@SUB=AlignableModifier::modify(..):\n"
154  << "I see parameter '" << *iParam << "' of type PSet, "
155  << "but expect either 'deformation' or a level name "
156  << "with 's' or a digit at the end.\n";
157  } // other PSets should now be hierarchy levels and thus be OK to ignore here
158  } else {
159  if ( !error.str().length() ) error << "Unknown parameter name(s): ";
160  error << " " << *iParam;
161  }
162  }
163 
164  // Check if both 'localN' and 'phiNlocal' have been used
165  if ( rotX_==2 ) throw cms::Exception("BadConfig") << "Found both localX and phiXlocal";
166  if ( rotY_==2 ) throw cms::Exception("BadConfig") << "Found both localY and phiYlocal";
167  if ( rotZ_==2 ) throw cms::Exception("BadConfig") << "Found both localZ and phiZlocal";
168 
169  // Check error
170  if ( error.str().length() )
171  throw cms::Exception("BadConfig") << error.str();
172 
173  // Decode distribution
175 
176  //if (scale_) { NO! Different random sequence if only parts scale to zero!
177 
178  // Apply displacements
179  if ( std::abs(dX_) + std::abs(dY_) + std::abs(dZ_) > 0 && setTranslations_ )
180  this->moveAlignable( alignable, random_, gaussian_, scale_*dX_, scale_*dY_, scale_*dZ_ );
181 
182  // Apply local displacements
184  this->moveAlignableLocal( alignable, random_, gaussian_,
186 
187  // Apply rotations
189  this->rotateAlignable( alignable, random_, gaussian_,
191 
192  // Apply local rotations
194  this->rotateAlignableLocal( alignable, random_, gaussian_,
196 
197  // Apply twist
198  if ( std::abs(twist_) > 0 )
199  edm::LogError("NotImplemented") << "Twist is not implemented yet";
200 
201  // Apply shear
202  if ( std::abs(shear_) > 0 )
203  edm::LogError("NotImplemented") << "Shear is not implemented yet";
204 
205  if (!deformation_.first.empty()) {
206  this->addDeformation(alignable, deformation_, random_, gaussian_, scale_);
207  }
208 
209  // Apply error - first add scale_ to error
210  scaleError_ *= scale_;
211  if ( setError_ && scaleError_ ) {
212  // Alignment Position Error for flat distribution: 1 sigma
213  if ( !gaussian_ ) scaleError_ *= 0.68;
214 
215 
216  // Error on displacement
217  if ( std::abs(dX_) + std::abs(dY_) + std::abs(dZ_) > 0 && setTranslations_ )
218  this->addAlignmentPositionError( alignable,
220 
221  // Error on local displacements
223  this->addAlignmentPositionErrorLocal( alignable,
226 
227  // Error on rotations
229  this->addAlignmentPositionErrorFromRotation( alignable,
231  scaleError_*phiZ_ );
232 
233  // Error on local rotations
235  && setRotations_ )
240  // Do we need to add any APE for deformations?
241  // Probably we would do so if there wouldn't be data, but only MC to play with... ;-)
242  }
243  // } // end if (scale_)
244 
245  return ( m_modified > 0 );
246 
247 }
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:186
void addAlignmentPositionError(Alignable *alignable, float dx, float dy, float dz)
Add the AlignmentPositionError (in global frame) to Alignable.
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;). ...
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 288 of file AlignableModifier.cc.

References flatRandomVector(), gaussianRandomVector(), LogDebug, m_modified, Alignable::move(), and fftjetvertexadder_cfi::sigmaZ.

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

290 {
291 
292 
293  std::ostringstream message;
294 
295  // Get movement vector according to arguments
296  GlobalVector moveV( sigmaX, sigmaY, sigmaZ ); // Default: fixed
297  if ( random ) {
298  std::vector<float> randomNumbers;
299  message << "random ";
300  if (gaussian) {
301  randomNumbers = this->gaussianRandomVector( sigmaX, sigmaY, sigmaZ );
302  message << "gaussian ";
303  } else {
304  randomNumbers = this->flatRandomVector( sigmaX, sigmaY, sigmaZ );
305  message << "flat ";
306  }
307  moveV = GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
308  }
309 
310  message << " move with sigma " << sigmaX << " " << sigmaY << " " << sigmaZ;
311 
312  LogDebug("PrintArgs") << message.str(); // Arguments
313 
314  LogDebug("PrintMovement") << "applied displacement: " << moveV; // Actual movements
315  alignable->move(moveV);
316  m_modified++;
317 
318 
319 }
#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 324 of file AlignableModifier.cc.

References addDeformation(), flatRandomVector(), gaussianRandomVector(), LogDebug, m_modified, Alignable::move(), fftjetvertexadder_cfi::sigmaZ, Alignable::surface(), and AlignableSurface::toGlobal().

Referenced by modify().

326 {
327 
328 
329  std::ostringstream message;
330 
331  // Get movement vector according to arguments
332  align::LocalVector moveV( sigmaX, sigmaY, sigmaZ ); // Default: fixed
333  if ( random ) {
334  std::vector<float> randomNumbers;
335  message << "random ";
336  if (gaussian) {
337  randomNumbers = this->gaussianRandomVector( sigmaX, sigmaY, sigmaZ );
338  message << "gaussian ";
339  } else {
340  randomNumbers = this->flatRandomVector( sigmaX, sigmaY, sigmaZ );
341  message << "flat ";
342  }
343  moveV = align::LocalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
344  }
345 
346  message << " move with sigma " << sigmaX << " " << sigmaY << " " << sigmaZ;
347 
348  LogDebug("PrintArgs") << message.str(); // Arguments
349 
350  LogDebug("PrintMovement") << "applied local displacement: " << moveV; // Actual movements
351  alignable->move( alignable->surface().toGlobal(moveV) );
352  m_modified++;
353 
354 
355 }
#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:135
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 534 of file AlignableModifier.cc.

References funct::abs(), mps_fire::i, and theDRand48Engine.

Referenced by addDeformation().

535 {
536  for (unsigned int i = 0; i < rnd.size(); ++i) {
537  if (rnd[i] < 0.) {
538  edm::LogWarning("BadConfig") << " taking absolute value to randomise " << i;
539  rnd[i] = std::abs(rnd[i]);
540  }
541 
542  if (gaussian) {
543  CLHEP::RandGauss aGaussObj( *theDRand48Engine, 0., rnd[i]);
544  rnd[i] = aGaussObj.fire();
545  } else {
546  CLHEP::RandFlat aFlatObj(*theDRand48Engine, -rnd[i], rnd[i]);
547  rnd[i] = aFlatObj.fire();
548  }
549  }
550 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 392 of file AlignableModifier.cc.

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

394 {
395 
396 
397  std::ostringstream message;
398 
399  // Get rotation vector according to arguments
400  GlobalVector rotV( sigmaPhiX, sigmaPhiY, sigmaPhiZ ); // Default: fixed
401  if ( random ) {
402  std::vector<float> randomNumbers;
403  message << "random ";
404  if (gaussian) {
405  randomNumbers = this->gaussianRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
406  message << "gaussian ";
407  } else {
408  randomNumbers = flatRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
409  message << "flat ";
410  }
411  rotV = GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
412  }
413 
414  message << "global rotation by angles " << sigmaPhiX << " " << sigmaPhiY << " " << sigmaPhiZ;
415 
416  LogDebug("PrintArgs") << message.str(); // Arguments
417 
418  LogDebug("PrintMovement") << "applied rotation angles: " << rotV; // Actual movements
419  if ( std::abs(sigmaPhiX) ) alignable->rotateAroundGlobalX( rotV.x() );
420  if ( std::abs(sigmaPhiY) ) alignable->rotateAroundGlobalY( rotV.y() );
421  if ( std::abs(sigmaPhiZ) ) alignable->rotateAroundGlobalZ( rotV.z() );
422  m_modified++;
423 
424 
425 }
#define LogDebug(id)
const std::vector< float > gaussianRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (gaussian distribution)
TRandom random
Definition: MVATrainer.cc:138
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
Definition: Alignable.cc:221
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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:169
virtual void rotateAroundGlobalY(Scalar radians)
Rotation around global y-axis.
Definition: Alignable.cc:195
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 431 of file AlignableModifier.cc.

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

433 {
434 
435 
436  std::ostringstream message;
437 
438  // Get rotation vector according to arguments
439  align::LocalVector rotV( sigmaPhiX, sigmaPhiY, sigmaPhiZ ); // Default: fixed
440  if ( random ) {
441  std::vector<float> randomNumbers;
442  message << "random ";
443  if (gaussian) {
444  randomNumbers = this->gaussianRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
445  message << "gaussian ";
446  } else {
447  randomNumbers = flatRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
448  message << "flat ";
449  }
450  rotV = align::LocalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
451  }
452 
453  message << "local rotation by angles " << sigmaPhiX << " " << sigmaPhiY << " " << sigmaPhiZ;
454 
455  LogDebug("PrintArgs") << message.str(); // Arguments
456 
457  LogDebug("PrintMovement") << "applied local rotation angles: " << rotV; // Actual movements
458  if ( std::abs(sigmaPhiX) ) alignable->rotateAroundLocalX( rotV.x() );
459  if ( std::abs(sigmaPhiY) ) alignable->rotateAroundLocalY( rotV.y() );
460  if ( std::abs(sigmaPhiZ) ) alignable->rotateAroundLocalZ( rotV.z() );
461  m_modified++;
462 
463 
464 }
#define LogDebug(id)
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
Definition: Alignable.cc:234
const std::vector< float > gaussianRandomVector(float sigmaX, float sigmaY, float sigmaZ) const
Return a vector of random numbers (gaussian distribution)
TRandom random
Definition: MVATrainer.cc:138
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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:208
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
Definition: Alignable.cc:182
void AlignableModifier::setDistribution ( const std::string &  distr)

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

Definition at line 251 of file AlignableModifier.cc.

References gaussian_, and random_.

Referenced by modify().

252 {
253 
254  if ( distr == "fixed" ) random_ = false;
255  else if ( distr == "flat" ) {
256  random_ = true;
257  gaussian_ = false;
258  } else if ( distr == "gaussian" ) {
259  random_ = true;
260  gaussian_ = true;
261  }
262 
263 }
void AlignableModifier::setSeed ( long  seed)

Resets the generator seed according to the argument.

If 'seed' is zero, asks RandomNumberGenerator service.

Definition at line 268 of file AlignableModifier.cc.

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

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

269 {
270 
271  long m_seed;
272 
273  if ( seed > 0 ) m_seed = seed;
274  else {
276  m_seed = rng->mySeed();
277  }
278 
279  LogDebug("PrintArgs") << "Setting generator seed to " << m_seed;
280 
281  theDRand48Engine->setSeed( m_seed );
282 
283 }
#define LogDebug(id)
CLHEP::DRand48Engine * theDRand48Engine
Unique random number generator.
virtual std::uint32_t mySeed() const =0

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().