CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static 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
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

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

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 fillTCDSFED (edm::EventID &eID, FEDRawDataCollection &data, uint32_t ls, timeval *now)
 

Private Attributes

bool empty_events
 
edm::EventNumber_t eventNum
 
unsigned int fakeLs_ = 0
 
bool fillRandom_
 
unsigned int injected_errors_per_million_events
 
unsigned int meansize
 
unsigned int modulo_error_events
 
edm::RunNumber_t runNum
 
unsigned int tcdsFEDID_
 
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
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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 20 of file DaqFakeReader.h.

Constructor & Destructor Documentation

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

Definition at line 34 of file DaqFakeReader.cc.

References Exception, fillRandom_, FEDNumbering::MINTCDSuTCAFEDID, submitPVValidationJobs::now, and tcdsFEDID_.

35  : runNum(1),
36  eventNum(1),
37  empty_events(pset.getUntrackedParameter<bool>("emptyEvents", false)),
38  fillRandom_(pset.getUntrackedParameter<bool>("fillRandom", false)),
39  meansize(pset.getUntrackedParameter<unsigned int>("meanSize", 1024)),
40  width(pset.getUntrackedParameter<unsigned int>("width", 1024)),
41  injected_errors_per_million_events(pset.getUntrackedParameter<unsigned int>("injectErrPpm", 0)),
42  tcdsFEDID_(pset.getUntrackedParameter<unsigned int>("tcdsFEDID", 1024)),
44  : 0xffffffff) {
45  // mean = pset.getParameter<float>("mean");
47  throw cms::Exception("DaqFakeReader::DaqFakeReader")
48  << " TCDS FED ID lower than " << FEDNumbering::MINTCDSuTCAFEDID;
49  if (fillRandom_) {
50  //intialize random seed
51  auto time_count =
52  static_cast<long unsigned int>(std::chrono::high_resolution_clock::now().time_since_epoch().count());
53  srand(time_count & 0xffffffff);
54  }
55  produces<FEDRawDataCollection>();
56 }
unsigned int width
Definition: DaqFakeReader.h:56
T getUntrackedParameter(std::string const &, T const &) const
unsigned int modulo_error_events
Definition: DaqFakeReader.h:59
unsigned int tcdsFEDID_
Definition: DaqFakeReader.h:58
unsigned int injected_errors_per_million_events
Definition: DaqFakeReader.h:57
unsigned int meansize
Definition: DaqFakeReader.h:55
edm::RunNumber_t runNum
Definition: DaqFakeReader.h:51
edm::EventNumber_t eventNum
Definition: DaqFakeReader.h:52
DaqFakeReader::~DaqFakeReader ( )
override

Definition at line 59 of file DaqFakeReader.cc.

59 {}

Member Function Documentation

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

Definition at line 184 of file DaqFakeReader.cc.

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

184  {
185  std::cout << "DaqFakeReader begin Lumi " << iL.luminosityBlock() << std::endl;
186  fakeLs_ = iL.luminosityBlock();
187 }
unsigned int fakeLs_
Definition: DaqFakeReader.h:60
tuple cout
Definition: gather_cfg.py:144
void DaqFakeReader::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 189 of file DaqFakeReader.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), submitPVResolutionJobs::desc, and edm::ParameterSetDescription::setComment().

