CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

AlignableModifier Class Reference

#include <AlignableModifier.h>

List of all members.

Public Member Functions

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

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.

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

                                           :
  distribution_(""),
  random_(false), gaussian_(false), setError_(false),
  setRotations_(false),setTranslations_(false),
  seed_(0),
  scaleError_(0.), scale_(0.),
  phiX_(0.), phiY_(0.), phiZ_(0.),
  phiXlocal_(0.), phiYlocal_(0.), phiZlocal_(0.),
  dX_(0.), dY_(0.), dZ_(0.),
  dXlocal_(0.), dYlocal_(0.), dZlocal_(0.),
  twist_(0.), shear_(0.)
{

  theDRand48Engine = new CLHEP::DRand48Engine();

}
AlignableModifier::~AlignableModifier ( )

Destructor.

Definition at line 39 of file AlignableModifier.cc.

References theDRand48Engine.

{

  delete theDRand48Engine;

}

Member Function Documentation

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

Add the AlignmentPositionError (in global frame) to Alignable.

Definition at line 545 of file AlignableModifier.cc.

References Alignable::addAlignmentPositionError(), and LogDebug.

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

{

  LogDebug("PrintArgs") << "Adding an AlignmentPositionError of size " 
                        << dx << " "  << dy << " "  << dz;

  AlignmentPositionError ape(dx,dy,dz);
  alignable->addAlignmentPositionError( ape, true );

}
void AlignableModifier::addAlignmentPositionErrorFromLocalRotation ( Alignable alignable,
float  phiX,
float  phiY,
float  phiZ 
)

Add alignment position error resulting from rotation in local frame.

Definition at line 601 of file AlignableModifier.cc.

References makeMuonMisalignmentScenario::rot.

Referenced by modify().

{

  align::RotationType rotx( Basic3DVector<float>(1.0, 0.0, 0.0), phiX );
  align::RotationType roty( Basic3DVector<float>(0.0, 1.0, 0.0), phiY );
  align::RotationType rotz( Basic3DVector<float>(0.0, 0.0, 1.0), phiZ );
  align::RotationType rot = rotz * roty * rotx;
  
  this->addAlignmentPositionErrorFromLocalRotation( alignable, rot );

}
void AlignableModifier::addAlignmentPositionErrorFromLocalRotation ( Alignable alignable,
align::RotationType rotation 
)

Add alignment position error resulting from rotation in local frame.

Definition at line 630 of file AlignableModifier.cc.

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

{ 
  
  LogDebug("PrintArgs") << "Adding an AlignmentPositionError from Local Rotation" << std::endl 
                        << rotation;
  
  // true: propagate down to components
  alignable->addAlignmentPositionErrorFromLocalRotation(rotation, true);
  
}
void AlignableModifier::addAlignmentPositionErrorFromRotation ( Alignable alignable,
float  phiX,
float  phiY,
float  phiZ 
)

Add alignment position error resulting from rotation in global frame.

Definition at line 585 of file AlignableModifier.cc.

References makeMuonMisalignmentScenario::rot.

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

{

  align::RotationType rotx( Basic3DVector<float>(1.0, 0.0, 0.0), phiX );
  align::RotationType roty( Basic3DVector<float>(0.0, 1.0, 0.0), phiY );
  align::RotationType rotz( Basic3DVector<float>(0.0, 0.0, 1.0), phiZ );
  align::RotationType rot = rotz * roty * rotx;
  
  this->addAlignmentPositionErrorFromRotation( alignable, rot );

}
void AlignableModifier::addAlignmentPositionErrorFromRotation ( Alignable alignable,
align::RotationType rotation 
)

Add alignment position error resulting from rotation in global frame.

Definition at line 617 of file AlignableModifier.cc.

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

