CMS 3D CMS Logo

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

#include <DaqFakeReader.h>

Inheritance diagram for DaqFakeReader:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DaqFakeReader (const edm::ParameterSet &pset)
 
virtual int fillRawData (edm::Event &e, FEDRawDataCollection *&data)
 
void produce (edm::Event &, edm::EventSetup const &) override
 
 ~DaqFakeReader () override
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlock const &iL, edm::EventSetup const &iE)
 
void fillFEDs (const int, const int, edm::EventID &eID, FEDRawDataCollection &data, float meansize, float width)
 
void fillGTPFED (edm::EventID &eID, FEDRawDataCollection &data, timeval *now)
 

Private Attributes

bool empty_events
 
edm::EventNumber_t eventNum
 
unsigned int fakeLs_ =0
 
unsigned int injected_errors_per_million_events
 
unsigned int meansize
 
unsigned int modulo_error_events
 
edm::RunNumber_t runNum
 
unsigned int width
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Generates empty FEDRawData of random size for all FEDs Proper headers and trailers are included; but the payloads are all 0s

Author
N. Amapane - CERN

Definition at line 21 of file DaqFakeReader.h.

Constructor & Destructor Documentation

DaqFakeReader::DaqFakeReader ( const edm::ParameterSet pset)

Definition at line 33 of file DaqFakeReader.cc.

34  : runNum(1)
35  , eventNum(1)
36  , empty_events(pset.getUntrackedParameter<bool>("emptyEvents",false))
37  , meansize(pset.getUntrackedParameter<unsigned int>("meanSize",1024))
38  , width(pset.getUntrackedParameter<unsigned int>("width",1024))
39  , injected_errors_per_million_events(pset.getUntrackedParameter<unsigned int>("injectErrPpm",0))
41 {
42  // mean = pset.getParameter<float>("mean");
43  produces<FEDRawDataCollection>();
44 }
unsigned int width
Definition: DaqFakeReader.h:61
T getUntrackedParameter(std::string const &, T const &) const
unsigned int modulo_error_events
Definition: DaqFakeReader.h:63
unsigned int injected_errors_per_million_events
Definition: DaqFakeReader.h:62
unsigned int meansize
Definition: DaqFakeReader.h:60
edm::RunNumber_t runNum
Definition: DaqFakeReader.h:57
edm::EventNumber_t eventNum
Definition: DaqFakeReader.h:58
DaqFakeReader::~DaqFakeReader ( )
override

Definition at line 47 of file DaqFakeReader.cc.

48 {
49 
50 }

Member Function Documentation

void DaqFakeReader::beginLuminosityBlock ( edm::LuminosityBlock const &  iL,
edm::EventSetup const &  iE 
)
privatevirtual

Definition at line 188 of file DaqFakeReader.cc.

References gather_cfg::cout, fakeLs_, and edm::LuminosityBlockBase::luminosityBlock().

189 {
190  std::cout << "DaqFakeReader begin Lumi " << iL.luminosityBlock() << std::endl;
191  fakeLs_=iL.luminosityBlock();
192 }
unsigned int fakeLs_
Definition: DaqFakeReader.h:64
void DaqFakeReader::fillFEDs ( const int  fedmin,
const int  fedmax,
edm::EventID eID,
FEDRawDataCollection data,
float  meansize,
float  width 
)
private

Definition at line 113 of file DaqFakeReader.cc.

References FEDRawData::data(), edm::EventID::event(), JetChargeProducer_cfi::exp, FEDRawDataCollection::FEDData(), l1t::stage2::layer2::fedId, createfilelist::int, cmsBatch::log, FEDRawData::resize(), FEDHeader::set(), FEDTrailer::set(), and findQualityFiles::size.

Referenced by fillRawData().

