CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
RPCCPPFUnpacker Class Reference

#include <RPCCPPFUnpacker.h>

Inheritance diagram for RPCCPPFUnpacker:
RPCAMCUnpacker

Public Member Functions

void beginRun (edm::Run const &run, edm::EventSetup const &setup)
 
void produce (edm::Event &event, edm::EventSetup const &setup, std::map< RPCAMCLink, rpcamc13::AMCPayload > const &amc_payload)
 
 RPCCPPFUnpacker (edm::stream::EDProducerBase &producer, edm::ParameterSet const &config)
 
- Public Member Functions inherited from RPCAMCUnpacker
std::vector< int > const & getFeds () const
 
 RPCAMCUnpacker (edm::stream::EDProducerBase &producer, edm::ParameterSet const &config)
 
virtual ~RPCAMCUnpacker ()
 

Protected Member Functions

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
 
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) const
 
void processTXRecord (RPCAMCLink link, unsigned int block, unsigned int word, rpccppf::TXRecord const &record, l1t::CPPFDigiCollection &rpc_cppf_digis) const
 
void putRPCDigis (edm::Event &event, std::set< std::pair< RPCDetId, RPCDigi > > const &digis) const
 

Protected Attributes

int bx_max_
 
int bx_min_
 
edm::ESHandle< RPCAMCLinkMapes_cppf_link_map_
 
edm::ESWatcher< RPCCPPFLinkMapRcdes_cppf_link_map_watcher_
 
edm::ESHandle< RPCLBLinkMapes_lb_link_map_
 
bool fill_counters_
 
- Protected Attributes inherited from RPCAMCUnpacker
std::vector< int > feds_
 

Additional Inherited Members

- Static Public Member Functions inherited from RPCAMCUnpacker
static void fillDescription (edm::ParameterSetDescription &desc)
 

Detailed Description

Definition at line 22 of file RPCCPPFUnpacker.h.

Constructor & Destructor Documentation

RPCCPPFUnpacker::RPCCPPFUnpacker ( edm::stream::EDProducerBase producer,
edm::ParameterSet const &  config 
)

Definition at line 19 of file RPCCPPFUnpacker.cc.

References fill_counters_.

20  : RPCAMCUnpacker(producer, config)
21  , fill_counters_(config.getParameter<bool>("fillAMCCounters"))
22  , bx_min_(config.getParameter<int>("bxMin"))
23  , bx_max_(config.getParameter<int>("bxMax"))
24 {
25  producer.produces<RPCDigiCollection>();
26  producer.produces<l1t::CPPFDigiCollection>();
27  if (fill_counters_) {
28  producer.produces<RPCAMCLinkCounters>("RPCAMCUnpacker");
29  }
30 }
Definition: config.py:1
RPCAMCUnpacker(edm::stream::EDProducerBase &producer, edm::ParameterSet const &config)
std::vector< CPPFDigi > CPPFDigiCollection
Definition: CPPFDigi.h:68

Member Function Documentation

void RPCCPPFUnpacker::beginRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
)
virtual

Reimplemented from RPCAMCUnpacker.

Definition at line 32 of file RPCCPPFUnpacker.cc.

References edm::ESWatcher< T >::check(), es_cppf_link_map_, es_cppf_link_map_watcher_, RPCAMCUnpacker::feds_, edm::EventSetup::get(), and RPCAMCLinkMap::getMap().

33 {
36  std::set<int> feds;
37  for (auto const & cppf_link : es_cppf_link_map_->getMap()) {
38  feds.insert(cppf_link.first.getFED());
39  }
40  feds_.assign(feds.begin(), feds.end());
41  }
42 }
std::vector< int > feds_
edm::ESHandle< RPCAMCLinkMap > es_cppf_link_map_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
map_type & getMap()
Definition: RPCAMCLinkMap.h:28
edm::ESWatcher< RPCCPPFLinkMapRcd > es_cppf_link_map_watcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
bool RPCCPPFUnpacker::processCPPF ( RPCAMCLink const &  link,
rpcamc13::AMCPayload const &  payload,
RPCAMCLinkCounters counters,
std::set< std::pair< RPCDetId, RPCDigi > > &  rpc_digis,
l1t::CPPFDigiCollection rpc_cppf_digis 
) const
protected

Definition at line 68 of file RPCCPPFUnpacker.cc.

