001
002 #include "GaudiKernel/MsgStream.h"
003 #include "AthenaKernel/getMessageSvc.h"
004 #include "MuonGeoModel/MuonDetectorFactory001.h"
005
006 #include "RDBAccessSvc/IRDBAccessSvc.h"
007 #include "RDBAccessSvc/IRDBRecord.h"
008 #include "RDBAccessSvc/IRDBRecordset.h"
009
010 #include "MuonGeoModel/MYSQL.h"
011 #include "MuonGeoModel/FPVMAP.h"
012 #include "MuonGeoModel/MuonSystemDescription.h"
013 #include "MuonGeoModel/StationSelector.h"
014 #include "MuonGeoModel/Station.h"
015 #include "MuonGeoModel/MuonChamber.h"
016 #include "MuonReadoutGeometry/GenericCSCCache.h"
017 #include "MuonReadoutGeometry/GenericMDTCache.h"
018 #include "MuonReadoutGeometry/GenericRPCCache.h"
019 #include "MuonReadoutGeometry/GenericTGCCache.h"
020 #include "MuonGeoModel/ArrayFunction.h"
021 #include "MuonReadoutGeometry/MuonStation.h"
022 #include "MuonGeoModel/BarrelToroidBuilderRDB.h"
023 #include "MuonGeoModel/EndCapToroidBuilderRDB.h"
024 #include "MuonGeoModel/FeetToroidBuilderRDB.h"
025 #include "MuonGeoModel/ShieldBuilderRDB.h"
026 #include "MuonGeoModel/CalorimeterSaddleBuilder.h"
027
028 #include "IdDictDetDescr/IdDictManager.h"
029 #include "MuonIdHelpers/MdtIdHelper.h"
030 #include "MuonIdHelpers/RpcIdHelper.h"
031 #include "MuonIdHelpers/TgcIdHelper.h"
032 #include "MuonIdHelpers/CscIdHelper.h"
033
034 #include "GeoModelKernel/GeoBox.h"
035 #include "GeoModelKernel/GeoTube.h"
036 #include "GeoModelKernel/GeoPcon.h"
037 #include "GeoModelKernel/GeoTrd.h"
038 #include "GeoModelKernel/GeoTrap.h"
039 #include "GeoModelKernel/GeoPgon.h"
040 #include "GeoModelKernel/GeoMaterial.h"
041 #include "GeoModelKernel/GeoLogVol.h"
042 #include "GeoModelKernel/GeoPhysVol.h"
043 #include "GeoModelKernel/GeoFullPhysVol.h"
044 #include "GeoModelKernel/GeoTransform.h"
045 #include "GeoModelKernel/GeoAlignableTransform.h"
046 #include "GeoModelKernel/GeoNameTag.h"
047 #include "GeoModelKernel/GeoShapeShift.h"
048 #include "GeoModelKernel/GeoShapeUnion.h"
049 #include "GeoModelKernel/GeoShapeSubtraction.h"
050 #include "GeoModelKernel/GeoSerialTransformer.h"
051 #include "GeoModelKernel/GeoIdentifierTag.h"
052 #include "GeoModelKernel/GeoPerfUtils.h"
053 #include "GeoModelSvc/StoredMaterialManager.h"
054
055 #include "StoreGate/StoreGateSvc.h"
056
057 #include "CLHEP/GenericFunctions/Variable.hh"
058
059 #include "MuonGeoModel/DBReader.h"
060 #include "MuonGeoModel/RDBReaderAtlas.h"
061
062 #include <stdexcept>
063 #include <vector>
064 #include <iomanip>
065 #include <sstream>
066 #include <fstream>
067 typedef std::stringstream my_sstream;
068 typedef std::ostringstream my_osstream;
069
070
071 typedef std::map<int, unsigned int, std::less<int> > muonsysIndMap;
072
073 using namespace Genfun;
074 using namespace GeoXF;
075
076 #define skip_chambers false
077 #define skip_toroids false
078 #define skip_shielding false
079 #define skip_caloSaddle false
080 #define useAssemblies false
081
082
083 namespace MuonGM {
084
085 MuonDetectorFactory001::MuonDetectorFactory001(StoreGateSvc* pDetStore)
086 : m_rdb(1), m_muon(NULL), m_manager(NULL), m_pDetStore(pDetStore),
087 m_pRDBAccess(0), m_altAsciiDBMap(0)
088 {
089 MsgStream log(Athena::getMessageSvc(), "MuonGeoModel");
090 m_muon = new MuonSystemDescription( "MuonSystem" );
091 m_muon->barrelInnerRadius = 4.30*m;
092 m_muon->innerRadius = 0.07*m;
093 m_muon->outerRadius = 13.00*m;
094 m_muon->endcapFrontFace = 6.74*m;
095 m_muon->length = 22.03*m;
096 m_muon->barreLength = 6.53*m;
097 m_muon->barrelInterRadius = 3.83*m;
098 m_muon->extraZ = 12.9*m;
099 m_muon->extraR = 12.5*m;
100
101 m_selectedStations = std::vector<std::string>(0);
102 m_selectedStEta = std::vector<int>(0);
103 m_selectedStPhi = std::vector<int>(0);
104
105 m_enableFineClashFixing = 0;
106
107 m_switchOnOff_BUILDINERTMATERIALS = 0;
108 m_switchOnOff_MINIMALGEO = 0;
109 m_switchOnOff_BUILDENDCAP = 0;
110 m_switchOnOff_BUILDCALOSADDLE = 0;
111 m_switchOnOff_BUILDBARRELTOROID = 0;
112 m_switchOnOff_BUILDENDCAPTOROID = 0;
113 m_switchOnOff_BUILDFEET = 0;
114 m_switchOnOff_BUILDDISKSHIELD = 0;
115 m_switchOnOff_BUILDTOROIDSHIELD = 0;
116 m_switchOnOff_BUILDFORWARDSHIELD = 0;
117
118 log<<MSG::INFO<<"MuonDetectorFactory - constructor "<<" MuonSystem OuterRadius "<< m_muon->outerRadius
119 <<" Length "<< m_muon->length <<endreq;
120
121 }
122
123 MuonDetectorFactory001::~MuonDetectorFactory001()
124 {
125 delete m_muon;
126 }
127
128 const MuonDetectorManager* MuonDetectorFactory001::getDetectorManager() const
129 {
130 return m_manager;
131 }
132
133 void MuonDetectorFactory001::create( GeoPhysVol* world )
134 {
135 MsgStream log(Athena::getMessageSvc(), "MuGM:MuonFactory");
136
137 std::ofstream geoModelStats("MuonGeoModelStatistics_MuonDetectorFactory");
138 int mem = GeoPerfUtils::getMem();
139 int cpu = int(GeoPerfUtils::getCpu()/100.);
140
141
142 geoModelStats <<"At MuonDetectorFactory::create entry point: \t SZ= " <<mem << " Kb \t Time = " << cpu << " seconds " << std::endl;
143
144 int umem = GeoPerfUtils::getMem();
145 int ucpu = int(GeoPerfUtils::getCpu()/100.);
146 geoModelStats <<"At MuonDetectorFactory::resetting to 0: \t SZ= " <<umem-mem << " Kb \t Time = " << ucpu-cpu << " seconds " << std::endl;
147 mem = umem;
148 cpu = ucpu;
149
150
151 if (!m_manager) m_manager = new MuonDetectorManager();
152
153
154
155 if (m_layout.substr(0,1) != "P" && m_layout.substr(0,3) != "CTB")
156 {
157
158
159
160
161
162
163 if (m_layout == "Q02_initial")
164 {
165 m_includeCutouts = 0;
166 m_includeCutoutsBog = 0;
167 log<<MSG::INFO<<"MuonLayout set to <"<<m_layout<<"> = Preliminary version for Rome workshop "<<endreq;
168 log<<MSG::INFO<<" BOG chambers are shorter; no cutouts implemented"<<endreq;
169 }
170 if (m_layout == "Q02_initial_pro")
171 {
172 m_includeCutouts = 0;
173 m_includeCutoutsBog = 1;
174 log<<MSG::INFO<<"MuonLayout set to <"<<m_layout<<"> = Production version for Rome workshop "<<endreq;
175 log<<MSG::INFO<<" BOG cutouts are activated, all other cutouts are disabled"<<endreq;
176 m_layout = "Q02_initial";
177 log<<MSG::INFO<<" Setting internal Layout Name to "<<m_layout<<endreq;
178 log<<MSG::INFO<<" includeCutouts and includeCutoutsBog to "
179 <<m_includeCutouts<<" "
180 <<m_includeCutoutsBog <<endreq;
181 }
182 if (m_layout == "Q02")
183 {
184 m_includeCutouts = 0;
185 m_includeCutoutsBog = 1;
186 log<<MSG::INFO<<"MuonLayout set to <"<<m_layout<<"> = Production version for Rome workshop "<<endreq;
187 log<<MSG::INFO<<" BOG cutouts are activated, all other cutouts are disabled"<<endreq;
188 log<<MSG::INFO<<" Setting includeCutouts and includeCutoutsBog to "
189 <<m_includeCutouts<<" "
190 <<m_includeCutoutsBog <<endreq;
191 }
192 if (m_layout.substr(0,1) == "R")
193 {
194 m_includeCutouts = 1;
195 m_includeCutoutsBog = 1;
196 log<<MSG::INFO<<"MuonLayout set to <"<<m_layout<<"> = Development version for DC3 - infrastructures "
197 <<endreq;
198 log<<MSG::INFO<<" BOG cutouts are activated "<<m_includeCutoutsBog
199 <<" , all other cutouts are disabled "<<m_includeCutouts<<endreq;
200 }
201 if (m_layout.substr(0,3) == "CTB")
202 {
203 log<<MSG::INFO<<"MuonLayout set to <"<<m_layout<<"> = 2004 Combined Testbeam "<<endreq;
204 if (m_includeCtbBis)
205 log<<MSG::INFO<<" The BIS (or BEE) chamber will be built"<<endreq;
206 else
207 log<<MSG::INFO<<" The BIS (or BEE) chamber will NOT be built (this is the default)."<<endreq;
208 }
209 }
210
211 m_manager->setCachingFlag(m_caching);
212 m_manager->setCacheFillingFlag(m_cacheFillingFlag);
213 m_manager->setGeometryVersion(m_layout);
214 m_manager->set_DBMuonVersion(m_DBMuonVersion);
215 log<<MSG::INFO<<"Manager created for geometry version "
216 <<m_manager->geometryVersion()<<" from DB MuonVersion <"<<m_manager->get_DBMuonVersion()<<">"<<endreq;
217
218
219 MYSQL *mysql= MYSQL::GetPointer();
220 mysql->setGeometryVersion(m_layout);
221 mysql->set_amdb_from_RDB(m_rdb == 1);
222 mysql->set_DBMuonVersion(m_DBMuonVersion);
223 log<<MSG::INFO<<"Mysql helper class created here for geometry version "
224 <<mysql->getGeometryVersion()<<" from DB MuonVersion <"<<mysql->get_DBMuonVersion()<<">"<<endreq;
225
226
227 StatusCode sc =StatusCode::SUCCESS;
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251 bool mdtidhInitialized=false;
252 MdtIdHelper *mdtidh = new MdtIdHelper;
253 const IdDictManager * idDictMgr = 0;
254 sc = m_pDetStore->retrieve(idDictMgr, "IdDict");
255 if (sc.isFailure()) {
256 log<<MSG::ERROR << " Could not get IdDictManager !" << endreq;
257 throw std::runtime_error("Error in MuonDetectorFactory, could not get IdDictManager");
258 }
259
260
261
262 if (idDictMgr) {
263 if (!idDictMgr->initializeHelper(*mdtidh)) {
264 mdtidhInitialized=true;
265 log<<MSG::INFO << " MdtIdHelper has been initialised! "
266 << endreq;
267 }
268 else
269 {
270 log<<MSG::WARNING<<" IdDictManager found BUT initializeHelper ="
271 <<idDictMgr->initializeHelper(*mdtidh)<<endreq;
272 }
273 }
274 else log<<MSG::WARNING<<" IdDictManager not found in the Detector Store"<<endreq;
275
276
277
278 if (!mdtidhInitialized) {
279 log<<MSG::ERROR << " Cannot initialize MdtIdHelper ! "
280 << endreq;
281 delete mdtidh;
282 mdtidh=NULL;
283 throw std::runtime_error("Error in MuonDetectorFactory, cannot initialize MdtIdHelper");
284 }
285 m_manager->set_mdtIdHelper(mdtidh);
286
287
288 bool cscidhInitialized=false;
289 CscIdHelper *cscidh = new CscIdHelper;
290 if (!idDictMgr->initializeHelper(*cscidh)) {
291 cscidhInitialized=true;
292 log<<MSG::INFO << " CscIdHelper has been initialised! "
293 << endreq;
294 }
295 if (!cscidhInitialized) {
296 log<<MSG::ERROR << " Cannot initialize CscIdHelper ! " << endreq;
297 delete cscidh;
298 cscidh=NULL;
299 throw std::runtime_error("Error in MuonDetectorFactory, cannot initialize CscIdHelper");
300 return;
301 }
302 m_manager->set_cscIdHelper(cscidh);
303
304
305 bool rpcidhInitialized=false;
306 RpcIdHelper *rpcidh = new RpcIdHelper;
307 if (!idDictMgr->initializeHelper(*rpcidh)) {
308 rpcidhInitialized=true;
309 log<<MSG::INFO << " RpcIdHelper has been initialised! " << endreq;
310 }
311 if (!rpcidhInitialized) {
312 log<<MSG::ERROR << " Cannot initialize RpcIdHelper ! " << endreq;
313 delete rpcidh;
314 rpcidh=NULL;
315 throw std::runtime_error("Error in MuonDetectorFactory, cannot initialize RpcIdHelper");
316 return;
317 }
318 m_manager->set_rpcIdHelper(rpcidh);
319
320
321 bool tgcidhInitialized=false;
322 TgcIdHelper *tgcidh = new TgcIdHelper;
323 if (!idDictMgr->initializeHelper(*tgcidh)) {
324 tgcidhInitialized=true;
325 log<<MSG::INFO << " TgcIdHelper has been initialised! " << endreq;
326 }
327 if (!tgcidhInitialized) {
328 log<<MSG::ERROR << " Cannot initialize TgcIdHelper ! " << endreq;
329 delete tgcidh;
330 tgcidh=NULL;
331 throw std::runtime_error("Error in MuonDetectorFactory, cannot initialize TgcIdHelper");
332 return;
333 }
334 m_manager->set_tgcIdHelper(tgcidh);
335
336
337
338 umem = GeoPerfUtils::getMem();
339 ucpu = int(GeoPerfUtils::getCpu()/100.);
340 geoModelStats <<"At MuonDetectorFactory::IdHelpers loaded \t SZ= " <<umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = "<<umem-mem<<" \t Delta T ="<<ucpu - cpu << std::endl;
341 mem = umem;
342 cpu = ucpu;
343
344
345
346 log<<MSG::INFO<<" **************** MuonDetectorFactory001 ************************"<<endreq;
347 log<< " *** Start building the Muon Geometry Tree **********************"<<endreq;
348
349 DBReader* dbr = NULL;
350 std::string OracleTag = m_DBkey;
351 std::string OracleNode = m_DBnode;
352 if (m_layout.substr(0,3) == "P03") {
353
354
355 dbr = new RDBReaderAtlas(m_pDetStore, m_pRDBAccess, OracleTag, OracleNode);
356
357
358
359
360
361
362
363 }
364 else if (m_layout.substr(0,11) == "Q02_initial" && m_includeCutoutsBog == 0) {
365
366
367 dbr = new RDBReaderAtlas(m_pDetStore, m_pRDBAccess, OracleTag, OracleNode);
368 }
369 else if (m_layout.substr(0,11) == "Q02_initial" && m_includeCutoutsBog == 1) {
370
371
372 dbr = new RDBReaderAtlas(m_pDetStore, m_pRDBAccess, OracleTag, OracleNode);
373 }
374 else if (m_layout == "Q02" || m_layout.substr(0,1) == "R" ) {
375
376
377
378
379 log<<MSG::DEBUG<<"calling RDBReaderAtlas with m_altAsciiDBMap"<<endreq;
380 dbr = new RDBReaderAtlas(m_pDetStore, m_pRDBAccess, OracleTag, OracleNode, m_altAsciiDBMap);
381
382 }
383 else if (m_layout == "CTB2004") {
384
385 log<<MSG::ERROR<<"Layout CTB2004 (existing only in NOVA) is NOT supported after 21/02/2007 and MuonGeoModel tag >= 00-04-01"<<endreq;
386 log<<MSG::ERROR<<"For CTB studies, use AtlasRelease <13.0.0"<<endreq;
387 return;
388 }
389 else
390 {
391 log << MSG::ERROR<<"Uninitialized DBReader; Muon node will not be built"<<endreq;
392 }
393
394
395 bool includeInertMaterials = true;
396 bool minimalgeo = false;
397 bool buildEndcap = true;
398 bool buildBarrelToroid = !skip_toroids;
399 bool buildEndcapToroid = !skip_toroids;
400
401 bool buildFeet = !skip_toroids;
402
403 bool buildDiskShielding = !skip_shielding;
404 bool buildToroidShielding = !skip_shielding;
405 bool buildForwardShielding = !skip_shielding;
406 bool buildCaloSaddle = !skip_caloSaddle;
407 const IRDBRecordset* switchesRec = m_pRDBAccess->getRecordset("MuonSwitches", OracleTag, OracleNode);
408 if( switchesRec->size()!=0 )
409 {
410
411 const IRDBRecord *mySwitch = (*switchesRec)[0];
412 if(!(mySwitch->isFieldNull("BUILDINERTMATERIALS")))
413 {
414 includeInertMaterials = (mySwitch->getInt("BUILDINERTMATERIALS")==0) ? false : true;
415 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: Overall Inert Materials are on/off "<<includeInertMaterials<<endreq;
416 if ( m_switchOnOff_BUILDINERTMATERIALS>100 && (m_switchOnOff_BUILDINERTMATERIALS%1000) != includeInertMaterials)
417 {
418 includeInertMaterials = m_switchOnOff_BUILDINERTMATERIALS%1000;
419 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR includeInertMaterials = "<<includeInertMaterials<<endreq;
420 }
421 }
422
423 if(!(mySwitch->isFieldNull("MINIMALGEO")))
424 {
425 minimalgeo = (mySwitch->getInt("MINIMALGEO")==0) ? false : true;
426 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: minimalgeo is "<<minimalgeo<<endreq;
427 if ( m_switchOnOff_MINIMALGEO>100 && (m_switchOnOff_MINIMALGEO%1000) != minimalgeo)
428 {
429 minimalgeo = m_switchOnOff_MINIMALGEO%1000;
430 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR minimalgeo = "<<minimalgeo<<endreq;
431 }
432 }
433
434 if(!(mySwitch->isFieldNull("BUILDENDCAP")))
435 {
436 buildEndcap = (mySwitch->getInt("BUILDENDCAP")==0) ? false : true;
437 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: EC chambers are on/off "<<buildEndcap<<endreq;
438 if (m_switchOnOff_BUILDENDCAP>100 && (m_switchOnOff_BUILDENDCAP%1000) != buildEndcap)
439 {
440 buildEndcap = m_switchOnOff_BUILDENDCAP%1000;
441 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR buildEndcap = "<<buildEndcap<<endreq;
442 }
443 if (!buildEndcap) {
444 m_selectedStations.push_back("B");
445 }
446 }
447
448 if(!(mySwitch->isFieldNull("BUILDBARRELTOROID")))
449 {
450 buildBarrelToroid = (mySwitch->getInt("BUILDBARRELTOROID")==0) ? false : true;
451 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: Barrel Toroid is on/off "<<buildBarrelToroid<<endreq;
452 if (m_switchOnOff_BUILDBARRELTOROID>100 && (m_switchOnOff_BUILDBARRELTOROID%1000) != buildBarrelToroid)
453 {
454 buildBarrelToroid = m_switchOnOff_BUILDBARRELTOROID%1000;
455 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR buildBarrelToroid = "<<buildBarrelToroid<<endreq;
456 }
457 }
458
459 if(!(mySwitch->isFieldNull("BUILDENDCAPTOROID")))
460 {
461 buildEndcapToroid = (mySwitch->getInt("BUILDENDCAPTOROID")==0) ? false : true;
462 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: Endcap Toroid is on/off "<<buildEndcapToroid<<endreq;
463 if (m_switchOnOff_BUILDENDCAPTOROID>100 && (m_switchOnOff_BUILDENDCAPTOROID%1000) != buildEndcapToroid)
464 {
465 buildEndcapToroid = m_switchOnOff_BUILDENDCAPTOROID%1000;
466 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR buildEndcapToroid = "<<buildEndcapToroid<<endreq;
467 }
468 }
469
470 if(!(mySwitch->isFieldNull("BUILDFEET")))
471 {
472 buildFeet = (mySwitch->getInt("BUILDFEET")==0) ? false : true;
473 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: Atlas Feet are on/off "<<buildFeet<<endreq;
474 if (m_switchOnOff_BUILDFEET>100 && (m_switchOnOff_BUILDFEET%1000) != buildFeet)
475 {
476 buildFeet = m_switchOnOff_BUILDFEET%1000;
477 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR buildFeet = "<<buildFeet<<endreq;
478 }
479 }
480
481 if(!(mySwitch->isFieldNull("BUILDDISKSHIELD")))
482 {
483 buildDiskShielding = (mySwitch->getInt("BUILDDISKSHIELD")==0) ? false : true;
484 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: Disk Shielding is on/off "<<buildDiskShielding<<endreq;
485 if (m_switchOnOff_BUILDDISKSHIELD>100 && (m_switchOnOff_BUILDDISKSHIELD%1000) != buildDiskShielding)
486 {
487 buildDiskShielding = m_switchOnOff_BUILDDISKSHIELD%1000;
488 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR buildDiskShielding = "<<buildDiskShielding<<endreq;
489 }
490 }
491
492 if(!(mySwitch->isFieldNull("BUILDTOROIDSHIELD")))
493 {
494 buildToroidShielding = (mySwitch->getInt("BUILDTOROIDSHIELD")==0) ? false : true;
495 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: Toroid Shielding is on/off "<<buildToroidShielding<<endreq;
496 if (m_switchOnOff_BUILDTOROIDSHIELD>100 && (m_switchOnOff_BUILDTOROIDSHIELD%1000) != buildToroidShielding)
497 {
498 buildToroidShielding = m_switchOnOff_BUILDTOROIDSHIELD%1000;
499 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR buildToroidShielding = "<<buildToroidShielding<<endreq;
500 }
501 }
502
503 if(!(mySwitch->isFieldNull("BUILDFORWARDSHIELD")))
504 {
505 buildForwardShielding = (mySwitch->getInt("BUILDFORWARDSHIELD")==0) ? false : true;
506 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: Forward Shielding is on/off "<<buildForwardShielding<<endreq;
507 if (m_switchOnOff_BUILDFORWARDSHIELD > 100 && (m_switchOnOff_BUILDFORWARDSHIELD%1000) != buildForwardShielding)
508 {
509 buildForwardShielding = m_switchOnOff_BUILDFORWARDSHIELD%1000;
510 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR buildForwardShielding = "<<buildForwardShielding<<endreq;
511 }
512 }
513
514 if(!(mySwitch->isFieldNull("BUILDCALOSADDLE")))
515 {
516 buildCaloSaddle = (mySwitch->getInt("BUILDCALOSADDLE")==0) ? false : true;
517 log<<MSG::INFO<<"From std conf. in MUONSWITCHES: Calorimeter Saddle is on/off "<<buildCaloSaddle<<endreq;
518 if (m_switchOnOff_BUILDCALOSADDLE > 100 && (m_switchOnOff_BUILDCALOSADDLE%1000) != buildCaloSaddle)
519 {
520 buildCaloSaddle = m_switchOnOff_BUILDCALOSADDLE%1000;
521 log<<MSG::INFO<<"Resetting std conf. for this Property: CUSTOM VALUE FOR buildCaloSaddle = "<<buildCaloSaddle<<endreq;
522 }
523 }
524 else buildCaloSaddle = false;
525 }
526
527
528
529
530
531 m_manager->setMinimalGeoFlag(minimalgeo);
532
533
534
535 m_manager->setCutoutsFlag(m_includeCutouts);
536 m_manager->setCutoutsBogFlag(m_includeCutoutsBog);
537 mysql->setCutoutsBogFlag(m_includeCutoutsBog);
538 mysql->setCtbBisFlag(m_includeCtbBis);
539 mysql->setControlAlines(m_controlAlines);
540
541 dbr->setGeometryVersion(m_layout);
542 dbr->setManager(m_manager);
543 sc = dbr->ProcessDB();
544 if (sc != StatusCode::SUCCESS)
545 {
546 log << MSG::ERROR<<" FAILURE in DB access; Muon node will not be built"<<endreq;
547 return;
548 }
549
550 delete dbr;
551 dbr = 0;
552
553 umem = GeoPerfUtils::getMem();
554 ucpu = int(GeoPerfUtils::getCpu()/100.);
555 geoModelStats <<"At MuonDetectorFactory::DB read \t SZ= " <<umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = "<<umem-mem<<" \t Delta T ="<<ucpu - cpu << std::endl;
556 mem = umem;
557 cpu = ucpu;
558
559
560
561
562
563 RPC* r = (RPC*)mysql->GetATechnology("RPC0");
564 GenericRPCCache rpcCache;
565 rpcCache.stripSeparation = r->stripSeparation;
566 rpcCache.stripPanelThickness = r->stripPanelThickness;
567 rpcCache.rpcLayerThickness = r->rpcLayerThickness;
568 rpcCache.centralSupPanelThickness = r->centralSupPanelThickness;
569 rpcCache.GasGapThickness = r->GasGapThickness;
570 rpcCache.frontendBoardWidth = r->frontendBoardWidth;
571 m_manager->setGenericRpcDescriptor(rpcCache);
572
573 MDT* m = (MDT*)mysql->GetATechnology("MDT0");
574 GenericMDTCache mdtCache;
575 mdtCache.innerRadius = m->innerRadius;
576 m_manager->setGenericMdtDescriptor(mdtCache);
577
578 TGC* t = (TGC*)mysql->GetATechnology("TGC0");
579 GenericTGCCache tgcCache;
580 tgcCache.frame_h = t->frame_h;
581 tgcCache.frame_ab = t->frame_ab;
582 tgcCache.nlayers = t->nlayers;
583
584
585
586
587
588
589
590
591
592
593
594
595 m_manager->setGenericTgcDescriptor(tgcCache);
596
597
598 GenericCSCCache cscCache;
599 cscCache.dummy1 = 0;
600 cscCache.dummy2 = 0;
601 m_manager->setGenericCscDescriptor(cscCache);
602
603 const StoredMaterialManager* theMaterialManager;
604 if ( StatusCode::SUCCESS != m_pDetStore->retrieve( theMaterialManager, "MATERIALS" ) )
605 {
606 return;
607 }
608 else
609 log<< MSG::INFO
610 <<" theMaterialManager retrieven successfully from the DetStore"
611 <<endreq;
612
613
614 DetectorElement::setMaterialManager(*theMaterialManager);
615
616 const GeoMaterial* m4 = theMaterialManager->getMaterial( "std::Air" );
617 GeoLogVol* l4;
618 if (m_layout != "CTB2004")
619 {
620 GeoPcon* c4 = new GeoPcon( 0, 360*deg );
621
622
623 const IRDBRecordset* muonSysRec = m_pRDBAccess->getRecordset("MuonSystem",OracleTag,OracleNode);
624
625
626 if(muonSysRec->size()==0)
627 {
628 muonSysRec = m_pRDBAccess->getRecordset("MuonSystem","MuonSystem-00");
629 log<< MSG::INFO
630 <<"MuonSystem description from default node in GeomDB, i.e. MuonSystem-00"<<endreq;
631 }
632 else log<< MSG::INFO
633 <<"MuonSystem description from OracleTag=<"<<OracleTag<<"> and node=<"<< OracleNode<<">"<<endreq;
634
635
636
637 if(muonSysRec->size()!=0)
638 {
639
640 muonsysIndMap _map;
641 muonsysIndMap::const_iterator iter;
642 const IRDBRecord* currentRecord;
643
644
645 for (unsigned int ind=0; ind<muonSysRec->size(); ind++)
646 {
647 int key = (*muonSysRec)[ind]->getInt("PLANE_ID");
648 _map[key] = ind;
649 }
650
651
652 for(unsigned int ind=0; ind<_map.size(); ind++)
653 {
654 iter = _map.find(ind);
655
656 if(iter==_map.end())
657 throw std::runtime_error("Error in MuonDetectorFactory, missing plane in MuonSystem");
658 else
659 {
660 currentRecord = (*muonSysRec)[(*iter).second];
661 c4->addPlane(currentRecord->getDouble("ZPLANE"),
662 currentRecord->getDouble("RMIN"),
663 currentRecord->getDouble("RMAX"));
664 }
665 }
666 }
667 else
668 {
669
670 log<< MSG::INFO
671 <<"MuonSystem description not available in GeomDB - using hard-wired description"<<endreq;
672
673 double ir = m_muon->barrelInnerRadius;
674 double pir = m_muon->innerRadius;
675 double orad = m_muon->outerRadius;
676 double l = m_muon->length;
677 double eff = m_muon->endcapFrontFace;
678
679 double extraR = m_muon->extraR;
680 double extraZ = m_muon->extraZ;
681
682
683 c4->addPlane( -l, pir, extraR);
684 c4->addPlane(-extraZ, pir, extraR);
685 c4->addPlane(-extraZ, pir, orad);
686
687 c4->addPlane(-eff, pir, orad);
688 c4->addPlane(-eff, ir, orad);
689 c4->addPlane(+eff, ir, orad);
690 c4->addPlane(+eff, pir, orad);
691
692 c4->addPlane(extraZ, pir, orad);
693 c4->addPlane(extraZ, pir, extraR);
694 c4->addPlane( l, pir, extraR);
695 }
696 l4 = new GeoLogVol( "MuonSys", c4, m4 );
697 }
698 else
699 {
700 double xhlen,yhlen,zhlen, xstart;
701 if (mysql->getLayoutName() == "a.05" || mysql->getLayoutName() == "b.01")
702 {
703 xhlen=22702.0*mm-1.*mm;
704 yhlen=4100.0*mm-1.*mm;
705 zhlen=2800.0*mm-1.*mm;
706 xstart = 12198.0*mm;
707 }
708 else
709 {
710 xhlen=22000.*mm-1.*mm;
711 yhlen=zhlen=6000.*mm-1.*mm;
712 xstart = 12175*mm;
713 }
714 const GeoShape* c4 = new GeoBox(xhlen,yhlen,zhlen);
715 c4 = & ( (*c4)<<HepTranslateX3D( xhlen+xstart) );
716 l4 = new GeoLogVol( "MuonSys", c4, m4 );
717 log<< MSG::INFO<<" Here is the tree top volume for the CTB"<<endreq;
718 }
719 GeoPhysVol* p4 = new GeoPhysVol(l4);
720
721
722
723
724
725
726 m_manager->addTreeTop(p4);
727 log << MSG::INFO<<" TreeTop added to the Manager"<<endreq;
728 log << MSG::INFO<<" Muon Layout "<< m_layout << endreq;
729
730
731 std::vector<std::string> slist;
732 if (m_selectedStations.size()<=0) slist.push_back("*");
733 else slist = m_selectedStations;
734
735
736
737 FPVMAP* savemem = FPVMAP::GetPointer();
738
739
740 int nstat_ss = 0;
741 int ntpos_ss = 0;
742 int npos_ss = 0;
743 int nAssemblies = 0;
744 if (m_enableFineClashFixing >0)
745 log<<MSG::INFO
746 <<"Fine Clash Fixing enabled: (should be ON/OFF for Simulation/Reconstruction)"<<endreq;
747 else
748 log<<MSG::INFO
749 <<"Fine Clash Fixing disabled: (should be ON/OFF for Simulation/Reconstruction)"<<endreq;
750
751 StationSelector sel(slist);
752 StationSelector::StationIterator it;
753
754 for ( it = sel.begin(); it != sel.end(); it++ )
755 {
756 Station *station = (*it).second;
757 std::string stname(station->GetName(), 0, 3);
758 if (m_selectedStations.size()<=0)
759 log<<MSG::VERBOSE<<"Processing Stations named <"<<station->GetName()<<"> "
760 <<nstat_ss<<" built until now"<<endreq;
761
762 if ((skip_chambers) && (stname.substr(0,1)!="X")) continue;
763
764 bool isAssembly = false;
765 if (station->GetNrOfCutouts() > 0 && stname.substr(0,1) != "T") isAssembly = true;
766 MuonChamber l(station);
767 l.setFineClashFixingFlag(m_enableFineClashFixing);
768
769 PositionIterator pit;
770 AlignPosIterator apit;
771 AlignPos ap;
772 npos_ss = 0;
773 for ( pit = station->begin(); pit != station->end(); pit++ )
774 {
775 int zi = (*pit).second.zindex;
776 int fi = (*pit).second.phiindex;
777 int sign = 1;
778 if(zi) sign = zi/abs(zi);
779
780
781 if (m_selectedStEta.size() >0)
782 {
783 bool selectedEta = false;
784 for (std::vector<int>::iterator i=m_selectedStEta.begin(); i<m_selectedStEta.end(); i++)
785 {
786 if (zi == *i)
787 {
788 selectedEta = true;
789 break;
790 }
791 }
792 if (!selectedEta) continue;
793 }
794
795 if (m_selectedStPhi.size() >0)
796 {
797 bool selectedPhi = false;
798 for (std::vector<int>::iterator i=m_selectedStPhi.begin(); i<m_selectedStPhi.end(); i++)
799 {
800 if ((fi+1) == *i)
801 {
802 selectedPhi = true;
803 break;
804 }
805 }
806 if (!selectedPhi) continue;
807 }
808
809
810 ntpos_ss++;
811
812 npos_ss++;
813
814 if ((m_selectedStPhi.size() + m_selectedStEta.size()) >0)
815 log<<MSG::INFO<<"Build selected Station <"<<station->GetName()<<"> at Jzz = "<<zi<<" Jff = "<<fi+1<<" ******* "
816 <<nstat_ss<<" stat.types built until now"<<endreq;
817
818
819
820 GeoNameTag *nm = new GeoNameTag( station->GetName() + "_station" );
821
822
823 bool is_mirrored = ((*pit).second).isMirrored;
824 int mirsign = 0;
825 if ( zi<0 && !is_mirrored ) mirsign = 1;
826 if (stname=="CSL") isAssembly = true;
827
828 GeoVPhysVol *pv = l.build(m_manager, zi, fi, is_mirrored, isAssembly);
829 if (isAssembly) nAssemblies ++;
830
831
832 if (useAssemblies || isAssembly)
833 {
834 int sideC = 0;
835 if ( zi<0 ) sideC = 1;
836 int geoid = (sideC*10000 + mirsign*1000 + abs(zi)*100 + fi+1)*100000;
837 log<<MSG::DEBUG<<"Adding Station with nameTag=<"<<station->GetName() + "_station"
838 <<"> and geoId "<<geoid<<endreq;
839 p4->add(new GeoIdentifierTag (geoid));
840 }
841 else
842 {
843 int geoid = (mirsign*1000 + abs(zi)*100 + fi+1)*sign;
844 p4->add(new GeoIdentifierTag (geoid));
845 log<<MSG::DEBUG<<"Adding Station with nameTag=<"<<station->GetName() + "_station"
846 <<"> and geoId "<<geoid<<" for zi/fi = "<<zi<<"/"<<fi<<endreq;
847 }
848
849
850 HepTransform3D DummyAline = HepTransform3D::Identity;
851
852 GeoAlignableTransform *xf = new GeoAlignableTransform( station->getNominalTransform( (*pit).second) );
853
854 xf->setDelta(DummyAline);
855 apit = station->FindAlignPos(zi,fi);
856 HepTransform3D Delta = HepTransform3D::Identity;
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871 if (apit != station->aend())
872 {
873
874 ap = apit->second;
875
876
877
878 if (ap.phiindex != fi || ap.zindex != zi)
879 {
880 log<<MSG::ERROR<<"Inconsistent AlignedPosition found in the static Geometry DB: aligPos.fi, zi = "<< ap.phiindex<<", "<<ap.zindex
881 <<" for station "<<station->GetName()<<" at fi/zi = "<<fi<<"/"<<zi
882 <<" AlignPos indices fi/zi "<<fi<<"/"<<zi<<endreq;
883 }
884 else
885 {
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903 }
904 }
905 else {
906 log<<MSG::DEBUG <<"No A-lines -> AlignedPositions for this station in the static Geometry DB"<<endreq;
907 ap.tras=ap.traz=ap.trat=ap.rots=ap.rotz=ap.rott=0.;
908 }
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925 MuonStation* mst = m_manager->getMuonStation (station->GetName(), zi, fi+1);
926 if (mst != NULL) {
927 mst->setTransform(xf);
928 HepTransform3D tsz_to_szt = HepTransform3D(HepPoint3D(1.,0.,0.),HepPoint3D(0.,1.,0.),
929 HepPoint3D(0.,0.,1.),HepPoint3D(0.,0.,1.),
930 HepPoint3D(1.,0.,0.),HepPoint3D(0.,1.,0.));
931 mst->setNativeToAmdbLRS( tsz_to_szt * station->native_to_tsz_frame( (*pit).second ) );
932 mst->setNominalAmdbLRSToGlobal( station->tsz_to_global_frame( (*pit).second ) * tsz_to_szt.inverse() );
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981 mst->setDelta_fromAline( ap.tras, ap.traz, ap.trat, ap.rots, ap.rotz, ap.rott );
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996 }
997 else log<<MSG::ERROR<<"Cannot record the alignable transform in the MuonStation; MuonStation not found for stName= "
998 <<station->GetName()<<" zi/fi "<<zi<<"/"<<fi+1
999 <<endreq;
1000
1001
1002 p4->add(nm);
1003 p4->add(xf);
1004 p4->add(pv);
1005
1006 }
1007
1008 if (npos_ss >0) nstat_ss ++;
1009 }
1010
1011
1012 log<<MSG::INFO<<" **************** MuonDetectorFactory001 ****************************"<<endreq
1013 <<" *** The Muon Chamber Geometry Tree is built with "<<endreq
1014 <<" *** "<<p4->getNChildVols()<<" child volumes "<<endreq
1015 <<" *** "<<savemem->NDetectors()<<" independent elements and "<<endreq
1016 <<" *** "<<savemem->NDetectorsReused()<<" elements cloned or shared "<<endreq
1017 <<" *** "<<nstat_ss<<" kinds of stations"<<endreq
1018 <<" *** "<<ntpos_ss<<" stations with alignable transforms"<<endreq
1019 <<" *** "<<nAssemblies<<" stations are described as Assemblies"<<endreq
1020 <<" *** "<<m_manager->nMuonStation()<<" MuonStations "<<endreq
1021 <<" *** \t "<<m_manager->nMdtRE()<<" MDT Readout Elements \t "
1022 <<m_manager->nMdtDE()<<" MDT Detector Elements "<<endreq
1023 <<" *** \t "<<m_manager->nCscRE()<<" CSC Readout Elements \t "
1024 <<m_manager->nCscDE()<<" CSC Detector Elements "<<endreq
1025 <<" *** \t "<<m_manager->nRpcRE()<<" RPC Readout Elements \t "
1026 <<m_manager->nRpcDE()<<" RPC Detector Elements "<<endreq
1027 <<" *** \t "<<m_manager->nTgcRE()<<" TGC Readout Elements \t "
1028 <<m_manager->nTgcDE()<<" TGC Detector Elements "<<endreq
1029 <<" ********************************************************************"<<endreq;
1030
1031 umem = GeoPerfUtils::getMem();
1032 ucpu = int(GeoPerfUtils::getCpu()/100.);
1033 geoModelStats <<"At MuonDetectorFactory::active geo done \t SZ= " <<umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = "<<umem-mem<<" \t Delta T ="<<ucpu - cpu << std::endl;
1034 mem = umem;
1035 cpu = ucpu;
1036
1037
1038
1039
1040
1041 delete savemem;
1042 savemem = NULL;
1043
1044
1045 delete mysql;
1046 mysql = NULL;
1047
1048
1049 umem = GeoPerfUtils::getMem();
1050 ucpu = int(GeoPerfUtils::getCpu()/100.);
1051 geoModelStats <<"At MuonDetectorFactory::released access.mem \t SZ= " <<umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = "<<umem-mem<<" \t Delta T ="<<ucpu - cpu << std::endl;
1052 mem = umem;
1053 cpu = ucpu;
1054
1055
1056
1057
1058 GeoNameTag *ntg = new GeoNameTag( "Muon" );
1059 world->add(ntg);
1060 world->add(p4);
1061
1062
1063 if ( (includeInertMaterials) && (m_layout != "CTB2004") )
1064 {
1065
1066
1067
1068
1069 log << MSG::INFO << " *** Going to build Muon Toroids/Feet/Supports/Rails **************** "
1070 << endreq;
1071
1072 if (buildBarrelToroid)
1073 {
1074 BarrelToroidBuilderV* m_barreltoroidBuilder;
1075 m_barreltoroidBuilder = new BarrelToroidBuilderRDB( m_pDetStore, m_pRDBAccess,
1076 OracleTag, OracleNode);
1077
1078 m_barreltoroidBuilder->buildBTVacuumVessel(p4);
1079 m_barreltoroidBuilder->buildBTColdMass(p4);
1080 m_barreltoroidBuilder->buildBTVoussoirs(p4);
1081 m_barreltoroidBuilder->buildBTStruts(p4);
1082 m_barreltoroidBuilder->buildBTCryoring(p4);
1083
1084 m_barreltoroidBuilder->buildRails(p4);
1085
1086 delete m_barreltoroidBuilder;
1087 m_barreltoroidBuilder = 0;
1088 }
1089 if (buildEndcapToroid)
1090 {
1091 EndCapToroidBuilderV* m_endcaptoroidBuilder;
1092 m_endcaptoroidBuilder = new EndCapToroidBuilderRDB( m_pDetStore, m_pRDBAccess,
1093 OracleTag, OracleNode);
1094
1095 m_endcaptoroidBuilder->buildECTVacuumVessel(p4);
1096 m_endcaptoroidBuilder->buildECTConductorBox(p4);
1097 m_endcaptoroidBuilder->buildECTKeystoneBox(p4);
1098 m_endcaptoroidBuilder->buildECTServiceTower(p4);
1099
1100 delete m_endcaptoroidBuilder;
1101 m_endcaptoroidBuilder = 0;
1102 }
1103 if (buildFeet)
1104 {
1105 FeetToroidBuilderV* m_feettoroidBuilder;
1106 m_feettoroidBuilder = new FeetToroidBuilderRDB( m_pDetStore, m_pRDBAccess,
1107 OracleTag, OracleNode);
1108
1109 m_feettoroidBuilder->buildStandardFeet(p4);
1110 m_feettoroidBuilder->buildExtremityFeet(p4);
1111 m_feettoroidBuilder->buildFeetGirders(p4);
1112 m_feettoroidBuilder->buildFeetRailSupports(p4);
1113 m_feettoroidBuilder->buildFeetVoussoirs(p4);
1114
1115 delete m_feettoroidBuilder;
1116 m_feettoroidBuilder = 0;
1117 }
1118
1119 if (buildDiskShielding || buildToroidShielding || buildForwardShielding)
1120 {
1121 ShieldBuilderV* m_shieldBuilder;
1122 m_shieldBuilder = new ShieldBuilderRDB( m_pDetStore, m_pRDBAccess, OracleTag, OracleNode );
1123
1124 if (buildDiskShielding) m_shieldBuilder->buildDiskShielding(p4);
1125 if (buildToroidShielding) m_shieldBuilder->buildToroidShielding(p4);
1126 if (buildForwardShielding) m_shieldBuilder->buildForwardShielding(p4);
1127
1128
1129 delete m_shieldBuilder;
1130 m_shieldBuilder = 0;
1131 }
1132
1133 if (buildCaloSaddle)
1134 {
1135 CalorimeterSaddleBuilder * caloSaddleBuilder = new CalorimeterSaddleBuilder( m_pDetStore,
1136 m_pRDBAccess,
1137 OracleTag,
1138 OracleNode );
1139 caloSaddleBuilder->build(p4);
1140 delete caloSaddleBuilder;
1141 caloSaddleBuilder = 0;
1142 }
1143
1144
1145 log << MSG::INFO
1146 << " *** The Muon Toroids/Feet/Supports/Rails/Shielding are built ****** "<< endreq;
1147 }
1148 log << MSG::INFO
1149 << " *** Inert Material built according to DB switches and config. ****** "<< endreq;
1150 log << MSG::INFO
1151 << " *** The Muon Geometry Tree has " << p4->getNChildVols() << " child vol.s in total ********"<< endreq
1152 << " ********************************************************************\n"<< endreq;
1153
1154 umem = GeoPerfUtils::getMem();
1155 ucpu = int(GeoPerfUtils::getCpu()/100.);
1156 geoModelStats <<"At MuonDetectorFactory::inert geo done \t SZ= " <<umem << " Kb \t Time = " << ucpu << " seconds ---- \t DeltaM = "<<umem-mem<<" \t Delta T ="<<ucpu - cpu << std::endl;
1157 mem = umem;
1158 cpu = ucpu;
1159
1160 geoModelStats.close();
1161
1162 }
1163
1164 }
1165
| 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.
|
|