CMS 3D CMS Logo

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

#include <L1GlobalTriggerEvmRawToDigi.h>

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

Public Member Functions

 L1GlobalTriggerEvmRawToDigi (const edm::ParameterSet &)
 constructor(s) More...
 
 ~L1GlobalTriggerEvmRawToDigi () override
 destructor More...
 
- 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
 

Private Member Functions

void dumpFedRawData (const unsigned char *, int, std::ostream &)
 dump FED raw data More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void produceEmptyProducts (edm::Event &)
 produce empty products in case of problems More...
 
void unpackHeader (const unsigned char *, FEDHeader &)
 block unpackers More...
 
void unpackTrailer (const unsigned char *, FEDTrailer &)
 unpack trailer word More...
 

Private Attributes

cms_uint16_t m_activeBoardsMaskGt
 mask for active boards More...
 
int m_bstLengthBytes
 length of BST record (in bytes) More...
 
int m_evmGtFedId
 
edm::InputTag m_evmGtInputTag
 input tags for GT EVM record More...
 
L1GtFdlWordm_gtFdlWord
 
L1GtfeExtWordm_gtfeWord
 
bool m_isDebugEnabled
 
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcdm_l1GtBMToken
 EventSetup Token for L1GtBoardMaps. More...
 
edm::ESGetToken< L1GtParameters, L1GtParametersRcdm_l1GtParamToken
 EventSetup Token for L1GtParameters. More...
 
int m_lowSkipBxInEvent
 
int m_recordLength0
 total Bx's in the event, obtained from GTFE block More...
 
int m_recordLength1
 corresponding to alternative 1 in altNrBxBoard() More...
 
L1TcsWordm_tcsWord
 
int m_totalBxInEvent
 number of Bx for a board, obtained from GTFE block (record length & alternative) More...
 
int m_unpackBxInEvent
 
int m_uppSkipBxInEvent
 
int m_verbosity
 verbosity level More...
 

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: unpack EVM raw data into digitized data.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

Description: unpack raw data into digitized data.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

Definition at line 49 of file L1GlobalTriggerEvmRawToDigi.h.

Constructor & Destructor Documentation

◆ L1GlobalTriggerEvmRawToDigi()

L1GlobalTriggerEvmRawToDigi::L1GlobalTriggerEvmRawToDigi ( const edm::ParameterSet pSet)
explicit

constructor(s)

EventSetup Token for L1GtParameters

Definition at line 50 of file L1GlobaTriggerEvmRawToDigi.cc.

References TauDecayModes::dec, LogDebug, m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_gtFdlWord, m_gtfeWord, m_isDebugEnabled, m_l1GtParamToken, m_tcsWord, m_unpackBxInEvent, and m_verbosity.

51  :
52 
53  // input tag for EVM GT record
54  m_evmGtInputTag(pSet.getParameter<edm::InputTag>("EvmGtInputTag")),
55 
56  // FED Id for GT EVM record
57  // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
58  // default value: assume the EVM record is the first GT record
60 
62  m_l1GtBMToken(esConsumes<L1GtBoardMaps, L1GtBoardMapsRcd>()),
63 
64  // mask for active boards
65  m_activeBoardsMaskGt(pSet.getParameter<unsigned int>("ActiveBoardsMask")),
66 
67  // number of bunch crossing to be unpacked
68  m_unpackBxInEvent(pSet.getParameter<int>("UnpackBxInEvent")),
69 
72 
73  m_recordLength0(0),
74  m_recordLength1(0),
75 
77 
78  // length of BST record (in bytes)
79  m_bstLengthBytes(pSet.getParameter<int>("BstLengthBytes")),
80 
81  m_verbosity(pSet.getUntrackedParameter<int>("Verbosity", 0)),
82 
84 
85 {
86  produces<L1GlobalTriggerEvmReadoutRecord>();
87 
89  LogDebug("L1GlobalTriggerEvmRawToDigi")
90  << "\nInput tag for EVM GT record: " << m_evmGtInputTag
91  << "\nFED Id for EVM GT record: " << m_evmGtFedId
92  << "\nMask for active boards (hex format): " << std::hex << std::setw(sizeof(m_activeBoardsMaskGt) * 2)
93  << std::setfill('0') << m_activeBoardsMaskGt << std::dec << std::setfill(' ')
94  << "\nNumber of bunch crossing to be unpacked: " << m_unpackBxInEvent
95  << "\nLength of BST message [bytes]: " << m_bstLengthBytes << "\n"
96  << std::endl;
97  }
98 
99  if ((m_unpackBxInEvent > 0) && ((m_unpackBxInEvent % 2) == 0)) {
101 
102  if (m_verbosity) {
103  edm::LogInfo("L1GlobalTriggerEvmRawToDigi")
104  << "\nWARNING: Number of bunch crossing to be unpacked rounded to: " << m_unpackBxInEvent
105  << "\n The number must be an odd number!\n"
106  << std::endl;
107  }
108  }
109 
110  // create GTFE, TCS, FDL cards once per analyzer
111  // content will be reset whenever needed
112 
113  m_gtfeWord = new L1GtfeExtWord();
114  m_tcsWord = new L1TcsWord();
115  m_gtFdlWord = new L1GtFdlWord();
116  consumes<FEDRawDataCollection>(m_evmGtInputTag);
117 
119  if (m_bstLengthBytes < 0) {
120  m_l1GtParamToken = esConsumes<L1GtParameters, L1GtParametersRcd>();
121  }
122 }
int m_bstLengthBytes
length of BST record (in bytes)
bool isDebugEnabled()
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int m_totalBxInEvent
number of Bx for a board, obtained from GTFE block (record length & alternative)
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
EventSetup Token for L1GtBoardMaps.
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< L1GtParameters, L1GtParametersRcd > m_l1GtParamToken
EventSetup Token for L1GtParameters.
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
Log< level::Info, false > LogInfo
int m_recordLength0
total Bx&#39;s in the event, obtained from GTFE block
#define LogDebug(id)
edm::InputTag m_evmGtInputTag
input tags for GT EVM record

