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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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
 
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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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 43 of file L1GlobalTriggerEvmRawToDigi.h.

Constructor & Destructor Documentation

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

constructor(s)

Definition at line 56 of file L1GlobaTriggerEvmRawToDigi.cc.

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

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

destructor

Definition at line 123 of file L1GlobaTriggerEvmRawToDigi.cc.

References m_gtFdlWord, m_gtfeWord, and m_tcsWord.

123  {
124  delete m_gtfeWord;
125  delete m_tcsWord;
126  delete m_gtFdlWord;
127 }

Member Function Documentation

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, jets_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 }
#define LogDebug(id)
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
void L1GlobalTriggerEvmRawToDigi::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
overrideprivate

Definition at line 132 of file L1GlobaTriggerEvmRawToDigi.cc.

References L1GtfeWord::activeBoards(), L1GtfeWord::altNrBxBoard(), FEDRawData::data(), TauDecayModes::dec, dumpFedRawData(), FDL, edm::EventSetup::get(), edm::Event::getByLabel(), L1GtfeExtWord::getSize(), L1TcsWord::getSize(), L1GtFdlWord::getSize(), GMT, L1GtBoardMaps::gtBoardMaps(), L1GtParameters::gtBstLengthBytes(), GTFE, edm::HandleBase::isValid(), LogDebug, LogTrace, L1TcsWord::luminositySegmentNr(), L1GtFdlWord::lumiSegmentNr(), m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_gtFdlWord, m_gtfeWord, m_isDebugEnabled, 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, edm::Event::put(), 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().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

132  {
133  // get records from EventSetup
134 
135  // board maps
137  evSetup.get<L1GtBoardMapsRcd>().get(l1GtBM);
138 
139  const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
140  int boardMapsSize = boardMaps.size();
141 
142  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
143 
144  // create an ordered vector for the GT EVM record
145  // header (pos 0 in record) and trailer (last position in record)
146  // not included, as they are not in board list
147  std::vector<L1GtBoard> gtRecordMap;
148  gtRecordMap.reserve(boardMapsSize);
149 
150  for (int iPos = 0; iPos < boardMapsSize; ++iPos) {
151  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
152  if (itBoard->gtPositionEvmRecord() == iPos) {
153  gtRecordMap.push_back(*itBoard);
154  break;
155  }
156  }
157  }
158 
159  // raw collection
160 
162  iEvent.getByLabel(m_evmGtInputTag, fedHandle);
163 
164  if (!fedHandle.isValid()) {
165  if (m_verbosity) {
166  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
167  << "\nWarning: FEDRawDataCollection with input tag " << m_evmGtInputTag
168  << "\nrequested in configuration, but not found in the event."
169  << "\nQuit unpacking this event" << std::endl;
170  }
171 
172  produceEmptyProducts(iEvent);
173 
174  return;
175  }
176 
177  // retrieve data for Global Trigger EVM FED
178  const FEDRawData& raw = (fedHandle.product())->FEDData(m_evmGtFedId);
179 
180  int gtSize = raw.size();
181 
182  // get a const pointer to the beginning of the data buffer
183  const unsigned char* ptrGt = raw.data();
184 
185  // get a const pointer to the end of the data buffer
186  const unsigned char* endPtrGt = ptrGt + gtSize;
187 
188  //
189  if (m_verbosity && m_isDebugEnabled) {
190  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Size of raw data: " << gtSize << "\n" << std::endl;
191 
192  std::ostringstream myCoutStream;
193  dumpFedRawData(ptrGt, gtSize, myCoutStream);
194 
195  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Dump FEDRawData\n" << myCoutStream.str() << "\n" << std::endl;
196  }
197 
198  // unpack header
199  int headerSize = 8;
200 
201  if ((ptrGt + headerSize) > endPtrGt) {
202  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after header greater than end pointer."
203  << "\n Put empty products in the event!"
204  << "\n Quit unpacking this event." << std::endl;
205 
206  produceEmptyProducts(iEvent);
207 
208  return;
209  }
210 
211  FEDHeader cmsHeader(ptrGt);
212  FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
213 
214  unpackHeader(ptrGt, cmsHeader);
215  ptrGt += headerSize; // advance with header size
216 
217  // unpack first GTFE to find the length of the record and the active boards
218  // here GTFE assumed immediately after the header
219 
220  bool gtfeUnpacked = false;
221 
222  // get the length of the BST message from parameter set or from event setup
223 
224  int bstLengthBytes = 0;
225 
226  if (m_bstLengthBytes < 0) {
227  // length from event setup // TODO cache it, if too slow
228 
230  evSetup.get<L1GtParametersRcd>().get(l1GtPar);
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 
273  produceEmptyProducts(iEvent);
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 
289  produceEmptyProducts(iEvent);
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 
516  produceEmptyProducts(iEvent);
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 
557  produceEmptyProducts(iEvent);
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 
623  produceEmptyProducts(iEvent);
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 }
#define LogDebug(id)
int m_bstLengthBytes
length of BST record (in bytes)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
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
void reset()
reset the content of a L1TcsWord
Definition: L1TcsWord.cc:259
void print(std::ostream &myCout) const override
pretty print the content of a L1GtfeExtWord
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
void unpack(const unsigned char *fdlPtr)
Definition: L1GtFdlWord.cc:689
const cms_uint16_t luminositySegmentNr() const
get/set luminosity segment number
Definition: L1TcsWord.h:121
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 unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtFdlWord.h:271
const cms_uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
Definition: L1GtfeWord.h:134
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
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 recordLength() const
get/set record length for alternative 0
Definition: L1GtfeWord.h:82
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
Definition: L1TcsWord.cc:274
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 setRecordLength1(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:73
void unpackHeader(const unsigned char *, FEDHeader &)
block unpackers
bool isValid() const
Definition: HandleBase.h:70
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
Definition: L1GtfeWord.h:119
#define LogTrace(id)
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:595
void resize(int bstSizeBytes)
resize the BST vector to get the right size of the block
int m_recordLength0
total Bx&#39;s in the event, obtained from GTFE block
const cms_uint16_t lumiSegmentNr() const
get/set luminosity segment number of the actual bx
Definition: L1GtFdlWord.h:247
T const * product() const
Definition: Handle.h:69
void setActiveBoards(cms_uint16_t activeBoardsValue)
Definition: L1GtfeWord.h:121
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 unpack(const unsigned char *tcsPtr)
Definition: L1TcsWord.cc:339
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
Definition: L1GtBoardMaps.h:43
T get() const
Definition: EventSetup.h:73
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
Definition: L1GtfeWord.h:71
void reset() override
reset the content of a L1GtfeExtWord
void unpackTrailer(const unsigned char *, FEDTrailer &)
unpack trailer word
T const * product() const
Definition: ESHandle.h:86
void unpack(const unsigned char *gtfePtr) override
def move(src, dest)
Definition: eostools.py:511
edm::InputTag m_evmGtInputTag
input tags for GT EVM record
void L1GlobalTriggerEvmRawToDigi::produceEmptyProducts ( edm::Event iEvent)
private

produce empty products in case of problems

Definition at line 730 of file L1GlobaTriggerEvmRawToDigi.cc.

References eostools::move(), and edm::Event::put().

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
def move(src, dest)
Definition: eostools.py:511
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(), jets_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 }
#define LogDebug(id)
bool isDebugEnabled()
uint8_t triggerType() const
Event Trigger type identifier.
Definition: FEDHeader.cc:13
bool moreHeaders() const
Definition: FEDHeader.cc:23
uint16_t sourceID() const
Identifier of the FED.
Definition: FEDHeader.cc:19
uint8_t version() const
Version identifier of the FED data format.
Definition: FEDHeader.cc:21
uint16_t bxID() const
The bunch crossing number.
Definition: FEDHeader.cc:17
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
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(), jets_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 }
#define LogDebug(id)
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
Definition: FEDTrailer.cc:15
bool moreTrailers() const
Definition: FEDTrailer.cc:21
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:13
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
Definition: FEDTrailer.cc:19
uint8_t evtStatus() const
Event fragment status information.
Definition: FEDTrailer.cc:17
unsigned long long cms_uint64_t
Definition: typedefs.h:17

