Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:55

0001 #ifndef FrameChanger_H
0002 #define FrameChanger_H
0003 
0004 #include "FWCore/Utilities/interface/Visibility.h"
0005 #include "DataFormats/GeometrySurface/interface/Plane.h"
0006 #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h"
0007 
0008 class dso_internal FrameChanger {
0009 public:
0010   /** Moves the first argument ("plane") to the reference frame given by the second 
0011    *  argument ("frame"). The returned frame is not positioned globally!
0012    */
0013   template <typename T>
0014   static Plane transformPlane(const Plane& plane, const GloballyPositioned<T>& frame) {
0015     typedef GloballyPositioned<T> Frame;
0016     typename Plane::RotationType rot = plane.rotation() * frame.rotation().transposed();
0017     typename Frame::LocalPoint lpos = frame.toLocal(plane.position());
0018     typename Plane::PositionType pos(lpos.basicVector());  // cheat!
0019     return Plane(pos, rot);
0020   }
0021 
0022   /** Moves the first argument ("plane") to the reference frame given by the second 
0023  *  argument ("frame"). The returned frame is not positioned globally!
0024  */
0025   template <typename T, typename U>
0026   static GloballyPositioned<T> toFrame(const GloballyPositioned<T>& plane, const GloballyPositioned<U>& frame) {
0027     typedef GloballyPositioned<T> Plane;
0028     typedef GloballyPositioned<U> Frame;
0029 
0030     typename Plane::RotationType rot = plane.rotation() * frame.rotation().transposed();
0031     typename Frame::LocalPoint lpos = frame.toLocal(plane.position());
0032     typename Plane::PositionType pos(lpos.basicVector());  // cheat!
0033     return Plane(pos, rot);
0034   }
0035 };
0036 
0037 #endif