test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
9 process(const l1t::Block& block, BXVector<T> * coll, F modify, bool isleft, bool isfirst,bool istau) {
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.));
14  l1t::getBXRange(nBX, firstBX, lastBX);
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 
26  if(!istau)coll->resize(bx,8);
27  else 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 
38  int candPt=candbit[icand] & 0x3F;
39  int candEta=(candbit[icand]>>6 ) & 0x7;
40  int candEtasign=(candbit[icand]>>9) & 0x1;
41  int candPhi=(candbit[icand]>>10) & 0x1F;
42 
43  T cand;
44  cand.setHwPt(candPt);
45  cand.setHwEta((candEtasign << 3) | candEta);
46  cand.setHwPhi(candPhi);
47  //int qualflag=cand.hwQual();
48  //qualflag|= (candPt == 0x3F);
49  //cand.setHwQual(qualflag);
50 
51  /* std::cout << "cand: eta " << cand.hwEta() << " phi " << cand.hwPhi() << " pT " << cand.hwPt() << " qual " << cand.hwQual() << std::endl; */
52  //std::cout << cand.hwPt() << " @ " << cand.hwEta() << ", " << cand.hwPhi() << " > " << cand.hwQual() << " > " << cand.hwIso() << std::endl;
53 
54  if(isfirst){
55  if(isleft){
56  coll->set(bx, 2*icand,modify(cand));
57  }
58  else if (!isleft){
59  coll->set(bx, 2*icand+1,modify(cand));
60  }
61  }
62  else if (!isfirst){
63  if(isleft){
64  coll->set(bx, 2*icand+4,modify(cand));
65  }
66  else if (!isleft){
67  coll->set(bx, 2*icand+5,modify(cand));
68  }
69  }
70  }
71  }
72 
73  return true;
74 }
75 
76 namespace l1t {
77  namespace stage1 {
78  bool
80  {
81  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
82  return process(block, res, [](l1t::EGamma eg) { eg.setHwIso(1); return eg; },true,true,false);
83  }
84 
85  bool
87  {
88  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
89  return process(block, res, [](const l1t::EGamma& eg) { return eg; },true,false,false);
90  }
91 
92  bool
94  {
95  auto res = static_cast<CaloCollections*>(coll)->getJets();
96  return process(block, res, [](const l1t::Jet& j) { return j; },true,true,false);
97  }
98 
99  bool
101  {
102  auto res = static_cast<CaloCollections*>(coll)->getJets();
103  return process(block, res, [](l1t::Jet j) { j.setHwQual(j.hwQual() | 2); return j; },true,false,false);
104  }
105 
106  bool
108  {
109  auto res = static_cast<CaloCollections*>(coll)->getTaus();
110  return process(block, res, [](const l1t::Tau& t) { return t; },true,true,true);
111  }
112 
113  bool
115  {
116  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
117  return process(block, res, [](const l1t::Tau& t) { return t; },true,true,true);
118  }
119 
120  bool
122  {
123  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
124  return process(block, res, [](l1t::EGamma eg) { eg.setHwIso(1); return eg; },false,true,false);
125  }
126 
127  bool
129  {
130  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
131  return process(block, res, [](const l1t::EGamma& eg) { return eg; },false,false,false);
132  }
133 
134  bool
136  {
137  auto res = static_cast<CaloCollections*>(coll)->getJets();
138  return process(block, res, [](const l1t::Jet& j) { return j; },false,true,false);
139  }
140 
141  bool
143  {
144  auto res = static_cast<CaloCollections*>(coll)->getJets();
145  return process(block, res, [](l1t::Jet j) { j.setHwQual(j.hwQual() | 2); return j; },false,false,false);
146  }
147 
148  bool
150  {
151  auto res = static_cast<CaloCollections*>(coll)->getTaus();
152  return process(block, res, [](const l1t::Tau& t) { return t; },false,true,true);
153  }
154 
155  bool
157  {
158  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
159  return process(block, res, [](const l1t::Tau& t) { return t; },false,true,true);
160  }
161  }
162 }
163 
#define LogDebug(id)
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
int i
Definition: DBlmapReader.cc:9
unsigned int getID() const
Definition: Block.h:22
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: Tau.h:16
void getBXRange(int nbx, int &first, int &last)
BlockHeader header() const
Definition: Block.h:56
void setHwQual(int qual)
Definition: L1Candidate.h:44
std::vector< uint32_t > payload() const
Definition: Block.h:57
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: Jet.h:16
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
int j
Definition: DBlmapReader.cc:9
int hwQual() const
Definition: L1Candidate.h:51
void set(int bx, unsigned i, const T &object)
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
void setHwIso(int iso)
Definition: L1Candidate.h:45
JetCorrectorParametersCollection coll
Definition: classes.h:10
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
void resize(int bx, unsigned size)
void setBXRange(int bxFirst, int bxLast)
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
#define DEFINE_L1T_UNPACKER(type)
unsigned int getSize() const
Definition: Block.h:23
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
tuple process
Definition: LaserDQM_cfg.py:3
long double T