File indexing completed on 2024-04-06 12:29:33
0001 #include "SimCalorimetry/HcalTrigPrimAlgos/interface/HcalFinegrainBit.h"
0002
0003 #include <cassert>
0004
0005 std::bitset<2> HcalFinegrainBit::compute(const HcalFinegrainBit::Tower& tower) const {
0006 if (version_ == 0) {
0007 std::bitset<2> result;
0008
0009
0010 result[0] = tower[is_mip][0];
0011
0012
0013
0014 result[1] = result[0] && (tower[is_above_mip].count() > 0);
0015
0016
0017
0018
0019
0020
0021
0022 return result;
0023 }
0024 if (version_ == 1) {
0025 std::bitset<2> result;
0026
0027
0028 result[0] = result[1] = tower[is_mip][0];
0029
0030 return result;
0031 }
0032 if (version_ == 2) {
0033 std::bitset<2> result;
0034
0035
0036 result[0] = result[1] = true;
0037
0038 return result;
0039 }
0040 return 0;
0041 }
0042
0043
0044 std::bitset<6> HcalFinegrainBit::compute(const HcalFinegrainBit::TowerTDC& tower, const HcalTrigTowerDetId& id) const {
0045 std::bitset<6> result;
0046
0047 int tp_ieta = id.ieta();
0048
0049 int Ndelayed = 0;
0050 int NveryDelayed = 0;
0051 int Nprompt = 0;
0052 int EarlyEnergy = 0;
0053 int DeepEnergy = 0;
0054
0055 for (size_t i = 0; i < 7; i++) {
0056 int bit12_15set = tower[i].first.first;
0057 bool is_compressed = tower[i].first.second;
0058 int bit12 = (bit12_15set & 0b0001);
0059 int bit13 = (bit12_15set & 0b0010) >> 1;
0060 int bit14 = (bit12_15set & 0b0100) >> 2;
0061 int bit15 = (bit12_15set & 0b1000) >> 3;
0062 int TDC = tower[i].second.first;
0063 int ADC = tower[i].second.second;
0064
0065
0066 if (TDC < 50) {
0067 if ((abs(tp_ieta) <= 16) || (i >= 1)) {
0068
0069
0070
0071 if (is_compressed == 1) {
0072 if (TDC == 1 && bit15 == 1)
0073 Ndelayed += 1;
0074 if (TDC == 2 && bit15 == 1)
0075 NveryDelayed += 1;
0076 if (TDC == 0 && bit14 == 1)
0077 Nprompt += 1;
0078 } else {
0079 if (TDC > tdc_boundary[abs(tp_ieta) - 1][i] && TDC <= tdc_boundary[abs(tp_ieta) - 1][i] + 2 && bit15 == 1)
0080 Ndelayed += 1;
0081 if (TDC > tdc_boundary[abs(tp_ieta) - 1][i] + 2 && bit15 == 1)
0082 NveryDelayed += 1;
0083 if (TDC <= tdc_boundary[abs(tp_ieta) - 1][i] && TDC >= 0 && bit14 == 1)
0084 Nprompt += 1;
0085 }
0086 }
0087 }
0088
0089
0090 if (ADC > 0 && bit12 == 0)
0091 EarlyEnergy +=
0092 1;
0093 if (ADC > 0 && bit13 == 1)
0094 DeepEnergy +=
0095 1;
0096 }
0097
0098
0099 if (DeepEnergy > 0 && EarlyEnergy == 0)
0100 result[0] = true;
0101 else
0102 result[0] = false;
0103 if (Nprompt > 0)
0104 result[1] = true;
0105 else
0106 result[1] = false;
0107 if (Ndelayed > 0)
0108 result[2] = true;
0109 else
0110 result[2] = false;
0111 if (NveryDelayed > 0)
0112 result[3] = true;
0113 else
0114 result[3] = false;
0115 result[4] = result[5] = false;
0116
0117 return result;
0118 }