Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicEventHeaderv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicEventHeaderv1.cc
1 #include "EicEventHeaderv1.h"
2 
3 #include <phool/phool.h>
4 
5 #include <climits>
6 #include <cmath>
7 #include <cstdlib>
8 #include <iostream> // for operator<<, basic_ostream, basic_ostream::o...
9 #include <string> // for operator<<, string, char_traits
10 #include <utility> // for pair
11 
12 using namespace std;
13 
15 {
16  CopyFrom(eicevt);
17 }
18 
20 {
21  prop_map.clear();
22 }
23 
24 bool EicEventHeaderv1::has_property(const PROPERTY prop_id) const
25 {
26  prop_map_t::const_iterator i = prop_map.find(prop_id);
27  return i != prop_map.end();
28 }
29 
31 {
32  if (!check_property(prop_id, type_float))
33  {
34  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
35  cout << PHWHERE << " Property " << property_info.first << " with id "
36  << prop_id << " is of type " << get_property_type(property_info.second)
37  << " not " << get_property_type(type_float) << endl;
38  exit(1);
39  }
40  prop_map_t::const_iterator i = prop_map.find(prop_id);
41 
42  if (i != prop_map.end()) return u_property(i->second).fdata;
43 
44  return NAN;
45 }
46 
48 {
49  if (!check_property(prop_id, type_int))
50  {
51  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
52  cout << PHWHERE << " Property " << property_info.first << " with id "
53  << prop_id << " is of type " << get_property_type(property_info.second)
54  << " not " << get_property_type(type_int) << endl;
55  exit(1);
56  }
57  prop_map_t::const_iterator i = prop_map.find(prop_id);
58 
59  if (i != prop_map.end()) return u_property(i->second).idata;
60 
61  return INT_MIN;
62 }
63 
64 unsigned int
66 {
67  if (!check_property(prop_id, type_uint))
68  {
69  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
70  cout << PHWHERE << " Property " << property_info.first << " with id "
71  << prop_id << " is of type " << get_property_type(property_info.second)
72  << " not " << get_property_type(type_uint) << endl;
73  exit(1);
74  }
75  prop_map_t::const_iterator i = prop_map.find(prop_id);
76 
77  if (i != prop_map.end()) return u_property(i->second).uidata;
78 
79  return UINT_MAX;
80 }
81 
82 void EicEventHeaderv1::set_property(const PROPERTY prop_id, const float value)
83 {
84  if (!check_property(prop_id, type_float))
85  {
86  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
87  cout << PHWHERE << " Property " << property_info.first << " with id "
88  << prop_id << " is of type " << get_property_type(property_info.second)
89  << " not " << get_property_type(type_float) << endl;
90  exit(1);
91  }
92  prop_map[prop_id] = u_property(value).get_storage();
93 }
94 
95 void EicEventHeaderv1::set_property(const PROPERTY prop_id, const int value)
96 {
97  if (!check_property(prop_id, type_int))
98  {
99  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
100  cout << PHWHERE << " Property " << property_info.first << " with id "
101  << prop_id << " is of type " << get_property_type(property_info.second)
102  << " not " << get_property_type(type_int) << endl;
103  exit(1);
104  }
105  prop_map[prop_id] = u_property(value).get_storage();
106 }
107 
108 void EicEventHeaderv1::set_property(const PROPERTY prop_id, const unsigned int value)
109 {
110  if (!check_property(prop_id, type_uint))
111  {
112  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
113  cout << PHWHERE << " Property " << property_info.first << " with id "
114  << prop_id << " is of type " << get_property_type(property_info.second)
115  << " not " << get_property_type(type_uint) << endl;
116  exit(1);
117  }
118  prop_map[prop_id] = u_property(value).get_storage();
119 }
120 
121 unsigned int
123 {
124  prop_map_t::const_iterator iter = prop_map.find(prop_id);
125  if (iter != prop_map.end())
126  {
127  return iter->second;
128  }
129  return UINT_MAX;
130 }