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 739 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Referenced by produce().

739  {
740  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nDump FED raw data.\n" << std::endl;
741 
744 
745  int gtWords = gtSize / uLength;
746  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\nFED GT words (" << wLength << " bits):" << gtWords << "\n" << std::endl;
747 
748  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtPtr));
749 
750  for (unsigned int i = 0; i < gtSize / sizeof(cms_uint64_t); i++) {
751  myCout << std::setw(4) << i << " " << std::hex << std::setfill('0') << std::setw(16) << payload[i] << std::dec
752  << std::setfill(' ') << std::endl;
753  }
754 }
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 numberGtfeBoards = 0;
317  int numberFdlBoards = 0;
318  int numberPsbBoards = 0;
319  int numberGmtBoards = 0;
320  int numberTcsBoards = 0;
321  int numberTimBoards = 0;
322 
323  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
324  int iActiveBit = itBoard->gtBitEvmActiveBoards();
325  bool activeBoardToUnpack = false;
326 
327  if (iActiveBit >= 0) {
328  activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
329  } else {
330  // board not in the ActiveBoards for the record
331  continue;
332  }
333 
334  if (activeBoardToUnpack) {
335  switch (itBoard->gtBoardType()) {
336  case GTFE: {
337  numberGtfeBoards++;
338  }
339 
340  break;
341  case FDL: {
342  numberFdlBoards++;
343  }
344 
345  break;
346  case PSB: {
347  numberPsbBoards++;
348  }
349 
350  break;
351  case GMT: {
352  numberGmtBoards++;
353  }
354 
355  break;
356  case TCS: {
357  numberTcsBoards++;
358  }
359 
360  break;
361  case TIM: {
362  numberTimBoards++;
363  }
364 
365  break;
366  default: {
367  // do nothing, all blocks are given in GtBoardType enum
368  if (m_verbosity) {
369  LogDebug("L1GlobalTriggerEvmRawToDigi")
370  << "\nBoard of type " << itBoard->gtBoardType() << " not expected in record.\n"
371  << std::endl;
372  }
373 
374  }
375 
376  break;
377  }
378  }
379  }
380 
381  // produce the L1GlobalTriggerEvmReadoutRecord now, after we found how many
382  // BxInEvent the record has and how many boards are active
383  //LogDebug("L1GlobalTriggerEvmRawToDigi")
384  //<< "\nL1GlobalTriggerEvmRawToDigi: producing L1GlobalTriggerEvmReadoutRecord\n"
385  //<< std::endl;
386 
387  // get number of Bx in the event from GTFE block corresponding to alternative 0 and 1 in
390 
391  int maxBxInEvent = std::max(m_recordLength0, m_recordLength1);
392 
393  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
394  new L1GlobalTriggerEvmReadoutRecord(maxBxInEvent, numberFdlBoards));
395 
396  // ... then unpack modules other than GTFE, if requested
397 
398  for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
399  int iActiveBit = itBoard->gtBitEvmActiveBoards();
400 
401  bool activeBoardToUnpack = false;
402  bool activeBoardInitial = false;
403 
404  int altNrBxBoardVal = -1;
405 
406  if (iActiveBit >= 0) {
407  activeBoardInitial = activeBoardsGtInitial & (1 << iActiveBit);
408  activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
409 
410  altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
411 
412  if (altNrBxBoardVal == 1) {
414  } else if (altNrBxBoardVal == 0) {
416  } else {
417  if (m_verbosity) {
418  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
419  << "\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal << " for board " << std::hex
420  << (itBoard->gtBoardId()) << std::dec << "\n iActiveBit = " << iActiveBit
421  << "\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
422  << "\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
423  << "\n activeBoardInitial = " << activeBoardInitial
424  << "\n activeBoardToUnpack = " << activeBoardToUnpack << "\n Set altNrBxBoardVal tentatively to "
425  << m_recordLength0 << "\n Job may crash or produce wrong results!\n\n"
426  << std::endl;
427  }
428 
430  }
431 
432  // number of BX required to be unpacked
433 
435  if (m_verbosity) {
436  LogDebug("L1GlobalTriggerEvmRawToDigi")
437  << "\nWARNING: Number of available bunch crosses for board" << (itBoard->gtBoardId())
438  << " in the record ( " << m_totalBxInEvent
439  << " ) \n is smaller than the number of bunch crosses requested to be unpacked (" << m_unpackBxInEvent
440  << " )!!! \n Unpacking only " << m_totalBxInEvent << " bunch crosses.\n"
441  << std::endl;
442  }
443 
444  m_lowSkipBxInEvent = 0;
446 
447  } else if (m_unpackBxInEvent < 0) {
448  m_lowSkipBxInEvent = 0;
450 
451  if (m_verbosity) {
452  LogDebug("L1GlobalTriggerEvmRawToDigi")
453  << "\nUnpacking all " << m_totalBxInEvent << " bunch crosses available."
454  << "\n"
455  << std::endl;
456  }
457 
458  } else if (m_unpackBxInEvent == 0) {
461 
462  if (m_verbosity) {
463  LogDebug("L1GlobalTriggerEvmRawToDigi")
464  << "\nNo bxInEvent required to be unpacked from " << m_totalBxInEvent << " bunch crosses available."
465  << "\n"
466  << std::endl;
467  }
468 
469  // change RecordLength
470  // cast int to cms_uint16_t (there are normally 3 or 5 BxInEvent)
471  m_gtfeWord->setRecordLength(static_cast<cms_uint16_t>(m_unpackBxInEvent));
472  m_gtfeWord->setRecordLength1(static_cast<cms_uint16_t>(m_unpackBxInEvent));
473 
474  } else {
477 
478  if (m_verbosity) {
479  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nUnpacking " << m_unpackBxInEvent << " bunch crosses from "
480  << m_totalBxInEvent << " bunch crosses available."
481  << "\n"
482  << std::endl;
483  }
484 
485  // change RecordLength
486  // cast int to cms_uint16_t (there are normally 3 or 5 BxInEvent)
487  m_gtfeWord->setRecordLength(static_cast<cms_uint16_t>(m_unpackBxInEvent));
488  m_gtfeWord->setRecordLength1(static_cast<cms_uint16_t>(m_unpackBxInEvent));
489  }
490 
491  } else {
492  // board not in the ActiveBoards for the record
493  continue;
494  }
495 
496  if (!activeBoardInitial) {
497  if (m_verbosity) {
498  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nBoard of type " << itBoard->gtBoardName() << " with index "
499  << itBoard->gtBoardIndex() << " not active initially in raw data.\n"
500  << std::endl;
501  }
502  continue;
503  }
504 
505  // active board initially, could unpack it
506  switch (itBoard->gtBoardType()) {
507  case TCS: {
508  // if pointer after TCS payload is greater than pointer at
509  // the end of GT payload, produce empty products and quit unpacking
510  if ((ptrGt + m_tcsWord->getSize()) > endPtrGt) {
511  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after TCS "
512  << " greater than end pointer."
513  << "\n Put empty products in the event!"
514  << "\n Quit unpacking this event." << std::endl;
515 
517 
518  return;
519  }
520 
521  // unpack only if requested, otherwise skip it
522  if (activeBoardToUnpack) {
523  m_tcsWord->unpack(ptrGt);
524 
525  // add 1 to the GT luminosity number to use the same convention as
526  // offline, where LS number starts with 1;
527  // in GT hardware, LS starts with 0
530 
531  // add TCS block to GT EVM readout record
532  gtReadoutRecord->setTcsWord(*m_tcsWord);
533 
534  if (m_verbosity && m_isDebugEnabled) {
535  std::ostringstream myCoutStream;
536  m_tcsWord->print(myCoutStream);
537  LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n" << std::endl;
538  }
539 
540  // ... and reset it
541  m_tcsWord->reset();
542  }
543 
544  ptrGt += m_tcsWord->getSize(); // advance with TCS block size
545 
546  } break;
547  case FDL: {
548  for (int iFdl = 0; iFdl < m_totalBxInEvent; ++iFdl) {
549  // if pointer after FDL payload is greater than pointer at
550  // the end of GT payload, produce empty products and quit unpacking
551  if ((ptrGt + m_gtFdlWord->getSize()) > endPtrGt) {
552  edm::LogError("L1GlobalTriggerEvmRawToDigi")
553  << "\nError: Pointer after FDL " << iFdl << " greater than end pointer."
554  << "\n Put empty products in the event!"
555  << "\n Quit unpacking this event." << std::endl;
556 
558 
559  return;
560  }
561 
562  // unpack only if requested, otherwise skip it
563  if (activeBoardToUnpack) {
564  // unpack only bxInEvent requested, otherwise skip it
565  if ((iFdl >= m_lowSkipBxInEvent) && (iFdl < m_uppSkipBxInEvent)) {
566  m_gtFdlWord->unpack(ptrGt);
567 
568  // add 1 to the GT luminosity number to use the same convention as
569  // offline, where LS number starts with 1;
570  // in GT hardware, LS starts with 0
571  cms_uint16_t lsNr = m_gtFdlWord->lumiSegmentNr() + 1;
573 
574  // add FDL block to GT readout record
575  gtReadoutRecord->setGtFdlWord(*m_gtFdlWord);
576 
577  if (m_verbosity && m_isDebugEnabled) {
578  std::ostringstream myCoutStream;
579  m_gtFdlWord->print(myCoutStream);
580  LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n" << std::endl;
581  }
582 
583  // ... and reset it
584  m_gtFdlWord->reset();
585  }
586  }
587 
588  ptrGt += m_gtFdlWord->getSize(); // advance with FDL block size
589  }
590  }
591 
592  break;
593  default: {
594  // do nothing, all blocks are given in GtBoardType enum
595  if (m_verbosity) {
596  LogDebug("L1GlobalTriggerEvmRawToDigi")
597  << "\nBoard of type " << itBoard->gtBoardType() << " not expected in record.\n"
598  << std::endl;
599  }
600  } break;
601  }
602  }
603 
604  // add GTFE block to GT readout record, after updating active boards and record length
605 
606  gtReadoutRecord->setGtfeWord(*m_gtfeWord);
607 
608  // ... and reset it
609  m_gtfeWord->reset();
610 
611  // unpack trailer
612 
613  int trailerSize = 8;
614 
615  // if pointer after trailer is greater than pointer at
616  // the end of GT payload, produce empty products and quit unpacking
617  if ((ptrGt + trailerSize) > endPtrGt) {
618  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after trailer "
619  << " greater than end pointer."
620  << "\n Put empty products in the event!"
621  << "\n Quit unpacking this event." << std::endl;
622 
624 
625  return;
626  }
627 
628  unpackTrailer(ptrGt, cmsTrailer);
629 
630  if (m_verbosity && m_isDebugEnabled) {
631  std::ostringstream myCoutStream;
632  gtReadoutRecord->print(myCoutStream);
633  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n The following L1 GT EVM readout record was unpacked.\n"
634  << myCoutStream.str() << "\n"
635  << std::endl;
636  }
637 
638  // put records into event
639  iEvent.put(std::move(gtReadoutRecord));
640 }
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:689
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:567
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:151
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:595
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 730 of file L1GlobaTriggerEvmRawToDigi.cc.

