94 {
96
97 int mem = 0;
98 float cpu = 0;
99 int umem = 0;
100 float ucpu = 0;
101 std::ofstream geoModelStats;
103 geoModelStats.open("MuonGeoModelStatistics_MuonDetectorFactory");
104
105 mem = GeoPerfUtils::getMem();
106 cpu =
int(GeoPerfUtils::getCpu() / 100.);
107
108 geoModelStats << "At MuonDetectorFactory::create entry point: \t SZ= " << mem << " Kb \t Time = " << cpu << " seconds " << std::endl;
109
110 umem = GeoPerfUtils::getMem();
111 ucpu =
int(GeoPerfUtils::getCpu() / 100.);
112 geoModelStats << "At MuonDetectorFactory::resetting to 0: \t SZ= " << umem - mem << " Kb \t Time = " << ucpu - cpu << " seconds " << std::endl;
113 mem = umem;
114 cpu = ucpu;
115 }
116
119
120
123 log << MSG::INFO <<
"MuonLayout set to <" <<
m_layout <<
"> = Development version for DC3 - infrastructures " <<
endmsg;
125
126
127
128
129
131
134
135 log << MSG::INFO <<
"Manager created for geometry version " <<
m_manager->geometryVersion() <<
" from DB MuonVersion <" <<
m_manager->get_DBMuonVersion() <<
">" <<
endmsg;
136
137
141
142
144
145
146 log << MSG::INFO <<
"MDTIDHELPER retrieved from DetStore" <<
endmsg;
147 log << MSG::INFO <<
"RPCIDHELPER retrieved from DetStore" <<
endmsg;
148 log << MSG::INFO <<
"TGCIDHELPER retrieved from DetStore" <<
endmsg;
149
151 log << MSG::INFO <<
"CSCIDHELPER retrieved from DetStore" <<
endmsg;
152 }
154 log << MSG::INFO <<
"STGCIDHELPER retrieved from DetStore" <<
endmsg;
155 }
157 log << MSG::INFO <<
"MMIDHELPER retrieved from DetStore" <<
endmsg;
158 }
159
161 umem = GeoPerfUtils::getMem();
162 ucpu =
int(GeoPerfUtils::getCpu() / 100.);
163 geoModelStats << "At MuonDetectorFactory::IdHelpers loaded \t SZ= " << umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = " << umem - mem
164 << " \t Delta T =" << ucpu - cpu << std::endl;
165 mem = umem;
166 cpu = ucpu;
167 }
168
169 log << MSG::INFO <<
" **************** MuonDetectorFactory001 ************************" <<
endmsg;
170 log <<
" *** Start building the Muon Geometry Tree **********************" <<
endmsg;
171
172 std::string OracleTag =
m_DBkey;
174
175 if (
log.level() <= MSG::DEBUG)
176 log << MSG::DEBUG <<
"calling RDBReaderAtlas with m_altAsciiDBMap" <<
endmsg;
177
179
180
181
182
183
186
189 sc =
dbr->ProcessDB(*mysql);
190 if (
sc != StatusCode::SUCCESS) {
191 log << MSG::ERROR <<
" FAILURE in DB access; Muon node will not be built" <<
endmsg;
192 return;
193 }
194
196 umem = GeoPerfUtils::getMem();
197 ucpu =
int(GeoPerfUtils::getCpu() / 100.);
198 geoModelStats << "At MuonDetectorFactory::DB read \t SZ= " << umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = " << umem - mem
199 << " \t Delta T =" << ucpu - cpu << std::endl;
200 mem = umem;
201 cpu = ucpu;
202 }
203
204 StoredMaterialManager *theMaterialManager;
205 if (StatusCode::SUCCESS !=
m_pDetStore->retrieve(theMaterialManager,
"MATERIALS")) {
206 return;
207 } else {
208 log << MSG::INFO <<
" theMaterialManager retrieven successfully from the DetStore" <<
endmsg;
209 }
210
211 const GeoMaterial *m4 = theMaterialManager->
getMaterial(
"std::Air");
212 GeoLogVol *l4;
213 GeoPcon *c4 = new GeoPcon(0, 360 * Gaudi::Units::deg);
214
215
216
217
219
220
221
222 if (muonSysRec->
size() == 0) {
223 muonSysRec =
m_pRDBAccess->getRecordsetPtr(
"MuonSystem",
"MuonSystem-00");
224 log << MSG::INFO <<
"MuonSystem description from default node in GeomDB, i.e. MuonSystem-00" <<
endmsg;
225 } else {
226 log << MSG::INFO <<
"MuonSystem description from OracleTag=<" << OracleTag <<
"> and node=<" << OracleNode <<
">" <<
endmsg;
227 }
228
229
230 if (muonSysRec->
size() != 0) {
231
233 muonsysIndMap::const_iterator
iter;
234 const IRDBRecord *currentRecord;
235
236
237 for (
unsigned int ind = 0; ind < muonSysRec->
size(); ind++) {
238 int key = (*muonSysRec)[ind]->getInt(
"PLANE_ID");
240 }
241
242
243 for (unsigned int ind = 0; ind < indmap.size(); ind++) {
244 iter = indmap.find(ind);
245
246 if (iter == indmap.end()) {
247 throw std::runtime_error("Error in MuonDetectorFactory, missing plane in MuonSystem");
248 } else {
249 currentRecord = (*muonSysRec)[(*iter).second];
251 }
252 }
253 } else {
254
255 log << MSG::INFO <<
"MuonSystem description not available in GeomDB - using hard-wired description" <<
endmsg;
256
257 double ir =
m_muon->barrelInnerRadius;
258 double pir =
m_muon->innerRadius;
259 double orad =
m_muon->outerRadius;
262
263 double extraR =
m_muon->extraR;
264 double extraZ =
m_muon->extraZ;
265
266 c4->addPlane(-l, pir, extraR);
267 c4->addPlane(-extraZ, pir, extraR);
268 c4->addPlane(-extraZ, pir, orad);
269
270 c4->addPlane(-eff, pir, orad);
271 c4->addPlane(-eff,
ir, orad);
272 c4->addPlane(+eff,
ir, orad);
273 c4->addPlane(+eff, pir, orad);
274
275 c4->addPlane(extraZ, pir, orad);
276 c4->addPlane(extraZ, pir, extraR);
277 c4->addPlane(l, pir, extraR);
278 }
279
280
281 l4 = new GeoLogVol("MuonSys", c4, m4);
282
283 GeoPhysVol *p4 = new GeoPhysVol(l4);
284
285
286
287
288
289
291 log << MSG::INFO <<
" TreeTop added to the Manager" <<
endmsg;
293
294 std::vector<std::string> slist;
296 slist.emplace_back("*");
297 else
299
300
301 std::unique_ptr<FPVMAP> savemem = std::make_unique< FPVMAP>();
302
303 int nstat_ss = 0;
304 int ntpos_ss = 0;
305 int npos_ss = 0;
306 int nAssemblies = 0;
308 log << MSG::INFO <<
"Fine Clash Fixing enabled: (should be ON/OFF for Simulation/Reconstruction)" <<
endmsg;
309 } else {
310 log << MSG::INFO <<
"Fine Clash Fixing disabled: (should be ON/OFF for Simulation/Reconstruction)" <<
endmsg;
311 }
312
313 StationSelector
sel(*mysql, slist);
315
316 for (it =
sel.begin(); it !=
sel.end(); ++it) {
317 Station *station = (*it).second;
318 std::string stname(station->GetName(), 0, 3);
320 if (
log.level() <= MSG::VERBOSE) {
321 log << MSG::VERBOSE <<
"Processing Stations named <" << station->GetName() <<
"> " << nstat_ss <<
" built until now" <<
endmsg;
322 }
323 }
324
326 continue;
327
328 bool isAssembly = false;
329 if (station->GetNrOfCutouts() > 0 && stname.substr(0, 1) != "T")
330 isAssembly = true;
331
332
333 if (stname == "BIR")
334 isAssembly = true;
335
336 MuonChamber
l(*mysql, station);
337 l.setFPVMAP(savemem.get());
339
343 npos_ss = 0;
344 for (pit = station->begin(); pit != station->end(); ++pit) {
345 int zi = (*pit).second.zindex;
346 int fi = (*pit).second.phiindex;
348 if (zi)
350
351
353 bool selectedEta = false;
355 if (zi == *i) {
356 selectedEta = true;
357 break;
358 }
359 }
360
361 if (!selectedEta)
362 continue;
363 }
364
365
367 bool selectedPhi = false;
369 if ((fi + 1) == *i) {
370 selectedPhi = true;
371 break;
372 }
373 }
374
375 if (!selectedPhi)
376 continue;
377 }
378
379
380 ntpos_ss++;
381
382 npos_ss++;
383
385 log << MSG::INFO <<
"Build selected Station <" << station->GetName() <<
"> at Jzz = " << zi <<
" Jff = " << fi + 1 <<
" ******* " << nstat_ss
386 <<
" stat.types built until now" <<
endmsg;
387 }
388
389
390 GeoNameTag *
nm =
new GeoNameTag(station->GetName() +
"_station");
391
392 bool is_mirrored = ((*pit).second).isMirrored;
393 int mirsign = 0;
394 if (zi < 0 && !is_mirrored)
395 mirsign = 1;
396 if (stname == "CSL")
397 isAssembly = true;
398
399
400 GeoVPhysVol *
pv =
l.build(*theMaterialManager, *mysql,
getDetectorManager(), zi, fi, is_mirrored, isAssembly);
401 if (isAssembly)
402 nAssemblies++;
403
404
407 if (zi < 0)
409 int geoid = (
sideC * 10000 + mirsign * 1000 + abs(zi) * 100 + fi + 1) * 100000;
410 if (
log.level() <= MSG::DEBUG) {
411 log << MSG::DEBUG <<
"Adding Station with nameTag=<" << station->GetName() +
"_station"
412 <<
"> and geoId " << geoid <<
endmsg;
413 }
414 p4->add(new GeoIdentifierTag(geoid));
415 } else {
416 int geoid = (mirsign * 1000 + abs(zi) * 100 + fi + 1) *
sign;
417 p4->add(new GeoIdentifierTag(geoid));
418 if (
log.level() <= MSG::DEBUG) {
419 log << MSG::DEBUG <<
"Adding Station with nameTag=<" << station->GetName() +
"_station"
420 <<
"> and geoId " << geoid <<
" for zi/fi = " << zi <<
"/" << fi <<
endmsg;
421 }
422 }
423
424
425 MuonStation *mst =
m_manager->getMuonStation(station->GetName(), zi, fi + 1);
426 if (!mst) {
427 log << MSG::WARNING <<
"For Station with nameTag=<" << station->GetName() <<
"> at zi/fi = " << zi <<
"/" << fi
428 <<
" no MuonStation found => no possibility to align" <<
endmsg;
429 continue;
430 }
431
432 GeoTrf::Transform3D tsz_to_szt = GeoTrf::RotateZ3D(-90 * Gaudi::Units::degree) * GeoTrf::RotateY3D(-90 * Gaudi::Units::degree);
433 GeoTrf::Transform3D nativeToAmdbLRS=tsz_to_szt * station->native_to_tsz_frame(*mysql, (*pit).second);
434
435 mst->setNativeToAmdbLRS(nativeToAmdbLRS);
436 mst->setNominalAmdbLRSToGlobal(station->tsz_to_global_frame(*mysql, (*pit).second) * tsz_to_szt.inverse());
437
438
439
440
441
442
443
444 int nAlines = station->CountAlignPos(zi, fi);
445
447
448
449
450 GeoAlignableTransform *xf = new GeoAlignableTransform(station->getNominalTransform(*mysql, (*pit).second));
451
452
453 p4->add(nm);
454 p4->add(xf);
455 p4->add(pv);
456
457
458 mst->setTransform(xf);
459 GeoTrf::Transform3D tsz_to_szt = GeoTrf::RotateZ3D(-90 * Gaudi::Units::degree) * GeoTrf::RotateY3D(-90 * Gaudi::Units::degree);
460
461 mst->setNativeToAmdbLRS(tsz_to_szt * station->native_to_tsz_frame(*mysql, (*pit).second));
462 mst->setNominalAmdbLRSToGlobal(station->tsz_to_global_frame(*mysql, (*pit).second) * tsz_to_szt.inverse());
463
464 mst->setDeltaAmdbLRS(GeoTrf::Transform3D::Identity());
465
466 } else if (nAlines ==1) {
469
471 ap = acurrent->second;
472
473 if (
ap.phiindex != fi ||
ap.zindex != zi) {
474 log << MSG::ERROR <<
"Inconsistent AlignedPosition found in the static Geometry DB: aligPos.fi, zi = " <<
ap.phiindex <<
", " <<
ap.zindex
475 <<
" for station " << station->GetName() <<
" at fi/zi = " << fi <<
"/" << zi <<
" AlignPos indices fi/zi " << fi <<
"/" << zi <<
endmsg;
476 }
477
478 if (
ap.jobindex == 0) {
479
480 if (
log.level() <= MSG::DEBUG) {
481 log << MSG::DEBUG <<
"Going to set delta from A-line for station" << stname <<
" at zi/fi " << zi <<
"/" << fi <<
endmsg;
482 log << MSG::DEBUG <<
"A-line is: " <<
ap.tras <<
" " <<
ap.traz <<
" " <<
ap.trat <<
" " <<
ap.rots <<
" " <<
ap.rotz <<
" " <<
ap.rott <<
endmsg;
483 }
484
485
486
487 GeoTrf::Transform3D delta_amdb =
488 GeoTrf::TranslateX3D(
ap.tras) * GeoTrf::TranslateY3D(
ap.traz) * GeoTrf::TranslateZ3D(
ap.trat) *
489 GeoTrf::RotateX3D(
ap.rots) * GeoTrf::RotateY3D(
ap.rotz) * GeoTrf::RotateZ3D(
ap.rott);
490
491 GeoTrf::Transform3D tsz_to_szt = GeoTrf::RotateZ3D(-90 * Gaudi::Units::degree) * GeoTrf::RotateY3D(-90 * Gaudi::Units::degree);
492 GeoTrf::Transform3D nominalTransform=station->getNominalTransform(*mysql, (*pit).second);
493 GeoTrf::Transform3D native_to_amdbl=tsz_to_szt * station->native_to_tsz_frame(*mysql, (*pit).second);
494 GeoAlignableTransform *xf = new GeoAlignableTransform(nominalTransform*native_to_amdbl.inverse()*delta_amdb*native_to_amdbl);
495
496
497 p4->add(nm);
498 p4->add(xf);
499 p4->add(pv);
500
501
502
503 mst->setTransform(xf);
504 mst->setNativeToAmdbLRS(tsz_to_szt * station->native_to_tsz_frame(*mysql, (*pit).second));
505 mst->setNominalAmdbLRSToGlobal(station->tsz_to_global_frame(*mysql, (*pit).second) * tsz_to_szt.inverse());
506 mst->setDeltaAmdbLRS(GeoTrf::Transform3D::Identity());
507
508
509 }
510 }
511 }
512 else {
513 }
514 }
515
516
517 if (npos_ss > 0)
518 nstat_ss++;
519 }
520
521 log << MSG::INFO <<
" **************** MuonDetectorFactory001 ****************************" <<
endmsg <<
" *** The Muon Chamber Geometry Tree is built with " <<
endmsg
522 <<
" *** " << p4->getNChildVols() <<
" child volumes " <<
endmsg <<
" *** " << savemem->NDetectors() <<
" independent elements and " <<
endmsg <<
" *** "
523 << savemem->NDetectorsReused() <<
" elements cloned or shared " <<
endmsg <<
" *** " << nstat_ss <<
" kinds of stations" <<
endmsg <<
" *** " << ntpos_ss
524 <<
" stations with alignable transforms" <<
endmsg <<
" *** " << nAssemblies <<
" stations are described as Assemblies" <<
endmsg <<
" *** "
526 <<
" MDT Detector Elements " <<
endmsg <<
" *** \t " <<
m_manager->nCscRE() <<
" CSC Readout Elements \t " <<
m_manager->nCscDE() <<
" CSC Detector Elements " <<
endmsg
527 <<
" *** \t " <<
m_manager->nRpcRE() <<
" RPC Readout Elements \t " <<
m_manager->nRpcDE() <<
" RPC Detector Elements " <<
endmsg <<
" *** \t " <<
m_manager->nTgcRE()
528 <<
" TGC Readout Elements \t " <<
m_manager->nTgcDE() <<
" TGC Detector Elements " <<
endmsg <<
" ********************************************************************"
530
532 umem = GeoPerfUtils::getMem();
533 ucpu =
int(GeoPerfUtils::getCpu() / 100.);
534 geoModelStats << "At MuonDetectorFactory::active geo done \t SZ= " << umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = " << umem - mem
535 << " \t Delta T =" << ucpu - cpu << std::endl;
536 mem = umem;
537 cpu = ucpu;
538 }
539
540
541
543
545 umem = GeoPerfUtils::getMem();
546 ucpu =
int(GeoPerfUtils::getCpu() / 100.);
547 geoModelStats << "At MuonDetectorFactory::released access.mem \t SZ= " << umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = " << umem - mem
548 << " \t Delta T =" << ucpu - cpu << std::endl;
549 mem = umem;
550 cpu = ucpu;
551 }
552
553 GeoNameTag *ntg = new GeoNameTag("Muon");
554 world->add(ntg);
555 world->add(p4);
556
557 log << MSG::INFO <<
" *** Inert Material built according to DB switches and config. ****** " <<
endmsg;
558 log << MSG::INFO <<
" *** The Muon Geometry Tree has " << p4->getNChildVols() <<
" child vol.s in total ********" <<
endmsg
559 << " ********************************************************************\n"
561
563 umem = GeoPerfUtils::getMem();
564 ucpu =
int(GeoPerfUtils::getCpu() / 100.);
565 geoModelStats << "At MuonDetectorFactory::inert geo done \t SZ= " << umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = " << umem - mem
566 << " \t Delta T =" << ucpu - cpu << std::endl;
567 mem = umem;
568 cpu = ucpu;
569
570 geoModelStats.close();
571 }
572 }
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
std::map< int, unsigned int, std::less< int > > muonsysIndMap
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
virtual unsigned int size() const =0
void set_amdb_from_RDB(bool)
void setGeometryVersion(const std::string &s)
static LockedMYSQL GetPointer()
CxxUtils::LockedPointer< MYSQL > LockedMYSQL
bool BEEShiftDisabled() const
int m_enableFineClashFixing
std::string m_DBMuonVersion
std::vector< std::string > m_selectedStations
AltAsciiDBMap m_altAsciiDBMap
virtual const MuonDetectorManager * getDetectorManager() const override
std::vector< int > m_selectedStEta
MuonDetectorManager * m_manager
std::vector< int > m_selectedStPhi
bool m_dumpMemoryBreakDown
IRDBAccessSvc * m_pRDBAccess
StationMap::const_iterator StationIterator
virtual const GeoMaterial * getMaterial(const std::string &name)=0
int ir
counter of the current depth
::StatusCode StatusCode
StatusCode definition for legacy code.
std::multimap< int, AlignPos, std::less< int > >::const_iterator AlignPosIterator
std::map< int, Position, std::less< int > >::const_iterator PositionIterator
l
Printing final latex table to .tex output file.
unsigned int constexpr sideC