File indexing completed on 2025-08-06 08:18:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef CLUSTERSTATUSMAPPER_DEFS_H
0012 #define CLUSTERSTATUSMAPPER_DEFS_H
0013
0014
0015 #include <calobase/TowerInfo.h>
0016
0017
0018 #include <TH1.h>
0019 #include <TH2.h>
0020
0021
0022 #include <map>
0023 #include <string>
0024 #include <utility>
0025 #include <vector>
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 namespace CaloStatusMapperDefs
0037 {
0038
0039
0040 typedef std::pair<std::string, int> NodeDef;
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 enum Calo
0051 {
0052 EMCal,
0053 HCal,
0054 NONE
0055 };
0056
0057
0058
0059
0060
0061
0062
0063
0064 enum Stat
0065 {
0066 Good,
0067 Hot,
0068 BadTime,
0069 BadChi,
0070 NotInstr,
0071 NoCalib,
0072 Unknown
0073 };
0074
0075
0076
0077
0078
0079
0080 inline std::map<Stat, std::string> const& StatLabels()
0081 {
0082 static std::map<Stat, std::string> mapStatLabels = {
0083 {Stat::Good, "Good"},
0084 {Stat::Hot, "Hot"},
0085 {Stat::BadTime, "BadTime"},
0086 {Stat::BadChi, "BadChi"},
0087 {Stat::NotInstr, "NotInstr"},
0088 {Stat::NoCalib, "NoCalib"},
0089 {Stat::Unknown, "Unknown"}
0090 };
0091 return mapStatLabels;
0092 }
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 struct AxisDef
0103 {
0104
0105
0106 std::string label {""};
0107 std::size_t nBins {10};
0108 float start {0.};
0109 float stop {1.};
0110
0111 };
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 template <std::size_t H, std::size_t F, std::size_t S>
0122 struct HistDef
0123 {
0124
0125
0126 AxisDef stat {"Status", S, -0.5, S - 0.5};
0127 AxisDef eta {"i_{#eta}", H, -0.5, H - 0.5};
0128 AxisDef phi {"i_{#phi}", F, -0.5, F - 0.5};
0129
0130
0131 TH1D* MakeStatus1D(const std::string& name) const
0132 {
0133 const std::string title = ";" + stat.label;
0134 return new TH1D(name.data(), title.data(), stat.nBins, stat.start, stat.stop);
0135 }
0136
0137
0138 TH1D* MakeEta1D(const std::string& name) const
0139 {
0140 const std::string title = ";" + eta.label;
0141 return new TH1D(name.data(), title.data(), eta.nBins, eta.start, eta.stop);
0142 }
0143
0144
0145 TH1D* MakePhi1D(const std::string& name) const
0146 {
0147 const std::string title = ";" + phi.label;
0148 return new TH1D(name.data(), title.data(), phi.nBins, phi.start, phi.stop);
0149 }
0150
0151
0152 TH2D* MakePhiEta2D(const std::string& name) const
0153 {
0154 const std::string title = ";" + eta.label + ";" + phi.label;
0155 return new TH2D(name.data(), title.data(), eta.nBins, eta.start, eta.stop, phi.nBins, phi.start, phi.stop);
0156 }
0157
0158 };
0159
0160
0161
0162
0163 typedef HistDef<96, 256, 7> EMCalHistDef;
0164 typedef HistDef<24, 64, 7> HCalHistDef;
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174 Stat GetTowerStatus(TowerInfo* tower)
0175 {
0176
0177 Stat status = Stat::Unknown;
0178 if (tower->get_isHot())
0179 {
0180 status = Stat::Hot;
0181 }
0182 else if (tower->get_isBadTime())
0183 {
0184 status = Stat::BadTime;
0185 }
0186 else if (tower->get_isBadChi2())
0187 {
0188 status = Stat::BadChi;
0189 }
0190 else if (tower->get_isNotInstr())
0191 {
0192 status = Stat::NotInstr;
0193 }
0194 else if (tower->get_isNoCalib())
0195 {
0196 status = Stat::NoCalib;
0197 }
0198 else
0199 {
0200 status = Stat::Good;
0201 }
0202 return status;
0203
0204 }
0205
0206
0207
0208
0209
0210
0211 bool IsStatusSkippable(const std::string& label)
0212 {
0213
0214 bool skip = false;
0215 if ((label == "Hot") ||
0216 (label == "BadTime") ||
0217 (label == "BadChi") ||
0218 (label == "NoCalib") ||
0219 (label == "NotInstr") ||
0220 (label == "Unknown"))
0221 {
0222 skip = true;
0223 }
0224 return skip;
0225
0226 }
0227
0228 }
0229
0230 #endif
0231
0232