{ 

  LogDebug("PrintArgs") << "Adding an AlignmentPositionError from Rotation" << std::endl 
                        << rotation;

  alignable->addAlignmentPositionErrorFromRotation(rotation, true); // propagate down to components

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

Add the AlignmentPositionError (in local frame) to Alignable.

Definition at line 559 of file AlignableModifier.cc.

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

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

{

  LogDebug("PrintArgs") << "Adding a local AlignmentPositionError of size " 
                        << dx << " "  << dy << " "  << dz;

  AlgebraicSymMatrix as(3,0); //3x3, zeroed
  as[0][0] = dx*dx; as[1][1] = dy*dy; as[2][2] = dz*dz; //diagonals
  align::RotationType rt = alignable->globalRotation(); //get rotation
  AlgebraicMatrix am(3,3);
  am[0][0]=rt.xx(); am[0][1]=rt.xy(); am[0][2]=rt.xz();
  am[1][0]=rt.yx(); am[1][1]=rt.yy(); am[1][2]=rt.yz();
  am[2][0]=rt.zx(); am[2][1]=rt.zy(); am[2][2]=rt.zz();
  as=as.similarityT(am); //rotate error matrix

  GlobalError ge( asSMatrix<3>(as) );
  AlignmentPositionError ape( ge );

  alignable->addAlignmentPositionError( ape, true ); // propagate down to components

}
void AlignableModifier::addDeformation ( Alignable alignable,
const DeformationMemberType deformation,
bool  random,
bool  gaussian,
double  scale 
) [private]

Definition at line 351 of file AlignableModifier.cc.

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

Referenced by modify().

{
  const SurfaceDeformationFactory::Type deformType
    = SurfaceDeformationFactory::surfaceDeformationType(deformation.first);

  // Scale and randomize
  // (need a little hack since ySplit must not be treated)!
  const bool rndNotLast = (deformType == SurfaceDeformationFactory::kTwoBowedSurfaces);
  std::vector<double> rndDeformation(deformation.second.begin(),
                                     deformation.second.end() - (rndNotLast ? 1 : 0));
  for (unsigned int i = 0; i < rndDeformation.size(); ++i) {
    rndDeformation[i] *= scale;
  }
  if (random) {
    this->randomise(rndDeformation, gaussian);
  }
  if (rndNotLast) { // put back ySplit at the end
    rndDeformation.push_back(deformation.second.back());
  }
  
  // auto_ptr has exception safe delete (in contrast to bare pointer)
  const std::auto_ptr<SurfaceDeformation> surfDef
    (SurfaceDeformationFactory::create(deformType, rndDeformation));
  
  alignable->addSurfaceDeformation(surfDef.get(), true); // true to propagate down
  ++m_modified;
}
const std::vector< float > AlignableModifier::flatRandomVector ( float  sigmaX,
float  sigmaY,
float  sigmaZ 
) const

Return a vector of random numbers (flat distribution)

Definition at line 495 of file AlignableModifier.cc.

References abs, and theDRand48Engine.

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

{

  // Get absolute value if negative arguments
  if ( sigmaX < 0 ) {
    edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_x";
    sigmaX = std::abs(sigmaX);
  }
  if ( sigmaY < 0 ) {
    edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_y";
    sigmaY = std::abs(sigmaY);
  }
  if ( sigmaZ < 0 ) {
    edm::LogWarning("BadConfig") << " taking absolute value for flat sigma_z";
    sigmaZ = std::abs(sigmaZ);
  }

  CLHEP::RandFlat aFlatObjX( *theDRand48Engine, -sigmaX, sigmaX );
  CLHEP::RandFlat aFlatObjY( *theDRand48Engine, -sigmaY, sigmaY );
  CLHEP::RandFlat aFlatObjZ( *theDRand48Engine, -sigmaZ, sigmaZ );

  std::vector<float> randomVector;
  randomVector.push_back( aFlatObjX.fire() );
  randomVector.push_back( aFlatObjY.fire() );
  randomVector.push_back( aFlatObjZ.fire() );

  return randomVector;

}
const std::vector< float > AlignableModifier::gaussianRandomVector ( float  sigmaX,
float  sigmaY,
float  sigmaZ 
) const

Return a vector of random numbers (gaussian distribution)

Definition at line 461 of file AlignableModifier.cc.

References abs, and theDRand48Engine.

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

{

  // Get absolute value if negative arguments
  if ( sigmaX < 0 ) {
    edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_x";
    sigmaX = std::abs(sigmaX);
  }
  if ( sigmaY < 0 ) {
    edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_y";
    sigmaY = std::abs(sigmaY);
  }
  if ( sigmaZ < 0 ) {
    edm::LogWarning("BadConfig") << " taking absolute value for gaussian sigma_z";
    sigmaZ = std::abs(sigmaZ);
  }

  // Pass by reference, otherwise pointer is deleted!
  CLHEP::RandGauss aGaussObjX( *theDRand48Engine, 0., sigmaX );
  CLHEP::RandGauss aGaussObjY( *theDRand48Engine, 0., sigmaY );
  CLHEP::RandGauss aGaussObjZ( *theDRand48Engine, 0., sigmaZ );

  std::vector<float> randomVector;
  randomVector.push_back( aGaussObjX.fire() );
  randomVector.push_back( aGaussObjY.fire() );
  randomVector.push_back( aGaussObjZ.fire() );

  return randomVector;

}
void AlignableModifier::init_ ( void  ) [private]

Initialisation of all parameters.

Definition at line 47 of file AlignableModifier.cc.

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

Referenced by modify().

{

  // Initialize all known parameters (according to ORCA's MisalignmentScenario.cc)
  distribution_ = "";        // Switch for distributions ("fixed","flat","gaussian")
  setError_     = false;     // Apply alignment errors
  setRotations_ = true;      // Apply rotations
  setTranslations_ = true;   // Apply translations
  scale_        = 1.;        // Scale to apply to all movements
  scaleError_   = 1.;        // Scale to apply to alignment errors
  phiX_         = 0.;        // Rotation angle around X [rad]
  phiY_         = 0.;        // Rotation angle around Y [rad]
  phiZ_         = 0.;        // Rotation angle around Z [rad]
  phiXlocal_    = 0.;        // Local rotation angle around X [rad]
  phiYlocal_    = 0.;        // Local rotation angle around Y [rad]
  phiZlocal_    = 0.;        // Local rotation angle around Z [rad]
  dX_           = 0.;        // X displacement [cm]
  dY_           = 0.;        // Y displacement [cm]
  dZ_           = 0.;        // Z displacement [cm]
  dXlocal_      = 0.;        // Local X displacement [cm]
  dYlocal_      = 0.;        // Local Y displacement [cm]
  dZlocal_      = 0.;        // Local Z displacement [cm]
  deformation_.first.clear();// SurfaceDeformation: type
  deformation_.second.clear();//SurfaceDeformation: parameter vector
  twist_        = 0.;        // Twist angle [rad]
  shear_        = 0.;        // Shear angle [rad]

  // These are set through 'distribution'
  random_       = true;      // Use random distributions
  gaussian_     = true;      // Use gaussian distribution (otherwise flat)

}
bool AlignableModifier::isPropagated ( const std::string &  parameterName) const

Check if given parameter should be propagated.

Definition at line 82 of file AlignableModifier.cc.

Referenced by MisalignmentScenarioBuilder::propagateParameters_().

{

  if ( parameterName == "distribution"    || 
       parameterName == "setError"        ||
       parameterName == "scaleError"      ||
       parameterName == "setRotations"    ||
       parameterName == "setTranslations" ||
       parameterName == "scale" 
       ) return true;
  
  return false;

}
bool AlignableModifier::modify ( Alignable alignable,
const edm::ParameterSet pSet 
)

Modify given set of alignables according to parameters.

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

Definition at line 100 of file AlignableModifier.cc.

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

{

  // Initialize parameters
  this->init_();
  int rotX_=0, rotY_=0, rotZ_=0; // To check correct backward compatibility


  // Reset counter
  m_modified = 0;
  
  // Retrieve parameters
  std::ostringstream error;
  std::vector<std::string> parameterNames = pSet.getParameterNames();
  for ( std::vector<std::string>::iterator iParam = parameterNames.begin(); 
        iParam != parameterNames.end(); iParam++ ) {
    if  ( (*iParam) == "distribution" ) distribution_ = pSet.getParameter<std::string>( *iParam );
    else if ( (*iParam) == "setError" ) setError_ = pSet.getParameter<bool>( *iParam );
    else if ( (*iParam) == "setRotations") setRotations_ = pSet.getParameter<bool>( *iParam );
    else if ( (*iParam) == "setTranslations") setTranslations_ = pSet.getParameter<bool>( *iParam );
    else if ( (*iParam) == "scale" )    scale_ = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "scaleError" ) scaleError_ = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "phiX" )    phiX_     = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "phiY" )    phiY_     = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "phiZ" )    phiZ_     = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "dX" )      dX_       = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "dY" )      dY_       = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "dZ" )      dZ_       = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "dXlocal" ) dXlocal_  = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "dYlocal" ) dYlocal_  = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "dZlocal" ) dZlocal_  = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "twist" )   twist_    = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "shear" )   shear_    = pSet.getParameter<double>( *iParam );
    else if ( (*iParam) == "localX" ) { phiXlocal_=pSet.getParameter<double>( *iParam ); rotX_++; }
    else if ( (*iParam) == "localY" ) { phiYlocal_=pSet.getParameter<double>( *iParam ); rotY_++; }
    else if ( (*iParam) == "localZ" ) { phiZlocal_=pSet.getParameter<double>( *iParam ); rotZ_++; }
    else if ( (*iParam) == "phiXlocal" ) { phiXlocal_=pSet.getParameter<double>( *iParam ); rotX_++; }
    else if ( (*iParam) == "phiYlocal" ) { phiYlocal_=pSet.getParameter<double>( *iParam ); rotY_++; }
    else if ( (*iParam) == "phiZlocal" ) { phiZlocal_=pSet.getParameter<double>( *iParam ); rotZ_++; }
    else if ( (*iParam) == "deformation" ) {
      const edm::ParameterSet deform(pSet.getParameter<edm::ParameterSet>( *iParam ));
      deformation_.first  = deform.getParameter<std::string>("type");
      deformation_.second = deform.getParameter<std::vector<double> >("parameters");
      // a non-complete check of simple mistyping of "deformation"
      // i.e. should detect at least a single wrong character... HACK
    } else if (pSet.existsAs<edm::ParameterSet>(*iParam)
               && ((*iParam).find("deform") != std::string::npos ||
                   (*iParam).find("ation")  != std::string::npos)) {
      throw cms::Exception("BadConfig") << "Probable mistyping in config: '" << (*iParam)
                                        << "' should probably mean 'deformation'\n";
    } else if ( !pSet.existsAs<edm::ParameterSet>(*iParam) ) { // other PSets are OK to ignore
      if ( !error.str().length() ) error << "Unknown parameter name(s): ";
      error << " " << *iParam;
    }
  }

  // Check if both 'localN' and 'phiNlocal' have been used
  if ( rotX_==2 ) throw cms::Exception("BadConfig") << "Found both localX and phiXlocal";
  if ( rotY_==2 ) throw cms::Exception("BadConfig") << "Found both localY and phiYlocal";
  if ( rotZ_==2 ) throw cms::Exception("BadConfig") << "Found both localZ and phiZlocal";

  // Check error
  if ( error.str().length() )
    throw cms::Exception("BadConfig") << error.str();

  // Decode distribution
  this->setDistribution( distribution_ );

  //if (scale_) { NO! Different random sequence if only parts scale to zero!

  // Apply displacements
  if ( std::abs(dX_) + std::abs(dY_) + std::abs(dZ_) > 0 && setTranslations_ )
    this->moveAlignable( alignable, random_, gaussian_, scale_*dX_, scale_*dY_, scale_*dZ_ );
  
  // Apply local displacements
  if ( std::abs(dXlocal_) + std::abs(dYlocal_) + std::abs(dZlocal_) > 0 && setTranslations_ )
    this->moveAlignableLocal( alignable, random_, gaussian_, 
                              scale_*dXlocal_, scale_*dYlocal_, scale_*dZlocal_ );
  
  // Apply rotations
  if ( std::abs(phiX_) + std::abs(phiY_) + std::abs(phiZ_) > 0 && setRotations_ )
    this->rotateAlignable( alignable, random_, gaussian_,
                           scale_*phiX_, scale_*phiY_, scale_*phiZ_ );
  
  // Apply local rotations
  if ( std::abs(phiXlocal_) + std::abs(phiYlocal_) + std::abs(phiZlocal_) > 0 && setRotations_ )
    this->rotateAlignableLocal( alignable, random_, gaussian_, 
                                scale_*phiXlocal_, scale_*phiYlocal_, scale_*phiZlocal_ );
  
  // Apply twist
  if ( std::abs(twist_) > 0 )
    edm::LogError("NotImplemented") << "Twist is not implemented yet";
  
  // Apply shear
  if ( std::abs(shear_) > 0 )
    edm::LogError("NotImplemented") << "Shear is not implemented yet";
  
  if (!deformation_.first.empty()) {
    this->addDeformation(alignable, deformation_, random_, gaussian_, scale_);
  }

  // Apply error - first add scale_ to error
  scaleError_ *= scale_;
  if ( setError_ && scaleError_ ) {
    // Alignment Position Error for flat distribution: 1 sigma
    if ( !gaussian_ ) scaleError_ *= 0.68;
    
    
    // Error on displacement
    if ( std::abs(dX_) + std::abs(dY_) + std::abs(dZ_) > 0 && setTranslations_ )
      this->addAlignmentPositionError( alignable, 
                                       scaleError_*dX_, scaleError_*dY_, scaleError_*dZ_ );
    
    // Error on local displacements
    if ( std::abs(dXlocal_) + std::abs(dYlocal_) + std::abs(dZlocal_) > 0 && setTranslations_ )
      this->addAlignmentPositionErrorLocal( alignable,
                                            scaleError_*dXlocal_, scaleError_*dYlocal_, 
                                            scaleError_*dZlocal_ );
    
    // Error on rotations
    if ( std::abs(phiX_) + std::abs(phiY_) + std::abs(phiZ_) > 0 && setRotations_ )
      this->addAlignmentPositionErrorFromRotation( alignable, 
                                                   scaleError_*phiX_, scaleError_*phiY_, 
                                                   scaleError_*phiZ_ );
    
    // Error on local rotations
    if ( std::abs(phiXlocal_) + std::abs(phiYlocal_) + std::abs(phiZlocal_) > 0
         && setRotations_ )
      this->addAlignmentPositionErrorFromLocalRotation( alignable, 
                                                        scaleError_*phiXlocal_, 
                                                        scaleError_*phiYlocal_, 
                                                        scaleError_*phiZlocal_ );
    // Do we need to add any APE for deformations?
    // Probably we would do so if there wouldn't be data, but only MC to play with... ;-)
  }
  // } // end if (scale_)

  return ( m_modified > 0 );
  
}
void AlignableModifier::moveAlignable ( Alignable alignable,
bool  random,
bool  gaussian,
float  sigmaX,
float  sigmaY,
float  sigmaZ 
)

