Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PidCandidatev1.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PidCandidatev1.C
1 #include "PidCandidatev1.h"
2 
3 #include <phool/phool.h>
4 
5 #include <cstdlib>
6 
7 using namespace std;
8 
10 
12 _candidateid(INT_MAX)
13 {
14 }
15 
17 {
18  Copy(tc);
19 }
20 
21 void
23 {
24  prop_map.clear();
25 }
26 
27 void
29  std::cout << "New PidCandidate 0x" << hex << _candidateid << std::endl;
30 
31  for (prop_map_t::const_iterator i = prop_map.begin(); i!= prop_map.end(); ++i)
32  {
33  PROPERTY prop_id = static_cast<PROPERTY>(i->first);
34  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
35  cout << "\t" << prop_id << ":\t" << property_info.first << " = \t";
36  switch(property_info.second)
37  {
38  case type_int:
39  cout << get_property_int(prop_id);
40  break;
41  case type_uint:
42  cout << get_property_uint(prop_id);
43  break;
44  case type_float:
45  cout << get_property_float(prop_id);
46  break;
47  default:
48  cout << " unknown type ";
49  }
50  cout <<endl;
51  }
52 }
53 
54 bool
56 {
57  prop_map_t::const_iterator i = prop_map.find(prop_id);
58  return i!=prop_map.end();
59 }
60 
61 float
63 {
64  if (!check_property(prop_id,type_float))
65  {
66  pair<const string,PROPERTY_TYPE> property_info =get_property_info(prop_id);
67  cout << PHWHERE << " Property " << property_info.first << " with id "
68  << prop_id << " is of type " << get_property_type(property_info.second)
69  << " not " << get_property_type(type_float) << endl;
70  exit(1);
71  }
72  prop_map_t::const_iterator i = prop_map.find(prop_id);
73 
74  if (i!=prop_map.end()) return u_property(i->second).fdata;
75 
76  return NAN ;
77 }
78 
79 int
81 {
82  if (!check_property(prop_id,type_int))
83  {
84  pair<const string,PROPERTY_TYPE> property_info =get_property_info(prop_id);
85  cout << PHWHERE << " Property " << property_info.first << " with id "
86  << prop_id << " is of type " << get_property_type(property_info.second)
87  << " not " << get_property_type(type_int) << endl;
88  exit(1);
89  }
90  prop_map_t::const_iterator i = prop_map.find(prop_id);
91 
92  if (i!=prop_map.end()) return u_property(i->second).idata;
93 
94  return INT_MIN;
95 }
96 
97 unsigned int
99 {
100  if (!check_property(prop_id,type_uint))
101  {
102  pair<const string,PROPERTY_TYPE> property_info =get_property_info(prop_id);
103  cout << PHWHERE << " Property " << property_info.first << " with id "
104  << prop_id << " is of type " << get_property_type(property_info.second)
105  << " not " << get_property_type(type_uint) << endl;
106  exit(1);
107  }
108  prop_map_t::const_iterator i = prop_map.find(prop_id);
109 
110  if (i!=prop_map.end()) return u_property(i->second).uidata;
111 
112  return UINT_MAX ;
113 }
114 
115 void
116 PidCandidatev1::set_property(const PROPERTY prop_id, const float value)
117 {
118  if (!check_property(prop_id,type_float))
119  {
120  pair<const string,PROPERTY_TYPE> property_info = get_property_info(prop_id);
121  cout << PHWHERE << " Property " << property_info.first << " with id "
122  << prop_id << " is of type " << get_property_type(property_info.second)
123  << " not " << get_property_type(type_float) << endl;
124  exit(1);
125  }
126  prop_map[prop_id] = u_property(value).get_storage();
127 }
128 
129 void
130 PidCandidatev1::set_property(const PROPERTY prop_id, const int value)
131 {
132  if (!check_property(prop_id,type_int))
133  {
134  pair<const string,PROPERTY_TYPE> property_info = get_property_info(prop_id);
135  cout << PHWHERE << " Property " << property_info.first << " with id "
136  << prop_id << " is of type " << get_property_type(property_info.second)
137  << " not " << get_property_type(type_int) << endl;
138  exit(1);
139  }
140  prop_map[prop_id] = u_property(value).get_storage();
141 }
142 
143 void
144 PidCandidatev1::set_property(const PROPERTY prop_id, const unsigned int value)
145 {
146  if (!check_property(prop_id,type_uint))
147  {
148  pair<const string,PROPERTY_TYPE> property_info = get_property_info(prop_id);
149  cout << PHWHERE << " Property " << property_info.first << " with id "
150  << prop_id << " is of type " << get_property_type(property_info.second)
151  << " not " << get_property_type(type_uint) << endl;
152  exit(1);
153  }
154  prop_map[prop_id] = u_property(value).get_storage();
155 }
156 
157 unsigned int
159 {
160  prop_map_t::const_iterator iter = prop_map.find(prop_id);
161  if (iter != prop_map.end())
162  {
163  return iter->second;
164  }
165  return UINT_MAX;
166 }
167 
168 void
170 {
171  cout << "PidCandidatev1 with candidate_id: 0x" << hex << _candidateid << dec << endl;
172  cout << "Class " << this->ClassName() << endl;
173 
174  for (prop_map_t::const_iterator i = prop_map.begin(); i!= prop_map.end(); ++i)
175  {
176  PROPERTY prop_id = static_cast<PROPERTY>(i->first);
177  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
178  cout << "\t" << prop_id << ":\t" << property_info.first << " = \t";
179  switch(property_info.second)
180  {
181  case type_int:
182  cout << get_property_int(prop_id);
183  break;
184  case type_uint:
185  cout << get_property_uint(prop_id);
186  break;
187  case type_float:
188  cout << get_property_float(prop_id);
189  break;
190  default:
191  cout << " unknown type ";
192  }
193  cout <<endl;
194  }
195 }