test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CLHEP.h
Go to the documentation of this file.
1 #ifndef CondFormats_External_CLHEP_H
2 #define CondFormats_External_CLHEP_H
3 
4 #include <boost/serialization/base_object.hpp>
5 #include <boost/serialization/nvp.hpp>
6 #include <boost/serialization/split_free.hpp>
7 
8 // std::vector used in DataFormats/EcalDetId/interface/EcalContainer.h
9 #include <boost/serialization/vector.hpp>
10 #include <boost/serialization/string.hpp>
11 #include <boost/serialization/map.hpp>
12 
13 #include "CLHEP/Vector/EulerAngles.h"
14 #include "CLHEP/Vector/ThreeVector.h"
15 
16 namespace boost {
17 namespace serialization {
18 
19 /*
20  * Note regarding object tracking: all autos used here
21  * must resolve to untracked types, since we use local
22  * variables in the stack which could end up with the same
23  * address. For the moment, all types resolved by auto here
24  * are primitive types, which are untracked by default
25  * by Boost Serialization.
26  */
27 
28 // CLHEP/Vector/ThreeVector.h
29 template<class Archive>
30 void save(Archive & ar, const CLHEP::Hep3Vector & obj, const unsigned int)
31 {
32  auto dx = obj.x();
33  auto dy = obj.y();
34  auto dz = obj.z();
35  ar & BOOST_SERIALIZATION_NVP(dx);
36  ar & BOOST_SERIALIZATION_NVP(dy);
37  ar & BOOST_SERIALIZATION_NVP(dz);
38 }
39 
40 template<class Archive>
41 void load(Archive & ar, CLHEP::Hep3Vector & obj, const unsigned int)
42 {
43  decltype(obj.x()) dx;
44  decltype(obj.y()) dy;
45  decltype(obj.z()) dz;
46  ar & BOOST_SERIALIZATION_NVP(dx);
47  ar & BOOST_SERIALIZATION_NVP(dy);
48  ar & BOOST_SERIALIZATION_NVP(dz);
49  obj.set(dx, dy, dz);
50 }
51 
52 template<class Archive>
53 void serialize(Archive & ar, CLHEP::Hep3Vector & obj, const unsigned int v)
54 {
55  split_free(ar, obj, v);
56 }
57 
58 
59 // CLHEP/Vector/EulerAngles.h
60 template<class Archive>
61 void save(Archive & ar, const CLHEP::HepEulerAngles & obj, const unsigned int)
62 {
63  auto phi_ = obj.phi();
64  auto theta_ = obj.theta();
65  auto psi_ = obj.psi();
66  ar & BOOST_SERIALIZATION_NVP(phi_);
67  ar & BOOST_SERIALIZATION_NVP(theta_);
68  ar & BOOST_SERIALIZATION_NVP(psi_);
69 }
70 
71 template<class Archive>
72 void load(Archive & ar, CLHEP::HepEulerAngles & obj, const unsigned int)
73 {
74  decltype(obj.phi()) phi_;
75  decltype(obj.theta()) theta_;
76  decltype(obj.psi()) psi_;
77  ar & BOOST_SERIALIZATION_NVP(phi_);
78  ar & BOOST_SERIALIZATION_NVP(theta_);
79  ar & BOOST_SERIALIZATION_NVP(psi_);
80  obj.set(phi_, theta_, psi_);
81 }
82 
83 template<class Archive>
84 void serialize(Archive & ar, CLHEP::HepEulerAngles & obj, const unsigned int v)
85 {
86  split_free(ar, obj, v);
87 }
88 
89 } // namespace serialization
90 } // namespace boost
91 
92 #endif
void serialize(Archive &ar, CLHEP::Hep3Vector &obj, const unsigned int v)
Definition: CLHEP.h:53
void load(Archive &ar, CLHEP::Hep3Vector &obj, const unsigned int)
Definition: CLHEP.h:41
void save(Archive &ar, const CLHEP::Hep3Vector &obj, const unsigned int)
Definition: CLHEP.h:30