8 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"RPCEMapSourceHandler")),
9 m_dummy(ps.getUntrackedParameter<int>(
"WriteDummy", 0)),
10 m_validate(ps.getUntrackedParameter<int>(
"Validate", 0)),
11 m_connect(ps.getUntrackedParameter<std::
string>(
"OnlineConn",
"")),
12 m_authpath(ps.getUntrackedParameter<std::
string>(
"OnlineAuthPath",
".")) {}
24 std::cout <<
" Validation was requested, so will check present contents" << std::endl;
25 std::cout <<
"Name of tag : " <<
tagInfo().name <<
", tag size : " <<
tagInfo().size <<
", last object valid since "
26 <<
tagInfo().lastInterval.since << std::endl;
27 payload = lastPayload();
33 tm*
ptm = gmtime(&rawtime);
35 strftime(buffer, 20,
"%d/%m/%Y_%H:%M:%S", ptm);
38 eMap =
new RPCEMap(eMap_version);
40 ConnectOnlineDB(m_connect, m_authpath);
50 difference = Compare2EMaps(payload, eMap);
52 std::cout <<
"No changes - will not write anything!!!" << std::endl;
53 if (difference == 1) {
54 std::cout <<
"Will write new object to offline DB!!!" << std::endl;
55 m_to_transfer.push_back(std::make_pair((
RPCEMap*)eMap, snc));
63 std::cout <<
"RPCEMapConfigSourceHandler: connecting to " << connect <<
"..." << std::flush;
73 session.transaction().start(
true);
74 coral::ISchema& schema =
session.nominalSchema();
76 coral::AttributeList conditionData;
78 std::cout << std::endl <<
"RPCEMapSourceHandler: start to build RPC e-Map..." << std::flush << std::endl << std::endl;
82 coral::IQuery* query1 = schema.newQuery();
83 query1->addToTableList(
"DCCBOARD");
84 query1->addToOutputList(
"DCCBOARD.DCCBOARDID",
"DCCBOARDID");
85 query1->addToOutputList(
"DCCBOARD.FEDNUMBER",
"FEDNUMBER");
86 query1->addToOrderList(
"FEDNUMBER");
87 condition =
"DCCBOARD.DCCBOARDID>0";
88 query1->setCondition(condition, conditionData);
90 coral::ICursor& cursor1 = query1->execute();
92 std::pair<int, int> tmp_tbl;
93 std::vector<std::pair<int, int> > theDAQ;
94 while (cursor1.next()) {
96 const coral::AttributeList& row = cursor1.currentRow();
97 tmp_tbl.first = row[
"DCCBOARDID"].data<
long long>();
98 tmp_tbl.second = row[
"FEDNUMBER"].data<
long long>();
99 theDAQ.push_back(tmp_tbl);
103 for (
unsigned int iFED = 0; iFED < theDAQ.size(); iFED++) {
104 thisDcc.
theId = theDAQ[iFED].second;
105 std::vector<std::pair<int, int> > theTB;
108 coral::IQuery* query2 = schema.newQuery();
109 query2->addToTableList(
"TRIGGERBOARD");
110 query2->addToOutputList(
"TRIGGERBOARD.TRIGGERBOARDID",
"TRIGGERBOARDID");
111 query2->addToOutputList(
"TRIGGERBOARD.DCCINPUTCHANNELNUM",
"DCCCHANNELNUM");
112 query2->addToOrderList(
"DCCCHANNELNUM");
113 condition =
"TRIGGERBOARD.DCCBOARD_DCCBOARDID=" + IntToString(theDAQ[iFED].
first);
114 query2->setCondition(condition, conditionData);
115 coral::ICursor& cursor2 = query2->execute();
117 while (cursor2.next()) {
120 const coral::AttributeList& row = cursor2.currentRow();
121 tmp_tbl.first = row[
"TRIGGERBOARDID"].data<
long long>();
122 tmp_tbl.second = row[
"DCCCHANNELNUM"].data<
long long>();
123 theTB.push_back(tmp_tbl);
126 for (
unsigned int iTB = 0; iTB < theTB.size(); iTB++) {
127 thisTB.
theNum = theTB[iTB].second;
128 std::vector<std::pair<int, int> > theLink;
131 coral::IQuery* query3 = schema.newQuery();
132 query3->addToTableList(
"BOARDBOARDCONN");
133 query3->addToOutputList(
"BOARDBOARDCONN.BOARD_BOARDID",
"BOARDID");
134 query3->addToOutputList(
"BOARDBOARDCONN.COLLECTORBOARDINPUTNUM",
"TBINPUTNUM");
135 query3->addToOrderList(
"TBINPUTNUM");
136 condition =
"BOARDBOARDCONN.BOARD_COLLECTORBOARDID=" + IntToString(theTB[iTB].first);
137 query3->setCondition(condition, conditionData);
138 coral::ICursor& cursor3 = query3->execute();
140 while (cursor3.next()) {
142 const coral::AttributeList& row = cursor3.currentRow();
143 tmp_tbl.first = row[
"BOARDID"].data<
long long>();
144 tmp_tbl.second = row[
"TBINPUTNUM"].data<
long long>();
145 theLink.push_back(tmp_tbl);
148 for (
unsigned int iLink = 0; iLink < theLink.size(); iLink++) {
149 int boardId = theLink[iLink].first;
151 std::vector<std::pair<int, std::string> > theLB;
152 std::pair<int, std::string> tmpLB;
155 coral::IQuery* query4 = schema.newQuery();
156 query4->addToTableList(
"BOARD");
157 query4->addToOutputList(
"BOARD.NAME",
"NAME");
158 condition =
"BOARD.BOARDID=" + IntToString(theLink[iLink].first);
159 query4->setCondition(condition, conditionData);
160 coral::ICursor& cursor4 = query4->execute();
162 while (cursor4.next()) {
164 const coral::AttributeList& row = cursor4.currentRow();
165 tmpLB.first = theLink[iLink].first;
167 theLB.push_back(tmpLB);
171 coral::IQuery* query5 = schema.newQuery();
172 query5->addToTableList(
"LINKBOARD");
173 query5->addToTableList(
"BOARD");
174 query5->addToOutputList(
"LINKBOARD.LINKBOARDID",
"LINKBOARDID");
175 query5->addToOutputList(
"BOARD.NAME",
"NAME");
176 query5->addToOrderList(
"LINKBOARDID");
177 condition =
"LINKBOARD.MASTERID=" + IntToString(theLink[iLink].first) +
178 " AND BOARD.BOARDID=LINKBOARD.LINKBOARDID AND LINKBOARD.MASTERID<>LINKBOARD.LINKBOARDID";
179 query5->setCondition(condition, conditionData);
180 coral::ICursor& cursor5 = query5->execute();
181 while (cursor5.next()) {
183 const coral::AttributeList& row = cursor5.currentRow();
184 tmpLB.first = row[
"LINKBOARDID"].data<
long long>();
186 theLB.push_back(tmpLB);
189 for (
unsigned int iLB = 0; iLB < theLB.size(); iLB++) {
193 int slength = theName.length();
195 int wheel = atoi((theName.substr(6, 1)).c_str());
197 std::string char2 = theName.substr(slength - 7, 1);
198 int num3 = atoi((theName.substr(slength - 6, 1)).c_str());
199 std::string char4 = theName.substr(slength - 5, 1);
200 bool itsS1to9 = (theName.substr(slength - 11, 1) ==
"S");
208 int sector = atoi((theName.substr(slength - n1, n2)).c_str());
211 std::string char4Val[9] = {
"0",
"1",
"2",
"3",
"A",
"B",
"C",
"D",
"E"};
212 for (
int i = 0;
i < 2;
i++)
213 if (char1 == char1Val[
i])
215 for (
int i = 0; i < 3; i++)
216 if (char2 == char2Val[i])
218 for (
int i = 0; i < 9; i++)
219 if (char4 == char4Val[i])
221 thisLB.
theCode = n3 + num3 * 10 + n2 * 100 + n1 * 1000 + wheel * 10000 + sector * 100000;
222 std::vector<FEBStruct> theFEB;
224 coral::IQuery* query6 = schema.newQuery();
225 query6->addToTableList(
"FEBLOCATION");
226 query6->addToTableList(
"FEBCONNECTOR");
227 query6->addToOutputList(
"FEBLOCATION.FEBLOCATIONID",
"FEBLOCATIONID");
228 query6->addToOutputList(
"FEBLOCATION.CL_CHAMBERLOCATIONID",
"CHAMBERLOCATIONID");
229 query6->addToOutputList(
"FEBCONNECTOR.FEBCONNECTORID",
"FEBCONNECTORID");
230 query6->addToOutputList(
"FEBLOCATION.FEBLOCALETAPARTITION",
"LOCALETAPART");
231 query6->addToOutputList(
"FEBLOCATION.POSINLOCALETAPARTITION",
"POSINLOCALETAPART");
232 query6->addToOutputList(
"FEBLOCATION.FEBCMSETAPARTITION",
"CMSETAPART");
233 query6->addToOutputList(
"FEBLOCATION.POSINCMSETAPARTITION",
"POSINCMSETAPART");
234 query6->addToOutputList(
"FEBCONNECTOR.LINKBOARDINPUTNUM",
"LINKBOARDINPUTNUM");
235 query6->addToOrderList(
"FEBLOCATIONID");
236 query6->addToOrderList(
"FEBCONNECTORID");
237 condition =
"FEBLOCATION.LB_LINKBOARDID=" + IntToString(theLB[iLB].first) +
238 " AND FEBLOCATION.FEBLOCATIONID=FEBCONNECTOR.FL_FEBLOCATIONID";
239 query6->setCondition(condition, conditionData);
240 coral::ICursor& cursor6 = query6->execute();
242 while (cursor6.next()) {
245 const coral::AttributeList& row = cursor6.currentRow();
246 tmpFEB.
febId = row[
"FEBLOCATIONID"].data<
long long>();
247 tmpFEB.
chamberId = row[
"CHAMBERLOCATIONID"].data<
long long>();
248 tmpFEB.
connectorId = row[
"FEBCONNECTORID"].data<
long long>();
253 tmpFEB.
lbInputNum = row[
"LINKBOARDINPUTNUM"].data<
short>();
254 theFEB.push_back(tmpFEB);
257 for (
unsigned int iFEB = 0; iFEB < theFEB.size(); iFEB++) {
260 std::string localEtaVal[6] = {
"Forward",
"Central",
"Backward",
"A",
"B",
"C"};
261 char localEtaPartition = 0;
262 for (
int i = 0; i < 6; i++)
263 if (temp == localEtaVal[i])
264 localEtaPartition = i + 1;
265 char positionInLocalEtaPartition = theFEB[iFEB].posInLocalEtaPart;
266 temp = theFEB[iFEB].cmsEtaPart;
267 std::string cmsEtaVal[6] = {
"1",
"2",
"3",
"A",
"B",
"C"};
268 char cmsEtaPartition = 0;
269 for (
int i = 0; i < 6; i++)
270 if (temp == cmsEtaVal[i])
271 cmsEtaPartition = i + 1;
272 char positionInCmsEtaPartition = theFEB[iFEB].posInCmsEtaPart;
273 thisFeb.
thePartition = positionInLocalEtaPartition + 10 * localEtaPartition +
274 100 * positionInCmsEtaPartition + 1000 * cmsEtaPartition;
277 coral::IQuery* query7 = schema.newQuery();
278 query7->addToTableList(
"CHAMBERLOCATION");
279 query7->addToOutputList(
"CHAMBERLOCATION.DISKORWHEEL",
"DISKORWHEEL");
280 query7->addToOutputList(
"CHAMBERLOCATION.LAYER",
"LAYER");
281 query7->addToOutputList(
"CHAMBERLOCATION.SECTOR",
"SECTOR");
282 query7->addToOutputList(
"CHAMBERLOCATION.SUBSECTOR",
"SUBSECTOR");
283 query7->addToOutputList(
"CHAMBERLOCATION.CHAMBERLOCATIONNAME",
"NAME");
284 query7->addToOutputList(
"CHAMBERLOCATION.FEBZORNT",
"FEBZORNT");
285 query7->addToOutputList(
"CHAMBERLOCATION.FEBRADORNT",
"FEBRADORNT");
286 query7->addToOutputList(
"CHAMBERLOCATION.BARRELORENDCAP",
"BARRELORENDCAP");
287 condition =
"CHAMBERLOCATION.CHAMBERLOCATIONID=" + IntToString(theFEB[iFEB].chamberId);
288 query7->setCondition(condition, conditionData);
289 coral::ICursor& cursor7 = query7->execute();
291 while (cursor7.next()) {
292 const coral::AttributeList& row = cursor7.currentRow();
293 char diskOrWheel = row[
"DISKORWHEEL"].data<
short>() + 3;
294 char layer = row[
"LAYER"].data<
short>();
295 int sector = row[
"SECTOR"].data<
short>();
306 std::string subsVal[5] = {
"--",
"-",
"",
"+",
"++"};
308 for (
int i = 0; i < 5; i++)
309 if (temp == subsVal[i])
316 char febZRadOrnt = 0;
318 for (
int i = 0; i < 3; i++)
319 if (temp == febZRVal[i])
322 char barrelOrEndcap = 0;
323 if (temp ==
"Barrel")
325 thisFeb.
theChamber = sector + 100 * subsector + 1000 * febZRadOrnt + 5000 * febZOrnt +
326 10000 * diskOrWheel + 100000 * layer + 1000000 * barrelOrEndcap;
330 coral::IQuery* query8 = schema.newQuery();
331 query8->addToTableList(
"CHAMBERSTRIP");
332 query8->addToOutputList(
"CHAMBERSTRIP.CABLECHANNELNUM",
"CABLECHANNELNUM");
333 query8->addToOutputList(
"CHAMBERSTRIP.CHAMBERSTRIPNUMBER",
"CHAMBERSTRIPNUM");
335 query8->addToOrderList(
"CABLECHANNELNUM");
336 condition =
"CHAMBERSTRIP.FC_FEBCONNECTORID=" + IntToString(theFEB[iFEB].connectorId);
337 query8->setCondition(condition, conditionData);
338 coral::ICursor& cursor8 = query8->execute();
342 int firstChamberStrip = 0;
344 int lastChamberStrip = 0;
346 while (cursor8.next()) {
347 const coral::AttributeList& row = cursor8.currentRow();
348 lastChamberStrip = row[
"CHAMBERSTRIPNUM"].data<
int>();
349 lastPin = row[
"CABLECHANNELNUM"].data<
short>();
351 firstChamberStrip = lastChamberStrip;
358 if (firstPin == 1 && lastPin == nstrips) {
360 }
else if (firstPin == 2 && lastPin == nstrips + 1) {
362 }
else if (firstPin == 3 && lastPin == nstrips + 2) {
364 }
else if (firstPin == 2 && lastPin == nstrips + 2) {
367 std::cout <<
" Unknown algo : " << firstPin <<
" " << lastPin << std::endl;
369 if ((lastPin - firstPin) * (lastChamberStrip - firstChamberStrip) < 0)
371 thisFeb.
theAlgo = algo + 100 * firstChamberStrip + 10000 * nstrips;
372 eMap->theFebs.push_back(thisFeb);
374 thisLB.
nFebs = nfebs;
375 eMap->theLBs.push_back(thisLB);
377 thisLink.
nLBs = nlbs;
378 eMap->theLinks.push_back(thisLink);
381 eMap->theTBs.push_back(thisTB);
385 eMap->theDccs.push_back(thisDcc);
387 std::cout << std::endl <<
"Building RPC e-Map done!" << std::flush << std::endl << std::endl;
391 const Ref& map1 = _map1;
394 std::vector<const DccSpec*> dccs1 = oldmap1->
dccList();
395 std::vector<const DccSpec*> dccs2 = oldmap2->
dccList();
396 if (dccs1.size() != dccs2.size()) {
401 if (dccRange1.first != dccRange2.first) {
404 if (dccRange1.second != dccRange2.second) {
407 typedef std::vector<const DccSpec*>::const_iterator IDCC;
408 IDCC idcc2 = dccs2.begin();
409 for (IDCC idcc1 = dccs1.begin(); idcc1 != dccs1.end(); idcc1++) {
410 int dccNo = (**idcc1).id();
412 if ((**idcc2).id() != dccNo) {
415 if ((**idcc2).print(4) != dccContents) {
void getNewObjects() override
int theTriggerBoardInputNumber
void ConnectOnlineDB(std::string connect, std::string authPath)
void DisconnectOnlineDB()
std::vector< const DccSpec * > dccList() const
all FEDs in map
int theLinkBoardNumInLink
constexpr std::array< uint8_t, layerIndexSize > layer
RPCEMapSourceHandler(const edm::ParameterSet &ps)
~RPCEMapSourceHandler() override
unsigned long long Time_t
Session createSession(const std::string &connectionString, bool writeCapable=false)
std::pair< int, int > dccNumberRange() const
Range of FED IDs in map (min and max id)
int Compare2EMaps(const Ref &map1, RPCEMap *map2)
std::unique_ptr< RPCEMap > Ref
cond::Time_t currentTime() const
RPCReadOutMapping const * convert() const
void setAuthenticationPath(const std::string &p)
tuple size
Write out results.