CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1GlobalTriggerRawToDigi Class Reference

#include <L1GlobalTriggerRawToDigi.h>

Inheritance diagram for L1GlobalTriggerRawToDigi:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1GlobalTriggerRawToDigi (const edm::ParameterSet &)
 constructor(s) More...
 
virtual ~L1GlobalTriggerRawToDigi ()
 destructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void dumpFedRawData (const unsigned char *, int, std::ostream &)
 dump FED raw data More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
void produceEmptyProducts (edm::Event &)
 produce empty products in case of problems More...
 
void unpackGMT (const unsigned char *, std::unique_ptr< L1MuGMTReadoutCollection > &, edm::Event &)
 unpack the GMT record More...
 
void unpackHeader (const unsigned char *, FEDHeader &)
 block unpackers More...
 
void unpackPSB (const edm::EventSetup &, const unsigned char *, L1GtPsbWord &)
 
void unpackTrailer (const unsigned char *, FEDTrailer &)
 unpack trailer word More...
 

Private Attributes

cms_uint16_t m_activeBoardsMaskGt
 mask for active boards More...
 
int m_daqGtFedId
 
edm::InputTag m_daqGtInputTag
 input tags for GT DAQ record More...
 
L1GtFdlWordm_gtFdlWord
 
L1GtfeWordm_gtfeWord
 
L1GtPsbWordm_gtPsbWord
 
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...
 
int m_totalBxInEvent
 number of Bx for a board, obtained from GTFE block (record length & alternative) More...
 
const L1MuTriggerPtScalem_TriggerPtScale
 
const L1MuTriggerScalesm_TriggerScales
 muon trigger scales to convert unpacked data into physical quantities More...
 
int m_unpackBxInEvent
 
int m_uppSkipBxInEvent
 
int m_verbosity
 verbosity level More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 raw data into digitized data.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna - GT
: Ivan Mikulec - HEPHY Vienna - GMT

Definition at line 49 of file L1GlobalTriggerRawToDigi.h.

Constructor & Destructor Documentation

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

constructor(s)

Definition at line 64 of file L1GlobaTriggerRawToDigi.cc.

References TauDecayModes::dec, LogDebug, m_activeBoardsMaskGt, m_daqGtFedId, m_daqGtInputTag, m_gtFdlWord, m_gtfeWord, m_gtPsbWord, m_isDebugEnabled, m_unpackBxInEvent, and m_verbosity.

64  :
65 
66  // input tag for DAQ GT record
67  m_daqGtInputTag(pSet.getParameter<edm::InputTag> ("DaqGtInputTag")),
68 
69  // FED Id for GT DAQ record
70  // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
71  // default value: assume the DAQ record is the last GT record
73  "DaqGtFedId", FEDNumbering::MAXTriggerGTPFEDID)),
74 
75  // mask for active boards
76  m_activeBoardsMaskGt(pSet.getParameter<unsigned int> ("ActiveBoardsMask")),
77 
78  // number of bunch crossing to be unpacked
79  m_unpackBxInEvent(pSet.getParameter<int> ("UnpackBxInEvent")),
80 
81  // create GTFE, FDL, PSB cards once per producer
82  // content will be reset whenever needed
83 
85 
87 
88  m_totalBxInEvent(0), m_verbosity(pSet.getUntrackedParameter<int> ("Verbosity", 0)),
89 
91 
92 {
93 
94  produces<L1GlobalTriggerReadoutRecord> ();
95  produces<L1MuGMTReadoutCollection> ();
96 
97  produces<std::vector<L1MuRegionalCand> > ("DT");
98  produces<std::vector<L1MuRegionalCand> > ("CSC");
99  produces<std::vector<L1MuRegionalCand> > ("RPCb");
100  produces<std::vector<L1MuRegionalCand> > ("RPCf");
101  produces<std::vector<L1MuGMTCand> > ();
102  consumes<FEDRawDataCollection>(m_daqGtInputTag);
103 
104  // create GTFE, FDL, PSB cards once per producer
105  // content will be reset whenever needed
106  m_gtfeWord = new L1GtfeWord();
107  m_gtFdlWord = new L1GtFdlWord();
108  m_gtPsbWord = new L1GtPsbWord();
109 
110  if (m_verbosity && m_isDebugEnabled) {
111 
112  LogDebug("L1GlobalTriggerRawToDigi")
113  << "\nInput tag for DAQ GT record: " << m_daqGtInputTag
114  << "\nFED Id for DAQ GT record: " << m_daqGtFedId
115  << "\nMask for active boards (hex format): " << std::hex
116  << std::setw(sizeof(m_activeBoardsMaskGt) * 2) << std::setfill('0')
118  << std::dec << std::setfill(' ')
119  << "\nNumber of bunch crossing to be unpacked: "
120  << m_unpackBxInEvent << "\n"
121  << std::endl;
122  }
123 
124  if ( ( m_unpackBxInEvent > 0 ) && ( ( m_unpackBxInEvent % 2 ) == 0 )) {
126 
127  if (m_verbosity) {
128  edm::LogInfo("L1GlobalTriggerRawToDigi")
129  << "\nWARNING: Number of bunch crossing to be unpacked rounded to: "
130  << m_unpackBxInEvent << "\n The number must be an odd number!\n"
131  << std::endl;
132  }
133  }
134 
135 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
T getUntrackedParameter(std::string const &, T const &) const
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
int m_recordLength0
total Bx&#39;s in the event, obtained from GTFE block
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
edm::InputTag m_daqGtInputTag
input tags for GT DAQ record
int m_totalBxInEvent
number of Bx for a board, obtained from GTFE block (record length & alternative)
L1GlobalTriggerRawToDigi::~L1GlobalTriggerRawToDigi ( )
virtual

destructor

Definition at line 138 of file L1GlobaTriggerRawToDigi.cc.

References m_gtFdlWord, m_gtfeWord, and m_gtPsbWord.

138  {
139 
140  delete m_gtfeWord;
141  delete m_gtFdlWord;
142  delete m_gtPsbWord;
143 
144 }

Member Function Documentation

void L1GlobalTriggerRawToDigi::dumpFedRawData ( const unsigned char *  gtPtr,
int  gtSize,
std::ostream &  myCout 
)
private

dump FED raw data

Definition at line 1058 of file L1GlobaTriggerRawToDigi.cc.

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

Referenced by produce().

1059  {
1060 
1061  LogDebug("L1GlobalTriggerRawToDigi") << "\nDump FED raw data.\n" << std::endl;
1062 
1065 
1066  int gtWords = gtSize / uLength;
1067  LogTrace("L1GlobalTriggerRawToDigi") << "\nFED GT words (" << wLength << " bits):" << gtWords
1068  << "\n" << std::endl;
1069 
1070  const cms_uint64_t* payload =
1071  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned char*> (gtPtr));
1072 
1073  for (unsigned int i = 0; i < gtSize / sizeof(cms_uint64_t); i++) {
1074  myCout << std::setw(4) << i << " " << std::hex << std::setfill('0') << std::setw(16)
1075  << payload[i] << std::dec << std::setfill(' ') << std::endl;
1076  }
1077 
1078 }
#define LogDebug(id)
static const int UnitLength
one unit in the word is UnitLength bits
static const int WordLength
GT DAQ record organized in words of WordLength bits.
payload
payload postfix for testing
#define LogTrace(id)
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void L1GlobalTriggerRawToDigi::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 146 of file L1GlobaTriggerRawToDigi.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and FEDNumbering::MAXTriggerGTPFEDID.

