CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EMTFBlockME.cc
Go to the documentation of this file.
1 // Code to unpack the "ME Data Record"
2 
4 #include "EMTFCollections.h"
5 #include "EMTFUnpackerTools.h"
6 
7 // This is the "header" - no EMTFBlockME.h file is needed
8 namespace l1t {
9  namespace stage2 {
10  namespace emtf {
11 
12  class MEBlockUnpacker : public Unpacker { // "MEBlockUnpacker" inherits from "Unpacker"
13  public:
14  // virtual bool checkFormat() override; // Return "false" if block format does not match expected format
15  virtual bool unpack(const Block& block, UnpackerCollections *coll) override; // Apparently it's always good to use override in C++
16  // virtual bool packBlock(const Block& block, UnpackerCollections *coll) override;
17  };
18 
19  // class MEBlockPacker : public Packer { // "MEBlockPacker" inherits from "Packer"
20  // public:
21  // virtual bool unpack(const Block& block, UnpackerCollections *coll) override; // Apparently it's always good to use override in C++
22  // };
23 
24  }
25  }
26 }
27 
28 namespace l1t {
29  namespace stage2 {
30  namespace emtf {
31 
33 
34  // Get the payload for this block, made up of 16-bit words (0xffff)
35  // Format defined in MTF7Payload::getBlock() in src/Block.cc
36  // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc.
37  auto payload = block.payload();
38 
39  // Assign payload to 16-bit words
40  uint16_t MEa = payload[0];
41  uint16_t MEb = payload[1];
42  uint16_t MEc = payload[2];
43  uint16_t MEd = payload[3];
44 
45  // std::cout << "This payload has " << payload.size() << " 16-bit words" << std::endl;
46  // for (uint iWord = 0; iWord < payload.size(); iWord++)
47  // std::cout << std::hex << std::setw(8) << std::setfill('0') << payload[iWord] << std::dec << std::endl;
48 
49  // res is a pointer to a collection of EMTFOutput class objects
50  // There is one EMTFOutput for each MTF7 (60 deg. sector) in the event
52  res = static_cast<EMTFCollections*>(coll)->getEMTFOutputs();
53  int iOut = res->size() - 1;
54 
56  // Unpack the ME Data Record
58 
59  l1t::emtf::ME ME_;
60 
61  ME_.set_clct_pattern ( GetHexBits(MEa, 0, 3) );
62  ME_.set_quality ( GetHexBits(MEa, 4, 7) );
63  ME_.set_key_wire_group ( GetHexBits(MEa, 8, 14) );
64 
65  ME_.set_clct_key_half_strip ( GetHexBits(MEb, 0, 7) );
66  ME_.set_csc_ID ( GetHexBits(MEb, 8, 11) );
67  ME_.set_lr ( GetHexBits(MEb, 12, 12) );
68  ME_.set_bxe ( GetHexBits(MEb, 13, 13) );
69  ME_.set_bc0 ( GetHexBits(MEb, 14, 14) );
70 
71  ME_.set_me_bxn ( GetHexBits(MEc, 0, 11) );
72  ME_.set_nit ( GetHexBits(MEc, 12, 12) );
73  ME_.set_cik ( GetHexBits(MEc, 13, 13) );
74  ME_.set_afff ( GetHexBits(MEc, 14, 14) );
75 
76  ME_.set_tbin_num ( GetHexBits(MEd, 0, 2) );
77  ME_.set_vp ( GetHexBits(MEd, 3, 3) );
78  ME_.set_station ( GetHexBits(MEd, 4, 6) );
79  ME_.set_af ( GetHexBits(MEd, 7, 7) );
80  ME_.set_epc ( GetHexBits(MEd, 8, 11) );
81  ME_.set_sm ( GetHexBits(MEd, 12, 12) );
82  ME_.set_se ( GetHexBits(MEd, 13, 13) );
83  ME_.set_afef ( GetHexBits(MEd, 14, 14) );
84 
85  // ME_.set_dataword ( uint64_t dataword);
86 
87  (res->at(iOut)).push_ME(ME_);
88 
89  // Finished with unpacking one ME Data Record
90  return true;
91 
92  } // End bool MEBlockUnpacker::unpack
93 
94  // bool MEBlockPacker::pack(const Block& block, UnpackerCollections *coll) {
95  // std::cout << "Inside MEBlockPacker::pack" << std::endl;
96  // return true;
97  // } // End bool MEBlockPacker::pack
98 
99  } // End namespace emtf
100  } // End namespace stage2
101 } // End namespace l1t
102 
104 // DEFINE_L1T_PACKER(l1t::stage2::MEBlockPacker);
void set_bxe(int bits)
Definition: ME.h:35
void set_af(int bits)
Definition: ME.h:43
void set_bc0(int bits)
Definition: ME.h:34
void set_vp(int bits)
Definition: ME.h:44
void set_epc(int bits)
Definition: ME.h:31
std::vector< uint32_t > payload() const
Definition: Block.h:57
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
void set_key_wire_group(int bits)
Definition: ME.h:26
void set_tbin_num(int bits)
Definition: ME.h:33
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: EMTFBlockME.cc:32
void set_se(int bits)
Definition: ME.h:41
std::vector< EMTFOutput > EMTFOutputCollection
Definition: EMTFOutput.h:102
void set_quality(int bits)
Definition: ME.h:28
void set_csc_ID(int bits)
Definition: ME.h:30
void set_afef(int bits)
Definition: ME.h:40
void set_afff(int bits)
Definition: ME.h:37
void set_nit(int bits)
Definition: ME.h:39
void set_lr(int bits)
Definition: ME.h:36
JetCorrectorParametersCollection coll
Definition: classes.h:10
void set_clct_key_half_strip(int bits)
Definition: ME.h:27
void set_cik(int bits)
Definition: ME.h:38
void set_station(int bits)
Definition: ME.h:32
void set_me_bxn(int bits)
Definition: ME.h:25
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)
void set_sm(int bits)
Definition: ME.h:42
void set_clct_pattern(int bits)
Definition: ME.h:29