CMS 3D CMS Logo

RPCTwinMuxLinkMapHandler.cc
Go to the documentation of this file.
2 
3 #include <fstream>
4 #include <sstream>
5 
10 
12 
14  : id_(_config.getParameter<std::string>("identifier"))
15  , data_tag_(_config.getParameter<std::string>("dataTag"))
16  , since_run_(_config.getParameter<unsigned long long>("sinceRun"))
17  , input_file_(_config.getParameter<edm::FileInPath>("inputFile").fullPath())
18  , wheel_fed_(_config.getParameter<std::vector<int> >("wheelFED"))
19  , wheel_sector_amc_(std::vector<std::vector<int> >(5, std::vector<int>(12, 0)))
20  , txt_file_(_config.getUntrackedParameter<std::string>("txtFile", ""))
21 {
22  std::vector<long long> _wheel_sector_amc_packed(_config.getParameter<std::vector<long long> >("wheelSectorAMC"));
23  std::vector<std::vector<int> >::iterator _sector_amc = wheel_sector_amc_.begin();
24  for (std::vector<long long>::const_iterator _sector_amc_packed = _wheel_sector_amc_packed.begin()
25  ; _sector_amc_packed != _wheel_sector_amc_packed.end() ; ++_sector_amc_packed, ++_sector_amc)
26  for (unsigned int _sector = 0 ; _sector < 12 ; ++_sector)
27  _sector_amc->at(_sector) = ((*_sector_amc_packed) >> (11*4-4*_sector)) & 0xf;
28 }
29 
31 {}
32 
34 {
35  edm::LogInfo("RPCTwinMuxLinkMapHandler") << "getNewObjects";
36  cond::TagInfo const & _tag_info = tagInfo();
37  if (since_run_ < _tag_info.lastInterval.first)
38  throw cms::Exception("RPCTwinMuxLinkMapHandler") << "Refuse to create RPCTwinMuxLinkMap for run " << since_run_
39  << ", older than most recent tag" << _tag_info.lastInterval.first;
40 
41  std::string _tm_name, _link_name;
42  int _wheel, _fed, _sector, _amc_number, _tm_input;
43 
44  RPCAMCLinkMap * _twinmux_link_map_object = new RPCAMCLinkMap();
45  RPCAMCLinkMap::map_type & _twinmux_link_map
46  = _twinmux_link_map_object->getMap();
47  RPCLBLink _lb_link;
48 
49  std::string _line;
50  std::istringstream _conv;
51 
52  std::ifstream _input_file(input_file_);
53 
54  _input_file >> _tm_name >> _tm_name >> _tm_input >> _link_name;
55  std::getline(_input_file, _line);
56 
57  while (_input_file) {
58  // parse AMC Slot Name - no checking: failure is an error
59  std::string::size_type _pos(2), _next(2);
60  _next = _tm_name.find_first_not_of("+-0123456789", _pos);
61  _conv.clear();
62  _conv.str(_tm_name.substr(_pos, _next - _pos));
63  _conv >> _wheel;
64 
65  _pos = _next + 2;
66  _next = _tm_name.find_first_not_of("+-0123456789", _pos);
67  if (_next == std::string::npos)
68  _next = _tm_name.size();
69  _conv.clear();
70  _conv.str(_tm_name.substr(_pos, _next - _pos));
71  _conv >> _sector;
72 
73  _fed = wheel_fed_.at(_wheel + 2);
74  _amc_number = wheel_sector_amc_.at(_wheel + 2).at(_sector - 1);
75 
76  RPCLBLinkNameParser::parse(_link_name, _lb_link);
77 
78  _twinmux_link_map.insert(std::pair<RPCAMCLink, RPCLBLink>(RPCAMCLink(_fed, _amc_number, _tm_input)
79  , _lb_link));
80 
81  _input_file >> _tm_name >> _tm_name >> _tm_input >> _link_name;
82  std::getline(_input_file, _line);
83  }
84  _input_file.close();
85 
86  if (!txt_file_.empty()) {
87  edm::LogInfo("RPCTwinMuxLinkMapHandler") << "Fill txtFile";
88  std::ofstream _ofstream(txt_file_);
89  for (RPCAMCLinkMap::map_type::const_iterator _link = _twinmux_link_map.begin()
90  ; _link != _twinmux_link_map.end() ; ++_link) {
91  _ofstream << _link->first << ": " << _link->second << std::endl;
92  }
93  }
94 
95  edm::LogInfo("RPCTwinMuxLinkMapHandler") << "Add to transfer list";
96  m_to_transfer.push_back(std::make_pair(_twinmux_link_map_object, since_run_));
97 }
98 
100 {
101  return id_;
102 }
std::vector< std::vector< int > > wheel_sector_amc_
T getParameter(std::string const &) const
uint16_t size_type
cond::ValidityInterval lastInterval
Definition: Types.h:74
map_type & getMap()
Definition: RPCAMCLinkMap.h:28
RPCTwinMuxLinkMapHandler(edm::ParameterSet const &_config)
std::map< RPCAMCLink, RPCLBLink > map_type
Definition: RPCAMCLinkMap.h:14
static void parse(std::string const &_name, RPCLBLink &_lb_link)
HLT enums.