CMS 3D CMS Logo

GctFormatTranslateMCLegacy.h
Go to the documentation of this file.
1 #ifndef GctFormatTranslateMCLegacy_h_
2 #define GctFormatTranslateMCLegacy_h_
3 
5 
16 // ************************************************************************
17 // *** THE TRANSLATION PROCESS MUST NEVER THROW ANY KIND OF EXCEPTION! ***
18 // ************************************************************************
19 
21 {
22 public:
23 
24  /* PUBLIC METHODS */
25 
27 
29  explicit GctFormatTranslateMCLegacy(bool hltMode = false, bool unpackSharedRegions = false);
30 
31  ~GctFormatTranslateMCLegacy() override;
32 
34  GctBlockHeader generateBlockHeader(const unsigned char * data) const override;
35 
37  bool convertBlock(const unsigned char * d, const GctBlockHeader& hdr) override;
38 
39 
40  /* ------------------------------ */
41  /* Public Block Packing Functions */
42  /* ------------------------------ */
43 
45 
46  void writeGctOutEmAndEnergyBlock(unsigned char * d,
47  const L1GctEmCandCollection* iso,
48  const L1GctEmCandCollection* nonIso,
49  const L1GctEtTotalCollection* etTotal,
50  const L1GctEtHadCollection* etHad,
51  const L1GctEtMissCollection* etMiss);
52 
54 
55  void writeGctOutJetBlock(unsigned char * d,
56  const L1GctJetCandCollection* cenJets,
57  const L1GctJetCandCollection* forJets,
58  const L1GctJetCandCollection* tauJets,
59  const L1GctHFRingEtSumsCollection* hfRingSums,
60  const L1GctHFBitCountsCollection* hfBitCounts,
61  const L1GctHtMissCollection* htMiss);
62 
64  void writeRctEmCandBlocks(unsigned char * d, const L1CaloEmCollection * rctEm);
65 
67  void writeAllRctCaloRegionBlock(unsigned char * d, const L1CaloRegionCollection * rctCalo);
68 
69 
70 protected:
71 
72  /* PROTECTED METHODS */
73 
74  /* Static data member access methods */
75  const BlockLengthMap& blockLengthMap() const final { return m_blockLength; }
76 
77  const BlockNameMap& blockNameMap() const final { return m_blockName; }
78 
79  const BlkToRctCrateMap& rctEmCrateMap() const final { return m_rctEmCrate; }
80 
81  const BlkToRctCrateMap& rctJetCrateMap() const final { return m_rctJetCrate; }
82 
84 
85 
86  /* Other general methods */
88  uint32_t generateRawHeader(const uint32_t blockId,
89  const uint32_t nSamples,
90  const uint32_t bxId,
91  const uint32_t eventId) const override;
92 
93 
94 private:
95 
96  /* PRIVATE TYPES & TYPEDEFS */
97 
99  typedef void (GctFormatTranslateMCLegacy::*PtrToUnpackFn)(const unsigned char *, const GctBlockHeader&);
101  typedef std::map<unsigned int, PtrToUnpackFn> BlockIdToUnpackFnMap;
102 
103 
104  /* PRIVATE MEMBER DATA */
105 
108 
110  static const BlockNameMap m_blockName;
111 
114 
117 
121 
123  static const BlockIdToUnpackFnMap m_blockUnpackFn;
124 
125 
126  /* PRIVATE METHODS */
127 
128  /* --------------------------------- */
129  /* Private Block Unpacking Functions */
130  /* --------------------------------- */
131 
133  void blockToGctEmCandsAndEnergySums(const unsigned char * d, const GctBlockHeader& hdr);
134 
136  void blockToGctJetCandsAndCounts(const unsigned char * d, const GctBlockHeader& hdr);
137 
139  void blockToRctEmCand(const unsigned char * d, const GctBlockHeader& hdr);
140 
142  void blockToFibres(const unsigned char * d, const GctBlockHeader& hdr);
143 
145  void blockToFibresAndToRctEmCand(const unsigned char * d, const GctBlockHeader& hdr);
146 
148  void blockToAllRctCaloRegions(const unsigned char * d, const GctBlockHeader& hdr);
149 
150 
151  /* ----------------------------- */
152  /* Miscellaneous Private Methods */
153  /* ----------------------------- */
154 
156 
157  template <typename Collection>
158  bool findBx0OffsetInCollection(unsigned& bx0Offset, const Collection* coll);
159 
160 };
161 
162 #endif
void writeGctOutEmAndEnergyBlock(unsigned char *d, const L1GctEmCandCollection *iso, const L1GctEmCandCollection *nonIso, const L1GctEtTotalCollection *etTotal, const L1GctEtHadCollection *etHad, const L1GctEtMissCollection *etMiss)
Writes GCT output EM and energy sums block into an unsigned char array, starting at the position poin...
std::vector< L1CaloEmCand > L1CaloEmCollection
uint32_t generateRawHeader(const uint32_t blockId, const uint32_t nSamples, const uint32_t bxId, const uint32_t eventId) const override
Returns a raw 32-bit header word generated from the blockId, number of time samples, bunch-crossing and event IDs.
void writeAllRctCaloRegionBlock(unsigned char *d, const L1CaloRegionCollection *rctCalo)
Writes the giant hack that is the RCT Calo Regions block.
std::vector< L1GctEtMiss > L1GctEtMissCollection
const BlkToRctCrateMap & rctJetCrateMap() const final
get the static block ID to RCT crate map for jets
std::vector< L1GctHFRingEtSums > L1GctHFRingEtSumsCollection
void blockToFibresAndToRctEmCand(const unsigned char *d, const GctBlockHeader &hdr)
unpack Fibres and RCT EM Candidates
const BlkToRctCrateMap & rctEmCrateMap() const final
get static the block ID to RCT crate map for electrons.
std::vector< L1GctEtHad > L1GctEtHadCollection
void writeRctEmCandBlocks(unsigned char *d, const L1CaloEmCollection *rctEm)
Writes the 4 RCT EM Candidate blocks.
Abstract interface for RawToDigi/DigiToRaw conversions of GCT data.
const BlockNameMap & blockNameMap() const final
get the static block ID to blockname map.
static const BlockNameMap m_blockName
Map to hold a description for each block number.
void writeGctOutJetBlock(unsigned char *d, const L1GctJetCandCollection *cenJets, const L1GctJetCandCollection *forJets, const L1GctJetCandCollection *tauJets, const L1GctHFRingEtSumsCollection *hfRingSums, const L1GctHFBitCountsCollection *hfBitCounts, const L1GctHtMissCollection *htMiss)
Writes GCT output jet cands and counts into an unsigned char array, starting at the position pointed ...
bool convertBlock(const unsigned char *d, const GctBlockHeader &hdr) override
Get digis from the block - will return true if it succeeds, false otherwise.
void blockToGctEmCandsAndEnergySums(const unsigned char *d, const GctBlockHeader &hdr)
unpack GCT EM Candidates and energy sums.
std::vector< L1GctEtTotal > L1GctEtTotalCollection
std::vector< L1GctHFBitCounts > L1GctHFBitCountsCollection
std::vector< L1GctJetCand > L1GctJetCandCollection
GctFormatTranslateMCLegacy(bool hltMode=false, bool unpackSharedRegions=false)
Constructor.
static const BlockLengthMap m_blockLength
Map to translate block number to fundamental size of a block (i.e. for 1 time-sample).
GctBlockHeader generateBlockHeader(const unsigned char *data) const override
Generate a block header from four 8-bit values.
Simple class for holding the basic attributes of an 32-bit block header.
const BlockLengthMap & blockLengthMap() const final
get the static block ID to block-length map.
void(GctFormatTranslateMCLegacy::* PtrToUnpackFn)(const unsigned char *, const GctBlockHeader &)
Function pointer typdef to a block unpack function.
void blockToRctEmCand(const unsigned char *d, const GctBlockHeader &hdr)
unpack RCT EM Candidates
std::map< unsigned int, unsigned int > BlockLengthMap
Block ID to Block Length map.
bool hltMode() const
Protected interface to get HLT optimisation mode flag.
constexpr size_t nSamples
~GctFormatTranslateMCLegacy() override
Destructor.
std::vector< L1GctHtMiss > L1GctHtMissCollection
void blockToGctJetCandsAndCounts(const unsigned char *d, const GctBlockHeader &hdr)
Unpack GCT Jet Candidates and jet counts.
const BlockIdToEmCandIsoBoundMap & internEmIsoBounds() const final
get the static intern EM cand isolated boundary map.
JetCorrectorParametersCollection coll
Definition: classes.h:10
Unpacks/packs the MC Legacy data originally produced by the GctBlockPacker class. ...
static const BlkToRctCrateMap m_rctJetCrate
Map to relate capture block ID to the RCT crate the data originated from (for jets).
static const BlockIdToUnpackFnMap m_blockUnpackFn
Block ID to unpack function map.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void blockToFibres(const unsigned char *d, const GctBlockHeader &hdr)
unpack Fibres
static const BlkToRctCrateMap m_rctEmCrate
Map to relate capture block ID to the RCT crate the data originated from (for electrons).
std::map< unsigned int, IsoBoundaryPair > BlockIdToEmCandIsoBoundMap
A typdef for mapping Block IDs to IsoBoundaryPairs.
std::vector< L1CaloRegion > L1CaloRegionCollection
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.
std::map< unsigned int, PtrToUnpackFn > BlockIdToUnpackFnMap
Typedef for a block ID to unpack function map.
bool findBx0OffsetInCollection(unsigned &bx0Offset, const Collection *coll)
Template function (used in packing) that will find the offset to first item in a collection vector wh...
void blockToAllRctCaloRegions(const unsigned char *d, const GctBlockHeader &hdr)
Unpack All RCT Calo Regions (&#39;orrible hack for DigiToRaw use)
static const BlockIdToEmCandIsoBoundMap m_internEmIsoBounds
std::vector< L1GctEmCand > L1GctEmCandCollection