CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1GlobalTriggerEvmRawToDigi Class Reference

#include <L1GlobalTriggerEvmRawToDigi.h>

Inheritance diagram for L1GlobalTriggerEvmRawToDigi:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 L1GlobalTriggerEvmRawToDigi (const edm::ParameterSet &)
 constructor(s) More...
 
virtual ~L1GlobalTriggerEvmRawToDigi ()
 destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
void dumpFedRawData (const unsigned char *, int, std::ostream &)
 dump FED raw data More...
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
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::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: unpack EVM raw data into digitized data.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Description: unpack raw data into digitized data.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Definition at line 46 of file L1GlobalTriggerEvmRawToDigi.h.

Constructor & Destructor Documentation

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

constructor(s)

Definition at line 58 of file L1GlobaTriggerEvmRawToDigi.cc.

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

58  :
59 
60  // input tag for EVM GT record
61  m_evmGtInputTag(pSet.getParameter<edm::InputTag> ("EvmGtInputTag")),
62 
63  // FED Id for GT EVM record
64  // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
65  // default value: assume the EVM record is the first GT record
67  "EvmGtFedId", FEDNumbering::MINTriggerGTPFEDID)),
68 
69  // mask for active boards
70  m_activeBoardsMaskGt(pSet.getParameter<unsigned int> ("ActiveBoardsMask")),
71 
72  // number of bunch crossing to be unpacked
73  m_unpackBxInEvent(pSet.getParameter<int> ("UnpackBxInEvent")),
74 
76 
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 
90  produces<L1GlobalTriggerEvmReadoutRecord> ();
91 
93 
94  LogDebug("L1GlobalTriggerEvmRawToDigi")
95  << "\nInput tag for EVM GT record: " << m_evmGtInputTag
96  << "\nFED Id for EVM GT record: " << m_evmGtFedId
97  << "\nMask for active boards (hex format): " << std::hex
98  << std::setw(sizeof(m_activeBoardsMaskGt) * 2) << std::setfill('0')
100  << std::dec << std::setfill(' ')
101  << "\nNumber of bunch crossing to be unpacked: " << m_unpackBxInEvent
102  << "\nLength of BST message [bytes]: " << m_bstLengthBytes << "\n"
103  << std::endl;
104  }
105 
106  if ( ( m_unpackBxInEvent > 0 ) && ( ( m_unpackBxInEvent % 2 ) == 0 )) {
108 
109  if (m_verbosity) {
110  edm::LogInfo("L1GlobalTriggerEvmRawToDigi")
111  << "\nWARNING: Number of bunch crossing to be unpacked rounded to: "
112  << m_unpackBxInEvent << "\n The number must be an odd number!\n"
113  << std::endl;
114  }
115  }
116 
117  // create GTFE, TCS, FDL cards once per analyzer
118  // content will be reset whenever needed
119 
120  m_gtfeWord = new L1GtfeExtWord();
121  m_tcsWord = new L1TcsWord();
122  m_gtFdlWord = new L1GtFdlWord();
123 
124 }
#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 &amp; 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 ( )
virtual

destructor

Definition at line 127 of file L1GlobaTriggerEvmRawToDigi.cc.

References m_gtFdlWord, m_gtfeWord, and m_tcsWord.

127  {
128 
129  delete m_gtfeWord;
130  delete m_tcsWord;
131  delete m_gtFdlWord;
132 
133 }

Member Function Documentation

void L1GlobalTriggerEvmRawToDigi::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 137 of file L1GlobaTriggerEvmRawToDigi.cc.

137  {
138 
139  // empty now
140 
141 }
void L1GlobalTriggerEvmRawToDigi::dumpFedRawData ( const unsigned char *  gtPtr,
int  gtSize,
std::ostream &  myCout 
)
private

dump FED raw data

Definition at line 807 of file L1GlobaTriggerEvmRawToDigi.cc.

References i, LogDebug, LogTrace, L1GlobalTriggerReadoutSetup::UnitLength, and L1GlobalTriggerReadoutSetup::WordLength.

Referenced by produce().

