CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalFinegrainBit.cc
Go to the documentation of this file.
2 
3 #include <cassert>
4 
6  if (version_ == 0) {
7  std::bitset<2> result;
8 
9  // First layer consistent with a MIP
10  result[0] = tower[is_mip][0];
11 
12  // First layer consistent with a MIP, at least one layer with more
13  // than MIP energy deposition
14  result[1] = result[0] & (tower[is_above_mip].count() > 0);
15 
16  // There layers consistent with a MIP
17  // result[2] = tower[is_mip].count() >= 3;
18 
19  // Unset
20  // result[3] = false;
21 
22  return result;
23  }
24  if (version_ == 1) {
25  std::bitset<2> result;
26 
27  // All algorithms the same for testing purposes
28  result[0] = result[1] = tower[is_mip][0];
29 
30  return result;
31  }
32  if (version_ == 2) {
33  std::bitset<2> result;
34 
35  // All algorithms the same for testing purposes
36  result[0] = result[1] = true;
37 
38  return result;
39  }
40  return 0;
41 }
42 
43 // timing/depth LLP bit setting
45  std::bitset<6> result;
46 
47  int tp_ieta = id.ieta();
48 
49  int Ndelayed = 0;
50  int NveryDelayed = 0;
51  int Nprompt = 0;
52  int EarlyEnergy = 0;
53  int DeepEnergy = 0;
54 
55  for (size_t i = 0; i < 7; i++) {
56  int bit12_15set = tower[i].first;
57  int bit12 = (bit12_15set & 0b0001); // low depth 1,2 energy
58  int bit13 = (bit12_15set & 0b0010) >> 1; // high depth 3+ energy
59  int bit14 = (bit12_15set & 0b0100) >> 2; // prompt energy passed
60  int bit15 = (bit12_15set & 0b1000) >> 3; // delayed energy passed
61  int TDC = tower[i].second.first;
62  int ADC = tower[i].second.second;
63 
64  // timing bits
65  if (TDC < 50) { // exclude error code for TDC in HE (unpacked)
66  if (abs(tp_ieta) <=
67  16) { // in HB, TDC values are compressed. 01 = first delayed range, 10 = second delayed range
68  if (TDC == 1 && bit15 == 1)
69  Ndelayed += 1;
70  if (TDC == 2 && bit15 == 1)
71  NveryDelayed += 1;
72  if (TDC == 0 && bit14 == 1)
73  Nprompt += 1;
74  }
75  if (abs(tp_ieta) > 16 &&
76  i >= 1) { // in HE, TDC values are uncompressed (0-49). Exclude depth 1 in HE due to backgrounds
77  if (TDC > tdc_HE[abs(tp_ieta) - 1][i] && TDC <= tdc_HE[abs(tp_ieta) - 1][i] + 2 && bit15 == 1)
78  Ndelayed += 1;
79  if (TDC > tdc_HE[abs(tp_ieta) - 1][i] + 2 && bit15 == 1)
80  NveryDelayed += 1;
81  if (TDC <= tdc_HE[abs(tp_ieta) - 1][i] && TDC >= 0 && bit14 == 1)
82  Nprompt += 1;
83  }
84  }
85 
86  // depth bit
87  if (ADC > 0 && bit12 == 0)
88  EarlyEnergy +=
89  1; // early layers, depth 1 and 2. If bit12 = 0, too much energy in early layers. Require ADC > 0 to ensure valid hit in cell
90  if (ADC > 0 && bit13 == 1)
91  DeepEnergy +=
92  1; // deep layers, 3+. If bit13 = 1, energy in deep layers. Require ADC > 0 to ensure valid hit in cell
93  }
94 
95  // very delayed (100000), slightly delayed (010000), prompt (001000), 2 reserved bits (000110), depth flag (000001)
96  if (DeepEnergy > 0 && EarlyEnergy == 0)
97  result[0] = true; // 000001
98  else
99  result[0] = false;
100  if (Nprompt > 0)
101  result[1] = true; // 000010
102  else
103  result[1] = false;
104  if (Ndelayed > 0)
105  result[2] = true; // 000100
106  else
107  result[2] = false;
108  if (NveryDelayed > 0)
109  result[3] = true; // 001000
110  else
111  result[3] = false;
112  result[4] = result[5] = false; // 110000 in HcalTriggerPrimitiveAlgo.cc, set to MIP bits from above
113 
114  return result;
115 }
std::array< std::bitset< 6 >, 2 > Tower
const int is_above_mip
tuple result
Definition: mps_fire.py:311
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int tdc_HE[29][7]
std::bitset< 2 > compute(const Tower &) const
std::array< std::pair< int, std::pair< int, int > >, 7 > TowerTDC