118 {
119 
120  // FIXME: last ID included?
121  for (int fedId = fedmin; fedId <= fedmax; ++fedId ) {
122 
123  // Generate size...
124  float logsiz = CLHEP::RandGauss::shoot(std::log(meansize),
126  size_t size = int(std::exp(logsiz));
127  size -= size % 8; // all blocks aligned to 64 bit words
128 
129  FEDRawData& feddata = data.FEDData(fedId);
130  // Allocate space for header+trailer+payload
131  feddata.resize(size+16);
132 
133  // Generate header
134  FEDHeader::set(feddata.data(),
135  1, // Trigger type
136  eID.event(), // LV1_id (24 bits)
137  0, // BX_id
138  fedId); // source_id
139 
140  // Payload = all 0s...
141 
142  // Generate trailer
143  int crc = 0; // FIXME : get CRC
144  FEDTrailer::set(feddata.data()+8+size,
145  size/8+2, // in 64 bit words!!!
146  crc,
147  0, // Evt_stat
148  0); // TTS bits
149  }
150 }
unsigned int width
Definition: DaqFakeReader.h:61
size
Write out results.
EventNumber_t event() const
Definition: EventID.h:41
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
Definition: FEDTrailer.cc:60
void resize(size_t newsize)
Definition: FEDRawData.cc:32
unsigned int meansize
Definition: DaqFakeReader.h:60
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
static void set(unsigned char *header, uint8_t triggerType, uint32_t lvl1ID, uint16_t bxID, uint16_t sourceID, uint8_t version=0, bool moreHeaders=false)
Set all fields in the header.
Definition: FEDHeader.cc:47
void DaqFakeReader::fillGTPFED ( edm::EventID eID,
FEDRawDataCollection data,
timeval *  now 
)
private

Definition at line 152 of file DaqFakeReader.cc.

References FEDRawData::data(), edm::EventID::event(), evf::evtn::EVM_BOARDID_OFFSET, evf::evtn::EVM_BOARDID_SHIFT, evf::evtn::EVM_BOARDID_VALUE, evf::evtn::EVM_GTFE_BSTGPS_OFFSET, evf::evtn::EVM_TCS_TRIGNR_OFFSET, FEDRawDataCollection::FEDData(), l1t::stage2::layer2::fedId, FEDHeader::length, FEDNumbering::MINTriggerGTPFEDID, FEDRawData::resize(), FEDHeader::set(), FEDTrailer::set(), findQualityFiles::size, evf::evtn::SLINK_HALFWORD_SIZE, and evf::evtn::SLINK_WORD_SIZE.

Referenced by fillRawData().

154 {
156  FEDRawData& feddata = data.FEDData(fedId);
157  uint32_t size = evf::evtn::SLINK_WORD_SIZE*37-16;//BST52_3BX
158  feddata.resize(size+16);
159 
160  FEDHeader::set(feddata.data(),
161  1, // Trigger type
162  eID.event(), // LV1_id (24 bits)
163  0, // BX_id
164  fedId); // source_id
165 
166  int crc = 0; // FIXME : get CRC
167  FEDTrailer::set(feddata.data()+8+size,
168  size/8+2, // in 64 bit words!!!
169  crc,
170  0, // Evt_stat
171  0); // TTS bits
172 
173  unsigned char * pOffset = feddata.data() + FEDHeader::length;
174  //fill in event ID
176  *( (uint32_t*)(pOffset + FEDHeader::length + (9*2 + evf::evtn::EVM_TCS_TRIGNR_OFFSET) * evf::evtn::SLINK_WORD_SIZE / 2)) = eID.event();
177  //fill in timestamp
178  *( (uint32_t*) (pOffset + evf::evtn::EVM_GTFE_BSTGPS_OFFSET * evf::evtn::SLINK_WORD_SIZE / 2)) = now->tv_sec;
180 
181  //*( (uint16_t*) (pOffset + (evtn::EVM_GTFE_BLOCK*2 + evtn::EVM_TCS_LSBLNR_OFFSET)*evtn::SLINK_HALFWORD_SIZE)) = (unsigned short)fakeLs_-1;
182 
183  //we could also generate lumiblock, bcr, orbit,... but they are not currently used by the FRD input source
184 
185 }
size
Write out results.
EventNumber_t event() const
Definition: EventID.h:41
const unsigned int EVM_TCS_TRIGNR_OFFSET
static const uint32_t length
Definition: FEDHeader.h:54
const unsigned int EVM_BOARDID_VALUE
const unsigned int SLINK_HALFWORD_SIZE
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
Definition: FEDTrailer.cc:60
void resize(size_t newsize)
Definition: FEDRawData.cc:32
const unsigned int SLINK_WORD_SIZE
const unsigned int EVM_BOARDID_OFFSET
const unsigned int EVM_GTFE_BSTGPS_OFFSET
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
const unsigned int EVM_BOARDID_SHIFT
static void set(unsigned char *header, uint8_t triggerType, uint32_t lvl1ID, uint16_t bxID, uint16_t sourceID, uint8_t version=0, bool moreHeaders=false)
Set all fields in the header.
Definition: FEDHeader.cc:47
int DaqFakeReader::fillRawData ( edm::Event e,
FEDRawDataCollection *&  data 
)
virtual

Definition at line 58 of file DaqFakeReader.cc.

References empty_events, eventNum, fillFEDs(), fillGTPFED(), edm::EventBase::id(), FEDNumbering::MAXCSCFEDID, FEDNumbering::MAXDTFEDID, FEDNumbering::MAXECALFEDID, FEDNumbering::MAXHCALFEDID, FEDNumbering::MAXRPCFEDID, FEDNumbering::MAXSiPixelFEDID, FEDNumbering::MAXSiStripFEDID, meansize, FEDNumbering::MINCSCFEDID, FEDNumbering::MINDTFEDID, FEDNumbering::MINECALFEDID, FEDNumbering::MINHCALFEDID, FEDNumbering::MINRPCFEDID, FEDNumbering::MINSiPixelFEDID, FEDNumbering::MINSiStripFEDID, cmsPerfSuiteHarvest::now, and width.

Referenced by produce().

60 {
61  // a null pointer is passed, need to allocate the fed collection
62  data=new FEDRawDataCollection();
63  EventID eID = e.id();
64 
65  if(!empty_events)
66  {
67 
68  // Fill the EventID
69  eventNum++;
70  // FIXME:
71 
74  eID, *data, meansize, width);
77  eID, *data, meansize, width);
80  eID, *data, meansize, width);
83  eID, *data, meansize, width);
86  eID, *data, meansize, width);
89  eID, *data, meansize, width);
92  eID, *data, meansize, width);
93 
94  timeval now;
95  gettimeofday(&now,nullptr);
96  fillGTPFED(eID, *data,&now);
97  //TODO: write fake TCDS FED filler
98  }
99  return 1;
100 }
unsigned int width
Definition: DaqFakeReader.h:61
void fillFEDs(const int, const int, edm::EventID &eID, FEDRawDataCollection &data, float meansize, float width)
void fillGTPFED(edm::EventID &eID, FEDRawDataCollection &data, timeval *now)
unsigned int meansize
Definition: DaqFakeReader.h:60
edm::EventID id() const
Definition: EventBase.h:60
edm::EventNumber_t eventNum
Definition: DaqFakeReader.h:58
void DaqFakeReader::produce ( edm::Event e,
edm::EventSetup const &  es 
)
overridevirtual

Implements edm::one::EDProducerBase.

Definition at line 102 of file DaqFakeReader.cc.

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

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

102  {
103 
105  FEDRawDataCollection *fedcoll = nullptr;
106  fillRawData(e,fedcoll);
107  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
108  e.put(std::move(bare_product));
109 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool DaqFakeReader::empty_events
private

Definition at line 59 of file DaqFakeReader.h.

Referenced by fillRawData().

edm::EventNumber_t DaqFakeReader::eventNum
private

Definition at line 58 of file DaqFakeReader.h.

Referenced by fillRawData().

unsigned int DaqFakeReader::fakeLs_ =0
private

Definition at line 64 of file DaqFakeReader.h.

Referenced by beginLuminosityBlock().

unsigned int DaqFakeReader::injected_errors_per_million_events
private

Definition at line 62 of file DaqFakeReader.h.

unsigned int DaqFakeReader::meansize
private

Definition at line 60 of file DaqFakeReader.h.

Referenced by fillRawData().

unsigned int DaqFakeReader::modulo_error_events
private

Definition at line 63 of file DaqFakeReader.h.

edm::RunNumber_t DaqFakeReader::runNum
private

Definition at line 57 of file DaqFakeReader.h.

unsigned int DaqFakeReader::width
private