146  {
148  static const char* const kComm1=
149  "# input tag for GT readout collection: \n"
150  "# source = hardware record, \n"
151  "# l1GtPack = GT packer (DigiToRaw)";
152  desc.add<edm::InputTag>("DaqGtInputTag",edm::InputTag("l1GtPack"))->setComment(kComm1);
153  static const char* const kComm2=
154  "# FED Id for GT DAQ record \n"
155  "# default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc";
156  desc.addUntracked<int>("DaqGtFedId",FEDNumbering::MAXTriggerGTPFEDID)->setComment(kComm2);
157  static const char* const kComm3=
158  "# mask for active boards (actually 16 bits) \n"
159  "# if bit is zero, the corresponding board will not be unpacked \n"
160  "# default: no board masked";
161  desc.add<unsigned int>("ActiveBoardsMask",0xFFFF)->setComment(kComm3);
162  static const char* const kComm4=
163  "# number of 'bunch crossing in the event' (bxInEvent) to be unpacked \n"
164  "# symmetric around L1Accept (bxInEvent = 0): \n"
165  "# 1 (bxInEvent = 0); 3 (F 0 1) (standard record); 5 (E F 0 1 2) (debug record) \n"
166  "# even numbers (except 0) 'rounded' to the nearest lower odd number \n"
167  "# negative value: unpack all available bxInEvent \n"
168  "# if more bxInEvent than available are required, unpack what exists and write a warning";
169  desc.add<int>("UnpackBxInEvent",-1)->setComment(kComm4);
170  desc.addUntracked<int>("Verbosity",0);
171  descriptions.add("l1GlobalTriggerRawToDigi",desc);
172 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void L1GlobalTriggerRawToDigi::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
overrideprivatevirtual

Definition at line 178 of file L1GlobaTriggerRawToDigi.cc.

References L1GtfeWord::activeBoards(), L1GtfeWord::altNrBxBoard(), FEDRawData::data(), TauDecayModes::dec, dumpFedRawData(), FDL, edm::EventSetup::get(), edm::Event::getByLabel(), L1GtPsbWord::getSize(), L1GtfeWord::getSize(), L1GtFdlWord::getSize(), GMT, L1GtBoardMaps::gtBoardMaps(), GTFE, edm::HandleBase::isValid(), LogDebug, LogTrace, L1GtFdlWord::lumiSegmentNr(), m_activeBoardsMaskGt, m_daqGtFedId, m_daqGtInputTag, m_gtFdlWord, m_gtfeWord, m_gtPsbWord, m_isDebugEnabled, m_lowSkipBxInEvent, m_recordLength0, m_recordLength1, m_totalBxInEvent, m_TriggerPtScale, m_TriggerScales, m_unpackBxInEvent, m_uppSkipBxInEvent, m_verbosity, hpstanc_transforms::max, eostools::move(), L1GtPsbWord::print(), L1GtfeWord::print(), L1GtFdlWord::print(), produceEmptyProducts(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), PSB, edm::Event::put(), L1GtfeWord::recordLength(), L1GtfeWord::recordLength1(), L1GtPsbWord::reset(), L1GtfeWord::reset(), L1GtFdlWord::reset(), L1GtfeWord::setActiveBoards(), L1GtFdlWord::setLumiSegmentNr(), L1GtfeWord::setRecordLength(), L1GtfeWord::setRecordLength1(), FEDRawData::size(), TCS, TIM, L1GtfeWord::unpack(), L1GtFdlWord::unpack(), unpackGMT(), unpackHeader(), unpackPSB(), and unpackTrailer().

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

178  {
179 
180  // get records from EventSetup
181 
182  // muon trigger scales
184  evSetup.get<L1MuTriggerScalesRcd> ().get(trigscales_h);
185  m_TriggerScales = trigscales_h.product();
186 
187  edm::ESHandle<L1MuTriggerPtScale> trigptscale_h;
188  evSetup.get<L1MuTriggerPtScaleRcd> ().get(trigptscale_h);
189  m_TriggerPtScale = trigptscale_h.product();
190 
191  // board maps
193  evSetup.get<L1GtBoardMapsRcd> ().get(l1GtBM);
194 
195  const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
196  int boardMapsSize = boardMaps.size();
197 
198  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
199 
200  // create an ordered vector for the GT DAQ record
201  // header (pos 0 in record) and trailer (last position in record)
202  // not included, as they are not in board list
203  std::vector<L1GtBoard> gtRecordMap;
204  gtRecordMap.reserve(boardMapsSize);
205 
206  for (int iPos = 0; iPos < boardMapsSize; ++iPos) {
207  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
208 
209  if (itBoard->gtPositionDaqRecord() == iPos) {
210  gtRecordMap.push_back(*itBoard);
211  break;
212  }
213 
214  }
215  }
216 
217  // raw collection
218 
220  iEvent.getByLabel(m_daqGtInputTag, fedHandle);
221 
222  if (!fedHandle.isValid()) {
223  if (m_verbosity) {
224  edm::LogWarning("L1GlobalTriggerRawToDigi")
225  << "\nWarning: FEDRawDataCollection with input tag " << m_daqGtInputTag
226  << "\nrequested in configuration, but not found in the event."
227  << "\nQuit unpacking this event" << std::endl;
228  }
229 
230  produceEmptyProducts(iEvent);
231 
232  return;
233  }
234 
235  // retrieve data for Global Trigger FED (GT + GMT)
236  const FEDRawData& raw = ( fedHandle.product() )->FEDData(m_daqGtFedId);
237 
238  int gtSize = raw.size();
239 
240  // get a const pointer to the beginning of the data buffer
241  const unsigned char* ptrGt = raw.data();
242 
243  // get a const pointer to the end of the data buffer
244  const unsigned char* endPtrGt = ptrGt + gtSize;
245 
246  //
247  if (m_verbosity && m_isDebugEnabled) {
248 
249  LogTrace("L1GlobalTriggerRawToDigi") << "\n Size of raw data: "
250  << gtSize << "\n" << std::endl;
251 
252  std::ostringstream myCoutStream;
253  dumpFedRawData(ptrGt, gtSize, myCoutStream);
254 
255  LogTrace("L1GlobalTriggerRawToDigi") << "\n Dump FEDRawData\n"
256  << myCoutStream.str() << "\n" << std::endl;
257 
258  }
259 
260  // unpack header (we have one header only)
261  int headerSize = 8;
262 
263  if ((ptrGt + headerSize) > endPtrGt) {
264  // a common error - no need to print an error anymore
265  produceEmptyProducts(iEvent);
266 
267  return;
268  }
269 
270 
271  FEDHeader cmsHeader(ptrGt);
272  FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
273 
274  unpackHeader(ptrGt, cmsHeader);
275  ptrGt += headerSize; // advance with header size
276 
277  // unpack first GTFE to find the length of the record and the active boards
278  // here GTFE assumed immediately after the header
279 
280  // if pointer after GTFE payload is greater than pointer at
281  // the end of GT payload, produce empty products and quit unpacking
282  if ((ptrGt + m_gtfeWord->getSize()) > endPtrGt) {
283  edm::LogError("L1GlobalTriggerRawToDigi")
284  << "\nError: Pointer after GTFE greater than end pointer."
285  << "\n Put empty products in the event!"
286  << "\n Quit unpacking this event." << std::endl;
287 
288  produceEmptyProducts(iEvent);
289 
290  return;
291  }
292 
293  bool gtfeUnpacked = false;
294 
295  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
296 
297  if (itBoard->gtBoardType() == GTFE) {
298 
299  // unpack GTFE
300  if (itBoard->gtPositionDaqRecord() == 1) {
301 
302  m_gtfeWord->unpack(ptrGt);
303  ptrGt += m_gtfeWord->getSize(); // advance with GTFE block size
304  gtfeUnpacked = true;
305 
306  if (m_verbosity && m_isDebugEnabled) {
307 
308  std::ostringstream myCoutStream;
309  m_gtfeWord->print(myCoutStream);
310  LogTrace("L1GlobalTriggerRawToDigi") << myCoutStream.str() << "\n" << std::endl;
311  }
312 
313  // break the loop - GTFE was found
314  break;
315 
316  } else {
317 
318  if (m_verbosity) {
319  edm::LogWarning("L1GlobalTriggerRawToDigi")
320  << "\nWarning: GTFE block found in raw data does not follow header."
321  << "\nAssumed start position of the block is wrong!"
322  << "\nQuit unpacking this event" << std::endl;
323  }
324 
325  produceEmptyProducts(iEvent);
326 
327  return;
328  }
329 
330  }
331  }
332 
333  // quit if no GTFE found
334  if (!gtfeUnpacked) {
335 
336  if (m_verbosity) {
337  edm::LogWarning("L1GlobalTriggerRawToDigi")
338  << "\nWarning: no GTFE block found in raw data."
339  << "\nCan not find the record length (BxInEvent) and the active boards!"
340  << "\nQuit unpacking this event" << std::endl;
341  }
342 
343  produceEmptyProducts(iEvent);
344 
345  return;
346  }
347 
348  // life normal here, GTFE found
349 
350  // get list of active blocks
351  // blocks not active are not written to the record
352  cms_uint16_t activeBoardsGtInitial = m_gtfeWord->activeBoards();
353  cms_uint16_t altNrBxBoardInitial = m_gtfeWord->altNrBxBoard();
354 
355  // mask some boards, if needed
356  cms_uint16_t activeBoardsGt = activeBoardsGtInitial & m_activeBoardsMaskGt;
357  m_gtfeWord->setActiveBoards(activeBoardsGt);
358 
359  if (m_verbosity) {
360  LogDebug("L1GlobalTriggerRawToDigi") << "\nActive boards before masking: 0x" << std::hex
361  << std::setw(sizeof ( activeBoardsGtInitial ) * 2) << std::setfill('0')
362  << activeBoardsGtInitial << std::dec << std::setfill(' ')
363  << "\nActive boards after masking: 0x" << std::hex << std::setw(
364  sizeof ( activeBoardsGt ) * 2) << std::setfill('0') << activeBoardsGt << std::dec
365  << std::setfill(' ') << " \n" << std::endl;
366  }
367 
368  // loop over other blocks in the raw record, count them if they are active
369 
370  int numberGtfeBoards = 0;
371  int numberFdlBoards = 0;
372  int numberPsbBoards = 0;
373  int numberGmtBoards = 0;
374  int numberTcsBoards = 0;
375  int numberTimBoards = 0;
376 
377  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
378 
379  int iActiveBit = itBoard->gtBitDaqActiveBoards();
380  bool activeBoardToUnpack = false;
381 
382  if (iActiveBit >= 0) {
383  activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
384  } else {
385  // board not in the ActiveBoards for the record
386  continue;
387  }
388 
389  if (activeBoardToUnpack) {
390 
391  switch (itBoard->gtBoardType()) {
392  case GTFE: {
393  numberGtfeBoards++;
394  }
395 
396  break;
397  case FDL: {
398  numberFdlBoards++;
399  }
400 
401  break;
402  case PSB: {
403  numberPsbBoards++;
404  }
405 
406  break;
407  case GMT: {
408  numberGmtBoards++;
409  }
410 
411  break;
412  case TCS: {
413  numberTcsBoards++;
414  }
415 
416  break;
417  case TIM: {
418  numberTimBoards++;
419  }
420 
421  break;
422  default: {
423  // do nothing, all blocks are given in GtBoardType enum
424  if (m_verbosity) {
425  LogDebug("L1GlobalTriggerRawToDigi") << "\nBoard of type "
426  << itBoard->gtBoardType() << " not expected in record.\n"
427  << std::endl;
428  }
429  }
430 
431  break;
432  }
433  }
434 
435  }
436 
437  // produce the L1GlobalTriggerReadoutRecord now, after we found the maximum number of
438  // BxInEvent the record has and how many boards are active (it is just reserving space
439  // for vectors)
440  //LogDebug("L1GlobalTriggerRawToDigi")
441  //<< "\nL1GlobalTriggerRawToDigi: producing L1GlobalTriggerReadoutRecord\n"
442  //<< "\nL1GlobalTriggerRawToDigi: producing L1MuGMTReadoutCollection;\n"
443  //<< std::endl;
444 
445  // get number of Bx in the event from GTFE block corresponding to alternative 0 and 1 in
448 
449  int maxBxInEvent = std::max(m_recordLength0, m_recordLength1);
450 
451 
452  std::unique_ptr<L1GlobalTriggerReadoutRecord> gtReadoutRecord(new L1GlobalTriggerReadoutRecord(
453  maxBxInEvent, numberFdlBoards, numberPsbBoards));
454 
455  // produce also the GMT readout collection and set the reference in GT record
456  std::unique_ptr<L1MuGMTReadoutCollection> gmtrc(new L1MuGMTReadoutCollection(maxBxInEvent));
457 
458  //edm::RefProd<L1MuGMTReadoutCollection> refProdMuGMT = iEvent.getRefBeforePut<
459  // L1MuGMTReadoutCollection> ();
460 
461  //if (m_verbosity) {
462  // LogDebug("L1GlobalTriggerRawToDigi")
463  // << "\nL1GlobalTriggerRawToDigi: set L1MuGMTReadoutCollection RefProd"
464  // << " in L1GlobalTriggerReadoutRecord.\n" << std::endl;
465  //}
466  //gtReadoutRecord->setMuCollectionRefProd(refProdMuGMT);
467 
468 
469  // ... then unpack modules other than GTFE, if requested
470 
471  for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
472 
473  int iActiveBit = itBoard->gtBitDaqActiveBoards();
474 
475  bool activeBoardToUnpack = false;
476  bool activeBoardInitial = false;
477 
478  int altNrBxBoardVal = -1;
479 
480  if (iActiveBit >= 0) {
481  activeBoardInitial = activeBoardsGtInitial & ( 1 << iActiveBit );
482  activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
483 
484  altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
485 
486  if (altNrBxBoardVal == 1) {
488  } else if (altNrBxBoardVal == 0) {
490  } else {
491  if (m_verbosity) {
492  edm::LogWarning("L1GlobalTriggerRawToDigi")
493  << "\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
494  << " for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
495  << "\n iActiveBit = " << iActiveBit
496  << "\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
497  << "\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
498  << "\n activeBoardInitial = " << activeBoardInitial
499  << "\n activeBoardToUnpack = " << activeBoardToUnpack
500  << "\n Set altNrBxBoardVal tentatively to "
501  << m_recordLength0 << "\n Job may crash or produce wrong results!\n\n"
502  << std::endl;
503  }
504 
506  }
507 
508  // number of BX required to be unpacked
509 
511  if (m_verbosity) {
512  LogDebug("L1GlobalTriggerRawToDigi")
513  << "\nWARNING: Number of available bunch crosses for board"
514  << ( itBoard->gtBoardId() ) << " in the record ( " << m_totalBxInEvent
515  << " ) \n is smaller than the number of bunch crosses requested to be unpacked ("
516  << m_unpackBxInEvent << " )!!! \n Unpacking only "
517  << m_totalBxInEvent << " bunch crosses.\n" << std::endl;
518  }
519 
520  m_lowSkipBxInEvent = 0;
522 
523  } else if (m_unpackBxInEvent < 0) {
524 
525  m_lowSkipBxInEvent = 0;
527 
528  if (m_verbosity) {
529  LogDebug("L1GlobalTriggerRawToDigi") << "\nUnpacking all " << m_totalBxInEvent
530  << " bunch crosses available." << "\n" << std::endl;
531  }
532 
533 
534  } else if (m_unpackBxInEvent == 0) {
535 
538 
539  if (m_verbosity) {
540  LogDebug("L1GlobalTriggerRawToDigi")
541  << "\nNo bxInEvent required to be unpacked from " << m_totalBxInEvent
542  << " bunch crosses available." << "\n" << std::endl;
543  }
544 
545  // change RecordLength
546  // cast int to cms_uint16_t (there are normally 3 or 5 BxInEvent)
547  m_gtfeWord->setRecordLength(static_cast<cms_uint16_t> (m_unpackBxInEvent));
548  m_gtfeWord->setRecordLength1(static_cast<cms_uint16_t> (m_unpackBxInEvent));
549 
550  } else {
551 
554 
555  if (m_verbosity) {
556  LogDebug("L1GlobalTriggerRawToDigi") << "\nUnpacking " << m_unpackBxInEvent
557  << " bunch crosses from " << m_totalBxInEvent
558  << " bunch crosses available." << "\n" << std::endl;
559  }
560 
561  // change RecordLength
562  // cast int to cms_uint16_t (there are normally 3 or 5 BxInEvent)
563  m_gtfeWord->setRecordLength(static_cast<cms_uint16_t> (m_unpackBxInEvent));
564  m_gtfeWord->setRecordLength1(static_cast<cms_uint16_t> (m_unpackBxInEvent));
565 
566  }
567 
568  } else {
569  // board not in the ActiveBoards for the record
570  continue;
571  }
572 
573  if (!activeBoardInitial) {
574  if (m_verbosity) {
575  LogDebug("L1GlobalTriggerRawToDigi") << "\nBoard of type "
576  << itBoard->gtBoardName() << " with index " << itBoard->gtBoardIndex()
577  << " not active initially in raw data.\n" << std::endl;
578  }
579  continue;
580  }
581 
582  // active board initially, could unpack it
583  switch (itBoard->gtBoardType()) {
584 
585  case FDL: {
586  for (int iFdl = 0; iFdl < m_totalBxInEvent; ++iFdl) {
587 
588  // if pointer after FDL payload is greater than pointer at
589  // the end of GT payload, produce empty products and quit unpacking
590  if ((ptrGt + m_gtFdlWord->getSize()) > endPtrGt) {
591  edm::LogError("L1GlobalTriggerRawToDigi")
592  << "\nError: Pointer after FDL " << iFdl
593  << " greater than end pointer."
594  << "\n Put empty products in the event!"
595  << "\n Quit unpacking this event." << std::endl;
596 
597  produceEmptyProducts(iEvent);
598 
599  return;
600  }
601 
602  // unpack only if requested, otherwise skip it
603  if (activeBoardToUnpack) {
604 
605  // unpack only bxInEvent requested, otherwise skip it
606  if ( ( iFdl >= m_lowSkipBxInEvent ) && ( iFdl < m_uppSkipBxInEvent )) {
607 
608  m_gtFdlWord->unpack(ptrGt);
609 
610  // add 1 to the GT luminosity number to use the same convention as
611  // offline, where LS number starts with 1;
612  // in GT hardware, LS starts with 0
613  cms_uint16_t lsNr = m_gtFdlWord->lumiSegmentNr() + 1;
615 
616  // add FDL block to GT readout record
617  gtReadoutRecord->setGtFdlWord(*m_gtFdlWord);
618 
619  if (m_verbosity && m_isDebugEnabled) {
620 
621  std::ostringstream myCoutStream;
622  m_gtFdlWord->print(myCoutStream);
623  LogTrace("L1GlobalTriggerRawToDigi") << myCoutStream.str() << "\n"
624  << std::endl;
625  }
626 
627  // ... and reset it
628  m_gtFdlWord->reset();
629  }
630 
631  }
632 
633  ptrGt += m_gtFdlWord->getSize(); // advance with FDL block size
634 
635  }
636  }
637 
638  break;
639  case PSB: {
640  for (int iPsb = 0; iPsb < m_totalBxInEvent; ++iPsb) {
641 
642  // if pointer after PSB payload is greater than pointer at
643  // the end of GT payload, produce empty products and quit unpacking
644  if ((ptrGt + m_gtPsbWord->getSize()) > endPtrGt) {
645  edm::LogError("L1GlobalTriggerRawToDigi")
646  << "\nError: Pointer after PSB " << iPsb
647  << " greater than end pointer."
648  << "\n Put empty products in the event!"
649  << "\n Quit unpacking this event." << std::endl;
650 
651  produceEmptyProducts(iEvent);
652 
653  return;
654  }
655 
656  // unpack only if requested, otherwise skip it
657  if (activeBoardToUnpack) {
658 
659  // unpack only bxInEvent requested, otherwise skip it
660  if ( ( iPsb >= m_lowSkipBxInEvent ) && ( iPsb < m_uppSkipBxInEvent )) {
661 
662  unpackPSB(evSetup, ptrGt, *m_gtPsbWord);
663 
664  // add PSB block to GT readout record
665  gtReadoutRecord->setGtPsbWord(*m_gtPsbWord);
666 
667  if (m_verbosity && m_isDebugEnabled) {
668 
669  std::ostringstream myCoutStream;
670  m_gtPsbWord->print(myCoutStream);
671  LogTrace("L1GlobalTriggerRawToDigi") << myCoutStream.str() << "\n"
672  << std::endl;
673  }
674 
675  // ... and reset it
676  m_gtPsbWord->reset();
677  }
678 
679  }
680 
681  ptrGt += m_gtPsbWord->getSize(); // advance with PSB block size
682 
683  }
684  }
685  break;
686  case GMT: {
687 
688  // 17*64/8 TODO FIXME ask Ivan for a getSize() function for GMT record
689  unsigned int gmtRecordSize = 136;
690  unsigned int gmtCollSize = m_totalBxInEvent * gmtRecordSize;
691 
692  // if pointer after GMT payload is greater than pointer at
693  // the end of GT payload, produce empty products and quit unpacking
694  if ((ptrGt + gmtCollSize) > endPtrGt) {
695  edm::LogError("L1GlobalTriggerRawToDigi")
696  << "\nError: Pointer after GMT "
697  << " greater than end pointer."
698  << "\n Put empty products in the event!"
699  << "\n Quit unpacking this event." << std::endl;
700 
701  produceEmptyProducts(iEvent);
702 
703  return;
704  }
705 
706  // unpack only if requested, otherwise skip it
707  if (activeBoardToUnpack) {
708  unpackGMT(ptrGt, gmtrc, iEvent);
709  }
710 
711 
712  ptrGt += gmtCollSize; // advance with GMT block size
713  }
714  break;
715  default: {
716  // do nothing, all blocks are given in GtBoardType enum
717  if (m_verbosity) {
718 
719  LogDebug("L1GlobalTriggerRawToDigi") << "\nBoard of type "
720  << itBoard->gtBoardType() << " not expected in record.\n" << std::endl;
721  }
722  }
723  break;
724 
725  }
726 
727  }
728 
729  // add GTFE block to GT readout record, after updating active boards and record length
730 
731  gtReadoutRecord->setGtfeWord(*m_gtfeWord);
732 
733  // ... and reset it
734  m_gtfeWord->reset();
735 
736 
737 
738  // unpack trailer
739 
740  int trailerSize = 8;
741 
742  // if pointer after trailer is greater than pointer at
743  // the end of GT payload, produce empty products and quit unpacking
744  if ((ptrGt + trailerSize) > endPtrGt) {
745  edm::LogError("L1GlobalTriggerRawToDigi")
746  << "\nError: Pointer after trailer "
747  << " greater than end pointer."
748  << "\n Put empty products in the event!"
749  << "\n Quit unpacking this event." << std::endl;
750 
751  produceEmptyProducts(iEvent);
752 
753  return;
754  }
755 
756  unpackTrailer(ptrGt, cmsTrailer);
757 
758  //
759  if (m_verbosity && m_isDebugEnabled) {
760  std::ostringstream myCoutStream;
761  gtReadoutRecord->print(myCoutStream);
762  LogTrace("L1GlobalTriggerRawToDigi")
763  << "\n The following L1 GT DAQ readout record was unpacked.\n"
764  << myCoutStream.str() << "\n" << std::endl;
765  }
766 
767  // put records into event
768 
769  iEvent.put(std::move(gmtrc));
770  iEvent.put(std::move(gtReadoutRecord));
771 
772 }
#define LogDebug(id)
const L1MuTriggerScales * m_TriggerScales
muon trigger scales to convert unpacked data into physical quantities
void reset()
reset the content of a L1GtPsbWord
Definition: L1GtPsbWord.cc:432
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const unsigned int getSize() const
get the size of the GTFE block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtfeWord.h:229
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
Definition: L1GtfeWord.cc:321
void unpackHeader(const unsigned char *, FEDHeader &)
block unpackers
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
int m_recordLength0
total Bx&#39;s in the event, obtained from GTFE block
void unpack(const unsigned char *fdlPtr)
Definition: L1GtFdlWord.cc:891
void unpackPSB(const edm::EventSetup &, const unsigned char *, L1GtPsbWord &)
void setRecordLength(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:109
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
const cms_uint16_t recordLength() const
get/set record length for alternative 0
Definition: L1GtfeWord.h:104
virtual void reset()
reset the content of a L1GtfeWord
Definition: L1GtfeWord.cc:306
const L1MuTriggerPtScale * m_TriggerPtScale
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
void setLumiSegmentNr(const cms_uint16_t &lumiSegmentNrValue)
Definition: L1GtFdlWord.h:357
edm::InputTag m_daqGtInputTag
input tags for GT DAQ record
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
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
Definition: L1GtfeWord.h:163
#define LogTrace(id)
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:766
void print(std::ostream &myCout) const
pretty print
Definition: L1GtPsbWord.cc:453
const cms_uint16_t lumiSegmentNr() const
get/set luminosity segment number of the actual bx
Definition: L1GtFdlWord.h:352
int m_totalBxInEvent
number of Bx for a board, obtained from GTFE block (record length & alternative)
T const * product() const
Definition: Handle.h:81
void setActiveBoards(cms_uint16_t activeBoardsValue)
Definition: L1GtfeWord.h:168
const T & get() const
Definition: EventSetup.h:56
void unpackTrailer(const unsigned char *, FEDTrailer &)
unpack trailer word
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
Definition: L1GtBoardMaps.h:47
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
void unpackGMT(const unsigned char *, std::unique_ptr< L1MuGMTReadoutCollection > &, edm::Event &)
unpack the GMT record
void produceEmptyProducts(edm::Event &)
produce empty products in case of problems
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
Definition: L1GtfeWord.h:85
T const * product() const
Definition: ESHandle.h:86
virtual void unpack(const unsigned char *gtfePtr)
Definition: L1GtfeWord.cc:380
def move(src, dest)
Definition: eostools.py:510
const unsigned int getSize() const
get the size of the PSB block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtPsbWord.h:198
void dumpFedRawData(const unsigned char *, int, std::ostream &)
dump FED raw data
void L1GlobalTriggerRawToDigi::produceEmptyProducts ( edm::Event iEvent)
private

produce empty products in case of problems

Definition at line 1029 of file L1GlobaTriggerRawToDigi.cc.

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

Referenced by produce().

1029  {
1030 
1031  std::unique_ptr<L1GlobalTriggerReadoutRecord> gtReadoutRecord(
1033 
1034  std::unique_ptr<L1MuGMTReadoutCollection> gmtrc(new L1MuGMTReadoutCollection());
1035 
1036  std::unique_ptr<std::vector<L1MuRegionalCand> > DTCands(new std::vector<L1MuRegionalCand>);
1037  std::unique_ptr<std::vector<L1MuRegionalCand> > CSCCands(new std::vector<L1MuRegionalCand>);
1038  std::unique_ptr<std::vector<L1MuRegionalCand> > RPCbCands(new std::vector<L1MuRegionalCand>);
1039  std::unique_ptr<std::vector<L1MuRegionalCand> > RPCfCands(new std::vector<L1MuRegionalCand>);
1040  std::unique_ptr<std::vector<L1MuGMTCand> > GMTCands(new std::vector<L1MuGMTCand>);
1041 
1042  // put empty records into event
1043 
1044  iEvent.put(std::move(gmtrc));
1045  iEvent.put(std::move(gtReadoutRecord));
1046 
1047  iEvent.put(std::move(DTCands), "DT");
1048  iEvent.put(std::move(CSCCands), "CSC");
1049  iEvent.put(std::move(RPCbCands), "RPCb");
1050  iEvent.put(std::move(RPCfCands), "RPCf");
1051  iEvent.put(std::move(GMTCands));
1052 
1053 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
def move(src, dest)
Definition: eostools.py:510
void L1GlobalTriggerRawToDigi::unpackGMT ( const unsigned char *  chp,
std::unique_ptr< L1MuGMTReadoutCollection > &  gmtrc,
edm::Event iEvent 
)
private

unpack the GMT record

Definition at line 866 of file L1GlobaTriggerRawToDigi.cc.

References TauDecayModes::dec, L1MuRegionalCand::empty(), L1MuGMTCand::empty(), L1MuRegionalCand::eta_packed(), L1MuGMTCand::etaIndex(), L1MuScale::getCenter(), L1MuTriggerScales::getGMTEtaScale(), L1MuScale::getLowEdge(), L1MuTriggerScales::getPhiScale(), L1MuTriggerPtScale::getPtScale(), L1MuTriggerScales::getRegionalEtaScale(), LogTrace, m_lowSkipBxInEvent, m_totalBxInEvent, m_TriggerPtScale, m_TriggerScales, m_uppSkipBxInEvent, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, L1MuRegionalCand::phi_packed(), L1MuGMTCand::phiIndex(), L1MuRegionalCand::pt_packed(), L1MuGMTCand::ptIndex(), edm::Event::put(), L1MuGMTReadoutRecord::setBCERR(), L1MuGMTReadoutRecord::setBxInEvent(), L1MuGMTReadoutRecord::setBxNr(), L1MuRegionalCand::setEtaValue(), L1MuGMTCand::setEtaValue(), L1MuGMTReadoutRecord::setEvNr(), L1MuGMTReadoutRecord::setGMTBrlCand(), L1MuGMTReadoutRecord::setGMTCand(), L1MuGMTReadoutRecord::setGMTFwdCand(), L1MuGMTReadoutRecord::setInputCand(), L1MuRegionalCand::setPhiValue(), L1MuGMTCand::setPhiValue(), L1MuRegionalCand::setPtValue(), L1MuGMTCand::setPtValue(), L1MuRegionalCand::setType(), and L1MuRegionalCand::type_idx().

Referenced by produce().

867  {
868 
869  //LogDebug("L1GlobalTriggerRawToDigi")
870  //<< "\nUnpacking GMT collection.\n"
871  //<< std::endl;
872 
873  // 17*64/2 TODO FIXME ask Ivan for a getSize() function for GMT record
874  const unsigned int gmtRecordSize32 = 34;
875 
876  std::unique_ptr<std::vector<L1MuRegionalCand> > DTCands(new std::vector<L1MuRegionalCand>);
877  std::unique_ptr<std::vector<L1MuRegionalCand> > CSCCands(new std::vector<L1MuRegionalCand>);
878  std::unique_ptr<std::vector<L1MuRegionalCand> > RPCbCands(new std::vector<L1MuRegionalCand>);
879  std::unique_ptr<std::vector<L1MuRegionalCand> > RPCfCands(new std::vector<L1MuRegionalCand>);
880  std::unique_ptr<std::vector<L1MuGMTCand> > GMTCands(new std::vector<L1MuGMTCand>);
881 
882  const unsigned* p = (const unsigned*) chp;
883 
884  // min Bx's in the event, computed after m_totalBxInEvent is obtained from GTFE block
885  // assume symmetrical number of BX around L1Accept
886  int iBxInEvent = ( m_totalBxInEvent + 1 ) / 2 - m_totalBxInEvent;
887 
888  for (int iGmtRec = 0; iGmtRec < m_totalBxInEvent; ++iGmtRec) {
889 
890  // unpack only bxInEvent requested, otherwise skip it
891  if ( ( iGmtRec >= m_lowSkipBxInEvent ) && ( iGmtRec < m_uppSkipBxInEvent )) {
892 
893  // Dump the block
894  const cms_uint64_t* bp =
895  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned*> (p));
896  for (int iWord = 0; iWord < 17; iWord++) {
897  LogTrace("L1GlobalTriggerRawToDigi") << std::setw(4) << iWord << " " << std::hex
898  << std::setfill('0') << std::setw(16) << *bp++ << std::dec << std::setfill(
899  ' ') << std::endl;
900  }
901 
902  L1MuGMTReadoutRecord gmtrr(iBxInEvent);
903 
904  gmtrr.setEvNr( ( *p ) & 0xffffff);
905  gmtrr.setBCERR( ( ( *p ) >> 24 ) & 0xff);
906  p++;
907 
908  gmtrr.setBxNr( ( *p ) & 0xfff);
909  if ( ( ( *p ) >> 15 ) & 1) {
910  gmtrr.setBxInEvent( ( ( ( *p ) >> 12 ) & 7 ) - 8);
911  } else {
912  gmtrr.setBxInEvent( ( ( ( *p ) >> 12 ) & 7 ));
913  }
914  // to do: check here the block length and the board id
915  p++;
916 
917  for (int im = 0; im < 16; im++) {
918  // flip the pt and quality bits -- this should better be done by GMT input chips
919  unsigned waux = *p++;
920  waux = ( waux & 0xffff00ff ) | ( ( ~waux ) & 0x0000ff00 );
921  L1MuRegionalCand cand(waux, iBxInEvent);
922  // fix the type assignment (csc=2, rpcb=1) -- should be done by GMT input chips
923  if (im >= 4 && im < 8) cand.setType(1);
924  if (im >= 8 && im < 12) cand.setType(2);
925  cand.setPhiValue(m_TriggerScales->getPhiScale()->getLowEdge(cand.phi_packed()));
926  cand.setEtaValue(m_TriggerScales->getRegionalEtaScale(cand.type_idx())->getCenter(
927  cand.eta_packed()));
928  cand.setPtValue(m_TriggerPtScale->getPtScale()->getLowEdge(cand.pt_packed()));
929  gmtrr.setInputCand(im, cand);
930  if (!cand.empty()) {
931  if (im < 4) DTCands->push_back(cand);
932  if (im >= 4 && im < 8) RPCbCands->push_back(cand);
933  if (im >= 8 && im < 12) CSCCands->push_back(cand);
934  if (im >= 12) RPCfCands->push_back(cand);
935  }
936  }
937 
938  unsigned char* prank = (unsigned char*) ( p + 12 );
939 
940  for (int im = 0; im < 12; im++) {
941  unsigned waux = *p++;
942  unsigned raux = im < 8 ? *prank++ : 0; // only fwd and brl cands have valid rank
943  L1MuGMTExtendedCand cand(waux, raux, iBxInEvent);
944  cand.setPhiValue(m_TriggerScales->getPhiScale()->getLowEdge(cand.phiIndex()));
945  cand.setEtaValue(m_TriggerScales->getGMTEtaScale()->getCenter(cand.etaIndex()));
946  cand.setPtValue(m_TriggerPtScale->getPtScale()->getLowEdge(cand.ptIndex()));
947  if (im < 4)
948  gmtrr.setGMTBrlCand(im, cand);
949  else if (im < 8)
950  gmtrr.setGMTFwdCand(im - 4, cand);
951  else {
952  gmtrr.setGMTCand(im - 8, cand);
953  if (!cand.empty()) GMTCands->push_back(cand);
954  }
955  }
956 
957  // skip the two sort rank words and two chip BX words
958  p += 4;
959 
960  gmtrc->addRecord(gmtrr);
961 
962  } else {
963  // increase the pointer with the GMT record size
964  p += gmtRecordSize32;
965  }
966 
967  // increase the BxInEvent number
968  iBxInEvent++;
969 
970  }
971 
972  iEvent.put(std::move(DTCands), "DT");
973  iEvent.put(std::move(CSCCands), "CSC");
974  iEvent.put(std::move(RPCbCands), "RPCb");
975  iEvent.put(std::move(RPCfCands), "RPCf");
976  iEvent.put(std::move(GMTCands));
977 
978 }
const L1MuTriggerScales * m_TriggerScales
muon trigger scales to convert unpacked data into physical quantities
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const L1MuScale * getPtScale() const
get the Pt scale
virtual float getCenter(unsigned packed) const =0
get the center of bin represented by packed
const L1MuTriggerPtScale * m_TriggerPtScale
const L1MuScale * getPhiScale() const
get the phi scale
#define LogTrace(id)
int m_totalBxInEvent
number of Bx for a board, obtained from GTFE block (record length & alternative)
const L1MuScale * getRegionalEtaScale(int isys) const
get the regioanl muon trigger eta scale, isys = 0(DT), 1(bRPC), 2(CSC), 3(fwdRPC) ...
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
const L1MuScale * getGMTEtaScale() const
get the GMT eta scale
unsigned long long cms_uint64_t
Definition: typedefs.h:17
def move(src, dest)
Definition: eostools.py:510
void L1GlobalTriggerRawToDigi::unpackHeader ( const unsigned char *  gtPtr,
FEDHeader cmsHeader 
)
private

block unpackers

unpack header

Definition at line 775 of file L1GlobaTriggerRawToDigi.cc.

References FEDHeader::bxID(), TauDecayModes::dec, LogDebug, FEDHeader::lvl1ID(), m_isDebugEnabled, m_verbosity, FEDHeader::moreHeaders(), jetCorrFactors_cfi::payload, FEDHeader::sourceID(), FEDHeader::triggerType(), and FEDHeader::version().

Referenced by produce().

775  {
776 
777  // TODO if needed in another format
778 
779  // print the header info
780  if (m_verbosity && m_isDebugEnabled) {
781 
782  const cms_uint64_t* payload =
783  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned char*> (gtPtr));
784 
785  std::ostringstream myCoutStream;
786 
787  // one word only
788  int iWord = 0;
789 
790  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0')
791  << std::setw(16) << payload[iWord] << std::dec << std::setfill(' ') << "\n"
792  << std::endl;
793 
794  myCoutStream << " Event_type: " << std::hex << " hex: " << " " << std::setw(1)
795  << std::setfill('0') << cmsHeader.triggerType() << std::setfill(' ') << std::dec
796  << " dec: " << cmsHeader.triggerType() << std::endl;
797 
798  myCoutStream << " LVL1_Id: " << std::hex << " hex: " << "" << std::setw(6)
799  << std::setfill('0') << cmsHeader.lvl1ID() << std::setfill(' ') << std::dec
800  << " dec: " << cmsHeader.lvl1ID() << std::endl;
801 
802  myCoutStream << " BX_Id: " << std::hex << " hex: " << " " << std::setw(3)
803  << std::setfill('0') << cmsHeader.bxID() << std::setfill(' ') << std::dec
804  << " dec: " << cmsHeader.bxID() << std::endl;
805 
806  myCoutStream << " Source_Id: " << std::hex << " hex: " << " " << std::setw(3)
807  << std::setfill('0') << cmsHeader.sourceID() << std::setfill(' ') << std::dec
808  << " dec: " << cmsHeader.sourceID() << std::endl;
809 
810  myCoutStream << " FOV: " << std::hex << " hex: " << " " << std::setw(1)
811  << std::setfill('0') << cmsHeader.version() << std::setfill(' ') << std::dec
812  << " dec: " << cmsHeader.version() << std::endl;
813 
814  myCoutStream << " H: " << std::hex << " hex: " << " " << std::setw(1)
815  << std::setfill('0') << cmsHeader.moreHeaders() << std::setfill(' ') << std::dec
816  << " dec: " << cmsHeader.moreHeaders() << std::endl;
817 
818  LogDebug("L1GlobalTriggerRawToDigi") << "\n CMS Header \n" << myCoutStream.str() << "\n"
819  << std::endl;
820 
821  }
822 
823 }
#define LogDebug(id)
int version()
Version identifier of the FED data format.
Definition: FEDHeader.cc:32
int sourceID()
Identifier of the FED.
Definition: FEDHeader.cc:28
payload
payload postfix for testing
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 L1GlobalTriggerRawToDigi::unpackPSB ( const edm::EventSetup evSetup,
const unsigned char *  psbPtr,
L1GtPsbWord psbWord 
)
private

unpack PSB blocks unpacking is done in PSB class format methods are given later to translate from the PSB format to the physical input of the PSB

Definition at line 827 of file L1GlobaTriggerRawToDigi.cc.

References TauDecayModes::dec, L1GtPsbWord::getSize(), LogTrace, jetCorrFactors_cfi::payload, L1GtPsbWord::setAData(), L1GtPsbWord::setBData(), L1GtPsbWord::setBoardId(), L1GtPsbWord::setBxInEvent(), L1GtPsbWord::setBxNr(), L1GtPsbWord::setEventNr(), L1GtPsbWord::setLocalBxNr(), and L1GlobalTriggerReadoutSetup::UnitLength.

Referenced by produce().

828  {
829 
830  //LogDebug("L1GlobalTriggerRawToDigi")
831  //<< "\nUnpacking PSB block.\n"
832  //<< std::endl;
833 
835 
836  int psbSize = psbWord.getSize();
837  int psbWords = psbSize / uLength;
838 
839  const cms_uint64_t* payload =
840  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned char*> (psbPtr));
841 
842  for (int iWord = 0; iWord < psbWords; ++iWord) {
843 
844  // fill PSB
845  // the second argument must match the word index defined in L1GtPsbWord class
846 
847  psbWord.setBoardId(payload[iWord], iWord);
848  psbWord.setBxInEvent(payload[iWord], iWord);
849  psbWord.setBxNr(payload[iWord], iWord);
850  psbWord.setEventNr(payload[iWord], iWord);
851 
852  psbWord.setAData(payload[iWord], iWord);
853  psbWord.setBData(payload[iWord], iWord);
854 
855  psbWord.setLocalBxNr(payload[iWord], iWord);
856 
857  LogTrace("L1GlobalTriggerRawToDigi") << std::setw(4) << iWord << " " << std::hex
858  << std::setfill('0') << std::setw(16) << payload[iWord] << std::dec
859  << std::setfill(' ') << std::endl;
860 
861  }
862 
863 }
static const int UnitLength
one unit in the word is UnitLength bits
void setBData(cms_uint16_t bDataVal, int iB)
Definition: L1GtPsbWord.cc:337
void setEventNr(cms_uint32_t eventNrValue)
Definition: L1GtPsbWord.h:134
void setBxNr(cms_uint16_t bxNrValue)
Definition: L1GtPsbWord.h:113
payload
payload postfix for testing
void setBoardId(cms_uint16_t boardIdValue)
Definition: L1GtPsbWord.h:71
void setBxInEvent(int bxInEventValue)
Definition: L1GtPsbWord.h:92
#define LogTrace(id)
void setLocalBxNr(cms_uint16_t localBxNrValue)
Definition: L1GtPsbWord.h:183
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setAData(cms_uint16_t aDataVal, int iA)
Definition: L1GtPsbWord.cc:242
const unsigned int getSize() const
get the size of the PSB block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtPsbWord.h:198
void L1GlobalTriggerRawToDigi::unpackTrailer ( const unsigned char *  trlPtr,
FEDTrailer cmsTrailer 
)
private

