CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
l1t::stage2::MuonUnpacker Class Reference

#include <MuonUnpacker.h>

Inheritance diagram for l1t::stage2::MuonUnpacker:
l1t::Unpacker

Public Member Functions

int getFedNumber ()
 
unsigned int getMuonCopy ()
 
 MuonUnpacker ()
 
void setFedNumber (const int fed)
 
void setMuonCopy (const unsigned int copy)
 
bool unpack (const Block &block, UnpackerCollections *coll) override
 
 ~MuonUnpacker () override
 
- Public Member Functions inherited from l1t::Unpacker
unsigned int getAlgoVersion ()
 
void setAlgoVersion (const unsigned int version)
 
 Unpacker ()
 
virtual ~Unpacker ()=default
 

Private Member Functions

void unpackBx (int bx, const std::vector< uint32_t > &payload, unsigned int startIdx=0)
 

Private Attributes

int fed_
 
unsigned int muonCopy_
 
MuonBxCollectionres_
 

Static Private Attributes

static unsigned bxzs_enable_shift_ = 1
 
static unsigned nWords_ = 6
 

Detailed Description

Definition at line 10 of file MuonUnpacker.h.

Constructor & Destructor Documentation

l1t::stage2::MuonUnpacker::MuonUnpacker ( )

Definition at line 12 of file MuonUnpacker.cc.

12  : res_(nullptr), muonCopy_(0)
13  {
14  }
MuonBxCollection * res_
Definition: MuonUnpacker.h:27
l1t::stage2::MuonUnpacker::~MuonUnpacker ( )
inlineoverride

Definition at line 13 of file MuonUnpacker.h.

References groupFilesInBlocks::block, coll, and unpack().

13 {};

Member Function Documentation

int l1t::stage2::MuonUnpacker::getFedNumber ( )
inline

Definition at line 17 of file MuonUnpacker.h.

References fed_.

17 { return fed_; };
unsigned int l1t::stage2::MuonUnpacker::getMuonCopy ( )
inline

Definition at line 18 of file MuonUnpacker.h.

References muonCopy_.

18 { return muonCopy_; };
void l1t::stage2::MuonUnpacker::setFedNumber ( const int  fed)
inline

Definition at line 20 of file MuonUnpacker.h.

References fed_.

20 { fed_ = fed; };
void l1t::stage2::MuonUnpacker::setMuonCopy ( const unsigned int  copy)
inline

Definition at line 21 of file MuonUnpacker.h.

References popcon2dropbox::copy(), and muonCopy_.

21 { muonCopy_ = copy; };
def copy(args, dbName)
bool l1t::stage2::MuonUnpacker::unpack ( const Block block,
UnpackerCollections coll 
)
overridevirtual

Implements l1t::Unpacker.

Definition at line 17 of file MuonUnpacker.cc.

References l1t::Block::amc(), bxzs_enable_shift_, coll, Exception, fed_, l1t::Block::getBxBlocks(), l1t::getBXRange(), l1t::BlockHeader::getFlags(), l1t::BlockHeader::getID(), l1t::BlockHeader::getSize(), l1t::BxBlockHeader::getTotalBx(), l1t::Block::header(), createfilelist::int, LogDebug, muonCopy_, nWords_, jets_cff::payload, l1t::Block::payload(), res_, BXVector< T >::setBXRange(), unpackBx(), and globals_cff::x1.

Referenced by ~MuonUnpacker().

