54 : fed_id_(iConfig.getParameter<unsigned
int>(
"fedId")),
55 store_emul_info_(iConfig.getParameter<
bool>(
"storeEmulatorInfo")),
56 store_fed_header_trailer_(iConfig.getParameter<
bool>(
"fedHeaderTrailer")),
63 <<
"No ECON-D parameters were retrieved from the configuration. Please add at least one.";
65 if (emul_type ==
"trivial")
66 emulator_ = std::make_unique<hgcal::econd::TrivialEmulator>(econd_params);
67 else if (emul_type ==
"hgcmodule")
68 emulator_ = std::make_unique<hgcal::econd::HGCalModuleTreeReader>(
73 throw cms::Exception(
"HGCalSlinkEmulator") <<
"Invalid emulator type chosen: '" << emul_type <<
"'.";
79 throw cms::Exception(
"HGCalSlinkEmulator") <<
"The HGCalSlinkEmulator module requires the " 80 "RandomNumberGeneratorService,\n" 81 "which appears to be absent. Please add that service to your " 83 "or remove the modules that require it.";
94 const auto slink_event_size = slink_event.size() *
sizeof(slink_event.at(0));
97 size_t total_event_size = slink_event_size;
104 fed_data.
resize(total_event_size);
105 auto* ptr = fed_data.data();
109 const auto event_id = std::get<0>(last_event.first), bx_id = std::get<1>(last_event.first);
113 LogDebug(
"HGCalSlinkEmulator").log([&](
auto&
log) {
115 log <<
"FED header: lvl1ID=" << hdr.
lvl1ID() <<
", bxID=" << hdr.
bxID() <<
", source ID=" << hdr.
sourceID()
122 std::memcpy(ptr, slink_event.data(), slink_event_size);
123 ptr += slink_event_size;
124 LogDebug(
"HGCalSlinkEmulator") <<
"Wrote " << slink_event.size() <<
" 64-bit words = " << slink_event_size
130 slink_event.size() + 2,
131 evf::compute_crc(reinterpret_cast<uint8_t*>(slink_event.data()), slink_event_size),
134 LogDebug(
"HGCalSlinkEmulator").log([&](
auto&
log) {
137 <<
", status: " << trl.
evtStatus() <<
".";
159 ->setComment(
"emulator mode (trivial, or hgcmodule)");
160 desc.add<
unsigned int>(
"fedId", 0)->setComment(
"FED number delivering the emulated frames");
161 desc.add<
bool>(
"fedHeaderTrailer",
false)->setComment(
"also add FED header/trailer info");
162 desc.add<
bool>(
"storeEmulatorInfo",
false)
163 ->setComment(
"also append a 'truth' auxiliary info to the output event content");
164 descriptions.
add(
"hgcalEmulatedSlinkRawData",
desc);
const bool store_fed_header_trailer_
T getParameter(std::string const &) const
const std::map< unsigned int, econd::EmulatorParameters > & econdParams() const
List of ECON-D operational parameters for emulation.
HGCalSlinkEmulator(const edm::ParameterSet &)
void setEmulator(econd::Emulator &)
Set the emulation source for ECON-D frames.
static const uint32_t length
const econd::ECONDInput & lastECONDEmulatedInput() const
Retrieve the last ECON-D event emulated.
const bool store_emul_info_
void produce(edm::Event &, const edm::EventSetup &) override
const edm::EDPutTokenT< FEDRawDataCollection > fedRawToken_
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
std::vector< uint64_t > produceSlinkEvent(unsigned int fed_id) const
Produce a S-link event from an emulated event.
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
T getUntrackedParameter(std::string const &, T const &) const
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.
void resize(size_t newsize)
std::unique_ptr< hgcal::econd::Emulator > emulator_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
A S-link/ECON-D payload generator helper.
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
#define DEFINE_FWK_MODULE(type)
uint8_t evtStatus() const
Event fragment status information.
const HGCalSlinkEmulatorInfo & lastSlinkEmulatedInfo() const
Retrieve the metadata generated along with the last S-link emulated payload.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
static edm::ParameterSetDescription description()
edm::EDPutTokenT< HGCalSlinkEmulatorInfo > fedEmulInfoToken_
hgcal::HGCalFrameGenerator frame_gen_
static void fillDescriptions(edm::ConfigurationDescriptions &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setRandomEngine(CLHEP::HepRandomEngine &rng)
Set the random number generator engine.
edm::Service< edm::RandomNumberGenerator > rng_
const unsigned int fed_id_