Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawTowerv2.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RawTowerv2.cc
1 #include "RawTowerv2.h"
2 
3 #include <climits> // for UCHAR_MAX
4 #include <cmath>
5 #include <iostream>
6 #include <string> // for operator<<, string
7 #include <utility> // for pair
8 
9 using namespace std;
10 
11 RawTowerv2::RawTowerv2() = default;
12 
14  : RawTowerv1(tower)
15 {
16  // This is a generic copy of ALL properties a hit has
17  // do not add explicit copies, they will be added to
18  // the new hits with their default value increasing memory use
19  for (unsigned char ic = 0; ic < UCHAR_MAX; ic++)
20  {
21  PROPERTY prop_id = static_cast<PROPERTY>(ic);
22  if (tower.has_property(prop_id))
23  {
24  set_property(prop_id, tower.get_property(prop_id));
25  }
26  }
27 }
28 
30  : RawTowerv1(id)
31 {
32 }
33 
34 RawTowerv2::RawTowerv2(const unsigned int ieta, const unsigned int iphi)
35  : RawTowerv1(ieta, iphi)
36 {
37 }
38 
40  const unsigned int ieta, const unsigned int iphi)
41  : RawTowerv1(caloid, ieta, iphi)
42 {
43 }
44 
46 {
48  prop_map.clear();
49 }
50 
52 {
53  return RawTowerv1::isValid();
54 }
55 
56 void RawTowerv2::identify(std::ostream& os) const
57 {
58  os << "RawTowerv2: etabin: " << get_bineta() << ", phibin: " << get_binphi()
59  << " energy=" << get_energy() << std::endl;
60 
61  for (auto i : prop_map)
62  {
63  PROPERTY prop_id = static_cast<PROPERTY>(i.first);
64  const string property_info = get_property_info(prop_id);
65  cout << "\t" << prop_id << ":\t" << property_info << " = \t" << get_property(prop_id) << endl;
66  }
67 }
68 
69 bool RawTowerv2::has_property(const PROPERTY prop_id) const
70 {
71  prop_map_t::const_iterator i = prop_map.find(prop_id);
72  return i != prop_map.end();
73 }
74 
75 double
76 RawTowerv2::get_property(const PROPERTY prop_id) const
77 {
78  prop_map_t::const_iterator i = prop_map.find(prop_id);
79 
80  if (i != prop_map.end())
81  {
82  return i->second;
83  }
84 
85  return NAN;
86 }
87 
88 void RawTowerv2::set_property(const PROPERTY prop_id, const double value)
89 {
90  prop_map[prop_id] = value;
91 }