CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
GctRawToDigi Class Reference

#include <EventFilter/GctRawToDigi/src/GctRawToDigi.cc>

Inheritance diagram for GctRawToDigi:
edm::stream::EDProducer<>

Public Member Functions

 GctRawToDigi (const edm::ParameterSet &)
 
 ~GctRawToDigi () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void addError (const unsigned code)
 
bool autoDetectRequiredFormatTranslator (const unsigned char *data)
 Looks at the firmware version header in the S-Link packet and instantiates relevant format translator. More...
 
void checkHeaders ()
 check block headers for consistency More...
 
void doVerboseOutput (const GctBlockHeaderCollection &bHdrs, const GctUnpackCollections *const colls) const
 Prints out a list of blocks and the various numbers of trigger objects that have been unpacked from them. More...
 
virtual void endJob ()
 method called at job end - use to print summary report More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void unpack (const FEDRawData &d, edm::Event &e, GctUnpackCollections *const colls)
 Unpacks the raw data. More...
 

Private Attributes

GctBlockHeaderCollection blockHeaders_
 
const bool checkHeaders_
 If true, check block headers for synchronisation. More...
 
std::vector< unsigned > errorCounters_
 Counts number of errors for each code (index) More...
 
L1TriggerErrorCollectionerrors_
 pointer to error collection More...
 
int fedId_
 GCT FED ID. More...
 
GctFormatTranslateBaseformatTranslator_
 pointer to the block-to-digi converter More...
 
const unsigned formatVersion_
 Defines unpacker verison to be used (e.g.: "Auto-detect", "MCLegacy", "V35", etc). More...
 
const bool hltMode_
 If true, only outputs the GCT data sent to the GT (number of BXs defined by numberOfGctSamplesToUnpack_) More...
 
edm::InputTag inputLabel_
 FED collection label. More...
 
const unsigned numberOfGctSamplesToUnpack_
 Number of BXs of GCT data to unpack (assuming they are in the raw data) More...
 
const unsigned numberOfRctSamplesToUnpack_
 Number of BXs of RCT data to unpack (assuming they are in the raw data) More...
 
unsigned unpackFailures_
 To count the total number of GCT unpack failures. More...
 
const bool unpackSharedRegions_
 Commissioning option: if true, where applicable the shared RCT calo regions will also be unpacked. More...
 
const bool verbose_
 If true, then debug print out for each event. More...
 

Static Private Attributes

static const unsigned MAX_BLOCKS = 256
 The maximum number of blocks we will try to unpack before thinking something is wrong. More...
 
static const unsigned MAX_ERR_CODE = 6
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: Produce GCT digis from raw data

Implementation: <Notes on="" implementation>="">

Definition at line 43 of file GctRawToDigi.h.

Constructor & Destructor Documentation

◆ GctRawToDigi()

GctRawToDigi::GctRawToDigi ( const edm::ParameterSet iConfig)
explicit

Register Products

Definition at line 34 of file GctRawToDigi.cc.

References fedId_, formatTranslator_, formatVersion_, hltMode_, inputLabel_, LogDebug, numberOfGctSamplesToUnpack_, numberOfRctSamplesToUnpack_, and unpackSharedRegions_.

