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 
l1t::stage1::legacy::TauUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: LegacyPhysCandUnpacker.cc:94
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::stage1::legacy::IsoEGammaUnpacker
Definition: LegacyPhysCandUnpacker.h:9
l1t::stage1::legacy::NonIsoEGammaUnpacker
Definition: LegacyPhysCandUnpacker.h:14
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
l1t::stage1::legacy::TauUnpacker
Definition: LegacyPhysCandUnpacker.h:29
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
BXVector
Definition: BXVector.h:15
l1t::Tau
Definition: Tau.h:20
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
l1t::stage1::legacy::CentralJetUnpacker
Definition: LegacyPhysCandUnpacker.h:19
l1t::stage1::legacy::CentralJetUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: LegacyPhysCandUnpacker.cc:73
UnpackerFactory.h
OrderedSet.t
t
Definition: OrderedSet.py:90
l1t::Jet
Definition: Jet.h:20
LegacyPhysCandUnpacker.h
edm::LogWarning
Definition: MessageLogger.h:141
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
l1t
delete x;
Definition: CaloConfig.h:22
l1t::stage1::legacy::ForwardJetUnpacker
Definition: LegacyPhysCandUnpacker.h:24
cand
Definition: decayParser.h:34
createfilelist.int
int
Definition: createfilelist.py:10
l1t::EGamma
Definition: EGamma.h:20
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
res
Definition: Electron.h:6
l1t::stage1::legacy::IsoTauUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: LegacyPhysCandUnpacker.cc:99
T
long double T
Definition: Basic3DVectorLD.h:48
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
l1t::L1Candidate::setHwIso
void setHwIso(int iso)
Definition: L1Candidate.h:32
l1t::stage1::legacy::IsoTauUnpacker
Definition: LegacyPhysCandUnpacker.h:34
RPCBxOrConfig_cff.lastBX
lastBX
Definition: RPCBxOrConfig_cff.py:4
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::getBXRange
void getBXRange(int nbx, int &first, int &last)
Definition: UnpackerFactory.cc:12
l1t::stage1::legacy::ForwardJetUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: LegacyPhysCandUnpacker.cc:82
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CaloCollections.h
BXVector::setBXRange
void setBXRange(int bxFirst, int bxLast)
l1t::Block
Definition: Block.h:54
process
bool process(const l1t::Block &block, BXVector< T > *coll, F modify)
Definition: LegacyPhysCandUnpacker.cc:9
BXVector::push_back
void push_back(int bx, T object)
l1t::stage1::legacy::IsoEGammaUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: LegacyPhysCandUnpacker.cc:60
l1t::stage1::legacy::NonIsoEGammaUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: LegacyPhysCandUnpacker.cc:68