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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1GlobalTriggerEvmRawToDigi (const edm::ParameterSet &)
 constructor(s) More...
 
virtual ~L1GlobalTriggerEvmRawToDigi ()
 destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 44 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 LogDebug, m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_gtFdlWord, m_gtfeWord, m_isDebugEnabled, m_tcsWord, m_unpackBxInEvent, and m_verbosity.

56  :
57 
58  // input tag for EVM GT record
59  m_evmGtInputTag(pSet.getParameter<edm::InputTag> ("EvmGtInputTag")),
60 
61  // FED Id for GT EVM record
62  // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
63  // default value: assume the EVM record is the first GT record
65  "EvmGtFedId", FEDNumbering::MINTriggerGTPFEDID)),
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 
74 
76 
78 
79  // length of BST record (in bytes)
80  m_bstLengthBytes(pSet.getParameter<int> ("BstLengthBytes")),
81 
82  m_verbosity(pSet.getUntrackedParameter<int> ("Verbosity", 0)),
83 
85 
86 {
87 
88  produces<L1GlobalTriggerEvmReadoutRecord> ();
89 
91 
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
96  << std::setw(sizeof(m_activeBoardsMaskGt) * 2) << std::setfill('0')
98  << std::dec << std::setfill(' ')
99  << "\nNumber of bunch crossing to be unpacked: " << m_unpackBxInEvent
100  << "\nLength of BST message [bytes]: " << m_bstLengthBytes << "\n"
101  << std::endl;
102  }
103 
104  if ( ( m_unpackBxInEvent > 0 ) && ( ( m_unpackBxInEvent % 2 ) == 0 )) {
106 
107  if (m_verbosity) {
108  edm::LogInfo("L1GlobalTriggerEvmRawToDigi")
109  << "\nWARNING: Number of bunch crossing to be unpacked rounded to: "
110  << m_unpackBxInEvent << "\n The number must be an odd number!\n"
111  << std::endl;
112  }
113  }
114 
115  // create GTFE, TCS, FDL cards once per analyzer
116  // content will be reset whenever needed
117 
118  m_gtfeWord = new L1GtfeExtWord();
119  m_tcsWord = new L1TcsWord();
120  m_gtFdlWord = new L1GtFdlWord();
121 
122 }
#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 125 of file L1GlobaTriggerEvmRawToDigi.cc.

References m_gtFdlWord, m_gtfeWord, and m_tcsWord.

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

Member Function Documentation

void L1GlobalTriggerEvmRawToDigi::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 135 of file L1GlobaTriggerEvmRawToDigi.cc.

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

dump FED raw data

Definition at line 805 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Referenced by produce().

806  {
807 
808  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nDump FED raw data.\n" << std::endl;
809 
812 
813  int gtWords = gtSize / uLength;
814  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\nFED GT words (" << wLength << " bits):"
815  << gtWords << "\n" << std::endl;
816 
817  const cms_uint64_t* payload =
818  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned char*> (gtPtr));
819 
820  for (unsigned int i = 0; i < gtSize / sizeof(cms_uint64_t); i++) {
821  myCout << std::setw(4) << i << " " << std::hex << std::setfill('0') << std::setw(16)
822  << payload[i] << std::dec << std::setfill(' ') << std::endl;
823  }
824 
825 }
#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 828 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Implements edm::EDProducer.

Definition at line 142 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().

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

References edm::Event::put().

Referenced by produce().

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

block unpackers

unpack header

Definition at line 695 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Referenced by produce().

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

unpack trailer word

Definition at line 747 of file L1GlobaTriggerEvmRawToDigi.cc.

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

Referenced by produce().

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

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

int L1GlobalTriggerEvmRawToDigi::m_bstLengthBytes
private

length of BST record (in bytes)

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

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

edm::InputTag L1GlobalTriggerEvmRawToDigi::m_evmGtInputTag
private

input tags for GT EVM record

Definition at line 85 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 99 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 108 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_recordLength1
private

corresponding to alternative 1 in altNrBxBoard()

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

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_unpackBxInEvent
private

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

Referenced by produce().

int L1GlobalTriggerEvmRawToDigi::m_verbosity
private

verbosity level

Definition at line 123 of file L1GlobalTriggerEvmRawToDigi.h.

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