◆ ~L1GlobalTriggerEvmRawToDigi()

L1GlobalTriggerEvmRawToDigi::~L1GlobalTriggerEvmRawToDigi ( )
override

destructor

Definition at line 125 of file L1GlobaTriggerEvmRawToDigi.cc.

References m_gtFdlWord, m_gtfeWord, and m_tcsWord.

125  {
126  delete m_gtfeWord;
127  delete m_tcsWord;
128  delete m_gtFdlWord;
129 }

Member Function Documentation

◆ dumpFedRawData()

void L1GlobalTriggerEvmRawToDigi::dumpFedRawData ( const unsigned char *  gtPtr,
int  gtSize,
std::ostream &  myCout 
)
private

dump FED raw data

Definition at line 719 of file L1GlobaTriggerEvmRawToDigi.cc.

References TauDecayModes::dec, mps_fire::i, LogDebug, LogTrace, jetsAK4_Puppi_cff::payload, L1GlobalTriggerReadoutSetup::UnitLength, and L1GlobalTriggerReadoutSetup::WordLength.

Referenced by produce().

719  {
720  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nDump FED raw data.\n" << std::endl;
721 
724 
725  int gtWords = gtSize / uLength;
726  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\nFED GT words (" << wLength << " bits):" << gtWords << "\n" << std::endl;
727 
728  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtPtr));
729 
730  for (unsigned int i = 0; i < gtSize / sizeof(cms_uint64_t); i++) {
731  myCout << std::setw(4) << i << " " << std::hex << std::setfill('0') << std::setw(16) << payload[i] << std::dec
732  << std::setfill(' ') << std::endl;
733  }
734 }
static const int UnitLength
one unit in the word is UnitLength bits
static const int WordLength
GT DAQ record organized in words of WordLength bits.
#define LogTrace(id)
unsigned long long cms_uint64_t
Definition: typedefs.h:17
#define LogDebug(id)

◆ produce()

void L1GlobalTriggerEvmRawToDigi::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
overrideprivate

Definition at line 134 of file L1GlobaTriggerEvmRawToDigi.cc.

References L1GtfeWord::activeBoards(), L1GtfeWord::altNrBxBoard(), FEDRawData::data(), TauDecayModes::dec, dumpFedRawData(), FDL, edm::EventSetup::getHandle(), L1GtfeExtWord::getSize(), L1TcsWord::getSize(), L1GtFdlWord::getSize(), GMT, L1GtBoardMaps::gtBoardMaps(), L1GtParameters::gtBstLengthBytes(), GTFE, iEvent, edm::HandleBase::isValid(), LogDebug, LogTrace, L1TcsWord::luminositySegmentNr(), L1GtFdlWord::lumiSegmentNr(), m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_gtFdlWord, m_gtfeWord, m_isDebugEnabled, m_l1GtBMToken, m_l1GtParamToken, m_lowSkipBxInEvent, m_recordLength0, m_recordLength1, m_tcsWord, m_totalBxInEvent, m_unpackBxInEvent, m_uppSkipBxInEvent, m_verbosity, SiStripPI::max, eostools::move(), L1GtfeExtWord::print(), L1TcsWord::print(), L1GtFdlWord::print(), produceEmptyProducts(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), PSB, L1GtfeWord::recordLength(), L1GtfeWord::recordLength1(), L1GtfeExtWord::reset(), L1TcsWord::reset(), L1GtFdlWord::reset(), L1GtfeExtWord::resize(), L1GtfeWord::setActiveBoards(), L1TcsWord::setLuminositySegmentNr(), L1GtFdlWord::setLumiSegmentNr(), L1GtfeWord::setRecordLength(), L1GtfeWord::setRecordLength1(), FEDRawData::size(), TCS, TIM, L1GtfeExtWord::unpack(), L1TcsWord::unpack(), L1GtFdlWord::unpack(), unpackHeader(), and unpackTrailer().