808  {
809 
810  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nDump FED raw data.\n" << std::endl;
811 
814 
815  int gtWords = gtSize / uLength;
816  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\nFED GT words (" << wLength << " bits):"
817  << gtWords << "\n" << std::endl;
818 
819  const cms_uint64_t* payload =
820  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned char*> (gtPtr));
821 
822  for (unsigned int i = 0; i < gtSize / sizeof(cms_uint64_t); i++) {
823  myCout << std::setw(4) << i << " " << std::hex << std::setfill('0') << std::setw(16)
824  << payload[i] << std::dec << std::setfill(' ') << std::endl;
825  }
826 
827 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
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::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 830 of file L1GlobaTriggerEvmRawToDigi.cc.

830  {
831 
832  // empty now
833 }
void L1GlobalTriggerEvmRawToDigi::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 144 of file L1GlobaTriggerEvmRawToDigi.cc.

References L1GtfeWord::activeBoards(), L1GtfeWord::altNrBxBoard(), FEDRawData::data(), dumpFedRawData(), FDL, edm::EventSetup::get(), edm::Event::getByLabel(), L1GtfeExtWord::getSize(), L1TcsWord::getSize(), L1GtFdlWord::getSize(), GMT, 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, max(), L1GtfeExtWord::print(), L1TcsWord::print(), L1GtFdlWord::print(), produceEmptyProducts(), edm::Handle< T >::product(), edm::ESHandle< class >::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().

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

References edm::Event::put().

Referenced by produce().

796  {
797 
798  std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
800 
801  // put empty records into event
802 
803  iEvent.put(gtReadoutRecord);
804 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void L1GlobalTriggerEvmRawToDigi::unpackHeader ( const unsigned char *  gtPtr,
FEDHeader cmsHeader 
)
private

block unpackers

unpack header

Definition at line 697 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Referenced by produce().

697  {
698 
699  // TODO if needed in another format
700 
701  // print the header info
702  if (edm::isDebugEnabled()) {
703 
704  const cms_uint64_t* payload =
705  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned char*> (gtPtr));
706 
707  std::ostringstream myCoutStream;
708 
709  // one word only
710  int iWord = 0;
711 
712  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0')
713  << std::setw(16) << payload[iWord] << std::dec << std::setfill(' ') << "\n"
714  << std::endl;
715 
716  myCoutStream << " Event_type: " << std::hex << " hex: " << " " << std::setw(1)
717  << std::setfill('0') << cmsHeader.triggerType() << std::setfill(' ') << std::dec
718  << " dec: " << cmsHeader.triggerType() << std::endl;
719 
720  myCoutStream << " LVL1_Id: " << std::hex << " hex: " << "" << std::setw(6)
721  << std::setfill('0') << cmsHeader.lvl1ID() << std::setfill(' ') << std::dec
722  << " dec: " << cmsHeader.lvl1ID() << std::endl;
723 
724  myCoutStream << " BX_Id: " << std::hex << " hex: " << " " << std::setw(3)
725  << std::setfill('0') << cmsHeader.bxID() << std::setfill(' ') << std::dec
726  << " dec: " << cmsHeader.bxID() << std::endl;
727 
728  myCoutStream << " Source_Id: " << std::hex << " hex: " << " " << std::setw(3)
729  << std::setfill('0') << cmsHeader.sourceID() << std::setfill(' ') << std::dec
730  << " dec: " << cmsHeader.sourceID() << std::endl;
731 
732  myCoutStream << " FOV: " << std::hex << " hex: " << " " << std::setw(1)
733  << std::setfill('0') << cmsHeader.version() << std::setfill(' ') << std::dec
734  << " dec: " << cmsHeader.version() << std::endl;
735 
736  myCoutStream << " H: " << std::hex << " hex: " << " " << std::setw(1)
737  << std::setfill('0') << cmsHeader.moreHeaders() << std::setfill(' ') << std::dec
738  << " dec: " << cmsHeader.moreHeaders() << std::endl;
739 
740  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Header \n" << myCoutStream.str() << "\n"
741  << std::endl;
742 
743  }
744 
745 }
#define LogDebug(id)
bool isDebugEnabled()
int version()
Version identifier of the FED data format.
Definition: FEDHeader.cc:34
int sourceID()
Identifier of the FED.
Definition: FEDHeader.cc:30
bool moreHeaders()
Definition: FEDHeader.cc:38
int bxID()
The bunch crossing number.
Definition: FEDHeader.cc:26
int lvl1ID()
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:22
unsigned long long cms_uint64_t
Definition: typedefs.h:17
int triggerType()
Event Trigger type identifier.
Definition: FEDHeader.cc:18
void L1GlobalTriggerEvmRawToDigi::unpackTrailer ( const unsigned char *  trlPtr,
FEDTrailer cmsTrailer 
)
private

