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

boost::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)
 
- 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 45 of file L1GlobalTriggerEvmRawToDigi.h.

Constructor & Destructor Documentation

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

constructor(s)

Definition at line 59 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.

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

References m_gtFdlWord, m_gtfeWord, and m_tcsWord.

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

Member Function Documentation

void L1GlobalTriggerEvmRawToDigi::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 138 of file L1GlobaTriggerEvmRawToDigi.cc.

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

dump FED raw data

Definition at line 808 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Referenced by produce().

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

Reimplemented from edm::EDProducer.

Definition at line 831 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Implements edm::EDProducer.

Definition at line 145 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 python.JSONExport.JsonExport::export(), and python.HTMLExport.HTMLExport::export().

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

References edm::Event::put().

Referenced by produce().

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

block unpackers

unpack header

Definition at line 698 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Referenced by produce().

698  {
699 
700  // TODO if needed in another format
701 
702  // print the header info
703  if (edm::isDebugEnabled()) {
704 
705  const boost::uint64_t* payload =
706  reinterpret_cast<boost::uint64_t*> (const_cast<unsigned char*> (gtPtr));
707 
708  std::ostringstream myCoutStream;
709 
710  // one word only
711  int iWord = 0;
712 
713  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0')
714  << std::setw(16) << payload[iWord] << std::dec << std::setfill(' ') << "\n"
715  << std::endl;
716 
717  myCoutStream << " Event_type: " << std::hex << " hex: " << " " << std::setw(1)
718  << std::setfill('0') << cmsHeader.triggerType() << std::setfill(' ') << std::dec
719  << " dec: " << cmsHeader.triggerType() << std::endl;
720 
721  myCoutStream << " LVL1_Id: " << std::hex << " hex: " << "" << std::setw(6)
722  << std::setfill('0') << cmsHeader.lvl1ID() << std::setfill(' ') << std::dec
723  << " dec: " << cmsHeader.lvl1ID() << std::endl;
724 
725  myCoutStream << " BX_Id: " << std::hex << " hex: " << " " << std::setw(3)
726  << std::setfill('0') << cmsHeader.bxID() << std::setfill(' ') << std::dec
727  << " dec: " << cmsHeader.bxID() << std::endl;
728 
729  myCoutStream << " Source_Id: " << std::hex << " hex: " << " " << std::setw(3)
730  << std::setfill('0') << cmsHeader.sourceID() << std::setfill(' ') << std::dec
731  << " dec: " << cmsHeader.sourceID() << std::endl;
732 
733  myCoutStream << " FOV: " << std::hex << " hex: " << " " << std::setw(1)
734  << std::setfill('0') << cmsHeader.version() << std::setfill(' ') << std::dec
735  << " dec: " << cmsHeader.version() << std::endl;
736 
737  myCoutStream << " H: " << std::hex << " hex: " << " " << std::setw(1)
738  << std::setfill('0') << cmsHeader.moreHeaders() << std::setfill(' ') << std::dec
739  << " dec: " << cmsHeader.moreHeaders() << std::endl;
740 
741  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Header \n" << myCoutStream.str() << "\n"
742  << std::endl;
743 
744  }
745 
746 }
#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
unsigned long long uint64_t
Definition: Time.h:15
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
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 750 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Referenced by produce().

750  {
751 
752  // TODO if needed in another format
753 
754  // print the trailer info
755  if (m_verbosity && m_isDebugEnabled) {
756 
757  const boost::uint64_t* payload =
758  reinterpret_cast<boost::uint64_t*> (const_cast<unsigned char*> (trlPtr));
759 
760  std::ostringstream myCoutStream;
761 
762  // one word only
763  int iWord = 0;
764 
765  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0')
766  << std::setw(16) << payload[iWord] << std::dec << std::setfill(' ') << "\n"
767  << std::endl;
768 
769  myCoutStream << " Event_length: " << std::hex << " hex: " << "" << std::setw(6)
770  << std::setfill('0') << cmsTrailer.lenght() << std::setfill(' ') << std::dec
771  << " dec: " << cmsTrailer.lenght() << std::endl;
772 
773  myCoutStream << " CRC: " << std::hex << " hex: " << " " << std::setw(4)
774  << std::setfill('0') << cmsTrailer.crc() << std::setfill(' ') << std::dec
775  << " dec: " << cmsTrailer.crc() << std::endl;
776 
777  myCoutStream << " Event_status: " << std::hex << " hex: " << " " << std::setw(2)
778  << std::setfill('0') << cmsTrailer.evtStatus() << std::setfill(' ') << std::dec
779  << " dec: " << cmsTrailer.evtStatus() << std::endl;
780 
781  myCoutStream << " TTS_bits: " << std::hex << " hex: " << " " << std::setw(1)
782  << std::setfill('0') << cmsTrailer.ttsBits() << std::setfill(' ') << std::dec
783  << " dec: " << cmsTrailer.ttsBits() << std::endl;
784 
785  myCoutStream << " More trailers: " << std::hex << " hex: " << " " << std::setw(1)
786  << std::setfill('0') << cmsTrailer.moreTrailers() << std::setfill(' ') << std::dec
787  << " dec: " << cmsTrailer.moreTrailers() << std::endl;
788 
789  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Trailer \n" << myCoutStream.str()
790  << "\n" << std::endl;
791 
792  }
793 
794 }
#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
unsigned long long uint64_t
Definition: Time.h:15
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

Member Data Documentation

boost::uint16_t L1GlobalTriggerEvmRawToDigi::m_activeBoardsMaskGt
private

mask for active boards

Definition at line 93 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

int L1GlobalTriggerEvmRawToDigi::m_bstLengthBytes
private

length of BST record (in bytes)

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

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

edm::InputTag L1GlobalTriggerEvmRawToDigi::m_evmGtInputTag
private

input tags for GT EVM record

Definition at line 86 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 100 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 109 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_recordLength1
private

corresponding to alternative 1 in altNrBxBoard()

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

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_unpackBxInEvent
private

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

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_verbosity
private

verbosity level

Definition at line 124 of file L1GlobalTriggerEvmRawToDigi.h.

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