File indexing completed on 2025-08-06 08:13:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #define SCORRELATORUTILITIES_TWRTOOLS_CC
0012
0013
0014 #include "TwrTools.h"
0015
0016
0017 using namespace std;
0018
0019
0020
0021
0022
0023 namespace SColdQcdCorrelatorAnalysis {
0024
0025
0026
0027
0028
0029
0030 int Tools::GetTowerStatus(const TowerInfo* tower) {
0031
0032 int status = Const::TowerStatus::Unknown;
0033 if (tower -> get_isHot()) {
0034 status = Const::TowerStatus::Hot;
0035 } else if (tower -> get_isBadTime()) {
0036 status = Const::TowerStatus::BadTime;
0037 } else if (tower -> get_isBadChi2()) {
0038 status = Const::TowerStatus::BadChi;
0039 } else if (tower -> get_isNotInstr()) {
0040 status = Const::TowerStatus::NotInstr;
0041 } else if (tower -> get_isNoCalib()) {
0042 status = Const::TowerStatus::NoCalib;
0043 } else {
0044 status = Const::TowerStatus::Good;
0045 }
0046 return status;
0047
0048 }
0049
0050
0051
0052
0053
0054
0055 int Tools::GetCaloIDFromRawTower(RawTower* tower) {
0056
0057 auto rawKey = tower -> get_id();
0058 return RawTowerDefs::decode_caloid(rawKey);
0059
0060 }
0061
0062
0063
0064
0065
0066
0067 int Tools::GetRawTowerKey(const int idGeo, const tuple<int, int, int> indices) {
0068
0069 const int key = (int) RawTowerDefs::encode_towerid(
0070 (RawTowerDefs::CalorimeterId) idGeo,
0071 get<1>(indices),
0072 get<2>(indices)
0073 );
0074 return key;
0075
0076 }
0077
0078
0079
0080
0081
0082
0083 tuple<int, int, int> Tools::GetTowerIndices(
0084 const int channel,
0085 const int subsys,
0086 PHCompositeNode* topNode
0087 ) {
0088
0089
0090 TowerInfoContainer* towers = Interfaces::GetTowerInfoStore(
0091 topNode,
0092 Const::MapIndexOntoTowerInfo()[ subsys ]
0093 );
0094 const uint32_t key = towers -> encode_key(channel);
0095
0096
0097 const int iEta = towers -> getTowerEtaBin(key);
0098 const int iPhi = towers -> getTowerPhiBin(key);
0099 return make_tuple((int) key, iEta, iPhi);
0100
0101 }
0102
0103
0104
0105
0106
0107
0108 ROOT::Math::XYZVector Tools::GetTowerPositionXYZ(const int rawKey, const int subsys, PHCompositeNode* topNode) {
0109
0110
0111 RawTowerGeom* geometry = Interfaces::GetTowerGeometry(topNode, subsys, rawKey);
0112
0113
0114 ROOT::Math::XYZVector position(
0115 geometry -> get_center_x(),
0116 geometry -> get_center_y(),
0117 geometry -> get_center_z()
0118 );
0119 return position;
0120
0121 }
0122
0123
0124
0125
0126
0127
0128 ROOT::Math::RhoEtaPhiVector Tools::GetTowerPositionRhoEtaPhi(
0129 const int rawKey,
0130 const int subsys,
0131 const float zVtx,
0132 PHCompositeNode* topNode
0133 ) {
0134
0135
0136 RawTowerGeom* geometry = Interfaces::GetTowerGeometry(topNode, subsys, rawKey);
0137
0138
0139 const float zShift = (geometry -> get_center_z()) - zVtx;
0140 const float radius = geometry -> get_center_radius();
0141 const float eta = asinh(zShift / radius);
0142 const float phi = atan2(geometry -> get_center_y(), geometry -> get_center_x());
0143
0144
0145 ROOT::Math::RhoEtaPhiVector position(
0146 radius,
0147 eta,
0148 phi
0149 );
0150 return position;
0151
0152 }
0153
0154
0155
0156
0157
0158
0159 ROOT::Math::PxPyPzEVector Tools::GetTowerMomentum(const double energy, const ROOT::Math::RhoEtaPhiVector pos) {
0160
0161
0162 const double hTwr = pos.Eta();
0163 const double fTwr = pos.Phi();
0164 const double ptTwr = energy / cosh(hTwr);
0165
0166
0167 ROOT::Math::PxPyPzEVector mom(
0168 ptTwr * cos(fTwr),
0169 ptTwr * sin(fTwr),
0170 ptTwr * sinh(hTwr),
0171 energy
0172 );
0173 return mom;
0174
0175 }
0176
0177 }
0178
0179