Move alignable in global space according to parameters.

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

Definition at line 280 of file AlignableModifier.cc.

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

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

{

  
  std::ostringstream message;
 
  // Get movement vector according to arguments
  GlobalVector moveV( sigmaX, sigmaY, sigmaZ ); // Default: fixed
  if ( random ) {
    std::vector<float> randomNumbers;
    message << "random ";
    if (gaussian)       {
      randomNumbers = this->gaussianRandomVector( sigmaX, sigmaY, sigmaZ );
      message << "gaussian ";
    } else      {
      randomNumbers = this->flatRandomVector( sigmaX, sigmaY, sigmaZ );
      message << "flat ";
    }
    moveV = GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
  }
  
  message << " move with sigma " << sigmaX << " " << sigmaY << " " << sigmaZ;

  LogDebug("PrintArgs") << message.str(); // Arguments

  LogDebug("PrintMovement") << "applied displacement: " << moveV; // Actual movements
  alignable->move(moveV);
  m_modified++;


}
void AlignableModifier::moveAlignableLocal ( Alignable alignable,
bool  random,
bool  gaussian,
float  sigmaX,
float  sigmaY,
float  sigmaZ 
)

Move alignable in local space according to parameters.

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

Definition at line 316 of file AlignableModifier.cc.

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

