7 m_name(ps.getUntrackedParameter<std::string>(
"name",
"RPCEMapSourceHandler")),
8 m_dummy(ps.getUntrackedParameter<int>(
"WriteDummy",0)),
9 m_validate(ps.getUntrackedParameter<int>(
"Validate",0)),
10 m_connect(ps.getUntrackedParameter<std::string>(
"OnlineConn",
"")),
11 m_authpath(ps.getUntrackedParameter<std::string>(
"OnlineAuthPath",
"."))
28 if(m_validate==1 && tagInfo().
size>0) {
29 std::cout<<
" Validation was requested, so will check present contents"<<std::endl;
30 std::cout<<
"Name of tag : "<<tagInfo().name <<
", tag size : " << tagInfo().size
31 <<
", last object valid since "
32 << tagInfo().lastInterval.first << std::endl;
33 payload = lastPayload();
39 tm *
ptm = gmtime(&rawtime);
41 strftime(buffer,20,
"%d/%m/%Y_%H:%M:%S",ptm);
42 std::string eMap_version=(std::string)buffer;
44 eMap =
new RPCEMap(eMap_version);
46 ConnectOnlineDB(m_connect,m_authpath);
55 if (m_validate==1) difference=Compare2EMaps(payload,eMap);
56 if (!difference)
std::cout<<
"No changes - will not write anything!!!"<<std::endl;
58 std::cout<<
"Will write new object to offline DB!!!"<<std::endl;
59 m_to_transfer.push_back(std::make_pair((
RPCEMap*)eMap,snc));
67 std::cout <<
"RPCEMapConfigSourceHandler: connecting to " << connect <<
"..." << std::flush;
70 connection->configuration().setAuthenticationPath( authPath ) ;
71 connection->configure();
87 session->transaction().start(
true );
89 std::string condition=
"";
90 coral::AttributeList conditionData;
92 std::cout << std::endl <<
"RPCEMapSourceHandler: start to build RPC e-Map..." << std::flush << std::endl << std::endl;
96 coral::IQuery* query1 = schema.newQuery();
97 query1->addToTableList(
"DCCBOARD" );
98 query1->addToOutputList(
"DCCBOARD.DCCBOARDID",
"DCCBOARDID");
99 query1->addToOutputList(
"DCCBOARD.FEDNUMBER",
"FEDNUMBER");
100 query1->addToOrderList(
"FEDNUMBER");
101 condition =
"DCCBOARD.DCCBOARDID>0";
102 query1->setCondition( condition, conditionData );
104 coral::ICursor& cursor1 = query1->execute();
106 std::pair<int,int> tmp_tbl;
107 std::vector< std::pair<int,int> > theDAQ;
108 while ( cursor1.next() ) {
110 const coral::AttributeList& row = cursor1.currentRow();
111 tmp_tbl.first=row[
"DCCBOARDID"].data<
long long>();
112 tmp_tbl.second=row[
"FEDNUMBER"].data<
long long>();
113 theDAQ.push_back(tmp_tbl);
117 for(
unsigned int iFED=0;iFED<theDAQ.size();iFED++) {
118 thisDcc.
theId=theDAQ[iFED].second;
119 std::vector<std::pair<int,int> > theTB;
122 coral::IQuery* query2 = schema.newQuery();
123 query2->addToTableList(
"TRIGGERBOARD" );
124 query2->addToOutputList(
"TRIGGERBOARD.TRIGGERBOARDID",
"TRIGGERBOARDID");
125 query2->addToOutputList(
"TRIGGERBOARD.DCCINPUTCHANNELNUM",
"DCCCHANNELNUM");
126 query2->addToOrderList(
"DCCCHANNELNUM");
127 condition =
"TRIGGERBOARD.DCCBOARD_DCCBOARDID="+IntToString(theDAQ[iFED].
first);
128 query2->setCondition( condition, conditionData );
129 coral::ICursor& cursor2 = query2->execute();
131 while ( cursor2.next() ) {
134 const coral::AttributeList& row = cursor2.currentRow();
135 tmp_tbl.first=row[
"TRIGGERBOARDID"].data<
long long>();
136 tmp_tbl.second=row[
"DCCCHANNELNUM"].data<
long long>();
137 theTB.push_back(tmp_tbl);
140 for(
unsigned int iTB=0;iTB<theTB.size();iTB++) {
141 thisTB.
theNum=theTB[iTB].second;
142 std::vector<std::pair<int,int> > theLink;
145 coral::IQuery* query3 = schema.newQuery();
146 query3->addToTableList(
"BOARDBOARDCONN");
147 query3->addToOutputList(
"BOARDBOARDCONN.BOARD_BOARDID",
"BOARDID");
148 query3->addToOutputList(
"BOARDBOARDCONN.COLLECTORBOARDINPUTNUM",
"TBINPUTNUM");
149 query3->addToOrderList(
"TBINPUTNUM");
150 condition =
"BOARDBOARDCONN.BOARD_COLLECTORBOARDID="+IntToString(theTB[iTB].first);
151 query3->setCondition( condition, conditionData );
152 coral::ICursor& cursor3 = query3->execute();
154 while (cursor3.next()) {
156 const coral::AttributeList& row = cursor3.currentRow();
157 tmp_tbl.first=row[
"BOARDID"].data<
long long>();
158 tmp_tbl.second=row[
"TBINPUTNUM"].data<
long long>();
159 theLink.push_back(tmp_tbl);
162 for(
unsigned int iLink=0;iLink<theLink.size();iLink++) {
163 int boardId=theLink[iLink].first;
165 std::vector<std::pair<int,std::string> > theLB;
166 std::pair<int,std::string> tmpLB;
169 coral::IQuery* query4 = schema.newQuery();
170 query4->addToTableList(
"BOARD");
171 query4->addToOutputList(
"BOARD.NAME",
"NAME");
172 condition =
"BOARD.BOARDID="+IntToString(theLink[iLink].first);
173 query4->setCondition( condition, conditionData );
174 coral::ICursor& cursor4 = query4->execute();
176 while (cursor4.next()) {
178 const coral::AttributeList& row = cursor4.currentRow();
179 tmpLB.first=theLink[iLink].first;
180 tmpLB.second=row[
"NAME"].data<std::string>();
181 theLB.push_back(tmpLB);
185 coral::IQuery* query5 = schema.newQuery();
186 query5->addToTableList(
"LINKBOARD");
187 query5->addToTableList(
"BOARD");
188 query5->addToOutputList(
"LINKBOARD.LINKBOARDID",
"LINKBOARDID");
189 query5->addToOutputList(
"BOARD.NAME",
"NAME");
190 query5->addToOrderList(
"LINKBOARDID");
191 condition =
"LINKBOARD.MASTERID="+IntToString(theLink[iLink].first)+
" AND BOARD.BOARDID=LINKBOARD.LINKBOARDID AND LINKBOARD.MASTERID<>LINKBOARD.LINKBOARDID";
192 query5->setCondition( condition, conditionData );
193 coral::ICursor& cursor5 = query5->execute();
194 while (cursor5.next()) {
196 const coral::AttributeList& row = cursor5.currentRow();
197 tmpLB.first=row[
"LINKBOARDID"].data<
long long>();
198 tmpLB.second=row[
"NAME"].data<std::string>();
199 theLB.push_back(tmpLB);
202 for(
unsigned int iLB=0; iLB<theLB.size(); iLB++) {
203 thisLB.
theMaster = (theLB[iLB].first==boardId);
205 std::string theName = theLB[iLB].second;
206 int slength = theName.length();
208 int wheel=atoi((theName.substr(6,1)).c_str());
209 std::string char1=(theName.substr(4,1)).c_str();
210 std::string char2=(theName.substr(slength-7,1)).c_str();
211 int num3=atoi((theName.substr(slength-6,1)).c_str());
212 std::string char4=(theName.substr(slength-5,1)).c_str();
213 bool itsS1to9=(theName.substr(slength-11,1)==
"S");
221 int sector=atoi((theName.substr(slength-n1,n2)).c_str());
222 std::string char1Val[2]={
"B",
"E"};
223 std::string char2Val[3]={
"N",
"M",
"P"};
224 std::string char4Val[9]={
"0",
"1",
"2",
"3",
"A",
"B",
"C",
"D",
"E"};
225 for (
int i=0;
i<2;
i++)
if (char1==char1Val[
i]) n1=i+1;
226 for (
int i=0; i<3; i++)
if (char2==char2Val[i]) n2=
i;
227 for (
int i=0; i<9; i++)
if (char4==char4Val[i]) n3=
i;
228 thisLB.
theCode=n3+num3*10+n2*100+n1*1000+wheel*10000+sector*100000;
230 std::vector<FEBStruct> theFEB;
233 coral::IQuery* query6 = schema.newQuery();
234 query6->addToTableList(
"FEBLOCATION");
235 query6->addToTableList(
"FEBCONNECTOR");
236 query6->addToOutputList(
"FEBLOCATION.FEBLOCATIONID",
"FEBLOCATIONID");
237 query6->addToOutputList(
"FEBLOCATION.CL_CHAMBERLOCATIONID",
"CHAMBERLOCATIONID");
238 query6->addToOutputList(
"FEBCONNECTOR.FEBCONNECTORID",
"FEBCONNECTORID");
239 query6->addToOutputList(
"FEBLOCATION.FEBLOCALETAPARTITION",
"LOCALETAPART");
240 query6->addToOutputList(
"FEBLOCATION.POSINLOCALETAPARTITION",
"POSINLOCALETAPART");
241 query6->addToOutputList(
"FEBLOCATION.FEBCMSETAPARTITION",
"CMSETAPART");
242 query6->addToOutputList(
"FEBLOCATION.POSINCMSETAPARTITION",
"POSINCMSETAPART");
243 query6->addToOutputList(
"FEBCONNECTOR.LINKBOARDINPUTNUM",
"LINKBOARDINPUTNUM");
244 query6->addToOrderList(
"FEBLOCATIONID");
245 query6->addToOrderList(
"FEBCONNECTORID");
246 condition =
"FEBLOCATION.LB_LINKBOARDID="+IntToString(theLB[iLB].first)+
" AND FEBLOCATION.FEBLOCATIONID=FEBCONNECTOR.FL_FEBLOCATIONID";
247 query6->setCondition( condition, conditionData );
248 coral::ICursor& cursor6 = query6->execute();
250 while (cursor6.next()) {
252 const coral::AttributeList& row = cursor6.currentRow();
253 tmpFEB.
febId=row[
"FEBLOCATIONID"].data<
long long>();
254 tmpFEB.
chamberId=row[
"CHAMBERLOCATIONID"].data<
long long>();
255 tmpFEB.
connectorId=row[
"FEBCONNECTORID"].data<
long long>();
256 tmpFEB.
localEtaPart=row[
"LOCALETAPART"].data<std::string>();
258 tmpFEB.
cmsEtaPart=row[
"CMSETAPART"].data<std::string>();
260 tmpFEB.
lbInputNum=row[
"LINKBOARDINPUTNUM"].data<
short>();
261 theFEB.push_back(tmpFEB);
264 for(
unsigned int iFEB=0; iFEB<theFEB.size(); iFEB++) {
265 std::string
temp=theFEB[iFEB].localEtaPart;
266 std::string localEtaVal[6]={
"Forward",
"Central",
"Backward",
"A",
"B",
"C"};
267 char localEtaPartition=0;
268 for (
int i=0; i<6; i++)
if (temp==localEtaVal[i]) localEtaPartition=i+1;
269 char positionInLocalEtaPartition=theFEB[iFEB].posInLocalEtaPart;
270 temp=theFEB[iFEB].cmsEtaPart;
271 std::string cmsEtaVal[6]={
"1",
"2",
"3",
"A",
"B",
"C"};
272 char cmsEtaPartition=0;
273 for (
int i=0; i<6; i++)
if (temp==cmsEtaVal[i]) cmsEtaPartition=i+1;
274 char positionInCmsEtaPartition=theFEB[iFEB].posInCmsEtaPart;
275 thisFeb.
thePartition=positionInLocalEtaPartition+10*localEtaPartition+100*positionInCmsEtaPartition+1000*cmsEtaPartition;
278 coral::IQuery* query7 = schema.newQuery();
279 query7->addToTableList(
"CHAMBERLOCATION");
280 query7->addToOutputList(
"CHAMBERLOCATION.DISKORWHEEL",
"DISKORWHEEL");
281 query7->addToOutputList(
"CHAMBERLOCATION.LAYER",
"LAYER");
282 query7->addToOutputList(
"CHAMBERLOCATION.SECTOR",
"SECTOR");
283 query7->addToOutputList(
"CHAMBERLOCATION.SUBSECTOR",
"SUBSECTOR");
284 query7->addToOutputList(
"CHAMBERLOCATION.CHAMBERLOCATIONNAME",
"NAME");
285 query7->addToOutputList(
"CHAMBERLOCATION.FEBZORNT",
"FEBZORNT");
286 query7->addToOutputList(
"CHAMBERLOCATION.FEBRADORNT",
"FEBRADORNT");
287 query7->addToOutputList(
"CHAMBERLOCATION.BARRELORENDCAP",
"BARRELORENDCAP");
288 condition =
"CHAMBERLOCATION.CHAMBERLOCATIONID="+IntToString(theFEB[iFEB].chamberId);
289 query7->setCondition( condition, conditionData );
290 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>();
296 temp=row[
"SUBSECTOR"].data<std::string>();
306 std::string subsVal[5]={
"--",
"-",
"",
"+",
"++"};
308 for (
int i=0; i<5; i++)
if (temp==subsVal[i]) subsector=
i;
309 temp=row[
"FEBZORNT"].data<std::string>();
311 if (temp==
"+z") febZOrnt=1;
312 temp=row[
"FEBRADORNT"].data<std::string>();
314 std::string febZRVal[3]={
"",
"IN",
"OUT"};
315 for (
int i=0; i<3; i++)
if (temp==febZRVal[i]) febZRadOrnt=
i;
316 temp=row[
"BARRELORENDCAP"].data<std::string>();
317 char barrelOrEndcap=0;
318 if (temp==
"Barrel") barrelOrEndcap=1;
319 thisFeb.
theChamber=sector+100*subsector+1000*febZRadOrnt+5000*febZOrnt+10000*diskOrWheel+100000*layer+1000000*barrelOrEndcap;
323 coral::IQuery* query8 = schema.newQuery();
324 query8->addToTableList(
"CHAMBERSTRIP");
325 query8->addToOutputList(
"CHAMBERSTRIP.CABLECHANNELNUM",
"CABLECHANNELNUM");
326 query8->addToOutputList(
"CHAMBERSTRIP.CHAMBERSTRIPNUMBER",
"CHAMBERSTRIPNUM");
328 query8->addToOrderList(
"CABLECHANNELNUM");
329 condition =
"CHAMBERSTRIP.FC_FEBCONNECTORID="+IntToString(theFEB[iFEB].connectorId);
330 query8->setCondition( condition, conditionData );
331 coral::ICursor& cursor8 = query8->execute();
335 int firstChamberStrip=0;
337 int lastChamberStrip=0;
339 while (cursor8.next()) {
340 const coral::AttributeList& row = cursor8.currentRow();
341 lastChamberStrip=row[
"CHAMBERSTRIPNUM"].data<
int>();
342 lastPin=row[
"CABLECHANNELNUM"].data<
short>();
344 firstChamberStrip=lastChamberStrip;
351 if (firstPin == 1 && lastPin == nstrips)
353 else if (firstPin == 2 && lastPin == nstrips+1)
355 else if (firstPin == 3 && lastPin == nstrips+2)
357 else if (firstPin == 2 && lastPin == nstrips+2)
360 {
std::cout<<
" Unknown algo : "<<firstPin<<
" "<<lastPin<<std::endl; }
361 if ((lastPin-firstPin)*(lastChamberStrip-firstChamberStrip) < 0) algo=algo+4;
362 thisFeb.
theAlgo=algo+100*firstChamberStrip+10000*nstrips;
363 eMap->theFebs.push_back(thisFeb);
366 eMap->theLBs.push_back(thisLB);
369 eMap->theLinks.push_back(thisLink);
372 eMap->theTBs.push_back(thisTB);
376 eMap->theDccs.push_back(thisDcc);
378 std::cout << std::endl <<
"Building RPC e-Map done!" << std::flush << std::endl << std::endl;
384 std::vector<const DccSpec *> dccs1 = oldmap1->
dccList();
385 std::vector<const DccSpec *> dccs2 = oldmap2->
dccList();
386 if(dccs1.size()!=dccs2.size()) {
391 if(dccRange1.first!=dccRange2.first) {
394 if(dccRange1.second!=dccRange2.second) {
397 typedef std::vector<const DccSpec *>::const_iterator IDCC;
398 IDCC idcc2 = dccs2.begin();
399 for (IDCC idcc1 = dccs1.begin(); idcc1 != dccs1.end(); idcc1++) {
400 int dccNo = (**idcc1).id();
401 std::string dccContents = (**idcc1).print(4);
402 if ((**idcc2).id()!=dccNo) {
405 if ((**idcc2).print(4)!=dccContents) {
int Compare2EMaps(Ref map1, RPCEMap *map2)
int theTriggerBoardInputNumber
edm::Ref< Container > Ref
void ConnectOnlineDB(std::string connect, std::string authPath)
RPCReadOutMapping * convert() const
void DisconnectOnlineDB()
std::vector< const DccSpec * > dccList() const
all FEDs in map
int theLinkBoardNumInLink
RPCEMapSourceHandler(const edm::ParameterSet &ps)
unsigned long long Time_t
std::pair< int, int > dccNumberRange() const
Range of FED IDs in map (min and max id)
cond::Time_t currentTime() const
tuple connect
process.AlignmentProducer.algoConfig.uvarFile = '.
tuple size
Write out results.