CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
RPCLBLinkMapHandler Class Reference

#include <RPCLBLinkMapHandler.h>

Inheritance diagram for RPCLBLinkMapHandler:
popcon::PopConSourceHandler< RPCLBLinkMap >

Public Member Functions

void getNewObjects () override
 
std::string id () const override
 
 RPCLBLinkMapHandler (edm::ParameterSet const &config)
 
 ~RPCLBLinkMapHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< RPCLBLinkMap >
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 ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Static Public Member Functions

static RPCDetId getRPCDetId (int region, int disk_or_wheel, int layer, int sector, std::string subsector_string, std::string partition)
 

Protected Attributes

std::string connect_
 
cond::persistency::ConnectionPool connection_
 
std::string data_tag_
 
std::string id_
 
cond::Time_t since_run_
 
std::string txt_file_
 
- Protected Attributes inherited from popcon::PopConSourceHandler< RPCLBLinkMap >
Container m_iovs
 
std::vector< std::pair
< RPCLBLinkMap *, Time_t > > 
m_to_transfer
 
std::string m_userTextLog
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< RPCLBLinkMap >
typedef std::map< Time_t,
std::shared_ptr< RPCLBLinkMap > > 
Container
 
typedef std::unique_ptr
< RPCLBLinkMap
Ref
 
typedef PopConSourceHandler
< RPCLBLinkMap
self
 
typedef cond::Time_t Time_t
 
typedef RPCLBLinkMap value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< RPCLBLinkMap >
cond::persistency::SessiondbSession () const
 

Detailed Description

Definition at line 17 of file RPCLBLinkMapHandler.h.

Constructor & Destructor Documentation

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

Definition at line 90 of file RPCLBLinkMapHandler.cc.

References cond::persistency::ConnectionPool::configure(), connection_, edm::ParameterSet::getParameter(), and cond::persistency::ConnectionPool::setParameters().

91  : id_(config.getParameter<std::string>("identifier")),
92  data_tag_(config.getParameter<std::string>("dataTag")),
93  since_run_(config.getParameter<unsigned long long>("sinceRun")),
94  txt_file_(config.getUntrackedParameter<std::string>("txtFile", "")),
95  connect_(config.getParameter<std::string>("connect")) {
96  edm::LogInfo("RPCDCCLinkMapHandler") << "Configuring Input Connection";
97  connection_.setParameters(config.getParameter<edm::ParameterSet>("DBParameters"));
99 }
void setParameters(const edm::ParameterSet &connectionPset)
cond::persistency::ConnectionPool connection_
Log< level::Info, false > LogInfo
tuple config
parse the configuration file
RPCLBLinkMapHandler::~RPCLBLinkMapHandler ( )
override

Definition at line 101 of file RPCLBLinkMapHandler.cc.

101 {}

Member Function Documentation

void RPCLBLinkMapHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< RPCLBLinkMap >.

Definition at line 103 of file RPCLBLinkMapHandler.cc.

References connect_, connection_, cond::persistency::ConnectionPool::createCoralSession(), Exception, RPCLBLink::getName(), getRPCDetId(), cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< RPCLBLinkMap >::m_to_transfer, RPCLBLinkNameParser::parse(), contentValuesFiles::query, RPCLBLink::setConnector(), cond::Iov_t::since, since_run_, slope, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< RPCLBLinkMap >::tagInfo(), and txt_file_.