References iEvent, and eostools::move().

Referenced by produce().

730  {
731  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(new L1GlobalTriggerEvmReadoutRecord());
732 
733  // put empty records into event
734 
735  iEvent.put(std::move(gtReadoutRecord));
736 }
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 643 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().

643  {
644  // TODO if needed in another format
645 
646  // print the header info
647  if (edm::isDebugEnabled()) {
648  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtPtr));
649 
650  std::ostringstream myCoutStream;
651 
652  // one word only
653  int iWord = 0;
654 
655  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16) << payload[iWord]
656  << std::dec << std::setfill(' ') << "\n"
657  << std::endl;
658 
659  myCoutStream << " Event_type: " << std::hex << " hex: "
660  << " " << std::setw(1) << std::setfill('0') << cmsHeader.triggerType() << std::setfill(' ')
661  << std::dec << " dec: " << cmsHeader.triggerType() << std::endl;
662 
663  myCoutStream << " LVL1_Id: " << std::hex << " hex: "
664  << "" << std::setw(6) << std::setfill('0') << cmsHeader.lvl1ID() << std::setfill(' ') << std::dec
665  << " dec: " << cmsHeader.lvl1ID() << std::endl;
666 
667  myCoutStream << " BX_Id: " << std::hex << " hex: "
668  << " " << std::setw(3) << std::setfill('0') << cmsHeader.bxID() << std::setfill(' ') << std::dec
669  << " dec: " << cmsHeader.bxID() << std::endl;
670 
671  myCoutStream << " Source_Id: " << std::hex << " hex: "
672  << " " << std::setw(3) << std::setfill('0') << cmsHeader.sourceID() << std::setfill(' ') << std::dec
673  << " dec: " << cmsHeader.sourceID() << std::endl;
674 
675  myCoutStream << " FOV: " << std::hex << " hex: "
676  << " " << std::setw(1) << std::setfill('0') << cmsHeader.version() << std::setfill(' ') << std::dec
677  << " dec: " << cmsHeader.version() << std::endl;
678 
679  myCoutStream << " H: " << std::hex << " hex: "
680  << " " << std::setw(1) << std::setfill('0') << cmsHeader.moreHeaders() << std::setfill(' ')
681  << std::dec << " dec: " << cmsHeader.moreHeaders() << std::endl;
682 
683  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Header \n" << myCoutStream.str() << "\n" << std::endl;
684  }
685 }
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 689 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().

