CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Friends

DDRotation Class Reference

Represents a uniquely identifyable rotation matrix. More...

#include <DDTransform.h>

Inheritance diagram for DDRotation:
DDBase< DDName, DDRotationMatrix * >

List of all members.

Public Member Functions

 DDRotation ()
 refers to the unit-rotation (no rotation at all)
 DDRotation (const DDName &name)
 Creates a initialized reference-object or a reference to an allready defined rotation.
 DDRotation (const DDName &, DDRotationMatrix *)
DDRotationMatrixmatrix ()
DDRotationMatrixrotation ()
const DDRotationMatrixrotation () const
 Returns the read-only rotation-matrix.

Private Member Functions

 DDRotation (DDRotationMatrix *)

Friends

DDRotation DDanonymousRot (DDRotationMatrix *)
 Defines a anonymous rotation or rotation-reflection matrix.
DDRotation DDrot (const DDName &, DDRotationMatrix *)
 Definition of a uniquely identifiable rotation matrix named by DDName name.
DDRotation DDrotReflect (const DDName &, double, double, double, double, double, double)
 Defines a rotation-reflection in the Geant3 way.
std::ostream & operator<< (std::ostream &, const DDRotation &)

Detailed Description

Represents a uniquely identifyable rotation matrix.

An object of this class is a reference-object and thus leightweighted. It is uniquely identified by its DDName. Further details concerning reference-objects can be found in the documentation of DDLogicalPart.

DDRotation encapsulates CLHEP CLHEP::HepRotation.

Definition at line 66 of file DDTransform.h.


Constructor & Destructor Documentation

DDRotation::DDRotation ( )

refers to the unit-rotation (no rotation at all)

Definition at line 44 of file DDRotation.cc.

References DDI::Singleton< I >::instance(), and DDBase< DDName, DDRotationMatrix * >::prep_.

                       : DDBase<DDName,DDRotationMatrix*>()
{
  //static bool onlyOnce=true;
  //if (onlyOnce) {
  //  static DDRotationMatrix* rm_ = new DDRotationMatrix;
  //  prep_ = StoreT::instance().create(DDName("",""), rm_ );
  static std::string baseName("DdBlNa");
  static int countBlank;
  static std::ostringstream ostr;
  ostr << countBlank++;
  prep_ = StoreT::instance().create(DDName(baseName+ostr.str(),baseName), new DDRotationMatrix );
  //  std::cout << "making a BLANK " << baseName+ostr.str() << " named rotation, " << prep_->second << std::endl;
  ostr.clear();
  ostr.str("");
}
DDRotation::DDRotation ( const DDName name)

Creates a initialized reference-object or a reference to an allready defined rotation.

A reference-object to a defined rotation is created if a rotation was already defined usind DDrot(). Otherwise a (default) initialized reference-object named name is created. At any later stage the rotation matrix can be defined using DDrot(). All initialized-reference object referring to the same name will then immidialtely refere to the matrix created by DDrot().

DDRotation is a lightweighted reference-object. For further details concerning reference-object refere to the documentation of DDLogicalPart.

Definition at line 61 of file DDRotation.cc.

References DDI::Singleton< I >::instance(), and DDBase< DDName, DDRotationMatrix * >::prep_.

DDRotation::DDRotation ( const DDName name,
DDRotationMatrix rot 
)
DDRotation::DDRotation ( DDRotationMatrix rot) [private]

Definition at line 76 of file DDRotation.cc.

References DDI::Singleton< I >::instance(), and DDBase< DDName, DDRotationMatrix * >::prep_.

 : DDBase<DDName,DDRotationMatrix*>()
{
  static std::string baseNoName("DdNoNa");
  static int countNN;
  static std::ostringstream ostr2;
  ostr2 << countNN++;
  prep_ = StoreT::instance().create(DDName(baseNoName+ostr2.str(), baseNoName), rot);
  //  std::cout << "making a NO-NAME " << baseNoName+ostr2.str() << " named rotation, " << prep_->second << std::endl;
  ostr2.clear();
  ostr2.str("");
}

Member Function Documentation

DDRotationMatrix* DDRotation::matrix ( void  ) [inline]
const DDRotationMatrix* DDRotation::rotation ( void  ) const [inline]
DDRotationMatrix* DDRotation::rotation ( void  ) [inline]

Definition at line 92 of file DDTransform.h.

References DDBase< DDName, DDRotationMatrix * >::rep().

{ return &(rep()); }

Friends And Related Function Documentation

DDRotation DDanonymousRot ( DDRotationMatrix rot) [friend]

Defines a anonymous rotation or rotation-reflection matrix.

It can't be addressed by a unique DDName. Once created, it's the users responsibility to keep the reference object DDRotation! Will be mostly used by algorithmic positioning.

Definition at line 198 of file DDRotation.cc.

{
  return DDRotation(rot);
}
DDRotation DDrot ( const DDName name,
DDRotationMatrix rot 
) [friend]

Definition of a uniquely identifiable rotation matrix named by DDName name.

DDrot() returns a reference-object DDRotation representing the rotation matrix rot.

The user must not free memory allocated for rot!

Definition at line 94 of file DDRotation.cc.

{
   // memory of rot goes sto DDRotationImpl!!
   //DCOUT('c', "DDrot: new rotation " << ddname);
   //if (rot) rot->invert();
   return DDRotation(ddname, rot);
}
DDRotation DDrotReflect ( const DDName name,
double  thetaX,
double  phiX,
double  thetaY,
double  phiY,
double  thetaZ,
double  phiZ 
) [friend]

Defines a rotation-reflection in the Geant3 way.

The resulting matrix MUST be a LEFThanded orthonormal system, otherwise a DDException will be thrown!

Definition at line 139 of file DDRotation.cc.

{
   
   // define 3 unit std::vectors forming the new left-handed axes 
   DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
   DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
   DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
   
   double tol = 1.0e-3; // Geant4 compatible
   double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
   if (fabs(1.+check)>tol) {
     edm::LogError("DDRotation") << ddname << " is not a LEFT-handed orthonormal matrix!" << std::endl;
     throw DDException( ddname.name() + std::string(" is not LEFT-handed!" ) );
   }
   
   DDRotationMatrix* rot = new DDRotationMatrix(x.x(),y.x(),z.x(),
                                                x.y(),y.y(),z.y(),
                                                x.z(),y.z(),z.z());

   //DCOUT('c', "DDrotReflect: new reflection " << ddname);
   //rot->invert();
   return DDRotation(ddname, rot);  
                                                                                         
}               
std::ostream& operator<< ( std::ostream &  os,
const DDRotation r 
) [friend]

Definition at line 20 of file DDRotation.cc.

{
  DDBase<DDName,DDRotationMatrix*>::def_type defined(r.isDefined());
  if (defined.first) {
    os << *(defined.first) << " ";
    if (defined.second) {
      const DDRotationMatrix & rm = *(r.rotation());
      DDAxisAngle   ra(rm);
      os << "t=" << ra.Axis().Theta()/deg << "deg "
         << "p=" << ra.Axis().Phi()/deg << "deg "
         << "a=" << ra.Angle()/deg << "deg"; 
      DCOUT_V('R', rm);
    }
    else {
      os << "* rotation not defined * ";  
    }
  }  
  else {
    os << "* rotation not declared * ";  
  }  
  return os;
}