CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
l1t::MP7BufferDumpToRaw Class Reference
Inheritance diagram for l1t::MP7BufferDumpToRaw:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MP7BufferDumpToRaw (const edm::ParameterSet &)
 
 ~MP7BufferDumpToRaw ()
 
- 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

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

Private Member Functions

virtual void beginJob () override
 
virtual void endJob () override
 
void fillBlocks (int iAmc)
 
void formatRaw (FEDRawData &feddata, int bx, int evtId, int orbit)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< Blockblocks_
 
int evType_
 
int fedId_
 
int fwVer_
 
int lenAMC13Header_
 
int lenAMC13Trailer_
 
int lenAMCHeader_
 
int lenAMCTrailer_
 
int lenSlinkHeader_
 
int lenSlinkTrailer_
 
unsigned nFramesPerEvent_
 
bool packetisedData_
 
std::vector< int > rxBlockLength_
 
MP7FileReader rxFileReader_
 
unsigned rxIndex_
 
std::vector< int > txBlockLength_
 
MP7FileReader txFileReader_
 
unsigned txIndex_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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

Definition at line 52 of file MP7BufferDumpToRaw.cc.

Constructor & Destructor Documentation

l1t::MP7BufferDumpToRaw::MP7BufferDumpToRaw ( const edm::ParameterSet iConfig)
explicit

Definition at line 126 of file MP7BufferDumpToRaw.cc.

References edm::ParameterSet::getUntrackedParameter(), packetisedData_, rxIndex_, and txIndex_.

