ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawTowerv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RawTowerv1.cc
1 #include "RawTowerv1.h"
2 
3 #include <cmath>
4 #include <iostream>
5 
6 using namespace std;
7 
9 {
10  towerid = (tower.get_id());
11  energy = (tower.get_energy());
12  time = (tower.get_time());
13 
14  CellConstRange cell_range = tower.get_g4cells();
15 
16  for (CellConstIterator cell_iter = cell_range.first;
17  cell_iter != cell_range.second; ++cell_iter)
18  {
19  add_ecell(cell_iter->first, cell_iter->second);
20  }
21 
22  ShowerConstRange shower_range = tower.get_g4showers();
23 
24  for (ShowerConstIterator shower_iter = shower_range.first;
25  shower_iter != shower_range.second; ++shower_iter)
26  {
27  add_eshower(shower_iter->first, shower_iter->second);
28  }
29 }
30 
32  : towerid(id)
33 {
34 }
35 
36 RawTowerv1::RawTowerv1(const unsigned int ieta, const unsigned int iphi)
37 {
39 }
40 
42  const unsigned int ieta, const unsigned int iphi)
43 {
44  towerid = RawTowerDefs::encode_towerid(caloid, ieta, iphi);
45 }
46 
48 {
49  energy = 0;
50  time = NAN;
51  ecells.clear();
52  eshowers.clear();
53 }
54 
56 {
57  return get_energy() != 0;
58 }
59 
60 void RawTowerv1::identify(std::ostream& os) const
61 {
62 
64  switch(caloid)
65  {
67  os << "RawTowerv1: etabin: " << get_bineta() << ", phibin: " << get_binphi() << ", l-bin: " << get_binl()
68  << " energy=" << get_energy() << std::endl;
69  return;
70  default:
71  os << "RawTowerv1: etabin: " << get_bineta() << ", phibin: " << get_binphi()
72  << " energy=" << get_energy() << std::endl;
73  return ;
74  }
75 
76 
77 }
78 
79 void RawTowerv1::add_ecell(const CellKeyType g4cellid,
80  const float ecell)
81 {
82  if (ecells.find(g4cellid) == ecells.end())
83  {
84  ecells[g4cellid] = ecell;
85  }
86  else
87  {
88  ecells[g4cellid] += ecell;
89  }
90 }
91 
92 void RawTowerv1::add_eshower(const int g4showerid, const float eshower)
93 {
94  if (eshowers.find(g4showerid) == eshowers.end())
95  {
96  eshowers[g4showerid] = eshower;
97  }
98  else
99  {
100  eshowers[g4showerid] += eshower;
101  }
102 }
103 
105 {
107  switch(caloid)
108  {
111  default:
113  }
114  return -1;
115 }
116 
118 {
120  switch(caloid)
121  {
124  default:
126  }
127  return -1;
128 }