ParameterSet_get_CLHEP_t.cc
Go to the documentation of this file.
3 #include "fhiclcpp/exception.h"
4 
5 #include <iostream>
6 #include <vector>
7 
8 int
9 main()
10 {
11 
13 
14  std::vector<double> const clhep_vec2 = {0.6, 123098};
15  std::vector<double> const clhep_vec3 = {0.4, -0.5, 123.0};
16  std::vector<double> const clhep_lorVec = {0.4, -0.5, 123.0, 58.};
17 
18  pset.put<std::vector<double>>("clhepTwoVector", clhep_vec2);
19  pset.put<std::vector<double>>("clhepThreeVector", clhep_vec3);
20  pset.put<std::vector<double>>("clhepLorVector", clhep_lorVec);
21 
22  auto const vec2 = pset.get<CLHEP::Hep2Vector>("clhepTwoVector");
23  auto const vec3 = pset.get<CLHEP::Hep3Vector>("clhepThreeVector");
24  auto const lorVec = pset.get<CLHEP::HepLorentzVector>("clhepLorVector");
25 
26  // Various errors
27  try {
28  pset.get<CLHEP::Hep3Vector>("clhepTwoVector");
29  }
30  catch (fhicl::exception const& e) {
31  std::cout << e.what() << std::endl;
32  }
33 
34  try {
35  pset.get<CLHEP::Hep2Vector>("clhepLorVector");
36  }
37  catch (fhicl::exception const& e) {
38  std::cout << e.what() << std::endl;
39  }
40 }
const double e
T get(std::string const &key) const
Definition: ParameterSet.h:271
int main()
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)