189  {
191  desc.setComment("Injector of generated raw FED data for DAQ testing");
192  desc.addUntracked<bool>("emptyEvents", false);
193  desc.addUntracked<bool>("fillRandom", false);
194  desc.addUntracked<unsigned int>("meanSize", 1024);
195  desc.addUntracked<unsigned int>("width", 1024);
196  desc.addUntracked<unsigned int>("injectErrPpm", 1024);
197  desc.addUntracked<unsigned int>("tcdsFEDID", 1024);
198  descriptions.add("DaqFakeReader", desc);
199 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void DaqFakeReader::fillFEDs ( const int  fedmin,
const int  fedmax,
edm::EventID eID,
FEDRawDataCollection data,
float  meansize,
float  width 
)
private

Definition at line 101 of file DaqFakeReader.cc.

References FEDRawData::data(), edm::EventID::event(), funct::exp(), FEDRawDataCollection::FEDData(), l1tstage2_dqm_sourceclient-live_cfg::fedId, fillRandom_, mps_fire::i, log, FEDRawData::resize(), FEDHeader::set(), FEDTrailer::set(), and findQualityFiles::size.

Referenced by fillRawData().

102  {
103  // FIXME: last ID included?
104  for (int fedId = fedmin; fedId <= fedmax; ++fedId) {
105  // Generate size...
106  float logsiz = CLHEP::RandGauss::shoot(std::log(meansize), std::log(meansize) - std::log(width / 2.));
107  size_t size = int(std::exp(logsiz));
108  size -= size % 8; // all blocks aligned to 64 bit words
109 
110  FEDRawData& feddata = data.FEDData(fedId);
111  // Allocate space for header+trailer+payload
112  feddata.resize(size + 16);
113 
114  if (fillRandom_) {
115  //fill FED with random values
116  size_t size_ui = size - size % sizeof(unsigned int);
117  for (size_t i = 0; i < size_ui; i += sizeof(unsigned int)) {
118  *((unsigned int*)(feddata.data() + i)) = (unsigned int)rand();
119  }
120  //remainder
121  for (size_t i = size_ui; i < size; i++) {
122  *(feddata.data() + i) = rand() & 0xff;
123  }
124  }
125 
126  // Generate header
127  FEDHeader::set(feddata.data(),
128  1, // Trigger type
129  eID.event(), // LV1_id (24 bits)
130  0, // BX_id
131  fedId); // source_id
132 
133  // Payload = all 0s...
134 
135  // Generate trailer
136  int crc = 0; // FIXME : get CRC
137  FEDTrailer::set(feddata.data() + 8 + size,
138  size / 8 + 2, // in 64 bit words!!!
139  crc,
140  0, // Evt_stat
141  0); // TTS bits
142  }
143 }
unsigned int width
Definition: DaqFakeReader.h:56
EventNumber_t event() const
Definition: EventID.h:40
static std::vector< std::string > checklist log
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
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:31
void resize(size_t newsize)
Definition: FEDRawData.cc:28
unsigned int meansize
Definition: DaqFakeReader.h:55
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
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:25
tuple size
Write out results.
int DaqFakeReader::fillRawData ( edm::Event e,
FEDRawDataCollection *&  data 
)
virtual

Definition at line 66 of file DaqFakeReader.cc.

References empty_events, eventNum, fillFEDs(), fillTCDSFED(), edm::EventBase::id(), eostools::ls(), edm::EventBase::luminosityBlock(), 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, submitPVValidationJobs::now, and width.

Referenced by produce().

66  {
67  // a null pointer is passed, need to allocate the fed collection
68  data = new FEDRawDataCollection();
69  EventID eID = e.id();
70  auto ls = e.luminosityBlock();
71 
72  if (!empty_events) {
73  // Fill the EventID
74  eventNum++;
75  // FIXME:
76 
84 
85  timeval now;
86  gettimeofday(&now, nullptr);
87  fillTCDSFED(eID, *data, ls, &now);
88  }
89  return 1;
90 }
unsigned int width
Definition: DaqFakeReader.h:56
def ls
Definition: eostools.py:349
void fillFEDs(const int, const int, edm::EventID &eID, FEDRawDataCollection &data, float meansize, float width)
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
unsigned int meansize
Definition: DaqFakeReader.h:55
void fillTCDSFED(edm::EventID &eID, FEDRawDataCollection &data, uint32_t ls, timeval *now)
edm::EventID id() const
Definition: EventBase.h:59
edm::EventNumber_t eventNum
Definition: DaqFakeReader.h:52
void DaqFakeReader::fillTCDSFED ( edm::EventID eID,
FEDRawDataCollection data,
uint32_t  ls,
timeval *  now 
)
private

Definition at line 145 of file DaqFakeReader.cc.

References tcds::Header_v1::bxid, FEDRawData::data(), edm::EventID::event(), tcds::Header_v1::eventNumber, FEDRawDataCollection::FEDData(), l1tstage2_dqm_sourceclient-live_cfg::fedId, tcds::BST_v1::gpstimehigh, tcds::BST_v1::gpstimelow, FEDHeader::length, tcds::BST_v1::lhcFillHigh, tcds::BST_v1::lhcFillLow, tcds::Header_v1::lumiSection, tcds::Header_v1::orbitHigh, tcds::Header_v1::orbitLow, FEDRawData::resize(), FEDHeader::set(), FEDTrailer::set(), findQualityFiles::size, and tcdsFEDID_.

Referenced by fillRawData().

145  {
146  uint32_t fedId = tcdsFEDID_;
147  FEDRawData& feddata = data.FEDData(fedId);
148  uint32_t size = sizeof(tcds::Raw_v1);
149  feddata.resize(size + 16);
150 
151  uint64_t orbitnr = 0;
152  uint16_t bxid = 0;
153 
154  FEDHeader::set(feddata.data(),
155  1, // Trigger type
156  eID.event(), // LV1_id (24 bits)
157  bxid, // BX_id
158  fedId); // source_id
159 
160  tcds::Raw_v1* tcds = reinterpret_cast<tcds::Raw_v1*>(feddata.data() + FEDHeader::length);
161  tcds::BST_v1* bst = const_cast<tcds::BST_v1*>(&tcds->bst);
162  tcds::Header_v1* header = const_cast<tcds::Header_v1*>(&tcds->header);
163 
164  const_cast<uint32_t&>(bst->gpstimehigh) = now->tv_sec;
165  const_cast<uint32_t&>(bst->gpstimelow) = now->tv_usec;
166  const_cast<uint16_t&>(bst->lhcFillHigh) = 0;
167  const_cast<uint16_t&>(bst->lhcFillLow) = 0;
168 
169  const_cast<uint32_t&>(header->orbitHigh) = orbitnr & 0xffff00;
170  const_cast<uint16_t&>(header->orbitLow) = orbitnr & 0xff;
171  const_cast<uint16_t&>(header->bxid) = bxid;
172 
173  const_cast<uint64_t&>(header->eventNumber) = eID.event();
174  const_cast<uint32_t&>(header->lumiSection) = ls;
175 
176  int crc = 0; // only full event crc32c checked in HLT, not FED CRC16
177  FEDTrailer::set(feddata.data() + 8 + size,
178  size / 8 + 2, // in 64 bit words!!!
179  crc,
180  0, // Evt_stat
181  0); // TTS bits
182 }
EventNumber_t event() const
Definition: EventID.h:40
const uint16_t orbitLow
Definition: TCDSRaw.h:48
static const uint32_t length
Definition: FEDHeader.h:54
const uint32_t lumiSection
Definition: TCDSRaw.h:42
unsigned int tcdsFEDID_
Definition: DaqFakeReader.h:58
const uint16_t bxid
Definition: TCDSRaw.h:47
def ls
Definition: eostools.py:349
const uint64_t eventNumber
Definition: TCDSRaw.h:51
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:31
void resize(size_t newsize)
Definition: FEDRawData.cc:28
const uint32_t orbitHigh
Definition: TCDSRaw.h:49
unsigned long long uint64_t
Definition: Time.h:13
const uint16_t lhcFillLow
Definition: TCDSRaw.h:79
const uint32_t gpstimelow
Definition: TCDSRaw.h:72
const uint32_t gpstimehigh
Definition: TCDSRaw.h:73
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
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:25
const uint16_t lhcFillHigh
Definition: TCDSRaw.h:80
tuple size
Write out results.
void DaqFakeReader::produce ( edm::Event e,
edm::EventSetup const &  es 
)
overridevirtual

Implements edm::one::EDProducerBase.

Definition at line 92 of file DaqFakeReader.cc.

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

92  {
94  FEDRawDataCollection* fedcoll = nullptr;
95  fillRawData(e, fedcoll);
96  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
97  e.put(std::move(bare_product));
98 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
def move
Definition: eostools.py:511

Member Data Documentation

bool DaqFakeReader::empty_events
private

Definition at line 53 of file DaqFakeReader.h.

Referenced by fillRawData().

edm::EventNumber_t DaqFakeReader::eventNum
private

Definition at line 52 of file DaqFakeReader.h.

Referenced by fillRawData().

unsigned int DaqFakeReader::fakeLs_ = 0
private

Definition at line 60 of file DaqFakeReader.h.

Referenced by beginLuminosityBlock().

bool DaqFakeReader::fillRandom_
private

Definition at line 54 of file DaqFakeReader.h.

Referenced by DaqFakeReader(), and fillFEDs().

unsigned int DaqFakeReader::injected_errors_per_million_events
private

Definition at line 57 of file DaqFakeReader.h.

unsigned int DaqFakeReader::meansize
private

Definition at line 55 of file DaqFakeReader.h.

Referenced by fillRawData().

unsigned int DaqFakeReader::modulo_error_events
private

Definition at line 59 of file DaqFakeReader.h.

edm::RunNumber_t DaqFakeReader::runNum
private

Definition at line 51 of file DaqFakeReader.h.

unsigned int DaqFakeReader::tcdsFEDID_
private

Definition at line 58 of file DaqFakeReader.h.

Referenced by DaqFakeReader(), and fillTCDSFED().

unsigned int DaqFakeReader::width
private