21 fill_counters_(
config.getParameter<
bool>(
"fillAMCCounters")),
22 bx_min_(
config.getParameter<
int>(
"bxMin")),
23 bx_max_(
config.getParameter<
int>(
"bxMax")),
24 cppfDaq_Delay_(
config.getParameter<
int>(
"cppfDaqDelay")),
25 es_cppf_link_map_br_token_(
40 for (
auto const& cppf_link : link_map->getMap()) {
41 feds.insert(cppf_link.first.getFED());
49 std::map<RPCAMCLink, rpcamc13::AMCPayload>
const& amc_payload) {
54 std::set<std::pair<RPCDetId, RPCDigi> > rpc_digis;
58 for (std::pair<RPCAMCLink const, rpcamc13::AMCPayload>
const&
payload : amc_payload) {
63 std::sort(rpc_cppf_digis->begin(), rpc_cppf_digis->end());
73 std::set<std::pair<RPCDetId, RPCDigi> >& rpc_digis,
75 LogDebug(
"RPCCPPFRawToDigi") <<
"RPCCPPF " << link <<
", size " <<
payload.getData().size();
81 std::vector<std::uint64_t>::const_iterator
word(
payload.getData().begin());
87 std::vector<std::uint64_t>::const_iterator word_end(
payload.getData().end());
89 unsigned int bx_counter(
header.getBXCounter());
90 unsigned int bx_counter_mod(bx_counter % 27);
95 unsigned int pos(0), length(0);
96 unsigned int caption_id(0);
97 bool zs_per_bx(
false), have_bx_header(
false);
98 unsigned int bx_words(0);
99 unsigned int block_id(0);
100 std::uint32_t records[2];
102 records[0] = *
word & 0xffffffff;
103 records[1] = (*
word >> 32) & 0xffffffff;
108 <<
" caption id " << block_header.
getCaptionId() <<
" zs per bx " 116 have_bx_header =
false;
118 block_id = block_header.
getId();
119 }
else if (zs_per_bx && !have_bx_header) {
121 have_bx_header =
true;
123 if (caption_id == 0x01) {
126 }
else if (caption_id == 0x02) {
139 unsigned int bx_counter_mod,
142 std::set<std::pair<RPCDetId, RPCDigi> >& rpc_digis,
145 int cppfDaq_Delay)
const {
147 unsigned int fed(link.
getFED());
149 if (
record.getLink() > 80)
153 int bx_offset = (
int)(
record.getBXCounterMod() + 31 - bx_counter_mod) % 27 - 4;
159 LogDebug(
"RPCCPPFRawToDigi") <<
"Link in error for " << link;
161 }
else if (!
record.isAcknowledge()) {
165 LogDebug(
"RPCCPPFRawToDigi") <<
"Link without acknowledge for " << link;
174 int bx(bx_offset - (
int)(
record.getDelay()));
175 LogDebug(
"RPCCPPFRawToDigi") <<
"RPC BX " <<
bx <<
" for offset " << bx_offset;
186 LogDebug(
"RPCCPPFRawToDigi") <<
"Skipping unknown RPCCPPFLink " << link;
196 LogDebug(
"RPCCPPFRawToDigi") <<
"Skipping invalid LinkBoard " <<
record.getLinkBoard() <<
" for record " << link
206 LogDebug(
"RPCCPPFRawToDigi") <<
"Skipping invalid Connector " <<
record.getConnector() <<
" for record " << link
208 <<
") from " << link;
220 LogDebug(
"RPCCPPFRawToDigi") <<
"Could not find " << lb_link <<
" for record " << link <<
" (" << std::hex
225 auto bx_corrected =
bx - cppfDaq_Delay;
226 if (bx_corrected < bx_min || bx_corrected > bx_max) {
236 unsigned int channel_offset(
record.getPartition() ? 9 : 1);
238 for (
unsigned int channel = 0; channel < 8; ++channel) {
239 if (
data & (0
x1 << channel)) {
240 unsigned int strip(feb_connector.
getStrip(channel + channel_offset));
243 LogDebug(
"RPCCPPFRawToDigi") <<
"RPCDigi " << det_id.rawId() <<
", " <<
strip <<
", " <<
bx <<
", " 263 static int const ring[6] = {2, 2, 2, 3, 2, 3};
264 static int const station[6] = {1, 2, 3, 3, 4, 4};
268 unsigned int emtf_sector(((34 + (link.
getAMCNumber() - (
region > 0 ? 3 : 7)) * 9 + (
block >> 1)) % 36) / 6 + 1);
274 ((endcap_sector - 1) / 6) + 1
278 (endcap_sector - 1) % 6 + 1
283 rpc_cppf_digis.push_back(
284 l1t::CPPFDigi(rpc_id, 0,
record.getPhi(0),
record.getTheta(0), 0, 0, 0, emtf_sector, emtf_link, 0, 0, 0, 0));
287 rpc_cppf_digis.push_back(
288 l1t::CPPFDigi(rpc_id, 0,
record.getPhi(1),
record.getTheta(1), 1, 0, 0, emtf_sector, emtf_link, 0, 0, 0, 0));
295 std::vector<RPCDigi> local_rpc_digis;
296 for (std::pair<RPCDetId, RPCDigi>
const& rpc_digi : rpc_digis) {
297 LogDebug(
"RPCCPPFRawToDigi") <<
"RPCDigi " << rpc_digi.first.rawId() <<
", " << rpc_digi.second.strip() <<
", " 298 << rpc_digi.second.bx();
299 if (rpc_digi.first != rpc_det_id) {
300 if (!local_rpc_digis.empty()) {
302 local_rpc_digis.clear();
304 rpc_det_id = rpc_digi.first;
306 local_rpc_digis.push_back(rpc_digi.second);
308 if (!local_rpc_digis.empty()) {
312 event.put(
std::move(rpc_digi_collection));
void produce(edm::Event &event, edm::EventSetup const &setup, std::map< RPCAMCLink, rpcamc13::AMCPayload > const &amc_payload) override
void processRXRecord(RPCAMCLink link, unsigned int bx_counter_mod, rpccppf::RXRecord const &record, RPCAMCLinkCounters &counters, std::set< std::pair< RPCDetId, RPCDigi > > &rpc_digis, int bx_min, int bx_max, int cppfDaq_Delay) const
edm::ESHandle< RPCLBLinkMap > es_lb_link_map_
static unsigned int const input_connector_not_used_
edm::ESHandle< RPCAMCLinkMap > es_cppf_link_map_
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
void processTXRecord(RPCAMCLink link, unsigned int block, unsigned int word, rpccppf::TXRecord const &record, l1t::CPPFDigiCollection &rpc_cppf_digis) const
static int const max_connector_
static unsigned int const input_link_error_
RPCAMCLink & setAMCInput(int amcinput=wildcard_)
static unsigned int const input_lb_invalid_
RPCLBLink & setConnector(int connector=wildcard_)
edm::ESGetToken< RPCAMCLinkMap, RPCCPPFLinkMapRcd > es_cppf_link_map_br_token_
void beginRun(edm::Run const &run, edm::EventSetup const &setup) override
static unsigned int const amc_link_invalid_
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
RPCDetId getRPCDetId() const
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
bool processCPPF(RPCAMCLink const &link, rpcamc13::AMCPayload const &payload, RPCAMCLinkCounters &counters, std::set< std::pair< RPCDetId, RPCDigi > > &rpc_digis, l1t::CPPFDigiCollection &rpc_cppf_digis) const
edm::ESWatcher< RPCCPPFLinkMapRcd > es_cppf_link_map_watcher_
edm::ESGetToken< RPCLBLinkMap, RPCLBLinkMapRcd > es_lb_link_map_token_
void putRPCDigis(edm::Event &event, std::set< std::pair< RPCDetId, RPCDigi > > const &digis) const
static unsigned int const input_event_
static unsigned int const input_link_ack_fail_
std::pair< const_iterator, const_iterator > Range
RPCCPPFUnpacker(edm::ParameterSet const &, edm::ConsumesCollector, edm::ProducesCollector)
bool check(const edm::EventSetup &iSetup)
char data[epos_bytes_allocation]
unsigned int getStrip(unsigned int channel) const
edm::ESGetToken< RPCAMCLinkMap, RPCCPPFLinkMapRcd > es_cppf_link_map_token_
#define DEFINE_EDM_PLUGIN(factory, type, name)
RPCLBLink & setLinkBoard(int linkboard=wildcard_)
std::vector< CPPFDigi > CPPFDigiCollection
static int const max_linkboard_
static unsigned int const input_eod_
static unsigned int const input_connector_invalid_