CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EMTFBlockRPC.cc
Go to the documentation of this file.
1 #include <memory>
3 
4 #include "EMTFCollections.h"
5 #include "EMTFUnpackerTools.h"
6 #include "EMTFBlockRPC.h"
7 
8 namespace l1t {
9  namespace stage2 {
10  namespace emtf {
11 
13 
14  auto payload = block.payload();
15  int errors = 0;
16 
17  //Check the number of 16-bit words
18  if(payload.size() != 4) { errors += 1; edm::LogError("L1T|EMTF") << "Payload size in 'RPC Data Record' is different than expected"; }
19 
20  //Check that each word is 16 bits
21  if(GetHexBits(payload[0], 16, 31) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Payload[0] has more than 16 bits in 'RPC Data Record'"; }
22  if(GetHexBits(payload[1], 16, 31) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Payload[1] has more than 16 bits in 'RPC Data Record'"; }
23  if(GetHexBits(payload[2], 16, 31) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Payload[2] has more than 16 bits in 'RPC Data Record'"; }
24  if(GetHexBits(payload[3], 16, 31) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Payload[3] has more than 16 bits in 'RPC Data Record'"; }
25 
26  uint16_t RPCa = payload[0];
27  uint16_t RPCb = payload[1];
28  uint16_t RPCc = payload[2];
29  uint16_t RPCd = payload[3];
30 
31  //Check Format
32  if(GetHexBits(RPCa, 15, 15) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in RPCa are incorrect"; }
33  if(GetHexBits(RPCb, 15, 15) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in RPCb are incorrect"; }
34  if(GetHexBits(RPCc, 12, 13) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in RPCc are incorrect"; }
35  if(GetHexBits(RPCc, 15, 15) != 1) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in RPCc are incorrect"; }
36  if(GetHexBits(RPCd, 3, 15) != 0) { errors += 1; edm::LogError("L1T|EMTF") << "Format identifier bits in RPCd are incorrect"; }
37 
38  return errors;
39 
40  }
41 
43 
44  // std::cout << "Inside EMTFBlockRPC.cc: unpack" << std::endl;
45 
46  // Get the payload for this block, made up of 16-bit words (0xffff)
47  // Format defined in MTF7Payload::getBlock() in src/Block.cc
48  // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc.
49  auto payload = block.payload();
50 
51  // Check Format of Payload
52  l1t::emtf::RPC RPC_;
53  for (int err = 0; err < checkFormat(block); err++) RPC_.add_format_error();
54 
55  // Assign payload to 16-bit words
56  uint16_t RPCa = payload[0];
57  uint16_t RPCb = payload[1];
58  uint16_t RPCc = payload[2];
59  uint16_t RPCd = payload[3];
60 
61  // res is a pointer to a collection of EMTFDaqOut class objects
62  // There is one EMTFDaqOut for each MTF7 (60 deg. sector) in the event
64  res = static_cast<EMTFCollections*>(coll)->getEMTFDaqOuts();
65  int iOut = res->size() - 1;
66  if (RPC_.Format_Errors() > 0) goto write;
67 
69  // Unpack the RPC Data Record
71 
72  RPC_.set_partition_data ( GetHexBits(RPCa, 0, 7) );
73  RPC_.set_partition_num ( GetHexBits(RPCa, 8, 11) );
74  RPC_.set_prt_delay ( GetHexBits(RPCa, 12, 14) );
75 
76  RPC_.set_link_number ( GetHexBits(RPCb, 0, 4) );
77  RPC_.set_lb ( GetHexBits(RPCb, 5, 6) );
78  RPC_.set_eod ( GetHexBits(RPCb, 7, 7) );
79  RPC_.set_bcn ( GetHexBits(RPCb, 8, 14) );
80 
81  RPC_.set_bxn ( GetHexBits(RPCc, 0, 11) );
82  RPC_.set_bc0 ( GetHexBits(RPCc, 14, 14) );
83 
84  RPC_.set_tbin ( GetHexBits(RPCd, 0, 2) );
85 
86  // RPC_.set_dataword ( uint64_t dataword);
87 
88  write:
89 
90  (res->at(iOut)).push_RPC(RPC_);
91 
92  // Finished with unpacking one RPC Data Record
93  return true;
94 
95  } // End bool RPCBlockUnpacker::unpack
96 
97  // bool RPCBlockPacker::pack(const Block& block, UnpackerCollections *coll) {
98  // std::cout << "Inside RPCBlockPacker::pack" << std::endl;
99  // return true;
100  // } // End bool RPCBlockPacker::pack
101 
102  } // End namespace emtf
103  } // End namespace stage2
104 } // End namespace l1t
105 
107 // DEFINE_L1T_PACKER(l1t::stage2::RPCBlockPacker);
void set_link_number(int bits)
Definition: RPC.h:33
void set_partition_data(int bits)
Definition: RPC.h:30
void set_bcn(int bits)
Definition: RPC.h:31
void add_format_error()
Definition: RPC.h:38
void set_prt_delay(int bits)
Definition: RPC.h:28
void set_bxn(int bits)
Definition: RPC.h:34
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: EMTFBlockRPC.cc:42
std::vector< uint32_t > payload() const
Definition: Block.h:57
void set_eod(int bits)
Definition: RPC.h:36
void set_partition_num(int bits)
Definition: RPC.h:29
void set_tbin(int bits)
Definition: RPC.h:35
int Format_Errors() const
Definition: RPC.h:51
std::vector< EMTFDaqOut > EMTFDaqOutCollection
Definition: EMTFDaqOut.h:130
void set_bc0(int bits)
Definition: RPC.h:37
void set_lb(int bits)
Definition: RPC.h:32
JetCorrectorParametersCollection coll
Definition: classes.h:10
#define DEFINE_L1T_UNPACKER(type)
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)
virtual int checkFormat(const Block &block)
Definition: EMTFBlockRPC.cc:12