134  {
135  // get records from EventSetup
136 
137  // board maps
139 
140  const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
141  int boardMapsSize = boardMaps.size();
142 
143  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
144 
145  // create an ordered vector for the GT EVM record
146  // header (pos 0 in record) and trailer (last position in record)
147  // not included, as they are not in board list
148  std::vector<L1GtBoard> gtRecordMap;
149  gtRecordMap.reserve(boardMapsSize);
150 
151  for (int iPos = 0; iPos < boardMapsSize; ++iPos) {
152  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
153  if (itBoard->gtPositionEvmRecord() == iPos) {
154  gtRecordMap.push_back(*itBoard);
155  break;
156  }
157  }
158  }
159 
160  // raw collection
161 
163  iEvent.getByLabel(m_evmGtInputTag, fedHandle);
164 
165  if (!fedHandle.isValid()) {
166  if (m_verbosity) {
167  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
168  << "\nWarning: FEDRawDataCollection with input tag " << m_evmGtInputTag
169  << "\nrequested in configuration, but not found in the event."
170  << "\nQuit unpacking this event" << std::endl;
171  }
172 
174 
175  return;
176  }
177 
178  // retrieve data for Global Trigger EVM FED
179  const FEDRawData& raw = (fedHandle.product())->FEDData(m_evmGtFedId);
180 
181  int gtSize = raw.size();
182 
183  // get a const pointer to the beginning of the data buffer
184  const unsigned char* ptrGt = raw.data();
185 
186  // get a const pointer to the end of the data buffer
187  const unsigned char* endPtrGt = ptrGt + gtSize;
188 
189  //
190  if (m_verbosity && m_isDebugEnabled) {
191  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Size of raw data: " << gtSize << "\n" << std::endl;
192 
193  std::ostringstream myCoutStream;
194  dumpFedRawData(ptrGt, gtSize, myCoutStream);
195 
196  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Dump FEDRawData\n" << myCoutStream.str() << "\n" << std::endl;
197  }
198 
199  // unpack header
200  int headerSize = 8;
201 
202  if ((ptrGt + headerSize) > endPtrGt) {
203  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after header greater than end pointer."
204  << "\n Put empty products in the event!"
205  << "\n Quit unpacking this event." << std::endl;
206 
208 
209  return;
210  }
211 
212  FEDHeader cmsHeader(ptrGt);
213  FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
214 
215  unpackHeader(ptrGt, cmsHeader);
216  ptrGt += headerSize; // advance with header size
217 
218  // unpack first GTFE to find the length of the record and the active boards
219  // here GTFE assumed immediately after the header
220 
221  bool gtfeUnpacked = false;
222 
223  // get the length of the BST message from parameter set or from event setup
224 
225  int bstLengthBytes = 0;
226 
227  if (m_bstLengthBytes < 0) {
228  // length from event setup // TODO cache it, if too slow
229 
231  const L1GtParameters* m_l1GtPar = l1GtPar.product();
232 
233  bstLengthBytes = static_cast<int>(m_l1GtPar->gtBstLengthBytes());
234 
235  } else {
236  // length from parameter set
237  bstLengthBytes = m_bstLengthBytes;
238  }
239 
240  if (m_verbosity) {
241  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Length of BST message (in bytes): " << bstLengthBytes << "\n"
242  << std::endl;
243  }
244 
245  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
246  if (itBoard->gtBoardType() == GTFE) {
247  // unpack GTFE
248  if (itBoard->gtPositionEvmRecord() == 1) {
249  // resize to the right size before unapacking
250  m_gtfeWord->resize(bstLengthBytes);
251 
252  m_gtfeWord->unpack(ptrGt);
253  ptrGt += m_gtfeWord->getSize(); // advance with GTFE block size
254  gtfeUnpacked = true;
255 
256  if (m_verbosity && m_isDebugEnabled) {
257  std::ostringstream myCoutStream;
258  m_gtfeWord->print(myCoutStream);
259  LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n" << std::endl;
260  }
261 
262  // break the loop - GTFE was found
263  break;
264 
265  } else {
266  if (m_verbosity) {
267  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
268  << "\nWarning: GTFE block found in raw data does not follow header."
269  << "\nAssumed start position of the block is wrong!"
270  << "\nQuit unpacking this event" << std::endl;
271  }
272 
274 
275  return;
276  }
277  }
278  }
279 
280  // quit if no GTFE found
281  if (!gtfeUnpacked) {
282  if (m_verbosity) {
283  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
284  << "\nWarning: no GTFE block found in raw data."
285  << "\nCan not find the record length (BxInEvent) and the active boards!"
286  << "\nQuit unpacking this event" << std::endl;
287  }
288 
290 
291  return;
292  }
293 
294  // life normal here, GTFE found
295 
296  // get list of active blocks
297  // blocks not active are not written to the record
298  cms_uint16_t activeBoardsGtInitial = m_gtfeWord->activeBoards();
299  cms_uint16_t altNrBxBoardInitial = m_gtfeWord->altNrBxBoard();
300 
301  // mask some boards, if needed
302  cms_uint16_t activeBoardsGt = activeBoardsGtInitial & m_activeBoardsMaskGt;
303  m_gtfeWord->setActiveBoards(activeBoardsGt);
304 
305  if (m_verbosity) {
306  LogDebug("L1GlobalTriggerEvmRawToDigi")
307  << "\nActive boards before masking(hex format): " << std::hex << std::setw(sizeof(activeBoardsGtInitial) * 2)
308  << std::setfill('0') << activeBoardsGtInitial << std::dec << std::setfill(' ')
309  << "\nActive boards after masking(hex format): " << std::hex << std::setw(sizeof(activeBoardsGt) * 2)
310  << std::setfill('0') << activeBoardsGt << std::dec << std::setfill(' ') << " \n"
311  << std::endl;
312  }
313 
314  // loop over other blocks in the raw record, count them if they are active
315 
316  int numberFdlBoards = 0;
317 
318  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
319  int iActiveBit = itBoard->gtBitEvmActiveBoards();
320  bool activeBoardToUnpack = false;
321 
322  if (iActiveBit >= 0) {
323  activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
324  } else {
325  // board not in the ActiveBoards for the record
326  continue;
327  }
328 
329  if (activeBoardToUnpack) {
330  switch (itBoard->gtBoardType()) {
331  case GTFE:
332  break;
333  case FDL: {
334  numberFdlBoards++;
335  }
336 
337  break;
338  case PSB:
339  break;
340  case GMT:
341  break;
342  case TCS:
343  break;
344  case TIM:
345  break;
346  default: {
347  // do nothing, all blocks are given in GtBoardType enum
348  if (m_verbosity) {
349  LogDebug("L1GlobalTriggerEvmRawToDigi")
350  << "\nBoard of type " << itBoard->gtBoardType() << " not expected in record.\n"
351  << std::endl;
352  }
353 
354  }
355 
356  break;
357  }
358  }
359  }
360 
361  // produce the L1GlobalTriggerEvmReadoutRecord now, after we found how many
362  // BxInEvent the record has and how many boards are active
363  //LogDebug("L1GlobalTriggerEvmRawToDigi")
364  //<< "\nL1GlobalTriggerEvmRawToDigi: producing L1GlobalTriggerEvmReadoutRecord\n"
365  //<< std::endl;
366 
367  // get number of Bx in the event from GTFE block corresponding to alternative 0 and 1 in
370 
371  int maxBxInEvent = std::max(m_recordLength0, m_recordLength1);
372 
373  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
374  new L1GlobalTriggerEvmReadoutRecord(maxBxInEvent, numberFdlBoards));
375 
376  // ... then unpack modules other than GTFE, if requested
377 
378  for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
379  int iActiveBit = itBoard->gtBitEvmActiveBoards();
380 
381  bool activeBoardToUnpack = false;
382  bool activeBoardInitial = false;
383 
384  int altNrBxBoardVal = -1;
385 
386  if (iActiveBit >= 0) {
387  activeBoardInitial = activeBoardsGtInitial & (1 << iActiveBit);
388  activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
389 
390  altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
391 
392  if (altNrBxBoardVal == 1) {
394  } else if (altNrBxBoardVal == 0) {
396  } else {
397  if (m_verbosity) {
398  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
399  << "\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal << " for board " << std::hex
400  << (itBoard->gtBoardId()) << std::dec << "\n iActiveBit = " << iActiveBit
401  << "\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
402  << "\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
403  << "\n activeBoardInitial = " << activeBoardInitial
404  << "\n activeBoardToUnpack = " << activeBoardToUnpack << "\n Set altNrBxBoardVal tentatively to "
405  << m_recordLength0 << "\n Job may crash or produce wrong results!\n\n"
406  << std::endl;
407  }
408 
410  }
411 
412  // number of BX required to be unpacked
413 
415  if (m_verbosity) {
416  LogDebug("L1GlobalTriggerEvmRawToDigi")
417  << "\nWARNING: Number of available bunch crosses for board" << (itBoard->gtBoardId())
418  << " in the record ( " << m_totalBxInEvent
419  << " ) \n is smaller than the number of bunch crosses requested to be unpacked (" << m_unpackBxInEvent
420  << " )!!! \n Unpacking only " << m_totalBxInEvent << " bunch crosses.\n"
421  << std::endl;
422  }
423 
424  m_lowSkipBxInEvent = 0;
426 
427  } else if (m_unpackBxInEvent < 0) {
428  m_lowSkipBxInEvent = 0;
430 
431  if (m_verbosity) {
432  LogDebug("L1GlobalTriggerEvmRawToDigi")
433  << "\nUnpacking all " << m_totalBxInEvent << " bunch crosses available."
434  << "\n"
435  << std::endl;
436  }
437 
438  } else if (m_unpackBxInEvent == 0) {
441 
442  if (m_verbosity) {
443  LogDebug("L1GlobalTriggerEvmRawToDigi")
444  << "\nNo bxInEvent required to be unpacked from " << m_totalBxInEvent << " bunch crosses available."
445  << "\n"
446  << std::endl;
447  }
448 
449  // change RecordLength
450  // cast int to cms_uint16_t (there are normally 3 or 5 BxInEvent)
451  m_gtfeWord->setRecordLength(static_cast<cms_uint16_t>(m_unpackBxInEvent));
452  m_gtfeWord->setRecordLength1(static_cast<cms_uint16_t>(m_unpackBxInEvent));
453 
454  } else {
457 
458  if (m_verbosity) {
459  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nUnpacking " << m_unpackBxInEvent << " bunch crosses from "
460  << m_totalBxInEvent << " bunch crosses available."
461  << "\n"
462  << std::endl;
463  }
464 
465  // change RecordLength
466  // cast int to cms_uint16_t (there are normally 3 or 5 BxInEvent)
467  m_gtfeWord->setRecordLength(static_cast<cms_uint16_t>(m_unpackBxInEvent));
468  m_gtfeWord->setRecordLength1(static_cast<cms_uint16_t>(m_unpackBxInEvent));
469  }
470 
471  } else {
472  // board not in the ActiveBoards for the record
473  continue;
474  }
475 
476  if (!activeBoardInitial) {
477  if (m_verbosity) {
478  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nBoard of type " << itBoard->gtBoardName() << " with index "
479  << itBoard->gtBoardIndex() << " not active initially in raw data.\n"
480  << std::endl;
481  }
482  continue;
483  }
484 
485  // active board initially, could unpack it
486  switch (itBoard->gtBoardType()) {
487  case TCS: {
488  // if pointer after TCS payload is greater than pointer at
489  // the end of GT payload, produce empty products and quit unpacking
490  if ((ptrGt + m_tcsWord->getSize()) > endPtrGt) {
491  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after TCS "
492  << " greater than end pointer."
493  << "\n Put empty products in the event!"
494  << "\n Quit unpacking this event." << std::endl;
495 
497 
498  return;
499  }
500 
501  // unpack only if requested, otherwise skip it
502  if (activeBoardToUnpack) {
503  m_tcsWord->unpack(ptrGt);
504 
505  // add 1 to the GT luminosity number to use the same convention as
506  // offline, where LS number starts with 1;
507  // in GT hardware, LS starts with 0
510 
511  // add TCS block to GT EVM readout record
512  gtReadoutRecord->setTcsWord(*m_tcsWord);
513 
514  if (m_verbosity && m_isDebugEnabled) {
515  std::ostringstream myCoutStream;
516  m_tcsWord->print(myCoutStream);
517  LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n" << std::endl;
518  }
519 
520  // ... and reset it
521  m_tcsWord->reset();
522  }
523 
524  ptrGt += m_tcsWord->getSize(); // advance with TCS block size
525 
526  } break;
527  case FDL: {
528  for (int iFdl = 0; iFdl < m_totalBxInEvent; ++iFdl) {
529  // if pointer after FDL payload is greater than pointer at
530  // the end of GT payload, produce empty products and quit unpacking
531  if ((ptrGt + m_gtFdlWord->getSize()) > endPtrGt) {
532  edm::LogError("L1GlobalTriggerEvmRawToDigi")
533  << "\nError: Pointer after FDL " << iFdl << " greater than end pointer."
534  << "\n Put empty products in the event!"
535  << "\n Quit unpacking this event." << std::endl;
536 
538 
539  return;
540  }
541 
542  // unpack only if requested, otherwise skip it
543  if (activeBoardToUnpack) {
544  // unpack only bxInEvent requested, otherwise skip it
545  if ((iFdl >= m_lowSkipBxInEvent) && (iFdl < m_uppSkipBxInEvent)) {
546  m_gtFdlWord->unpack(ptrGt);
547 
548  // add 1 to the GT luminosity number to use the same convention as
549  // offline, where LS number starts with 1;
550  // in GT hardware, LS starts with 0
551  cms_uint16_t lsNr = m_gtFdlWord->lumiSegmentNr() + 1;
553 
554  // add FDL block to GT readout record
555  gtReadoutRecord->setGtFdlWord(*m_gtFdlWord);
556 
557  if (m_verbosity && m_isDebugEnabled) {
558  std::ostringstream myCoutStream;
559  m_gtFdlWord->print(myCoutStream);
560  LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n" << std::endl;
561  }
562 
563  // ... and reset it
564  m_gtFdlWord->reset();
565  }
566  }
567 
568  ptrGt += m_gtFdlWord->getSize(); // advance with FDL block size
569  }
570  }
571 
572  break;
573  default: {
574  // do nothing, all blocks are given in GtBoardType enum
575  if (m_verbosity) {
576  LogDebug("L1GlobalTriggerEvmRawToDigi")
577  << "\nBoard of type " << itBoard->gtBoardType() << " not expected in record.\n"
578  << std::endl;
579  }
580  } break;
581  }
582  }
583 
584  // add GTFE block to GT readout record, after updating active boards and record length
585 
586  gtReadoutRecord->setGtfeWord(*m_gtfeWord);
587 
588  // ... and reset it
589  m_gtfeWord->reset();
590 
591  // unpack trailer
592 
593  int trailerSize = 8;
594 
595  // if pointer after trailer is greater than pointer at
596  // the end of GT payload, produce empty products and quit unpacking
597  if ((ptrGt + trailerSize) > endPtrGt) {
598  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after trailer "
599  << " greater than end pointer."
600  << "\n Put empty products in the event!"
601  << "\n Quit unpacking this event." << std::endl;
602 
604 
605  return;
606  }
607 
608  unpackTrailer(ptrGt, cmsTrailer);
609 
610  if (m_verbosity && m_isDebugEnabled) {
611  std::ostringstream myCoutStream;
612  gtReadoutRecord->print(myCoutStream);
613  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n The following L1 GT EVM readout record was unpacked.\n"
614  << myCoutStream.str() << "\n"
615  << std::endl;
616  }
617 
618  // put records into event
619  iEvent.put(std::move(gtReadoutRecord));
620 }
int m_bstLengthBytes
length of BST record (in bytes)
const cms_uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
Definition: L1GtfeWord.h:134
int m_totalBxInEvent
number of Bx for a board, obtained from GTFE block (record length & alternative)
void produceEmptyProducts(edm::Event &)
produce empty products in case of problems
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
Definition: L1GtfeWord.h:71
void reset()
reset the content of a L1TcsWord
Definition: L1TcsWord.cc:259
T const * product() const
Definition: Handle.h:70
void unpack(const unsigned char *fdlPtr)
Definition: L1GtFdlWord.cc:687
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const cms_uint16_t luminositySegmentNr() const
get/set luminosity segment number
Definition: L1TcsWord.h:121
Log< level::Error, false > LogError
void dumpFedRawData(const unsigned char *, int, std::ostream &)
dump FED raw data
void setRecordLength(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:84
void setLuminositySegmentNr(const cms_uint16_t luminositySegmentNrValue)
Definition: L1TcsWord.h:123
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
EventSetup Token for L1GtBoardMaps.
#define LogTrace(id)
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
const cms_uint16_t recordLength() const
get/set record length for alternative 0
Definition: L1GtfeWord.h:82
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
edm::ESGetToken< L1GtParameters, L1GtParametersRcd > m_l1GtParamToken
EventSetup Token for L1GtParameters.
void setLumiSegmentNr(const cms_uint16_t &lumiSegmentNrValue)
Definition: L1GtFdlWord.h:249
void reset()
reset the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:565
unsigned short cms_uint16_t
Definition: typedefs.h:13
void print(std::ostream &myCout) const override
pretty print the content of a L1GtfeExtWord
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
Definition: L1TcsWord.h:197
void setRecordLength1(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:73
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
Definition: L1GtBoardMaps.h:43
void unpackHeader(const unsigned char *, FEDHeader &)
block unpackers
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
const cms_uint16_t lumiSegmentNr() const
get/set luminosity segment number of the actual bx
Definition: L1GtFdlWord.h:247
void resize(int bstSizeBytes)
resize the BST vector to get the right size of the block
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
Definition: L1TcsWord.cc:274
int m_recordLength0
total Bx&#39;s in the event, obtained from GTFE block
void setActiveBoards(cms_uint16_t activeBoardsValue)
Definition: L1GtfeWord.h:121
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtFdlWord.h:271
bool isValid() const
Definition: HandleBase.h:70
void unpack(const unsigned char *tcsPtr)
Definition: L1TcsWord.cc:339
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:593
const unsigned int getSize() const
get the size of the GTFE block in GT EVM record (in multiple of 8 bits)
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
Definition: L1GtfeWord.h:119
Log< level::Warning, false > LogWarning
void reset() override
reset the content of a L1GtfeExtWord
void unpackTrailer(const unsigned char *, FEDTrailer &)
unpack trailer word
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
void unpack(const unsigned char *gtfePtr) override
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)
edm::InputTag m_evmGtInputTag
input tags for GT EVM record

◆ produceEmptyProducts()

void L1GlobalTriggerEvmRawToDigi::produceEmptyProducts ( edm::Event iEvent)
private

produce empty products in case of problems

Definition at line 710 of file L1GlobaTriggerEvmRawToDigi.cc.

References iEvent, and eostools::move().

Referenced by produce().

710  {
711  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(new L1GlobalTriggerEvmReadoutRecord());
712 
713  // put empty records into event
714 
715  iEvent.put(std::move(gtReadoutRecord));
716 }
int iEvent
Definition: GenABIO.cc:224
def move(src, dest)
Definition: eostools.py:511

◆ unpackHeader()

void L1GlobalTriggerEvmRawToDigi::unpackHeader ( const unsigned char *  gtPtr,
FEDHeader cmsHeader 
)
private

block unpackers

unpack header

Definition at line 623 of file L1GlobaTriggerEvmRawToDigi.cc.

References FEDHeader::bxID(), TauDecayModes::dec, edm::isDebugEnabled(), LogDebug, FEDHeader::lvl1ID(), FEDHeader::moreHeaders(), jetsAK4_Puppi_cff::payload, FEDHeader::sourceID(), FEDHeader::triggerType(), and FEDHeader::version().

Referenced by produce().

623  {
624  // TODO if needed in another format
625 
626  // print the header info
627  if (edm::isDebugEnabled()) {
628  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtPtr));
629 
630  std::ostringstream myCoutStream;
631 
632  // one word only
633  int iWord = 0;
634 
635  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16) << payload[iWord]
636  << std::dec << std::setfill(' ') << "\n"
637  << std::endl;
638 
639  myCoutStream << " Event_type: " << std::hex << " hex: "
640  << " " << std::setw(1) << std::setfill('0') << cmsHeader.triggerType() << std::setfill(' ')
641  << std::dec << " dec: " << cmsHeader.triggerType() << std::endl;
642 
643  myCoutStream << " LVL1_Id: " << std::hex << " hex: "
644  << "" << std::setw(6) << std::setfill('0') << cmsHeader.lvl1ID() << std::setfill(' ') << std::dec
645  << " dec: " << cmsHeader.lvl1ID() << std::endl;
646 
647  myCoutStream << " BX_Id: " << std::hex << " hex: "
648  << " " << std::setw(3) << std::setfill('0') << cmsHeader.bxID() << std::setfill(' ') << std::dec
649  << " dec: " << cmsHeader.bxID() << std::endl;
650 
651  myCoutStream << " Source_Id: " << std::hex << " hex: "
652  << " " << std::setw(3) << std::setfill('0') << cmsHeader.sourceID() << std::setfill(' ') << std::dec
653  << " dec: " << cmsHeader.sourceID() << std::endl;
654 
655  myCoutStream << " FOV: " << std::hex << " hex: "
656  << " " << std::setw(1) << std::setfill('0') << cmsHeader.version() << std::setfill(' ') << std::dec
657  << " dec: " << cmsHeader.version() << std::endl;
658 
659  myCoutStream << " H: " << std::hex << " hex: "
660  << " " << std::setw(1) << std::setfill('0') << cmsHeader.moreHeaders() << std::setfill(' ')
661  << std::dec << " dec: " << cmsHeader.moreHeaders() << std::endl;
662 
663  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Header \n" << myCoutStream.str() << "\n" << std::endl;
664  }
665 }
uint8_t triggerType() const
Event Trigger type identifier.
Definition: FEDHeader.cc:13
bool isDebugEnabled()
uint16_t sourceID() const
Identifier of the FED.
Definition: FEDHeader.cc:19
bool moreHeaders() const
Definition: FEDHeader.cc:23
uint16_t bxID() const
The bunch crossing number.
Definition: FEDHeader.cc:17
uint8_t version() const
Version identifier of the FED data format.
Definition: FEDHeader.cc:21
uint32_t lvl1ID() const
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:15
unsigned long long cms_uint64_t
Definition: typedefs.h:17
#define LogDebug(id)

