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 
l1t::stage1::ForwardJetUnpackerLeft
Definition: PhysCandUnpacker.h:23
mps_fire.i
i
Definition: mps_fire.py:428
l1t::stage1::TauUnpackerRight
Definition: PhysCandUnpacker.h:58
l1t::stage1::IsoEGammaUnpackerRight::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:126
l1t::stage1::IsoEGammaUnpackerLeft
Definition: PhysCandUnpacker.h:8
PhysCandUnpacker.h
l1t::stage1::IsoTauUnpackerLeft
Definition: PhysCandUnpacker.h:33
l1t::stage1::NonIsoEGammaUnpackerLeft::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:88
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
l1t::stage1::IsoEGammaUnpackerRight
Definition: PhysCandUnpacker.h:38
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
BXVector
Definition: BXVector.h:15
l1t::Tau
Definition: Tau.h:20
MakerMacros.h
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
process
bool process(const l1t::Block &block, BXVector< T > *coll, F modify, bool isleft, bool isfirst, bool istau)
Definition: PhysCandUnpacker.cc:8
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
UnpackerFactory.h
l1t::Jet
Definition: Jet.h:20
l1t::stage1::ForwardJetUnpackerRight
Definition: PhysCandUnpacker.h:53
l1t::stage1::IsoTauUnpackerRight
Definition: PhysCandUnpacker.h:63
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
l1t
delete x;
Definition: CaloConfig.h:22
cand
Definition: decayParser.h:32
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::TauUnpackerLeft
Definition: PhysCandUnpacker.h:28
BXVector::resize
void resize(int bx, unsigned size)
l1t::stage1::CentralJetUnpackerRight
Definition: PhysCandUnpacker.h:48
l1t::stage1::ForwardJetUnpackerLeft::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:100
l1t::stage1::CentralJetUnpackerLeft::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:94
l1t::stage1::CentralJetUnpackerLeft
Definition: PhysCandUnpacker.h:18
l1t::stage1::IsoTauUnpackerLeft::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:120
l1t::stage1::IsoEGammaUnpackerLeft::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:74
l1t::stage1::CentralJetUnpackerRight::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:146
l1t::stage1::NonIsoEGammaUnpackerRight
Definition: PhysCandUnpacker.h:43
l1t::stage1::IsoTauUnpackerRight::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:172
T
long double T
Definition: Basic3DVectorLD.h:48
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
BXVector::set
void set(int bx, unsigned i, const T &object)
l1t::L1Candidate::setHwIso
void setHwIso(int iso)
Definition: L1Candidate.h:32
l1t::stage1::TauUnpackerRight::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:166
l1t::stage1::TauUnpackerLeft::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:114
RPCBxOrConfig_cff.lastBX
lastBX
Definition: RPCBxOrConfig_cff.py:4
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::stage1::NonIsoEGammaUnpackerRight::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:140
l1t::getBXRange
void getBXRange(int nbx, int &first, int &last)
Definition: UnpackerFactory.cc:12
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CaloCollections.h
BXVector::setBXRange
void setBXRange(int bxFirst, int bxLast)
l1t::Block
Definition: Block.h:70
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
l1t::stage1::NonIsoEGammaUnpackerLeft
Definition: PhysCandUnpacker.h:13
l1t::stage1::ForwardJetUnpackerRight::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: PhysCandUnpacker.cc:152