References bx_max_, bx_min_, TauDecayModes::dec, rpcmp7::BlockHeader::getCaptionId(), rpcamc13::AMCPayload::getData(), rpcmp7::BlockHeader::getId(), rpcmp7::BlockHeader::getLength(), rpcmp7::BlockHeader::getRecord(), rpcmp7::BlockHeader::hasZeroSuppressionPerBX(), RecoTauValidation_cfi::header, rpcamc13::AMCPayload::isValid(), rpcmp7::BlockHeader::isZeroSuppressed(), LogDebug, processRXRecord(), processTXRecord(), and record.

Referenced by produce().

72 {
73  LogDebug("RPCCPPFRawToDigi") << "RPCCPPF " << link
74  << ", size " << payload.getData().size();
75 
76  if (!payload.isValid()) {
77  return false;
78  }
79 
80  std::vector<std::uint64_t>::const_iterator word(payload.getData().begin());
81  rpcmp7::Header header(&(*word));
82  ++word; ++word;
83  rpcmp7::SubHeader subheader(*word);
84  ++word;
85  std::vector<std::uint64_t>::const_iterator word_end(payload.getData().end());
86  --word_end; // rpcamc::Trailer
87  unsigned int bx_counter(header.getBXCounter());
88  unsigned int bx_counter_mod(bx_counter % 27);
89 
90  int bx_min(bx_min_), bx_max(bx_max_);
91  // no adjustable bx window implemented in readout yet
92 
93  unsigned int pos(0), length(0);
94  unsigned int caption_id(0);
95  bool zs_per_bx(false), have_bx_header(false);
96  unsigned int bx_words(0);
97  unsigned int block_id(0);
98  std::uint32_t records[2];
99  for ( ; word != word_end ; ++word) {
100  records[0] = *word & 0xffffffff;
101  records[1] = (*word >> 32) & 0xffffffff;
102  for (std::uint32_t * record = &(records[0]) ; record < &(records[2]) ; ++record) {
103  if (pos >= length) {
104  rpcmp7::BlockHeader block_header(*record);
105  LogDebug("RPCCPPFUnpacker") << "block header " << std::hex << block_header.getRecord() << std::dec
106  << " caption id " << block_header.getCaptionId()
107  << " zs per bx " << block_header.hasZeroSuppressionPerBX()
108  << " zs " << block_header.isZeroSuppressed()
109  << " length " << block_header.getLength()
110  << " " << word_end - word;
111  pos = 0;
112  length = block_header.getLength();
113  caption_id = block_header.getCaptionId();
114  zs_per_bx = block_header.hasZeroSuppressionPerBX();
115  have_bx_header = false;
116  bx_words = 6;
117  block_id = block_header.getId();
118  } else if (zs_per_bx && !have_bx_header) {
119  // rpcmp7::BXHeader bx_header(*record);
120  have_bx_header = true;
121  } else {
122  if (caption_id == 0x01) { // RX
123  processRXRecord(link, bx_counter_mod, rpccppf::RXRecord(*record), counters, rpc_digis, bx_min, bx_max);
124  } else if (caption_id == 0x02) { // TX
125  processTXRecord(link, block_id, 6 - bx_words, rpccppf::TXRecord(*record), rpc_cppf_digis);
126  }
127  ++pos;
128  --bx_words;
129  }
130  }
131  }
132 
133  return true;
134 }
#define LogDebug(id)
JetCorrectorParameters::Record record
Definition: classes.h:7
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) const
void processTXRecord(RPCAMCLink link, unsigned int block, unsigned int word, rpccppf::TXRecord const &record, l1t::CPPFDigiCollection &rpc_cppf_digis) const
void RPCCPPFUnpacker::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 
) const
protected

Definition at line 136 of file RPCCPPFUnpacker.cc.

