001
002 #include "MuonGeoModel/RDBReaderAtlas.h"
003 #include "MuonReadoutGeometry/GlobalUtilities.h"
004 #include "MuonGeoModel/StationSelector.h"
005 #include "MuonGeoModel/MdtComponent.h"
006 #include "MuonReadoutGeometry/MuonDetectorManager.h"
007 #include "RDBAccessSvc/IRDBAccessSvc.h"
008 #include "RDBAccessSvc/IRDBRecord.h"
009 #include "RDBAccessSvc/IRDBRecordset.h"
010 #include "MuonReadoutGeometry/TgcReadoutParams.h"
011 #include "CLHEP/Units/SystemOfUnits.h"
012
013 #include "MuonGeoModel/TGC_Technology.h"
014
015 namespace MuonGM {
016
017 RDBReaderAtlas::RDBReaderAtlas(StoreGateSvc *pDetStore, IRDBAccessSvc* pRDBAccess, std::string geoTag, std::string geoNode,
018 const std::map<std::string,std::string>* asciiFileDBMap)
019 :
020 DBReader(pDetStore),
021 _geoTag(geoTag),
022 _geoNode(geoNode),
023 m_pRDBAccess(pRDBAccess)
024 {
025 m_msgSvc = Athena::getMessageSvc();
026 MsgStream log(m_msgSvc, "MuGM:RDBReadAtlas");
027 SCdbaccess = StatusCode::FAILURE;
028
029 log<<MSG::INFO<<"Start retriving dbObjects with tag = <"<<geoTag<<"> node <"<<geoNode<<">"<<endreq;
030
031 const IRDBRecordset* dbdata;
032 dbdata = m_pRDBAccess->getRecordset("ATYP",geoTag,geoNode);
033 dhatyp = new DblQ00Atyp(dbdata);
034 atyp = dhatyp->data();
035 dbdata = m_pRDBAccess->getRecordset("ASMP",geoTag,geoNode);
036 dhasmp = new DblQ00Asmp(dbdata);
037 asmp = dhasmp->data();
038 dbdata = m_pRDBAccess->getRecordset("ALMN",geoTag,geoNode);
039 dhalmn = new DblQ00Almn(dbdata);
040 almn = dhalmn->data();
041 dbdata = m_pRDBAccess->getRecordset("APTP",geoTag,geoNode);
042 dhaptp = new DblQ00Aptp(dbdata);
043 aptp = dhaptp->data();
044 dbdata = m_pRDBAccess->getRecordset("ACUT",geoTag,geoNode);
045 dhacut = new DblQ00Acut(dbdata);
046 acut = dhacut->data();
047 dbdata = m_pRDBAccess->getRecordset("ALIN",geoTag,geoNode);
048 dhalin = new DblQ00Alin(dbdata);
049 alin = dhalin->data();
050 dbdata = m_pRDBAccess->getRecordset("DBAM",geoTag,geoNode);
051 dhdbam = new DblQ00Dbam(dbdata);
052 dbam = dhdbam->data();
053 dbdata = m_pRDBAccess->getRecordset("AWLN",geoTag,geoNode);
054 dhwrpc = new DblQ00Awln(dbdata);
055 wrpc= dhwrpc->data();
056 dbdata = m_pRDBAccess->getRecordset("ATLN",geoTag,geoNode);
057 dhwtgc = new DblQ00Atln(dbdata);
058 wtgc= dhwtgc->data();
059 dbdata = m_pRDBAccess->getRecordset("WMDT",geoTag,geoNode);
060 dhwmdt = new DblQ00Wmdt(dbdata);
061 wmdt= dhwmdt->data();
062 dbdata = m_pRDBAccess->getRecordset("WCSC",geoTag,geoNode);
063 dhwcsc = new DblQ00Wcsc(dbdata);
064 wcsc= dhwcsc->data();
065 dbdata = m_pRDBAccess->getRecordset("WRPC",geoTag,geoNode);
066 dhwrpcall = new DblQ00Wrpc(dbdata);
067 wrpcall= dhwrpcall->data();
068 dbdata = m_pRDBAccess->getRecordset("WTGC",geoTag,geoNode);
069 dhwtgcall = new DblQ00Wtgc(dbdata);
070 wtgcall= dhwtgcall->data();
071 dbdata = m_pRDBAccess->getRecordset("WSPA",geoTag,geoNode);
072 dhwspa = new DblQ00Wspa(dbdata);
073 wspa= dhwspa->data();
074 dbdata = m_pRDBAccess->getRecordset("WDED",geoTag,geoNode);
075 dhwded = new DblQ00Wded(dbdata);
076 wded= dhwded->data();
077 dbdata = m_pRDBAccess->getRecordset("WSUP",geoTag,geoNode);
078 dhwsup = new DblQ00Wsup(dbdata);
079 wsup= dhwsup->data();
080
081
082 dhaszt=0;
083 if (asciiFileDBMap!=0 &&
084 asciiFileDBMap->find("ASZT") != asciiFileDBMap->end()) {
085 log<<MSG::INFO<<"getting aszt from ascii file"<<endreq;
086 dbdata=0;
087 dhaszt = new DblQ00Aszt(asciiFileDBMap->find("ASZT")->second);
088 if (dhaszt->size()==0)
089 log<<MSG::ERROR<<"Couldn't read ASZT from ascii file!"<<endreq;
090 else log<<MSG::INFO<<"N. of lines read = "<<dhaszt->size()<<endreq;
091 }
092 if (dhaszt==0 || dhaszt->size()==0) {
093 dbdata = m_pRDBAccess->getRecordset("ASZT",geoTag,geoNode);
094 if (dbdata->size() == 0) {
095 dhaszt = new DblQ00Aszt();
096 log<<MSG::INFO<<"No ASZT table "<<endreq;
097 }
098 else {
099 log<<MSG::INFO<<"ASZT table found"<<endreq;
100 dhaszt = new DblQ00Aszt(dbdata);
101
102 }
103 }
104 log<<MSG::DEBUG<<"writing ASZT values to file"<<endreq;
105
106 aszt= dhaszt->data();
107
108
109
110
111
112 if (geoTag != "ATLAS-00")
113 {
114 dbdata = m_pRDBAccess->getRecordset("WCHV",geoTag,geoNode);
115 dhwchv = new DblQ00Wchv(dbdata);
116 wchv= dhwchv->data();
117 dbdata = m_pRDBAccess->getRecordset("WCRO",geoTag,geoNode);
118 dhwcro = new DblQ00Wcro(dbdata);
119 wcro= dhwcro->data();
120 dbdata = m_pRDBAccess->getRecordset("WCMI",geoTag,geoNode);
121 dhwcmi = new DblQ00Wcmi(dbdata);
122 wcmi= dhwcmi->data();
123 dbdata = m_pRDBAccess->getRecordset("WLBI",geoTag,geoNode);
124 dhwlbi = new DblQ00Wlbi(dbdata);
125 wlbi= dhwlbi->data();
126 }
127
128
129
130
131 SCdbaccess = StatusCode::SUCCESS;
132 log<<MSG::INFO<<"Access granted for all dbObjects needed by muon detectors"<<endreq;
133 }
134
135 StatusCode RDBReaderAtlas::ProcessDB()
136 {
137 MsgStream log(m_msgSvc, "MuGM:RDBReadAtlas");
138
139 if (SCdbaccess == StatusCode::FAILURE)
140 {
141 return SCdbaccess;
142 }
143
144 MYSQL * mysql = MYSQL::GetPointer();
145
146 mysql->setGeometryVersion(getGeometryVersion());
147
148 mysql->setLayoutName(dbam[0].amdb);
149
150 mysql->setNovaVersion(dbam[0].version);
151
152 mysql->setNovaReadVersion(dbam[0].nvrs);
153
154
155 MuonGM::ProcessStations(dhalmn, almn, dhatyp, atyp);
156
157
158 ProcessTechnologies();
159
160
161 MuonGM::ProcessPositions(dhaptp, aptp);
162
163
164 if (getGeometryVersion().substr(0,1) != "P")
165 MuonGM::ProcessCutouts(dhacut, acut, dhalin, alin, dhatyp, atyp);
166
167
168 if (dhaszt->size() >0) MuonGM::ProcessAlignements(dhaszt, aszt);
169
170
171
172 RDBReaderAtlas::ProcessTGCreadout();
173
174
175 log<<MSG::INFO<<"Intermediate Objects built from primary numbers"<<endreq;
176
177 return SCdbaccess;
178
179 }
180 RDBReaderAtlas::~RDBReaderAtlas()
181 {
182 delete dhdbam;
183 delete dhatyp;
184 delete dhasmp;
185 delete dhaszt;
186 delete dhalmn;
187 delete dhaptp;
188 delete dhwmdt;
189 delete dhwrpc;
190 delete dhwrpcall;
191 delete dhwcsc;
192 delete dhwtgc;
193 delete dhwtgcall;
194 delete dhalin;
195 delete dhacut;
196 delete dhwded;
197 delete dhwspa;
198 delete dhwsup;
199 delete dhwchv;
200 delete dhwcro;
201 delete dhwcmi;
202 delete dhwlbi;
203 }
204
205
206 void RDBReaderAtlas::ProcessTechnologies()
207 {
208 MsgStream log(m_msgSvc, "MuGM:ProcTechnol.s");
209
210 std::vector<std::string> slist;
211 slist.push_back("*");
212 StationSelector sel(slist);
213 StationSelector::StationIterator it;
214 log<<MSG::DEBUG<<" from RDBReaderAtlas --- start "<<endreq;
215
216
217 bool have_spa_details = (getGeometryVersion().substr(0,1) != "P");
218
219 for ( it = sel.begin(); it != sel.end(); it++ )
220 {
221 Station *station = (*it).second;
222 for ( int ic = 0; ic< station->GetNrOfComponents(); ic++ )
223 {
224 Component* c = station->GetComponent(ic);
225 if (c == NULL) continue;
226 std::string cname = c->name;
227 if (cname.substr(0,3) == "CSC") MuonGM::ProcessCSC(dhwcsc, wcsc, cname);
228 else if (cname.substr(0,3) == "MDT") MuonGM::ProcessMDT(dhwmdt, wmdt, cname);
229 else if (cname.substr(0,3) == "RPC") MuonGM::ProcessRPC(dhwrpc, wrpc, dhwrpcall, wrpcall, cname);
230 else if (cname.substr(0,3) == "TGC") MuonGM::ProcessTGC(dhwtgc, wtgc, dhwtgcall, wtgcall, cname);
231 else if (cname.substr(0,3) == "SPA") MuonGM::ProcessSPA(dhwspa, wspa, cname);
232 else if (cname.substr(0,3) == "DED") MuonGM::ProcessDED(dhwded, wded, cname);
233 else if (cname.substr(0,3) == "SUP") MuonGM::ProcessSUP(dhwsup, wsup, cname);
234 else if (cname.substr(0,3) == "CHV" && have_spa_details) MuonGM::ProcessCHV(dhwchv, wchv, cname);
235 else if (cname.substr(0,3) == "CRO" && have_spa_details) MuonGM::ProcessCRO(dhwcro, wcro, cname);
236 else if (cname.substr(0,3) == "CMI" && have_spa_details) MuonGM::ProcessCMI(dhwcmi, wcmi, cname);
237 else if (cname.substr(0,2) == "LB" && have_spa_details) MuonGM::ProcessLBI(dhwlbi, wlbi, cname);
238 }
239 }
240
241 log<<MSG::INFO<<"nMDT "<<nmdt<<" nCSC "<<ncsc<<" nTGC "<<ntgc<<" nRPC "<<nrpc<<endreq;
242 log<<MSG::INFO<<"nDED "<<nded<<" nSUP "<<nsup<<" nSPA "<<nspa<<endreq;
243 log<<MSG::INFO<<"nCHV "<<nchv<<" nCRO "<<ncro<<" nCMI "<<ncmi<<" nLBI "<<nlbi<<endreq;
244
245 }
246
247 void RDBReaderAtlas::ProcessTGCreadout () {
248
249 MsgStream log(m_msgSvc, "MuGM:RDBReadAtlas");
250
251 if (getGeometryVersion().substr(0,1) == "P")
252 {
253
254
255 const IRDBRecordset *ggsd = m_pRDBAccess->getRecordset("GGSD",_geoTag,_geoNode);
256 const IRDBRecordset *ggcd = m_pRDBAccess->getRecordset("GGCD",_geoTag,_geoNode);
257 log<<MSG::INFO
258 <<"RDBReaderAtlas::ProcessTGCreadout GGSD, GGCD retrieven from Oracle"<<endreq;
259
260
261 int version = (int) (*ggsd)[0]->getDouble("VERS");
262 float wirespacing = (*ggsd)[0]->getDouble("WIRESP")*cm;
263 log<<MSG::INFO
264 <<" ProcessTGCreadout - version "<<version<<" wirespacing "<<wirespacing<<endreq;
265
266
267
268
269
270
271 for (unsigned int ich=0; ich<ggcd->size(); ++ich)
272 {
273 int type = (int)(*ggcd)[ich]->getDouble("ICHTYP");
274 if (ich<19)
275 {
276 std::string name=RDBReaderAtlas::TGCreadoutName(type);
277
278
279
280
281
282 int nchrng = (int) (*ggcd)[ich]->getDouble("NCHRNG");
283 std::vector<float> nwgs,roffst,poffst,nsps;
284 std::vector<float> iwgs1(180), iwgs2(180), iwgs3(180);
285
286 for (int i=0;i<3;i++) {
287 std::ostringstream Astr;
288 Astr <<"_" << i;
289 std::string A=Astr.str();
290 nwgs.push_back((*ggcd)[ich]->getDouble("NWGS"+A));
291 roffst.push_back((*ggcd)[ich]->getDouble("ROFFST"+A));
292 poffst.push_back((*ggcd)[ich]->getDouble("POFFST"+A));
293 nsps.push_back((*ggcd)[ich]->getDouble("NSPS"+A));
294 }
295 for (int i=0;i<nwgs[0];i++) {
296 std::ostringstream Astr;
297 Astr <<"_" << i;
298 std::string A=Astr.str();
299
300 iwgs1[i] = (float)(*ggcd)[ich]->getDouble("IWGS1"+A);
301 }
302 for (int i=0;i<nwgs[1];i++) {
303 std::ostringstream Astr;
304 Astr <<"_" << i;
305 std::string A=Astr.str();
306 iwgs2[i] = (float)(*ggcd)[ich]->getDouble("IWGS2"+A);
307 }
308 for (int i=0;i<nwgs[2];i++) {
309 std::ostringstream Astr;
310 Astr <<"_" << i;
311 std::string A=Astr.str();
312 iwgs3[i] = (float)(*ggcd)[ich]->getDouble("IWGS3"+A);
313 }
314 TgcReadoutParams* rpar = new TgcReadoutParams(name, type, version, wirespacing,
315 nchrng,
316 &(nwgs[0]),
317 &(iwgs1[0]),
318 &iwgs2[0],
319 &iwgs3[0],
320 &roffst[0],
321 &nsps[0],
322 &poffst[0], _mgr->msgSvc());
323 MYSQL::GetPointer()->StoreTgcRPars(rpar);
324 _mgr->storeTgcReadoutParams(rpar);
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346 }
347 }
348
349 }
350 else
351 {
352
353
354
355 const IRDBRecordset *ggln;
356
357
358 ggln = m_pRDBAccess->getRecordset("GGLN",_geoTag,_geoNode);
359
360 int version = (int) (*ggln)[0]->getInt("VERS");
361 float wirespacing = (*ggln)[0]->getFloat("WIRESP")*mm;
362 log<<MSG::INFO
363 <<" ProcessTGCreadout - version "<<version<<" wirespacing "<<wirespacing<<endreq;
364
365 MYSQL *mysql=MYSQL::GetPointer();
366
367
368 for (unsigned int ich=0; ich<ggln->size(); ++ich)
369 {
370 int type = (int)(*ggln)[ich]->getInt("JSTA");
371
372
373 std::string oldname=RDBReaderAtlas::TGCreadoutName(type);
374 std::string name="TGCReadout"+MuonGM::buildString(type,2);
375
376
377
378
379 int nchrng;
380 if (type == 1 || type == 6 || type == 12 || type >= 18) {
381 nchrng = 24;
382 }
383 else {
384 nchrng = 48;
385 }
386 std::vector<float> nwgs,roffst,poffst,nsps;
387 std::vector<float> iwgs1(130), iwgs2(130), iwgs3(130), slarge(33), sshort(33);
388
389 for (int i=0;i<3;i++) {
390 std::ostringstream Astr;
391 Astr <<"_" << i;
392 std::string A=Astr.str();
393 nwgs.push_back((*ggln)[ich]->getInt("NWGS"+A));
394 roffst.push_back((*ggln)[ich]->getInt("ROFFST"+A));
395
396 poffst.push_back(0);
397 nsps.push_back((*ggln)[ich]->getInt("NSPS"+A));
398 }
399 for (int i=0;i<nwgs[0];i++) {
400 std::ostringstream Astr;
401 Astr <<"_" << i;
402 std::string A=Astr.str();
403
404 iwgs1[i] = (float)(*ggln)[ich]->getInt("IWGS1"+A);
405 }
406 for (int i=0;i<nwgs[1];i++) {
407 std::ostringstream Astr;
408 Astr <<"_" << i;
409 std::string A=Astr.str();
410 iwgs2[i] = (float)(*ggln)[ich]->getInt("IWGS2"+A);
411 }
412 for (int i=0;i<nwgs[2];i++) {
413 std::ostringstream Astr;
414 Astr <<"_" << i;
415 std::string A=Astr.str();
416 iwgs3[i] = (float)(*ggln)[ich]->getInt("IWGS3"+A);
417 }
418
419
420
421 float pdist = (*ggln)[ich]->getFloat("PDIST");
422
423 for (int i=0;i<nsps[0]+1;i++) {
424 std::ostringstream Astr;
425 Astr <<"_" << i;
426 std::string A=Astr.str();
427 slarge[i] = (float)(*ggln)[ich]->getFloat("SLARGE"+A);
428 sshort[i] = (float)(*ggln)[ich]->getFloat("SHORT"+A);
429 }
430
431
432
433 TgcReadoutParams* rpar = new TgcReadoutParams(name, type, version, wirespacing,
434 nchrng,
435 &(nwgs[0]),
436 &(iwgs1[0]),
437 &iwgs2[0],
438 &iwgs3[0],
439 pdist,
440 &slarge[0],
441 &sshort[0],
442 &roffst[0],
443 &nsps[0],
444 &poffst[0], _mgr->msgSvc());
445 MYSQL::GetPointer()->StoreTgcRPars(rpar);
446 _mgr->storeTgcReadoutParams(rpar);
447
448
449
450 std::ostringstream Astr;
451 if (ich < 9) {
452 Astr << "0" << ich+1;
453 }
454 else {
455 Astr << ich+1;
456 }
457 std::string A = Astr.str();
458 TGC *tgc = (TGC*) mysql->GetTechnology("TGC"+A);
459 tgc->widthWireSupport = (*ggln)[ich]->getFloat("S1PP");
460 tgc->widthGasChannel = (*ggln)[ich]->getFloat("S2PP");
461 tgc->distanceWireSupport = (*ggln)[ich]->getFloat("WSEP");
462 tgc->offsetWireSupport[0] = (*ggln)[ich]->getFloat("SP1WI");
463 tgc->offsetWireSupport[1] = (*ggln)[ich]->getFloat("SP2WI");
464 tgc->offsetWireSupport[2] = (*ggln)[ich]->getFloat("SP3WI");
465 tgc->angleTilt = (*ggln)[ich]->getFloat("TILT")*deg;
466 tgc->radiusButton = (*ggln)[ich]->getFloat("SP1BU");
467 tgc->pitchButton[0] = (*ggln)[ich]->getFloat("SP2BU");
468 tgc->pitchButton[1] = (*ggln)[ich]->getFloat("SP3BU");
469 tgc->angleButton = (*ggln)[ich]->getFloat("SP4BU")*deg;
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495 }
496 }
497
498 }
499
500 std::string RDBReaderAtlas::TGCreadoutName(int ichtyp)
501 {
502
503 if (getGeometryVersion().substr(0,1) == "P")
504 {
505
506 if ( _tgcReadoutMapping.size() == 0)
507 {
508
509 _tgcReadoutMapping.push_back("T1F1");
510
511 _tgcReadoutMapping.push_back("T1E1");
512 _tgcReadoutMapping.push_back("T1E2");
513 _tgcReadoutMapping.push_back("T1E3");
514 _tgcReadoutMapping.push_back("T1E4");
515
516 _tgcReadoutMapping.push_back("T2F1");
517
518 _tgcReadoutMapping.push_back("T2E1");
519 _tgcReadoutMapping.push_back("T2E2");
520 _tgcReadoutMapping.push_back("T2E3");
521 _tgcReadoutMapping.push_back("T2E4");
522 _tgcReadoutMapping.push_back("T2E5");
523
524 _tgcReadoutMapping.push_back("T3F1");
525
526 _tgcReadoutMapping.push_back("T3E1");
527 _tgcReadoutMapping.push_back("T3E2");
528 _tgcReadoutMapping.push_back("T3E3");
529 _tgcReadoutMapping.push_back("T3E4");
530 _tgcReadoutMapping.push_back("T3E5");
531
532 _tgcReadoutMapping.push_back("T4F1");
533
534 _tgcReadoutMapping.push_back("T4E1");
535 }
536
537 if (ichtyp<1 || ichtyp>19) {
538 std::cerr<<" DBReader::TGCreadoutName - ichtype "
539 <<ichtyp<<" out of range 1-19"<<std::endl;
540 return "XXXY";
541 }
542 }
543 else
544 {
545
546
547 if ( _tgcReadoutMapping.size() == 0)
548 {
549
550 _tgcReadoutMapping.push_back("T1F1_1");
551
552 _tgcReadoutMapping.push_back("T1E1_1");
553 _tgcReadoutMapping.push_back("T1E1_2");
554 _tgcReadoutMapping.push_back("T1E1_3");
555 _tgcReadoutMapping.push_back("T1E1_4");
556
557 _tgcReadoutMapping.push_back("T2F1_1");
558
559 _tgcReadoutMapping.push_back("T2E1_1");
560 _tgcReadoutMapping.push_back("T2E1_2");
561 _tgcReadoutMapping.push_back("T2E1_3");
562 _tgcReadoutMapping.push_back("T2E1_4");
563 _tgcReadoutMapping.push_back("T2E1_5");
564
565 _tgcReadoutMapping.push_back("T3F1_1");
566
567 _tgcReadoutMapping.push_back("T3E1_1");
568 _tgcReadoutMapping.push_back("T3E1_2");
569 _tgcReadoutMapping.push_back("T3E1_3");
570 _tgcReadoutMapping.push_back("T3E1_4");
571 _tgcReadoutMapping.push_back("T3E1_5");
572
573 _tgcReadoutMapping.push_back("T4F1_1");
574 _tgcReadoutMapping.push_back("T4F2_1");
575
576 _tgcReadoutMapping.push_back("T4E1_1");
577 _tgcReadoutMapping.push_back("T4E2_1");
578 }
579
580 if (ichtyp<1 || ichtyp>21) {
581 std::cerr<<" DBReader::TGCreadoutName - ichtype "
582 <<ichtyp<<" out of range 1-21"<<std::endl;
583 return "XXXY";
584 }
585 }
586
587
588
589 return _tgcReadoutMapping[ichtyp-1];
590 }
591
592
593 }
594
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|