ATLAS Offline Software
Loading...
Searching...
No Matches
CLHEPHelpers.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5//-----------------------------------------------------------------------------
6//
7// author: Lukasz Janyst <ljanyst@cern.ch>
8// file: CLHEPHelpers.h
9//
10//-----------------------------------------------------------------------------
11
12#ifndef CLHEP_HELPERS_H
13#define CLHEP_HELPERS_H
14
15#include "CLHEP/Geometry/Transform3D.h"
16#include "CLHEP/Matrix/Vector.h"
17
18#include <vector>
19
20namespace {
21
22class SetTransform3D : public HepGeom::Transform3D
23{
24public:
25 void setTransform (double XX, double XY, double XZ, double DX,
26 double YX, double YY, double YZ, double DY,
27 double ZX, double ZY, double ZZ, double DZ)
28 {
29 HepGeom::Transform3D::setTransform (XX, XY, XZ, DX,
30 YX, YY, YZ, DY,
31 ZX, ZY, ZZ, DZ);
32 }
33};
34
35}
36
38{
39 public:
40
42 template <class T>
43 static void hepTransform3DToVector( const HepGeom::Transform3D &trans,
44 T &vec )
45 {
46 vec.reserve(12);
47 vec.push_back( trans.xx() );
48 vec.push_back( trans.xy() );
49 vec.push_back( trans.xz() );
50 vec.push_back( trans.dx() );
51
52 vec.push_back( trans.yx() );
53 vec.push_back( trans.yy() );
54 vec.push_back( trans.yz() );
55 vec.push_back( trans.dy() );
56
57 vec.push_back( trans.zx() );
58 vec.push_back( trans.zy() );
59 vec.push_back( trans.zz() );
60 vec.push_back( trans.dz() );
61 }
62
64 template <class T>
65 static void vectorToHepTransform3D( const T &vec,
66 HepGeom::Transform3D &trans )
67 {
68 static_cast<SetTransform3D&> (trans).setTransform (
69 vec[0], // xx
70 vec[1], // xy
71 vec[2], // xz
72 vec[3], // dx
73 vec[4], // yx
74 vec[5], // yy
75 vec[6], // yz
76 vec[7], // dy
77 vec[8], // zx
78 vec[9], // zy
79 vec[10], // zz
80 vec[11] ); // dz
81 }
82
84 template <class T>
85 static void basicVector3DToVector( const T &bvec,
86 std :: vector<double> &vec )
87 {
88 vec.reserve(3);
89 vec.push_back( bvec.x() );
90 vec.push_back( bvec.y() );
91 vec.push_back( bvec.z() );
92 }
93
94 template <class T>
95 static void vectorToBasicVector3D( const std :: vector<double> &vec,
96 T &bvec )
97 {
98 bvec.setX( vec[0] );
99 bvec.setY( vec[1] );
100 bvec.setZ( vec[2] );
101 }
102
103 //---------------------------------------------------------------------
104 // Convert CLHEP::HepVector to std vector<double> and vice versa
105 //---------------------------------------------------------------------
106 static void hepVectorToVector( const CLHEP::HepVector &hvec,
107 std :: vector<double> &vec )
108 {
109 vec.reserve(hvec.num_row());
110 for( int i = 0; i < hvec.num_row(); i++ )
111 vec.push_back( hvec[i] );
112 }
113
114 static void vectorToHepVector( const std :: vector<double> &vec,
115 CLHEP::HepVector &hvec )
116 {
117 for( unsigned i = 0; i < vec.size(); i++ )
118 hvec[i] = vec[i];
119 }
120};
121
122#endif // CLHEP_HELPERS_H
std::vector< size_t > vec
static void vectorToHepVector(const std ::vector< double > &vec, CLHEP::HepVector &hvec)
static void hepTransform3DToVector(const HepGeom::Transform3D &trans, T &vec)
Convert HepGeom::Transform3D to std :: vector<double>
static void hepVectorToVector(const CLHEP::HepVector &hvec, std ::vector< double > &vec)
static void basicVector3DToVector(const T &bvec, std ::vector< double > &vec)
Convert HepGeom::BasicVector3D<double> to std :: vector<double> and vice versa.
static void vectorToHepTransform3D(const T &vec, HepGeom::Transform3D &trans)
Convert std :: vector<double> to HepGeom::Transform3D.
static void vectorToBasicVector3D(const std ::vector< double > &vec, T &bvec)