CMS 3D CMS Logo

LegacyPhysCandUnpacker.cc
Go to the documentation of this file.
2 
4 
5 #include "CaloCollections.h"
7 
8 template <typename T, typename F>
9 bool process(const l1t::Block& block, BXVector<T>* coll, F modify) {
10  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
11 
12  int nBX, firstBX, lastBX;
13  nBX = int(ceil(block.header().getSize() / 2.));
15 
16  coll->setBXRange(firstBX, lastBX);
17 
18  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
19 
20  // Initialise index
21  int unsigned i = 0;
22 
23  // Loop over multiple BX and then number of jets filling jet collection
24  for (int bx = firstBX; bx <= lastBX; bx++) {
25  uint32_t raw_data0 = block.payload()[i++];
26  uint32_t raw_data1 = block.payload()[i++];
27 
28  uint16_t candbit[4];
29  candbit[0] = raw_data0 & 0xFFFF;
30  candbit[1] = (raw_data0 >> 16) & 0xFFFF;
31  candbit[2] = raw_data1 & 0xFFFF;
32  candbit[3] = (raw_data1 >> 16) & 0xFFFF;
33 
34  for (int icand = 0; icand < 4; icand++) {
35  int candPt = candbit[icand] & 0x3F;
36  int candEta = (candbit[icand] >> 6) & 0x7;
37  int candEtasign = (candbit[icand] >> 9) & 0x1;
38  int candPhi = (candbit[icand] >> 10) & 0x1F;
39 
40  T cand;
41  cand.setHwPt(candPt);
42  cand.setHwEta((candEtasign << 3) | candEta);
43  cand.setHwPhi(candPhi);
44  //int qualflag=cand.hwQual();
45  //qualflag|= (candPt == 0x3F);
46  //cand.setHwQual(qualflag);
47 
48  /* std::cout << "cand: eta " << cand.hwEta() << " phi " << cand.hwPhi() << " pT " << cand.hwPt() << " qual " << cand.hwQual() << std::endl; */
49  //std::cout << cand.hwPt() << " @ " << cand.hwEta() << ", " << cand.hwPhi() << " > " << cand.hwQual() << " > " << cand.hwIso() << std::endl;
50  coll->push_back(bx, modify(cand));
51  }
52  }
53 
54  return true;
55 }
56 
57 namespace l1t {
58  namespace stage1 {
59  namespace legacy {
61  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
62  return process(block, res, [](l1t::EGamma eg) {
63  eg.setHwIso(1);
64  return eg;
65  });
66  }
67 
69  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
70  return process(block, res, [](const l1t::EGamma& eg) { return eg; });
71  }
72 
74  auto res = static_cast<CaloCollections*>(coll)->getJets();
75 
76  if (res->size(0) != 0)
77  edm::LogWarning("L1T") << "Need to unpack central jets before forward ones";
78 
79  return process(block, res, [](const l1t::Jet& j) { return j; });
80  }
81 
83  auto res = static_cast<CaloCollections*>(coll)->getJets();
84 
85  if (res->size(0) != 4)
86  edm::LogWarning("L1T") << "Need to unpack central jets before forward ones";
87 
88  return process(block, res, [](l1t::Jet j) {
89  j.setHwQual(j.hwQual() | 2);
90  return j;
91  });
92  }
93 
95  auto res = static_cast<CaloCollections*>(coll)->getTaus();
96  return process(block, res, [](const l1t::Tau& t) { return t; });
97  }
98 
100  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
101  return process(block, res, [](const l1t::Tau& t) { return t; });
102  }
103  } // namespace legacy
104  } // namespace stage1
105 } // namespace l1t
106 
constexpr int32_t ceil(float num)
Definition: Tau.h:20
void getBXRange(int nbx, int &first, int &last)
bool unpack(const Block &block, UnpackerCollections *coll) override
bool process(const l1t::Block &block, BXVector< T > *coll, F modify)
delete x;
Definition: CaloConfig.h:22
Definition: Electron.h:6
Definition: Jet.h:20
bool unpack(const Block &block, UnpackerCollections *coll) override
bool unpack(const Block &block, UnpackerCollections *coll) override
bool unpack(const Block &block, UnpackerCollections *coll) override
bool unpack(const Block &block, UnpackerCollections *coll) override
void setHwIso(int iso)
Definition: L1Candidate.h:32
void setBXRange(int bxFirst, int bxLast)
bool unpack(const Block &block, UnpackerCollections *coll) override
#define DEFINE_L1T_UNPACKER(type)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
long double T
void push_back(int bx, T object)
#define LogDebug(id)