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 
30 {
31 public:
32 
34 
36  explicit GctFormatTranslateBase(bool hltMode = false, bool unpackSharedRegions = false);
37 
38  virtual ~GctFormatTranslateBase();
39 
41  void setUnpackCollections(GctUnpackCollections * const collections) { m_collections = collections; }
42 
43  // Set the bunch crossing ID that will be put into the block headers when packing raw data (i.e. Digi -> Raw).
44  void setPackingBxId(uint32_t bxId) { m_packingBxId = bxId; }
45 
46  // Set the event ID that will be put into the block headers when packing raw data (i.e. Digi -> Raw).
47  void setPackingEventId(uint32_t eventId) { m_packingEventId = eventId; }
48 
50  virtual GctBlockHeader generateBlockHeader(const unsigned char * data) const = 0;
51 
53  const std::string& getBlockDescription(const GctBlockHeader& header) const;
54 
56  virtual bool convertBlock(const unsigned char * d, const GctBlockHeader& hdr) = 0;
57 
58 protected:
59 
60  /* PROTECTED TYPDEFS, ENUMS, AND CLASS CONSTANTS. */
61 
63 
65 
67 
69 
70  typedef std::map<unsigned int, unsigned int> BlockLengthMap;
71  typedef std::pair<unsigned int, unsigned int> BlockLengthPair;
72  typedef std::map<unsigned int, std::string> BlockNameMap;
73  typedef std::pair<unsigned int, std::string> BlockNamePair;
74 
76  typedef std::map<unsigned int, unsigned int> BlkToRctCrateMap;
77 
83  typedef std::pair<unsigned int, unsigned int> IsoBoundaryPair;
84 
86  typedef std::map<unsigned int, IsoBoundaryPair> BlockIdToEmCandIsoBoundMap;
87 
88 
89  /* PROTECTED METHODS */
90 
91  /* Static data member access methods */
92  virtual BlockLengthMap& blockLengthMap() = 0;
93  virtual const BlockLengthMap& blockLengthMap() const = 0;
94 
95  virtual BlockNameMap& blockNameMap() = 0;
96  virtual const BlockNameMap& blockNameMap() const = 0;
97 
98  virtual BlkToRctCrateMap& rctEmCrateMap() = 0;
99  virtual const BlkToRctCrateMap& rctEmCrateMap() const = 0;
100 
101  virtual BlkToRctCrateMap& rctJetCrateMap() = 0;
102  virtual const BlkToRctCrateMap& rctJetCrateMap() const = 0;
103 
105  virtual const BlockIdToEmCandIsoBoundMap& internEmIsoBounds() const = 0;
106 
107 
108  /* Data member access methods */
109  GctUnpackCollections * const colls() const { return m_collections; }
110  bool hltMode() const { return m_hltMode; }
111  bool unpackSharedRegions() const { return m_unpackSharedRegions; }
113  const uint32_t packingBxId() const { return m_packingBxId; }
114  const uint32_t packingEventId() const { return m_packingEventId; }
115 
116 
117  /* Other general methods */
119  L1GctJetCandCollection * const gctJets(const unsigned cat) const;
120 
122  virtual uint32_t generateRawHeader(const uint32_t blockId,
123  const uint32_t nSamples,
124  const uint32_t bxId,
125  const uint32_t eventId) const = 0;
126 
128 
129  void writeRawHeader(unsigned char * data, uint32_t blockId, uint32_t nSamples) const;
130 
132  bool checkBlock(const GctBlockHeader& hdr) const;
133 
135  void blockDoNothing(const unsigned char * d, const GctBlockHeader& hdr) {}
136 
137 
138 private:
139 
140  /* PRIVATE STATIC CONSTS */
142 
143  /* PRIVATE MEMBER DATA */
144 
147 
149  bool m_hltMode;
150 
152 
154 
157 
159  uint32_t m_packingBxId;
160 
163 
164 };
165 
166 #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 BlkToRctCrateMap & rctJetCrateMap()=0
get the static block ID to RCT crate map for jets
virtual ~GctFormatTranslateBase()
Destructor.
virtual BlockNameMap & blockNameMap()=0
get the static block ID to block-name map.
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.
virtual BlkToRctCrateMap & rctEmCrateMap()=0
get the static block ID to RCT crate map for electrons.
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
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.
uint32_t m_packingEventId
The event ID to be used by the data packing methods.
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.
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.
virtual BlockLengthMap & blockLengthMap()=0
get the static block ID to block-length map.
virtual BlockIdToEmCandIsoBoundMap & internEmIsoBounds()=0
get the static intern EM cand isolated boundary map.
void setPackingBxId(uint32_t bxId)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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.