unpack trailer word

Definition at line 982 of file L1GlobaTriggerRawToDigi.cc.

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

Referenced by produce().

982  {
983 
984  // TODO if needed in another format
985 
986  // print the trailer info
987  if (m_verbosity && m_isDebugEnabled) {
988 
989  const cms_uint64_t* payload =
990  reinterpret_cast<cms_uint64_t*> (const_cast<unsigned char*> (trlPtr));
991 
992  std::ostringstream myCoutStream;
993 
994  // one word only
995  int iWord = 0;
996 
997  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0')
998  << std::setw(16) << payload[iWord] << std::dec << std::setfill(' ') << "\n"
999  << std::endl;
1000 
1001  myCoutStream << " Event_length: " << std::hex << " hex: " << "" << std::setw(6)
1002  << std::setfill('0') << cmsTrailer.lenght() << std::setfill(' ') << std::dec
1003  << " dec: " << cmsTrailer.lenght() << std::endl;
1004 
1005  myCoutStream << " CRC: " << std::hex << " hex: " << " " << std::setw(4)
1006  << std::setfill('0') << cmsTrailer.crc() << std::setfill(' ') << std::dec
1007  << " dec: " << cmsTrailer.crc() << std::endl;
1008 
1009  myCoutStream << " Event_status: " << std::hex << " hex: " << " " << std::setw(2)
1010  << std::setfill('0') << cmsTrailer.evtStatus() << std::setfill(' ') << std::dec
1011  << " dec: " << cmsTrailer.evtStatus() << std::endl;
1012 
1013  myCoutStream << " TTS_bits: " << std::hex << " hex: " << " " << std::setw(1)
1014  << std::setfill('0') << cmsTrailer.ttsBits() << std::setfill(' ') << std::dec
1015  << " dec: " << cmsTrailer.ttsBits() << std::endl;
1016 
1017  myCoutStream << " More trailers: " << std::hex << " hex: " << " " << std::setw(1)
1018  << std::setfill('0') << cmsTrailer.moreTrailers() << std::setfill(' ') << std::dec
1019  << " dec: " << cmsTrailer.moreTrailers() << std::endl;
1020 
1021  LogDebug("L1GlobalTriggerRawToDigi") << "\n CMS Trailer \n" << myCoutStream.str() << "\n"
1022  << std::endl;
1023 
1024  }
1025 
1026 }
#define LogDebug(id)
int evtStatus()
Event fragment status information.
Definition: FEDTrailer.cc:27
bool moreTrailers()
Definition: FEDTrailer.cc:37
payload
payload postfix for testing
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 L1GlobalTriggerRawToDigi::m_activeBoardsMaskGt
private