35  : inputLabel_(iConfig.getParameter<edm::InputTag>("inputLabel")),
37  hltMode_(iConfig.getParameter<bool>("hltMode")),
38  numberOfGctSamplesToUnpack_(iConfig.getParameter<unsigned>("numberOfGctSamplesToUnpack")),
39  numberOfRctSamplesToUnpack_(iConfig.getParameter<unsigned>("numberOfRctSamplesToUnpack")),
40  unpackSharedRegions_(iConfig.getParameter<bool>("unpackSharedRegions")),
41  formatVersion_(iConfig.getParameter<unsigned>("unpackerVersion")),
42  checkHeaders_(iConfig.getUntrackedParameter<bool>("checkHeaders", false)),
43  verbose_(iConfig.getUntrackedParameter<bool>("verbose", false)),
44  formatTranslator_(nullptr),
45  errors_(nullptr),
46  errorCounters_(MAX_ERR_CODE + 1), // initialise with the maximum error codes!
47  unpackFailures_(0) {
48  LogDebug("GCT") << "GctRawToDigi will unpack FED Id " << fedId_;
49 
50  // If the GctFormatTranslate version has been forced from config file, instantiate the relevant one.
51  /*** THIS OBVIOUSLY STINKS - NEED TO REPLACE WITH SOMETHING BETTER THAN MASSIVE IF-ELSE SOON ***/
52  /*** WHEN THIS MESS IS REMOVED REMEMBER THAT THE V38 FORMAT TRANSLATE HAS A DIFERENT CTOR TO THE OTHERS ***/
53  if (formatVersion_ == 0) {
54  edm::LogInfo("GCT")
55  << "The required GCT Format Translator will be automatically determined from the first S-Link packet header.";
56  } else if (formatVersion_ == 1) {
57  edm::LogInfo("GCT") << "You have selected to use GctFormatTranslateMCLegacy";
59  } else if (formatVersion_ == 2) {
60  edm::LogInfo("GCT") << "You have selected to use GctFormatTranslateV35";
62  } else if (formatVersion_ == 3) {
63  edm::LogInfo("GCT") << "You have selected to use GctFormatTranslateV38";
66  } else {
67  edm::LogWarning("GCT")
68  << "You have requested a version of GctFormatTranslate that does not exist! Will attempt to auto-detect "
69  "the required GCT Format Translator from the first S-Link packet header instead.";
70  }
71 
72  if (hltMode_) {
73  edm::LogInfo("GCT") << "HLT unpack mode selected: HLT unpack optimisations will be used.";
74  }
76  edm::LogInfo("GCT") << "You have selected to unpack shared RCT calo regions - be warned: "
77  "this is for commissioning purposes only!";
78  }
79 
81  // GCT input collections
82  produces<L1GctFibreCollection>();
83  produces<L1CaloEmCollection>();
84  produces<L1CaloRegionCollection>();
85 
86  // GCT internal collections
87  produces<L1GctInternEmCandCollection>();
88  produces<L1GctInternJetDataCollection>();
89  produces<L1GctInternEtSumCollection>();
90  produces<L1GctInternHFDataCollection>();
91  produces<L1GctInternHtMissCollection>();
92 
93  // GCT output collections
94  produces<L1GctEmCandCollection>("isoEm");
95  produces<L1GctEmCandCollection>("nonIsoEm");
96  produces<L1GctJetCandCollection>("cenJets");
97  produces<L1GctJetCandCollection>("forJets");
98  produces<L1GctJetCandCollection>("tauJets");
99  produces<L1GctHFBitCountsCollection>();
100  produces<L1GctHFRingEtSumsCollection>();
101  produces<L1GctEtTotalCollection>();
102  produces<L1GctEtHadCollection>();
103  produces<L1GctEtMissCollection>();
104  produces<L1GctHtMissCollection>();
105  produces<L1GctJetCountsCollection>(); // Deprecated (empty collection still needed by GT)
106 
107  // Error collection
108  produces<L1TriggerErrorCollection>();
109  consumes<FEDRawDataCollection>(inputLabel_);
110 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const bool unpackSharedRegions_
Commissioning option: if true, where applicable the shared RCT calo regions will also be unpacked...
Definition: GctRawToDigi.h:88
const unsigned numberOfGctSamplesToUnpack_
Number of BXs of GCT data to unpack (assuming they are in the raw data)
Definition: GctRawToDigi.h:84
const bool hltMode_
If true, only outputs the GCT data sent to the GT (number of BXs defined by numberOfGctSamplesToUnpac...
Definition: GctRawToDigi.h:82
Unpacks/packs the V38 raw format.
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag inputLabel_
FED collection label.
Definition: GctRawToDigi.h:78
const unsigned formatVersion_
Defines unpacker verison to be used (e.g.: "Auto-detect", "MCLegacy", "V35", etc).
Definition: GctRawToDigi.h:89
unsigned unpackFailures_
To count the total number of GCT unpack failures.
Definition: GctRawToDigi.h:103
Unpacks/packs the V35 raw format.
const unsigned numberOfRctSamplesToUnpack_
Number of BXs of RCT data to unpack (assuming they are in the raw data)
Definition: GctRawToDigi.h:86
const bool verbose_
If true, then debug print out for each event.
Definition: GctRawToDigi.h:91
Log< level::Info, false > LogInfo
const bool checkHeaders_
If true, check block headers for synchronisation.
Definition: GctRawToDigi.h:90
static const unsigned MAX_ERR_CODE
Definition: GctRawToDigi.h:100
Unpacks/packs the MC Legacy data originally produced by the GctBlockPacker class. ...
int fedId_
GCT FED ID.
Definition: GctRawToDigi.h:79
std::vector< unsigned > errorCounters_
Counts number of errors for each code (index)
Definition: GctRawToDigi.h:102
GctFormatTranslateBase * formatTranslator_
pointer to the block-to-digi converter
Definition: GctRawToDigi.h:94
Log< level::Warning, false > LogWarning
L1TriggerErrorCollection * errors_
pointer to error collection
Definition: GctRawToDigi.h:101
#define LogDebug(id)

◆ ~GctRawToDigi()

GctRawToDigi::~GctRawToDigi ( )
override

Definition at line 112 of file GctRawToDigi.cc.

References formatTranslator_.

112  {
113  // do anything here that needs to be done at destruction time
114  // (e.g. close files, deallocate resources etc.)
115  delete formatTranslator_;
116 }
GctFormatTranslateBase * formatTranslator_
pointer to the block-to-digi converter
Definition: GctRawToDigi.h:94

Member Function Documentation

◆ addError()

void GctRawToDigi::addError ( const unsigned  code)
private

Definition at line 291 of file GctRawToDigi.cc.

References errorCounters_, errors_, fedId_, LogDebug, MAX_ERR_CODE, and verbose_.

Referenced by autoDetectRequiredFormatTranslator(), produce(), and unpack().

291  {
292  // check this isn't going to break error handling
293  if (code > MAX_ERR_CODE) {
294  LogDebug("GCT") << "Unknown error code : " << code;
295  return;
296  }
297 
298  // print message on first instance of this error and if verbose flag set to true
299  if (errorCounters_.at(code) == 0 && verbose_) {
300  std::ostringstream os;
301  switch (code) {
302  case 0:
303  os << "Reserved error code - not in use";
304  break;
305  case 1:
306  os << "FED record empty or too short";
307  break;
308  case 2:
309  os << "Unknown raw data version";
310  break;
311  case 3:
312  os << "Detected unknown firmware version";
313  break;
314  case 4:
315  os << "Detected unknown data block";
316  break;
317  case 5:
318  os << "Block headers out of sync";
319  break;
320  case 6:
321  os << "Too many blocks";
322  break;
323  default:
324  os << "Unknown error code";
325  }
326  edm::LogError("GCT") << "Unpacking error " << code << " : " << os.str();
327  }
328 
329  // increment error counter
330  ++(errorCounters_.at(code));
331 
332  // store error in event if possible
333  if (errors_ != nullptr) {
334  errors_->push_back(L1TriggerError(fedId_, code));
335  } else
336  LogDebug("GCT") << "Detected error (code=" << code << ") but no error collection available!";
337 }
Log< level::Error, false > LogError
const bool verbose_
If true, then debug print out for each event.
Definition: GctRawToDigi.h:91
static const unsigned MAX_ERR_CODE
Definition: GctRawToDigi.h:100
int fedId_
GCT FED ID.
Definition: GctRawToDigi.h:79
std::vector< unsigned > errorCounters_
Counts number of errors for each code (index)
Definition: GctRawToDigi.h:102
L1TriggerErrorCollection * errors_
pointer to error collection
Definition: GctRawToDigi.h:101
#define LogDebug(id)

◆ autoDetectRequiredFormatTranslator()

bool GctRawToDigi::autoDetectRequiredFormatTranslator ( const unsigned char *  data)
private

Looks at the firmware version header in the S-Link packet and instantiates relevant format translator.

Returns false if it fails to instantiate a Format Translator

Definition at line 238 of file GctRawToDigi.cc.

References addError(), ztail::d, TauDecayModes::dec, formatTranslator_, hltMode_, LogDebug, numberOfGctSamplesToUnpack_, numberOfRctSamplesToUnpack_, and unpackSharedRegions_.

Referenced by produce().

238  {
239  LogDebug("GCT") << "About to auto-detect the required format translator from the firmware version header.";
240 
241  const uint32_t* p32 = reinterpret_cast<const uint32_t*>(d);
242  unsigned firmwareHeader = p32[2];
243 
244  /*** THIS OBVIOUSLY STINKS - NEED TO REPLACE WITH SOMETHING BETTER THAN MASSIVE IF-ELSE SOON ***/
245  /*** WHEN THIS MESS IS REMOVED REMEMBER THAT THE V38 FORMAT TRANSLATE HAS A DIFERENT CTOR TO THE OTHERS ***/
246 
247  if (firmwareHeader >= 25 && firmwareHeader <= 35) {
248  edm::LogInfo("GCT") << "Firmware Version V" << firmwareHeader << " detected: GctFormatTranslateV" << firmwareHeader
249  << " will be used to unpack.";
251  return true;
252  } else if (firmwareHeader == 38) {
253  edm::LogInfo("GCT") << "Firmware Version V" << firmwareHeader << " detected: GctFormatTranslateV" << firmwareHeader
254  << " will be used to unpack.";
257  return true;
258  } else if (firmwareHeader == 0x00000000) {
259  edm::LogInfo("GCT") << "Legacy Monte-Carlo data detected: GctFormatTranslateMCLegacy will be used to unpack.";
261  return true;
262  }
263  // these lines comments otherwise error is not reported!!!
264  // else if(firmwareHeader == 0xdeadffff) { /* Driver detected unknown firmware version. L1TriggerError code? */ }
265  // else if( firmwareHeader == 0xaaaaaaaa) { /* Before driver firmware version checks implemented. L1TriggerError code? */ }
266  else { /* Totally unknown firmware header */
267 
268  LogDebug("GCT") << "Failed to determine unpacker to use from the firmware version header! "
269  "(firmware header = 0x"
270  << hex << firmwareHeader << dec << ")";
271  addError(2);
272  return false;
273  }
274 }
const bool unpackSharedRegions_
Commissioning option: if true, where applicable the shared RCT calo regions will also be unpacked...
Definition: GctRawToDigi.h:88
const unsigned numberOfGctSamplesToUnpack_
Number of BXs of GCT data to unpack (assuming they are in the raw data)
Definition: GctRawToDigi.h:84
void addError(const unsigned code)
const bool hltMode_
If true, only outputs the GCT data sent to the GT (number of BXs defined by numberOfGctSamplesToUnpac...
Definition: GctRawToDigi.h:82
Unpacks/packs the V38 raw format.
Unpacks/packs the V35 raw format.
const unsigned numberOfRctSamplesToUnpack_
Number of BXs of RCT data to unpack (assuming they are in the raw data)
Definition: GctRawToDigi.h:86
d
Definition: ztail.py:151
Log< level::Info, false > LogInfo
Unpacks/packs the MC Legacy data originally produced by the GctBlockPacker class. ...
GctFormatTranslateBase * formatTranslator_
pointer to the block-to-digi converter
Definition: GctRawToDigi.h:94
#define LogDebug(id)

◆ checkHeaders()

void GctRawToDigi::checkHeaders ( )
private

check block headers for consistency

Definition at line 276 of file GctRawToDigi.cc.

Referenced by produce().

276  {
277  // TODO : loop over block headers found this event and check for consistency
278 }

◆ doVerboseOutput()

void GctRawToDigi::doVerboseOutput ( const GctBlockHeaderCollection bHdrs,
const GctUnpackCollections *const  colls 
) const
private

Prints out a list of blocks and the various numbers of trigger objects that have been unpacked from them.

Definition at line 280 of file GctRawToDigi.cc.

References formatTranslator_, GctFormatTranslateBase::getBlockDescription(), mps_fire::i, and findQualityFiles::size.

Referenced by produce().

281  {
282  std::ostringstream os;
283  os << "Found " << bHdrs.size() << " GCT block headers" << endl;
284  for (unsigned i = 0, size = bHdrs.size(); i < size; ++i) {
285  os << "GCT Raw Data Block : " << formatTranslator_->getBlockDescription(bHdrs[i]) << " : " << bHdrs[i] << endl;
286  }
287  os << *colls << endl;
288  edm::LogVerbatim("GCT") << os.str();
289 }
size
Write out results.
Log< level::Info, true > LogVerbatim
const std::string & getBlockDescription(const GctBlockHeader &header) const
Get block description.
GctFormatTranslateBase * formatTranslator_
pointer to the block-to-digi converter
Definition: GctRawToDigi.h:94

◆ endJob()

void GctRawToDigi::endJob ( void  )
privatevirtual

method called at job end - use to print summary report

Definition at line 340 of file GctRawToDigi.cc.

References errorCounters_, mps_fire::i, MAX_ERR_CODE, dqmMemoryStats::total, and verbose_.

340  {
341  unsigned total = 0;
342  std::ostringstream os;
343 
344  for (unsigned i = 0; i <= MAX_ERR_CODE; ++i) {
345  total += errorCounters_.at(i);
346  os << "Error " << i << " (" << errorCounters_.at(i) << ")";
347  if (i < MAX_ERR_CODE) {
348  os << ", ";
349  }
350  }
351 
352  if (total > 0 && verbose_) {
353  edm::LogError("GCT") << "Encountered " << total << " unpacking errors: " << os.str();
354  }
355 }
Log< level::Error, false > LogError
const bool verbose_
If true, then debug print out for each event.
Definition: GctRawToDigi.h:91
static const unsigned MAX_ERR_CODE
Definition: GctRawToDigi.h:100
std::vector< unsigned > errorCounters_
Counts number of errors for each code (index)
Definition: GctRawToDigi.h:102

◆ fillDescriptions()

void GctRawToDigi::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 118 of file GctRawToDigi.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and kComment.

118  {
120  desc.add<bool>("unpackSharedRegions", false);
121  desc.add<unsigned int>("numberOfGctSamplesToUnpack", 1);
122  desc.add<unsigned int>("numberOfRctSamplesToUnpack", 1);
123  desc.add<bool>("hltMode", false);
124  desc.add<edm::InputTag>("inputLabel", edm::InputTag("rawDataCollector"));
125  static const char* const kComment =
126  " \n"
127  " value | Unpacker/RAW Format Version \n"
128  "-----------|---------------------------------------------------------------------------- \n"
129  " 0 | Auto-detects RAW Format in use - the recommended option \n"
130  " 1 | Force usage of the Monte-Carlo Legacy unpacker (unpacks DigiToRaw events) \n"
131  " 2 | Force usage of the RAW Format V35 unpacker \n"
132  " 3 | Force usage of the RAW Format V38 unpacker \n";
133  desc.add<unsigned int>("unpackerVersion", 0)->setComment(kComment);
134  desc.addUntracked<int>("gctFedId", 745);
135  desc.addUntracked<bool>("checkHeaders", false), desc.addUntracked<bool>("verbose", false);
136  descriptions.add("gctRawToDigi", desc);
137 }
static const char *const kComment
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void GctRawToDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 144 of file GctRawToDigi.cc.

References addError(), autoDetectRequiredFormatTranslator(), blockHeaders_, checkHeaders(), checkHeaders_, FEDRawData::data(), TauDecayModes::dec, doVerboseOutput(), errors_, fedId_, l1tstage2emulator_dqm_sourceclient-live_cfg::feds, formatTranslator_, iEvent, inputLabel_, LogDebug, FEDRawData::size(), unpack(), and verbose_.

144  {
145  using namespace edm;
146 
147  // Instantiate all the collections the unpacker needs; puts them in event when this object goes out of scope.
148  std::unique_ptr<GctUnpackCollections> colls(new GctUnpackCollections(iEvent));
149  errors_ = colls->errors();
150 
151  // get raw data collection
153  iEvent.getByLabel(inputLabel_, feds);
154 
155  // if raw data collection is present, do the unpacking
156  if (feds.isValid()) {
157  const FEDRawData& gctRcd = feds->FEDData(fedId_);
158 
159  LogDebug("GCT") << "Upacking FEDRawData of size " << std::dec << gctRcd.size();
160 
161  // check for empty events
162  if (gctRcd.size() < 16) {
163  LogDebug("GCT") << "Cannot unpack: empty/invalid GCT raw data (size = " << gctRcd.size()
164  << "). Returning empty collections!";
165  addError(1);
166  return;
167  }
168 
169  // If no format translator yet set, need to auto-detect from header.
170  // If auto format detection fails, we have no concrete format
171  // translator instantiated... set error and bail
172  if (!formatTranslator_) {
174  return;
175  }
176 
177  // reset collection of block headers
178  blockHeaders_.clear();
179 
180  // do the unpacking
181  unpack(gctRcd, iEvent, colls.get());
182 
183  // check headers, if enabled
184  if (checkHeaders_)
185  checkHeaders();
186 
187  // dump summary in verbose mode
188  if (verbose_) {
189  doVerboseOutput(blockHeaders_, colls.get());
190  }
191  }
192 }
bool autoDetectRequiredFormatTranslator(const unsigned char *data)
Looks at the firmware version header in the S-Link packet and instantiates relevant format translator...
GctBlockHeaderCollection blockHeaders_
Definition: GctRawToDigi.h:97
void addError(const unsigned code)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
void checkHeaders()
check block headers for consistency
edm::InputTag inputLabel_
FED collection label.
Definition: GctRawToDigi.h:78
int iEvent
Definition: GenABIO.cc:224
RAII and useful methods for the many dataformat collections required by the GCT unpacker.
const bool verbose_
If true, then debug print out for each event.
Definition: GctRawToDigi.h:91
const bool checkHeaders_
If true, check block headers for synchronisation.
Definition: GctRawToDigi.h:90
int fedId_
GCT FED ID.
Definition: GctRawToDigi.h:79
void unpack(const FEDRawData &d, edm::Event &e, GctUnpackCollections *const colls)
Unpacks the raw data.
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
GctFormatTranslateBase * formatTranslator_
pointer to the block-to-digi converter
Definition: GctRawToDigi.h:94
void doVerboseOutput(const GctBlockHeaderCollection &bHdrs, const GctUnpackCollections *const colls) const
Prints out a list of blocks and the various numbers of trigger objects that have been unpacked from t...
L1TriggerErrorCollection * errors_
pointer to error collection
Definition: GctRawToDigi.h:101
#define LogDebug(id)

◆ unpack()

void GctRawToDigi::unpack ( const FEDRawData d,
edm::Event e,
GctUnpackCollections *const  colls 
)
private

Unpacks the raw data.

Parameters
invalidDataFlag- if true, then won't attempt unpack but just output empty collecions.

Definition at line 194 of file GctRawToDigi.cc.

References addError(), blockHeaders_, GctBlockHeader::blockLength(), checkHeaders_, GctFormatTranslateBase::convertBlock(), ztail::d, data, formatTranslator_, GctFormatTranslateBase::generateBlockHeader(), LogDebug, MAX_BLOCKS, GctBlockHeader::nSamples(), GctFormatTranslateBase::setUnpackCollections(), and verbose_.

Referenced by produce().

194  {
195  // We should now have a valid formatTranslator pointer
197 
198  const unsigned char* data = d.data(); // The 8-bit wide raw-data array.
199 
200  // Data offset - starts at 16 as there is a 64-bit S-Link header followed
201  // by a 64-bit software-controlled header (for pipeline format version
202  // info that is not yet used).
203  unsigned dPtr = 16;
204 
205  const unsigned dEnd = d.size() - 8; // End of payload is at (packet size - final slink header)
206 
207  // read blocks
208  for (unsigned nb = 0; dPtr < dEnd; ++nb) {
209  if (nb >= MAX_BLOCKS) {
210  LogDebug("GCT") << "Reached block limit - bailing out from this event!";
211  addError(6);
212  break;
213  }
214 
215  // read block header
217 
218  // unpack the block; dPtr+4 is to get to the block data.
219  if (!formatTranslator_->convertBlock(&data[dPtr + 4],
220  blockHeader)) // Record if we had an unpack problem then skip rest of event.
221  {
222  LogDebug("GCT") << "Encountered block unpack error - bailing out from this event!";
223  addError(4);
224  break;
225  }
226 
227  // advance pointer
228  dPtr += 4 * (blockHeader.blockLength() * blockHeader.nSamples() +
229  1); // *4 because blockLen is in 32-bit words, +1 for header
230 
231  // if verbose or checking block headers, store the header
232  if (verbose_ || checkHeaders_)
233  blockHeaders_.push_back(blockHeader);
234  }
235 }
GctBlockHeaderCollection blockHeaders_
Definition: GctRawToDigi.h:97
void addError(const unsigned code)
static const unsigned MAX_BLOCKS
The maximum number of blocks we will try to unpack before thinking something is wrong.
Definition: GctRawToDigi.h:75
virtual bool convertBlock(const unsigned char *d, const GctBlockHeader &hdr)=0
Get digis from the block - will return true if it succeeds, false otherwise.
uint32_t blockLength() const
Get the fundamental block length (for 1 time sample)
Simple class for holding the basic attributes of an 32-bit block header.
d
Definition: ztail.py:151
const bool verbose_
If true, then debug print out for each event.
Definition: GctRawToDigi.h:91
const bool checkHeaders_
If true, check block headers for synchronisation.
Definition: GctRawToDigi.h:90
uint32_t nSamples() const
Get the number of time samples.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void setUnpackCollections(GctUnpackCollections *const collections)
Set the pointer to the unpack collections.
GctFormatTranslateBase * formatTranslator_
pointer to the block-to-digi converter
Definition: GctRawToDigi.h:94
#define LogDebug(id)
virtual GctBlockHeader generateBlockHeader(const unsigned char *data) const =0
Generate a block header from four 8-bit values.

Member Data Documentation

◆ blockHeaders_

GctBlockHeaderCollection GctRawToDigi::blockHeaders_
private

Definition at line 97 of file GctRawToDigi.h.

Referenced by produce(), and unpack().

◆ checkHeaders_

const bool GctRawToDigi::checkHeaders_
private

If true, check block headers for synchronisation.

Definition at line 90 of file GctRawToDigi.h.

Referenced by produce(), and unpack().

◆ errorCounters_

std::vector<unsigned> GctRawToDigi::errorCounters_
private

Counts number of errors for each code (index)

Definition at line 102 of file GctRawToDigi.h.

Referenced by addError(), and endJob().

◆ errors_

L1TriggerErrorCollection* GctRawToDigi::errors_
private

pointer to error collection

Definition at line 101 of file GctRawToDigi.h.

Referenced by addError(), and produce().

◆ fedId_

int GctRawToDigi::fedId_
private

GCT FED ID.

Definition at line 79 of file GctRawToDigi.h.

Referenced by addError(), GctRawToDigi(), and produce().

◆ formatTranslator_

GctFormatTranslateBase* GctRawToDigi::formatTranslator_
private

pointer to the block-to-digi converter

Definition at line 94 of file GctRawToDigi.h.

Referenced by autoDetectRequiredFormatTranslator(), doVerboseOutput(), GctRawToDigi(), produce(), unpack(), and ~GctRawToDigi().

◆ formatVersion_

const unsigned GctRawToDigi::formatVersion_
private

Defines unpacker verison to be used (e.g.: "Auto-detect", "MCLegacy", "V35", etc).

Definition at line 89 of file GctRawToDigi.h.

Referenced by GctRawToDigi().

◆ hltMode_

const bool GctRawToDigi::hltMode_
private

If true, only outputs the GCT data sent to the GT (number of BXs defined by numberOfGctSamplesToUnpack_)

Definition at line 82 of file GctRawToDigi.h.

Referenced by autoDetectRequiredFormatTranslator(), and GctRawToDigi().

◆ inputLabel_

edm::InputTag GctRawToDigi::inputLabel_
private

FED collection label.

Definition at line 78 of file GctRawToDigi.h.

Referenced by GctRawToDigi(), and produce().

◆ MAX_BLOCKS

const unsigned GctRawToDigi::MAX_BLOCKS = 256
staticprivate

The maximum number of blocks we will try to unpack before thinking something is wrong.

Definition at line 75 of file GctRawToDigi.h.

Referenced by unpack().

◆ MAX_ERR_CODE

const unsigned GctRawToDigi::MAX_ERR_CODE = 6
staticprivate

Definition at line 100 of file GctRawToDigi.h.

Referenced by addError(), and endJob().

◆ numberOfGctSamplesToUnpack_

const unsigned GctRawToDigi::numberOfGctSamplesToUnpack_
private

Number of BXs of GCT data to unpack (assuming they are in the raw data)

Definition at line 84 of file GctRawToDigi.h.

Referenced by autoDetectRequiredFormatTranslator(), and GctRawToDigi().

◆ numberOfRctSamplesToUnpack_

const unsigned GctRawToDigi::numberOfRctSamplesToUnpack_
private

Number of BXs of RCT data to unpack (assuming they are in the raw data)

Definition at line 86 of file GctRawToDigi.h.

Referenced by autoDetectRequiredFormatTranslator(), and GctRawToDigi().

◆ unpackFailures_

unsigned GctRawToDigi::unpackFailures_
private

To count the total number of GCT unpack failures.

Definition at line 103 of file GctRawToDigi.h.

◆ unpackSharedRegions_

const bool GctRawToDigi::unpackSharedRegions_
private

Commissioning option: if true, where applicable the shared RCT calo regions will also be unpacked.

Definition at line 88 of file GctRawToDigi.h.

Referenced by autoDetectRequiredFormatTranslator(), and GctRawToDigi().

◆ verbose_

const bool GctRawToDigi::verbose_
private

If true, then debug print out for each event.

Definition at line 91 of file GctRawToDigi.h.

Referenced by addError(), endJob(), produce(), and unpack().