diff --git a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/src/LArDetectorFactoryLite.h b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/src/LArDetectorFactoryLite.h index 014804e5e7d9fb158c952dace62f92bffc53cfee..d65083e3939b1b9675a1fb4453ed1c85cb6cc6ab 100755 --- a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/src/LArDetectorFactoryLite.h +++ b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/src/LArDetectorFactoryLite.h @@ -7,7 +7,7 @@ * * @class LArGeo::LArDetectorFactoryLite * - * @brief LArDetectorFactory is invoked by the LArDetectorTool when the GeoModel + * @brief LArDetectorFactoryLite is invoked by the LArDetectorTool when the GeoModel * description of LAr calorimeter is built from the SQLite database * relevant 'Construction' classes (Barrel, Endcap). It also builds readout geometry * diff --git a/TileCalorimeter/TileGeoModel/src/TileDetectorFactoryLite.cxx b/TileCalorimeter/TileGeoModel/src/TileDetectorFactoryLite.cxx new file mode 100755 index 0000000000000000000000000000000000000000..64a8b1b953885d6284b4ed689b778acb9304258e --- /dev/null +++ b/TileCalorimeter/TileGeoModel/src/TileDetectorFactoryLite.cxx @@ -0,0 +1,78 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TileDetectorFactoryLite.h" +#include "TileGeoSectionBuilder.h" +#include "TileGeoCutBuilder.h" +#include "TileDetDescr/TileDetDescrManager.h" +#include "TileDetDescr/TileDddbManager.h" +#include "TileDetDescr/TileDetDescriptor.h" + +#include "CaloIdentifier/TileID.h" + +#include "GeoModelKernel/GeoVolumeCursor.h" + +#include "StoreGate/StoreGateSvc.h" + +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <stdexcept> +#include <iostream> +#include <iomanip> +#include <algorithm> +#include <cmath> +#include <string> + + +// Constructor: +TileDetectorFactoryLite::TileDetectorFactoryLite(StoreGateSvc *pDetStore, + TileDetDescrManager *manager, + GeoModelIO::ReadGeoModel* sqliteReader, + bool addPlates, + int ushape, + int glue, + int cstube, + MsgStream *log, + bool fullGeo) + : m_detectorStore(pDetStore) + , m_detectorManager(manager) + , m_sqliteReader(sqliteReader) + , m_log(log) + , m_addPlatesToCellVolume(addPlates) + , m_uShape(ushape) + , m_glue(glue) + , m_csTube(cstube) + , m_testbeamGeometry(false) + , m_verbose(log->level()<=MSG::VERBOSE) + , m_fullGeo(fullGeo) +{ +} + +// Destructor: +TileDetectorFactoryLite::~TileDetectorFactoryLite(){} + +// Creation of geometry: +void TileDetectorFactoryLite::create(GeoPhysVol *world) +{ + (*m_log) << MSG::INFO <<" Entering TileDetectorFactoryLite::create()" << endmsg; + + + // Build Readout geometry + // ... TO-DO... + // + + + // Set geometry Tree Tops + GeoVolumeCursor cursor(world); + while(!cursor.atEnd()) { + std::string volName = cursor.getName(); + if(volName.compare(0,3,"Tile")==0) { + m_detectorManager->addTreeTop(GeoPVLink(cursor.getVolume().operator->())); + } + cursor.next(); + } +} + + diff --git a/TileCalorimeter/TileGeoModel/src/TileDetectorFactoryLite.h b/TileCalorimeter/TileGeoModel/src/TileDetectorFactoryLite.h new file mode 100755 index 0000000000000000000000000000000000000000..37469a5112326da1f28dd80b5eaf8f1df72dddc0 --- /dev/null +++ b/TileCalorimeter/TileGeoModel/src/TileDetectorFactoryLite.h @@ -0,0 +1,98 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TileDetectorFactoryLite.h + * + * @class TileDetectorFactoryLite + * + * @brief Definition of the TileDetectorFactoryLite class. + * The TileDetectorFactoryLite is invoked by the TileDetectorTool when the GeoModel + * description of Tile calorimeter is built from the SQLite database + * It also builds readout geometry (coming soon). + * + * @author Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch> , Aug 2021 + * + * Updates: + * - Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch>, Oct 2021 + * + */ + +#ifndef TileDetectorFactoryLite_h +#define TileDetectorFactoryLite_h 1 + +#include "GeoModelKernel/GeoVDetectorFactory.h" +#include "TileDetDescr/TileDetDescrManager.h" + +// FWD Declarations +class MsgStream; +class StoreGateSvc; +namespace GeoModelIO { + class ReadGeoModel; +} + + +class TileDetectorFactoryLite : public GeoVDetectorFactory +{ +public: + + /** Constructor */ + TileDetectorFactoryLite(StoreGateSvc *pDetStore, + TileDetDescrManager *manager, + GeoModelIO::ReadGeoModel* sqliteReader, + bool addPlates, + int uShape, + int glue, + int cstube, + MsgStream *log, + bool fullGeo); + + /** Destructor */ + ~TileDetectorFactoryLite(); + + /** Creation of Tile geometry */ + virtual void create(GeoPhysVol *world); + + /** Access function to TileDetDescr geometry data */ + virtual const TileDetDescrManager * getDetectorManager() const { return m_detectorManager; } + + +private: + + /** Detector pointer to Store Gate service */ + StoreGateSvc *m_detectorStore; + + /** Detector pointer to TileDetDescrManager */ + TileDetDescrManager *m_detectorManager; + + /** Pointer to an instance of the GeoModel I/O class */ + GeoModelIO::ReadGeoModel* m_sqliteReader; + + /** Get message SVC */ + MsgStream *m_log; + + /** Add plates to cell volume */ + bool m_addPlatesToCellVolume; + + /** U-shape version used */ + int m_uShape; + + /** 0: glue layer is removed and replaced by iron, + 1: simulation with glue, + 2: glue is replaced by iron + width of iron is modified in order to get the same sampling fraction */ + int m_glue; + + int m_csTube; + /** Flag for using test beam geometry */ + bool m_testbeamGeometry; + + /** Flag for activation verbose level for debugging */ + bool m_verbose; + + /** Geometry configuration: FULL, RECO */ + bool m_fullGeo; +}; + +#endif + diff --git a/TileCalorimeter/TileGeoModel/src/TileDetectorTool.cxx b/TileCalorimeter/TileGeoModel/src/TileDetectorTool.cxx index c3be4c60a26671f4e8b1e13e9963aa0eb608545a..944030805137aab95d18302e37bc2027219e0560 100755 --- a/TileCalorimeter/TileGeoModel/src/TileDetectorTool.cxx +++ b/TileCalorimeter/TileGeoModel/src/TileDetectorTool.cxx @@ -6,6 +6,8 @@ #include "TileDetectorFactory.h" #include "TileAtlasFactory.h" #include "TileTBFactory.h" +#include "TileDetectorFactoryLite.h" + #include "TileDetDescr/TileDetDescrManager.h" #include "TileDetDescr/TileDddbManager.h" #include "TileConditions/TileCablingService.h" @@ -24,6 +26,8 @@ #include "RDBAccessSvc/IRDBRecordset.h" #include "RDBAccessSvc/IRDBRecord.h" +#include "GeoModelRead/ReadGeoModel.h" + #include "AthenaKernel/ClassID_traits.h" #include "SGTools/DataProxy.h" @@ -85,12 +89,21 @@ StatusCode TileDetectorTool::create() if ( 0 == m_detector ) { + + IRDBAccessSvc* raccess = 0; ATH_CHECK(service("RDBAccessSvc",raccess)); TileDddbManager_ptr dbManager(new TileDddbManager(raccess,versionTag,versionNode)); m_manager = new TileDetDescrManager(dbManager); + // Get the detector configuration. + ServiceHandle<IGeoDbTagSvc> geoDbTag("GeoDbTagSvc",name()); + ATH_CHECK(geoDbTag.retrieve()); + + // Get the SQLite reader, if specified in the jobOption + GeoModelIO::ReadGeoModel* sqliteReader = geoDbTag->getSqliteReader(); + std::cout << "sqliteReader: " << sqliteReader << std::endl; if (0==dbManager->GetNumberOfEnv() && m_useNewFactory) { ATH_MSG_WARNING("New TileAtlasFactory can not be used because TileGlobals do not exist in Database"); ATH_MSG_WARNING("Use old TileDetectorFactory instead"); @@ -142,21 +155,39 @@ StatusCode TileDetectorTool::create() m_addPlates = dbManager->addPlatesToCell(); GeoPhysVol *world=&*theExpt->getPhysVol(); - if(m_testBeam) - { - TileTBFactory theTileTBFactory(detStore().operator->(),m_manager,m_addPlates,m_uShape,m_glue,m_csTube,&log); - theTileTBFactory.create(world); - } - else if (m_useNewFactory) - { - TileAtlasFactory theTileFactory(detStore().operator->(),m_manager,m_addPlates,m_uShape,m_glue,m_csTube,&log,m_geometryConfig=="FULL"); - theTileFactory.create(world); - } - else - { - TileDetectorFactory theTileFactory(detStore().operator->(),m_manager,m_addPlates,m_uShape,m_glue,m_csTube,&log); - theTileFactory.create(world); - } + + // build the geometry from the standalone SQLite file + if (sqliteReader) { + TileDetectorFactoryLite theTileFactoryLite(detStore().operator->(), + m_manager, + sqliteReader, + m_addPlates, + m_uShape, + m_glue, + m_csTube, + &log, + false); + theTileFactoryLite.create(world); + } + // build the geometry from the Oracle-based GeometryDB + else { + + if(m_testBeam) + { + TileTBFactory theTileTBFactory(detStore().operator->(),m_manager,m_addPlates,m_uShape,m_glue,m_csTube,&log); + theTileTBFactory.create(world); + } + else if (m_useNewFactory) + { + TileAtlasFactory theTileFactory(detStore().operator->(),m_manager,m_addPlates,m_uShape,m_glue,m_csTube,&log,m_geometryConfig=="FULL"); + theTileFactory.create(world); + } + else + { + TileDetectorFactory theTileFactory(detStore().operator->(),m_manager,m_addPlates,m_uShape,m_glue,m_csTube,&log); + theTileFactory.create(world); + } + } // end of building the geometry from the GeometryDB CHECK( createElements() ); @@ -170,6 +201,7 @@ StatusCode TileDetectorTool::create() m_manager->releaseDbManager(); return StatusCode::SUCCESS; + } return StatusCode::FAILURE;