103  {
104  edm::LogInfo("RPCLBLinkMapHandler") << "getNewObjects";
105  cond::TagInfo_t const& tag_info = tagInfo();
106  if (since_run_ < tag_info.lastInterval.since)
107  throw cms::Exception("RPCLBLinkMapHandler") << "Refuse to create RPCLBLinkMap for run " << since_run_
108  << ", older than most recent tag" << tag_info.lastInterval.since;
109 
110  edm::LogInfo("RPCDCCLinkMapHandler") << "Opening read-only Input Session";
111  auto input_session = connection_.createCoralSession(connect_, false); // writeCapable
112  edm::LogInfo("RPCDCCLinkMapHandler") << "Started Input Transaction";
113  input_session->transaction().start(true); // readOnly
114 
115  std::unique_ptr<coral::IQuery> query(input_session->schema("CMS_RPC_CONF").newQuery());
116  query->addToTableList("BOARD");
117  query->addToTableList("CHAMBERSTRIP");
118  query->addToTableList("CHAMBERLOCATION");
119  query->addToTableList("FEBLOCATION");
120  query->addToTableList("FEBCONNECTOR");
121  coral::IQueryDefinition& subquery_min_channel(query->defineSubQuery("MIN_CHANNEL"));
122  query->addToTableList("MIN_CHANNEL");
123  coral::IQueryDefinition& subquery_max_strip(query->defineSubQuery("MAX_STRIP"));
124  query->addToTableList("MAX_STRIP");
125 
126  query->addToOutputList("BOARD.NAME", "LB_NAME");
127  query->addToOutputList("FEBCONNECTOR.LINKBOARDINPUTNUM", "CONNECTOR");
128  query->addToOutputList("CHAMBERSTRIP.CHAMBERSTRIPNUMBER", "FIRST_STRIP");
129  query->addToOutputList("CAST(DECODE(SIGN(MAX_STRIP.STRIP - CHAMBERSTRIP.CHAMBERSTRIPNUMBER), 1, 1, -1) AS INTEGER)",
130  "SLOPE");
131  query->addToOutputList("MIN_CHANNEL.CHANNELS", "CHANNELS");
132  query->addToOutputList(
133  "CAST(DECODE(CHAMBERLOCATION.BARRELORENDCAP, 'Barrel', 0, DECODE(SIGN(CHAMBERLOCATION.DISKORWHEEL), 1, 1, -1)) "
134  "AS INTEGER)",
135  "REGION");
136  query->addToOutputList("CHAMBERLOCATION.DISKORWHEEL", "DISKORWHEEL");
137  query->addToOutputList("CHAMBERLOCATION.LAYER", "LAYER");
138  query->addToOutputList("CHAMBERLOCATION.SECTOR", "SECTOR");
139  query->addToOutputList("CHAMBERLOCATION.SUBSECTOR", "SUBSECTOR");
140  query->addToOutputList("FEBLOCATION.FEBLOCALETAPARTITION", "ETAPARTITION");
141 
142  subquery_min_channel.addToTableList("CHAMBERSTRIP");
143  subquery_min_channel.addToOutputList("FC_FEBCONNECTORID");
144  subquery_min_channel.addToOutputList("MIN(CABLECHANNELNUM)", "CHANNEL");
145  subquery_min_channel.addToOutputList("CAST(SUM(POWER(2, CABLECHANNELNUM-1)) AS INTEGER)", "CHANNELS");
146  subquery_min_channel.groupBy("FC_FEBCONNECTORID");
147  coral::AttributeList subquery_min_channel_condition_data;
148  subquery_min_channel.setCondition("CABLECHANNELNUM IS NOT NULL", subquery_min_channel_condition_data);
149 
150  subquery_max_strip.addToTableList("CHAMBERSTRIP");
151  coral::IQueryDefinition& subquery_max_channel(subquery_max_strip.defineSubQuery("MAX_CHANNEL"));
152  subquery_max_strip.addToTableList("MAX_CHANNEL");
153  subquery_max_strip.addToOutputList("CHAMBERSTRIP.FC_FEBCONNECTORID", "FC_FEBCONNECTORID");
154  subquery_max_strip.addToOutputList("CHAMBERSTRIP.CHAMBERSTRIPNUMBER", "STRIP");
155  coral::AttributeList subquery_max_strip_condition_data;
156  subquery_max_strip.setCondition(
157  "CHAMBERSTRIP.FC_FEBCONNECTORID=MAX_CHANNEL.FC_FEBCONNECTORID"
158  " AND CHAMBERSTRIP.CABLECHANNELNUM=MAX_CHANNEL.CHANNEL",
159  subquery_max_strip_condition_data);
160 
161  subquery_max_channel.addToTableList("CHAMBERSTRIP");
162  subquery_max_channel.addToOutputList("FC_FEBCONNECTORID");
163  subquery_max_channel.addToOutputList("MAX(CABLECHANNELNUM)", "CHANNEL");
164  subquery_max_channel.groupBy("FC_FEBCONNECTORID");
165  coral::AttributeList subquery_max_channel_condition_data;
166  subquery_max_channel.setCondition("CABLECHANNELNUM IS NOT NULL", subquery_max_channel_condition_data);
167 
168  coral::AttributeList query_condition_data;
169  query->setCondition(
170  "CHAMBERSTRIP.FC_FEBCONNECTORID=MIN_CHANNEL.FC_FEBCONNECTORID"
171  " AND CHAMBERSTRIP.CABLECHANNELNUM=MIN_CHANNEL.CHANNEL"
172  " AND CHAMBERSTRIP.FC_FEBCONNECTORID=MAX_STRIP.FC_FEBCONNECTORID"
173  " AND CHAMBERSTRIP.FC_FEBCONNECTORID=FEBCONNECTOR.FEBCONNECTORID"
174  " AND FEBCONNECTOR.FL_FEBLOCATIONID=FEBLOCATION.FEBLOCATIONID"
175  " AND BOARD.BOARDID=FEBLOCATION.LB_LINKBOARDID"
176  " AND CHAMBERLOCATION.CHAMBERLOCATIONID=FEBLOCATION.CL_CHAMBERLOCATIONID",
177  query_condition_data);
178 
179  std::string lb_name("");
180  int first_strip(0), slope(1);
181  std::uint16_t channels(0x0);
182 
183  std::unique_ptr<RPCLBLinkMap> lb_link_map_object(new RPCLBLinkMap());
184  RPCLBLinkMap::map_type& lb_link_map = lb_link_map_object->getMap();
185  RPCLBLink lb_link;
186  RPCDetId det_id;
187  std::string subsector;
188 
189  edm::LogInfo("RPCLBLinkMapHandler") << "Execute query";
190  coral::ICursor& cursor(query->execute());
191  while (cursor.next()) {
192  coral::AttributeList const& row(cursor.currentRow());
193 
194  // RPCLBLink
195  lb_name = row["LB_NAME"].data<std::string>();
196  RPCLBLinkNameParser::parse(lb_name, lb_link);
197  if (lb_name != lb_link.getName())
198  edm::LogWarning("RPCLBLinkMapHandler") << "Mismatch LinkBoard Name: " << lb_name << " vs " << lb_link;
199  lb_link.setConnector(row["CONNECTOR"].data<short>() - 1); // 1-6 to 0-5
200 
201  // RPCDetId
202  if (row["SUBSECTOR"].isNull())
203  subsector = "";
204  else
205  subsector = row["SUBSECTOR"].data<std::string>();
206  det_id = getRPCDetId(row["REGION"].data<long long>(),
207  row["DISKORWHEEL"].data<short>(),
208  row["LAYER"].data<short>(),
209  row["SECTOR"].data<short>(),
210  subsector,
211  row["ETAPARTITION"].data<std::string>());
212 
213  // RPCFebConnector
214  first_strip = row["FIRST_STRIP"].data<int>();
215  slope = row["SLOPE"].data<long long>();
216  channels = (std::uint16_t)(row["CHANNELS"].data<long long>());
217 
218  lb_link_map.insert(
219  std::pair<RPCLBLink, RPCFebConnector>(lb_link, RPCFebConnector(det_id, first_strip, slope, channels)));
220  }
221  cursor.close();
222 
223  input_session->transaction().commit();
224 
225  if (!txt_file_.empty()) {
226  edm::LogInfo("RPCLBLinkMapHandler") << "Fill txtFile";
227  std::ofstream ofstream(txt_file_);
228  for (auto const& link_connector : lb_link_map) {
229  ofstream << link_connector.first << ": " << link_connector.second << std::endl;
230  }
231  }
232 
233  edm::LogInfo("RPCLBLinkMapHandler") << "Add to transfer list";
234  m_to_transfer.push_back(std::make_pair(lb_link_map_object.release(), since_run_));
235 }
Iov_t lastInterval
Definition: Types.h:73
static const double slope[3]
Time_t since
Definition: Types.h:53
static RPCDetId getRPCDetId(int region, int disk_or_wheel, int layer, int sector, std::string subsector_string, std::string partition)
cond::persistency::ConnectionPool connection_
std::vector< std::pair< RPCLBLinkMap *, Time_t > > m_to_transfer
Log< level::Info, false > LogInfo
std::map< RPCLBLink, RPCFebConnector > map_type
Definition: RPCLBLinkMap.h:13
static void parse(std::string const &name, RPCLBLink &lb_link)
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
cond::TagInfo_t const & tagInfo() const
RPCDetId RPCLBLinkMapHandler::getRPCDetId ( int  region,
int  disk_or_wheel,
int  layer,
int  sector,
std::string  subsector_string,
std::string  partition 
)
static

