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
10 process(const l1t::Block& block, BXVector<T> * coll, F modify) {
11  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
12 
13  int nBX, firstBX, lastBX;
14  nBX = int(ceil(block.header().getSize() / 2.));
15  l1t::getBXRange(nBX, firstBX, lastBX);
16 
17  coll->setBXRange(firstBX, lastBX);
18 
19  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
20 
21  // Initialise index
22  int unsigned i = 0;
23 
24  // Loop over multiple BX and then number of jets filling jet collection
25  for (int bx=firstBX; bx<=lastBX; bx++){
26  uint32_t raw_data0 = block.payload()[i++];
27  uint32_t raw_data1 = block.payload()[i++];
28 
29  uint16_t candbit[4];
30  candbit[0] = raw_data0 & 0xFFFF;
31  candbit[1] = (raw_data0 >> 16) & 0xFFFF;
32  candbit[2] = raw_data1 & 0xFFFF;
33  candbit[3] = (raw_data1 >> 16) & 0xFFFF;
34 
35  for (int icand=0;icand<4;icand++){
36 
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  coll->push_back(bx, modify(cand));
53  }
54  }
55 
56  return true;
57 }
58 
59 namespace l1t {
60  namespace stage1 {
61  namespace legacy {
62  bool
64  {
65  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
66  return process(block, res, [](l1t::EGamma eg) { eg.setHwIso(1); return eg; });
67  }
68 
69  bool
71  {
72  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
73  return process(block, res, [](const l1t::EGamma& eg) { return eg; });
74  }
75 
76  bool
78  {
79  auto res = static_cast<CaloCollections*>(coll)->getJets();
80 
81  if (res->size(0) != 0)
82  edm::LogWarning("L1T") << "Need to unpack central jets before forward ones";
83 
84  return process(block, res, [](const l1t::Jet& j) { return j; });
85  }
86 
87  bool
89  {
90  auto res = static_cast<CaloCollections*>(coll)->getJets();
91 
92  if (res->size(0) != 4)
93  edm::LogWarning("L1T") << "Need to unpack central jets before forward ones";
94 
95  return process(block, res, [](l1t::Jet j) { j.setHwQual(j.hwQual() | 2); return j; });
96  }
97 
98  bool
100  {
101  auto res = static_cast<CaloCollections*>(coll)->getTaus();
102  return process(block, res, [](const l1t::Tau& t) { return t; });
103  }
104 
105  bool
107  {
108  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
109  return process(block, res, [](const l1t::Tau& t) { return t; });
110  }
111  }
112  }
113 }
114 
#define LogDebug(id)
unsigned int getID() const
Definition: Block.h:21
Definition: Tau.h:16
void getBXRange(int nbx, int &first, int &last)
BlockHeader header() const
Definition: Block.h:59
void setHwQual(int qual)
Definition: L1Candidate.h:44
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
std::vector< uint32_t > payload() const
Definition: Block.h:60
Definition: Electron.h:4
Definition: Jet.h:16
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
int hwQual() const
Definition: L1Candidate.h:51
void setHwIso(int iso)
Definition: L1Candidate.h:45
JetCorrectorParametersCollection coll
Definition: classes.h:10
void setBXRange(int bxFirst, int bxLast)
bool unpack(const Block &block, UnpackerCollections *coll) override
#define DEFINE_L1T_UNPACKER(type)
unsigned int getSize() const
Definition: Block.h:22
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
long double T
void push_back(int bx, T object)