126  :
127  rxFileReader_(iConfig.getUntrackedParameter<std::string>("rxFile", "rx_summar\
128 y.txt")),
129  txFileReader_(iConfig.getUntrackedParameter<std::string>("txFile", "tx_summar\
130 y.txt")),
131  rxIndex_(0),
132  txIndex_(0),
133  packetisedData_(iConfig.getUntrackedParameter<bool>("packetisedData", true)),
134  nFramesPerEvent_(iConfig.getUntrackedParameter<unsigned>("nFramesPerEvent", 6)),
135  fedId_(iConfig.getUntrackedParameter<int>("fedId", 1)),
136  evType_(iConfig.getUntrackedParameter<int>("eventType", 1)),
137  fwVer_(iConfig.getUntrackedParameter<int>("fwVersion", 1)),
138  lenSlinkHeader_(iConfig.getUntrackedParameter<int>("lenSlinkHeader", 16)),
139  lenSlinkTrailer_(iConfig.getUntrackedParameter<int>("lenSlinkTrailer", 16)),
140  lenAMC13Header_(iConfig.getUntrackedParameter<int>("lenAMC13Header", 0)),
141  lenAMC13Trailer_(iConfig.getUntrackedParameter<int>("lenAMC13Trailer", 0)),
142  lenAMCHeader_(iConfig.getUntrackedParameter<int>("lenAMCHeader", 12)),
143  lenAMCTrailer_(iConfig.getUntrackedParameter<int>("lenAMCTrailer", 8)),
144  rxBlockLength_(iConfig.getUntrackedParameter< std::vector<int> >("rxBlockLength")),
145  txBlockLength_(iConfig.getUntrackedParameter< std::vector<int> >("txBlockLength"))
146 {
147 
148  produces<FEDRawDataCollection>();
149 
150  // advance pointers for non packetised data
151  if (!packetisedData_) {
152  rxIndex_ += iConfig.getUntrackedParameter<int>("nFramesOffset", 0);
153  txIndex_ += rxIndex_;
154  txIndex_ += iConfig.getUntrackedParameter<int>("nFramesLatency", 0);
155  }
156 
157 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > rxBlockLength_
std::vector< int > txBlockLength_
l1t::MP7BufferDumpToRaw::~MP7BufferDumpToRaw ( )

Definition at line 160 of file MP7BufferDumpToRaw.cc.

161 {
162 
163  // do anything here that needs to be done at desctruction time
164  // (e.g. close files, deallocate resources etc.)
165 
166 }

Member Function Documentation

void l1t::MP7BufferDumpToRaw::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 444 of file MP7BufferDumpToRaw.cc.

445 {
446 
447 
448 
449 }
void l1t::MP7BufferDumpToRaw::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 454 of file MP7BufferDumpToRaw.cc.

455 {
456 
457 
458 }
void l1t::MP7BufferDumpToRaw::fillBlocks ( int  iAmc)
private

Definition at line 206 of file MP7BufferDumpToRaw.cc.

References createPayload::block, blocks_, data, MP7FileReader::get(), i, FileData::link(), nFramesPerEvent_, packetisedData_, rxBlockLength_, rxFileReader_, rxIndex_, findQualityFiles::size, txBlockLength_, txFileReader_, and txIndex_.

Referenced by produce().

207 {
208 
209  // Rx blocks first
210  for (unsigned i=0; i<rxBlockLength_.size(); ++i) {
211 
212  unsigned id = i*2;
213  unsigned size = rxBlockLength_.at(i);
214 
215  std::vector<uint32_t> data;
216  for (unsigned iFrame=rxIndex_; iFrame<size; ++iFrame) {
217  if (!packetisedData_) {
218  data.push_back( rxFileReader_.get(iAmc).link(i).at(iFrame) );
219  }
220  }
221 
222  Block block(id, data);
223  blocks_.push_back(block);
224 
225  }
226 
227  // then Tx blocks
228  for (unsigned i=0; i<txBlockLength_.size(); ++i) {
229 
230  unsigned id = (i*2)+1;
231  unsigned size = txBlockLength_.at(i);
232 
233  std::vector<uint32_t> data(size);
234  for (unsigned iFrame=txIndex_; iFrame<size; ++iFrame) {
235  if (!packetisedData_) {
236  data.push_back( txFileReader_.get(iAmc).link(i).at(iFrame) );
237  }
238  }
239 
240  Block block(id, data);
241 
242  blocks_.push_back(block);
243 
244  }
245 
246  // advance pointers to next event
247  if (!packetisedData_) {
250  }
251 
252 }
int i
Definition: DBlmapReader.cc:9
std::vector< int > rxBlockLength_
const FileData & get(size_t k) const
data getter via index
std::vector< Block > blocks_
std::vector< int > txBlockLength_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const std::vector< uint64_t > & link(uint32_t i) const
tuple size
Write out results.
void l1t::MP7BufferDumpToRaw::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 494 of file MP7BufferDumpToRaw.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

494  {
495  //The following says we do not know what parameters are allowed so do no validation
496  // Please change this to state exactly what you do use, even if it is no parameters
498  desc.setUnknown();
499  descriptions.addDefault(desc);
500 }
void addDefault(ParameterSetDescription const &psetDescription)
void l1t::MP7BufferDumpToRaw::formatRaw ( FEDRawData feddata,
int  bx,
int  evtId,
int  orbit 
)
private

Definition at line 256 of file MP7BufferDumpToRaw.cc.

References blocks_, FEDRawData::data(), evType_, fedId_, fwVer_, i, lenAMC13Header_, lenAMC13Trailer_, lenAMCHeader_, lenAMCTrailer_, lenSlinkHeader_, lenSlinkTrailer_, FEDRawData::resize(), rxBlockLength_, and txBlockLength_.

Referenced by produce().

257 {
258 
259  // now create the raw data array
260  int capEvtSize = 0;
261  for (std::vector<Block>::const_iterator itr=blocks_.begin(); itr!=blocks_.end(); ++itr) {
262  capEvtSize += itr->getSize() + 1;
263  }
264 
265  int amcSize = 0;
266  for (unsigned i=0; i<rxBlockLength_.size(); ++i) amcSize += 4 * (rxBlockLength_.at(i) + 1);
267  for (unsigned i=0; i<txBlockLength_.size(); ++i) amcSize += 4 * (txBlockLength_.at(i) + 1);
268 
269  int fedSize = amcSize;
270  fedSize += lenSlinkHeader_;
271  fedSize += lenSlinkTrailer_;
272  fedSize += lenAMC13Header_;
273  fedSize += lenAMC13Trailer_;
274  fedSize += lenAMCHeader_;
275  fedSize += lenAMCTrailer_;
276  fedSize = (fedSize+7) & ~0x7;// round up to multiple of 8
277 
278  edm::LogInfo("mp7") << "Captured event size=" << capEvtSize << ", AMCsize=" << amcSize << ", FED size=" << fedSize << std::endl;
279 
280  // event info for headers
281  edm::LogInfo("mp7") << "Event : " << evtId << " orbit=" << orbit << " bx=" << bx << std::endl;
282 
283 
284  // Allocate space for header+trailer+payload
285  feddata.resize(fedSize);
286 
287  int iWord = 0;
288 
289  // write SLINK header
290  feddata.data()[iWord+1] |= fedId_ & 0xff;
291  feddata.data()[iWord+2] |= (fedId_>>8) & 0xf;
292 
293  feddata.data()[iWord+2] |= (bx<<4) & 0xff;
294  feddata.data()[iWord+3] |= (bx>>4) & 0xff;
295 
296  feddata.data()[iWord+4] = evtId & 0xff;
297  feddata.data()[iWord+5] = (evtId>>8) & 0xff;
298  feddata.data()[iWord+6] = (evtId>>16) & 0xff;
299 
300  feddata.data()[iWord+7] |= evType_ & 0xf;
301  feddata.data()[iWord+7] |= 0x50;
302 
303 
304  // write AMC13 header
305  iWord += lenSlinkHeader_;
306 
307  // do nothing for now
308 
309  // write AMC header
310  iWord += lenAMC13Header_;
311 
312  feddata.data()[iWord+0] = evtId & 0xff;
313  feddata.data()[iWord+1] = (evtId>>8) & 0xff;
314  feddata.data()[iWord+2] = (evtId>>16) & 0xff;
315 
316  feddata.data()[iWord+4] |= (orbit<<4) & 0xff;
317  feddata.data()[iWord+5] |= (orbit>>4) & 0xff;
318  feddata.data()[iWord+6] |= (orbit>>12) & 0xff;
319 
320  feddata.data()[iWord+6] |= (bx>>4) & 0xff;
321  feddata.data()[iWord+7] |= (bx>>12) & 0xff;
322 
323  feddata.data()[iWord+8] = evType_ & 0xff;
324 
325  feddata.data()[iWord+9] = (amcSize/4) & 0xff;
326  feddata.data()[iWord+10] = ((amcSize/4) >> 8) & 0xff;
327 
328  feddata.data()[iWord+11] = fwVer_ & 0xff;
329 
330 
331  // now add payload
332 
333  iWord += lenAMCHeader_;
334  std::ostringstream payloadInfo;
335 
336  // for (int iBlock=0; iBlock<nRxLinks_ && iWord<fedSize; ++iBlock) {
337 
338  // int blockId = 2*iBlock;
339  // int blockLength = rxBlockLength_.at(iBlock);
340 
341  // write block header
342  // feddata.data()[iWord+2] = blockLength & 0xff;
343  // feddata.data()[iWord+3] = blockId & 0xff;
344  // iWord+=4;
345 
346  // if (blockLength!=0) {
347  // payloadInfo << ", " << (blockId&0xff) << " (" << (blockLength&0xff) << ")";
348  // }
349 
350  // if (blockLength>(int)rxData.at(iBlock).size()) {
351  // edm::LogError("mp7") << "Read insufficient data for block " << blockId <<". Expected " << rxBlockLength_.at(iBlock) << " read " << rxData.at(iBlock).size() << " from Rx link " << iBlock << std::endl;
352  // continue;
353  // }
354 
355  // for (int i=0; i<blockLength; ++i) {
356  // if(i < (int)rxData.at(iBlock).size()) {
357  // feddata.data()[iWord] = rxData.at(iBlock).at(i) & 0xff;
358  // feddata.data()[iWord+1] = (rxData.at(iBlock).at(i) >> 8) & 0xff;
359  // feddata.data()[iWord+2] = (rxData.at(iBlock).at(i) >> 16) & 0xff;
360  // feddata.data()[iWord+3] = (rxData.at(iBlock).at(i) >> 24) & 0xff;
361  // iWord+=4;
362  // }
363  // else {
364  // feddata.data()[iWord] = 0;
365  // feddata.data()[iWord+1] = 0;
366  // feddata.data()[iWord+2] = 0;
367  // feddata.data()[iWord+3] = 0;
368  // iWord+=4;
369  // }
370  // }
371 
372  // }
373 
374  // edm::LogInfo("mp7") << "Rx blocks : " << payloadInfo.str() << std::endl;
375 
376  // now do Tx links
377  // strictly these will appear in the wrong place
378  // they should be interspersed with Rx channels, not appended
379 
380  // payloadInfo.str("");
381 
382  // for (int iBlock=0; iBlock<nTxLinks_ && iWord<fedSize; ++iBlock) {
383 
384  // int blockId = (2*iBlock)+1;
385  // int blockLength = txBlockLength_.at(iBlock);
386 
387  // // write block header
388  // feddata.data()[iWord+2] = blockLength & 0xff;
389  // feddata.data()[iWord+3] = blockId & 0xff;
390  // iWord+=4;
391 
392  // payloadInfo << ", " << (blockId&0xff) << "(" << (blockLength&0xff) << ")";
393 
394  // if (blockLength>(int)txData.at(iBlock).size()) {
395  // edm::LogError("mp7") << "Read insufficient data for block " << blockId <<". Expected " << blockLength << " read " << txData.at(iBlock).size() << " from Tx link " << iBlock << std::endl;
396  // continue;
397  // }
398 
399  // for (int i=0; i<blockLength; ++i) {
400  // if (i<(int)txData.at(iBlock).size()) {
401  // feddata.data()[iWord] = txData.at(iBlock).at(i) & 0xff;
402  // feddata.data()[iWord+1] = (txData.at(iBlock).at(i) >> 8) & 0xff;
403  // feddata.data()[iWord+2] = (txData.at(iBlock).at(i) >> 16) & 0xff;
404  // feddata.data()[iWord+3] = (txData.at(iBlock).at(i) >> 24) & 0xff;
405  // iWord+=4;
406  // }
407  // else {
408  // feddata.data()[iWord] = 0;
409  // feddata.data()[iWord+1] = 0;
410  // feddata.data()[iWord+2] = 0;
411  // feddata.data()[iWord+3] = 0;
412  // iWord+=4;
413  // }
414  // }
415 
416  // }
417 
418  // edm::LogInfo("mp7") << "Tx blocks : " << payloadInfo.str() << std::endl;
419 
420  // write AMC trailer
421  feddata.data()[iWord] = evtId & 0xff;
422  feddata.data()[iWord+1] = (evtId>>8) & 0xff;
423 
424  // write AMC13 trailer
425  iWord += lenAMCTrailer_;
426 
427  // write SLINK trailer
428  iWord += lenAMC13Trailer_;
429  iWord = (iWord+7) & ~0x7; // move to next 64 bit boundary
430  feddata.data()[iWord+4] = (fedSize/8) & 0xff;
431  feddata.data()[iWord+5] = ((fedSize/8)>>8) & 0xff;
432  feddata.data()[iWord+6] = ((fedSize/8)>>16) & 0xff;
433 
434  feddata.data()[iWord+7] |= 0xa0;
435 
436  edm::LogInfo("mp7") << "End of packet after " << iWord+8 << " bytes of " << fedSize << std::endl;
437 
438 
439 }
int i
Definition: DBlmapReader.cc:9
std::vector< int > rxBlockLength_
void resize(size_t newsize)
Definition: FEDRawData.cc:32
std::vector< Block > blocks_
std::vector< int > txBlockLength_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
void l1t::MP7BufferDumpToRaw::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 175 of file MP7BufferDumpToRaw.cc.

References blocks_, edm::EventBase::bunchCrossing(), edm::EventID::event(), fedId_, fillBlocks(), formatRaw(), edm::EventBase::id(), edm::EventBase::orbitNumber(), and edm::Event::put().

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

176 {
177  using namespace edm;
178 
179  // fill the block structure
180  blocks_.clear();
181 
182  int iAmc=0;
183  fillBlocks(iAmc);
184 
185  // create the collection
186  std::auto_ptr<FEDRawDataCollection> rawColl(new FEDRawDataCollection());
187 
188  // retrieve the target buffer
189  FEDRawData& feddata=rawColl->FEDData(fedId_);
190 
191  // fill the RAW data
192  int bx = iEvent.bunchCrossing();
193  int evtId = iEvent.id().event();
194  long int orbit = iEvent.orbitNumber();
195 
196  formatRaw(feddata, bx, evtId, orbit);
197 
198  // put the collection in the event
199  iEvent.put(rawColl);
200 
201 }
EventNumber_t event() const
Definition: EventID.h:41
void formatRaw(FEDRawData &feddata, int bx, int evtId, int orbit)
int bunchCrossing() const
Definition: EventBase.h:62
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
int orbitNumber() const
Definition: EventBase.h:63
std::vector< Block > blocks_
edm::EventID id() const
Definition: EventBase.h:56

Member Data Documentation

std::vector<Block> l1t::MP7BufferDumpToRaw::blocks_
private

Definition at line 111 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks(), formatRaw(), and produce().

int l1t::MP7BufferDumpToRaw::evType_
private

Definition at line 98 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw().

int l1t::MP7BufferDumpToRaw::fedId_
private

Definition at line 97 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw(), and produce().

int l1t::MP7BufferDumpToRaw::fwVer_
private

Definition at line 99 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw().

int l1t::MP7BufferDumpToRaw::lenAMC13Header_
private

Definition at line 102 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw().

int l1t::MP7BufferDumpToRaw::lenAMC13Trailer_
private

Definition at line 103 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw().

int l1t::MP7BufferDumpToRaw::lenAMCHeader_
private

Definition at line 104 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw().

int l1t::MP7BufferDumpToRaw::lenAMCTrailer_
private

Definition at line 105 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw().

int l1t::MP7BufferDumpToRaw::lenSlinkHeader_
private

Definition at line 100 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw().

int l1t::MP7BufferDumpToRaw::lenSlinkTrailer_
private

Definition at line 101 of file MP7BufferDumpToRaw.cc.

Referenced by formatRaw().

unsigned l1t::MP7BufferDumpToRaw::nFramesPerEvent_
private

Definition at line 91 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks().

bool l1t::MP7BufferDumpToRaw::packetisedData_
private

Definition at line 88 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks(), and MP7BufferDumpToRaw().

std::vector<int> l1t::MP7BufferDumpToRaw::rxBlockLength_
private

Definition at line 106 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks(), and formatRaw().

MP7FileReader l1t::MP7BufferDumpToRaw::rxFileReader_
private

Definition at line 77 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks().

unsigned l1t::MP7BufferDumpToRaw::rxIndex_
private

Definition at line 79 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks(), and MP7BufferDumpToRaw().

std::vector<int> l1t::MP7BufferDumpToRaw::txBlockLength_
private

Definition at line 107 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks(), and formatRaw().

MP7FileReader l1t::MP7BufferDumpToRaw::txFileReader_
private

Definition at line 78 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks().

unsigned l1t::MP7BufferDumpToRaw::txIndex_
private

Definition at line 80 of file MP7BufferDumpToRaw.cc.

Referenced by fillBlocks(), and MP7BufferDumpToRaw().