CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TauUnpacker.cc
Go to the documentation of this file.
2 
4 
5 #include "L1TObjectCollections.h"
6 
7 namespace l1t {
8  namespace stage2 {
9  class TauUnpacker : public Unpacker {
10  public:
11  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
12  };
13  }
14 }
15 
16 // Implementation
17 
18 namespace l1t {
19 namespace stage2 {
20  bool
22  {
23 
24  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
25 
26  int nBX = int(ceil(block.header().getSize() / 8.)); // Since there are 8 Tau objects reported per event (see CMS IN-2013/005)
27 
28  // Find the first and last BXs
29  int firstBX = -(ceil((double)nBX/2.)-1);
30  int lastBX;
31  if (nBX % 2 == 0) {
32  lastBX = ceil((double)nBX/2.);
33  } else {
34  lastBX = ceil((double)nBX/2.)-1;
35  }
36 
37  auto res_ = static_cast<L1TObjectCollections*>(coll)->getTaus();
38  res_->setBXRange(firstBX, lastBX);
39 
40  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
41 
42  // Initialise index
43  int unsigned i = 0;
44 
45  // Loop over multiple BX and then number of Tau cands filling collection
46  for (int bx=firstBX; bx<=lastBX; bx++){
47 
48  for (unsigned nTau=0; nTau < 8 && nTau < block.header().getSize(); nTau++){
49 
50  uint32_t raw_data = block.payload()[i++];
51 
52  if (raw_data == 0)
53  continue;
54 
55  l1t::Tau tau = l1t::Tau();
56 
57  tau.setHwPt(raw_data & 0x1FF);
58 
59  int abs_eta = (raw_data >> 9) & 0x7F;
60  if ((raw_data >> 16) & 0x1) {
61  tau.setHwEta(-1*abs_eta);
62  } else {
63  tau.setHwEta(abs_eta);
64  }
65 
66  tau.setHwPhi((raw_data >> 17) & 0xFF);
67  tau.setHwIso((raw_data >> 25) & 0x1); // Assume one bit for now?
68  tau.setHwQual((raw_data >> 26) & 0x7); // Assume 3 bits for now? leaves 3 spare bits
69 
70  LogDebug("L1T") << "Tau: eta " << tau.hwEta() << " phi " << tau.hwPhi() << " pT " << tau.hwPt() << " iso " << tau.hwIso() << " qual " << tau.hwQual();
71 
72  res_->push_back(bx,tau);
73 
74  }
75 
76  }
77 
78  return true;
79  }
80 }
81 }
82 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: TauUnpacker.cc:21
unsigned int getID() const
Definition: Block.h:22
Definition: Tau.h:13
BlockHeader header() const
Definition: Block.h:56
void setHwQual(int qual)
Definition: L1Candidate.cc:64
int hwPhi() const
Definition: L1Candidate.cc:79
std::vector< uint32_t > payload() const
Definition: Block.h:57
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
int hwIso() const
Definition: L1Candidate.cc:84
int hwEta() const
Definition: L1Candidate.cc:74
int hwQual() const
Definition: L1Candidate.cc:89
void setHwPhi(int phi)
Definition: L1Candidate.cc:54
void setHwIso(int iso)
Definition: L1Candidate.cc:59
JetCorrectorParametersCollection coll
Definition: classes.h:10
int hwPt() const
Definition: L1Candidate.cc:69
void setHwPt(int pt)
Definition: L1Candidate.cc:44
unsigned int getSize() const
Definition: Block.h:23
void setHwEta(int eta)
Definition: L1Candidate.cc:49