unpack trailer word

Definition at line 749 of file L1GlobaTriggerEvmRawToDigi.cc.

References FEDTrailer::crc(), FEDTrailer::evtStatus(), FEDTrailer::lenght(), LogDebug, m_isDebugEnabled, m_verbosity, FEDTrailer::moreTrailers(), and FEDTrailer::ttsBits().

Referenced by produce().

749  {
750 
751  // TODO if needed in another format
752 
753  // print the trailer info
754  if (m_verbosity && m_isDebugEnabled) {
755 
756  const cms_uint64_t* payload =
757  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned char*> (trlPtr));
758 
759  std::ostringstream myCoutStream;
760 
761  // one word only
762  int iWord = 0;
763 
764  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0')
765  << std::setw(16) << payload[iWord] << std::dec << std::setfill(' ') << "\n"
766  << std::endl;
767 
768  myCoutStream << " Event_length: " << std::hex << " hex: " << "" << std::setw(6)
769  << std::setfill('0') << cmsTrailer.lenght() << std::setfill(' ') << std::dec
770  << " dec: " << cmsTrailer.lenght() << std::endl;
771 
772  myCoutStream << " CRC: " << std::hex << " hex: " << " " << std::setw(4)
773  << std::setfill('0') << cmsTrailer.crc() << std::setfill(' ') << std::dec
774  << " dec: " << cmsTrailer.crc() << std::endl;
775 
776  myCoutStream << " Event_status: " << std::hex << " hex: " << " " << std::setw(2)
777  << std::setfill('0') << cmsTrailer.evtStatus() << std::setfill(' ') << std::dec
778  << " dec: " << cmsTrailer.evtStatus() << std::endl;
779 
780  myCoutStream << " TTS_bits: " << std::hex << " hex: " << " " << std::setw(1)
781  << std::setfill('0') << cmsTrailer.ttsBits() << std::setfill(' ') << std::dec
782  << " dec: " << cmsTrailer.ttsBits() << std::endl;
783 
784  myCoutStream << " More trailers: " << std::hex << " hex: " << " " << std::setw(1)
785  << std::setfill('0') << cmsTrailer.moreTrailers() << std::setfill(' ') << std::dec
786  << " dec: " << cmsTrailer.moreTrailers() << std::endl;
787 
788  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Trailer \n" << myCoutStream.str()
789  << "\n" << std::endl;
790 
791  }
792 
793 }
#define LogDebug(id)
int evtStatus()
Event fragment status information.
Definition: FEDTrailer.cc:29
bool moreTrailers()
Definition: FEDTrailer.cc:39
int ttsBits()
Current value of the Trigger Throttling System bitsAQ).
Definition: FEDTrailer.cc:34
int lenght()
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:19
int crc()
Cyclic Redundancy Code of the event fragment including header and trailer.
Definition: FEDTrailer.cc:24
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 94 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

int L1GlobalTriggerEvmRawToDigi::m_bstLengthBytes
private

length of BST record (in bytes)

Definition at line 120 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 91 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

edm::InputTag L1GlobalTriggerEvmRawToDigi::m_evmGtInputTag
private

input tags for GT EVM record

Definition at line 87 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 101 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 110 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_recordLength1
private

corresponding to alternative 1 in altNrBxBoard()

Definition at line 113 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 116 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_unpackBxInEvent
private

Definition at line 97 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 105 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_verbosity
private

verbosity level

Definition at line 125 of file L1GlobalTriggerEvmRawToDigi.h.

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