CMS 3D CMS Logo

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

#include <RPCAMCLinkMapHandler.h>

Inheritance diagram for RPCAMCLinkMapHandler:
popcon::PopConSourceHandler< RPCAMCLinkMap >

Public Member Functions

void getNewObjects () override
 
std::string id () const override
 
 RPCAMCLinkMapHandler (edm::ParameterSet const &config)
 
 ~RPCAMCLinkMapHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< RPCAMCLinkMap >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const *, std::string const > operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Protected Attributes

std::string data_tag_
 
std::string id_
 
std::string input_file_
 
unsigned int n_sectors_
 
cond::Time_t since_run_
 
std::string txt_file_
 
bool wheel_not_side_
 
std::vector< int > wos_fed_
 
std::vector< std::vector< int > > wos_sector_amc_
 
- Protected Attributes inherited from popcon::PopConSourceHandler< RPCAMCLinkMap >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< RPCAMCLinkMap >
typedef std::vector< Triplet > Container
 
typedef std::vector< std::pair< RPCAMCLinkMap *, cond::Time_t > > OldContainer
 
typedef PopConSourceHandler< RPCAMCLinkMapself
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef RPCAMCLinkMap value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< RPCAMCLinkMap >
int add (value_type *payload, Summary *summary, Time_t time)
 
cond::persistency::SessiondbSession () const
 

Detailed Description

Definition at line 17 of file RPCAMCLinkMapHandler.h.

Constructor & Destructor Documentation

RPCAMCLinkMapHandler::RPCAMCLinkMapHandler ( edm::ParameterSet const &  config)

Definition at line 14 of file RPCAMCLinkMapHandler.cc.

