diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/VetoNuDetectorManager.h b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/VetoNuDetectorManager.h new file mode 100644 index 0000000000000000000000000000000000000000..86d34b84c94bc6f7ef4087a57696afa0be7ce3b3 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/VetoNuDetectorManager.h @@ -0,0 +1,163 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// VetoNuDetectorManager.h +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef SCINTREADOUTGEOMETRY_VETONUDETECTORMANAGER_H +#define SCINTREADOUTGEOMETRY_VETONUDETECTORMANAGER_H + +#include "GeoPrimitives/GeoPrimitives.h" + +#include "GeoModelKernel/GeoVPhysVol.h" + +#include "ScintReadoutGeometry/ScintDetectorManager.h" +#include "ScintReadoutGeometry/ScintDetectorElementCollection.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" + +#include "ScintIdentifier/VetoNuID.h" + +class StoreGateSvc; +class Identifier; +class IdentifierHash; +class GeoAlignableTransform; +class GeoVFullPhysVol; +class GeoVPhysVol; +class GeoVAlignmentStore; +class CondAttrListCollection; + +namespace ScintDD { + + class ScintDetectorElement; + class ExtendedAlignableTransform; + class VetoNuDetectorDesign; + + /** @class VetoNuDetectorManager + + Dedicated detector manager extending the functionality of the ScintDetectorManager + with dedicated VetoNu information, access. + + @author: Grant Gorfine + - modified and maintained by Nick Styles & Andreas Salzburger + - modified for FASER by D. Casper + */ + + class VetoNuDetectorManager : public ScintDetectorManager { + + public: + + // Constructor + VetoNuDetectorManager( StoreGateSvc* detStore ); + + // Destructor + virtual ~VetoNuDetectorManager(); + + /** Access Raw Geometry */ + virtual unsigned int getNumTreeTops() const override; + virtual PVConstLink getTreeTop(unsigned int i) const override; + /** Add tree top */ + void addTreeTop(PVLink); + + + // + // Access Readout Elements + // + + /** access to individual elements via Identifier */ + virtual ScintDetectorElement * getDetectorElement(const Identifier &id) const override; + + /** access to individual elements via IdentifierHash */ + virtual ScintDetectorElement * getDetectorElement(const IdentifierHash &idHash) const override; + + /** access to individual elements via module numbering schema */ + ScintDetectorElement * getDetectorElement(int station, int plate) const; + + /** access to whole collectiom via iterators */ + virtual const ScintDetectorElementCollection * getDetectorElementCollection() const override; + virtual ScintDetectorElementCollection::const_iterator getDetectorElementBegin() const override; + virtual ScintDetectorElementCollection::const_iterator getDetectorElementEnd() const override; + + /** Add elememts during construction */ + virtual void addDetectorElement(ScintDetectorElement * element) override; + + /** Add alignable transforms. No access to these, they will be changed by manager: */ + virtual void addAlignableTransform (int level, + const Identifier &id, + GeoAlignableTransform *xf, + const GeoVFullPhysVol * child); + + /** As above but does a dynamic_cast to GeoVFullPhysVol */ + virtual void addAlignableTransform (int level, + const Identifier &id, + GeoAlignableTransform *xf, + const GeoVPhysVol * child); + + /** Initialize the neighbours. This can only be done when all elements are built. */ + virtual void initNeighbours() override; + + /** Check identifier is for this detector */ + virtual bool identifierBelongs(const Identifier & id) const override; + + /** Access to module design, casts to VetoNuDetectorDesign */ + const ScintDetectorDesign * getVetoNuDesign() const; + + /** Process new global DB folders for L1 and L2 **/ + virtual + bool processGlobalAlignment(const std::string &, int level, FrameType frame, + const CondAttrListCollection* obj, + GeoVAlignmentStore* alignStore) const override; + + // comply with ScintDetectorManager interface + bool processSpecialAlignment(const std::string & key, + ScintDD::AlignFolderType alignfolder) const override; + + bool processSpecialAlignment(const std::string& key, + const CondAttrListCollection* obj=nullptr, + GeoVAlignmentStore* alignStore=nullptr) const override; + + + private: + /** implements the main alignment update for delta transforms in different frames, + it translates into the LocalDelta or GlobalDelta function of ScintDetectorManager + */ + virtual bool setAlignableTransformDelta(int level, + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const override; + + /** Prevent copy and assignment */ + const VetoNuDetectorManager & operator=(const VetoNuDetectorManager &right); + VetoNuDetectorManager(const VetoNuDetectorManager &right); + + virtual const VetoNuID* getIdHelper() const override; + + // Private member data + std::vector<PVLink> m_volume; + ScintDetectorElementCollection m_elementCollection; + typedef std::map<Identifier, ExtendedAlignableTransform *> AlignableTransformMap; + std::vector< AlignableTransformMap > m_higherAlignableTransforms; + std::vector< ExtendedAlignableTransform *> m_alignableTransforms; + const VetoNuID* m_idHelper; + + /** This variable switches the how the local alignment corrections are applied + If true they will be calcualted on top of all of other corrections but in the default reference frame + If false they will be calcualted on top of all of other corrections but in the globally aligned reference frame + */ + bool m_isLogical; + + + }; + +} // namespace ScintDD + +#ifndef GAUDI_NEUTRAL +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF(ScintDD::VetoNuDetectorManager, 238247911, 1) +#endif + +#endif // SCINTREADOUTGEOMETRY_VETONIDETECTORMANAGER_H diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/VetoNuDetectorManager.cxx b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/VetoNuDetectorManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..eb17df41a63a22599b064adf561c2080e472a29e --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/VetoNuDetectorManager.cxx @@ -0,0 +1,348 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "ScintReadoutGeometry/VetoNuDetectorManager.h" + +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "GeoPrimitives/CLHEPtoEigenConverter.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "ScintIdentifier/VetoNuID.h" +#include "ScintReadoutGeometry/ScintDetectorElementCollection.h" +#include "ScintReadoutGeometry/ScintDetectorElement.h" +#include "ScintReadoutGeometry/ExtendedAlignableTransform.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" +#include "StoreGate/StoreGateSvc.h" + +#include <iostream> + +namespace ScintDD { + + const int FIRST_HIGHER_LEVEL = 1; + + VetoNuDetectorManager::VetoNuDetectorManager( StoreGateSvc* detStore ) + : ScintDetectorManager(detStore, "VetoNu"), + m_idHelper(0), + m_isLogical(false) // Change to true to change the definition of local module corrections + { + // + // Initialized the Identifier helper. + // + StatusCode sc = detStore->retrieve(m_idHelper, "VetoNuID"); + if (sc.isFailure()) { + ATH_MSG_ERROR("Could not retrieve VetoNu id helper"); + } + // Initialize the collections. + if (m_idHelper) { + m_elementCollection.resize(m_idHelper->plate_hash_max()); + m_alignableTransforms.resize(m_idHelper->plate_hash_max()); + // m_moduleAlignableTransforms.resize(m_idHelper->plate_hash_max()); + } + } + + + + VetoNuDetectorManager::~VetoNuDetectorManager() + { + // Clean up + for (size_t i=0; i < m_volume.size(); i++) { + m_volume[i]->unref(); + } + + for (size_t j=0; j < m_higherAlignableTransforms.size(); j++){ + AlignableTransformMap::iterator iterMap; + for (iterMap = m_higherAlignableTransforms[j].begin(); + iterMap != m_higherAlignableTransforms[j].end(); + ++iterMap) { + delete iterMap->second; + } + } + + for (size_t k=0; k < m_alignableTransforms.size(); k++){ + delete m_alignableTransforms[k]; + } + + // for (size_t l=0; l < m_moduleAlignableTransforms.size(); l++){ + // delete m_moduleAlignableTransforms[l]; + // } + } + + unsigned int VetoNuDetectorManager::getNumTreeTops() const + { + return m_volume.size(); + } + + PVConstLink VetoNuDetectorManager::getTreeTop(unsigned int i) const + { + return m_volume[i]; + } + + void VetoNuDetectorManager::addTreeTop(PVLink vol){ + vol->ref(); + m_volume.push_back(vol); + } + + + ScintDetectorElement* VetoNuDetectorManager::getDetectorElement(const Identifier & id) const + { + // NB the id helpers implementation for getting a hash is not optimal. + // Essentially does a binary search. + // Make sure it is a wafer Id + Identifier waferId = m_idHelper->plate_id(id); + IdentifierHash idHash = m_idHelper->plate_hash(waferId); + if (idHash.is_valid()) { + return m_elementCollection[idHash]; + } else { + return 0; + } + } + + ScintDetectorElement* VetoNuDetectorManager::getDetectorElement(const IdentifierHash & idHash) const + { + return m_elementCollection[idHash]; + } + + ScintDetectorElement* VetoNuDetectorManager::getDetectorElement(int station, int plate) const + { + return getDetectorElement(m_idHelper->plate_id(station, plate)); + } + + const ScintDetectorElementCollection* VetoNuDetectorManager::getDetectorElementCollection() const + { + return &m_elementCollection; + } + + ScintDetectorElementCollection::const_iterator VetoNuDetectorManager::getDetectorElementBegin() const + { + return m_elementCollection.begin(); + } + + ScintDetectorElementCollection::const_iterator VetoNuDetectorManager::getDetectorElementEnd() const + { + return m_elementCollection.end(); + } + + + void VetoNuDetectorManager::addDetectorElement(ScintDetectorElement * element) + { + IdentifierHash idHash = element->identifyHash(); + if (idHash >= m_elementCollection.size()) + throw std::runtime_error("VetoNuDetectorManager: Error adding detector element."); + m_elementCollection[idHash] = element; + } + + void VetoNuDetectorManager::initNeighbours() + { + ScintDetectorElementCollection::iterator iter; + + // Loop over all elements and set the neighbours + for (iter = m_elementCollection.begin(); iter != m_elementCollection.end(); ++iter){ + + ScintDetectorElement * element = *iter; + if (element) { + + IdentifierHash idHash = element->identifyHash(); + IdentifierHash idHashOther; + + int result; + // If no neighbour, result != 0 in which case we leave neighbour as null + result = m_idHelper->get_next_in_z(idHash, idHashOther); + if (result==0) element->setNextInZ(m_elementCollection[idHashOther]); + + result = m_idHelper->get_prev_in_z(idHash, idHashOther); + if (result==0) element->setPrevInZ(m_elementCollection[idHashOther]); + } + } + } + + const VetoNuID* VetoNuDetectorManager::getIdHelper() const + { + return m_idHelper; + } + + + bool VetoNuDetectorManager::setAlignableTransformDelta(int level, + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const + { + + if (level == 0) { // 0 - At the element level + + // We retrieve it via a hashId. + IdentifierHash idHash = m_idHelper->plate_hash(id); + if (!idHash.is_valid()) return false; + + if (frame == ScintDD::global) { // global shift + // Its a global transform + return setAlignableTransformGlobalDelta(m_alignableTransforms[idHash], delta, alignStore); + + } else if (frame == ScintDD::local) { // local shift + + ScintDetectorElement * element = m_elementCollection[idHash]; + if (!element) return false; + + + // Its a local transform + //See header file for definition of m_isLogical + if( m_isLogical ){ + //Ensure cache is up to date and use the alignment corrected local to global transform + element->setCache(); + return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->transform(), delta, alignStore); + } else + //Use default local to global transform + return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->defTransform(), delta, alignStore); + + } else { + // other not supported + ATH_MSG_WARNING("Frames other than global or local are not supported."); + return false; + } + } else { // higher level + if (frame != ScintDD::global) { + ATH_MSG_WARNING("Non global shift at higher levels is not supported."); + return false; + } + + int index = level - FIRST_HIGHER_LEVEL; // level 0 is treated separately. + if (index >= static_cast<int>(m_higherAlignableTransforms.size())) return false; + + // We retrieve it from a map. + AlignableTransformMap::const_iterator iter; + iter = m_higherAlignableTransforms[index].find(id); + if (iter == m_higherAlignableTransforms[index].end()) return false; + + // Its a global transform + return setAlignableTransformGlobalDelta(iter->second, delta, alignStore); + } + } + + void VetoNuDetectorManager::addAlignableTransform (int level, + const Identifier & id, + GeoAlignableTransform *transform, + const GeoVPhysVol * child) + { + if (m_idHelper) { + + const GeoVFullPhysVol * childFPV = dynamic_cast<const GeoVFullPhysVol *>(child); + if (!childFPV) { + ATH_MSG_ERROR("Child of alignable transform is not a full physical volume"); + } else { + addAlignableTransform (level, id, transform, childFPV); + } + } + } + + void VetoNuDetectorManager::addAlignableTransform (int level, + const Identifier & id, + GeoAlignableTransform *transform, + const GeoVFullPhysVol * child) + { + if (m_idHelper) { + if (level == 0) { + // Element + IdentifierHash idHash = m_idHelper->plate_hash(id); + if (idHash.is_valid()) { + m_alignableTransforms[idHash]= new ExtendedAlignableTransform(transform, child); + } + } else { + // Higher levels are saved in a map. NB level=0 is treated above. + int index = level - FIRST_HIGHER_LEVEL; // level 0 is treated separately. + if (index >= static_cast<int>(m_higherAlignableTransforms.size())) m_higherAlignableTransforms.resize(index+1); + m_higherAlignableTransforms[index][id] = new ExtendedAlignableTransform(transform, child); + } + } + } + + bool + VetoNuDetectorManager::identifierBelongs(const Identifier & id) const + { + return getIdHelper()->is_veto(id); + } + + + const ScintDetectorDesign* VetoNuDetectorManager::getVetoNuDesign() const + { + return dynamic_cast<const ScintDetectorDesign *>(getDesign()); + } + + // New global alignment folders + bool VetoNuDetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame, + const CondAttrListCollection* obj, GeoVAlignmentStore* alignStore) const + { + ATH_MSG_INFO("Processing new global alignment containers with key " << key << " in the " << frame << " frame at level "); + + const CondAttrListCollection* atrlistcol=obj; + if(atrlistcol==nullptr and m_detStore->retrieve(atrlistcol,key)!=StatusCode::SUCCESS) { + ATH_MSG_INFO("Cannot find new global align Container for key " + << key << " - no new global alignment "); + return false; + } + + bool alignmentChange = false; + Identifier ident=Identifier(); + + // loop over objects in collection + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + const coral::AttributeList& atrlist=citr->second; + // SCT manager, therefore ignore all that is not a SCT Identifier + // if (atrlist["det"].data<int>()!=2) continue; + ATH_MSG_FATAL("Using invalid alignment data for VetoNu detector (correct treatment not yet implemented"); + ident = getIdHelper()->plate_id(atrlist["station"].data<int>(), + atrlist["plate"].data<int>()); // The last is the module side which is at this ident-level always the 0-side + + // construct new transform + // Order of rotations is defined as around z, then y, then x. + Amg::Translation3D newtranslation(atrlist["Tx"].data<float>(),atrlist["Ty"].data<float>(),atrlist["Tz"].data<float>()); + Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity(); + newtrans *= Amg::AngleAxis3D(atrlist["Rz"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,0.,1.)); + newtrans *= Amg::AngleAxis3D(atrlist["Ry"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,1.,0.)); + newtrans *= Amg::AngleAxis3D(atrlist["Rx"].data<float>()*CLHEP::mrad, Amg::Vector3D(1.,0.,0.)); + + ATH_MSG_DEBUG("New global DB -- channel: " << citr->first + << " ,det: " << atrlist["det"].data<int>() + << " ,bec: " << atrlist["bec"].data<int>() + << " ,layer: " << atrlist["layer"].data<int>() + << " ,ring: " << atrlist["ring"].data<int>() + << " ,sector: " << atrlist["sector"].data<int>() + << " ,Tx: " << atrlist["Tx"].data<float>() + << " ,Ty: " << atrlist["Ty"].data<float>() + << " ,Tz: " << atrlist["Tz"].data<float>() + << " ,Rx: " << atrlist["Rx"].data<float>() + << " ,Ry: " << atrlist["Ry"].data<float>() + << " ,Rz: " << atrlist["Rz"].data<float>()); + + // Set the new transform; Will replace existing one with updated transform + bool status = setAlignableTransformDelta(level, + ident, + newtrans, + frame, + alignStore); + + if (!status) { + ATH_MSG_DEBUG("Cannot set AlignableTransform for identifier." + << getIdHelper()->show_to_string(ident) + << " at level " << level << " for new global DB "); + } + + alignmentChange = (alignmentChange || status); + } + return alignmentChange; + } + +bool VetoNuDetectorManager::processSpecialAlignment( + const std::string &, ScintDD::AlignFolderType) const { + return false; +} + +bool VetoNuDetectorManager::processSpecialAlignment(const std::string& /*key*/, + const CondAttrListCollection* /*obj*/, + GeoVAlignmentStore* /*alignStore*/) const { + return false; + +} + +} // namespace ScintDD diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/CMakeLists.txt b/Scintillator/ScintDetDescr/VetoNuGeoModel/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..404a64a14c4deecf4fd9f51908c5800e0129cd28 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/CMakeLists.txt @@ -0,0 +1,29 @@ +################################################################################ +# Package: VetoNuGeoModel +################################################################################ + +# Declare the package name: +atlas_subdir( VetoNuGeoModel ) + +# External dependencies: +find_package( Boost COMPONENTS filesystem thread system ) +find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) +find_package( Eigen ) +find_package( GeoModel ) + +# Component(s) in the package: +atlas_add_component( VetoNuGeoModel + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaKernel GeoModelFaserUtilities GaudiKernel SGTools StoreGateLib SGtests AthenaPoolUtilities DetDescrConditions FaserDetDescr ScintGeoModelUtils ScintReadoutGeometry ScintIdentifier Identifier ) + +atlas_add_test( VetoNuGMConfig_test + SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/test/VetoNuGMConfig_test.py + PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + PROPERTIES TIMEOUT 300 ) + + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/VetoNuGeoModel/VetoNuDetectorTool.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/VetoNuGeoModel/VetoNuDetectorTool.h new file mode 100644 index 0000000000000000000000000000000000000000..60e4ee6ab63659996fd6b2b942e6dc64ceb03fbb --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/VetoNuGeoModel/VetoNuDetectorTool.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETONUGEOMODEL_VETONUDETECTORTOOL_H +#define VETONUGEOMODEL_VETONUDETECTORTOOL_H + +#include "GeoModelFaserUtilities/GeoModelTool.h" +#include "VetoNuGeoModel/VetoNuGeoModelAthenaComps.h" + +#include "GeometryDBSvc/IGeometryDBSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" + +#include "GaudiKernel/ServiceHandle.h" + +#include <string> + +namespace ScintDD { + class VetoNuDetectorManager; +} + +class VetoNuID; +// class FaserDetectorID; + +class VetoNuDetectorTool : public GeoModelTool { + +public: + // Standard Constructor + VetoNuDetectorTool(const std::string& type, const std::string& name, const IInterface* parent); + + virtual StatusCode create() override final; + virtual StatusCode clear() override final; + + // Register callback function on ConDB object + virtual StatusCode registerCallback ATLAS_NOT_THREAD_SAFE () override final; + + // Callback function itself + virtual StatusCode align(IOVSVC_CALLBACK_ARGS) override; + +private: + StringProperty m_detectorName{this, "DetectorName", "VetoNu"}; + BooleanProperty m_alignable{this, "Alignable", true}; + BooleanProperty m_useDynamicAlignFolders{this, "useDynamicAlignFolders", false}; + bool m_cosmic; + + const ScintDD::VetoNuDetectorManager* m_manager; + + VetoNuGeoModelAthenaComps m_athenaComps; + + ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc; + ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc; + ServiceHandle< IGeometryDBSvc > m_geometryDBSvc; + + StringProperty m_run1Folder{this, "Run1Folder", "/Scint/Align"}; + StringProperty m_run2L1Folder{this, "Run2L1Folder", "/Scint/AlignL1/ID"}; + StringProperty m_run2L2Folder{this, "Run2L2Folder", "/Scint/AlignL2/SCT"}; + StringProperty m_run2L3Folder{this, "Run2L3Folder", "/Scint/AlignL3"}; +}; + +#endif // VETOGEOMODEL_VETODETECTORTOOL_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/VetoNuGeoModel/VetoNuGeoModelAthenaComps.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/VetoNuGeoModel/VetoNuGeoModelAthenaComps.h new file mode 100644 index 0000000000000000000000000000000000000000..c873da9365eade697769bbcc116d05bfd1b9ee45 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/VetoNuGeoModel/VetoNuGeoModelAthenaComps.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoNuGeoModel_VetoNuGeoModelAthenaComps_H +#define VetoNuGeoModel_VetoNuGeoModelAthenaComps_H 1 + +#include "ScintGeoModelUtils/ScintDDAthenaComps.h" + +class VetoNuID; + +/// Class to hold various Athena components +// template <class ID_HELPER> +class VetoNuGeoModelAthenaComps : public ScintDD::AthenaComps { + +public: + + VetoNuGeoModelAthenaComps(); + + void setIdHelper(const VetoNuID* idHelper); + + const VetoNuID* getIdHelper() const; + +private: + const VetoNuID* m_idHelper; + +}; + +#endif // VetoNuGeoModel_VetoNuGeoModelAthenaComps_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/python/VetoNuGeoModelConfig.py b/Scintillator/ScintDetDescr/VetoNuGeoModel/python/VetoNuGeoModelConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..9f55fbad90243aa8ba56ba4044a99ca085a1a811 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/python/VetoNuGeoModelConfig.py @@ -0,0 +1,20 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentFactory import CompFactory +# from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline + +def VetoNuGeometryCfg( flags ): + from FaserGeoModel.GeoModelConfig import GeoModelCfg + acc = GeoModelCfg( flags ) + geoModelSvc = acc.getPrimary() + + GeometryDBSvc=CompFactory.GeometryDBSvc + acc.addService(GeometryDBSvc("ScintGeometryDBSvc")) + + VetoNuDetectorTool = CompFactory.VetoNuDetectorTool + vetoNuDetectorTool = VetoNuDetectorTool() + + vetoNuDetectorTool.useDynamicAlignFolders = flags.GeoModel.Align.Dynamic + geoModelSvc.DetectorTools += [ vetoNuDetectorTool ] + + return acc diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuComponentFactory.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuComponentFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..711a8dfd097f349dddc59d33a00dc955090bcd2c --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuComponentFactory.cxx @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuComponentFactory.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <sstream> +#include <string> + +using ScintDD::VetoNuDetectorManager; + +const double VetoNuComponentFactory::s_epsilon = 1.0e-6 * Gaudi::Units::mm; + +VetoNuComponentFactory::VetoNuComponentFactory(const std::string & name, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials) + : m_detectorManager(detectorManager), + m_geometryManager(geometryManager), + m_materials(materials), + m_name(name) +{} + +VetoNuComponentFactory::~VetoNuComponentFactory() +{} + +std::string +VetoNuComponentFactory::intToString(int i) const +{ + std::ostringstream str; + str << i; + return str.str(); +} + +double +VetoNuComponentFactory::epsilon() const +{ + return s_epsilon; +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuComponentFactory.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuComponentFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..340f896f9b111f7b620194b7ded5943c72523899 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuComponentFactory.h @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETONUGEOMODEL_VETONUCOMPONENTFACTORY_H +#define VETONUGEOMODEL_VETONUCOMPONENTFACTORY_H + +#include "VetoNuIdentifier.h" +#include <string> + +namespace ScintDD{class VetoNuDetectorManager;} +class VetoNuGeometryManager; +class VetoNuMaterialManager; + +class GeoLogVol; +class GeoVPhysVol; + + +class VetoNuComponentFactory +{ + +public: + VetoNuComponentFactory(const std::string & name, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials); + + const std::string & getName() const {return m_name;} + + // utility function to covert int to string + std::string intToString(int i) const; + +protected: + ScintDD::VetoNuDetectorManager* m_detectorManager; + const VetoNuGeometryManager* m_geometryManager; + VetoNuMaterialManager* m_materials; + + double epsilon() const; + virtual ~VetoNuComponentFactory(); + +private: + std::string m_name; + static const double s_epsilon; + +}; + + +class VetoNuSharedComponentFactory : public VetoNuComponentFactory +{ + +public: + VetoNuSharedComponentFactory(const std::string & name, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials=nullptr) : + VetoNuComponentFactory(name, detectorManager, geometryManager, materials), + m_physVolume(nullptr) + {}; + + GeoVPhysVol * getVolume() {return m_physVolume;} + +protected: + GeoVPhysVol * m_physVolume; + virtual GeoVPhysVol * build() = 0; + +}; + +class VetoNuUniqueComponentFactory : public VetoNuComponentFactory +{ + +public: + VetoNuUniqueComponentFactory(const std::string & name, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials=nullptr) : + VetoNuComponentFactory(name, detectorManager, geometryManager, materials), + m_logVolume{nullptr} + {}; + + virtual GeoVPhysVol * build(VetoNuIdentifier id) = 0; + +protected: + const GeoLogVol * m_logVolume; + + virtual const GeoLogVol * preBuild() = 0; + +}; + +#endif // VETOGEOMODEL_VETOCOMPONENTFACTORY_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDataBase.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDataBase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..58c19908bda3299b05f846b04c24439d01d499ec --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDataBase.cxx @@ -0,0 +1,109 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuDataBase.h" + +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" + +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" + +#include "VetoNuGeoModel/VetoNuGeoModelAthenaComps.h" + +#include <iostream> + +VetoNuDataBase::VetoNuDataBase(const VetoNuGeoModelAthenaComps * athenaComps) +{ + m_athenaComps = athenaComps; + + IGeoDbTagSvc * geoDbTag = m_athenaComps->geoDbTagSvc(); + + // Get version tag and node for VetoNu + DecodeFaserVersionKey versionKey(geoDbTag,"VetoNu"); + std::string versionTag = versionKey.tag(); + std::string versionNode = versionKey.node(); + + // Get version tag and node for Scintillator. + DecodeFaserVersionKey scintVersionKey(geoDbTag,"Scintillator"); + + // Access the RDB + IRDBAccessSvc* rdbSvc = m_athenaComps->rdbAccessSvc(); + + // VetoNu version tag + m_vetoVersionTag = rdbSvc->getChildTag("VetoNu", versionKey.tag(), versionKey.node(), "FASERDD"); + + +///////////////////////////////////////////////////////// +// +// Gets the structures +// +///////////////////////////////////////////////////////// + + msg(MSG::INFO) << "Retrieving Record Sets from database ..." << endmsg; + msg(MSG::DEBUG) << " Using version tag: " << versionTag << endmsg; + msg(MSG::DEBUG) << " at node: " << versionNode << endmsg; + msg(MSG::DEBUG) << " VetoNu Version: " << m_vetoVersionTag << endmsg; + + // ATLS - not sure I use it. + // General atlas parameters + + // + // VetoNu General + // + + // VetoNu TopLevel + m_topLevel = rdbSvc->getRecordsetPtr("VetoNuTopLevel", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table VetoNuTopLevel Fetched" << endmsg; + + // Weight Table + m_weightTable = rdbSvc->getRecordsetPtr("VetoNuWeights", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table VetoNuWeights Fetched" << endmsg; + + // Extra Scaling Table. This is used for extra material studies. For nominal material the table should be empty. + // NB this is at InnerDetector level node. + m_scalingTable = rdbSvc->getRecordsetPtr("VetoNuMatScaling", scintVersionKey.tag(), scintVersionKey.node(), "FASERDD"); + msg(MSG::DEBUG) << "Table VetoNuMatScaling Fetched" << endmsg; + +// // Default conditions +// m_conditions = rdbSvc->getRecordsetPtr("VetoNuConditions", versionTag, versionNode, "FASERDD"); +// msg(MSG::DEBUG) << "Table VetoNuConditions Fetched" << endmsg; + + m_stationGeneral = rdbSvc->getRecordsetPtr("VetoNuStationGeneral", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table VetoNuStationGeneral Fetched" << endmsg; + + m_plateGeneral = rdbSvc->getRecordsetPtr("VetoNuPlateGeneral", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table VetoNuPlateGeneral Fetched" << endmsg; + + m_radiatorGeneral = rdbSvc->getRecordsetPtr("VetoNuRadiatorGeneral", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table VetoNuRadiatorGeneral Fetched" << endmsg; + + +} + +const VetoNuGeoModelAthenaComps* VetoNuDataBase::athenaComps() const { return m_athenaComps; } + +IRDBRecordset_ptr VetoNuDataBase::weightTable() const {return m_weightTable;} + +IRDBRecordset_ptr VetoNuDataBase::scalingTable() const {return m_scalingTable;} + +// //const IRDBRecord* VetoNuDataBase::atls() const {return *m_atls)[0];} +IRDBRecordset_ptr VetoNuDataBase::topLevelTable() const {return m_topLevel;} + +// IRDBRecordset_ptr VetoNuDataBase::conditionsTable() const {return m_conditions;} +// const IRDBRecord* VetoNuDataBase::conditions() const {return (*m_conditions)[0];} + +const IRDBRecord* VetoNuDataBase::stationGeneral() const {return (*m_stationGeneral)[0];} +const IRDBRecord* VetoNuDataBase::plateGeneral() const {return (*m_plateGeneral)[0];} +const IRDBRecord* VetoNuDataBase::radiatorGeneral() const {return (*m_radiatorGeneral)[0];} + +const std::string & VetoNuDataBase::versionTag() const { + return m_vetoVersionTag; +} + +MsgStream& VetoNuDataBase::msg (MSG::Level lvl) const +{ + return m_athenaComps->msg(lvl); +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDataBase.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDataBase.h new file mode 100644 index 0000000000000000000000000000000000000000..1028ed0198798fabf12c64604f9b25ddc355a427 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDataBase.h @@ -0,0 +1,155 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoNuGeoModel_VetoNuDataBase_H +#define VetoNuGeoModel_VetoNuDataBase_H + +#include "VetoNuGeoModel/VetoNuGeoModelAthenaComps.h" +#include <string> + +#include "RDBAccessSvc/IRDBAccessSvc.h" +class IRDBRecord; + + +class VetoNuDataBase +{ + + +public: + + VetoNuDataBase(const VetoNuGeoModelAthenaComps* athenaComps); + + const VetoNuGeoModelAthenaComps* athenaComps() const; + + IRDBRecordset_ptr weightTable() const; + IRDBRecordset_ptr scalingTable() const; + IRDBRecordset_ptr topLevelTable() const; + +// IRDBRecordset_ptr conditionsTable() const; +// const IRDBRecord* conditions() const; + +// const IRDBRecord* brlSensor() const; +// const IRDBRecord* brlModule() const; + +// const IRDBRecord* brlSki() const; +// const IRDBRecord* brlSkiZ(int i) const; +// int brlSkiZSize() const; +// const IRDBRecord* brlLayer(int i) const; +// const IRDBRecord* brlServices() const; +// const IRDBRecord* brlServPerLayer(int i) const; +// const IRDBRecord* brlThermalShield() const; + const IRDBRecord* stationGeneral() const; + const IRDBRecord* plateGeneral() const; + const IRDBRecord* radiatorGeneral() const; +// const IRDBRecord* brlFSI() const; +// int brlFSISize() const; +// const IRDBRecord* brlFSILocation(int i) const; + +// const IRDBRecord* fwdSensor(int i) const; +// const IRDBRecord* fwdHybrid() const; +// const IRDBRecord* fwdSpine(int i) const; +// const IRDBRecord* fwdModule(int i) const; +// int fwdModuleSize() const; +// IRDBRecordset_ptr fwdModuleConnectorTable() const; +// const IRDBRecord* fwdModuleConnector() const; + +// const IRDBRecord* fwdRing(int i) const; +// int fwdRingSize() const; +// const IRDBRecord* fwdWheel(int i) const; +// const IRDBRecord* fwdWheelRingMap(int i) const; +// int fwdWheelRingMapSize() const; +// const IRDBRecord* fwdDiscSupport() const; +// const IRDBRecord* fwdPatchPanelLoc(int i) const; +// int fwdPatchPanelLocSize() const; +// const IRDBRecord* fwdPatchPanel(int i) const; +// int fwdPatchPanelSize() const; +// const IRDBRecord* fwdPPConnector() const; +// int fwdPPConnectorSize() const; +// const IRDBRecord* fwdPPCooling() const; +// int fwdPPCoolingSize() const; +// const IRDBRecord* fwdCoolingBlock(int i) const; +// const IRDBRecord* fwdRingServices(int i) const; +// const IRDBRecord* fwdServices() const; +// const IRDBRecord* fwdFSILocation(int i) const; +// int fwdFSILocationSize() const; +// const IRDBRecord* fwdFSIType(int i) const; +// int fwdFSITypeSize() const; +// const IRDBRecord* fwdFSI(int i) const; +// int fwdFSISize() const; +// const IRDBRecord* fwdThermalShield(int i) const; +// int fwdThermalShieldSize() const; +// const IRDBRecord* fwdGeneral() const; +// IRDBRecordset_ptr fwdOptoHarnessTable() const; +// const IRDBRecord* fwdOptoHarness(int i) const; +// IRDBRecordset_ptr fwdDiscFixationTable() const; +// const IRDBRecord* fwdDiscFixation() const; +// const IRDBRecord* fwdCylServ(int i) const; +// int fwdCylServSize() const; +// const IRDBRecord* fwdCylServLoc(int i) const; +// int fwdCylServLocSize() const; + + // Return the VetoNu version tag. + const std::string & versionTag() const; + + MsgStream& msg (MSG::Level lvl) const; + +private: + + VetoNuDataBase(const VetoNuDataBase &); + VetoNuDataBase& operator= (const VetoNuDataBase &); + +private: + + const VetoNuGeoModelAthenaComps* m_athenaComps; + + std::string m_vetoVersionTag; + + IRDBRecordset_ptr m_weightTable; + IRDBRecordset_ptr m_scalingTable; + IRDBRecordset_ptr m_topLevel; + IRDBRecordset_ptr m_conditions; + +// IRDBRecordset_ptr m_brlSensor; +// IRDBRecordset_ptr m_brlModule; +// IRDBRecordset_ptr m_brlSki; +// IRDBRecordset_ptr m_brlSkiZ; +// IRDBRecordset_ptr m_brlLayer; +// IRDBRecordset_ptr m_brlServices; +// IRDBRecordset_ptr m_brlServPerLayer; +// IRDBRecordset_ptr m_brlThermalShield; + IRDBRecordset_ptr m_stationGeneral; + IRDBRecordset_ptr m_plateGeneral; + IRDBRecordset_ptr m_radiatorGeneral; +// IRDBRecordset_ptr m_brlFSI; +// IRDBRecordset_ptr m_brlFSILocation; +// IRDBRecordset_ptr m_fwdSensor; +// IRDBRecordset_ptr m_fwdHybrid; +// IRDBRecordset_ptr m_fwdSpine; +// IRDBRecordset_ptr m_fwdModule; +// IRDBRecordset_ptr m_fwdModuleConnector; +// IRDBRecordset_ptr m_fwdRing; +// IRDBRecordset_ptr m_fwdWheel; +// IRDBRecordset_ptr m_fwdWheelRingMap; +// IRDBRecordset_ptr m_fwdDiscSupport; +// IRDBRecordset_ptr m_fwdPatchPanelLoc; +// IRDBRecordset_ptr m_fwdPatchPanel; +// IRDBRecordset_ptr m_fwdPPConnector; +// IRDBRecordset_ptr m_fwdPPCooling; +// IRDBRecordset_ptr m_fwdCoolingBlock; +// IRDBRecordset_ptr m_fwdRingServices; +// IRDBRecordset_ptr m_fwdServices; +// IRDBRecordset_ptr m_fwdFSILocation; +// IRDBRecordset_ptr m_fwdFSIType; +// IRDBRecordset_ptr m_fwdFSI; +// IRDBRecordset_ptr m_fwdThermalShield; +// IRDBRecordset_ptr m_fwdGeneral; +// IRDBRecordset_ptr m_fwdOptoHarness; +// IRDBRecordset_ptr m_fwdDiscFixation; +// IRDBRecordset_ptr m_fwdCylServ; +// IRDBRecordset_ptr m_fwdCylServLoc; + + +}; + +#endif //VetoNuGeoModel_VetoNuDataBase_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorFactory.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e22fe6f59b314cb4a0c7054fbd0446047ed5a5ae --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorFactory.cxx @@ -0,0 +1,279 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// +// VetoNuDetectorFactory: This is the top level node +// + + +#include "VetoNuDetectorFactory.h" + +#include "VetoNuDataBase.h" +#include "VetoNuIdentifier.h" +#include "VetoNuGeometryManager.h" +#include "VetoNuMaterialManager.h" +#include "VetoNuGeneralParameters.h" +#include "ScintReadoutGeometry/Version.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" + +#include "VetoNuStation.h" +#include "VetoNuRadiator.h" +#include "VetoNuPlate.h" +#include "VetoNuDataBase.h" +#include "VetoNuGeoModel/VetoNuGeoModelAthenaComps.h" + +// +// GeoModel include files: +// +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoTube.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoNameTag.h" +#include "GeoModelKernel/GeoIdentifierTag.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoVPhysVol.h" +#include "GeoModelKernel/GeoTransform.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelKernel/GeoShape.h" +#include "GeoModelKernel/GeoShapeUnion.h" +#include "GeoModelKernel/GeoShapeShift.h" +#include "GeoModelInterfaces/StoredMaterialManager.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "DetDescrConditions/AlignableTransformContainer.h" +# +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/ISvcLocator.h" + +#include "GeoModelKernel/GeoDefinitions.h" +#include "GaudiKernel/SystemOfUnits.h" + + + +#include <iostream> +#include <iomanip> +#include <string> + +using ScintDD::VetoNuDetectorManager; +using ScintDD::ScintCommonItems; + +VetoNuDetectorFactory::VetoNuDetectorFactory(const VetoNuGeoModelAthenaComps * athenaComps, + const VetoNuOptions & options) + : ScintDD::DetectorFactoryBase(athenaComps), + m_useDynamicAlignFolders(false) +{ + + // Create the detector manager + m_detectorManager = new VetoNuDetectorManager(detStore()); + msg(MSG::DEBUG) << "Created VetoNuDetectorManager" << endmsg; + + // Create the database + m_db = new VetoNuDataBase{athenaComps}; + msg(MSG::DEBUG) << "Created VetoNuDataBase" << endmsg; + + // Create the material manager + m_materials = new VetoNuMaterialManager{m_db}; + msg(MSG::DEBUG) << "Created VetoNuMaterialManager" << endmsg; + + // Create the geometry manager. + m_geometryManager = new VetoNuGeometryManager{m_db}; + msg(MSG::DEBUG) << "Created VetoNuGeometryManager" << endmsg; + m_geometryManager->setOptions(options); + msg(MSG::DEBUG) << "Set options on VetoNuGeometryManager" << endmsg; + + m_useDynamicAlignFolders = options.dynamicAlignFolders(); + + // Set Version information + // Get the geometry tag + DecodeFaserVersionKey versionKey(geoDbTagSvc(),"VetoNu"); + IRDBRecordset_ptr switchSet + = rdbAccessSvc()->getRecordsetPtr("VetoNuSwitches", versionKey.tag(), versionKey.node(),"FASERDD"); + const IRDBRecord *switches = (*switchSet)[0]; + msg(MSG::DEBUG) << "Retrieved VetoNuSwitches" << endmsg; + + std::string layout = "Final"; + std::string description; + if (!switches->isFieldNull("LAYOUT")) { + layout = switches->getString("LAYOUT"); + } + if (!switches->isFieldNull("DESCRIPTION")) { + description = switches->getString("DESCRIPTION"); + } + + std::string versionTag = rdbAccessSvc()->getChildTag("VetoNu", versionKey.tag(), versionKey.node(),"FASERDD"); + std::string versionName = switches->getString("VERSIONNAME"); + int versionMajorNumber = 1; + int versionMinorNumber = 0; + int versionPatchNumber = 0; + ScintDD::Version version(versionTag, + versionName, + layout, + description, + versionMajorNumber, + versionMinorNumber, + versionPatchNumber); + m_detectorManager->setVersion(version); +} + + +VetoNuDetectorFactory::~VetoNuDetectorFactory() +{ + // NB the detector manager (m_detectorManager)is stored in the detector store by the + // Tool and so we don't delete it. + delete m_db; + delete m_materials; + delete m_geometryManager; +} + +void VetoNuDetectorFactory::create(GeoPhysVol *world) +{ + + msg(MSG::INFO) << "Building VetoNu Detector." << endmsg; + msg(MSG::INFO) << " " << m_detectorManager->getVersion().fullDescription() << endmsg; + + // Change precision. + int oldPrecision = std::cout.precision(6); + + // The tree tops get added to world. We name it "indet" though. + GeoPhysVol *scint = world; + + const VetoNuGeneralParameters * vetoGeneral = m_geometryManager->generalParameters(); + + GeoTrf::Transform3D vetoTransform = vetoGeneral->partTransform("VetoNu"); + + std::string stationA_Label = "StationA"; + std::string stationB_Label = "StationB"; + std::string radiator_Label = "Radiator"; + + bool stationA_Present = vetoGeneral->partPresent(stationA_Label); + bool stationB_Present = vetoGeneral->partPresent(stationB_Label); + bool radiator_Present = vetoGeneral->partPresent(radiator_Label); + // + // Plate is the same for all stations + // + VetoNuPlate plate("Plate", m_detectorManager, m_geometryManager, m_materials); + msg(MSG::DEBUG) << "Created VetoNu plate with dimensions (" << plate.thickness() << "," << plate.width() << "," << plate.length() << ")" << endmsg; + // + // Station A + // + if (stationA_Present) + { + msg(MSG::DEBUG) << "Building the VetoNu Station A." << endmsg; + m_detectorManager->numerology().addStation(0); + + // Create the station + VetoNuStation stationA("VetoNuStationA", &plate, m_detectorManager, m_geometryManager, m_materials); + VetoNuIdentifier id{m_geometryManager->athenaComps()->getIdHelper()}; + id.setStation(0); + GeoVPhysVol* stationA_PV = stationA.build(id); + GeoAlignableTransform* stationA_Transform = new GeoAlignableTransform(vetoTransform * vetoGeneral->partTransform(stationA_Label)); + + GeoNameTag* topLevelNameTag = new GeoNameTag("VetoNu"); + scint->add(topLevelNameTag); + scint->add(new GeoIdentifierTag(0)); + scint->add(stationA_Transform); + scint->add(stationA_PV); + m_detectorManager->addTreeTop(stationA_PV); + + // Store alignable transform for station (level = 1) + m_detectorManager->addAlignableTransform(1, id.getPlateId(), stationA_Transform, stationA_PV); + } + + // // + // // Station B + // // + // if (stationB_Present) + // { + // msg(MSG::DEBUG) << "Building the VetoNu Station B." << endmsg; + // m_detectorManager->numerology().addStation(1); + + // // Create the station + // VetoNuStation stationB("VetoNuStationB", &plate, m_detectorManager, m_geometryManager, m_materials); + // VetoNuIdentifier id{m_geometryManager->athenaComps()->getIdHelper()}; + // id.setStation(1); + // GeoVPhysVol* stationB_PV = stationB.build(id); + // GeoAlignableTransform* stationB_Transform = new GeoAlignableTransform(vetoTransform * vetoGeneral->partTransform(stationB_Label)); + + // GeoNameTag* topLevelNameTag = new GeoNameTag("VetoNu"); + // scint->add(topLevelNameTag); + // scint->add(new GeoIdentifierTag(0)); + // scint->add(stationB_Transform); + // scint->add(stationB_PV); + // m_detectorManager->addTreeTop(stationB_PV); + + // // Store alignable transform for station (level = 1) + // m_detectorManager->addAlignableTransform(1, id.getPlateId(), stationB_Transform, stationB_PV); + // } + + // // Passive radiator + // if (radiator_Present) + // { + // msg(MSG::DEBUG) << "Building the VetoNu Radiator." << endmsg; + + // // Create the radiator + // VetoNuRadiator radiator("VetoNuRadiator", m_detectorManager, m_geometryManager, m_materials); + // GeoAlignableTransform* radiator_Transform = new GeoAlignableTransform(vetoTransform * vetoGeneral->partTransform(radiator_Label)); + + // GeoNameTag* topLevelNameTag = new GeoNameTag("VetoNu"); + // scint->add(topLevelNameTag); + // scint->add(new GeoIdentifierTag(0)); + // scint->add(radiator_Transform); + // scint->add(radiator.getVolume()); + // m_detectorManager->addTreeTop(radiator.getVolume()); + + // } + + + // Set the neighbours + m_detectorManager->initNeighbours(); + + // Set number of pmts in numerology. + const ScintDD::ScintDetectorDesign* design = m_detectorManager->getVetoNuDesign(); + if (design != nullptr) + { + m_detectorManager->numerology().setNumPmtsPerPlate(m_detectorManager->getVetoNuDesign()->cells()); + } + else + { + m_detectorManager->numerology().setNumPmtsPerPlate(0); + } + + + // Register the keys and the level corresponding to the key + // and whether it expects a global or local shift. + // level 0: sensor, level 1: module, level 2, layer/disc, level 3: whole barrel/enccap + + + if (!m_useDynamicAlignFolders){ + + m_detectorManager->addAlignFolderType(ScintDD::static_run1); + // m_detectorManager->addFolder("/Scint/Align"); + } + else { + m_detectorManager->addAlignFolderType(ScintDD::timedependent_run2); + // m_detectorManager->addGlobalFolder("/Scint/AlignL1/Scint"); + // m_detectorManager->addGlobalFolder("/Scint/AlignL2/VetoNu"); + // m_detectorManager->addChannel("/Scint/AlignL1/Scint",3,ScintDD::global); + // m_detectorManager->addChannel("/Scint/AlignL2/VetoNu",2,ScintDD::global); + // m_detectorManager->addFolder("/Scint/AlignL3"); + } + + // Return precision to its original value + std::cout.precision(oldPrecision); + +} + + +const VetoNuDetectorManager * VetoNuDetectorFactory::getDetectorManager() const +{ + return m_detectorManager; +} + + diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorFactory.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..f9cc9e793dbd1a1cd4b088d79f5d3d30f81a0d1c --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorFactory.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETONUGEOMODEL_VETONUDETECTORFACTORY_H +#define VETONUGEOMODEL_VETONUDETECTORFACTORY_H + +#include "ScintGeoModelUtils/DetectorFactoryBase.h" +#include "ScintReadoutGeometry/VetoNuDetectorManager.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" + +class GeoPhysVol; +class VetoNuDataBase; +class VetoNuGeometryManager; +class VetoNuGeoModelAthenaComps; +class VetoNuMaterialManager; +class VetoNuOptions; + +class VetoNuDetectorFactory : public ScintDD::DetectorFactoryBase +{ + + public: + // Constructor + VetoNuDetectorFactory(const VetoNuGeoModelAthenaComps * athenaComps, + const VetoNuOptions & options); + + // Destructor + virtual ~VetoNuDetectorFactory(); + + // Creation of geometry: + virtual void create(GeoPhysVol *world); + + // Access to the results: + virtual const ScintDD::VetoNuDetectorManager * getDetectorManager() const; + + private: + // Copy and assignments operations illegal and so are made private + VetoNuDetectorFactory(const VetoNuDetectorFactory &right); + const VetoNuDetectorFactory & operator=(const VetoNuDetectorFactory &right); + + ScintDD::VetoNuDetectorManager *m_detectorManager; + VetoNuGeometryManager *m_geometryManager; + VetoNuDataBase* m_db; + VetoNuMaterialManager* m_materials; + bool m_useDynamicAlignFolders; + +}; + +#endif + diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorTool.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9b74df9592c7c1e4226163a36a06cd0e4a872962 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuDetectorTool.cxx @@ -0,0 +1,249 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuGeoModel/VetoNuDetectorTool.h" + +#include "VetoNuDetectorFactory.h" +#include "VetoNuDataBase.h" +// #include "VetoNuMaterialManager.h" +#include "VetoNuOptions.h" + +// temporary +#include "ScintReadoutGeometry/VetoNuDetectorManager.h" +#include "ScintIdentifier/VetoNuID.h" +#include "DetDescrConditions/AlignableTransformContainer.h" + +#include "GeoModelFaserUtilities/GeoModelExperiment.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" +#include "StoreGate/DataHandle.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" + +#include "AthenaKernel/ClassID_traits.h" +#include "SGTools/DataProxy.h" + +using ScintDD::VetoNuDetectorManager; +using ScintDD::ScintDetectorManager; + +// +// Constructor +// +VetoNuDetectorTool::VetoNuDetectorTool(const std::string& type, + const std::string& name, + const IInterface* parent) + : GeoModelTool(type, name, parent), + m_cosmic{false}, + m_manager{nullptr}, + m_athenaComps{ }, + m_geoDbTagSvc{"GeoDbTagSvc", name}, + m_rdbAccessSvc{"RDBAccessSvc", name}, + m_geometryDBSvc{"ScintGeometryDBSvc", name} +{ + // Get parameter values from jobOptions file + declareProperty("GeoDbTagSvc", m_geoDbTagSvc); + declareProperty("RDBAccessSvc", m_rdbAccessSvc); + declareProperty("GeometryDBSvc", m_geometryDBSvc); +} + +// +// Create the Geometry via the factory corresponding to this tool +// + +StatusCode +VetoNuDetectorTool::create() +{ + // Get the detector configuration. + ATH_CHECK(m_geoDbTagSvc.retrieve()); + + DecodeFaserVersionKey versionKey{&*m_geoDbTagSvc, "VetoNu"}; + // Issue error if AUTO. + if (versionKey.tag() == "AUTO") { + ATH_MSG_ERROR("AUTO Faser version. Please select a version."); + } + ATH_MSG_INFO("Building VetoNu with Version Tag: " << versionKey.tag() << " at Node: " << versionKey.node()); + + ATH_CHECK(m_rdbAccessSvc.retrieve()); + // Print the VetoNu version tag: + std::string vetoVersionTag{m_rdbAccessSvc->getChildTag("VetoNu", versionKey.tag(), versionKey.node(), "FASERDD")}; + ATH_MSG_INFO("VetoNu Version: " << vetoVersionTag); + // Check if version is empty. If so, then the VetoNu cannot be built. This may or may not be intentional. We + // just issue an INFO message. + if (vetoVersionTag.empty()) { + ATH_MSG_INFO("No VetoNu Version. VetoNu will not be built."); + } else { + std::string versionName; + if (versionKey.custom()) { + ATH_MSG_WARNING("VetoNuDetectorTool: Detector Information coming from a custom configuration!!"); + } else { + ATH_MSG_DEBUG("VetoNuDetectorTool: Detector Information coming from the database and job options IGNORED."); + ATH_MSG_DEBUG("Keys for VetoNu Switches are " << versionKey.tag() << " " << versionKey.node()); + + IRDBRecordset_ptr switchSet{m_rdbAccessSvc->getRecordsetPtr("VetoNuSwitches", versionKey.tag(), versionKey.node(), "FASERDD")}; + const IRDBRecord* switches{(*switchSet)[0]}; + m_detectorName.setValue(switches->getString("DETECTORNAME")); + + if (not switches->isFieldNull("COSMICLAYOUT")) + { + m_cosmic = switches->getInt("COSMICLAYOUT"); + } + if (not switches->isFieldNull("VERSIONNAME")) + { + versionName = switches->getString("VERSIONNAME"); + } + } + + ATH_MSG_DEBUG("Creating the VetoNu"); + ATH_MSG_DEBUG("VetoNu Geometry Options: "); + ATH_MSG_DEBUG(" Alignable: " << (m_alignable.value() ? "true" : "false")); + ATH_MSG_DEBUG(" CosmicLayout: " << (m_cosmic ? "true" : "false")); + ATH_MSG_DEBUG(" VersionName: " << versionName); + + VetoNuOptions options; + options.setAlignable(m_alignable.value()); + options.setDynamicAlignFolders(m_useDynamicAlignFolders.value()); + m_manager = nullptr; + + // + // Locate the top level experiment node + // + GeoModelExperiment* theExpt{nullptr}; + ATH_CHECK(detStore()->retrieve(theExpt, "FASER")); + + // Retrieve the Geometry DB Interface + ATH_CHECK(m_geometryDBSvc.retrieve()); + + // Pass athena services to factory, etc + m_athenaComps.setDetStore(detStore().operator->()); + m_athenaComps.setGeoDbTagSvc(&*m_geoDbTagSvc); + m_athenaComps.setGeometryDBSvc(&*m_geometryDBSvc); + m_athenaComps.setRDBAccessSvc(&*m_rdbAccessSvc); + const VetoNuID* idHelper{nullptr}; + ATH_CHECK(detStore()->retrieve(idHelper, "VetoNuID")); + m_athenaComps.setIdHelper(idHelper); + idHelper->test_plate_packing(); + // + // This strange way of casting is to avoid an + // utterly brain damaged compiler warning. + // + GeoPhysVol* world{&*theExpt->getPhysVol()}; + if (world != nullptr) ATH_MSG_INFO("Retrieved World PhysVol"); + + VetoNuDetectorFactory theVetoNu{&m_athenaComps, options}; + ATH_MSG_INFO("Created instance of detector factory"); + theVetoNu.create(world); + ATH_MSG_INFO("Called create methon on factory"); + m_manager = theVetoNu.getDetectorManager(); + ATH_MSG_INFO("Attempted to retrieve detector manager"); + + if (m_manager==nullptr) { + ATH_MSG_FATAL("VetoNuDetectorManager not created"); + return StatusCode::FAILURE; + } + + // Get the manager from the factory and store it in the detector store. + // m_detector is non constant so I can not set it to a const pointer. + // m_detector = theSCT.getDetectorManager(); + + ATH_MSG_DEBUG("Registering VetoNuDetectorManager. "); + ATH_CHECK(detStore()->record(m_manager, m_manager->getName())); + theExpt->addManager(m_manager); + + // Create a symLink to the ScintDetectorManager base class + const ScintDetectorManager* scintDetManager{m_manager}; + ATH_CHECK(detStore()->symLink(m_manager, scintDetManager)); + } + + return StatusCode::SUCCESS; +} + +StatusCode +VetoNuDetectorTool::clear() +{ + ATH_MSG_WARNING("Called untested VetoNuDetectorTool::clear()"); + SG::DataProxy* proxy{detStore()->proxy(ClassID_traits<VetoNuDetectorManager>::ID(), m_manager->getName())}; + if (proxy) { + proxy->reset(); + m_manager = nullptr; + } + return StatusCode::SUCCESS; +} + +StatusCode +VetoNuDetectorTool::registerCallback() +{ + StatusCode sc{StatusCode::FAILURE}; + if (m_alignable.value()) { + ATH_MSG_WARNING("Called untested VetoNuDetectorTool::registerCallback()"); + if (m_useDynamicAlignFolders.value()) { + + if (detStore()->contains<CondAttrListCollection>(m_run2L1Folder.value())) { + ATH_MSG_DEBUG("Registering callback on global Container with folder " << m_run2L1Folder.value()); + const DataHandle<CondAttrListCollection> calc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), calc, m_run2L1Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on global Container with folder " << m_run2L1Folder.value()); + return StatusCode::FAILURE; + } + + if (detStore()->contains<CondAttrListCollection>(m_run2L2Folder.value())) { + ATH_MSG_DEBUG("Registering callback on global Container with folder " << m_run2L2Folder.value()); + const DataHandle<CondAttrListCollection> calc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), calc, m_run2L2Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on global Container with folder " << m_run2L2Folder.value()); + return StatusCode::FAILURE; + } + + if (detStore()->contains<AlignableTransformContainer>(m_run2L3Folder.value())) { + ATH_MSG_DEBUG("Registering callback on AlignableTransformContainer with folder " << m_run2L3Folder.value()); + const DataHandle<AlignableTransformContainer> atc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), atc, m_run2L3Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on AlignableTransformContainer with folder " << m_run2L3Folder.value()); + return StatusCode::FAILURE; + } + + } else { + + if (detStore()->contains<AlignableTransformContainer>(m_run1Folder.value())) { + ATH_MSG_DEBUG("Registering callback on AlignableTransformContainer with folder " << m_run1Folder.value()); + const DataHandle<AlignableTransformContainer> atc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), atc, m_run1Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on AlignableTransformContainer with folder " + << m_run1Folder.value() << ", Alignment disabled (only if no Run2 scheme is loaded)!"); + return StatusCode::FAILURE; + } + } + } else { + ATH_MSG_INFO("Alignment disabled. No callback registered"); + // We return failure otherwise it will try and register + // a GeoModelSvc callback associated with this callback. + return StatusCode::FAILURE; + } + return sc; +} + +StatusCode +VetoNuDetectorTool::align(IOVSVC_CALLBACK_ARGS_P(I, keys)) +{ + ATH_MSG_WARNING("Called untested VetoNuDetectorTool::align()"); + void* i = &I; + void* k = &keys; + if (i == nullptr && k == nullptr) return StatusCode::SUCCESS; // suppress stupid warning + if (m_manager==nullptr) { + ATH_MSG_FATAL("Manager does not exist"); + return StatusCode::FAILURE; + } + if (m_alignable.value()) { + return m_manager->align(I, keys); + } else { + ATH_MSG_DEBUG("Alignment disabled. No alignments applied"); + return StatusCode::SUCCESS; + } +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeneralParameters.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeneralParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2e88fe60692993cd96c766032a9a396e8fb65416 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeneralParameters.cxx @@ -0,0 +1,88 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuGeneralParameters.h" +#include "VetoNuDataBase.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "GaudiKernel/SystemOfUnits.h" +#include "GeoModelKernel/GeoDefinitions.h" +#include "ScintGeoModelUtils/TopLevelPlacements.h" + +const double VetoNuSAFETY = 0.01 * Gaudi::Units::mm; // Used in some places to make envelopes slightly larger to ensure + // no overlaps due to rounding errors. + + +VetoNuGeneralParameters::VetoNuGeneralParameters(VetoNuDataBase* rdb) +{ + m_rdb = rdb; + m_placements = new TopLevelPlacements(m_rdb->topLevelTable()); +} + + +VetoNuGeneralParameters::~VetoNuGeneralParameters() +{ + delete m_placements; +} + + +const GeoTrf::Transform3D & +VetoNuGeneralParameters::partTransform(const std::string & partName) const +{ + return m_placements->transform(partName); +} + + +bool +VetoNuGeneralParameters::partPresent(const std::string & partName) const +{ + return m_placements->present(partName); +} + + + +// +// General +// +double +VetoNuGeneralParameters::safety() const +{ + return VetoNuSAFETY; +} + +// Default Conditions. Values should be come form conditions data base. These values provide +// default vlaues if nothing from the conditions database is provided. + + +// double +// VetoNuGeneralParameters::temperature() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 266.15 * Gaudi::Units::kelvin; // -7 C +// } +// return (m_rdb->conditions()->getDouble("TEMPERATURE") + 273.15) * Gaudi::Units::kelvin; +// } + + +// double +// SCT_GeneralParameters::biasVoltage() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 100 * Gaudi::Units::volt; +// } +// return m_rdb->conditions()->getDouble("BIASVOLT") * Gaudi::Units::volt; +// } + +// double +// SCT_GeneralParameters::depletionVoltage() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 20 * Gaudi::Units::volt; +// } +// return m_rdb->conditions()->getDouble("DEPLETIONVOLT") * Gaudi::Units::volt; +// } + + + + diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeneralParameters.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeneralParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..d8a6d55788bf3ea6347204ecd8980f79f157854d --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeneralParameters.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoNuGeoModel_VetoNuGeneralParameters_H +#define VetoNuGeoModel_VetoNuGeneralParameters_H + +#include "GeoModelKernel/GeoDefinitions.h" + +#include <map> +#include <string> + +class VetoNuDataBase; +class TopLevelPlacements; + +class VetoNuGeneralParameters { + +public: + + VetoNuGeneralParameters(VetoNuDataBase* rdb); + ~VetoNuGeneralParameters(); + //Explicitly disallow copy, assignment to appease coverity + VetoNuGeneralParameters(const VetoNuGeneralParameters &) = delete; + VetoNuGeneralParameters & operator=(const VetoNuGeneralParameters &) = delete; + + // General + double safety() const; + + //Default conditions. +// double temperature() const; +// double biasVoltage() const; +// double depletionVoltage() const; + + const GeoTrf::Transform3D & partTransform(const std::string & partName) const; + bool partPresent(const std::string & partName) const; + +private: + + VetoNuDataBase * m_rdb; + TopLevelPlacements * m_placements; + +}; + + +#endif // SCT_GeoModel_SCT_GeneralParameters_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeoModelAthenaComps.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeoModelAthenaComps.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ad8256acbb791c752d6cf80272104e4f76944b98 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeoModelAthenaComps.cxx @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuGeoModel/VetoNuGeoModelAthenaComps.h" + +VetoNuGeoModelAthenaComps::VetoNuGeoModelAthenaComps() + : ScintDD::AthenaComps("VetoNuGeoModel"), + m_idHelper(0) +{} + +void +VetoNuGeoModelAthenaComps::setIdHelper(const VetoNuID* idHelper) +{ + m_idHelper = idHelper; +} + +const VetoNuID* +VetoNuGeoModelAthenaComps::getIdHelper() const +{ + return m_idHelper; +} + diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeometryManager.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeometryManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..df334a198a6f6c6a8c61d66863327000a2e3c71d --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeometryManager.cxx @@ -0,0 +1,123 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuGeometryManager.h" + +#include "ScintGeoModelUtils/DistortedMaterialManager.h" +#include "ScintIdentifier/VetoNuID.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" +#include "VetoNuStationParameters.h" +#include "VetoNuPlateParameters.h" +#include "VetoNuRadiatorParameters.h" +#include "VetoNuDataBase.h" +#include "VetoNuGeneralParameters.h" +#include "VetoNuGeoModel/VetoNuGeoModelAthenaComps.h" + +VetoNuGeometryManager::VetoNuGeometryManager(VetoNuDataBase* rdb) + : m_athenaComps{rdb->athenaComps()}, + m_rdb{rdb} +{ + // This class uses reference counting. Should not be delete'd in destructor. + m_commonItems = new ScintDD::ScintCommonItems(m_athenaComps->getIdHelper()); + + m_stationParameters = std::make_unique<VetoNuStationParameters>(m_rdb); + m_plateParameters = std::make_unique<VetoNuPlateParameters>(m_rdb); + m_radiatorParameters = std::make_unique<VetoNuRadiatorParameters>(m_rdb); + m_generalParameters = std::make_unique<VetoNuGeneralParameters>(m_rdb); + m_distortedMatManager = std::make_unique<ScintDD::DistortedMaterialManager>(); +} + +VetoNuGeometryManager::~VetoNuGeometryManager() +{ +} + +// +// Access to run time options. +// +const VetoNuOptions & +VetoNuGeometryManager::options() const +{ + return m_options; +} + +void +VetoNuGeometryManager::setOptions(const VetoNuOptions & options) +{ + m_options = options; +} + +const VetoNuGeoModelAthenaComps * +VetoNuGeometryManager::athenaComps() const +{ + return m_athenaComps; +} + +// +// ScintCommonItems which are passed to ScintDetectorElements. +// + +const ScintDD::ScintCommonItems * +VetoNuGeometryManager::commonItems() const +{ + return m_commonItems; +} + +const VetoNuStationParameters * +VetoNuGeometryManager::stationParameters() const +{ + return m_stationParameters.get(); +} + +const VetoNuPlateParameters * +VetoNuGeometryManager::plateParameters() const +{ + return m_plateParameters.get(); +} + +const VetoNuRadiatorParameters * +VetoNuGeometryManager::radiatorParameters() const +{ + return m_radiatorParameters.get(); +} + + +const VetoNuGeneralParameters * +VetoNuGeometryManager::generalParameters() const +{ + return m_generalParameters.get(); +} + +const ScintDD::DistortedMaterialManager * +VetoNuGeometryManager::distortedMatManager() const +{ + return m_distortedMatManager.get(); +} + +VetoNuGeometryManager& +VetoNuGeometryManager::operator=(const VetoNuGeometryManager& right) { + if (this != &right) { + m_options = right.m_options; + m_athenaComps = right.m_athenaComps; + m_commonItems = right.m_commonItems; + m_rdb = right.m_rdb; + m_stationParameters.reset(new VetoNuStationParameters(m_rdb)); + m_plateParameters.reset(new VetoNuPlateParameters(m_rdb)); + m_radiatorParameters.reset(new VetoNuRadiatorParameters(m_rdb)); + m_generalParameters.reset(new VetoNuGeneralParameters(m_rdb)); + m_distortedMatManager.reset(new ScintDD::DistortedMaterialManager()); + } + return *this; +} + +VetoNuGeometryManager::VetoNuGeometryManager(const VetoNuGeometryManager& right) { + m_options = right.m_options; + m_athenaComps = right.m_athenaComps; + m_commonItems = right.m_commonItems; + m_rdb = right.m_rdb; + m_stationParameters.reset(new VetoNuStationParameters(m_rdb)); + m_plateParameters.reset(new VetoNuPlateParameters(m_rdb)); + m_radiatorParameters.reset(new VetoNuRadiatorParameters(m_rdb)); + m_generalParameters.reset(new VetoNuGeneralParameters(m_rdb)); + m_distortedMatManager.reset(new ScintDD::DistortedMaterialManager()); +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeometryManager.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeometryManager.h new file mode 100644 index 0000000000000000000000000000000000000000..0fa5eff1bc628cf691df5ee05269832b5aa62eb4 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuGeometryManager.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoNuGeoModel_VetoNuGeometryManager_H +#define VetoNuGeoModel_VetoNuGeometryManager_H + +#include "VetoNuOptions.h" + +#include <memory> + +namespace ScintDD { + class ScintCommonItems; + class DistortedMaterialManager; +} + +class VetoNuStationParameters; +class VetoNuPlateParameters; +class VetoNuRadiatorParameters; +class VetoNuDataBase; +class VetoNuGeneralParameters; +class VetoNuGeoModelAthenaComps; + +class VetoNuGeometryManager { + +public: + + // Constructor + VetoNuGeometryManager(VetoNuDataBase* rdb); + + // Destructor + ~VetoNuGeometryManager(); + + // Access to run time options + const VetoNuOptions & options() const; + void setOptions(const VetoNuOptions & options); + + // Access to athena components + const VetoNuGeoModelAthenaComps * athenaComps() const; + + // To be passed to detector element. + const ScintDD::ScintCommonItems * commonItems() const; + + const VetoNuStationParameters* stationParameters() const; + const VetoNuPlateParameters* plateParameters() const; + const VetoNuRadiatorParameters* radiatorParameters() const; + const VetoNuGeneralParameters* generalParameters() const; + const ScintDD::DistortedMaterialManager* distortedMatManager() const; + + VetoNuGeometryManager& operator=(const VetoNuGeometryManager& right); + VetoNuGeometryManager(const VetoNuGeometryManager& right); + +private: + + VetoNuOptions m_options; + const VetoNuGeoModelAthenaComps * m_athenaComps; + ScintDD::ScintCommonItems * m_commonItems; + VetoNuDataBase* m_rdb; + + std::unique_ptr<VetoNuStationParameters> m_stationParameters; + std::unique_ptr<VetoNuPlateParameters> m_plateParameters; + std::unique_ptr<VetoNuRadiatorParameters> m_radiatorParameters; + std::unique_ptr<VetoNuGeneralParameters> m_generalParameters; + std::unique_ptr<ScintDD::DistortedMaterialManager> m_distortedMatManager; + +}; + + +#endif // VetoNuGeoModel_VetoNuGeometryManager_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuIdentifier.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuIdentifier.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8ef8f33806fce3f29f70568fe1feeac9c623eaad --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuIdentifier.cxx @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuIdentifier.h" +#include "ScintIdentifier/VetoNuID.h" +#include "Identifier/Identifier.h" + +#include <cassert> +#include <iostream> + +Identifier +VetoNuIdentifier::getPlateId() +{ + assert (m_idHelper); + return m_idHelper->plate_id(m_station, m_plate); +} + +void VetoNuIdentifier::print() +{ + std::cout << "2/1/" << m_station << "/" + << m_plate << std::endl; +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuIdentifier.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuIdentifier.h new file mode 100644 index 0000000000000000000000000000000000000000..b19425ffe01c560ad0338cd28c6d04b05131e0a2 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuIdentifier.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETONUGEOMODEL_VETONUIDENTIFIER_H +#define VETONUGEOMODEL_VETONUIDENTIFIER_H + +class Identifier; +class VetoNuID; + +class VetoNuIdentifier +{ +public: + + VetoNuIdentifier( const VetoNuID* idHelper, + int station = 0, + int plate = 0 ) + : m_idHelper{idHelper}, + m_station{station}, + m_plate{plate} + {}; + + + void setStation(int i) {m_station = i;} + int getStation() const {return m_station;} + + void setPlate(int i) {m_plate = i;} + int getPlate() const {return m_plate;} + + Identifier getPlateId(); + + // For debugging purposes. + void print(); + +private: + const VetoNuID* m_idHelper; + int m_station; + int m_plate; +}; + +#endif // VETOGEOMODEL_VETOIDENTIFIER_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuMaterialManager.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuMaterialManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..da71318c2526648265235b17e51297ef98f9dde5 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuMaterialManager.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuMaterialManager.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoElement.h" +#include "VetoNuDataBase.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> + +// Constructor +VetoNuMaterialManager::VetoNuMaterialManager(VetoNuDataBase* db) +{ + // Get my material manager. + ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap + StoreGateSvc* detStore; + StatusCode sc = svcLocator->service("DetectorStore", detStore ); + if (sc.isFailure()) { + std::cout << "Could not locate DetectorStore" << std::endl; + return; + } + + m_materialManager = std::make_unique<ScintMaterialManager>("VetoNuMaterialManager", db->athenaComps()); + m_materialManager->addWeightTable(db->weightTable(), "veto"); + m_materialManager->addScalingTable(db->scalingTable()); + + loadMaterials(); + + m_gasMaterial = m_materialManager->getMaterial("std::Air"); +} + +// Add materials not yet in the database +void +VetoNuMaterialManager::loadMaterials() +{ +} + +const GeoElement* +VetoNuMaterialManager::getElement(const std::string & elementName) const +{ + return m_materialManager->getElement(elementName); +} + +const GeoMaterial* +VetoNuMaterialManager::getMaterial(const std::string & materialName) const +{ + return m_materialManager->getMaterial(materialName); +} + +void +VetoNuMaterialManager::addMaterial(GeoMaterial* material) +{ + return m_materialManager->addMaterial(material); +} + +const GeoMaterial* +VetoNuMaterialManager::getMaterial(const std::string & originalMaterial, + double density, + const std::string & newName) +{ + + return m_materialManager->getMaterial(originalMaterial, density, newName); +} + +const GeoMaterial * +VetoNuMaterialManager::getMaterialForVolume(const std::string & materialName, double volume) +{ + return m_materialManager->getMaterialForVolume(materialName, volume); +} + + + +const GeoMaterial* +VetoNuMaterialManager::gasMaterial() const +{ + return m_gasMaterial; +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuMaterialManager.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuMaterialManager.h new file mode 100644 index 0000000000000000000000000000000000000000..32f0ded52b1868e2b09b926d64d9bf3c6417dbff --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuMaterialManager.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETONUMATERIALMANAGER_H +#define VETONUMATERIALMANAGER_H + +// VetoNuMaterialManager. This provides an interface to the ScintMaterialManager which in turn +// is an interface to GeoModel Material Manager with some additional functionality. +#include "ScintGeoModelUtils/ScintMaterialManager.h" + +#include <memory> +#include <string> + +class GeoMaterial; +class GeoElement; +class ScintMaterialManager; +class VetoNuDataBase; + +class VetoNuMaterialManager +{ + +public: + + VetoNuMaterialManager(VetoNuDataBase* db); + + const GeoMaterial* getMaterial(const std::string & materialName) const; + const GeoElement* getElement(const std::string & elementName) const; + + const GeoMaterial* getMaterial(const std::string & originalMaterial, + double density, + const std::string & newName = ""); + const GeoMaterial *getMaterialForVolume(const std::string & materialName, double volume); + + // Default gas material + const GeoMaterial* gasMaterial() const; + +private: + void loadMaterials(); + void addMaterial(GeoMaterial* material); + + std::unique_ptr<ScintMaterialManager> m_materialManager; + const GeoMaterial* m_gasMaterial; + +}; + + +#endif // VETONUMATERIALMANAGER_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuOptions.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuOptions.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0c63b320f4d5e2063e5047c4fa07a0ac1ebd011c --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuOptions.cxx @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuOptions.h" + +VetoNuOptions::VetoNuOptions() + : m_alignable(true) +// , m_alignModule(true) + , m_dynAlignFolders(false) +{} + +void +VetoNuOptions::setAlignable(bool flag) +{ + m_alignable = flag; +} + +bool +VetoNuOptions::alignable() const +{ + return m_alignable; +} + +// following may eventually become useful +// +// void +// SCT_Options::setAlignAtModuleLevel(bool flag) +// { +// m_alignModule = flag; +// } + +// bool +// SCT_Options::alignAtModuleLevel() const +// { +// return m_alignModule; +// } + +void VetoNuOptions::setDynamicAlignFolders(const bool flag) +{ + m_dynAlignFolders = flag; +} + +bool VetoNuOptions::dynamicAlignFolders() const +{ + return m_dynAlignFolders; +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuOptions.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuOptions.h new file mode 100644 index 0000000000000000000000000000000000000000..166ae9e6cb2116b3372b3d485e5b9df0f91402aa --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuOptions.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoNuGeoModel_VetoNuOptions_H +#define VetoNuGeoModel_VetoNuOptions_H + +// Class for any run time options. + + +class VetoNuOptions +{ + +public: + VetoNuOptions(); + bool alignable() const; +// bool alignAtModuleLevel() const; + + void setAlignable(bool flag = true); +// void setAlignAtModuleLevel(bool flag = true); + + //dynamic alignment folders + void setDynamicAlignFolders(const bool flag = true); + bool dynamicAlignFolders() const; + +private: + + bool m_alignable; +// bool m_alignModule; + bool m_dynAlignFolders; //controls which set of alignment folders is used + +}; + + +#endif // VetoNuGeoModel_VetoNuOptions_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlate.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlate.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e14c88cbe5cb09c886752d7be8d8a57c0dfbd836 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlate.cxx @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuPlate.h" + +#include "VetoNuGeometryManager.h" +#include "VetoNuMaterialManager.h" + +#include "VetoNuPlateParameters.h" + +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoMaterial.h" + +#include "ScintReadoutGeometry/VetoNuDetectorManager.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" +#include "ScintReadoutGeometry/ScintDetectorElement.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" + +#include "GaudiKernel/SystemOfUnits.h" + +using namespace ScintDD; + +VetoNuPlate::VetoNuPlate(const std::string & name, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials) + : VetoNuUniqueComponentFactory(name, detectorManager, geometryManager, materials), + m_noElementWarning{true} +{ + getParameters(); + m_logVolume = preBuild(); +} + + +void +VetoNuPlate::getParameters() +{ + + const VetoNuPlateParameters * parameters = m_geometryManager->plateParameters(); + m_material = m_materials->getMaterial(parameters->plateMaterial()); + m_thickness = parameters->plateThickness(); + m_length = parameters->plateLength(); + m_width = parameters->plateWidth(); + m_detectorManager->numerology().setNumPmtsPerPlate(parameters->platePmts()); +} + +const GeoLogVol * +VetoNuPlate::preBuild() +{ + + // Build the plate. Just a simple box. + // const GeoBox * plateShape = new GeoBox(0.5*m_thickness, 0.5*m_width, 0.5*m_length); + const GeoBox * plateShape = new GeoBox(0.5*m_width, 0.5*m_length, 0.5*m_thickness); + GeoLogVol * plateLog = new GeoLogVol(getName(), plateShape, m_material); + + // Make the scint design for this plate + makeDesign(); + + m_detectorManager->setDesign(m_design); + + return plateLog; +} + + +void +VetoNuPlate::makeDesign() +{ + //SiDetectorDesign::Axis etaAxis = SiDetectorDesign::zAxis; + //SiDetectorDesign::Axis phiAxis = SiDetectorDesign::yAxis; + //SiDetectorDesign::Axis depthAxis = SiDetectorDesign::xAxis; + + const VetoNuPlateParameters * parameters = m_geometryManager->plateParameters(); + + m_design = new ScintDetectorDesign(m_thickness, + m_length, + m_width, + parameters->platePmts()); +} + + + +GeoVPhysVol * +VetoNuPlate::build(VetoNuIdentifier id) +{ + GeoFullPhysVol * plate = new GeoFullPhysVol(m_logVolume); + + // Make detector element and add to collection + // Only do so if we have a valid id helper. + + //id.print(); // for debugging only + + const ScintCommonItems* commonItems = m_geometryManager->commonItems(); + + if (commonItems->getIdHelper()) { + + ScintDetectorElement * detElement; + + detElement = new ScintDetectorElement(id.getPlateId(), + m_design, + plate, + commonItems); + + // Add the detector element. + m_detectorManager->addDetectorElement(detElement); + + } else { + if (m_noElementWarning) { + std::cout << "WARNING!!!!: No VetoNu id helper and so no elements being produced." << std::endl; + m_noElementWarning = false; + } + } + return plate; +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlate.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlate.h new file mode 100644 index 0000000000000000000000000000000000000000..efc8638052c8dcb8c083d63584dccf649354d7ce --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlate.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETONUGEOMODEL_VETONUPLATE_H +#define VETONUGEOMODEL_VETONUPLATE_H + +#include "VetoNuComponentFactory.h" + +#include <atomic> +#include <string> + +class GeoMaterial; +class GeoVPhysVol; +namespace ScintDD{class ScintDetectorDesign;} + +class VetoNuPlate: public VetoNuUniqueComponentFactory +{ +public: + VetoNuPlate(const std::string & name, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials); + +public: + const GeoMaterial * material() const {return m_material;} + double thickness() const {return m_thickness;} + double width() const {return m_width;} + double length() const {return m_length;} + + virtual GeoVPhysVol * build(VetoNuIdentifier id); + +private: + void getParameters(); + virtual const GeoLogVol * preBuild(); + void makeDesign(); + + const GeoMaterial * m_material; + double m_thickness; + double m_width; + double m_length; + + ScintDD::ScintDetectorDesign * m_design; + + mutable std::atomic_bool m_noElementWarning; +}; + +#endif // VETOGEOMODEL_VETOPLATE_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlateParameters.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlateParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..121df4dcbc9c60ead0099ea05b22d9de56e78809 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlateParameters.cxx @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuPlateParameters.h" +#include "VetoNuGeometryManager.h" + +#include "VetoNuDataBase.h" + +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> + + +VetoNuPlateParameters::VetoNuPlateParameters(VetoNuDataBase* rdb) +{ + m_rdb = rdb; +} + +// +// Plate General +// +int +VetoNuPlateParameters::platePmts() const +{ + return m_rdb->plateGeneral()->getInt("NUMPMTS"); +} + +double +VetoNuPlateParameters::plateWidth() const +{ + return m_rdb->plateGeneral()->getDouble("WIDTH") * Gaudi::Units::mm; +} + +double +VetoNuPlateParameters::plateLength() const +{ + return m_rdb->plateGeneral()->getDouble("LENGTH") * Gaudi::Units::mm; +} + +double +VetoNuPlateParameters::plateThickness() const +{ + return m_rdb->plateGeneral()->getDouble("THICKNESS") * Gaudi::Units::mm; +} + +std::string VetoNuPlateParameters::plateMaterial() const +{ + return m_rdb->plateGeneral()->getString("MATERIAL"); +} + diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlateParameters.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlateParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..11ebd07129db93286277420b25c532d2cf51bbce --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuPlateParameters.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoNuGeoModel_VetoNuPlateParameters_H +#define VetoNuGeoModel_VetoNuPlateParameters_H + +#include <string> + +class VetoNuDataBase; + +class VetoNuPlateParameters { + +public: + + // Constructor + VetoNuPlateParameters(VetoNuDataBase* rdb); + + // Barrel General + int platePmts() const; + double plateThickness() const; + double plateWidth() const; + double plateLength() const; + std::string plateMaterial() const; + + private: + VetoNuDataBase * m_rdb; + +}; + + +#endif // VetoNuGeoModel_VetoNuPlateParameters_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiator.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiator.cxx new file mode 100644 index 0000000000000000000000000000000000000000..49a9fe83c78c883f968f020d38e942fcd53ffdbe --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiator.cxx @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuRadiator.h" + +#include "VetoNuMaterialManager.h" + +#include "VetoNuGeometryManager.h" +#include "VetoNuGeneralParameters.h" +#include "VetoNuRadiatorParameters.h" + +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoMaterial.h" + +VetoNuRadiator::VetoNuRadiator(const std::string & name, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials) + : VetoNuSharedComponentFactory(name, detectorManager, geometryManager, materials) +{ + getParameters(); + m_physVolume = build(); +} + +void +VetoNuRadiator::getParameters() +{ + const VetoNuRadiatorParameters * parameters = m_geometryManager->radiatorParameters(); + const VetoNuGeneralParameters* generalParameters = m_geometryManager->generalParameters(); + + m_material = m_materials->getMaterial(parameters->radiatorMaterial()); + m_safety = generalParameters->safety(); + m_thickness = parameters->radiatorThickness(); + m_width = parameters->radiatorWidth(); + m_length = parameters->radiatorLength(); +} + +GeoVPhysVol * +VetoNuRadiator::build() +{ + // Just a simple box. + const GeoBox * simpleRadiatorShape = new GeoBox(0.5*m_width, + 0.5*m_length, + 0.5*m_thickness); + + const GeoLogVol * simpleRadiatorLog = + new GeoLogVol(getName(), simpleRadiatorShape, m_material); + + GeoPhysVol * simpleRadiator = new GeoPhysVol(simpleRadiatorLog); + + return simpleRadiator; +} diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiator.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiator.h new file mode 100644 index 0000000000000000000000000000000000000000..5c25fcec17f21b848c1a7f9e3f41d2b396e77277 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiator.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETONUGEOMODEL_VETONURADIATOR_H +#define VETONUGEOMODEL_VETONURADIATOR_H + +#include "VetoNuComponentFactory.h" + +class GeoVPhysVol; +class GeoFullPhysVol; +class GeoLogVol; +class GeoMaterial; + +class VetoNuRadiator : public VetoNuSharedComponentFactory +{ + +public: + VetoNuRadiator(const std::string & name, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials); + +public: + const GeoMaterial * material() const {return m_material;} + double thickness() const {return m_thickness;} + double width() const {return m_width;} + double length() const {return m_length;} + +private: + virtual GeoVPhysVol * build(); + void getParameters(); + + const GeoMaterial * m_material; + double m_thickness; + double m_width; + double m_length; + + double m_safety; +}; + +#endif // VETOGEOMODEL_VETORADIATOR_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiatorParameters.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiatorParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..33391054eaba30e6fde505065921e3a2594cd0d2 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiatorParameters.cxx @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuRadiatorParameters.h" +#include "VetoNuGeometryManager.h" + +#include "VetoNuDataBase.h" + +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> + + +VetoNuRadiatorParameters::VetoNuRadiatorParameters(VetoNuDataBase* rdb) +{ + m_rdb = rdb; +} + +// +// Radiator General +// +double +VetoNuRadiatorParameters::radiatorWidth() const +{ + return m_rdb->radiatorGeneral()->getDouble("WIDTH") * Gaudi::Units::mm; +} + +double +VetoNuRadiatorParameters::radiatorLength() const +{ + return m_rdb->radiatorGeneral()->getDouble("LENGTH") * Gaudi::Units::mm; +} + +double +VetoNuRadiatorParameters::radiatorThickness() const +{ + return m_rdb->radiatorGeneral()->getDouble("THICKNESS") * Gaudi::Units::mm; +} + +std::string VetoNuRadiatorParameters::radiatorMaterial() const +{ + return m_rdb->radiatorGeneral()->getString("MATERIAL"); +} + diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiatorParameters.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiatorParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..eedd316d60e0c52a5b4f0b55640a5ddfea62f7b4 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuRadiatorParameters.h @@ -0,0 +1,31 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoNuGeoModel_VetoNuRadiatorParameters_H +#define VetoNuGeoModel_VetoNuRadiatorParameters_H + +#include <string> + +class VetoNuDataBase; + +class VetoNuRadiatorParameters { + +public: + + // Constructor + VetoNuRadiatorParameters(VetoNuDataBase* rdb); + + // Barrel General + double radiatorThickness() const; + double radiatorWidth() const; + double radiatorLength() const; + std::string radiatorMaterial() const; + + private: + VetoNuDataBase * m_rdb; + +}; + + +#endif // VetoNuGeoModel_VetoNuRadiatorParameters_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStation.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStation.cxx new file mode 100644 index 0000000000000000000000000000000000000000..65fb5fd7b80d4eb2af761723476d75259923af43 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStation.cxx @@ -0,0 +1,100 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuStation.h" + +#include "VetoNuMaterialManager.h" + +#include "VetoNuGeometryManager.h" +#include "VetoNuStationParameters.h" +#include "VetoNuGeneralParameters.h" +#include "VetoNuIdentifier.h" +#include "VetoNuPlate.h" + +#include "ScintReadoutGeometry/VetoNuDetectorManager.h" + +#include "ScintGeoModelUtils/ExtraMaterial.h" + +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoNameTag.h" +#include "GeoModelKernel/GeoIdentifierTag.h" +#include "GeoModelKernel/GeoTransform.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoShape.h" +#include "GeoModelKernel/GeoShapeShift.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> + +VetoNuStation::VetoNuStation(const std::string & name, + VetoNuPlate* plate, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials) + : VetoNuUniqueComponentFactory(name, detectorManager, geometryManager, materials), + m_plate { plate } +{ + getParameters(); + m_logVolume = preBuild(); +} + + +void +VetoNuStation::getParameters() +{ + const VetoNuStationParameters * parameters = m_geometryManager->stationParameters(); + + m_numPlates = parameters->numPlates(); + m_platePitch = parameters->platePitch(); + + const VetoNuGeneralParameters* generalParameters = m_geometryManager->generalParameters(); + m_safety = generalParameters->safety(); + + m_width = m_plate->width() + m_safety; + m_length = m_plate->length() + m_safety; + // pitch includes thickness of one plate + m_thickness = (m_numPlates - 1) * m_platePitch + m_plate->thickness() + m_safety; + + // Set numerology + m_detectorManager->numerology().setNumPlatesPerStation(m_numPlates); +} + +const GeoLogVol * +VetoNuStation::preBuild() +{ + // Create the station volume + // Box envelope containing the station. + const GeoBox* stationEnvelopeShape = new GeoBox(0.5 * m_width, 0.5 * m_length, 0.5 * m_thickness); + GeoLogVol* stationLog = new GeoLogVol(getName(), stationEnvelopeShape, m_materials->gasMaterial()); + return stationLog; +} + +GeoVPhysVol * +VetoNuStation::build(VetoNuIdentifier id) +{ + + GeoFullPhysVol * station = new GeoFullPhysVol(m_logVolume); + + double activeDepth = m_thickness - m_safety; + double plateThickness = m_plate->thickness(); + for (int iPlate = 0; iPlate < m_numPlates; iPlate++) + { + station->add(new GeoNameTag("Plate#"+intToString(iPlate))); + station->add(new GeoIdentifierTag(iPlate)); + id.setPlate(iPlate); + GeoAlignableTransform* transform = new GeoAlignableTransform(GeoTrf::Translate3D(0.0, + 0.0, + (plateThickness - activeDepth)/2 + iPlate * m_platePitch)); + station->add(transform); + GeoVPhysVol* platePV = m_plate->build(id); + station->add(platePV); + m_detectorManager->addAlignableTransform(0, id.getPlateId(), transform, platePV); + } + return station; +} + diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStation.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStation.h new file mode 100644 index 0000000000000000000000000000000000000000..50702df10006c6d767c929f68750b797c8fcae56 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStation.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETONUGEOMODEL_VETONUSTATION_H +#define VETONUGEOMODEL_VETONUSTATION_H + +#include "VetoNuComponentFactory.h" + +class GeoVPhysVol; +class GeoFullPhysVol; +class GeoLogVol; +class VetoNuIdentifier; +class VetoNuPlate; + +class VetoNuStation : public VetoNuUniqueComponentFactory +{ + +public: + VetoNuStation(const std::string & name, + VetoNuPlate* plate, + ScintDD::VetoNuDetectorManager* detectorManager, + const VetoNuGeometryManager* geometryManager, + VetoNuMaterialManager* materials); + virtual GeoVPhysVol * build(VetoNuIdentifier id); + +public: + int numPlates() const {return m_numPlates;} + double platePitch() const {return m_platePitch;} + double thickness() const {return m_thickness;} + double width() const {return m_width;} + double length() const {return m_length;} + +private: + void getParameters(); + virtual const GeoLogVol * preBuild(); + + VetoNuPlate* m_plate; + + int m_numPlates; + double m_platePitch; + + double m_thickness; + double m_width; + double m_length; + + double m_safety; +}; + +#endif // VETONUGEOMODEL_VETONUSTATION_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStationParameters.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStationParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9ec319eaa4377a7e5b58702f09b876d93c4752de --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStationParameters.cxx @@ -0,0 +1,872 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoNuStationParameters.h" +#include "VetoNuGeometryManager.h" + +#include "VetoNuDataBase.h" + +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> + + +VetoNuStationParameters::VetoNuStationParameters(VetoNuDataBase* rdb) +{ + m_rdb = rdb; +} + + +// // +// // Barrel Ski +// // +// int +// SCT_BarrelParameters::skiFirstStagger() const +// { +// return m_rdb->brlSki()->getInt("SKIFIRSTSTAGGER"); +// } + +// double +// SCT_BarrelParameters::skiRadialSep() const +// { +// return m_rdb->brlSki()->getDouble("SKIRADIALSEP") * Gaudi::Units::mm; +// } + +// int +// SCT_BarrelParameters::modulesPerSki() const +// { +// return m_rdb->brlSkiZSize(); +// } + +// double +// SCT_BarrelParameters::skiZPosition(int index) const +// { +// return m_rdb->brlSkiZ(index)->getDouble("ZPOSITION") * Gaudi::Units::mm; +// } + +// int +// SCT_BarrelParameters::skiModuleIdentifier(int index) const +// { +// return m_rdb->brlSkiZ(index)->getInt("MODULEID"); +// } + +// // +// // Barrel Layer +// // +// double +// SCT_BarrelParameters::tilt(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getDouble("TILT") * Gaudi::Units::degree; +// } + +// int +// SCT_BarrelParameters::layerStereoSign(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getInt("STEREOSIGN"); +// } + + +// double +// SCT_BarrelParameters::radius(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getDouble("RADIUS") * Gaudi::Units::mm; +// } + +// int +// SCT_BarrelParameters::skisPerLayer(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getInt("SKISPERLAYER"); +// } + +// double +// SCT_BarrelParameters::layerBracketPhiOffset(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getDouble("BRACKETPHIOFFSET") * Gaudi::Units::deg; +// } + +// double +// SCT_BarrelParameters::layerPhiOfRefModule(int iLayer) const +// { +// // For backward compatibility, if field is null return (90 - tilt) +// // as ref module is horizontal in old versions. +// if (m_rdb->brlLayer(iLayer)->isFieldNull("PHIOFREFMODULE")) { +// return 90*Gaudi::Units::deg - tilt(iLayer); +// } +// return m_rdb->brlLayer(iLayer)->getDouble("PHIOFREFMODULE") * Gaudi::Units::deg; +// } + + +// // +// // Barrel Bracket +// // +// double +// SCT_BarrelParameters::bracketThickness() const +// { +// return m_rdb->brlSki()->getDouble("BRACKETTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::bracketWidth() const +// { +// return m_rdb->brlSki()->getDouble("BRACKETWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::bracketLength() const +// { +// return m_rdb->brlSki()->getDouble("BRACKETLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::bracketMaterial() const +// { +// return m_rdb->brlSki()->getString("BRACKETMATERIAL"); +// } + +// // +// // Barrel Dogleg +// // +// double +// SCT_BarrelParameters::doglegThickness() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::doglegWidth() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::doglegLength() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::doglegMaterial() const +// { +// return m_rdb->brlSki()->getString("DOGLEGMATERIAL"); +// } + +// double +// SCT_BarrelParameters::doglegOffsetX() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGOFFSETX") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::doglegOffsetY() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGOFFSETY") * Gaudi::Units::mm; +// } + +// // +// // Barrel CoolingBlock +// // +// double +// SCT_BarrelParameters::coolingBlockThickness() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKTHICK") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingBlockWidth() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingBlockLength() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::coolingBlockMaterial() const +// { +// return m_rdb->brlSki()->getString("COOLINGBLOCKMATERIAL"); +// } + +// double +// SCT_BarrelParameters::coolingBlockOffsetX() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKOFFSETX") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingBlockOffsetY() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKOFFSETY") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingBlockOffsetZ() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKOFFSETZ") * Gaudi::Units::mm; +// } + +// // +// // Barrel CoolingPipe +// // +// double +// SCT_BarrelParameters::coolingPipeRadius() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGPIPERADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::coolingPipeMaterial() const +// { +// return m_rdb->brlSki()->getString("COOLINGPIPEMATERIAL"); +// } + +// double +// SCT_BarrelParameters::coolingPipeOffsetX() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGPIPEOFFSETX") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingPipeOffsetY() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGPIPEOFFSETY") * Gaudi::Units::mm; +// } + + +// // +// // Barrel PowerTape +// // +// double +// SCT_BarrelParameters::powerTapeThickness() const +// { +// return m_rdb->brlSki()->getDouble("POWERTAPETHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::powerTapeWidth() const +// { +// return m_rdb->brlSki()->getDouble("POWERTAPEWIDTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::powerTapeMaterial() const +// { +// return m_rdb->brlSki()->getString("POWERTAPEMATERIAL"); +// } + +// double +// SCT_BarrelParameters::powerTapeStartPointOffset() const +// { +// return m_rdb->brlSki()->getDouble("POWERTAPESTARTOFFSET") * Gaudi::Units::mm; +// } + +// // +// // Barrel Harness +// // +// double +// SCT_BarrelParameters::harnessThickness() const +// { +// return m_rdb->brlSki()->getDouble("HARNESSTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::harnessWidth() const +// { +// return m_rdb->brlSki()->getDouble("HARNESSWIDTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::harnessMaterial() const +// { +// return m_rdb->brlSki()->getString("HARNESSMATERIAL"); +// } + +// // +// // Barrel SupportCyl +// // +// double +// SCT_BarrelParameters::supportCylInnerRadius(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("SUPPORTCYLINNERRAD") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::supportCylOuterRadius(int iLayer) const +// { +// return supportCylInnerRadius(iLayer) + supportCylDeltaR(iLayer); +// } + +// double +// SCT_BarrelParameters::supportCylDeltaR(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("SUPPORTCYLDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::supportCylMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("SUPPORTCYLMATERIAL"); +// } + + +// // +// // Barrel Flange +// // +// double +// SCT_BarrelParameters::flangeDeltaZ(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("FLANGEDELTAZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::flangeDeltaR(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("FLANGEDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::flangeMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("FLANGEMATERIAL"); +// } + +// // +// // Barrel Clamp +// // +// double +// SCT_BarrelParameters::clampDeltaZ(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("CLAMPDELTAZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::clampDeltaR(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("CLAMPDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::clampMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("CLAMPMATERIAL"); +// } + +// // +// // Barrel Cooling Inlet/outlets +// // +// double +// SCT_BarrelParameters::coolingEndDeltaR(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("COOLINGENDDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::coolingEndMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("COOLINGENDMATERIAL"); +// } + +// // +// // Barrel CloseOut +// // +// double +// SCT_BarrelParameters::closeOutDeltaZ(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("CLOSEOUTDELTAZ") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::closeOutMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("CLOSEOUTMATERIAL"); +// } + +// // +// // Barrel InterLink and B6 bearing +// // +// double +// SCT_BarrelParameters::interLinkDeltaZ() const +// { +// return m_rdb->brlServices()->getDouble("INTERLINKDELTAZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::interLinkInnerRadius() const +// { +// return m_rdb->brlServices()->getDouble("INTERLINKINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::interLinkOuterRadius() const +// { +// return m_rdb->brlServices()->getDouble("INTERLINKOUTERRADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::interLinkMaterial() const +// { +// return m_rdb->brlServices()->getString("INTERLINKMATERIAL"); +// } + +// double +// SCT_BarrelParameters::interLinkDeltaPhi() const +// { +// if (m_rdb->brlServices()->isFieldNull("INTERLINKDPHI")) { +// return 360.*Gaudi::Units::deg; +// } +// return m_rdb->brlServices()->getDouble("INTERLINKDPHI") * Gaudi::Units::deg; +// } + +// double +// SCT_BarrelParameters::interLinkPhiPos() const +// { +// if (m_rdb->brlServices()->isFieldNull("INTERLINKPHIPOS")) { +// return 0.; +// } +// return m_rdb->brlServices()->getDouble("INTERLINKPHIPOS") * Gaudi::Units::deg; +// } + +// int +// SCT_BarrelParameters::interLinkNRepeat() const +// { +// if (m_rdb->brlServices()->isFieldNull("INTERLINKNREPEAT")) { +// return 1; +// } +// return m_rdb->brlServices()->getInt("INTERLINKNREPEAT"); +// } + +// double +// SCT_BarrelParameters::bearingDeltaPhi() const +// { +// if (m_rdb->brlServices()->isFieldNull("BEARINGDPHI")) { +// return 0.; +// } +// return m_rdb->brlServices()->getDouble("BEARINGDPHI") * Gaudi::Units::deg; +// } + +// double +// SCT_BarrelParameters::bearingPhiPos() const +// { +// if (m_rdb->brlServices()->isFieldNull("BEARINGPHIPOS")) { +// return 0.; +// } +// return m_rdb->brlServices()->getDouble("BEARINGPHIPOS") * Gaudi::Units::deg; +// } + +// int +// SCT_BarrelParameters::bearingNRepeat() const +// { +// if (m_rdb->brlServices()->isFieldNull("BEARINGNREPEAT")) { +// return 0; +// } +// return m_rdb->brlServices()->getInt("BEARINGNREPEAT"); +// } + +// std::string +// SCT_BarrelParameters::bearingMaterial() const +// { +// if (m_rdb->brlServices()->isFieldNull("BEARINGMATERIAL")) { +// return " "; +// } +// return m_rdb->brlServices()->getString("BEARINGMATERIAL"); +// } + +// // +// // Barrel FSI and FSI flange +// // +// bool +// SCT_BarrelParameters::includeFSI() const +// { +// if (m_rdb->brlFSISize() > 0) {return true;} +// return false; +// } + +// double +// SCT_BarrelParameters::fsiFlangeInnerRadius() const +// { +// return m_rdb->brlFSI()->getDouble("FLANGEINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiFlangeOuterRadius() const +// { +// return m_rdb->brlFSI()->getDouble("FLANGEOUTERRADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::fsiFlangeMaterial() const +// { +// return m_rdb->brlFSI()->getString("FLANGEMATERIAL"); +// } + +// double +// SCT_BarrelParameters::fsiFibreMaskDeltaR() const +// { +// return m_rdb->brlFSI()->getDouble("FIBREMASKDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::fsiFibreMaskMaterial() const +// { +// return m_rdb->brlFSI()->getString("FIBREMASKMATERIAL"); +// } + +// double +// SCT_BarrelParameters::fsiEndJewelRadialWidth() const +// { +// return m_rdb->brlFSI()->getDouble("ENDJEWELRADIALWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiEndJewelRPhiWidth() const +// { +// return m_rdb->brlFSI()->getDouble("ENDJEWELRPHIWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiEndJewelLength() const +// { +// return m_rdb->brlFSI()->getDouble("ENDJEWELLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::fsiEndJewelMaterial() const +// { +// return m_rdb->brlFSI()->getString("ENDJEWELMATERIAL"); +// } + +// int +// SCT_BarrelParameters::fsiEndJewelNRepeat(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getInt("ENDJEWELNREPEAT"); +// } + +// double +// SCT_BarrelParameters::fsiEndJewelPhi(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getDouble("ENDJEWELPHI") * Gaudi::Units::degree; +// } + +// double +// SCT_BarrelParameters::fsiEndJewelZ(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getDouble("ENDJEWELZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiScorpionRadialWidth() const +// { +// return m_rdb->brlFSI()->getDouble("SCORPIONRADIALWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiScorpionRPhiWidth() const +// { +// return m_rdb->brlFSI()->getDouble("SCORPIONRPHIWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiScorpionLength() const +// { +// return m_rdb->brlFSI()->getDouble("SCORPIONLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::fsiScorpionMaterial() const +// { +// return m_rdb->brlFSI()->getString("SCORPIONMATERIAL"); +// } + +// int +// SCT_BarrelParameters::fsiScorpionNRepeat(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getInt("SCORPIONNREPEAT"); +// } + +// double +// SCT_BarrelParameters::fsiScorpionPhi(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getDouble("SCORPIONPHI") * Gaudi::Units::degree; +// } + +// double +// SCT_BarrelParameters::fsiScorpionZ(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getDouble("SCORPIONZ") * Gaudi::Units::mm; +// } + + +// // +// // Barrel Cooling Spider +// // +// double +// SCT_BarrelParameters::spiderDeltaZ() const +// { +// return m_rdb->brlServices()->getDouble("SPIDERDELTAZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::spiderInnerRadius() const +// { +// return m_rdb->brlServices()->getDouble("SPIDERINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::spiderOuterRadius() const +// { +// return m_rdb->brlServices()->getDouble("SPIDEROUTERRADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::spiderMaterial() const +// { +// return m_rdb->brlServices()->getString("SPIDERMATERIAL"); +// } + +// // +// // Barrel Thermal Shield +// // +// double +// SCT_BarrelParameters::thermalShieldInnerRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("INNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldOuterRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("OUTERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndZMax() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDZMAX") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldCylTotalThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("CYLTOTALTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldCylInnerWallThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("CYLINNERWALLTHICK") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldCylOuterWallThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("CYLOUTERWALLTHICK") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldSpacerZWidth() const +// { +// return m_rdb->brlThermalShield()->getDouble("SPACERZWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldFirstSpacerZMin() const +// { +// return m_rdb->brlThermalShield()->getDouble("FIRSTSPACERZMIN") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndCapCylThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDCAPCYLTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndCapThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDCAPTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldBulkheadInnerRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("BULKHEADINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldBulkheadOuterRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("BULKHEADOUTERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndPanelInnerRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDPANELINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndPanelOuterRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDPANELOUTERRADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::thermalShieldMaterialSpacer() const +// { +// return m_rdb->brlThermalShield()->getString("MATERIALSPACER"); +// } + +// std::string +// SCT_BarrelParameters::thermalShieldMaterialCyl() const +// { +// return m_rdb->brlThermalShield()->getString("MATERIALCYL"); +// } + +// std::string +// SCT_BarrelParameters::thermalShieldMaterialOuterSect() const +// { +// return m_rdb->brlThermalShield()->getString("MATERIALOUTERSECT"); +// } + +// std::string +// SCT_BarrelParameters::thermalShieldMaterialInnerSect() const +// { +// return m_rdb->brlThermalShield()->getString("MATERIALINNERSECT"); +// } + +// // +// // Barrel EMI Shield +// // +// double +// SCT_BarrelParameters::emiShieldInnerRadius() const +// { +// return m_rdb->brlServices()->getDouble("EMIINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::emiShieldDeltaR() const +// { +// return m_rdb->brlServices()->getDouble("EMIDELTAR") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::emiShieldZMax() const +// { +// return m_rdb->brlServices()->getDouble("EMIZMAX") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::emiShieldMaterial() const +// { +// return m_rdb->brlServices()->getString("EMIMATERIAL"); +// } + +// double +// SCT_BarrelParameters::emiJointDeltaR() const +// { +// return m_rdb->brlServices()->getDouble("EMIJOINTDELTAR") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::emiJointRPhi() const +// { +// return m_rdb->brlServices()->getDouble("EMIJOINTRPHI") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::emiJointMaterial() const +// { +// return m_rdb->brlServices()->getString("EMIJOINTMATERIAL"); +// } + + + +// // +// // Attachment of pixel to SCT. +// // +// double +// SCT_BarrelParameters::pixelAttachmentInnerRadius() const +// { +// return m_rdb->brlServices()->getDouble("PIXELATTACHINNERRAD") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::pixelAttachmentOuterRadius() const +// { +// return m_rdb->brlServices()->getDouble("PIXELATTACHOUTERRAD") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::pixelAttachmentZMin() const +// { +// return m_rdb->brlServices()->getDouble("PIXELATTACHZMIN") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::pixelAttachmentDeltaZ() const +// { +// return m_rdb->brlServices()->getDouble("PIXELATTACHDELTAZ") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::pixelAttachmentMaterial() const +// { +// return m_rdb->brlServices()->getString("PIXELATTACHMATERIAL"); +// } + +// +// Barrel General +// +int +VetoNuStationParameters::numPlates() const +{ + return m_rdb->stationGeneral()->getInt("NUMPLATES"); +} + +double +VetoNuStationParameters::platePitch() const +{ + return m_rdb->stationGeneral()->getDouble("PLATEPITCH"); +} + +// double +// VetoNuStationParameters::stationWidth() const +// { +// return m_rdb->stationGeneral()->getDouble("WIDTH") * Gaudi::Units::mm; +// } + +// double +// VetoNuStationParameters::stationLength() const +// { +// return m_rdb->stationGeneral()->getDouble("LENGTH") * Gaudi::Units::mm; +// } + +// double +// VetoNuStationParameters::stationThickness() const +// { +// return m_rdb->stationGeneral()->getDouble("THICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::cylinderLength() const +// { +// return m_rdb->brlGeneral()->getDouble("CYLINDERLENGTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::activeLength() const +// { +// return m_rdb->brlGeneral()->getDouble("ACTIVELENGTH") * Gaudi::Units::mm; +// } + +// bool +// SCT_BarrelParameters::isOldGeometry() const +// { +// if (m_rdb->brlGeneral()->isFieldNull("CYLINDERLENGTH")) {return true;} +// return false; +// } + diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStationParameters.h b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStationParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..843b6095e29ff703ab1605e1c8eb66cdd114f635 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/VetoNuStationParameters.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoNuGeoModel_VetoNuStationParameters_H +#define VetoNuGeoModel_VetoNuStationParameters_H + +#include <string> + +class VetoNuDataBase; + +class VetoNuStationParameters { + +public: + + // Constructor + VetoNuStationParameters(VetoNuDataBase* rdb); + + + // General + int numPlates() const; + double platePitch() const; + + private: + VetoNuDataBase * m_rdb; + +}; + + +#endif // VetoNuGeoModel_VetoNuStationParameters_H diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/src/components/VetoNuGeoModel_entries.cxx b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/components/VetoNuGeoModel_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..cc2cd2581e8954fa96943ded066d9e6f5cb15544 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/src/components/VetoNuGeoModel_entries.cxx @@ -0,0 +1,3 @@ +#include "VetoNuGeoModel/VetoNuDetectorTool.h" + +DECLARE_COMPONENT( VetoNuDetectorTool ) \ No newline at end of file diff --git a/Scintillator/ScintDetDescr/VetoNuGeoModel/test/VetoNuGMConfig_test.py b/Scintillator/ScintDetDescr/VetoNuGeoModel/test/VetoNuGMConfig_test.py new file mode 100644 index 0000000000000000000000000000000000000000..8a8bca5989485cfa7c046e244e966d8d00c0d85f --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoNuGeoModel/test/VetoNuGMConfig_test.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Run tests on VetoNuGeoModel configuration + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +if __name__ == "__main__": + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior=1 + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + from AthenaConfiguration.TestDefaults import defaultTestFiles + + ConfigFlags.Input.Files = defaultTestFiles.HITS + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion + ConfigFlags.GeoModel.Align.Dynamic = False + ConfigFlags.lock() + + from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + from VetoNuGeoModel.VetoNuGeoModelConfig import VetoNuGeometryCfg + acc = VetoNuGeometryCfg(ConfigFlags) + f=open('VetoNuGeometryCfg.pkl','wb') + acc.store(f) + f.close() diff --git a/Scintillator/ScintG4/VetoNuG4_SD/CMakeLists.txt b/Scintillator/ScintG4/VetoNuG4_SD/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..eb9aab190b1ea05e06536d8f0477d6909a0f8499 --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/CMakeLists.txt @@ -0,0 +1,22 @@ +################################################################################ +# Package: VetoNuG4_SD +################################################################################ + +# Declare the package name: +atlas_subdir( VetoNuG4_SD ) + +# External dependencies: +find_package( CLHEP ) +find_package( Geant4 ) +find_package( XercesC ) + +# Component(s) in the package: +atlas_add_component( VetoNuG4_SD + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} StoreGateLib SGtests GaudiKernel ScintSimEvent G4AtlasToolsLib FaserMCTruth ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) + diff --git a/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDConfig.py b/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..053b12e58099026922369886fb8f4f22575733c2 --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDConfig.py @@ -0,0 +1,22 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from ISF_Algorithms.collection_merger_helpersNew import CollectionMergerCfg + +VetoNuSensorSDTool=CompFactory.VetoNuSensorSDTool + +def getVetoNuSensorSD(ConfigFlags, name="VetoNuSensorSD", **kwargs): + + result = ComponentAccumulator() + bare_collection_name = "VetoNuHits" + mergeable_collection_suffix = "_G4" + merger_input_property = "VetoNuHits" + + acc, hits_collection_name = CollectionMergerCfg(ConfigFlags, bare_collection_name, mergeable_collection_suffix, merger_input_property) + kwargs.setdefault("LogicalVolumeNames", ["VetoNu::Plate"]) + kwargs.setdefault("OutputCollectionNames", [hits_collection_name]) + + result.merge(acc) + return result, VetoNuSensorSDTool(name, **kwargs) + diff --git a/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDConfigDb.py b/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDConfigDb.py new file mode 100644 index 0000000000000000000000000000000000000000..5909581e180436c7d1505a0581c5244155993ef4 --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDConfigDb.py @@ -0,0 +1,5 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.CfgGetter import addTool + +addTool("VetoNuG4_SD.VetoNuG4_SDConfig.getVetoNuSensorSD" , "VetoNuSensorSD" ) diff --git a/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDToolConfig.py b/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDToolConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..8ea87d4239aa26a87481f39918dd59f8665508c8 --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/python/VetoNuG4_SDToolConfig.py @@ -0,0 +1,24 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +# from ISF_Algorithms.collection_merger_helpersNew import CollectionMergerCfg + +VetoNuSensorSDTool=CompFactory.VetoNuSensorSDTool + +def VetoNuSensorSDCfg(ConfigFlags, name="VetoNuSensorSD", **kwargs): + + result = ComponentAccumulator() + bare_collection_name = "VetoNuHits" + # mergeable_collection_suffix = "_G4" + # merger_input_property = "VetoNuHits" + + # acc, hits_collection_name = CollectionMergerCfg(ConfigFlags, bare_collection_name, mergeable_collection_suffix, merger_input_property, 'SCINT') + # kwargs.setdefault("OutputCollectionNames", [hits_collection_name]) + kwargs.setdefault("LogicalVolumeNames", ["VetoNu::Plate"]) + kwargs.setdefault("OutputCollectionNames", [bare_collection_name]) + + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.VetoNuSensorSDTool(name, **kwargs)) + return result + diff --git a/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSD.cxx b/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSD.cxx new file mode 100644 index 0000000000000000000000000000000000000000..85587985abcde4886e642fdf0ef72fe832e9160f --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSD.cxx @@ -0,0 +1,116 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// +// VetoNu Sensitive Detector. +// The Hits are processed here. For every hit I get the position and +// an information on the sensor in which the interaction happened +// + +// class headers +#include "VetoNuSensorSD.h" + +// athena includes +#include "FaserMCTruth/FaserTrackHelper.h" + +// Geant4 includes +#include "G4Step.hh" +#include "G4ThreeVector.hh" +#include "G4SDManager.hh" +#include "G4Geantino.hh" +#include "G4ChargedGeantino.hh" + +// CLHEP transform +#include "CLHEP/Geometry/Transform3D.h" + +#include <memory> // For make unique + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +VetoNuSensorSD::VetoNuSensorSD( const std::string& name, const std::string& hitCollectionName ) + : G4VSensitiveDetector( name ) + , m_HitColl( hitCollectionName ) +{ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void VetoNuSensorSD::Initialize(G4HCofThisEvent *) +{ + if (!m_HitColl.isValid()) m_HitColl = std::make_unique<ScintHitCollection>(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4bool VetoNuSensorSD::ProcessHits(G4Step* aStep, G4TouchableHistory* /*ROhist*/) +{ + double edep = aStep->GetTotalEnergyDeposit(); + if(edep==0.) { + if(aStep->GetTrack()->GetDefinition()!=G4Geantino::GeantinoDefinition() && + aStep->GetTrack()->GetDefinition()!=G4ChargedGeantino::ChargedGeantinoDefinition()) + return false; + } + edep *= CLHEP::MeV; + // + // Get the Touchable History: + // + const G4TouchableHistory *myTouch = dynamic_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable()); + // + // Get the hit coordinates. Start and End Point + // + G4ThreeVector coord1 = aStep->GetPreStepPoint()->GetPosition(); + G4ThreeVector coord2 = aStep->GetPostStepPoint()->GetPosition(); + // + // Calculate the local step begin and end position. + // From a G4 FAQ: + // http://geant4-hn.slac.stanford.edu:5090/HyperNews/public/get/geometry/17/1.html + // + const G4AffineTransform transformation = myTouch->GetHistory()->GetTopTransform(); + G4ThreeVector localPosition1 = transformation.TransformPoint(coord1); + G4ThreeVector localPosition2 = transformation.TransformPoint(coord2); + // + // Get it into a vector in local coords and with the right units: + // + HepGeom::Point3D<double> lP1,lP2; + + // No funny business with coordinates like ATLAS... + lP1[2] = localPosition1[2]*CLHEP::mm; + lP1[1] = localPosition1[1]*CLHEP::mm; + lP1[0] = localPosition1[0]*CLHEP::mm; + + lP2[2] = localPosition2[2]*CLHEP::mm; + lP2[1] = localPosition2[1]*CLHEP::mm; + lP2[0] = localPosition2[0]*CLHEP::mm; + + // Now Navigate the history to know in what detector the step is: + // and finally set the ID of det element in which the hit is. + // + //G4int History; + // + // Get station and plate + // + int station = 0; + int plate = 0; + this->indexMethod(myTouch, station, plate); + // get the HepMcParticleLink from the TrackHelper + FaserTrackHelper trHelp(aStep->GetTrack()); + m_HitColl->Emplace(lP1, + lP2, + edep, + aStep->GetPreStepPoint()->GetGlobalTime(),//use the global time. i.e. the time from the beginning of the event + trHelp.GetParticleLink(), + 3,station,plate); + return true; +} + +void VetoNuSensorSD::indexMethod(const G4TouchableHistory *myTouch, + int &station, int &plate) { + + + plate = myTouch->GetVolume()->GetCopyNo(); + const std::string stationName = myTouch->GetVolume(1)->GetLogicalVolume()->GetName(); + station = (stationName == "VetoNu::VetoNuStationA" ? 0 : 1 ); + + return; +} diff --git a/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSD.h b/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSD.h new file mode 100644 index 0000000000000000000000000000000000000000..478121ccd5a3c27a19ee200153bc290a872ff1b6 --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSD.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/**************************************************************** + VetoNu Sensitive Detector class +****************************************************************/ + +#ifndef VETONUG4_SD_VETONUSENSORSD_H +#define VETONUG4_SD_VETONUSENSORSD_H + +// Base class +#include "G4VSensitiveDetector.hh" + +// For the hits +#include "ScintSimEvent/ScintHitCollection.h" +#include "StoreGate/WriteHandle.h" + +// G4 needed classes +class G4Step; +class G4TouchableHistory; + +class VetoNuSensorSD : public G4VSensitiveDetector +{ +public: + // Constructor + VetoNuSensorSD(const std::string& name, const std::string& hitCollectionName); + + // Destructor + ~VetoNuSensorSD() { /* If all goes well we do not own myHitColl here */ } + + // Deal with each G4 hit + G4bool ProcessHits(G4Step*, G4TouchableHistory*) override; + + // For setting up the hit collection + void Initialize(G4HCofThisEvent*) override final; + + /** Templated method to stuff a single hit into the sensitive detector class. This + could get rather tricky, but the idea is to allow fast simulations to use the very + same SD classes as the standard simulation. */ + template <class... Args> void AddHit(Args&&... args){ m_HitColl->Emplace( args... ); } + +private: + void indexMethod(const G4TouchableHistory *myTouch, int &station, int &plate); +protected: + // The hits collection + SG::WriteHandle<ScintHitCollection> m_HitColl; +}; + +#endif //VETONUG4_SD_VETONUSENSORSD_H diff --git a/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSDTool.cxx b/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSDTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6f3a6f5a693e2fd25e42bf58121d79cc91de310f --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSDTool.cxx @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// VetoNu Sensitive Detector Tool. +// + +// class header +#include "VetoNuSensorSDTool.h" + +// package includes +#include "VetoNuSensorSD.h" + +// STL includes +#include <exception> + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +VetoNuSensorSDTool::VetoNuSensorSDTool(const std::string& type, const std::string& name, const IInterface* parent) + : SensitiveDetectorBase( type , name , parent ) +{ + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4VSensitiveDetector* VetoNuSensorSDTool::makeSD() const +{ + ATH_MSG_DEBUG( "Creating VetoNu SD: " << name() ); + return new VetoNuSensorSD(name(), m_outputCollectionNames[0]); +} + diff --git a/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSDTool.h b/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSDTool.h new file mode 100644 index 0000000000000000000000000000000000000000..073a7cd07a136376d97e8b1361a9a4fc252a23d4 --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/src/VetoNuSensorSDTool.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/**************************************************************** + VetoNu Sensitive Detector Tool + ****************************************************************/ + +#ifndef VETONUG4_SD_VETONUSENSORSDTOOL_H +#define VETONUG4_SD_VETONUSENSORSDTOOL_H + +// Base class +#include "G4AtlasTools/SensitiveDetectorBase.h" + +// STL headers +#include <string> + +class G4VSensitiveDetector; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... + +class VetoNuSensorSDTool : public SensitiveDetectorBase +{ + public: + // Constructor + VetoNuSensorSDTool(const std::string& type, const std::string& name, const IInterface *parent); + + // Destructor + ~VetoNuSensorSDTool() { /* If all goes well we do not own myHitColl here */ } + +protected: + // Make me an SD! + G4VSensitiveDetector* makeSD() const override final; +}; + +#endif //VETOG4_SD_VETOSENSORSDTOOL_H diff --git a/Scintillator/ScintG4/VetoNuG4_SD/src/components/VetoNuG4_SD_entries.cxx b/Scintillator/ScintG4/VetoNuG4_SD/src/components/VetoNuG4_SD_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5ae057c14079dc0241808a300e4487ec3638d53d --- /dev/null +++ b/Scintillator/ScintG4/VetoNuG4_SD/src/components/VetoNuG4_SD_entries.cxx @@ -0,0 +1,3 @@ +#include "../VetoNuSensorSDTool.h" + +DECLARE_COMPONENT( VetoNuSensorSDTool ) diff --git a/Scintillator/ScintSimEvent/ScintSimEvent/ScintHit.h b/Scintillator/ScintSimEvent/ScintSimEvent/ScintHit.h index 5a0a4d17282cc234c09b697cdee2c028480a2b96..a2e02b596f4485d330a24ae6a5190832c9f0fa24 100644 --- a/Scintillator/ScintSimEvent/ScintSimEvent/ScintHit.h +++ b/Scintillator/ScintSimEvent/ScintSimEvent/ScintHit.h @@ -106,6 +106,7 @@ public: bool isVeto() const; bool isTrigger() const; bool isPreshower() const; + bool isVetoNu() const; // Station int getStation() const; diff --git a/Scintillator/ScintSimEvent/ScintSimEvent/ScintHitIdHelper.h b/Scintillator/ScintSimEvent/ScintSimEvent/ScintHitIdHelper.h index 233acb37e9a01ff47d8e3f93924e473eebe37f62..a8740bf0f779f74f89f427b3b3458dbe275d4398 100644 --- a/Scintillator/ScintSimEvent/ScintSimEvent/ScintHitIdHelper.h +++ b/Scintillator/ScintSimEvent/ScintSimEvent/ScintHitIdHelper.h @@ -28,6 +28,7 @@ #include "ScintIdentifier/VetoID.h" #include "ScintIdentifier/TriggerID.h" #include "ScintIdentifier/PreshowerID.h" +#include "ScintIdentifier/VetoNuID.h" #include "Identifier/Identifier.h" @@ -45,6 +46,7 @@ class ScintHitIdHelper : HitIdHelper { bool isVeto(const int& hid) const; bool isTrigger(const int& hid) const; bool isPreshower(const int& hid) const; + bool isVetoNu(const int& hid) const; // Barrel or Endcap int getStation(const int& hid) const; @@ -71,6 +73,7 @@ class ScintHitIdHelper : HitIdHelper { const VetoID* m_vetoID{nullptr}; const TriggerID* m_triggerID{nullptr}; const PreshowerID* m_preshowerID{nullptr}; + const VetoNuID* m_vetoNuID{nullptr}; }; diff --git a/Scintillator/ScintSimEvent/src/ScintHit.cxx b/Scintillator/ScintSimEvent/src/ScintHit.cxx index 2ef1cfd9b1361c75183fd1e399ffa31e453604db..3f5506ed8af50ea471fbba91e8d5c674ab803648 100644 --- a/Scintillator/ScintSimEvent/src/ScintHit.cxx +++ b/Scintillator/ScintSimEvent/src/ScintHit.cxx @@ -138,6 +138,10 @@ bool ScintHit::isPreshower() const { return ScintHitIdHelper::GetHelper()->isPreshower(m_ID); } +bool ScintHit::isVetoNu() const { + return ScintHitIdHelper::GetHelper()->isVetoNu(m_ID); +} + HepGeom::Point3D<double> ScintHit::localStartPosition() const { return HepGeom::Point3D<double>((double) m_stX, (double) m_stY, (double) m_stZ); @@ -162,7 +166,9 @@ void ScintHit::print() const { } else if (isTrigger()) { std::cout << "*** Trigger Hit " << std::endl; } else if (isPreshower()) { - std::cout << "*** Preshower Hit " << std::endl; + std::cout << "*** Preshower Hit " << std::endl; + } else if (isVetoNu()) { + std::cout << "*** VetoNu Hit " << std::endl; } else { std::cout << "*** Unrecognized Scintillator Hit " << std::endl; } diff --git a/Scintillator/ScintSimEvent/src/ScintHitIdHelper.cxx b/Scintillator/ScintSimEvent/src/ScintHitIdHelper.cxx index 12cec61e319f4abb89e89b2fac16734a4984fd14..52b0faa99ce77f29913d1f94de525becce3d450f 100644 --- a/Scintillator/ScintSimEvent/src/ScintHitIdHelper.cxx +++ b/Scintillator/ScintSimEvent/src/ScintHitIdHelper.cxx @@ -43,11 +43,12 @@ void ScintHitIdHelper::Initialize() { ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "ScitHitIdHelper"); if (detStore.retrieve().isSuccess()) { if (detStore->retrieve(m_vetoID, "VetoID").isFailure()) { m_vetoID = 0; } + if (detStore->retrieve(m_vetoNuID, "VetoNuID").isFailure()) { m_vetoNuID = 0; } if (detStore->retrieve(m_triggerID, "TriggerID").isFailure()) { m_triggerID = 0; } if (detStore->retrieve(m_preshowerID, "PreshowerID").isFailure()) { m_preshowerID = 0; } } - InitializeField("VetoTriggerPreshower", 0, 2); + InitializeField("VetoTriggerPreshower", 0, 3); InitializeField("Station", -2, 2); InitializeField("Plate", 0, 4); } @@ -61,6 +62,13 @@ bool ScintHitIdHelper::isVeto(const int& hid) const else return false; } +bool ScintHitIdHelper::isVetoNu(const int& hid) const +{ + int ps = this->GetFieldValue("VetoTriggerPreshower", hid); + if ( ps == 3 ) return true; + else return false; +} + bool ScintHitIdHelper::isTrigger(const int& hid) const { int ps = this->GetFieldValue("VetoTriggerPreshower", hid); @@ -97,6 +105,8 @@ Identifier ScintHitIdHelper::getIdentifier(const int& hid) const return m_triggerID->pmt_id(getStation(hid), getPlate(hid), 0); } else if (isPreshower(hid)) { return m_preshowerID->pmt_id(getStation(hid), getPlate(hid), 0); + } else if (isVetoNu(hid)) { + return m_vetoNuID->pmt_id(getStation(hid), getPlate(hid), 0); } return Identifier(); }