8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/SystemOfUnits.h"
10 #include "GeoGenericFunctions/Variable.h"
12 #include "GeoModelKernel/GeoAlignableTransform.h"
13 #include "GeoModelKernel/GeoBox.h"
14 #include "GeoModelKernel/GeoDefinitions.h"
15 #include "GeoModelKernel/GeoFullPhysVol.h"
16 #include "GeoModelKernel/GeoIdentifierTag.h"
17 #include "GeoModelKernel/GeoLogVol.h"
18 #include "GeoModelKernel/GeoMaterial.h"
19 #include "GeoModelKernel/GeoNameTag.h"
20 #include "GeoModelKernel/GeoPcon.h"
21 #include "GeoModelKernel/GeoPerfUtils.h"
22 #include "GeoModelKernel/GeoPgon.h"
23 #include "GeoModelKernel/GeoPhysVol.h"
24 #include "GeoModelKernel/GeoSerialTransformer.h"
25 #include "GeoModelKernel/GeoShapeShift.h"
26 #include "GeoModelKernel/GeoShapeSubtraction.h"
27 #include "GeoModelKernel/GeoShapeUnion.h"
28 #include "GeoModelKernel/GeoTransform.h"
29 #include "GeoModelKernel/GeoTrap.h"
30 #include "GeoModelKernel/GeoTrd.h"
31 #include "GeoModelKernel/GeoTube.h"
61 using namespace GeoXF;
63 #define skip_chambers false
64 #define skip_toroids false
65 #define skip_shielding false
66 #define skip_caloSaddle true
67 #define useAssemblies false
71 MuonDetectorFactory001::MuonDetectorFactory001(
StoreGateSvc *pDetStore):
73 m_pDetStore{pDetStore} {
85 log << MSG::INFO <<
"MuonDetectorFactory - constructor "
86 <<
" MuonSystem OuterRadius " << m_muon->outerRadius <<
" Length " << m_muon->length <<
endmsg;
101 std::ofstream geoModelStats;
103 geoModelStats.open(
"MuonGeoModelStatistics_MuonDetectorFactory");
105 mem = GeoPerfUtils::getMem();
108 geoModelStats <<
"At MuonDetectorFactory::create entry point: \t SZ= " << mem <<
" Kb \t Time = " << cpu <<
" seconds " << std::endl;
110 umem = GeoPerfUtils::getMem();
112 geoModelStats <<
"At MuonDetectorFactory::resetting to 0: \t SZ= " << umem - mem <<
" Kb \t Time = " << ucpu - cpu <<
" seconds " << std::endl;
123 log << MSG::INFO <<
"MuonLayout set to <" <<
m_layout <<
"> = Development version for DC3 - infrastructures " <<
endmsg;
139 mysql->setGeometryVersion(
m_layout);
140 mysql->set_amdb_from_RDB(
m_rdb == 1);
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;
151 log << MSG::INFO <<
"CSCIDHELPER retrieved from DetStore" <<
endmsg;
154 log << MSG::INFO <<
"STGCIDHELPER retrieved from DetStore" <<
endmsg;
157 log << MSG::INFO <<
"MMIDHELPER retrieved from DetStore" <<
endmsg;
161 umem = GeoPerfUtils::getMem();
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;
169 log << MSG::INFO <<
" **************** MuonDetectorFactory001 ************************" <<
endmsg;
170 log <<
" *** Start building the Muon Geometry Tree **********************" <<
endmsg;
172 std::string OracleTag =
m_DBkey;
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;
196 umem = GeoPerfUtils::getMem();
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;
205 if (StatusCode::SUCCESS !=
m_pDetStore->retrieve(theMaterialManager,
"MATERIALS")) {
208 log << MSG::INFO <<
" theMaterialManager retrieven successfully from the DetStore" <<
endmsg;
211 const GeoMaterial *m4 = theMaterialManager->
getMaterial(
"std::Air");
222 if (muonSysRec->size() == 0) {
224 log << MSG::INFO <<
"MuonSystem description from default node in GeomDB, i.e. MuonSystem-00" <<
endmsg;
226 log << MSG::INFO <<
"MuonSystem description from OracleTag=<" << OracleTag <<
"> and node=<" << OracleNode <<
">" <<
endmsg;
230 if (muonSysRec->size() != 0) {
233 muonsysIndMap::const_iterator iter;
237 for (
unsigned int ind = 0;
ind < muonSysRec->size();
ind++) {
238 int key = (*muonSysRec)[
ind]->getInt(
"PLANE_ID");
243 for (
unsigned int ind = 0;
ind < indmap.size();
ind++) {
244 iter = indmap.find(
ind);
246 if (iter == indmap.end()) {
247 throw std::runtime_error(
"Error in MuonDetectorFactory, missing plane in MuonSystem");
249 currentRecord = (*muonSysRec)[(*iter).second];
255 log << MSG::INFO <<
"MuonSystem description not available in GeomDB - using hard-wired description" <<
endmsg;
257 double ir =
m_muon->barrelInnerRadius;
258 double pir =
m_muon->innerRadius;
259 double orad =
m_muon->outerRadius;
263 double extraR =
m_muon->extraR;
264 double extraZ =
m_muon->extraZ;
266 c4->addPlane(-
l, pir, extraR);
267 c4->addPlane(-extraZ, pir, extraR);
268 c4->addPlane(-extraZ, pir, orad);
270 c4->addPlane(-
eff, pir, orad);
271 c4->addPlane(-
eff,
ir, orad);
272 c4->addPlane(+
eff,
ir, orad);
273 c4->addPlane(+
eff, pir, orad);
275 c4->addPlane(extraZ, pir, orad);
276 c4->addPlane(extraZ, pir, extraR);
277 c4->addPlane(
l, pir, extraR);
281 l4 =
new GeoLogVol(
"MuonSys", c4, m4);
283 GeoPhysVol *p4 =
new GeoPhysVol(l4);
291 log << MSG::INFO <<
" TreeTop added to the Manager" <<
endmsg;
294 std::vector<std::string> slist;
296 slist.emplace_back(
"*");
301 std::unique_ptr<FPVMAP> savemem = std::make_unique< FPVMAP>();
308 log << MSG::INFO <<
"Fine Clash Fixing enabled: (should be ON/OFF for Simulation/Reconstruction)" <<
endmsg;
310 log << MSG::INFO <<
"Fine Clash Fixing disabled: (should be ON/OFF for Simulation/Reconstruction)" <<
endmsg;
317 Station *station = (*it).second;
318 std::string stname(station->
GetName(), 0, 3);
328 bool isAssembly =
false;
337 l.setFPVMAP(savemem.get());
344 for (pit = station->
begin(); pit != station->
end(); ++pit) {
345 int zi = (*pit).second.zindex;
346 int fi = (*pit).second.phiindex;
353 bool selectedEta =
false;
367 bool selectedPhi =
false;
369 if ((
fi + 1) == *
i) {
385 log << MSG::INFO <<
"Build selected Station <" << station->
GetName() <<
"> at Jzz = " << zi <<
" Jff = " <<
fi + 1 <<
" ******* " << nstat_ss
386 <<
" stat.types built until now" <<
endmsg;
390 GeoNameTag *
nm =
new GeoNameTag(station->
GetName() +
"_station");
392 bool is_mirrored = ((*pit).second).isMirrored;
394 if (zi < 0 && !is_mirrored)
409 int geoid = (
sideC * 10000 + mirsign * 1000 + abs(zi) * 100 +
fi + 1) * 100000;
412 <<
"> and geoId " << geoid <<
endmsg;
414 p4->add(
new GeoIdentifierTag(geoid));
416 int geoid = (mirsign * 1000 + abs(zi) * 100 +
fi + 1) *
sign;
417 p4->add(
new GeoIdentifierTag(geoid));
420 <<
"> and geoId " << geoid <<
" for zi/fi = " << zi <<
"/" <<
fi <<
endmsg;
427 log << MSG::WARNING <<
"For Station with nameTag=<" << station->
GetName() <<
"> at zi/fi = " << zi <<
"/" <<
fi
428 <<
" no MuonStation found => no possibility to align" <<
endmsg;
450 GeoAlignableTransform *xf =
new GeoAlignableTransform(station->
getNominalTransform(*mysql, (*pit).second));
466 }
else if (nAlines ==1) {
471 ap = acurrent->second;
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;
478 if (
ap.jobindex == 0) {
481 log <<
MSG::DEBUG <<
"Going to set delta from A-line for station" << stname <<
" at zi/fi " << zi <<
"/" <<
fi <<
endmsg;
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);
494 GeoAlignableTransform *xf =
new GeoAlignableTransform(nominalTransform*native_to_amdbl.inverse()*delta_amdb*native_to_amdbl);
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 <<
" *** "
528 <<
" TGC Readout Elements \t " <<
m_manager->
nTgcDE() <<
" TGC Detector Elements " <<
endmsg <<
" ********************************************************************"
532 umem = GeoPerfUtils::getMem();
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;
545 umem = GeoPerfUtils::getMem();
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;
553 GeoNameTag *ntg =
new GeoNameTag(
"Muon");
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"
563 umem = GeoPerfUtils::getMem();
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;
570 geoModelStats.close();