File indexing completed on 2025-08-05 08:13:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef TRIGGERCLUSTERMAKERDEFS_H
0012 #define TRIGGERCLUSTERMAKERDEFS_H
0013
0014
0015 #include <limits>
0016 #include <utility>
0017
0018 #include <calobase/TowerInfoDefs.h>
0019
0020
0021 #include <calotrigger/TriggerDefs.h>
0022
0023
0024
0025
0026
0027
0028 namespace TriggerClusterMakerDefs {
0029
0030
0031
0032
0033 enum Cal {
0034 EM,
0035 IH,
0036 OH
0037 };
0038
0039
0040 enum Axis {
0041 Eta,
0042 Phi
0043 };
0044
0045
0046 enum Type {
0047 Prim,
0048 LL1
0049 };
0050
0051
0052
0053
0054
0055
0056
0057
0058 inline uint32_t NTowInRetow() {
0059 static const uint32_t nTowInRetow = 4;
0060 return nTowInRetow;
0061 }
0062
0063
0064
0065
0066 inline uint32_t NTowInLL1() {
0067 static const uint32_t nTowInLL1 = 4;
0068 return nTowInLL1;
0069 }
0070
0071
0072
0073
0074 inline uint32_t NTowInPrim() {
0075 static const uint32_t nTowInPrim = 2;
0076 return nTowInPrim;
0077 }
0078
0079
0080
0081
0082
0083
0084
0085
0086 uint32_t GetBin(const uint32_t sumkey, const uint32_t axis, const uint32_t type = Type::Prim) {
0087
0088
0089 uint32_t sumID;
0090 uint32_t primID;
0091 switch (axis) {
0092 case Axis::Eta:
0093 sumID = TriggerDefs::getSumEtaId(sumkey);
0094 primID = TriggerDefs::getPrimitiveEtaId_from_TriggerSumKey(sumkey);
0095 break;
0096 case Axis::Phi:
0097 sumID = TriggerDefs::getSumPhiId(sumkey);
0098 primID = TriggerDefs::getPrimitivePhiId_from_TriggerSumKey(sumkey);
0099 break;
0100 default:
0101 sumID = std::numeric_limits<uint32_t>::max();
0102 primID = std::numeric_limits<uint32_t>::max();
0103 break;
0104 }
0105
0106
0107 uint32_t segment;
0108 switch (type) {
0109 case Type::LL1:
0110 segment = NTowInLL1();
0111 break;
0112 case Type::Prim:
0113 [[fallthrough]];
0114 default:
0115 segment = NTowInPrim();
0116 break;
0117 }
0118 return sumID + (segment * primID);
0119
0120 }
0121
0122
0123
0124
0125
0126
0127 uint32_t GetKeyFromEtaPhiIndex(const uint32_t eta, const uint32_t phi, const uint32_t det) {
0128
0129 uint32_t key;
0130 switch (det) {
0131
0132
0133 case TriggerDefs::DetectorId::emcalDId:
0134 key = TowerInfoDefs::encode_emcal(eta, phi);
0135 break;
0136
0137
0138 case TriggerDefs::DetectorId::hcalinDId:
0139 [[fallthrough]];
0140 case TriggerDefs::DetectorId::hcaloutDId:
0141 [[fallthrough]];
0142 case TriggerDefs::DetectorId::hcalDId:
0143 key = TowerInfoDefs::encode_hcal(eta, phi);
0144 break;
0145
0146
0147 default:
0148 key = std::numeric_limits<uint32_t>::max();
0149 break;
0150 }
0151 return key;
0152
0153 }
0154
0155
0156
0157
0158
0159
0160 std::pair<uint32_t, uint32_t> GetRangeOfIndices(
0161 const uint32_t iStartTrg,
0162 const uint32_t detector,
0163 const uint32_t type = Type::Prim
0164 ) {
0165
0166 uint32_t iStart;
0167 uint32_t iStop;
0168 switch (detector) {
0169
0170
0171 case TriggerDefs::DetectorId::emcalDId:
0172 iStart = iStartTrg;
0173 iStop = iStartTrg + (2 * NTowInRetow()) - 1;
0174 break;
0175
0176
0177 case TriggerDefs::DetectorId::hcalinDId:
0178 [[fallthrough]];
0179 case TriggerDefs::DetectorId::hcaloutDId:
0180 [[fallthrough]];
0181 case TriggerDefs::DetectorId::hcalDId:
0182 iStart = iStartTrg;
0183 iStop = iStartTrg;
0184 break;
0185
0186
0187 default:
0188 iStart = iStartTrg;
0189 iStop = iStartTrg;
0190 break;
0191 }
0192 return std::make_pair(iStart, iStop);
0193
0194 }
0195
0196 }
0197
0198 #endif
0199
0200