Referenced by modify().

{

  
  std::ostringstream message;
 
  // Get movement vector according to arguments
  align::LocalVector moveV( sigmaX, sigmaY, sigmaZ ); // Default: fixed
  if ( random ) {
    std::vector<float> randomNumbers;
    message << "random ";
    if (gaussian) {
      randomNumbers = this->gaussianRandomVector( sigmaX, sigmaY, sigmaZ );
      message << "gaussian ";
    } else {
      randomNumbers = this->flatRandomVector( sigmaX, sigmaY, sigmaZ );
      message << "flat ";
    }
    moveV = align::LocalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
  }
  
  message << " move with sigma " << sigmaX << " " << sigmaY << " " << sigmaZ;

  LogDebug("PrintArgs") << message.str(); // Arguments

  LogDebug("PrintMovement") << "applied local displacement: " << moveV; // Actual movements
  alignable->move( alignable->surface().toGlobal(moveV) );
  m_modified++;


}
void AlignableModifier::randomise ( std::vector< double > &  rnd,
bool  gaussian 
) const

Randomise all entries in 'rnd':

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

Definition at line 526 of file AlignableModifier.cc.

References abs, i, and theDRand48Engine.

{
  for (unsigned int i = 0; i < rnd.size(); ++i) {
    if (rnd[i] < 0.)  {
      edm::LogWarning("BadConfig") << " taking absolute value to randomise " << i;
      rnd[i] = std::abs(rnd[i]);
    }
    
    if (gaussian) {
      CLHEP::RandGauss aGaussObj( *theDRand48Engine, 0., rnd[i]);
      rnd[i] = aGaussObj.fire();
    } else {
      CLHEP::RandFlat aFlatObj(*theDRand48Engine, -rnd[i], rnd[i]);
      rnd[i] = aFlatObj.fire();
    }
  }
}
void AlignableModifier::rotateAlignable ( Alignable alignable,
bool  random,
bool  gaussian,
float  sigmaPhiX,
float  sigmaPhiY,
float  sigmaPhiZ 
)

