14 #include "RelationalAccess/ICursor.h" 15 #include "RelationalAccess/IQuery.h" 16 #include "RelationalAccess/IQueryDefinition.h" 17 #include "RelationalAccess/ISchema.h" 18 #include "RelationalAccess/ISessionProxy.h" 19 #include "RelationalAccess/ITransaction.h" 21 #include "CoralBase/Attribute.h" 22 #include "CoralBase/AttributeList.h" 56 if (subsector_string ==
"-")
58 else if (subsector_string ==
"+")
60 else if (subsector_string ==
"++")
68 subsector = (
sector - 1) % 6 + 1;
71 subsector = (
sector - 1) % 3 + 1;
93 since_run_(
config.getParameter<unsigned long long>(
"sinceRun")),
96 edm::LogInfo(
"RPCDCCLinkMapHandler") <<
"Configuring Input Connection";
110 edm::LogInfo(
"RPCDCCLinkMapHandler") <<
"Opening read-only Input Session";
112 edm::LogInfo(
"RPCDCCLinkMapHandler") <<
"Started Input Transaction";
113 input_session->transaction().start(
true);
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");
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)",
131 query->addToOutputList(
"MIN_CHANNEL.CHANNELS",
"CHANNELS");
132 query->addToOutputList(
133 "CAST(DECODE(CHAMBERLOCATION.BARRELORENDCAP, 'Barrel', 0, DECODE(SIGN(CHAMBERLOCATION.DISKORWHEEL), 1, 1, -1)) " 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");
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);
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);
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);
168 coral::AttributeList query_condition_data;
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);
180 int first_strip(0),
slope(1);
183 std::unique_ptr<RPCLBLinkMap> lb_link_map_object(
new RPCLBLinkMap());
190 coral::ICursor& cursor(
query->execute());
191 while (cursor.next()) {
192 coral::AttributeList
const& row(cursor.currentRow());
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);
202 if (row[
"SUBSECTOR"].isNull())
206 det_id =
getRPCDetId(row[
"REGION"].data<long long>(),
207 row[
"DISKORWHEEL"].data<short>(),
208 row[
"LAYER"].data<short>(),
209 row[
"SECTOR"].data<short>(),
211 row[
"ETAPARTITION"].data<std::string>());
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>());
223 input_session->transaction().commit();
228 for (
auto const& link_connector : lb_link_map) {
229 ofstream << link_connector.first <<
": " << link_connector.second << std::endl;
233 edm::LogInfo(
"RPCLBLinkMapHandler") <<
"Add to transfer list";
void getNewObjects() override
static const double slope[3]
RPCLBLink & setConnector(int connector=wildcard_)
static RPCDetId getRPCDetId(int region, int disk_or_wheel, int layer, int sector, std::string subsector_string, std::string partition)
void setParameters(const edm::ParameterSet &connectionPset)
std::string getName() const
cond::TagInfo_t const & tagInfo() const
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
cond::persistency::ConnectionPool connection_
std::vector< std::pair< RPCLBLinkMap *, Time_t > > m_to_transfer
Abs< T >::type abs(const T &t)
Log< level::Info, false > LogInfo
RPCLBLinkMapHandler(edm::ParameterSet const &config)
std::string id() const override
std::map< RPCLBLink, RPCFebConnector > map_type
~RPCLBLinkMapHandler() override
static void parse(std::string const &name, RPCLBLink &lb_link)
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)