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