References Exception, edm::ParameterSet::getParameter(), n_sectors_, wos_fed_, and wos_sector_amc_.

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 {
25  std::vector<long long> wos_sector_amc_packed(config.getParameter<std::vector<long long> >("wheelOrSideSectorAMC"));
26 
27  if (wos_fed_.size() != wos_sector_amc_packed.size()) {
28  throw cms::Exception("RPCAMCLinkMapHandler") << "Refuse to handle inconsistent input: "
29  << "sizes of wheelOrSideFED and wheelOrSideSectorAMC don't match";
30  }
31 
32  std::vector<std::vector<int> >::iterator sector_amc = wos_sector_amc_.begin();
33  for (std::vector<long long>::const_iterator sector_amc_packed = wos_sector_amc_packed.begin()
34  ; sector_amc_packed != wos_sector_amc_packed.end() ; ++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 }
Definition: config.py:1
std::vector< std::vector< int > > wos_sector_amc_
std::string fullPath() const
Definition: FileInPath.cc:163
std::vector< int > wos_fed_
RPCAMCLinkMapHandler::~RPCAMCLinkMapHandler ( )
override

Definition at line 41 of file RPCAMCLinkMapHandler.cc.

42 {}

Member Function Documentation

void RPCAMCLinkMapHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< RPCAMCLinkMap >.

Definition at line 44 of file RPCAMCLinkMapHandler.cc.

References conv, Exception, input_file_, cond::TagInfo_t::lastInterval, mps_splice::line, popcon::PopConSourceHandler< RPCAMCLinkMap >::m_to_transfer, n_sectors_, GetRecoTauVFromDQM_MC_cff::next, RPCLBLinkNameParser::parse(), since_run_, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< RPCAMCLinkMap >::tagInfo(), txt_file_, makeMuonMisalignmentScenario::wheel, wheel_not_side_, wos_fed_, and wos_sector_amc_.

45 {
46  edm::LogInfo("RPCAMCLinkMapHandler") << "getNewObjects";
47  cond::TagInfo const & tag_info = tagInfo();
48  if (since_run_ < tag_info.lastInterval.first) {
49  throw cms::Exception("RPCAMCLinkMapHandler") << "Refuse to create RPCAMCLinkMap for run " << since_run_
50  << ", older than most recent tag" << tag_info.lastInterval.first;
51  }
52 
53  std::string amc_name, link_name;
54  unsigned int wos, sector, amc_number, amc_input;
55 
56  std::unique_ptr<RPCAMCLinkMap> amc_link_map_object(new RPCAMCLinkMap());
57  RPCAMCLinkMap::map_type & amc_link_map
58  = amc_link_map_object->getMap();
59  RPCLBLink lb_link;
60 
62  std::istringstream conv;
63 
64  std::ifstream input_file(input_file_);
65 
66  input_file >> amc_name >> amc_input >> link_name;
67  std::getline(input_file, line);
68 
69  while (input_file) {
70  // parse AMC Slot Name - no checking: failure is an error
71  if (wheel_not_side_) { // wheel
72  std::string::size_type pos(2), next(2); // skip YB
73  int wheel;
74  next = amc_name.find_first_not_of("+-0123456789", pos);
75  conv.clear();
76  conv.str(amc_name.substr(pos, next - pos));
77  conv >> wheel;
78  wos = wheel + 2;
79 
80  pos = next + 2;
81  next = amc_name.find_first_not_of("+-0123456789", pos);
82  if (next == std::string::npos)
83  next = amc_name.size();
84  conv.clear();
85  conv.str(amc_name.substr(pos, next - pos));
86  conv >> sector;
87  } else { // side
88  wos = (amc_name.at(4) == 'n' ? 0 : 1); // skip CPPF or OMTF
89  conv.clear();
90  conv.str(amc_name.substr(5, 1));
91  conv >> sector;
92  }
93 
94  if (sector > n_sectors_) {
95  throw cms::Exception("RPCAMCLinkMapHandler") << "Found sector greater than the number of sectors: "
96  << sector << " > " << n_sectors_;
97  }
98 
99  if (wos >= wos_fed_.size()) {
100  throw cms::Exception("RPCAMCLinkMapHandler") << "Found " << (wheel_not_side_ ? "wheel" : "side") << " outside range: "
101  << wos << " >= " << wos_fed_.size();
102  }
103 
104  amc_number = wos_sector_amc_.at(wos).at(sector - 1);
105 
106  RPCLBLinkNameParser::parse(link_name, lb_link);
107 
108  amc_link_map.insert(std::pair<RPCAMCLink, RPCLBLink>(RPCAMCLink(wos_fed_.at(wos), amc_number, amc_input)
109  , lb_link));
110 
111  input_file >> amc_name >> amc_input >> link_name;
112  std::getline(input_file, line);
113  }
114  input_file.close();
115 
116  if (!txt_file_.empty()) {
117  edm::LogInfo("RPCAMCLinkMapHandler") << "Fill txtFile";
118  std::ofstream ofstream(txt_file_);
119  for (auto const link : amc_link_map) {
120  ofstream << link.first << ": " << link.second << std::endl;
121  }
122  }
123 
124  edm::LogInfo("RPCAMCLinkMapHandler") << "Add to transfer list";
125  m_to_transfer.push_back(std::make_pair(amc_link_map_object.release(), since_run_));
126 }
static HepMC::IO_HEPEVT conv
uint16_t size_type
cond::ValidityInterval lastInterval
Definition: Types.h:76
std::map< RPCAMCLink, RPCLBLink > map_type
Definition: RPCAMCLinkMap.h:14
std::vector< std::vector< int > > wos_sector_amc_
static void parse(std::string const &name, RPCLBLink &lb_link)
std::vector< int > wos_fed_
std::string RPCAMCLinkMapHandler::id ( ) const
overridevirtual

Implements popcon::PopConSourceHandler< RPCAMCLinkMap >.

Definition at line 128 of file RPCAMCLinkMapHandler.cc.

References id_.

129 {
130  return id_;
131 }

Member Data Documentation

std::string RPCAMCLinkMapHandler::data_tag_
protected

Definition at line 29 of file RPCAMCLinkMapHandler.h.

std::string RPCAMCLinkMapHandler::id_
protected

Definition at line 28 of file RPCAMCLinkMapHandler.h.

Referenced by id().

std::string RPCAMCLinkMapHandler::input_file_
protected

Definition at line 32 of file RPCAMCLinkMapHandler.h.

Referenced by getNewObjects().

unsigned int RPCAMCLinkMapHandler::n_sectors_
protected

Definition at line 35 of file RPCAMCLinkMapHandler.h.

Referenced by getNewObjects(), and RPCAMCLinkMapHandler().

cond::Time_t RPCAMCLinkMapHandler::since_run_
protected

Definition at line 30 of file RPCAMCLinkMapHandler.h.

Referenced by getNewObjects().

std::string RPCAMCLinkMapHandler::txt_file_
protected

Definition at line 38 of file RPCAMCLinkMapHandler.h.

Referenced by getNewObjects().

bool RPCAMCLinkMapHandler::wheel_not_side_
protected

Definition at line 33 of file RPCAMCLinkMapHandler.h.

Referenced by getNewObjects().

std::vector<int> RPCAMCLinkMapHandler::wos_fed_
protected

Definition at line 34 of file RPCAMCLinkMapHandler.h.

Referenced by getNewObjects(), and RPCAMCLinkMapHandler().

std::vector<std::vector<int> > RPCAMCLinkMapHandler::wos_sector_amc_
protected

Definition at line 36 of file RPCAMCLinkMapHandler.h.

Referenced by getNewObjects(), and RPCAMCLinkMapHandler().