CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions

BeamSpotAlignmentParameters Class Reference

#include <BeamSpotAlignmentParameters.h>

Inheritance diagram for BeamSpotAlignmentParameters:
AlignmentParameters

List of all members.

Public Types

enum  AlignmentParameterName {
  dx = 0, dy, dxslope, dyslope,
  N_PARAM
}
 

Give parameters a name.

More...

Public Member Functions

virtual void apply ()
 apply parameters to alignable
 BeamSpotAlignmentParameters (Alignable *alignable, bool calcMis)
 BeamSpotAlignmentParameters (Alignable *alignable, const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix)
 Constructor for full set of parameters.
 BeamSpotAlignmentParameters (Alignable *alignable, const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix, const std::vector< bool > &selection)
 Constructor for selection.
virtual
BeamSpotAlignmentParameters
clone (const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const
 Clone all parameters (for update of parameters)
virtual
BeamSpotAlignmentParameters
cloneFromSelected (const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const
 Clone selected parameters (for update of parameters)
virtual AlgebraicMatrix derivatives (const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &) const
 Get all derivatives.
AlgebraicVector globalParameters (void) const
 calculate and return parameters in global frame
void print (void) const
 print parameters to screen
AlgebraicVector rotation (void) const
 Get rotation parameters.
virtual AlgebraicMatrix selectedDerivatives (const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &) const
 Get selected derivatives.
AlgebraicVector translation (void) const
 Get translation parameters.
virtual int type () const
 tell type (AlignmentParametersFactory::ParametersType - but no circular dependency)
virtual ~BeamSpotAlignmentParameters ()
 Destructor.

Static Public Member Functions

static AlgebraicVector displacementFromAlignable (const Alignable *ali)

Detailed Description

Concrete class for alignment parameters and associated quantities [derived from AlignmentParameters]. The number of parameters N_PARAM is fixed to 4 (2 translations in x & y, and 2 slopes)

Date:
2010/09/10 11:16:36
Revision:
1.1

(last update by

Author:
mussgill

)

Definition at line 21 of file BeamSpotAlignmentParameters.h.


Member Enumeration Documentation

Give parameters a name.

Enumerator:
dx 
dy 
dxslope 
dyslope 
N_PARAM 

Definition at line 27 of file BeamSpotAlignmentParameters.h.

        {
          dx = 0, dy,
          dxslope, dyslope,
          N_PARAM
        };

Constructor & Destructor Documentation

BeamSpotAlignmentParameters::BeamSpotAlignmentParameters ( Alignable alignable,
bool  calcMis 
)

Constructor with empty parameters/covariance (if calcMis = false) or with parameters (no covariance) created from current (mis-)placement of alignable (if calcMis = true).

Definition at line 22 of file BeamSpotAlignmentParameters.cc.

Referenced by clone(), and cloneFromSelected().

BeamSpotAlignmentParameters::BeamSpotAlignmentParameters ( Alignable alignable,
const AlgebraicVector parameters,
const AlgebraicSymMatrix covMatrix 
)

Constructor for full set of parameters.

Definition at line 30 of file BeamSpotAlignmentParameters.cc.

References Exception, and N_PARAM.

                                                                                              :
  AlignmentParameters( alignable, parameters, covMatrix )
{  
  if (parameters.num_row() != N_PARAM) {
    throw cms::Exception("BadParameters") << "in BeamSpotAlignmentParameters(): "
                                          << parameters.num_row() << " instead of " << N_PARAM 
                                          << " parameters.";
  }
}
BeamSpotAlignmentParameters::BeamSpotAlignmentParameters ( Alignable alignable,
const AlgebraicVector parameters,
const AlgebraicSymMatrix covMatrix,
const std::vector< bool > &  selection 
)

Constructor for selection.

Definition at line 43 of file BeamSpotAlignmentParameters.cc.

References Exception, and N_PARAM.

                                                                                            :
  AlignmentParameters( alignable, parameters, covMatrix, selection )
{  
  if (parameters.num_row() != N_PARAM) {
    throw cms::Exception("BadParameters") << "in BeamSpotAlignmentParameters(): "
                                          << parameters.num_row() << " instead of " << N_PARAM 
                                          << " parameters.";
  }
}
BeamSpotAlignmentParameters::~BeamSpotAlignmentParameters ( ) [virtual]

Destructor.

Definition at line 57 of file BeamSpotAlignmentParameters.cc.

{

} 

Member Function Documentation

void BeamSpotAlignmentParameters::apply ( ) [virtual]

apply parameters to alignable

Implements AlignmentParameters.

Definition at line 169 of file BeamSpotAlignmentParameters.cc.

References AlignmentParameters::alignable(), Exception, Alignable::move(), align::rectify(), makeMuonMisalignmentScenario::rot, Alignable::rotateInGlobalFrame(), rotation(), edm::shift, Alignable::surface(), AlignableSurface::toGlobal(), align::toMatrix(), and translation().

{
  Alignable *alignable = this->alignable();
  if (!alignable) {
    throw cms::Exception("BadParameters") 
      << "BeamSpotAlignmentParameters::apply: parameters without alignable";
  }
  
  // Translation in local frame
  AlgebraicVector shift = this->translation(); // fixme: should be LocalVector
  
  // Translation local->global
  align::GlobalVector gv(shift[0], shift[1], shift[2]);
  alignable->move( gv );

  // Rotation in local frame
  align::EulerAngles angles = this->rotation();
  // original code:
  //  alignable->rotateInLocalFrame( align::toMatrix(angles) );
  // correct for rounding errors:
  align::RotationType rot = alignable->surface().toGlobal( align::toMatrix(angles) );
  align::rectify(rot);
  alignable->rotateInGlobalFrame(rot);
}
BeamSpotAlignmentParameters * BeamSpotAlignmentParameters::clone ( const AlgebraicVector parameters,
const AlgebraicSymMatrix covMatrix 
) const [virtual]
BeamSpotAlignmentParameters * BeamSpotAlignmentParameters::cloneFromSelected ( const AlgebraicVector parameters,
const AlgebraicSymMatrix covMatrix 
) const [virtual]
AlgebraicMatrix BeamSpotAlignmentParameters::derivatives ( const TrajectoryStateOnSurface tsos,
const AlignableDetOrUnitPtr alidet 
) const [virtual]

Get all derivatives.

Implements AlignmentParameters.

Definition at line 93 of file BeamSpotAlignmentParameters.cc.

References AlignmentParameters::alignable(), and FrameToFrameDerivative::frameToFrameDerivative().

Referenced by selectedDerivatives().

{
  const Alignable *ali = this->alignable(); // Alignable of these parameters

  if (ali == alidet) { // same alignable => same frame
    return BeamSpotAlignmentDerivatives()(tsos);
  } else { // different alignable => transform into correct frame
    const AlgebraicMatrix deriv = BeamSpotAlignmentDerivatives()(tsos);
    FrameToFrameDerivative ftfd;
    return ftfd.frameToFrameDerivative(alidet, ali) * deriv;
  }
}
AlgebraicVector BeamSpotAlignmentParameters::displacementFromAlignable ( const Alignable ali) [static]

Calculate parameter vector of misplacements (shift+rotation) from alignable. (If ali=0, return empty AlgebraicVector of proper length.)

Definition at line 234 of file BeamSpotAlignmentParameters.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), Alignable::displacement(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, Alignable::globalRotation(), N_PARAM, Alignable::rotation(), TkRotation< T >::transposed(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

{
  AlgebraicVector displacement(N_PARAM);

  if (ali) {
    const align::RotationType& dR = ali->rotation();
    
    const align::LocalVector shifts( ali->globalRotation() * 
                                     ( dR.transposed() * ali->displacement().basicVector() ) );
    
    align::GlobalVector gv(0.0, 0.0, 1.0);
    align::LocalVector lv(dR.transposed() * gv.basicVector());
    
    displacement[0] = shifts.x();
    displacement[1] = shifts.y();
    displacement[2] = lv.x()/lv.z();
    displacement[3] = lv.y()/lv.z();
  }

  return displacement;
}
AlgebraicVector BeamSpotAlignmentParameters::globalParameters ( void  ) const

calculate and return parameters in global frame

Definition at line 201 of file BeamSpotAlignmentParameters.cc.

References N_PARAM, edm::shift, Alignable::surface(), AlignmentParameters::theAlignable, AlignableSurface::toGlobal(), translation(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

{
  AlgebraicVector m_GlobalParameters(N_PARAM, 0);

  const AlgebraicVector shift = translation(); // fixme: should return LocalVector

  const align::GlobalVector dg(shift[0], shift[1], 0);
  
  m_GlobalParameters[0] = dg.x();
  m_GlobalParameters[1] = dg.y();
  
  align::LocalVector lv(0.0, 0.0, 1.0);
  align::GlobalVector gv = theAlignable->surface().toGlobal(lv);
  
  double dxdz = gv.x()/gv.z();
  double dydz = gv.x()/gv.z();
  
  m_GlobalParameters[2] = dxdz;
  m_GlobalParameters[3] = dydz;
  
  return m_GlobalParameters;
}
void BeamSpotAlignmentParameters::print ( void  ) const

print parameters to screen

Definition at line 225 of file BeamSpotAlignmentParameters.cc.

References gather_cfg::cout, and AlignmentParameters::theData.

{

  std::cout << "Contents of BeamSpotAlignmentParameters:"
            << "\nParameters: " << theData->parameters()
            << "\nCovariance: " << theData->covariance() << std::endl;
}
AlgebraicVector BeamSpotAlignmentParameters::rotation ( void  ) const

Get rotation parameters.

Definition at line 142 of file BeamSpotAlignmentParameters.cc.

References funct::cos(), makeMuonMisalignmentScenario::rot, funct::sin(), AlignmentParameters::theData, and align::toAngles().

Referenced by apply().

{
  AlgebraicVector rot(3);

  double dxdz = theData->parameters()[2];  
  double dydz = theData->parameters()[3];  
  double angleY = std::atan(dxdz);
  double angleX = -std::atan(dydz);

  align::RotationType rotY( std::cos(angleY),  0., -std::sin(angleY), 
                            0.,                1.,  0.,
                            std::sin(angleY),  0.,  std::cos(angleY) );

  align::RotationType rotX( 1.,  0.,                0.,
                            0.,  std::cos(angleX),  std::sin(angleX),
                            0., -std::sin(angleX),  std::cos(angleX) );

  align::EulerAngles angles = align::toAngles(rotY * rotX);

  rot[0] = angles(1);
  rot[1] = angles(2);
  rot[2] = angles(3);

  return rot;
}
AlgebraicMatrix BeamSpotAlignmentParameters::selectedDerivatives ( const TrajectoryStateOnSurface tsos,
const AlignableDetOrUnitPtr alignableDet 
) const [virtual]

Get selected derivatives.

Reimplemented from AlignmentParameters.

Definition at line 109 of file BeamSpotAlignmentParameters.cc.

References derivatives(), AlignmentParameters::numSelected(), and AlignmentParameters::selector().

{
  const AlgebraicMatrix dev = this->derivatives( tsos, alignableDet );

  int ncols  = dev.num_col();
  int nrows  = dev.num_row();
  int nsel   = numSelected();

  AlgebraicMatrix seldev( nsel, ncols );

  int ir2=0;
  for ( int irow=0; irow<nrows; ++irow ) {
    if (selector()[irow]) {
      for ( int icol=0; icol<ncols; ++icol ) seldev[ir2][icol] = dev[irow][icol];
      ++ir2;
    }
  }

  return seldev;
}
AlgebraicVector BeamSpotAlignmentParameters::translation ( void  ) const

Get translation parameters.

Definition at line 132 of file BeamSpotAlignmentParameters.cc.

References i, edm::shift, and AlignmentParameters::theData.

Referenced by apply(), and globalParameters().

{ 
  AlgebraicVector shift(3);
  for ( int i=0;i<2;++i ) shift[i] = theData->parameters()[i];
  shift[2] = 0.0;

  return shift;
}
int BeamSpotAlignmentParameters::type ( ) const [virtual]

tell type (AlignmentParametersFactory::ParametersType - but no circular dependency)

Implements AlignmentParameters.

Definition at line 195 of file BeamSpotAlignmentParameters.cc.

References AlignmentParametersFactory::kBeamSpot.