◆ unpackTrailer()

void L1GlobalTriggerEvmRawToDigi::unpackTrailer ( const unsigned char *  trlPtr,
FEDTrailer cmsTrailer 
)
private

unpack trailer word

Definition at line 669 of file L1GlobaTriggerEvmRawToDigi.cc.

References FEDTrailer::crc(), TauDecayModes::dec, FEDTrailer::evtStatus(), FEDTrailer::fragmentLength(), LogDebug, m_isDebugEnabled, m_verbosity, FEDTrailer::moreTrailers(), jetsAK4_Puppi_cff::payload, and FEDTrailer::ttsBits().

Referenced by produce().

669  {
670  // TODO if needed in another format
671 
672  // print the trailer info
673  if (m_verbosity && m_isDebugEnabled) {
674  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(trlPtr));
675 
676  std::ostringstream myCoutStream;
677 
678  // one word only
679  int iWord = 0;
680 
681  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16) << payload[iWord]
682  << std::dec << std::setfill(' ') << "\n"
683  << std::endl;
684 
685  myCoutStream << " Event_length: " << std::hex << " hex: "
686  << "" << std::setw(6) << std::setfill('0') << cmsTrailer.fragmentLength() << std::setfill(' ')
687  << std::dec << " dec: " << cmsTrailer.fragmentLength() << std::endl;
688 
689  myCoutStream << " CRC: " << std::hex << " hex: "
690  << " " << std::setw(4) << std::setfill('0') << cmsTrailer.crc() << std::setfill(' ') << std::dec
691  << " dec: " << cmsTrailer.crc() << std::endl;
692 
693  myCoutStream << " Event_status: " << std::hex << " hex: "
694  << " " << std::setw(2) << std::setfill('0') << cmsTrailer.evtStatus() << std::setfill(' ')
695  << std::dec << " dec: " << cmsTrailer.evtStatus() << std::endl;
696 
697  myCoutStream << " TTS_bits: " << std::hex << " hex: "
698  << " " << std::setw(1) << std::setfill('0') << cmsTrailer.ttsBits() << std::setfill(' ')
699  << std::dec << " dec: " << cmsTrailer.ttsBits() << std::endl;
700 
701  myCoutStream << " More trailers: " << std::hex << " hex: "
702  << " " << std::setw(1) << std::setfill('0') << cmsTrailer.moreTrailers() << std::setfill(' ')
703  << std::dec << " dec: " << cmsTrailer.moreTrailers() << std::endl;
704 
705  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Trailer \n" << myCoutStream.str() << "\n" << std::endl;
706  }
707 }
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
Definition: FEDTrailer.cc:19
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:13
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
Definition: FEDTrailer.cc:15
uint8_t evtStatus() const
Event fragment status information.
Definition: FEDTrailer.cc:17
unsigned long long cms_uint64_t
Definition: typedefs.h:17
bool moreTrailers() const
Definition: FEDTrailer.cc:21
#define LogDebug(id)