Member Data Documentation

cms_uint16_t L1GlobalTriggerEvmRawToDigi::m_activeBoardsMaskGt
private

mask for active boards

Definition at line 81 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

int L1GlobalTriggerEvmRawToDigi::m_bstLengthBytes
private

length of BST record (in bytes)

Definition at line 106 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

int L1GlobalTriggerEvmRawToDigi::m_evmGtFedId
private

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

Definition at line 78 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

edm::InputTag L1GlobalTriggerEvmRawToDigi::m_evmGtInputTag
private

input tags for GT EVM record

Definition at line 74 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

L1GtFdlWord* L1GlobalTriggerEvmRawToDigi::m_gtFdlWord
private
L1GtfeExtWord* L1GlobalTriggerEvmRawToDigi::m_gtfeWord
private
bool L1GlobalTriggerEvmRawToDigi::m_isDebugEnabled
private
int L1GlobalTriggerEvmRawToDigi::m_lowSkipBxInEvent
private

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

Definition at line 88 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_recordLength0
private

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

corresponding to alternative 0 in altNrBxBoard()

Definition at line 97 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_recordLength1
private

corresponding to alternative 1 in altNrBxBoard()

Definition at line 100 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

L1TcsWord* L1GlobalTriggerEvmRawToDigi::m_tcsWord
private
int L1GlobalTriggerEvmRawToDigi::m_totalBxInEvent
private

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

Definition at line 103 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_unpackBxInEvent
private

Definition at line 84 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

int L1GlobalTriggerEvmRawToDigi::m_uppSkipBxInEvent
private

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

Definition at line 92 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_verbosity
private

verbosity level

Definition at line 110 of file L1GlobalTriggerEvmRawToDigi.h.

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