18  {
19  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
20  // process only if there is a payload
21  // If all BX block were zero suppressed the block header size is 0.
22  if (block.header().getSize() < 1) {
23  return true;
24  }
25 
26  auto payload = block.payload();
27 
28  int nBX, firstBX, lastBX;
29  // Check if per BX zero suppression was enabled
30  bool bxZsEnabled = ((block.header().getFlags() >> bxzs_enable_shift_) & 0x1) == 1;
31  // Calculate the total number of BXs
32  if (bxZsEnabled) {
33  BxBlockHeader bxHeader(payload.at(0));
34  nBX = bxHeader.getTotalBx();
35  } else {
36  nBX = int(ceil(block.header().getSize() / nWords_));
37  }
38  getBXRange(nBX, firstBX, lastBX);
39 
40  // Set the muon collection and the BX range
41  res_ = static_cast<L1TObjectCollections*>(coll)->getMuons(muonCopy_);
42  res_->setBXRange(firstBX, lastBX);
43  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
44 
45  // Get the BX blocks and unpack them
46  auto bxBlocks = block.getBxBlocks(nWords_, bxZsEnabled);
47  for (const auto& bxBlock : bxBlocks) {
48  // Throw an exception if finding a corrupt BX header with out of range BX numbers
49  const auto bx = bxBlock.header().getBx();
50  if (bx < firstBX || bx > lastBX) {
51  throw cms::Exception("CorruptData") << "Corrupt RAW data from FED " << fed_ << ", AMC " << block.amc().getAMCNumber() << ". BX number " << bx << " in BX header is outside of the BX range [" << firstBX << "," << lastBX << "] defined in the block header.";
52  }
53  unpackBx(bx, bxBlock.payload());
54  }
55  return true;
56  }
#define LogDebug(id)
MuonBxCollection * res_
Definition: MuonUnpacker.h:27
static unsigned bxzs_enable_shift_
Definition: MuonUnpacker.h:25
void getBXRange(int nbx, int &first, int &last)
void unpackBx(int bx, const std::vector< uint32_t > &payload, unsigned int startIdx=0)
Definition: MuonUnpacker.cc:60
static unsigned nWords_
Definition: MuonUnpacker.h:24
JetCorrectorParametersCollection coll
Definition: classes.h:10
void setBXRange(int bxFirst, int bxLast)
void l1t::stage2::MuonUnpacker::unpackBx ( int  bx,
const std::vector< uint32_t > &  payload,
unsigned int  startIdx = 0 
)
private

Definition at line 60 of file MuonUnpacker.cc.

References DEFINE_L1T_UNPACKER, fed_, l1t::MuonRawDigiTranslator::fillMuon(), l1t::Unpacker::getAlgoVersion(), l1t::Muon::hwCharge(), l1t::Muon::hwChargeValid(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwIso(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), l1t::L1Candidate::hwQual(), mps_fire::i, LogDebug, RPCpg::mu, nWords_, l1t::MuonRawDigiTranslator::ptMask_, l1t::MuonRawDigiTranslator::ptShift_, BXVector< T >::push_back(), and res_.

Referenced by unpack().

61  {
62  unsigned int i = startIdx;
63  // Check if there are enough words left in the payload
64  if (i + nWords_ <= payload.size()) {
65  for (unsigned nWord = 0; nWord < nWords_; nWord += 2) {
66  uint32_t raw_data_00_31 = payload[i++];
67  uint32_t raw_data_32_63 = payload[i++];
68  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << raw_data_00_31 << " raw_data_32_63 = 0x" << raw_data_32_63;
69  // skip empty muons (hwPt == 0)
71  LogDebug("L1T") << "Muon hwPt zero. Skip.";
72  continue;
73  }
74 
75  Muon mu;
76 
77  MuonRawDigiTranslator::fillMuon(mu, raw_data_00_31, raw_data_32_63, fed_, getAlgoVersion());
78 
79  LogDebug("L1T") << "Mu" << nWord/2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt() << " iso " << mu.hwIso() << " qual " << mu.hwQual() << " charge " << mu.hwCharge() << " charge valid " << mu.hwChargeValid();
80 
81  res_->push_back(bx, mu);
82  }
83  } else {
84  edm::LogWarning("L1T") << "Only " << payload.size() - i << " 32 bit words in this BX but " << nWords_ << " are required. Not unpacking the data for BX " << bx << ".";
85  }
86  }
#define LogDebug(id)
unsigned int getAlgoVersion()
Definition: Unpacker.h:18
MuonBxCollection * res_
Definition: MuonUnpacker.h:27
Definition: Muon.py:1
const int mu
Definition: Constants.h:22
static unsigned nWords_
Definition: MuonUnpacker.h:24
static const unsigned ptShift_
void push_back(int bx, T object)
static const unsigned ptMask_
static void fillMuon(Muon &, uint32_t, uint32_t, int, unsigned int)

Member Data Documentation

unsigned l1t::stage2::MuonUnpacker::bxzs_enable_shift_ = 1
staticprivate

Definition at line 25 of file MuonUnpacker.h.

Referenced by unpack().

int l1t::stage2::MuonUnpacker::fed_
private

Definition at line 28 of file MuonUnpacker.h.

Referenced by getFedNumber(), setFedNumber(), unpack(), and unpackBx().

unsigned int l1t::stage2::MuonUnpacker::muonCopy_
private

Definition at line 29 of file MuonUnpacker.h.

Referenced by getMuonCopy(), setMuonCopy(), and unpack().

unsigned l1t::stage2::MuonUnpacker::nWords_ = 6
staticprivate

Definition at line 24 of file MuonUnpacker.h.

Referenced by unpack(), and unpackBx().

MuonBxCollection* l1t::stage2::MuonUnpacker::res_
private

Definition at line 27 of file MuonUnpacker.h.

Referenced by unpack(), and unpackBx().