CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LegacyPhysCandUnpacker.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) {
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  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 
36  int candPt=candbit[icand] & 0x3F;
37  int candEta=(candbit[icand]>>6 ) & 0x7;
38  int candEtasign=(candbit[icand]>>9) & 0x1;
39  int candPhi=(candbit[icand]>>10) & 0x1F;
40 
41  T cand;
42  cand.setHwPt(candPt);
43  cand.setHwEta((candEtasign << 3) | candEta);
44  cand.setHwPhi(candPhi);
45  //int qualflag=cand.hwQual();
46  //qualflag|= (candPt == 0x3F);
47  //cand.setHwQual(qualflag);
48 
49  /* std::cout << "cand: eta " << cand.hwEta() << " phi " << cand.hwPhi() << " pT " << cand.hwPt() << " qual " << cand.hwQual() << std::endl; */
50  //std::cout << cand.hwPt() << " @ " << cand.hwEta() << ", " << cand.hwPhi() << " > " << cand.hwQual() << " > " << cand.hwIso() << std::endl;
51  coll->push_back(bx, modify(cand));
52  }
53  }
54 
55  return true;
56 }
57 
58 namespace l1t {
59  namespace stage1 {
60  namespace legacy {
61  class IsoEGammaUnpacker : public Unpacker {
62  public:
63  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
64  };
65 
66  class NonIsoEGammaUnpacker : public Unpacker {
67  public:
68  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
69  };
70 
71  class CentralJetUnpacker : public Unpacker {
72  public:
73  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
74  };
75 
76  class ForwardJetUnpacker : public Unpacker {
77  public:
78  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
79  };
80 
81  class TauUnpacker : public Unpacker {
82  public:
83  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
84  };
85 
86  class IsoTauUnpacker : public Unpacker {
87  public:
88  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
89  };
90  }
91  }
92 }
93 
94 // Implementation
95 
96 namespace l1t {
97  namespace stage1 {
98  namespace legacy {
99  bool
101  {
102  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
103  return process(block, res, [](l1t::EGamma eg) { eg.setHwIso(1); return eg; });
104  }
105 
106  bool
108  {
109  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
110  return process(block, res, [](const l1t::EGamma& eg) { return eg; });
111  }
112 
113  bool
115  {
116  auto res = static_cast<CaloCollections*>(coll)->getJets();
117 
118  if (res->size(0) != 0)
119  edm::LogWarning("L1T") << "Need to unpack central jets before forward ones";
120 
121  return process(block, res, [](const l1t::Jet& j) { return j; });
122  }
123 
124  bool
126  {
127  auto res = static_cast<CaloCollections*>(coll)->getJets();
128 
129  if (res->size(0) != 4)
130  edm::LogWarning("L1T") << "Need to unpack central jets before forward ones";
131 
132  return process(block, res, [](l1t::Jet j) { j.setHwQual(j.hwQual() | 2); return j; });
133  }
134 
135  bool
137  {
138  auto res = static_cast<CaloCollections*>(coll)->getTaus();
139  return process(block, res, [](const l1t::Tau& t) { return t; });
140  }
141 
142  bool
144  {
145  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
146  return process(block, res, [](const l1t::Tau& t) { return t; });
147  }
148  }
149  }
150 }
151 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
unsigned int getID() const
Definition: Block.h:22
Definition: Tau.h:13
void getBXRange(int nbx, int &first, int &last)
Definition: Unpacker.cc:12
BlockHeader header() const
Definition: Block.h:56
void setHwQual(int qual)
Definition: L1Candidate.cc:64
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
std::vector< uint32_t > payload() const
Definition: Block.h:57
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
Definition: Jet.h:13
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
int j
Definition: DBlmapReader.cc:9
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
int hwQual() const
Definition: L1Candidate.cc:89
void setHwIso(int iso)
Definition: L1Candidate.cc:59
JetCorrectorParametersCollection coll
Definition: classes.h:10
void setBXRange(int bxFirst, int bxLast)
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
unsigned int getSize() const
Definition: Block.h:23
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
tuple process
Definition: LaserDQM_cfg.py:3
long double T
void push_back(int bx, T object)