34 using namespace rpcrawtodigi;
39 : dataLabel_(pset.getParameter<edm::
InputTag>(
"InputLabel")),
40 doSynchro_(pset.getParameter<bool>(
"doSynchro")),
44 produces<RPCDigiCollection>();
45 produces<RPCRawDataCounts>();
47 produces<RPCRawSynchro::ProdItem>();
56 desc.
add<
bool>(
"doSynchro",
true);
57 descriptions.
add(
"rpcUnpackingModule", desc);
62 LogTrace(
"") <<
"record has CHANGED!!, (re)initialise readout map!";
80 auto producedRPCDigis = std::make_unique<RPCDigiCollection>();
81 auto producedRawDataCounts = std::make_unique<RPCRawDataCounts>();
82 std::unique_ptr<RPCRawSynchro::ProdItem> producedRawSynchoCounts;
84 producedRawSynchoCounts = std::make_unique<RPCRawSynchro::ProdItem>();
92 unsigned int nWords = rawData.
size() /
sizeof(
Word64);
101 bool moreHeaders =
true;
102 while (moreHeaders) {
104 FEDHeader fedHeader(reinterpret_cast<const unsigned char*>(header));
105 if (!fedHeader.
check()) {
106 producedRawDataCounts->addReadoutError(
fedId,
ReadoutError(ReadoutError::HeaderCheckFail));
108 LogTrace(
"") <<
" ** PROBLEM **, header.check() failed, break";
112 producedRawDataCounts->addReadoutError(
fedId,
ReadoutError(ReadoutError::InconsitentFedId));
114 LogTrace(
"") <<
" ** PROBLEM **, fedHeader.sourceID() != fedId"
115 <<
"fedId = " <<
fedId <<
" sourceID=" << fedHeader.
sourceID();
117 triggerBX = fedHeader.
bxID();
121 str <<
" header: " << *
reinterpret_cast<const bitset<64>*
>(header) << endl;
122 str <<
" header triggerType: " << fedHeader.
triggerType() << endl;
123 str <<
" header lvl1ID: " << fedHeader.
lvl1ID() << endl;
124 str <<
" header bxID: " << fedHeader.
bxID() << endl;
125 str <<
" header sourceID: " << fedHeader.
sourceID() << endl;
126 str <<
" header version: " << fedHeader.
version() << endl;
134 const Word64* trailer =
reinterpret_cast<const Word64*
>(rawData.
data()) + (nWords - 1);
136 bool moreTrailers =
true;
137 while (moreTrailers) {
139 FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
140 if (!fedTrailer.
check()) {
141 producedRawDataCounts->addReadoutError(
fedId,
ReadoutError(ReadoutError::TrailerCheckFail));
143 LogTrace(
"") <<
" ** PROBLEM **, trailer.check() failed, break";
147 producedRawDataCounts->addReadoutError(
fedId,
ReadoutError(ReadoutError::InconsistentDataSize));
149 LogTrace(
"") <<
" ** PROBLEM **, fedTrailer.fragmentLength()!= nWords, break";
155 str <<
" trailer: " << *
reinterpret_cast<const bitset<64>*
>(trailer) << endl;
156 str <<
" trailer lenght: " << fedTrailer.
fragmentLength() << endl;
157 str <<
" trailer crc: " << fedTrailer.
crc() << endl;
158 str <<
" trailer evtStatus: " << fedTrailer.
evtStatus() << endl;
159 str <<
" trailer ttsBits: " << fedTrailer.
ttsBits() << endl;
170 str <<
" data: " << *
reinterpret_cast<const bitset<64>*
>(
word) << endl;
178 for (
int iRecord = 1; iRecord <= 4; iRecord++) {
183 std::ostringstream
str;
184 str <<
"record: " << record.
print() <<
" hex: " << hex << *pRecord <<
dec;
187 str <<
" --> dccId: " <<
fedId <<
" rmb: " <<
event.recordSLD().rmb()
188 <<
" lnk: " <<
event.recordSLD().tbLinkInputNumber() <<
" lb: " <<
event.recordCD().lbInLink()
189 <<
" part: " <<
event.recordCD().partitionNumber() <<
" data: " <<
event.recordCD().partitionData()
190 <<
" eod: " <<
event.recordCD().eod();
194 producedRawDataCounts->addDccRecord(
fedId, record);
198 event, producedRPCDigis.get(), producedRawDataCounts.get(), producedRawSynchoCounts.get());
205 LogTrace(
"") <<
" RPCUnpackingModule - There was unpacking PROBLEM in this event" << endl;
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static MessageDrop * instance()
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
bool check() const
Check that the trailer is OK.
bool moreTrailers() const
void init(const RPCReadOutMapping *arm)
takes ownership of map
size_t size() const
Lenght of the data buffer in bytes.
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
RPCUnpackingModule(const edm::ParameterSet &pset)
Constructor.
const std::string & version() const
version as string
edm::ESGetToken< RPCEMap, RPCEMapRcd > theReadoutMappingToken
void produce(edm::Event &ev, const edm::EventSetup &es) override
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const RPCReadOutMapping * theCabling
~RPCUnpackingModule() override
Destructor.
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
unsigned long long uint64_t
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
uint8_t evtStatus() const
Event fragment status information.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool check(const edm::EventSetup &iSetup)
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
std::string print() const
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
DataRecordType type() const
unsigned long eventCounter_
edm::ESWatcher< RPCEMapRcd > theRecordWatcher