689  {
690  // TODO if needed in another format
691 
692  // print the trailer info
693  if (m_verbosity && m_isDebugEnabled) {
694  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(trlPtr));
695 
696  std::ostringstream myCoutStream;
697 
698  // one word only
699  int iWord = 0;
700 
701  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16) << payload[iWord]
702  << std::dec << std::setfill(' ') << "\n"
703  << std::endl;
704 
705  myCoutStream << " Event_length: " << std::hex << " hex: "
706  << "" << std::setw(6) << std::setfill('0') << cmsTrailer.fragmentLength() << std::setfill(' ')
707  << std::dec << " dec: " << cmsTrailer.fragmentLength() << std::endl;
708 
709  myCoutStream << " CRC: " << std::hex << " hex: "
710  << " " << std::setw(4) << std::setfill('0') << cmsTrailer.crc() << std::setfill(' ') << std::dec
711  << " dec: " << cmsTrailer.crc() << std::endl;
712 
713  myCoutStream << " Event_status: " << std::hex << " hex: "
714  << " " << std::setw(2) << std::setfill('0') << cmsTrailer.evtStatus() << std::setfill(' ')
715  << std::dec << " dec: " << cmsTrailer.evtStatus() << std::endl;
716 
717  myCoutStream << " TTS_bits: " << std::hex << " hex: "
718  << " " << std::setw(1) << std::setfill('0') << cmsTrailer.ttsBits() << std::setfill(' ')
719  << std::dec << " dec: " << cmsTrailer.ttsBits() << std::endl;
720 
721  myCoutStream << " More trailers: " << std::hex << " hex: "
722  << " " << std::setw(1) << std::setfill('0') << cmsTrailer.moreTrailers() << std::setfill(' ')
723  << std::dec << " dec: " << cmsTrailer.moreTrailers() << std::endl;
724 
725  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Trailer \n" << myCoutStream.str() << "\n" << std::endl;
726  }
727 }
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().