mask for active boards

Definition at line 106 of file L1GlobalTriggerRawToDigi.h.

Referenced by L1GlobalTriggerRawToDigi(), and produce().

int L1GlobalTriggerRawToDigi::m_daqGtFedId
private

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

Definition at line 103 of file L1GlobalTriggerRawToDigi.h.

Referenced by L1GlobalTriggerRawToDigi(), and produce().

edm::InputTag L1GlobalTriggerRawToDigi::m_daqGtInputTag
private

input tags for GT DAQ record

Definition at line 99 of file L1GlobalTriggerRawToDigi.h.

Referenced by L1GlobalTriggerRawToDigi(), and produce().

L1GtFdlWord* L1GlobalTriggerRawToDigi::m_gtFdlWord
private
L1GtfeWord* L1GlobalTriggerRawToDigi::m_gtfeWord
private
L1GtPsbWord* L1GlobalTriggerRawToDigi::m_gtPsbWord
private
bool L1GlobalTriggerRawToDigi::m_isDebugEnabled
private
int L1GlobalTriggerRawToDigi::m_lowSkipBxInEvent
private

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

Definition at line 113 of file L1GlobalTriggerRawToDigi.h.

Referenced by produce(), and unpackGMT().

int L1GlobalTriggerRawToDigi::m_recordLength0
private

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

