CMS 3D CMS Logo

PhysCandUnpacker.cc
Go to the documentation of this file.
3 
4 #include "CaloCollections.h"
5 #include "PhysCandUnpacker.h"
6 
7 template <typename T, typename F>
8 bool process(const l1t::Block& block, BXVector<T>* coll, F modify, bool isleft, bool isfirst, bool istau) {
9  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
10 
11  int nBX, firstBX, lastBX;
12  nBX = int(ceil(block.header().getSize() / 2.));
14 
15  coll->setBXRange(firstBX, lastBX);
16 
17  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
18 
19  // Initialise index
20  int unsigned i = 0;
21 
22  // Loop over multiple BX and then number of jets filling jet collection
23  for (int bx = firstBX; bx <= lastBX; bx++) {
24  if (!istau)
25  coll->resize(bx, 8);
26  else
27  coll->resize(bx, 4);
28 
29  uint32_t raw_data0 = block.payload()[i++];
30  uint32_t raw_data1 = block.payload()[i++];
31 
32  uint16_t candbit[2];
33  candbit[0] = raw_data0 & 0xFFFF;
34  candbit[1] = raw_data1 & 0xFFFF;
35 
36  for (int icand = 0; icand < 2; icand++) {
37  int candPt = candbit[icand] & 0x3F;
38  int candEta = (candbit[icand] >> 6) & 0x7;
39  int candEtasign = (candbit[icand] >> 9) & 0x1;
40  int candPhi = (candbit[icand] >> 10) & 0x1F;
41 
42  T cand;
43  cand.setHwPt(candPt);
44  cand.setHwEta((candEtasign << 3) | candEta);
45  cand.setHwPhi(candPhi);
46  //int qualflag=cand.hwQual();
47  //qualflag|= (candPt == 0x3F);
48  //cand.setHwQual(qualflag);
49 
50  /* std::cout << "cand: eta " << cand.hwEta() << " phi " << cand.hwPhi() << " pT " << cand.hwPt() << " qual " << cand.hwQual() << std::endl; */
51  //std::cout << cand.hwPt() << " @ " << cand.hwEta() << ", " << cand.hwPhi() << " > " << cand.hwQual() << " > " << cand.hwIso() << std::endl;
52 
53  if (isfirst) {
54  if (isleft) {
55  coll->set(bx, 2 * icand, modify(cand));
56  } else if (!isleft) {
57  coll->set(bx, 2 * icand + 1, modify(cand));
58  }
59  } else if (!isfirst) {
60  if (isleft) {
61  coll->set(bx, 2 * icand + 4, modify(cand));
62  } else if (!isleft) {
63  coll->set(bx, 2 * icand + 5, modify(cand));
64  }
65  }
66  }
67  }
68 
69  return true;
70 }
71 
72 namespace l1t {
73  namespace stage1 {
75  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
76  return process(
77  block,
78  res,
79  [](l1t::EGamma eg) {
80  eg.setHwIso(1);
81  return eg;
82  },
83  true,
84  true,
85  false);
86  }
87 
89  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
90  return process(
91  block, res, [](const l1t::EGamma& eg) { return eg; }, true, false, false);
92  }
93 
95  auto res = static_cast<CaloCollections*>(coll)->getJets();
96  return process(
97  block, res, [](const l1t::Jet& j) { return j; }, true, true, false);
98  }
99 
101  auto res = static_cast<CaloCollections*>(coll)->getJets();
102  return process(
103  block,
104  res,
105  [](l1t::Jet j) {
106  j.setHwQual(j.hwQual() | 2);
107  return j;
108  },
109  true,
110  false,
111  false);
112  }
113 
115  auto res = static_cast<CaloCollections*>(coll)->getTaus();
116  return process(
117  block, res, [](const l1t::Tau& t) { return t; }, true, true, true);
118  }
119 
121  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
122  return process(
123  block, res, [](const l1t::Tau& t) { return t; }, true, true, true);
124  }
125 
127  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
128  return process(
129  block,
130  res,
131  [](l1t::EGamma eg) {
132  eg.setHwIso(1);
133  return eg;
134  },
135  false,
136  true,
137  false);
138  }
139 
141  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
142  return process(
143  block, res, [](const l1t::EGamma& eg) { return eg; }, false, false, false);
144  }
145 
147  auto res = static_cast<CaloCollections*>(coll)->getJets();
148  return process(
149  block, res, [](const l1t::Jet& j) { return j; }, false, true, false);
150  }
151 
153  auto res = static_cast<CaloCollections*>(coll)->getJets();
154  return process(
155  block,
156  res,
157  [](l1t::Jet j) {
158  j.setHwQual(j.hwQual() | 2);
159  return j;
160  },
161  false,
162  false,
163  false);
164  }
165 
167  auto res = static_cast<CaloCollections*>(coll)->getTaus();
168  return process(
169  block, res, [](const l1t::Tau& t) { return t; }, false, true, true);
170  }
171 
173  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
174  return process(
175  block, res, [](const l1t::Tau& t) { return t; }, false, true, true);
176  }
177  } // namespace stage1
178 } // namespace l1t
179 
constexpr int32_t ceil(float num)
bool unpack(const Block &block, UnpackerCollections *coll) override
bool unpack(const Block &block, UnpackerCollections *coll) override
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: Tau.h:20
void getBXRange(int nbx, int &first, int &last)
delete x;
Definition: CaloConfig.h:22
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: Electron.h:6
bool unpack(const Block &block, UnpackerCollections *coll) override
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: Jet.h:20
bool unpack(const Block &block, UnpackerCollections *coll) override
void set(int bx, unsigned i, const T &object)
bool unpack(const Block &block, UnpackerCollections *coll) override
void setHwIso(int iso)
Definition: L1Candidate.h:32
bool unpack(const Block &block, UnpackerCollections *coll) override
void resize(int bx, unsigned size)
bool process(const l1t::Block &block, BXVector< T > *coll, F modify, bool isleft, bool isfirst, bool istau)
void setBXRange(int bxFirst, int bxLast)
bool unpack(const Block &block, UnpackerCollections *coll) override
bool unpack(const Block &block, UnpackerCollections *coll) override
#define DEFINE_L1T_UNPACKER(type)
bool unpack(const Block &block, UnpackerCollections *coll) override
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
long double T
#define LogDebug(id)