References RPCAMCLinkCounters::add(), RPCAMCLinkEvents::amc_link_invalid_, data, TauDecayModes::dec, es_cppf_link_map_, es_lb_link_map_, fill_counters_, RPCAMCLink::getAMCNumber(), rpccppf::RXRecord::getBXCounterMod(), rpccppf::RXRecord::getConnector(), rpccppf::RXRecord::getDelay(), RPCAMCLink::getFED(), rpccppf::RXRecord::getLink(), rpccppf::RXRecord::getLinkBoard(), RPCLBLinkMap::getMap(), RPCAMCLinkMap::getMap(), rpccppf::RXRecord::getPartition(), rpccppf::RXRecord::getPartitionData(), rpccppf::RXRecord::getRecord(), RPCFebConnector::getRPCDetId(), RPCFebConnector::getStrip(), RPCAMCLinkEvents::input_connector_invalid_, RPCAMCLinkEvents::input_connector_not_used_, RPCAMCLinkEvents::input_eod_, RPCAMCLinkEvents::input_event_, RPCAMCLinkEvents::input_lb_invalid_, RPCAMCLinkEvents::input_link_ack_fail_, RPCAMCLinkEvents::input_link_error_, createfilelist::int, rpccppf::RXRecord::isAcknowledge(), rpccppf::RXRecord::isEOD(), rpccppf::RXRecord::isError(), LogDebug, RPCLBLink::max_connector_, RPCLBLink::max_linkboard_, RPCAMCLink::setAMCInput(), RPCLBLink::setConnector(), RPCLBLink::setLinkBoard(), digitizers_cfi::strip, and globals_cff::x1.

Referenced by processCPPF().

142 {
143  LogDebug("RPCCPPFRawToDigi") << "RXRecord " << std::hex << record.getRecord() << std::dec << std::endl;
144  unsigned int fed(link.getFED());
145  unsigned int amc_number(link.getAMCNumber());
146  link.setAMCInput(record.getLink());
147 
148  int bx_offset = (int)(record.getBXCounterMod() + 31 - bx_counter_mod) % 27 - 4;
149 
150  if (record.isError()) {
151  if (fill_counters_ && bx_offset == 0) {
153  }
154  LogDebug("RPCCPPFRawToDigi") << "Link in error for " << link;
155  return;
156  } else if (!record.isAcknowledge()) {
157  if (fill_counters_ && bx_offset == 0) {
159  }
160  LogDebug("RPCCPPFRawToDigi") << "Link without acknowledge for " << link;
161  return;
162  }
163 
164  std::uint8_t data(record.getPartitionData());
165  if (!data) {
166  return;
167  }
168 
169  int bx(bx_offset - (int)(record.getDelay()));
170  LogDebug("RPCCPPFRawToDigi") << "RPC BX " << bx << " for offset " << bx_offset;
171 
172  if (fill_counters_ && bx == 0 && record.isEOD()) { // EOD comes at the last delay
173  counters.add(RPCAMCLinkEvents::input_eod_, link);
174  }
175 
176  RPCAMCLinkMap::map_type::const_iterator link_it = es_cppf_link_map_->getMap().find(link);
177  if (link_it == es_cppf_link_map_->getMap().end()) {
178  if (fill_counters_ && bx_offset == 0) {
179  counters.add(RPCAMCLinkEvents::amc_link_invalid_, RPCAMCLink(fed, amc_number));
180  }
181  LogDebug("RPCCPPFRawToDigi") << "Skipping unknown RPCCPPFLink " << link;
182  return;
183  }
184 
185  RPCLBLink lb_link = link_it->second;
186 
187  if (record.getLinkBoard() > (unsigned int)RPCLBLink::max_linkboard_) {
188  if (fill_counters_ && bx_offset == 0) {
190  }
191  LogDebug("RPCCPPFRawToDigi") << "Skipping invalid LinkBoard " << record.getLinkBoard()
192  << " for record " << link << " (" << std::hex << record.getRecord()
193  << " in " << record.getRecord() << std::dec
194  << " from " << link;
195  return;
196  }
197 
198  if (record.getConnector() > (unsigned int)RPCLBLink::max_connector_) {
199  if (fill_counters_ && bx_offset == 0) {
201  }
202  LogDebug("RPCCPPFRawToDigi") << "Skipping invalid Connector " << record.getConnector()
203  << " for record " << link << " (" << std::hex << record.getRecord()
204  << " in " << record.getRecord() << std::dec
205  << ") from " << link;
206  return;
207  }
208 
209  lb_link.setLinkBoard(record.getLinkBoard());
210  lb_link.setConnector(record.getConnector());
211 
212  RPCLBLinkMap::map_type::const_iterator lb_link_it = es_lb_link_map_->getMap().find(lb_link);
213  if (lb_link_it == es_lb_link_map_->getMap().end()) {
214  if (fill_counters_ && bx_offset == 0) {
216  }
217  LogDebug("RPCCPPFRawToDigi") << "Could not find " << lb_link
218  << " for record " << link << " (" << std::hex << record.getRecord()
219  << " in " << record.getRecord() << std::dec
220  << ") from " << link;
221  return;
222  }
223 
224  if (bx < bx_min || bx > bx_max) {
225  return;
226  }
227 
228  if (fill_counters_ && bx == 0) {
229  counters.add(RPCAMCLinkEvents::input_event_, link);
230  }
231 
232  RPCFebConnector const & feb_connector(lb_link_it->second);
233  RPCDetId det_id(feb_connector.getRPCDetId());
234  unsigned int channel_offset(record.getPartition() ? 9 : 1); // 1-16
235 
236  for (unsigned int channel = 0 ; channel < 8 ; ++channel) {
237  if (data & (0x1 << channel)) {
238  unsigned int strip(feb_connector.getStrip(channel + channel_offset));
239  if (strip) {
240  rpc_digis.insert(std::pair<RPCDetId, RPCDigi>(det_id, RPCDigi(strip, bx)));
241  LogDebug("RPCCPPFRawToDigi") << "RPCDigi " << det_id.rawId()
242  << ", " << strip << ", " << bx;
243  }
244  }
245  }
246 }
#define LogDebug(id)
edm::ESHandle< RPCLBLinkMap > es_lb_link_map_
static unsigned int const input_connector_not_used_
edm::ESHandle< RPCAMCLinkMap > es_cppf_link_map_
JetCorrectorParameters::Record record
Definition: classes.h:7
static unsigned int const input_link_error_
static unsigned int const input_lb_invalid_
static unsigned int const amc_link_invalid_
map_type & getMap()
Definition: RPCAMCLinkMap.h:28
map_type & getMap()
Definition: RPCLBLinkMap.h:28
static unsigned int const input_event_
void add(unsigned int event, RPCAMCLink const &link, unsigned int count=1)
static unsigned int const input_link_ack_fail_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static unsigned int const input_eod_
static unsigned int const input_connector_invalid_
void RPCCPPFUnpacker::processTXRecord ( RPCAMCLink  link,
unsigned int  block,
unsigned int  word,
rpccppf::TXRecord const &  record,
l1t::CPPFDigiCollection rpc_cppf_digis 
) const
protected

