Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:32

0001 //#include "Utilities/Configuration/interface/Architecture.h"
0002 
0003 #include "DataFormats/GeometrySurface/interface/Surface.h"
0004 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
0005 
0006 #include <iostream>
0007 
0008 using namespace std;
0009 
0010 void st() {}
0011 void en() {}
0012 
0013 template <typename Scalar>
0014 void go() {
0015   typedef GloballyPositioned<float> Frame;
0016   Surface::RotationType rot;
0017   Surface::PositionType pos(.1, .2, .3);
0018 
0019   std::cout << "size of Frame " << sizeof(Frame) << std::endl;
0020   std::cout << "size of Surface " << sizeof(Surface) << std::endl;
0021   std::cout << "size of Plane " << sizeof(Plane) << std::endl;
0022   std::cout << "size of BoundPlane " << sizeof(BoundPlane) << std::endl;
0023 
0024   for (int i = 0; i != 10; ++i) {
0025     cout << "pos " << pos << std::endl;
0026     BoundPlane plane(pos, rot);
0027     cout << "prec " << plane.posPrec() << std::endl;
0028     Vector3DBase<float, GlobalTag> d(1., 1., 1.);
0029     for (int j = 0; j != 10; ++j) {
0030       std::cout << plane.localZclamped(pos + d) << " ";
0031       d *= 0.1f;
0032     }
0033     std::cout << std::endl;
0034 
0035     LocalPoint lp(0, 0, 0);
0036     cout << plane.toGlobal(lp) << ", delta = " << plane.toGlobal(lp) - pos << endl;
0037 
0038     Scalar eps = 1.e-10;
0039     Point3DBase<float, LocalTag> f2(eps, eps, eps);
0040     cout << plane.toGlobal(f2) << ", delta = " << plane.toGlobal(f2) - pos << endl;
0041 
0042     Point3DBase<Scalar, GlobalTag> nom(1, 2, 3);
0043     Point3DBase<Scalar, LocalTag> dlp(0, 0, 0);
0044     cout << plane.toGlobal(dlp) << ", delta = " << plane.toGlobal(dlp) - nom << endl;
0045 
0046     Point3DBase<Scalar, LocalTag> d2(eps, eps, eps);
0047     cout << plane.toGlobal(d2) << ", delta = " << plane.toGlobal(d2) - nom << endl;
0048 
0049     Point3DBase<Scalar, GlobalTag> dgp(0.1, 0.2, 0.3);
0050     Vector3DBase<Scalar, GlobalTag> dgv(0.1, 0.2, 0.3);
0051     Vector3DBase<Scalar, LocalTag> dlv(0.1, 0.2, 0.3);
0052 
0053     st();
0054     Point3DBase<Scalar, LocalTag> p1 = plane.toLocal(dgp);
0055     Vector3DBase<Scalar, LocalTag> v1 = plane.toLocal(dgv);
0056     Vector3DBase<Scalar, GlobalTag> g1 = plane.toGlobal(dlv);
0057     en();
0058     cout << p1 << endl;
0059     cout << v1 << endl;
0060     cout << g1 << endl;
0061 
0062     Scalar a[3];
0063     Scalar v[3] = {dgv.x(), dgv.y(), dgv.z()};
0064     Scalar r[9] = {rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()};
0065 
0066     st();
0067     for (int i = 0; i < 3; i++) {
0068       int j = 3 * i;
0069       a[i] = r[j] * v[0] + r[j + 1] * v[1] + r[j + 2] * v[2];
0070     }
0071     en();
0072 
0073     Vector3DBase<Scalar, LocalTag> v2(a[0], a[1], a[2]);
0074     cout << v2 << endl;
0075     cout << endl;
0076 
0077     pos = Surface::PositionType(4 * pos.x(), 4 * pos.y(), 4 * pos.z());
0078   }
0079   cout << endl;
0080   cout << endl;
0081 }
0082 
0083 int main() {
0084   go<float>();
0085   go<double>();
0086   return 0;
0087 }