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" 36 case 4:
station = 2; layer -= 2;
break;
37 case 5:
station = 3; layer = 1;
break;
38 case 6:
station = 4; layer = 1;
break;
43 if (subsector_string ==
"+" 45 || (
station==4 && (sector != 4 && sector != 9 && sector != 11)))
48 if (
station == 4 && sector == 4) {
49 if (subsector_string ==
"-")
51 else if (subsector_string ==
"+")
53 else if (subsector_string ==
"++")
61 subsector = (sector - 1) % 6 + 1;
62 sector = (sector - 1) / 6 + 1;
64 subsector = (sector - 1) % 3 + 1;
65 sector = (sector - 1) / 3 + 1;
69 if (partition ==
"Backward" || partition ==
"A")
71 else if (partition ==
"Central" || partition ==
"B")
73 else if (partition ==
"Forward" || partition ==
"C")
75 else if (partition ==
"D")
78 throw cms::Exception(
"RPCLBLinkMapHandler") <<
"Unexpected partition name " << partition;
86 ,
since_run_(config.getParameter<unsigned long long>(
"sinceRun"))
90 edm::LogInfo(
"RPCDCCLinkMapHandler") <<
"Configuring Input Connection";
104 <<
", older than most recent tag" << tag_info.
lastInterval.first;
106 edm::LogInfo(
"RPCDCCLinkMapHandler") <<
"Opening read-only Input Session";
108 edm::LogInfo(
"RPCDCCLinkMapHandler") <<
"Started Input Transaction";
109 input_session->transaction().start(
true);
111 std::auto_ptr<coral::IQuery>
query(input_session->schema(
"CMS_RPC_CONF").newQuery());
112 query->addToTableList(
"BOARD");
113 query->addToTableList(
"CHAMBERSTRIP");
114 query->addToTableList(
"CHAMBERLOCATION");
115 query->addToTableList(
"FEBLOCATION");
116 query->addToTableList(
"FEBCONNECTOR");
117 coral::IQueryDefinition & subquery_min_channel(
query->defineSubQuery(
"MIN_CHANNEL"));
118 query->addToTableList(
"MIN_CHANNEL");
119 coral::IQueryDefinition & subquery_max_strip(
query->defineSubQuery(
"MAX_STRIP"));
120 query->addToTableList(
"MAX_STRIP");
122 query->addToOutputList(
"BOARD.NAME",
"LB_NAME");
123 query->addToOutputList(
"FEBCONNECTOR.LINKBOARDINPUTNUM",
"CONNECTOR");
124 query->addToOutputList(
"CHAMBERSTRIP.CHAMBERSTRIPNUMBER",
"FIRST_STRIP");
125 query->addToOutputList(
"CAST(DECODE(SIGN(MAX_STRIP.STRIP - CHAMBERSTRIP.CHAMBERSTRIPNUMBER), 1, 1, -1) AS INTEGER)",
"SLOPE");
126 query->addToOutputList(
"MIN_CHANNEL.CHANNELS",
"CHANNELS");
127 query->addToOutputList(
"CAST(DECODE(CHAMBERLOCATION.BARRELORENDCAP, 'Barrel', 0, DECODE(SIGN(CHAMBERLOCATION.DISKORWHEEL), 1, 1, -1)) AS INTEGER)",
"REGION");
128 query->addToOutputList(
"CHAMBERLOCATION.DISKORWHEEL",
"DISKORWHEEL");
129 query->addToOutputList(
"CHAMBERLOCATION.LAYER",
"LAYER");
130 query->addToOutputList(
"CHAMBERLOCATION.SECTOR",
"SECTOR");
131 query->addToOutputList(
"CHAMBERLOCATION.SUBSECTOR",
"SUBSECTOR");
132 query->addToOutputList(
"FEBLOCATION.FEBLOCALETAPARTITION",
"ETAPARTITION");
134 subquery_min_channel.addToTableList(
"CHAMBERSTRIP");
135 subquery_min_channel.addToOutputList(
"FC_FEBCONNECTORID");
136 subquery_min_channel.addToOutputList(
"MIN(CABLECHANNELNUM)",
"CHANNEL");
137 subquery_min_channel.addToOutputList(
"CAST(SUM(POWER(2, CABLECHANNELNUM-1)) AS INTEGER)",
"CHANNELS");
138 subquery_min_channel.groupBy(
"FC_FEBCONNECTORID");
139 coral::AttributeList subquery_min_channel_condition_data;
140 subquery_min_channel.setCondition(
"CABLECHANNELNUM IS NOT NULL" 141 , subquery_min_channel_condition_data);
143 subquery_max_strip.addToTableList(
"CHAMBERSTRIP");
144 coral::IQueryDefinition & subquery_max_channel(subquery_max_strip.defineSubQuery(
"MAX_CHANNEL"));
145 subquery_max_strip.addToTableList(
"MAX_CHANNEL");
146 subquery_max_strip.addToOutputList(
"CHAMBERSTRIP.FC_FEBCONNECTORID",
"FC_FEBCONNECTORID");
147 subquery_max_strip.addToOutputList(
"CHAMBERSTRIP.CHAMBERSTRIPNUMBER",
"STRIP");
148 coral::AttributeList subquery_max_strip_condition_data;
149 subquery_max_strip.setCondition(
"CHAMBERSTRIP.FC_FEBCONNECTORID=MAX_CHANNEL.FC_FEBCONNECTORID" 150 " AND CHAMBERSTRIP.CABLECHANNELNUM=MAX_CHANNEL.CHANNEL" 151 , subquery_max_strip_condition_data);
153 subquery_max_channel.addToTableList(
"CHAMBERSTRIP");
154 subquery_max_channel.addToOutputList(
"FC_FEBCONNECTORID");
155 subquery_max_channel.addToOutputList(
"MAX(CABLECHANNELNUM)",
"CHANNEL");
156 subquery_max_channel.groupBy(
"FC_FEBCONNECTORID");
157 coral::AttributeList subquery_max_channel_condition_data;
158 subquery_max_channel.setCondition(
"CABLECHANNELNUM IS NOT NULL" 159 , subquery_max_channel_condition_data);
161 coral::AttributeList query_condition_data;
162 query->setCondition(
"CHAMBERSTRIP.FC_FEBCONNECTORID=MIN_CHANNEL.FC_FEBCONNECTORID" 163 " AND CHAMBERSTRIP.CABLECHANNELNUM=MIN_CHANNEL.CHANNEL" 164 " AND CHAMBERSTRIP.FC_FEBCONNECTORID=MAX_STRIP.FC_FEBCONNECTORID" 165 " AND CHAMBERSTRIP.FC_FEBCONNECTORID=FEBCONNECTOR.FEBCONNECTORID" 166 " AND FEBCONNECTOR.FL_FEBLOCATIONID=FEBLOCATION.FEBLOCATIONID" 167 " AND BOARD.BOARDID=FEBLOCATION.LB_LINKBOARDID" 168 " AND CHAMBERLOCATION.CHAMBERLOCATIONID=FEBLOCATION.CL_CHAMBERLOCATIONID" 169 , query_condition_data);
172 int first_strip(0),
slope(1);
173 std::uint16_t channels(0x0);
175 std::unique_ptr<RPCLBLinkMap> lb_link_map_object(
new RPCLBLinkMap());
177 = lb_link_map_object->getMap();
183 coral::ICursor & cursor(
query->execute());
184 while (cursor.next()) {
185 coral::AttributeList
const & row(cursor.currentRow());
190 if (lb_name != lb_link.
getName())
191 edm::LogWarning(
"RPCLBLinkMapHandler") <<
"Mismatch LinkBoard Name: " << lb_name <<
" vs " << lb_link;
192 lb_link.
setConnector(row[
"CONNECTOR"].data<short>() - 1);
195 if (row[
"SUBSECTOR"].isNull())
199 det_id =
getRPCDetId(row[
"REGION"].data<long long>()
200 , row[
"DISKORWHEEL"].data<short>()
201 , row[
"LAYER"].data<short>()
202 , row[
"SECTOR"].data<short>()
204 , row[
"ETAPARTITION"].data<std::string>());
207 first_strip = row[
"FIRST_STRIP"].data<
int>();
208 slope = row[
"SLOPE"].data<
long long>();
209 channels = (std::uint16_t)(row[
"CHANNELS"].data<long long>());
211 lb_link_map.insert(std::pair<RPCLBLink, RPCFebConnector>(lb_link,
RPCFebConnector(det_id
218 input_session->transaction().commit();
223 for (
auto const & link_connector : lb_link_map) {
224 ofstream << link_connector.first <<
": " << link_connector.second << std::endl;
228 edm::LogInfo(
"RPCLBLinkMapHandler") <<
"Add to transfer list";
void getNewObjects() override
T getParameter(std::string const &) const
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)
std::string id() const override
def query(query_str, verbose=False)
OldContainer m_to_transfer
void setParameters(const edm::ParameterSet &connectionPset)
cond::persistency::ConnectionPool connection_
cond::ValidityInterval lastInterval
Abs< T >::type abs(const T &t)
std::string getName() const
RPCLBLinkMapHandler(edm::ParameterSet const &config)
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)
cond::TagInfo_t const & tagInfo() const