Definition at line 248 of file RPCCPPFUnpacker.cc.

References RPCAMCLink::getAMCNumber(), rpccppf::TXRecord::getPhi(), rpccppf::TXRecord::getTheta(), rpccppf::TXRecord::isValid(), relativeConstraints::ring, and relativeConstraints::station.

Referenced by processCPPF().

253 {
254  if (!record.isValid(0) && !record.isValid(1)) {
255  return;
256  }
257 
258  // This translation should become part of a CondFormat
259  if (word > 5) {
260  return;
261  }
262  static int const ring[6] = {2, 2, 2, 3, 2, 3};
263  static int const station[6] = {1, 2, 3, 3, 4, 4};
264  int region(link.getAMCNumber() < 7 ? 1 : -1);
265  unsigned int endcap_sector((35 + (link.getAMCNumber() - (region > 0 ? 3 : 7)) * 9 + (block >> 1)) % 36 + 1);
266  RPCDetId rpc_id(region
267  , ring[word] // ring
268  , station[word] // station
269  , (endcap_sector / 6) + 1 // sector
270  , 1 // layer
271  , (endcap_sector - 1) % 6 + 1 // subsector
272  , 0); // roll
273 
274  if (record.isValid(0)) {
275  rpc_cppf_digis.push_back(l1t::CPPFDigi(rpc_id, 0, record.getTheta(0), record.getPhi(0)));
276  }
277  if (record.isValid(1)) {
278  rpc_cppf_digis.push_back(l1t::CPPFDigi(rpc_id, 0, record.getTheta(1), record.getPhi(1)));
279  }
280 }
JetCorrectorParameters::Record record
Definition: classes.h:7
void RPCCPPFUnpacker::produce ( edm::Event event,
edm::EventSetup const &  setup,
std::map< RPCAMCLink, rpcamc13::AMCPayload > const &  amc_payload 
)
virtual

Reimplemented from RPCAMCUnpacker.

Definition at line 44 of file RPCCPPFUnpacker.cc.

References es_cppf_link_map_, es_lb_link_map_, fill_counters_, edm::EventSetup::get(), eostools::move(), jets_cff::payload, processCPPF(), and putRPCDigis().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

