File indexing completed on 2025-08-06 08:18:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "PHG4CylinderCellGeom_Spacalv1.h"
0012 #include "PHG4CylinderCellDefs.h"
0013
0014 #include <cassert>
0015 #include <cstdlib>
0016 #include <iostream>
0017 #include <sstream>
0018 #include <stdexcept>
0019
0020 void PHG4CylinderCellGeom_Spacalv1::identify(std::ostream& os) const
0021 {
0022 PHG4CylinderCellGeom::identify(os);
0023
0024 std::cout << "PHG4CylinderCellGeom_Spacalv1::identify - Tower mapping:" << std::endl;
0025 for (const tower_z_ID_eta_bin_map_t::value_type& tower_z_ID_eta_bin :
0026 get_tower_z_ID_eta_bin_map())
0027 {
0028 std::cout << "\t"
0029 << "Tower Z ID[" << tower_z_ID_eta_bin.first
0030 << "] \t-> Eta Bin " << tower_z_ID_eta_bin.second << std::endl;
0031 }
0032
0033 std::cout << "PHG4CylinderCellGeom_Spacalv1::identify - Bin -> z range:" << std::endl;
0034 for (const bound_map_t::value_type& b : z_bound_map)
0035 {
0036 std::cout << "\t"
0037 << "bin[" << b.first << "] \t-> z = " << b.second.first
0038 << " - " << b.second.second << std::endl;
0039 }
0040
0041 std::cout << "PHG4CylinderCellGeom_Spacalv1::identify - Bin -> eta range:" << std::endl;
0042 for (const bound_map_t::value_type& b : eta_bound_map)
0043 {
0044 std::cout << "\t"
0045 << "bin[" << b.first << "] \t-> eta = " << b.second.first
0046 << " - " << b.second.second << std::endl;
0047 }
0048 return;
0049 }
0050
0051 void PHG4CylinderCellGeom_Spacalv1::map_consistency_check() const
0052 {
0053 if ((size_t) nzbins != z_bound_map.size())
0054 {
0055 std::cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
0056 << "z_bound_map.size() of " << z_bound_map.size()
0057 << " in inconsistent with nzbins of " << nzbins << std::endl;
0058 exit(1);
0059 }
0060 if ((size_t) nzbins != eta_bound_map.size())
0061 {
0062 std::cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
0063 << "eta_bound_map.size() of " << eta_bound_map.size()
0064 << " in inconsistent with nzbins of " << nzbins << std::endl;
0065 exit(1);
0066 }
0067 if ((size_t) nzbins < tower_z_ID_eta_bin_map.size())
0068 {
0069 std::cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
0070 << "tower_z_ID_eta_bin_map.size() of " << tower_z_ID_eta_bin_map.size()
0071 << " in inconsistent with nzbins of " << nzbins << std::endl;
0072 exit(1);
0073 }
0074 }
0075
0076 void PHG4CylinderCellGeom_Spacalv1::set_zbounds(const int ibin,
0077 const std::pair<double, double>& bounds)
0078 {
0079 assert(ibin >= 0);
0080 z_bound_map[ibin] = bounds;
0081 }
0082
0083 void PHG4CylinderCellGeom_Spacalv1::set_etabounds(const int ibin,
0084 const std::pair<double, double>& bounds)
0085 {
0086 assert(ibin >= 0);
0087 eta_bound_map[ibin] = bounds;
0088 }
0089
0090 std::pair<double, double>
0091 PHG4CylinderCellGeom_Spacalv1::get_zbounds(const int ibin) const
0092 {
0093 map_consistency_check();
0094 check_binning_method(PHG4CylinderCellDefs::spacalbinning);
0095 bound_map_t ::const_iterator iter =
0096 z_bound_map.find(ibin);
0097
0098 if (iter == z_bound_map.end())
0099 {
0100 std::cout
0101 << "PHG4CylinderCellGeom_Spacalv1::get_zbounds - Fatal Error - Asking for invalid bin in z: "
0102 << ibin << ". Print of content:" << std::endl;
0103 identify();
0104 exit(1);
0105 }
0106 return iter->second;
0107 }
0108
0109 std::pair<double, double>
0110 PHG4CylinderCellGeom_Spacalv1::get_etabounds(const int ibin) const
0111 {
0112 map_consistency_check();
0113 check_binning_method(PHG4CylinderCellDefs::spacalbinning);
0114
0115 bound_map_t ::const_iterator iter =
0116 eta_bound_map.find(ibin);
0117
0118 if (iter == eta_bound_map.end())
0119 {
0120 std::cout
0121 << "PHG4CylinderCellGeom_Spacalv1::get_etabounds - Fatal Error - Asking for invalid bin in z: "
0122 << ibin << ". Print of content:" << std::endl;
0123 identify();
0124 exit(1);
0125 }
0126 return iter->second;
0127 }
0128
0129 int PHG4CylinderCellGeom_Spacalv1::get_zbin(const double ) const
0130 {
0131 std::cout << "PHG4CylinderCellGeom_Spacalv1::get_zbin is invalid" << std::endl;
0132 exit(1);
0133 return -1;
0134 }
0135
0136 int PHG4CylinderCellGeom_Spacalv1::get_etabin(const double ) const
0137 {
0138 std::cout << "PHG4CylinderCellGeom_Spacalv1::get_etabin is invalid" << std::endl;
0139 exit(1);
0140 return -1;
0141 }
0142
0143 double
0144 PHG4CylinderCellGeom_Spacalv1::get_zcenter(const int ibin) const
0145 {
0146 std::pair<double, double> bound = get_zbounds(ibin);
0147 return 0.5 * (bound.first + bound.second);
0148 }
0149
0150 double
0151 PHG4CylinderCellGeom_Spacalv1::get_etacenter(const int ibin) const
0152 {
0153 std::pair<double, double> bound = get_etabounds(ibin);
0154 return 0.5 * (bound.first + bound.second);
0155 }
0156
0157 int PHG4CylinderCellGeom_Spacalv1::get_etabin_block(const int tower_z_ID) const
0158 {
0159 map_consistency_check();
0160
0161 tower_z_ID_eta_bin_map_t::const_iterator iter = tower_z_ID_eta_bin_map.find(tower_z_ID);
0162
0163 if (iter == tower_z_ID_eta_bin_map.end())
0164 {
0165 std::string msg;
0166
0167 msg = "PHG4CylinderCellGeom_Spacalv1::get_etabin - Fatal Error - can not find tower_z_ID of " + std::to_string(tower_z_ID) + std::string(".");
0168
0169 throw std::range_error(msg);
0170 }
0171
0172 return iter->second;
0173 }