27 using namespace rpcrawtodigi;
33 readoutMappingToken_ = esConsumes<RPCEMap, RPCEMapRcd>();
35 produces<FEDRawDataCollection>();
45 if (recordWatcher_.check(es)) {
47 LogTrace(
"") <<
"record has CHANGED!!, initialise readout map!";
49 theCabling = readoutMapping->convert();
50 LogTrace(
"") <<
" READOUT MAP VERSION: " << theCabling->version() << endl;
53 auto buffers = std::make_unique<FEDRawDataCollection>();
56 pair<int, int> rpcFEDS(790, 792);
57 for (
int id = rpcFEDS.first;
id <= rpcFEDS.second; ++
id) {
59 unsigned int lvl1_ID = ev.
id().
event();
63 fedRawData = *rawData;
82 vector<Word64> dataWords;
84 typedef vector<EventRecords>::const_iterator
IR;
85 for (IR ir = merged.begin(), irEnd = merged.end(); ir != irEnd; ++ir) {
86 Word64 w = (((
Word64(ir->recordBX().data()) << 16) | ir->recordSLD().data()) << 16 | ir->recordCD().data()) << 16 |
88 dataWords.push_back(w);
96 int dataSize = (nHeaders + nTrailers + dataWords.size()) *
sizeof(
Word64);
102 unsigned char* pHeader = raw->
data();
104 int source_ID =
fedId;
110 for (
unsigned int idata = 0; idata < dataWords.size(); idata++) {
112 *word = dataWords[idata];
118 unsigned char* pTrailer = pHeader + raw->
size() -
sizeof(
Word64);
133 vector<EventRecords> dataRecords;
136 for (DigiRangeIterator it = digis->begin(); it != digis->end(); it++) {
138 uint32_t rawDetId = rpcDetId.
rawId();
140 for (vector<RPCDigi>::const_iterator
id = range.first;
id != range.second;
id++) {
142 vector<EventRecords> rawFromDigi = formatter.
recordPack(rawDetId, digi, trigger_BX);
143 dataRecords.insert(dataRecords.end(), rawFromDigi.begin(), rawFromDigi.end());
150 LogTrace(
"RPCRawDataPacker") <<
" size of data: " << dataRecords.size();
151 vector<EventRecords>
merged = EventRecords::mergeRecords(dataRecords);
152 LogTrace(
"") <<
" size of megred: " << merged.size();
EventNumber_t event() const
#define IR(x)
Integer representation of a floating-point value.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
~RPCPackingModule() override
dtor
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr uint32_t rawId() const
get the raw id
static std::vector< rpcrawtodigi::EventRecords > eventRecords(int fedId, int trigger_BX, const RPCDigiCollection *, const RPCRecordFormatter &)
size_t size() const
Lenght of the data buffer in bytes.
const uint16_t range(const Frame &aFrame)
FEDRawData * rawData(int fedId, unsigned int lvl1_ID, const RPCDigiCollection *, const RPCRecordFormatter &) 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.
const Data & data() const
T const * product() const
unsigned long long uint64_t
RPCPackingModule(const edm::ParameterSet &)
ctor
void produce(edm::Event &, const edm::EventSetup &) override
get data, convert to raw event, attach again to Event
std::pair< const_iterator, const_iterator > Range
T getParameter(std::string const &) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const