CMS 3D CMS Logo

EMTFBlockCounters.cc
Go to the documentation of this file.
2 
3 #include "EMTFCollections.h"
4 #include "EMTFUnpackerTools.h"
5 #include "EMTFBlockCounters.h"
6 
7 namespace l1t {
8  namespace stage2 {
9  namespace emtf {
10 
12 
13  auto payload = block.payload();
14  int errors = 0;
15 
16  //Check the number of 16-bit words
17  if(payload.size() != 4) { errors += 1; edm::LogError("L1T|EMTF") << "Payload size in 'Block of Counters' is different than expected"; }
18 
19  //Check that each word is 16 bits
20  if(GetHexBits(payload[0], 16, 31) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Payload[0] has more than 16 bits in 'Block of Counters'"; }
21  if(GetHexBits(payload[1], 16, 31) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Payload[1] has more than 16 bits in 'Block of Counters'"; }
22  if(GetHexBits(payload[2], 16, 31) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Payload[2] has more than 16 bits in 'Block of Counters'"; }
23  if(GetHexBits(payload[3], 16, 31) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Payload[3] has more than 16 bits in 'Block of Counters'"; }
24 
25  uint16_t BCa = payload[0];
26  uint16_t BCb = payload[1];
27  uint16_t BCc = payload[2];
28  uint16_t BCd = payload[3];
29 
30  //Check Format
31  if(GetHexBits(BCa, 15, 15) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in BCa are incorrect"; }
32  if(GetHexBits(BCb, 15, 15) != 1) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in BCb are incorrect"; }
33  if(GetHexBits(BCc, 15, 15) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in BCc are incorrect"; }
34  if(GetHexBits(BCd, 15, 15) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in BCd are incorrect"; }
35 
36  return errors;
37  }
38 
39 
41 
42  // std::cout << "Inside EMTFBlockCounters.cc: unpack" << std::endl;
43 
44  // Get the payload for this block, made up of 16-bit words (0xffff)
45  // Format defined in MTF7Payload::getBlock() in src/Block.cc
46  // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc.
47  auto payload = block.payload();
48 
49  // Check Format of Payload
50  l1t::emtf::Counters Counters_;
51  for (int err = 0; err < checkFormat(block); err++) Counters_.add_format_error();
52 
53  // Assign payload to 16-bit words
54  uint16_t BCa = payload[0];
55  uint16_t BCb = payload[1];
56  uint16_t BCc = payload[2];
57  uint16_t BCd = payload[3];
58 
59  // res is a pointer to a collection of EMTFDaqOut class objects
60  // There is one EMTFDaqOut for each MTF7 (60 deg. sector) in the event
62  res = static_cast<EMTFCollections*>(coll)->getEMTFDaqOuts();
63  int iOut = res->size() - 1;
64 
66  // Unpack the Block of Counters
68  if ( (res->at(iOut)).HasCounters() == true )
69  { (res->at(iOut)).add_format_error(); edm::LogError("L1T|EMTF") << "Why is there already a Counters object?"; goto write; }
70  if (Counters_.Format_Errors() > 0) goto write;
71 
72  Counters_.set_track_counter( GetHexBits(BCa, 0, 14, BCb, 0, 14) );
73  Counters_.set_orbit_counter( GetHexBits(BCc, 0, 14, BCd, 0, 14) );
74  // Counters_.set_rpc_counter( GetHexBits(payload[], , ) );
75  // Counters_.set_dataword(uint64_t bits) { dataword = bits; };
76 
77  write:
78  (res->at(iOut)).set_Counters(Counters_);
79 
80  // Finished with unpacking Counters
81  return true;
82 
83  } // End bool CountersBlockUnpacker::unpack
84 
85  // bool CountersBlockPacker::pack(const Block& block, UnpackerCollections *coll) {
86  // std::cout << "Inside CountersBlockPacker::pack" << std::endl;
87  // return true;
88  // } // End bool CountersBlockPacker::pack
89 
90  } // End namespace emtf
91  } // End namespace stage2
92 } // End namespace l1t
93 
95 // DEFINE_L1T_PACKER(l1t::stage2::CountersBlockPacker);
virtual int checkFormat(const Block &block)
void set_track_counter(int bits)
Definition: Counters.h:26
Definition: Event.h:15
delete x;
Definition: CaloConfig.h:22
int Format_Errors() const
Definition: Counters.h:35
std::vector< uint32_t > payload() const
Definition: Block.h:61
Definition: Electron.h:4
payload
payload postfix for testing
void add_format_error()
Definition: Counters.h:29
std::vector< EMTFDaqOut > EMTFDaqOutCollection
Definition: EMTFDaqOut.h:130
void set_orbit_counter(int bits)
Definition: Counters.h:27
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
JetCorrectorParametersCollection coll
Definition: classes.h:10
#define DEFINE_L1T_UNPACKER(type)
Definition: errors.py:1
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)
def write(self, setup)