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) {
10  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
11 
12  int nBX = int(ceil(block.header().getSize() / 2.));
13 
14  // Find the first and last BXs
15  int firstBX = -(ceil((double)nBX/2.)-1);
16  int lastBX;
17  if (nBX % 2 == 0) {
18  lastBX = ceil((double)nBX/2.)+1;
19  } else {
20  lastBX = ceil((double)nBX/2.);
21  }
22 
23  coll->setBXRange(firstBX, lastBX);
24 
25  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
26 
27  // Initialise index
28  int unsigned i = 0;
29 
30  // Loop over multiple BX and then number of jets filling jet collection
31  for (int bx=firstBX; bx<lastBX; bx++){
32  uint32_t raw_data0 = block.payload()[i++];
33  uint32_t raw_data1 = block.payload()[i++];
34 
35  uint16_t candbit[4];
36  candbit[0] = raw_data0 & 0xFFFF;
37  candbit[1] = (raw_data0 >> 16) & 0xFFFF;
38  candbit[2] = raw_data1 & 0xFFFF;
39  candbit[3] = (raw_data1 >> 16) & 0xFFFF;
40 
41  for (int icand=0;icand<4;icand++){
42 
43  int candPt=candbit[icand] & 0x3F;
44  int candEta=(candbit[icand]>>6 ) & 0x7;
45  int candEtasign=(candbit[icand]>>9) & 0x1;
46  int candPhi=(candbit[icand]>>10) & 0x1F;
47 
48  T cand;
49  cand.setHwPt(candPt);
50  cand.setHwEta((candEtasign << 3) | candEta);
51  cand.setHwPhi(candPhi);
52  //int qualflag=cand.hwQual();
53  //qualflag|= (candPt == 0x3F);
54  //cand.setHwQual(qualflag);
55 
56  /* std::cout << "cand: eta " << cand.hwEta() << " phi " << cand.hwPhi() << " pT " << cand.hwPt() << " qual " << cand.hwQual() << std::endl; */
57  //std::cout << cand.hwPt() << " @ " << cand.hwEta() << ", " << cand.hwPhi() << " > " << cand.hwQual() << " > " << cand.hwIso() << std::endl;
58  coll->push_back(bx, modify(cand));
59  }
60  }
61 
62  return true;
63 }
64 
65 namespace l1t {
66  namespace stage1 {
67  class IsoEGammaUnpacker : public Unpacker {
68  public:
69  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
70  };
71 
72  class NonIsoEGammaUnpacker : public Unpacker {
73  public:
74  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
75  };
76 
77  class CentralJetUnpacker : public Unpacker {
78  public:
79  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
80  };
81 
82  class ForwardJetUnpacker : public Unpacker {
83  public:
84  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
85  };
86 
87  class TauUnpacker : public Unpacker {
88  public:
89  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
90  };
91 
92  class IsoTauUnpacker : public Unpacker {
93  public:
94  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
95  };
96  }
97 }
98 
99 // Implementation
100 
101 namespace l1t {
102  namespace stage1 {
103  bool
105  {
106  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
107  return process(block, res, [](l1t::EGamma eg) { eg.setHwIso(1); return eg; });
108  }
109 
110  bool
112  {
113  auto res = static_cast<CaloCollections*>(coll)->getEGammas();
114  return process(block, res, [](const l1t::EGamma& eg) { return eg; });
115  }
116 
117  bool
119  {
120  auto res = static_cast<CaloCollections*>(coll)->getJets();
121 
122  if (res->size(0) != 0)
123  edm::LogWarning("L1T") << "Need to unpack central jets before forward ones";
124 
125  return process(block, res, [](const l1t::Jet& j) { return j; });
126  }
127 
128  bool
130  {
131  auto res = static_cast<CaloCollections*>(coll)->getJets();
132 
133  if (res->size(0) != 4)
134  edm::LogWarning("L1T") << "Need to unpack central jets before forward ones";
135 
136  return process(block, res, [](l1t::Jet j) { j.setHwQual(j.hwQual() | 2); return j; });
137  }
138 
139  bool
141  {
142  auto res = static_cast<CaloCollections*>(coll)->getTaus();
143  return process(block, res, [](const l1t::Tau& t) { return t; });
144  }
145 
146  bool
148  {
149  auto res = static_cast<CaloCollections*>(coll)->getIsoTaus();
150  return process(block, res, [](const l1t::Tau& t) { return t; });
151  }
152  }
153 }
154 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
unsigned int getID() const
Definition: Block.h:14
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: Tau.h:13
BlockHeader header() const
Definition: Block.h:37
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:38
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:29
Definition: Jet.h:13
std::vector< JetPair > getJets(HWW &hww, int, double, double, bool, bool)
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
int j
Definition: DBlmapReader.cc:9
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
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
void setBXRange(int bxFirst, int bxLast)
unsigned int getSize() const
Definition: Block.h:15
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)