Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

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 // The objects for mapping plane indexes in MuonSystem to the record index in RDBRecordset
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   //std::cerr<<"MuonDetectorFactory - constructor/// size of vectors "<<m_selectedStations.size()<<" "<<m_selectedStEta.size()<<" "<<m_selectedStPhi.size()<<std::endl;
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     // std::cout<<" MuonDetectorFactory001::create m_layout = <"<<m_layout<<">"<<std::endl;
153     
154     // check consistency of flags coming from the tool
155     if (m_layout.substr(0,1) != "P" && m_layout.substr(0,3) != "CTB") 
156     {
157 //         if (m_rdb == 0) 
158 //         {
159 //             log<<MSG::WARNING<<"Muon Layouts of type Q and following are available only via Oracle"<<endreq;
160 //             log<<MSG::WARNING<<"                       => overwriting UseRDB flag"<<endreq;
161 //             m_rdb = 1;
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     // here create the MYSQL singleton and assign to it the geometry version
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 //     if (m_idhfromconverters != 0)
230 //     {
231 //         const DataHandle<MdtIdHelper>  mdtidh;
232 //         sc = m_pDetStore->retrieve(mdtidh,"MDTIDHELPER");
233 //         if (sc.isFailure())log<<MSG::ERROR<<" not found MDT "<<endreq;
234 //         m_manager->set_mdtIdHelper(mdtidh);
235 //         const DataHandle<RpcIdHelper> rpcidh;
236 //         sc = m_pDetStore->retrieve(rpcidh,"RPCIDHELPER");
237 //         if (sc.isFailure() )log<<MSG::ERROR<<" not found RPC "<<endreq;
238 //         m_manager->set_rpcIdHelper(rpcidh);
239 //         const DataHandle<TgcIdHelper> tgcidh;
240 //         sc = m_pDetStore->retrieve(tgcidh,"TGCIDHELPER");
241 //         if (sc.isFailure() )log<<MSG::ERROR<<" not found TGC "<<endreq;
242 //         m_manager->set_tgcIdHelper(tgcidh);
243 //         const DataHandle<CscIdHelper> cscidh;
244 //         sc = m_pDetStore->retrieve(cscidh,"CSCIDHELPER");
245 //         if (sc.isFailure() )log<<MSG::ERROR<<" not found CSC "<<endreq;
246 //         m_manager->set_cscIdHelper(cscidh);
247 //     }
248 //     else 
249 //     {
250     // MdtIdHelper
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     //  if (StatusCode::SUCCESS == sc) {
262     if (idDictMgr) {
263       if (!idDictMgr->initializeHelper(*mdtidh)) { // Returns 1 if there is a problem
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     //  else log<<MSG::ERROR<<" FAILURE:: IdDictManager not found in the Detector Store"
277     //<<endreq;
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     // CscIdHelper
288     bool cscidhInitialized=false;
289     CscIdHelper *cscidh = new CscIdHelper;
290     if (!idDictMgr->initializeHelper(*cscidh)) { // Returns 1 if there is a problem
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     // RpcIdHelper
305     bool rpcidhInitialized=false;
306     RpcIdHelper *rpcidh = new RpcIdHelper;
307     if (!idDictMgr->initializeHelper(*rpcidh)) { // Returns 1 if there is a problem
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     // TgcIdHelper
321     bool tgcidhInitialized=false;
322     TgcIdHelper *tgcidh = new TgcIdHelper;
323     if (!idDictMgr->initializeHelper(*tgcidh)) { // Returns 1 if there is a problem
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         // DC1 and DC2
354         // OracleTag = "ATLAS-00";
355         dbr = new RDBReaderAtlas(m_pDetStore, m_pRDBAccess, OracleTag, OracleNode);
356 //         else
357 //         {
358 //             //ss 21/02/2007 breaking all dependencies from NOVA
359 //             // dbr = new  DBReaderAtlasP(m_pDetStore);
360 //             log<<MSG::ERROR<<"Layout P from NOVA is NOT supported after 21/02/2007 and MuonGeoModel tag >= 00-04-01"<<endreq;
361 //             return;
362 //         }
363     }
364     else if (m_layout.substr(0,11) == "Q02_initial" && m_includeCutoutsBog == 0) {
365         // Preliminary Rome ws version
366         // OracleTag = "ATLAS-Rome-Initial-01";
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         // Production Rome ws version 
371         // OracleTag = "ATLAS-Rome-Initial-02";
372         dbr = new RDBReaderAtlas(m_pDetStore, m_pRDBAccess, OracleTag, OracleNode);
373     }
374     else if (m_layout == "Q02" || m_layout.substr(0,1) == "R" )       {
375         // Production Rome Final
376         // OracleTag = "ATLAS-Rome-Final-00";
377         //dbr = new RDBReaderAtlas(m_pDetStore, m_pRDBAccess, OracleTag, OracleNode);
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         // dbr = new DBReaderTB04(m_pDetStore);
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     //bool buildEndcapToroid        = false;
401     bool buildFeet                = !skip_toroids;
402     //bool buildFeet                = false;
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     // set here the flag defining the geometry granularity
528     // minimalgeo = 1 => The geo tree is built up to the Detector Level (Full PhysVol)
529     //                     no internal structure of the Detector is built
530     // minimalgeo = 0 => The geo tree is built in full details 
531     m_manager->setMinimalGeoFlag(minimalgeo);
532     // set here the flag deciding whether to include cutouts:
533     //m_includeCutouts = 1 => include cutouts
534     //m_includeCutouts = 0 => no cutouts
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     //release memory
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     // now store detector-generic-descriptors into the manager
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 //     std::cout << " TGC SIZE CHECK: nlayers = " << t->nlayers 
584 //               << " materials.size() = " << (t->materials).size() << std::endl;
585 // no need for the following info in the Generic TGC cache  
586 //     for (unsigned int i = 0; i < (t->materials).size(); i++) 
587 //     {
588 //      //tgcCache.materials[i] = t->materials[i];
589 //      (tgcCache.materials).push_back(t->materials[i]);
590 //      //tgcCache.positions[i] = t->positions[i];
591 //      (tgcCache.positions).push_back(t->positions[i]);
592 //      //tgcCache.tck[i] = t->tck[i];
593 //      (tgcCache.tck).push_back(t->tck[i]);
594 //     }
595     m_manager->setGenericTgcDescriptor(tgcCache);
596 
597 //    CSC* c = (CSC*)mysql->GetATechnology("CSC0");
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         //--- --- --- CREATE ENVELOPE --- --- ---
622         // First try to get data from the GeomDB
623         const IRDBRecordset* muonSysRec = m_pRDBAccess->getRecordset("MuonSystem",OracleTag,OracleNode);
624         // -- Next two lines allow to use MuonSystem-00 by default instead of hardwired numbers
625         //    even for geometry tags where MuonSystem was not collected 
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         // --- Envelope from DB ....
637         if(muonSysRec->size()!=0)
638         {
639             // Data retrieved
640             muonsysIndMap _map;
641             muonsysIndMap::const_iterator iter;
642             const IRDBRecord* currentRecord;
643             
644             // First fill the contents of muonsysIndMap
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             // Create the polycone
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         }// ... end if  Envelope from DB ---
667         else
668         {
669             // Muon System node is not present, go for handcoded version
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     // Cannot (yet) cope with this:
722     // G4UserLimits *ul=new G4UserLimits;
723     // ul->SetMaxAllowedStep(5*cm);
724     // lv->GetLogicalVolume()->SetUserLimits(ul);
725   
726     m_manager->addTreeTop(p4); // This is the top!
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     // create the fullphysvol map to allow cloning and save memory
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     //  log<<MSG::DEBUG<<" Size of the station list is ???"<<endreq;
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);  // here is where we start to create a MuonChamber with all readoutelements
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             // if there's a selection of eta location, check if this chamber is selected
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             // if there's a selection of phi location, check if this chamber is selected
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             // total number of stations positioned in the layout
810             ntpos_ss++;
811             // total number of locations for this chamber 
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             // here define GeoNameTag 
820             GeoNameTag   *nm = new GeoNameTag( station->GetName() + "_station" );
821 
822             // here build the physical volume (tree) associated to the chamber 
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                 //CSL because coffin shape of the station mother volume
828             GeoVPhysVol *pv = l.build(m_manager, zi, fi, is_mirrored, isAssembly);
829             if (isAssembly) nAssemblies ++;
830 
831             // here define GeoIdentifierTag 
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             // here define the GeoAlignableTransform associated to the chamber
850             HepTransform3D DummyAline = HepTransform3D::Identity;
851             // nominal transform first 
852             GeoAlignableTransform *xf = new GeoAlignableTransform( station->getNominalTransform( (*pit).second) );             
853             // find correct alignment information for this position
854             xf->setDelta(DummyAline); // just in case we don't find one
855             apit = station->FindAlignPos(zi,fi);
856             HepTransform3D Delta = HepTransform3D::Identity;
857 //             log<<MSG::VERBOSE << "From the Factory:: Nominal transformation for " << stname << ":"
858 //                << endreq <<
859 //                 (xf->getTransform())[0][0] << " " <<
860 //                 (xf->getTransform())[0][1] << " " <<
861 //                 (xf->getTransform())[0][2] << " " <<
862 //                 (xf->getTransform())[0][3] << " " << endreq <<
863 //                 (xf->getTransform())[1][0] << " " <<
864 //                 (xf->getTransform())[1][1] << " " <<
865 //                 (xf->getTransform())[1][2] << " " <<
866 //                 (xf->getTransform())[1][3] << " " << endreq <<
867 //                 (xf->getTransform())[2][0] << " " <<
868 //                 (xf->getTransform())[2][1] << " " <<
869 //                 (xf->getTransform())[2][2] << " " <<
870 //                 (xf->getTransform())[2][3] << " " << endreq;
871             if (apit != station->aend())
872             {   //just consistency checks here 
873                 //std::cout<<"There's a delta transform to be applied"<<std::endl;
874                 ap = apit->second;
875                 //                ap.rots = 0.001356;
876                 //                ap.rotz =-0.001113;
877                 //                ap.rott = 0.001067;
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                     //old-style: update the transform with a Delta computed in the Station class
887                     // Delta = station->getDeltaTransform( ap, (*pit).second );
888 //                     log<<MSG::VERBOSE << "From the Factory:: Delta(tsz) transformation for " << stname << ":"
889 //                        << endreq <<
890 //                         (Delta)[0][0] << " " <<
891 //                         (Delta)[0][1] << " " <<
892 //                         (Delta)[0][2] << " " <<
893 //                         (Delta)[0][3] << " " << endreq <<
894 //                         (Delta)[1][0] << " " <<
895 //                         (Delta)[1][1] << " " <<
896 //                         (Delta)[1][2] << " " <<
897 //                         (Delta)[1][3] << " " << endreq <<
898 //                         (Delta)[2][0] << " " <<
899 //                         (Delta)[2][1] << " " <<
900 //                         (Delta)[2][2] << " " <<
901 //                         (Delta)[2][3] << " " << endreq;
902                     // xf->setDelta( Delta );
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 //             log<<MSG::VERBOSE << "From the Factory:: Total transformation for " << stname << ":"
910 //                << endreq <<
911 //                 (xf->getTransform())[0][0] << " " <<
912 //                 (xf->getTransform())[0][1] << " " <<
913 //                 (xf->getTransform())[0][2] << " " <<
914 //                 (xf->getTransform())[0][3] << " " << endreq <<
915 //                 (xf->getTransform())[1][0] << " " <<
916 //                 (xf->getTransform())[1][1] << " " <<
917 //                 (xf->getTransform())[1][2] << " " <<
918 //                 (xf->getTransform())[1][3] << " " << endreq <<
919 //                 (xf->getTransform())[2][0] << " " <<
920 //                 (xf->getTransform())[2][1] << " " <<
921 //                 (xf->getTransform())[2][2] << " " <<
922 //                 (xf->getTransform())[2][3] << " " << endreq;
923             // get the MuonStation from the manager; store the relevant transforms;
924             // let the MuonStation compute the Delta of the GeoAlignableTransform (new style)
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 //                 log<<MSG::VERBOSE << "From the Factory:: Before setting delta to the MuonStation " << stname << ":"
934 //                    << endreq <<
935 //                     (xf->getTransform())[0][0] << " " <<
936 //                     (xf->getTransform())[0][1] << " " <<
937 //                     (xf->getTransform())[0][2] << " " <<
938 //                     (xf->getTransform())[0][3] << " " << endreq <<
939 //                     (xf->getTransform())[1][0] << " " <<
940 //                     (xf->getTransform())[1][1] << " " <<
941 //                     (xf->getTransform())[1][2] << " " <<
942 //                     (xf->getTransform())[1][3] << " " << endreq <<
943 //                     (xf->getTransform())[2][0] << " " <<
944 //                     (xf->getTransform())[2][1] << " " <<
945 //                     (xf->getTransform())[2][2] << " " <<
946 //                     (xf->getTransform())[2][3] << " " << endreq;
947              // HepTransform3D Delta_amdb_frame = tsz_to_szt*station->getDeltaTransform_tszFrame(ap)*tsz_to_szt.inverse();
948              // mst->setDeltaAmdbLRS(  Delta_amdb_frame );
949 //                 log<<MSG::VERBOSE << "From the Factory:: Delta(amdb) transformation for " << stname << ":"
950 //                    << endreq <<
951 //                     (Delta_amdb_frame)[0][0] << " " <<
952 //                     (Delta_amdb_frame)[0][1] << " " <<
953 //                     (Delta_amdb_frame)[0][2] << " " <<
954 //                     (Delta_amdb_frame)[0][3] << " " << endreq <<
955 //                     (Delta_amdb_frame)[1][0] << " " <<
956 //                     (Delta_amdb_frame)[1][1] << " " <<
957 //                     (Delta_amdb_frame)[1][2] << " " <<
958 //                     (Delta_amdb_frame)[1][3] << " " << endreq <<
959 //                     (Delta_amdb_frame)[2][0] << " " <<
960 //                     (Delta_amdb_frame)[2][1] << " " <<
961 //                     (Delta_amdb_frame)[2][2] << " " <<
962 //                     (Delta_amdb_frame)[2][3] << " " << endreq;
963 //                 //now get and check the full transform
964 //                 log<<MSG::VERBOSE << "From MuonStation:: Total transformation for " << stname << ":"
965 //                    << endreq <<
966 //                     (xf->getTransform())[0][0] << " " <<
967 //                     (xf->getTransform())[0][1] << " " <<
968 //                     (xf->getTransform())[0][2] << " " <<
969 //                     (xf->getTransform())[0][3] << " " << endreq <<
970 //                     (xf->getTransform())[1][0] << " " <<
971 //                     (xf->getTransform())[1][1] << " " <<
972 //                     (xf->getTransform())[1][2] << " " <<
973 //                     (xf->getTransform())[1][3] << " " << endreq <<
974 //                     (xf->getTransform())[2][0] << " " <<
975 //                     (xf->getTransform())[2][1] << " " <<
976 //                     (xf->getTransform())[2][2] << " " <<
977 //                     (xf->getTransform())[2][3] << " " << endreq;
978                 //now get and check the full transform after updating the delta directly with a-line
979                 //std::cout<<setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(12);
980                 //std::cout<<"A-lines from DB to MuonStation: "<<ap.tras<<" "<<ap.traz<<" "<<ap.trat<<" "<<ap.rots<<" "<<ap.rotz<<" "<<ap.rott<<std::endl;
981                 mst->setDelta_fromAline( ap.tras, ap.traz, ap.trat, ap.rots, ap.rotz, ap.rott );
982 //                 log<<MSG::VERBOSE << "From MuonStation (A line):: Total transformation for " << stname << ":"
983 //                    << endreq <<
984 //                     (xf->getTransform())[0][0] << " " <<
985 //                     (xf->getTransform())[0][1] << " " <<
986 //                     (xf->getTransform())[0][2] << " " <<
987 //                     (xf->getTransform())[0][3] << " " << endreq <<
988 //                     (xf->getTransform())[1][0] << " " <<
989 //                     (xf->getTransform())[1][1] << " " <<
990 //                     (xf->getTransform())[1][2] << " " <<
991 //                     (xf->getTransform())[1][3] << " " << endreq <<
992 //                     (xf->getTransform())[2][0] << " " <<
993 //                     (xf->getTransform())[2][1] << " " <<
994 //                     (xf->getTransform())[2][2] << " " <<
995 //                     (xf->getTransform())[2][3] << " " << endreq;
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             // add tag, transform and physicalvolume associated to the chamber to the mother-volume
1002             p4->add(nm);
1003             p4->add(xf);
1004             p4->add(pv);
1005             //m_manager->addStation(xf,nm); //ss 19-02-2007 not needed anymore 
1006         }//end loop on positions 
1007         //number of stations realised in the layout 
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     // delete the fullphysvol map
1041     delete savemem;
1042     savemem = NULL;
1043 
1044     // delete the station and technology map
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     //if (  (!includeInertMaterials) || m_layout == "CTB2004" ) return;
1063     if (  (includeInertMaterials) && (m_layout != "CTB2004") ) 
1064     {
1065         
1066     //------------------------------------------------------------------------------------------
1067     //  Build Toroids (Barrel/Endcap), Feet and Rails 
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       // Barrel Toroid 
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       // Rails
1084       m_barreltoroidBuilder->buildRails(p4);
1085       // release memory
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       // Endcap Toroid
1095       m_endcaptoroidBuilder->buildECTVacuumVessel(p4);
1096       m_endcaptoroidBuilder->buildECTConductorBox(p4);
1097       m_endcaptoroidBuilder->buildECTKeystoneBox(p4);
1098       m_endcaptoroidBuilder->buildECTServiceTower(p4);
1099       //release memory 
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       // Feet
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       //release memory
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         // JD, JTT, and JF Shielding 
1124         if (buildDiskShielding)    m_shieldBuilder->buildDiskShielding(p4); // conflicts with CSCs in layout P03
1125         if (buildToroidShielding)  m_shieldBuilder->buildToroidShielding(p4);
1126         if (buildForwardShielding) m_shieldBuilder->buildForwardShielding(p4);
1127 
1128         //release memory 
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 } // namespace MuonGM
1165 

source navigation ] diff markup ] identifier search ] general search ]

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. Valid HTML 4.01!