46 {
47  // Get EventSetup Electronics Maps
50 
51  std::set<std::pair<RPCDetId, RPCDigi> > rpc_digis;
52  std::unique_ptr<l1t::CPPFDigiCollection> rpc_cppf_digis(new l1t::CPPFDigiCollection());
53  std::unique_ptr<RPCAMCLinkCounters> counters(new RPCAMCLinkCounters());
54 
55  for (std::pair<RPCAMCLink const, rpcamc13::AMCPayload> const & payload : amc_payload) {
56  processCPPF(payload.first, payload.second
57  , *counters, rpc_digis, *rpc_cppf_digis);
58  }
59 
60  putRPCDigis(event, rpc_digis);
61  std::sort(rpc_cppf_digis->begin(), rpc_cppf_digis->end());
62  event.put(std::move(rpc_cppf_digis));
63  if (fill_counters_) {
64  event.put(std::move(counters), "RPCAMCUnpacker");
65  }
66 }
edm::ESHandle< RPCLBLinkMap > es_lb_link_map_
edm::ESHandle< RPCAMCLinkMap > es_cppf_link_map_
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
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
void putRPCDigis(edm::Event &event, std::set< std::pair< RPCDetId, RPCDigi > > const &digis) const
std::vector< CPPFDigi > CPPFDigiCollection
Definition: CPPFDigi.h:68
def move(src, dest)
Definition: eostools.py:510
void RPCCPPFUnpacker::putRPCDigis ( edm::Event event,
std::set< std::pair< RPCDetId, RPCDigi > > const &  digis 
) const
protected

Definition at line 282 of file RPCCPPFUnpacker.cc.

References DEFINE_EDM_PLUGIN, LogDebug, and eostools::move().

Referenced by produce().

284 {
285  std::unique_ptr<RPCDigiCollection> rpc_digi_collection(new RPCDigiCollection());
286  RPCDetId rpc_det_id;
287  std::vector<RPCDigi> local_rpc_digis;
288  for (std::pair<RPCDetId, RPCDigi> const & rpc_digi : rpc_digis) {
289  LogDebug("RPCCPPFRawToDigi") << "RPCDigi " << rpc_digi.first.rawId()
290  << ", " << rpc_digi.second.strip() << ", " << rpc_digi.second.bx();
291  if (rpc_digi.first != rpc_det_id) {
292  if (!local_rpc_digis.empty()) {
293  rpc_digi_collection->put(RPCDigiCollection::Range(local_rpc_digis.begin(), local_rpc_digis.end()), rpc_det_id);
294  local_rpc_digis.clear();
295  }
296  rpc_det_id = rpc_digi.first;
297  }
298  local_rpc_digis.push_back(rpc_digi.second);
299  }
300  if (!local_rpc_digis.empty()) {
301  rpc_digi_collection->put(RPCDigiCollection::Range(local_rpc_digis.begin(), local_rpc_digis.end()), rpc_det_id);
302  }
303 
304  event.put(std::move(rpc_digi_collection));
305 }
#define LogDebug(id)
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
std::pair< const_iterator, const_iterator > Range
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

int RPCCPPFUnpacker::bx_max_
protected

Definition at line 53 of file RPCCPPFUnpacker.h.

Referenced by processCPPF().

int RPCCPPFUnpacker::bx_min_
protected

Definition at line 53 of file RPCCPPFUnpacker.h.

Referenced by processCPPF().

edm::ESHandle<RPCAMCLinkMap> RPCCPPFUnpacker::es_cppf_link_map_
protected

Definition at line 56 of file RPCCPPFUnpacker.h.

Referenced by beginRun(), processRXRecord(), and produce().

edm::ESWatcher<RPCCPPFLinkMapRcd> RPCCPPFUnpacker::es_cppf_link_map_watcher_
protected

Definition at line 55 of file RPCCPPFUnpacker.h.

Referenced by beginRun().

edm::ESHandle<RPCLBLinkMap> RPCCPPFUnpacker::es_lb_link_map_
protected

Definition at line 57 of file RPCCPPFUnpacker.h.

Referenced by processRXRecord(), and produce().

bool RPCCPPFUnpacker::fill_counters_
protected

Definition at line 52 of file RPCCPPFUnpacker.h.

Referenced by processRXRecord(), produce(), and RPCCPPFUnpacker().