CMS 3D CMS Logo

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