test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
15 
28 {
29 public:
30 
32 
34  explicit GctFormatTranslateBase(bool hltMode = false, bool unpackSharedRegions = false);
35 
36  virtual ~GctFormatTranslateBase();
37 
39  void setUnpackCollections(GctUnpackCollections * const collections) { m_collections = collections; }
40 
41  // Set the bunch crossing ID that will be put into the block headers when packing raw data (i.e. Digi -> Raw).
42  void setPackingBxId(uint32_t bxId) { m_packingBxId = bxId; }
43 
44  // Set the event ID that will be put into the block headers when packing raw data (i.e. Digi -> Raw).
45  void setPackingEventId(uint32_t eventId) { m_packingEventId = eventId; }
46 
48  virtual GctBlockHeader generateBlockHeader(const unsigned char * data) const = 0;
49 
51  const std::string& getBlockDescription(const GctBlockHeader& header) const;
52 
54  virtual bool convertBlock(const unsigned char * d, const GctBlockHeader& hdr) = 0;
55 
56 protected:
57 
58  /* PROTECTED TYPDEFS, ENUMS, AND CLASS CONSTANTS. */
59 
61 
63 
65 
67 
68  typedef std::map<unsigned int, unsigned int> BlockLengthMap;
69  typedef std::pair<unsigned int, unsigned int> BlockLengthPair;
70  typedef std::map<unsigned int, std::string> BlockNameMap;
71  typedef std::pair<unsigned int, std::string> BlockNamePair;
72 
74  typedef std::map<unsigned int, unsigned int> BlkToRctCrateMap;
75 
81  typedef std::pair<unsigned int, unsigned int> IsoBoundaryPair;
82 
84  typedef std::map<unsigned int, IsoBoundaryPair> BlockIdToEmCandIsoBoundMap;
85 
86 
87  /* PROTECTED METHODS */
88 
89  /* Static data member access methods */
90  virtual const BlockLengthMap& blockLengthMap() const = 0;
91 
92  virtual const BlockNameMap& blockNameMap() const = 0;
93 
94  virtual const BlkToRctCrateMap& rctEmCrateMap() const = 0;
95 
96  virtual const BlkToRctCrateMap& rctJetCrateMap() const = 0;
97 
98  virtual const BlockIdToEmCandIsoBoundMap& internEmIsoBounds() const = 0;
99 
100 
101  /* Data member access methods */
102  GctUnpackCollections * const colls() const { return m_collections; }
103  bool hltMode() const { return m_hltMode; }
104  bool unpackSharedRegions() const { return m_unpackSharedRegions; }
106  const uint32_t packingBxId() const { return m_packingBxId; }
107  const uint32_t packingEventId() const { return m_packingEventId; }
108 
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 
131 private:
132 
133  /* PRIVATE STATIC CONSTS */
135 
136  /* PRIVATE MEMBER DATA */
137 
140 
142  bool m_hltMode;
143 
145 
147 
150 
152  uint32_t m_packingBxId;
153 
156 
157 };
158 
159 #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:400
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)
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.