Rotate alignable in global space according to parameters.

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

Definition at line 384 of file AlignableModifier.cc.

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

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

{

  
  std::ostringstream message;

  // Get rotation vector according to arguments
  GlobalVector rotV( sigmaPhiX, sigmaPhiY, sigmaPhiZ ); // Default: fixed
  if ( random ) {
    std::vector<float> randomNumbers;
    message << "random ";
    if (gaussian) {
      randomNumbers = this->gaussianRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
      message << "gaussian ";
    } else {
      randomNumbers = flatRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
      message << "flat ";
    }
    rotV = GlobalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
  }
  
  message << "global rotation by angles " << sigmaPhiX << " " << sigmaPhiY << " " << sigmaPhiZ;

  LogDebug("PrintArgs") << message.str(); // Arguments

  LogDebug("PrintMovement") << "applied rotation angles: " << rotV; // Actual movements
  if ( std::abs(sigmaPhiX) ) alignable->rotateAroundGlobalX( rotV.x() );
  if ( std::abs(sigmaPhiY) ) alignable->rotateAroundGlobalY( rotV.y() );
  if ( std::abs(sigmaPhiZ) ) alignable->rotateAroundGlobalZ( rotV.z() );
  m_modified++;


}
void AlignableModifier::rotateAlignableLocal ( Alignable alignable,
bool  random,
bool  gaussian,
float  sigmaPhiX,
float  sigmaPhiY,
float  sigmaPhiZ 
)

