test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GctFormatTranslateBase.cc
Go to the documentation of this file.
2 
3 // Framework headers
5 
6 // INITIALISE STATICS
7 const std::string GctFormatTranslateBase::INVALID_BLOCK_HEADER_STR = "UNKNOWN/INVALID BLOCK HEADER";
8 
9 
10 // PUBLIC METHODS
11 
13  m_collections(0),
14  m_hltMode(hltMode),
15  m_unpackSharedRegions(unpackSharedRegions),
16  m_srcCardRouting(),
17  m_packingBxId(0),
18  m_packingEventId(0)
19 {
20 }
21 
23 
25 {
26  if(!header.valid()) { return INVALID_BLOCK_HEADER_STR; }
27  return blockNameMap().find(header.blockId())->second;
28 }
29 
30 
31 // PROTECTED METHODS
32 
34 {
35  switch(cat)
36  {
37  case TAU_JETS: return colls()->gctTauJets();
38  case FORWARD_JETS: return colls()->gctForJets();
39  default: return colls()->gctCenJets();
40  }
41 }
42 
43 void GctFormatTranslateBase::writeRawHeader(unsigned char * data, uint32_t blockId, uint32_t nSamples) const
44 {
45  uint32_t hdr = generateRawHeader(blockId, nSamples, packingBxId(), packingEventId());
46  uint32_t * p = reinterpret_cast<uint32_t*>(const_cast<unsigned char *>(data));
47  *p = hdr;
48 }
49 
51 {
52  // check block is valid
53  if ( !hdr.valid() )
54  {
55  LogDebug("GCT") << "Block unpack error: cannot unpack the following unknown/invalid block:\n" << hdr;
56  return false;
57  }
58 
59  // check block doesn't have too many time samples
60  if ( hdr.nSamples() >= 0xf ) {
61  LogDebug("GCT") << "Block unpack error: cannot unpack a block with 15 or more time samples:\n" << hdr;
62  return false;
63  }
64  return true;
65 }
66 
67 
#define LogDebug(id)
L1GctJetCandCollection *const gctTauJets() const
GCT output: Tau Jets collection.
bool valid() const
Returns true if it&#39;s valid block header - i.e. if the header is known and can be unpacked.
const std::string & getBlockDescription(const GctBlockHeader &header) const
Get block description.
bool checkBlock(const GctBlockHeader &hdr) const
Performs checks on the block header to see if the block is possible to unpack or not.
virtual ~GctFormatTranslateBase()
Destructor.
void writeRawHeader(unsigned char *data, uint32_t blockId, uint32_t nSamples) const
Writes a raw block header into the raw data array for a given block ID and number of time-samples...
static const std::string INVALID_BLOCK_HEADER_STR
GctFormatTranslateBase(bool hltMode=false, bool unpackSharedRegions=false)
Constructor.
U second(std::pair< T, U > const &p)
std::vector< L1GctJetCand > L1GctJetCandCollection
GctUnpackCollections *const colls() const
Protected access to the GCT Unpack Collections.
L1GctJetCandCollection *const gctCenJets() const
GCT output: Central Jets collection.
virtual const BlockNameMap & blockNameMap() const =0
get the static block ID to blockname map.
def cat
Definition: eostools.py:400
Simple class for holding the basic attributes of an 32-bit block header.
constexpr size_t nSamples
tuple unpackSharedRegions
Definition: HLT_Fake_cff.py:49
const uint32_t packingEventId() const
Get the EventId to be used when packing data.
L1GctJetCandCollection *const gctJets(const unsigned cat) const
Get a specific jet candandiate collection using the JetCandCategory enumeration.
uint32_t blockId() const
Get the block ID.
uint32_t nSamples() const
Get the number of time samples.
virtual uint32_t generateRawHeader(const uint32_t blockId, const uint32_t nSamples, const uint32_t bxId, const uint32_t eventId) const =0
Returns a raw 32-bit header word generated from the blockId, number of time samples, bunch-crossing and event IDs.
const uint32_t packingBxId() const
Get the BxId to be used when packing data.
L1GctJetCandCollection *const gctForJets() const
GCT output: Forward Jets collection.