1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
#ifndef GctFormatTranslateMCLegacy_h_
#define GctFormatTranslateMCLegacy_h_
#include "EventFilter/GctRawToDigi/src/GctFormatTranslateBase.h"
/*!
* \class GctFormatTranslateMCLegacy
* \brief Unpacks/packs the MC Legacy data originally produced by the GctBlockPacker class.
*
* The data produced by the legacy GctBlockPacker class should have a firmware version header
* that wasn't set to anything, i.e.: 0x00000000
*
* \author Robert Frazier
*/
// ************************************************************************
// *** THE TRANSLATION PROCESS MUST NEVER THROW ANY KIND OF EXCEPTION! ***
// ************************************************************************
class GctFormatTranslateMCLegacy : public GctFormatTranslateBase {
public:
/* PUBLIC METHODS */
/// Constructor.
/*! \param hltMode - set true to unpack only BX zero and GCT output data (i.e. to run as quick as possible).
* \param unpackSharedRegions - this is a commissioning option to unpack the shared RCT calo regions. */
explicit GctFormatTranslateMCLegacy(bool hltMode = false, bool unpackSharedRegions = false);
~GctFormatTranslateMCLegacy() override; ///< Destructor.
/// Generate a block header from four 8-bit values.
GctBlockHeader generateBlockHeader(const unsigned char* data) const override;
/// Get digis from the block - will return true if it succeeds, false otherwise.
bool convertBlock(const unsigned char* d, const GctBlockHeader& hdr) override;
/* ------------------------------ */
/* Public Block Packing Functions */
/* ------------------------------ */
/// Writes GCT output EM and energy sums block into an unsigned char array, starting at the position pointed to by d.
/*! \param d must be pointing at the position where the EM Output block header should be written! */
void writeGctOutEmAndEnergyBlock(unsigned char* d,
const L1GctEmCandCollection* iso,
const L1GctEmCandCollection* nonIso,
const L1GctEtTotalCollection* etTotal,
const L1GctEtHadCollection* etHad,
const L1GctEtMissCollection* etMiss);
/// Writes GCT output jet cands and counts into an unsigned char array, starting at the position pointed to by d.
/*! \param d must be pointing at the position where the Jet Output block header should be written! */
void writeGctOutJetBlock(unsigned char* d,
const L1GctJetCandCollection* cenJets,
const L1GctJetCandCollection* forJets,
const L1GctJetCandCollection* tauJets,
const L1GctHFRingEtSumsCollection* hfRingSums,
const L1GctHFBitCountsCollection* hfBitCounts,
const L1GctHtMissCollection* htMiss);
/// Writes the 4 RCT EM Candidate blocks.
void writeRctEmCandBlocks(unsigned char* d, const L1CaloEmCollection* rctEm);
/// Writes the giant hack that is the RCT Calo Regions block.
void writeAllRctCaloRegionBlock(unsigned char* d, const L1CaloRegionCollection* rctCalo);
protected:
/* PROTECTED METHODS */
/* Static data member access methods */
const BlockLengthMap& blockLengthMap() const final {
return m_blockLength;
} ///< get the static block ID to block-length map.
const BlockNameMap& blockNameMap() const final { return m_blockName; } ///< get the static block ID to blockname map.
const BlkToRctCrateMap& rctEmCrateMap() const final {
return m_rctEmCrate;
} ///< get static the block ID to RCT crate map for electrons.
const BlkToRctCrateMap& rctJetCrateMap() const final {
return m_rctJetCrate;
} ///< get the static block ID to RCT crate map for jets
const BlockIdToEmCandIsoBoundMap& internEmIsoBounds() const final {
return m_internEmIsoBounds;
} ///< get the static intern EM cand isolated boundary map.
/* Other general methods */
/// Returns a raw 32-bit header word generated from the blockId, number of time samples, bunch-crossing and event IDs.
uint32_t generateRawHeader(const uint32_t blockId,
const uint32_t nSamples,
const uint32_t bxId,
const uint32_t eventId) const override;
private:
/* PRIVATE TYPES & TYPEDEFS */
/// Function pointer typdef to a block unpack function.
typedef void (GctFormatTranslateMCLegacy::*PtrToUnpackFn)(const unsigned char*, const GctBlockHeader&);
/// Typedef for a block ID to unpack function map.
typedef std::map<unsigned int, PtrToUnpackFn> BlockIdToUnpackFnMap;
/* PRIVATE MEMBER DATA */
/// Map to translate block number to fundamental size of a block (i.e. for 1 time-sample).
static const BlockLengthMap m_blockLength;
/// Map to hold a description for each block number.
static const BlockNameMap m_blockName;
/// Map to relate capture block ID to the RCT crate the data originated from (for electrons).
static const BlkToRctCrateMap m_rctEmCrate;
/// Map to relate capture block ID to the RCT crate the data originated from (for jets).
static const BlkToRctCrateMap m_rctJetCrate;
/*! A map of Block IDs to IsoBoundaryPairs for storing the location of the isolated
* Internal EM cands in the pipeline, as this differs with Block ID. */
static const BlockIdToEmCandIsoBoundMap m_internEmIsoBounds;
/// Block ID to unpack function map.
static const BlockIdToUnpackFnMap m_blockUnpackFn;
/* PRIVATE METHODS */
/* --------------------------------- */
/* Private Block Unpacking Functions */
/* --------------------------------- */
/// unpack GCT EM Candidates and energy sums.
void blockToGctEmCandsAndEnergySums(const unsigned char* d, const GctBlockHeader& hdr);
/// Unpack GCT Jet Candidates and jet counts.
void blockToGctJetCandsAndCounts(const unsigned char* d, const GctBlockHeader& hdr);
/// unpack RCT EM Candidates
void blockToRctEmCand(const unsigned char* d, const GctBlockHeader& hdr);
/// unpack Fibres
void blockToFibres(const unsigned char* d, const GctBlockHeader& hdr);
/// unpack Fibres and RCT EM Candidates
void blockToFibresAndToRctEmCand(const unsigned char* d, const GctBlockHeader& hdr);
/// Unpack All RCT Calo Regions ('orrible hack for DigiToRaw use)
void blockToAllRctCaloRegions(const unsigned char* d, const GctBlockHeader& hdr);
/* ----------------------------- */
/* Miscellaneous Private Methods */
/* ----------------------------- */
/// Template function (used in packing) that will find the offset to first item in a collection vector where bx=0.
/*! Returns false if fails to find any item in the collection with bx=0 */
template <typename Collection>
bool findBx0OffsetInCollection(unsigned& bx0Offset, const Collection* coll);
};
#endif
|