Rotate alignable in local space according to parameters.

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

Definition at line 423 of file AlignableModifier.cc.

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

Referenced by modify().

{

  
  std::ostringstream message;

  // Get rotation vector according to arguments
  align::LocalVector rotV( sigmaPhiX, sigmaPhiY, sigmaPhiZ ); // Default: fixed
  if ( random ) {
    std::vector<float> randomNumbers;
    message << "random ";
    if (gaussian) {
      randomNumbers = this->gaussianRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
      message << "gaussian ";
    } else {
      randomNumbers = flatRandomVector( sigmaPhiX, sigmaPhiY, sigmaPhiZ );
      message << "flat ";
    }
    rotV = align::LocalVector( randomNumbers[0], randomNumbers[1], randomNumbers[2] );
  }
  
  message << "local rotation by angles " << sigmaPhiX << " " << sigmaPhiY << " " << sigmaPhiZ;
  
  LogDebug("PrintArgs") << message.str(); // Arguments
  
  LogDebug("PrintMovement") << "applied local rotation angles: " << rotV; // Actual movements
  if ( std::abs(sigmaPhiX) ) alignable->rotateAroundLocalX( rotV.x() );
  if ( std::abs(sigmaPhiY) ) alignable->rotateAroundLocalY( rotV.y() );
  if ( std::abs(sigmaPhiZ) ) alignable->rotateAroundLocalZ( rotV.z() );
  m_modified++;


}
void AlignableModifier::setDistribution ( const std::string &  distr)

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

Definition at line 243 of file AlignableModifier.cc.

References gaussian_, and random_.

Referenced by modify().

{

  if ( distr == "fixed" ) random_ = false;
  else if ( distr == "flat" ) {
    random_   = true;
    gaussian_ = false;
  } else if ( distr == "gaussian" ) {
    random_   = true;
    gaussian_ = true;
  }
  
}
void AlignableModifier::setSeed ( long  seed)

Resets the generator seed according to the argument.

If 'seed' is zero, asks RandomNumberGenerator service.

Definition at line 260 of file AlignableModifier.cc.

References LogDebug, and theDRand48Engine.

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

{

  long m_seed;

  if ( seed > 0 ) m_seed = seed;
  else {
    edm::Service<edm::RandomNumberGenerator> rng;
    m_seed = rng->mySeed();
  }

  LogDebug("PrintArgs") << "Setting generator seed to " << m_seed;

  theDRand48Engine->setSeed( m_seed );

}

Member Data Documentation

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

Definition at line 106 of file AlignableModifier.h.

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

double AlignableModifier::phiX_ [private]

Definition at line 110 of file AlignableModifier.h.

Referenced by init_(), and modify().

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

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

Definition at line 111 of file AlignableModifier.h.

Referenced by init_(), and modify().

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

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.

Definition at line 106 of file AlignableModifier.h.

Referenced by init_(), and modify().

Definition at line 107 of file AlignableModifier.h.

Referenced by init_(), and modify().

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