corresponding to alternative 0 in altNrBxBoard()

Definition at line 122 of file L1GlobalTriggerRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerRawToDigi::m_recordLength1
private

corresponding to alternative 1 in altNrBxBoard()

Definition at line 125 of file L1GlobalTriggerRawToDigi.h.

Referenced by produce().

int L1GlobalTriggerRawToDigi::m_totalBxInEvent
private

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

Definition at line 128 of file L1GlobalTriggerRawToDigi.h.

Referenced by produce(), and unpackGMT().

const L1MuTriggerPtScale* L1GlobalTriggerRawToDigi::m_TriggerPtScale
private

Definition at line 133 of file L1GlobalTriggerRawToDigi.h.

Referenced by produce(), and unpackGMT().

const L1MuTriggerScales* L1GlobalTriggerRawToDigi::m_TriggerScales
private

muon trigger scales to convert unpacked data into physical quantities

Definition at line 132 of file L1GlobalTriggerRawToDigi.h.

Referenced by produce(), and unpackGMT().

int L1GlobalTriggerRawToDigi::m_unpackBxInEvent
private

Definition at line 109 of file L1GlobalTriggerRawToDigi.h.

Referenced by L1GlobalTriggerRawToDigi(), and produce().

int L1GlobalTriggerRawToDigi::m_uppSkipBxInEvent
private

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

Definition at line 117 of file L1GlobalTriggerRawToDigi.h.

Referenced by produce(), and unpackGMT().

int L1GlobalTriggerRawToDigi::m_verbosity
private

verbosity level

Definition at line 138 of file L1GlobalTriggerRawToDigi.h.

Referenced by L1GlobalTriggerRawToDigi(), produce(), unpackHeader(), and unpackTrailer().