Member Data Documentation

◆ m_activeBoardsMaskGt

cms_uint16_t L1GlobalTriggerEvmRawToDigi::m_activeBoardsMaskGt
private

mask for active boards

Definition at line 93 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

◆ m_bstLengthBytes

int L1GlobalTriggerEvmRawToDigi::m_bstLengthBytes
private

length of BST record (in bytes)

Definition at line 118 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

◆ m_evmGtFedId

int L1GlobalTriggerEvmRawToDigi::m_evmGtFedId
private

FED Id for GT EVM record default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc

Definition at line 84 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

◆ m_evmGtInputTag

edm::InputTag L1GlobalTriggerEvmRawToDigi::m_evmGtInputTag
private

input tags for GT EVM record

Definition at line 80 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

◆ m_gtFdlWord

L1GtFdlWord* L1GlobalTriggerEvmRawToDigi::m_gtFdlWord
private

◆ m_gtfeWord

L1GtfeExtWord* L1GlobalTriggerEvmRawToDigi::m_gtfeWord
private

◆ m_isDebugEnabled

bool L1GlobalTriggerEvmRawToDigi::m_isDebugEnabled
private

◆ m_l1GtBMToken

const edm::ESGetToken<L1GtBoardMaps, L1GtBoardMapsRcd> L1GlobalTriggerEvmRawToDigi::m_l1GtBMToken
private

