CMS 3D CMS Logo

List of all members | Static Public Member Functions
RPCLBPacker Class Reference

#include <RPCLBPacker.h>

Static Public Member Functions

static void getRPCLBRecords (RPCInverseLBLinkMap const &lb_map, int min_bx, int max_bx, unsigned int bcn, RPCDigiCollection const &digis, std::map< RPCLBLink, std::vector< std::pair< int, RPCLBRecord > > > &mlb_bx_lbrecord, bool ignore_eod=false)
 

Detailed Description

Definition at line 13 of file RPCLBPacker.h.

Member Function Documentation

◆ getRPCLBRecords()

void RPCLBPacker::getRPCLBRecords ( RPCInverseLBLinkMap const &  lb_map,
int  min_bx,
int  max_bx,
unsigned int  bcn,
RPCDigiCollection const &  digis,
std::map< RPCLBLink, std::vector< std::pair< int, RPCLBRecord > > > &  mlb_bx_lbrecord,
bool  ignore_eod = false 
)
static

Definition at line 8 of file RPCLBPacker.cc.

References phase2TrackerDigitizer_cfi::delay, Exception, RPCLBLink::getConnector(), RPCLBLink::getLinkBoard(), RPCInverseLBLinkMap::getMap(), heavyIonCSV_trainingSettings::idx, input, genParticles_cff::map, RPCLBLink::setConnector(), RPCLBLink::setLinkBoard(), jetsAK4_CHS_cff::sort, and trackerHitRTTI::vector.

Referenced by RPCTwinMuxPacker::getRPCTwinMuxRecords().

14  {
15  if (max_bx - min_bx >= 128 || min_bx < -3564) { // limit 7 bits RPCLBRecord BCN; avoid overflow
16  throw cms::Exception("RPCLBPacker") << "Out-of-range input for min_bx, max_bx (" << min_bx << ": " << max_bx << ")";
17  }
18 
19  std::map<RPCLBLink, std::vector<RPCLBRecord> > mlb_lbrecords;
20 
21  // digi to record ; setBCN to (bx - min_bx) for easy sorting (avoid -1 = 3563 > 0)
22  RPCDigiCollection::DigiRangeIterator digi_range_end(digis.end());
23  for (RPCDigiCollection::DigiRangeIterator digi_range = digis.begin(); digi_range != digi_range_end; ++digi_range) {
24  RPCDigiCollection::DigiRangeIterator::value_type digi_range_value(*digi_range);
25  std::pair<RPCInverseLBLinkMap::map_type::const_iterator, RPCInverseLBLinkMap::map_type::const_iterator> lookup_range(
26  lb_map.getMap().equal_range(digi_range_value.first.rawId()));
27 
28  for (RPCDigiCollection::const_iterator digi = digi_range_value.second.first; digi != digi_range_value.second.second;
29  ++digi) {
30  if (digi->bx() < min_bx || digi->bx() > max_bx) {
31  continue;
32  }
33 
34  for (RPCInverseLBLinkMap::map_type::const_iterator link_it = lookup_range.first; link_it != lookup_range.second;
35  ++link_it) {
36  if (link_it->second.second.hasStrip(digi->strip())) {
37  unsigned int channel(link_it->second.second.getChannel(digi->strip()));
38  RPCLBLink lb_link(link_it->second.first);
39  RPCLBLink mlb_link(lb_link);
40  mlb_link.setLinkBoard().setConnector();
41  mlb_lbrecords[mlb_link].push_back(RPCLBRecord(digi->bx() - min_bx,
42  false,
43  lb_link.getLinkBoard(),
44  false,
45  0,
46  lb_link.getConnector(),
47  (channel > 8 ? 1 : 0),
48  0x01 << ((channel - 1) % 8)));
49  break;
50  }
51  }
52  }
53  }
54 
55  // merge records, set correct bcn and delay, and EOD if necessary
56  for (std::map<RPCLBLink, std::vector<RPCLBRecord> >::iterator mlb_lbrecords_it = mlb_lbrecords.begin();
57  mlb_lbrecords_it != mlb_lbrecords.end();
58  ++mlb_lbrecords_it) {
59  std::vector<RPCLBRecord>& input(mlb_lbrecords_it->second);
60  std::sort(input.begin(), input.end());
61 
62  std::vector<std::pair<int, RPCLBRecord> > bx_lbrecord;
63  bx_lbrecord.reserve(input.size());
64 
65  RPCLBRecord last_lbrecord(input.front()); // it's not empty by construction
66  unsigned int idx(0);
67  for (std::vector<RPCLBRecord>::const_iterator input_it = input.begin() + 1; input_it <= input.end(); ++input_it) {
68  if (input_it != input.end() && ((last_lbrecord.getRecord() & ~RPCLBRecord::partition_data_mask_) ==
69  (input_it->getRecord() & ~RPCLBRecord::partition_data_mask_))) {
70  last_lbrecord.set(last_lbrecord.getRecord() | input_it->getRecord());
71  } else {
72  unsigned int last_bcn(last_lbrecord.getBCN());
73  if (last_bcn > idx) {
74  idx = last_bcn;
75  }
76  unsigned int delay(idx - last_bcn);
77  if (ignore_eod && delay == 8) {
78  --idx;
79  --delay;
80  bx_lbrecord.back().second.setEOD(true);
81  last_lbrecord.setEOD(true);
82  }
83  if (delay < 8) {
84  last_lbrecord.setDelay(delay);
85  last_bcn = (3564 + bcn + min_bx + idx) % 3564;
86  last_lbrecord.setBCN(last_bcn);
87  last_lbrecord.setBC0(last_bcn == 0);
88  bx_lbrecord.push_back(std::pair<int, RPCLBRecord>(min_bx + idx, last_lbrecord));
89  ++idx;
90  } else {
91  bx_lbrecord.back().second.setEOD(true);
92  }
93  if (input_it != input.end()) {
94  last_lbrecord = *input_it;
95  }
96  }
97  }
98 
99  mlb_bx_lbrecord.insert(std::map<RPCLBLink, std::vector<std::pair<int, RPCLBRecord> > >::value_type(
100  mlb_lbrecords_it->first, bx_lbrecord));
101  }
102 }
static std::string const input
Definition: EdmProvDump.cc:50
std::pair< IndexType, std::pair< DigiRangeIterator, DigiRangeIterator > > value_type
std::vector< RPCDigi >::const_iterator const_iterator