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.
2 
4 
5 #include "CaloCollections.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 {
79  public:
80  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
81  };
82 
84  public:
85  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
86  };
87 
89  public:
90  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
91  };
92 
94  public:
95  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
96  };
97 
98  class TauUnpackerLeft : public Unpacker {
99  public:
100  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
101  };
102 
103  class IsoTauUnpackerLeft : public Unpacker {
104  public:
105  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
106  };
107 
109  public:
110  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
111  };
112 
114  public:
115  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
116  };
117 
119  public:
120  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
121  };
122 
124  public:
125  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
126  };
127 
128  class TauUnpackerRight : public Unpacker {
129  public:
130  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
131  };
132 
133  class IsoTauUnpackerRight : public Unpacker {
134  public:
135  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
136  };
137 
138  }
139 }
140 
141 // Implementation
142 
143 namespace l1t {
144  namespace stage1 {
145  bool
147  {
148  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
149  return process(block, res, [](l1t::EGamma eg) { eg.setHwIso(1); return eg; },true,true,false);
150  }
151 
152  bool
154  {
155  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
156  return process(block, res, [](const l1t::EGamma& eg) { return eg; },true,false,false);
157  }
158 
159  bool
161  {
162  auto res = static_cast<CaloCollections*>(coll)->getJets();
163  return process(block, res, [](const l1t::Jet& j) { return j; },true,true,false);
164  }
165 
166  bool
168  {
169  auto res = static_cast<CaloCollections*>(coll)->getJets();
170  return process(block, res, [](l1t::Jet j) { j.setHwQual(j.hwQual() | 2); return j; },true,false,false);
171  }
172 
173  bool
175  {
176  auto res = static_cast<CaloCollections*>(coll)->getTaus();
177  return process(block, res, [](const l1t::Tau& t) { return t; },true,true,true);
178  }
179 
180  bool
182  {
183  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
184  return process(block, res, [](const l1t::Tau& t) { return t; },true,true,true);
185  }
186 
187  bool
189  {
190  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
191  return process(block, res, [](l1t::EGamma eg) { eg.setHwIso(1); return eg; },false,true,false);
192  }
193 
194  bool
196  {
197  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
198  return process(block, res, [](const l1t::EGamma& eg) { return eg; },false,false,false);
199  }
200 
201  bool
203  {
204  auto res = static_cast<CaloCollections*>(coll)->getJets();
205  return process(block, res, [](const l1t::Jet& j) { return j; },false,true,false);
206  }
207 
208  bool
210  {
211  auto res = static_cast<CaloCollections*>(coll)->getJets();
212  return process(block, res, [](l1t::Jet j) { j.setHwQual(j.hwQual() | 2); return j; },false,false,false);
213  }
214 
215  bool
217  {
218  auto res = static_cast<CaloCollections*>(coll)->getTaus();
219  return process(block, res, [](const l1t::Tau& t) { return t; },false,true,true);
220  }
221 
222  bool
224  {
225  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
226  return process(block, res, [](const l1t::Tau& t) { return t; },false,true,true);
227  }
228  }
229 }
230 
#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)
Definition: Unpacker.cc:14
BlockHeader header() const
Definition: Block.h:56
void setHwQual(int qual)
Definition: L1Candidate.cc:64
std::vector< uint32_t > payload() const
Definition: Block.h:57
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
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.cc:89
void set(int bx, unsigned i, const T &object)
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
void setHwIso(int iso)
Definition: L1Candidate.cc:59
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
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