Definition at line 26 of file RPCLBLinkMapHandler.cc.

References funct::abs(), Exception, phase1PixelTopology::layer, relativeConstraints::ring, RPCDetId, and relativeConstraints::station.

Referenced by getNewObjects().

27  {
28  int station(0), ring(0), subsector(0), roll(0);
29  // region well-defined
30  if (!region) { // barrel
31  switch (layer) {
32  case 1:
33  case 2:
34  station = 1;
35  break;
36  case 3:
37  case 4:
38  station = 2;
39  layer -= 2;
40  break;
41  case 5:
42  station = 3;
43  layer = 1;
44  break;
45  case 6:
46  station = 4;
47  layer = 1;
48  break;
49  }
50  ring = disk_or_wheel;
51  // sector well-defined
52  subsector = 1;
53  if (subsector_string == "+" && (station == 3 || (station == 4 && (sector != 4 && sector != 9 && sector != 11))))
54  subsector = 2;
55  if (station == 4 && sector == 4) {
56  if (subsector_string == "-")
57  subsector = 2;
58  else if (subsector_string == "+")
59  subsector = 3;
60  else if (subsector_string == "++")
61  subsector = 4;
62  }
63  } else { // endcap
64  station = std::abs(disk_or_wheel);
65  ring = layer;
66  layer = 1;
67  if (ring > 1 || station == 1) {
68  subsector = (sector - 1) % 6 + 1;
69  sector = (sector - 1) / 6 + 1;
70  } else {
71  subsector = (sector - 1) % 3 + 1;
72  sector = (sector - 1) / 3 + 1;
73  }
74  }
75  // roll
76  if (partition == "Backward" || partition == "A")
77  roll = 1;
78  else if (partition == "Central" || partition == "B")
79  roll = 2;
80  else if (partition == "Forward" || partition == "C")
81  roll = 3;
82  else if (partition == "D")
83  roll = 4;
84  else
85  throw cms::Exception("RPCLBLinkMapHandler") << "Unexpected partition name " << partition;
86 
87  return RPCDetId(region, ring, station, sector, layer, subsector, roll);
88 }
constexpr std::array< uint8_t, layerIndexSize > layer
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string RPCLBLinkMapHandler::id ( ) const
overridevirtual

Implements popcon::PopConSourceHandler< RPCLBLinkMap >.

Definition at line 237 of file RPCLBLinkMapHandler.cc.

References id_.

237 { return id_; }

Member Data Documentation

std::string RPCLBLinkMapHandler::connect_
protected

Definition at line 36 of file RPCLBLinkMapHandler.h.

Referenced by getNewObjects().

cond::persistency::ConnectionPool RPCLBLinkMapHandler::connection_
protected

Definition at line 37 of file RPCLBLinkMapHandler.h.

Referenced by getNewObjects(), and RPCLBLinkMapHandler().

std::string RPCLBLinkMapHandler::data_tag_
protected

Definition at line 31 of file RPCLBLinkMapHandler.h.

std::string RPCLBLinkMapHandler::id_
protected

Definition at line 30 of file RPCLBLinkMapHandler.h.

Referenced by id().

cond::Time_t RPCLBLinkMapHandler::since_run_
protected

Definition at line 32 of file RPCLBLinkMapHandler.h.

Referenced by getNewObjects().

std::string RPCLBLinkMapHandler::txt_file_
protected

Definition at line 34 of file RPCLBLinkMapHandler.h.

Referenced by getNewObjects().