CMS 3D CMS Logo

RPCAMCLinkMapHandler.cc
Go to the documentation of this file.
2 
3 #include <fstream>
4 #include <memory>
5 #include <sstream>
6 
11 
13 
15  : id_(config.getParameter<std::string>("identifier")),
16  data_tag_(config.getParameter<std::string>("dataTag")),
17  since_run_(config.getParameter<unsigned long long>("sinceRun")),
18  input_file_(config.getParameter<edm::FileInPath>("inputFile").fullPath()),
19  wheel_not_side_(config.getParameter<bool>("wheelNotSide")),
20  wos_fed_(config.getParameter<std::vector<int> >("wheelOrSideFED")),
21  n_sectors_(config.getParameter<unsigned int>("nSectors")),
22  wos_sector_amc_(wos_fed_.size(), std::vector<int>(n_sectors_, 0)),
23  txt_file_(config.getUntrackedParameter<std::string>("txtFile", "")) {
24  std::vector<long long> wos_sector_amc_packed(config.getParameter<std::vector<long long> >("wheelOrSideSectorAMC"));
25 
26  if (wos_fed_.size() != wos_sector_amc_packed.size()) {
27  throw cms::Exception("RPCAMCLinkMapHandler") << "Refuse to handle inconsistent input: "
28  << "sizes of wheelOrSideFED and wheelOrSideSectorAMC don't match";
29  }
30 
31  std::vector<std::vector<int> >::iterator sector_amc = wos_sector_amc_.begin();
32  for (std::vector<long long>::const_iterator sector_amc_packed = wos_sector_amc_packed.begin();
33  sector_amc_packed != wos_sector_amc_packed.end();
34  ++sector_amc_packed, ++sector_amc) {
35  for (unsigned int sector = 0; sector < n_sectors_; ++sector) {
36  sector_amc->at(sector) = ((*sector_amc_packed) >> (4 * (n_sectors_ - sector - 1))) & 0xf;
37  }
38  }
39 }
40 
42 
44  edm::LogInfo("RPCAMCLinkMapHandler") << "getNewObjects";
45  cond::TagInfo_t const& tag_info = tagInfo();
46  if (since_run_ < tag_info.lastInterval.since) {
47  throw cms::Exception("RPCAMCLinkMapHandler") << "Refuse to create RPCAMCLinkMap for run " << since_run_
48  << ", older than most recent tag" << tag_info.lastInterval.since;
49  }
50 
51  std::string amc_name, link_name;
52  unsigned int wos, sector, amc_number, amc_input;
53 
54  std::unique_ptr<RPCAMCLinkMap> amc_link_map_object(new RPCAMCLinkMap());
55  RPCAMCLinkMap::map_type& amc_link_map = amc_link_map_object->getMap();
56  RPCLBLink lb_link;
57 
59  std::istringstream conv;
60 
61  std::ifstream input_file(input_file_);
62 
63  input_file >> amc_name >> amc_input >> link_name;
64  std::getline(input_file, line);
65 
66  while (input_file) {
67  // parse AMC Slot Name - no checking: failure is an error
68  if (wheel_not_side_) { // wheel
69  std::string::size_type pos(2), next(2); // skip YB
70  int wheel;
71  next = amc_name.find_first_not_of("+-0123456789", pos);
72  conv.clear();
73  conv.str(amc_name.substr(pos, next - pos));
74  conv >> wheel;
75  wos = wheel + 2;
76 
77  pos = next + 2;
78  next = amc_name.find_first_not_of("+-0123456789", pos);
79  if (next == std::string::npos)
80  next = amc_name.size();
81  conv.clear();
82  conv.str(amc_name.substr(pos, next - pos));
83  conv >> sector;
84  } else { // side
85  wos = (amc_name.at(4) == 'n' ? 0 : 1); // skip CPPF or OMTF
86  conv.clear();
87  conv.str(amc_name.substr(5, 1));
88  conv >> sector;
89  }
90 
91  if (sector > n_sectors_) {
92  throw cms::Exception("RPCAMCLinkMapHandler")
93  << "Found sector greater than the number of sectors: " << sector << " > " << n_sectors_;
94  }
95 
96  if (wos >= wos_fed_.size()) {
97  throw cms::Exception("RPCAMCLinkMapHandler")
98  << "Found " << (wheel_not_side_ ? "wheel" : "side") << " outside range: " << wos << " >= " << wos_fed_.size();
99  }
100 
101  amc_number = wos_sector_amc_.at(wos).at(sector - 1);
102 
103  RPCLBLinkNameParser::parse(link_name, lb_link);
104 
105  amc_link_map.insert(std::pair<RPCAMCLink, RPCLBLink>(RPCAMCLink(wos_fed_.at(wos), amc_number, amc_input), lb_link));
106 
107  input_file >> amc_name >> amc_input >> link_name;
108  std::getline(input_file, line);
109  }
110  input_file.close();
111 
112  if (!txt_file_.empty()) {
113  edm::LogInfo("RPCAMCLinkMapHandler") << "Fill txtFile";
114  std::ofstream ofstream(txt_file_);
115  for (auto const link : amc_link_map) {
116  ofstream << link.first << ": " << link.second << std::endl;
117  }
118  }
119 
120  edm::LogInfo("RPCAMCLinkMapHandler") << "Add to transfer list";
121  m_to_transfer.push_back(std::make_pair(amc_link_map_object.release(), since_run_));
122 }
123 
electrons_cff.bool
bool
Definition: electrons_cff.py:366
RPCLBLinkNameParser::parse
static void parse(std::string const &name, RPCLBLink &lb_link)
Definition: RPCLBLinkNameParser.cc:7
popcon::PopConSourceHandler< RPCAMCLinkMap >::m_to_transfer
OldContainer m_to_transfer
Definition: PopConSourceHandler.h:162
MessageLogger.h
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
edm
HLT enums.
Definition: AlignableModifier.h:19
RPCAMCLinkMapHandler::input_file_
std::string input_file_
Definition: RPCAMCLinkMapHandler.h:30
pos
Definition: PixelAliasList.h:18
RPCAMCLinkMapHandler::RPCAMCLinkMapHandler
RPCAMCLinkMapHandler(edm::ParameterSet const &config)
Definition: RPCAMCLinkMapHandler.cc:14
RPCAMCLinkMap
Definition: RPCAMCLinkMap.h:11
RPCAMCLinkMapHandler::txt_file_
std::string txt_file_
Definition: RPCAMCLinkMapHandler.h:36
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
RPCAMCLinkMapHandler::wos_fed_
std::vector< int > wos_fed_
Definition: RPCAMCLinkMapHandler.h:32
RPCAMCLinkMapHandler::wos_sector_amc_
std::vector< std::vector< int > > wos_sector_amc_
Definition: RPCAMCLinkMapHandler.h:34
config
Definition: config.py:1
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
RPCAMCLinkMapHandler::n_sectors_
unsigned int n_sectors_
Definition: RPCAMCLinkMapHandler.h:33
RPCAMCLinkMapHandler::wheel_not_side_
bool wheel_not_side_
Definition: RPCAMCLinkMapHandler.h:31
RPCAMCLinkMapHandler::~RPCAMCLinkMapHandler
~RPCAMCLinkMapHandler() override
Definition: RPCAMCLinkMapHandler.cc:41
FileInPath.h
edm::ParameterSet
Definition: ParameterSet.h:47
popcon::PopConSourceHandler< RPCAMCLinkMap >::tagInfo
cond::TagInfo_t const & tagInfo() const
Definition: PopConSourceHandler.h:78
RPCLBLinkNameParser.h
cond::Iov_t::since
Time_t since
Definition: Types.h:53
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
RPCAMCLinkMapHandler::id
std::string id() const override
Definition: RPCAMCLinkMapHandler.cc:124
RPCAMCLinkMapHandler.h
RPCAMCLinkMapHandler::id_
std::string id_
Definition: RPCAMCLinkMapHandler.h:26
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::TagInfo_t::lastInterval
Iov_t lastInterval
Definition: Types.h:73
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:245
RPCAMCLinkMapHandler::getNewObjects
void getNewObjects() override
Definition: RPCAMCLinkMapHandler.cc:43
Exception.h
RPCAMCLinkMapHandler::since_run_
cond::Time_t since_run_
Definition: RPCAMCLinkMapHandler.h:28
ParameterSet.h
cond::TagInfo_t
Definition: Types.h:69
mps_splice.line
line
Definition: mps_splice.py:76
RPCAMCLinkMap::map_type
std::map< RPCAMCLink, RPCLBLink > map_type
Definition: RPCAMCLinkMap.h:13
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
conv
EPOS::IO_EPOS conv
Definition: ReggeGribovPartonMCHadronizer.cc:42