CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GctFormatTranslateBase.h
Go to the documentation of this file.
1 #ifndef GctFormatTranslateBase_h_
2 #define GctFormatTranslateBase_h_
3 
4 // C++ includes
5 #include <map>
6 #include <utility>
7 #include <string>
8 
9 // CMSSW includes
14 
26 public:
28 
30  explicit GctFormatTranslateBase(bool hltMode = false, bool unpackSharedRegions = false);
31 
32  virtual ~GctFormatTranslateBase();
33 
35  void setUnpackCollections(GctUnpackCollections* const collections) { m_collections = collections; }
36 
37  // Set the bunch crossing ID that will be put into the block headers when packing raw data (i.e. Digi -> Raw).
38  void setPackingBxId(uint32_t bxId) { m_packingBxId = bxId; }
39 
40  // Set the event ID that will be put into the block headers when packing raw data (i.e. Digi -> Raw).
41  void setPackingEventId(uint32_t eventId) { m_packingEventId = eventId; }
42 
44  virtual GctBlockHeader generateBlockHeader(const unsigned char* data) const = 0;
45 
47  const std::string& getBlockDescription(const GctBlockHeader& header) const;
48 
50  virtual bool convertBlock(const unsigned char* d, const GctBlockHeader& hdr) = 0;
51 
52 protected:
53  /* PROTECTED TYPDEFS, ENUMS, AND CLASS CONSTANTS. */
54 
56 
58 
60 
62 
63  typedef std::map<unsigned int, unsigned int> BlockLengthMap;
64  typedef std::pair<unsigned int, unsigned int> BlockLengthPair;
65  typedef std::map<unsigned int, std::string> BlockNameMap;
66  typedef std::pair<unsigned int, std::string> BlockNamePair;
67 
69  typedef std::map<unsigned int, unsigned int> BlkToRctCrateMap;
70 
76  typedef std::pair<unsigned int, unsigned int> IsoBoundaryPair;
77 
79  typedef std::map<unsigned int, IsoBoundaryPair> BlockIdToEmCandIsoBoundMap;
80 
81  /* PROTECTED METHODS */
82 
83  /* Static data member access methods */
84  virtual const BlockLengthMap& blockLengthMap() const = 0;
85 
86  virtual const BlockNameMap& blockNameMap() const = 0;
87 
88  virtual const BlkToRctCrateMap& rctEmCrateMap()
89  const = 0;
90 
91  virtual const BlkToRctCrateMap& rctJetCrateMap() const = 0;
92 
94  const = 0;
95 
96  /* Data member access methods */
97  GctUnpackCollections* const colls() const {
98  return m_collections;
99  }
100  bool hltMode() const { return m_hltMode; }
101  bool unpackSharedRegions() const {
102  return m_unpackSharedRegions;
103  }
105  return m_srcCardRouting;
106  }
107  const uint32_t packingBxId() const { return m_packingBxId; }
108  const uint32_t packingEventId() const { return m_packingEventId; }
109 
110  /* Other general methods */
112  L1GctJetCandCollection* const gctJets(const unsigned cat) const;
113 
115  virtual uint32_t generateRawHeader(const uint32_t blockId,
116  const uint32_t nSamples,
117  const uint32_t bxId,
118  const uint32_t eventId) const = 0;
119 
121 
122  void writeRawHeader(unsigned char* data, uint32_t blockId, uint32_t nSamples) const;
123 
125  bool checkBlock(const GctBlockHeader& hdr) const;
126 
128  void blockDoNothing(const unsigned char* d, const GctBlockHeader& hdr) {}
129 
130 private:
131  /* PRIVATE STATIC CONSTS */
133 
134  /* PRIVATE MEMBER DATA */
135 
138 
140  bool m_hltMode;
141 
143 
145 
148 
150  uint32_t m_packingBxId;
151 
154 };
155 
156 #endif /* GctFormatTranslateBase_h_ */
bool m_hltMode
If true, unpack only BX zero and GCT output data (i.e. to run as quickly as possible) ...
void setPackingEventId(uint32_t eventId)
const std::string & getBlockDescription(const GctBlockHeader &header) const
Get block description.
std::pair< unsigned int, unsigned int > IsoBoundaryPair
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.
virtual const BlkToRctCrateMap & rctEmCrateMap() const =0
get static the block ID to RCT crate map for electrons.
GctUnpackCollections * m_collections
Pointer to the output collections object.
Abstract interface for RawToDigi/DigiToRaw conversions of GCT data.
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...
const SourceCardRouting & srcCardRouting() const
Protected interface to the unpackSharedRegions commissioning option.
static const std::string INVALID_BLOCK_HEADER_STR
uint32_t m_packingBxId
The bunch-crossing ID to be used by the data packing methods.
GctFormatTranslateBase(bool hltMode=false, bool unpackSharedRegions=false)
Constructor.
std::vector< L1GctJetCand > L1GctJetCandCollection
tuple d
Definition: ztail.py:151
virtual bool convertBlock(const unsigned char *d, const GctBlockHeader &hdr)=0
Get digis from the block - will return true if it succeeds, false otherwise.
GctUnpackCollections *const colls() const
Protected access to the GCT Unpack Collections.
std::pair< unsigned int, std::string > BlockNamePair
Block ID/Description pair.
virtual const BlockNameMap & blockNameMap() const =0
get the static block ID to blockname map.
def cat
Definition: eostools.py:401
uint32_t m_packingEventId
The event ID to be used by the data packing methods.
virtual const BlockLengthMap & blockLengthMap() const =0
get the static block ID to block-length map.
Simple class for holding the basic attributes of an 32-bit block header.
SourceCardRouting m_srcCardRouting
Source card mapping info.
std::map< unsigned int, unsigned int > BlockLengthMap
Block ID to Block Length map.
void blockDoNothing(const unsigned char *d, const GctBlockHeader &hdr)
The null unpack function - obviously common to all formats.
bool hltMode() const
Protected interface to get HLT optimisation mode flag.
constexpr size_t nSamples
virtual const BlockIdToEmCandIsoBoundMap & internEmIsoBounds() const =0
get the static intern EM cand isolated boundary map.
RAII and useful methods for the many dataformat collections required by the GCT unpacker.
const uint32_t packingEventId() const
Get the EventId to be used when packing data.
bool m_unpackSharedRegions
If true, the shared RCT Calo regions will be unpacked also.
L1GctJetCandCollection *const gctJets(const unsigned cat) const
Get a specific jet candandiate collection using the JetCandCategory enumeration.
void setPackingBxId(uint32_t bxId)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
virtual const BlkToRctCrateMap & rctJetCrateMap() const =0
get the static block ID to RCT crate map for jets
std::pair< unsigned int, unsigned int > BlockLengthPair
Block ID/length pair.
void setUnpackCollections(GctUnpackCollections *const collections)
Set the pointer to the unpack collections.
std::map< unsigned int, IsoBoundaryPair > BlockIdToEmCandIsoBoundMap
A typdef for mapping Block IDs to IsoBoundaryPairs.
std::map< unsigned int, unsigned int > BlkToRctCrateMap
Typedef for mapping block ID to RCT crate.
std::map< unsigned int, std::string > BlockNameMap
Block ID to Block Description map.
EmCandCatagory
An enum of the EM candidate types.
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.
JetCandCategory
Useful enumeration for jet candidate pack/unpack.
const uint32_t packingBxId() const
Get the BxId to be used when packing data.
virtual GctBlockHeader generateBlockHeader(const unsigned char *data) const =0
Generate a block header from four 8-bit values.