EventSetup Token for L1GtBoardMaps.

Definition at line 87 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

◆ m_l1GtParamToken

edm::ESGetToken<L1GtParameters, L1GtParametersRcd> L1GlobalTriggerEvmRawToDigi::m_l1GtParamToken
private

EventSetup Token for L1GtParameters.

Definition at line 90 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

◆ m_lowSkipBxInEvent

int L1GlobalTriggerEvmRawToDigi::m_lowSkipBxInEvent
private

lowest bxInEvent to be unpacked in the event assume symmetrical number of BX around L1Accept

Definition at line 100 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

◆ m_recordLength0

int L1GlobalTriggerEvmRawToDigi::m_recordLength0
private

total Bx's in the event, obtained from GTFE block

corresponding to alternative 0 in altNrBxBoard()

Definition at line 109 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

◆ m_recordLength1

int L1GlobalTriggerEvmRawToDigi::m_recordLength1
private

corresponding to alternative 1 in altNrBxBoard()

Definition at line 112 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

◆ m_tcsWord

L1TcsWord* L1GlobalTriggerEvmRawToDigi::m_tcsWord
private

◆ m_totalBxInEvent

int L1GlobalTriggerEvmRawToDigi::m_totalBxInEvent
private

number of Bx for a board, obtained from GTFE block (record length & alternative)

Definition at line 115 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

◆ m_unpackBxInEvent

int L1GlobalTriggerEvmRawToDigi::m_unpackBxInEvent
private

Definition at line 96 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

◆ m_uppSkipBxInEvent

int L1GlobalTriggerEvmRawToDigi::m_uppSkipBxInEvent
private

upper bxInEvent to be unpacked in the event assume symmetrical number of BX around L1Accept

Definition at line 104 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

◆ m_verbosity

int L1GlobalTriggerEvmRawToDigi::m_verbosity
private

verbosity level

Definition at line 122 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), produce(), and unpackTrailer().