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

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 Exception, funct::false, RPCLBLink::getConnector(), RPCLBLink::getLinkBoard(), RPCInverseLBLinkMap::getMap(), training_settings::idx, input, genParticles_cff::map, RPCLBLink::setConnector(), RPCLBLink::setLinkBoard(), and jetUpdater_cfi::sort.

Referenced by RPCTwinMuxPacker::getRPCTwinMuxRecords().

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