Commit d18a1d7a authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'master-hgtd-trk-geo' into 'master'

Implement HGTD tracking geometry

See merge request atlas/athena!47198
parents b9ad4a31 01596374
......@@ -422,6 +422,13 @@ using Trk::distDepth;
ATH_MSG_ERROR( "Orientation of local depth axis does not follow correct convention.");
dir.m_depthDirection = true; // Don't swap.
}
// for HGTD modules, the check on phi and eta directions don't make sense
// as the modules do not respect the conventional position for endcap discs:
// - the local eta axis is never parallel to the radial direction
// - the local phi axis is never perpendicular to the radial direction
// hence, removing errors and allowing swap of the axis when needed
bool isHGTD = this->getIdHelper()->is_hgtd(m_id);
//
// Phi axis
......@@ -435,8 +442,7 @@ using Trk::distDepth;
ATH_MSG_DEBUG("Unable to swap local xPhi axis.");
}
}
if (std::abs(dir.m_phiAngle) < 0.5) { // Check that it is in roughly the right direction.
if (not isHGTD and std::abs(dir.m_phiAngle) < 0.5) { // Check that it is in roughly the right direction.
ATH_MSG_ERROR( "Orientation of local xPhi axis does not follow correct convention.");
dir.m_phiDirection = true; // Don't swap.
}
......@@ -453,7 +459,7 @@ using Trk::distDepth;
ATH_MSG_DEBUG("Unable to swap local xEta axis.");
}
}
if (std::abs(dir.m_etaAngle) < 0.5) { // Check that it is in roughly the right direction.
if (not isHGTD and std::abs(dir.m_etaAngle) < 0.5) { // Check that it is in roughly the right direction.
ATH_MSG_ERROR( "Orientation of local xEta axis does not follow correct convention.");
dir.m_etaDirection = true; // Don't swap
}
......
HighGranularityTimingDetector/HGTD_Conditions/HGTD_ConditionsAlgorithms
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( HGTD_ConditionsAlgorithms )
# External dependencies:
find_package( CLHEP )
find_package( CORAL COMPONENTS CoralBase )
# Component(s) in the package:
atlas_add_component( HGTD_ConditionsAlgorithms
src/*.h src/*.cxx src/components/*.cxx
INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS}
LINK_LIBRARIES ${CLHEP_LIBRARIES} ${CORAL_LIBRARIES} AthenaBaseComps AthenaKernel AthenaPoolUtilities DetDescrConditions GaudiKernel GeoModelUtilities GeoPrimitives Identifier HGTD_Identifier HGTD_ReadoutGeometry StoreGateLib TrkGeometry TrkSurfaces )
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
"""Define functions to configure HGTD conditions algorithms
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
"""
def HGTD_DetectorElementCondAlgCfg(flags, name="HGTD_DetectorElementCondAlg", **kwargs):
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
"""Return a ComponentAccumulator with configured HGTD_DetectorElementCondAlg for HGTD"""
acc = ComponentAccumulator()
kwargs.setdefault("DetManagerName", "HGTD")
kwargs.setdefault("WriteKey", "HGTD_DetectorElementCollection")
acc.addCondAlgo(CompFactory.HGTD_DetectorElementCondAlg(name, **kwargs))
return acc
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "HGTD_DetectorElementCondAlg.h"
#include "HGTD_ReadoutGeometry/HGTD_DetectorManager.h"
#include "HGTD_ReadoutGeometry/HGTD_DetectorElement.h"
#include "TrkGeometry/Layer.h"
#include "TrkSurfaces/Surface.h"
#include "AthenaKernel/IOVInfiniteRange.h"
#include <map>
HGTD_DetectorElementCondAlg::HGTD_DetectorElementCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
: ::AthReentrantAlgorithm(name, pSvcLocator)
{
}
StatusCode HGTD_DetectorElementCondAlg::initialize()
{
ATH_MSG_DEBUG("initialize " << name());
// Write Handle
ATH_CHECK(m_writeKey.initialize());
// CondSvc
ATH_CHECK(m_condSvc.retrieve());
// Register write handle
ATH_CHECK(m_condSvc->regHandle(this, m_writeKey));
// We need the detector manager
ATH_CHECK(detStore()->retrieve(m_detManager, m_detManagerName));
return StatusCode::SUCCESS;
}
StatusCode HGTD_DetectorElementCondAlg::execute(const EventContext& ctx) const
{
ATH_MSG_DEBUG("execute " << name());
// ____________ Construct Write Cond Handle and check its validity ____________
SG::WriteCondHandle<InDetDD::HGTD_DetectorElementCollection> writeHandle{m_writeKey, ctx};
// Do we have a valid Write Cond Handle for current time?
if (writeHandle.isValid()) {
ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
<< ". In theory this should not be called, but may happen"
<< " if multiple concurrent events are being processed out of order.");
return StatusCode::SUCCESS;
}
const InDetDD::HGTD_DetectorElementCollection* oldColl{m_detManager->getDetectorElementCollection()};
if (oldColl==nullptr) {
ATH_MSG_FATAL("Null pointer is returned by getDetectorElementCollection()");
return StatusCode::FAILURE;
}
// ____________ Construct new Write Cond Object ____________
std::unique_ptr<InDetDD::HGTD_DetectorElementCollection> writeCdo{std::make_unique<InDetDD::HGTD_DetectorElementCollection>()};
// Make sure we make a mixed IOV.
writeHandle.addDependency (IOVInfiniteRange::infiniteMixed());
// ____________ Update writeCdo ____________
std::map<const InDetDD::HGTD_DetectorElement*, const InDetDD::HGTD_DetectorElement*> oldToNewMap;
oldToNewMap[nullptr] = nullptr;
writeCdo->resize(oldColl->size(), nullptr);
InDetDD::HGTD_DetectorElementCollection::iterator newEl{writeCdo->begin()};
for (const InDetDD::HGTD_DetectorElement* oldEl: *oldColl) {
*newEl = new InDetDD::HGTD_DetectorElement(oldEl->identify(),
&(oldEl->design()),
oldEl->GeoVDetectorElement::getMaterialGeom(),
oldEl->getCommonItems());
oldToNewMap[oldEl] = *newEl;
++newEl;
}
// Set layer to surface
InDetDD::HGTD_DetectorElementCollection::const_iterator oldIt{oldColl->begin()};
for (InDetDD::HGTD_DetectorElement* newEl: *writeCdo) {
if (oldToNewMap[(*oldIt)]!=newEl) {
ATH_MSG_ERROR("Old and new elements are not synchronized!");
}
// Layer of old element is set by HGTDet::HGTD_LayerBuilderCond::registerSurfacesToLayer.
const Trk::Layer* layer{(*oldIt)->surface().associatedLayer()};
if (layer) {
newEl->surface().associateLayer(*layer);
}
++oldIt;
}
// Apply alignment using readCdo passed to HGTD_DetectorElement
for (InDetDD::HGTD_DetectorElement* newEl: *writeCdo) {
newEl->setCache();
}
// Record WriteCondHandle
const std::size_t size{writeCdo->size()};
if (writeHandle.record(std::move(writeCdo)).isFailure()) {
ATH_MSG_FATAL("Could not record " << writeHandle.key()
<< " with EventRange " << writeHandle.getRange()
<< " into Conditions Store");
return StatusCode::FAILURE;
}
ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange()
<< " with size of " << size << " into Conditions Store");
return StatusCode::SUCCESS;
}
// -*- C++ -*-
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef HGTD_CONDITIONSALGORITHMS_HGTD_DETECTORELEMENTCONDALG_H
#define HGTD_CONDITIONSALGORITHMS_HGTD_DETECTORELEMENTCONDALG_H
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "GeoPrimitives/GeoPrimitives.h"
#include "HGTD_ReadoutGeometry/HGTD_DetectorElementCollection.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "StoreGate/WriteCondHandleKey.h"
#include "StoreGate/CondHandleKeyArray.h"
#include "GaudiKernel/ICondSvc.h"
class HGTD_DetectorManager;
class HGTD_DetectorElementCondAlg : public AthReentrantAlgorithm
{
public:
HGTD_DetectorElementCondAlg(const std::string& name, ISvcLocator* pSvcLocator);
virtual ~HGTD_DetectorElementCondAlg() override = default;
virtual StatusCode initialize() override;
virtual StatusCode execute(const EventContext& ctx) const override;
/** Make this algorithm clonable. */
virtual bool isClonable() const override { return true; };
private:
SG::WriteCondHandleKey<InDetDD::HGTD_DetectorElementCollection> m_writeKey
{this, "WriteKey", "HGTD_DetectorElementCollection", "Key of output HGTD_DetectorElementCollection for HGTD"};
ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"};
StringProperty m_detManagerName{this, "DetManagerName", "HGTD", "Name of the DeterctorManager to retrieve"};
const HGTD_DetectorManager* m_detManager{nullptr};
};
#endif // HGTD_CONDITIONSALGORITHMS_HGTD_DETECTORELEMENTCONDALG_H
#include "../HGTD_DetectorElementCondAlg.h"
DECLARE_COMPONENT( HGTD_DetectorElementCondAlg )
......@@ -22,4 +22,5 @@ atlas_add_component( HGTD_GeoModel
src/components/*.cxx
LINK_LIBRARIES GaudiKernel HGTD_GeoModelLib )
atlas_install_python_modules( python/*.py )
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
......@@ -15,6 +15,7 @@
namespace InDetDD {
class HGTD_ModuleDesign;
class SiCommonItems;
}
class GeoTube ;
......@@ -121,6 +122,8 @@ public:
std::map<std::string,GeoCylVolParams> m_cylVolPars;
std::map<std::string,GeoBoxVolParams> m_boxVolPars;
HgtdGeoParams m_hgtdPars;
std::unique_ptr<const InDetDD::SiCommonItems> m_commonItems;
};
} // End HGTDGeo namespace
......
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
from AthenaConfiguration.ComponentFactory import CompFactory
def HGTD_GeometryCfg(flags):
from AtlasGeoModel.GeoModelConfig import GeoModelCfg
acc = GeoModelCfg(flags)
geoModelSvc = acc.getPrimary()
from AthenaConfiguration.ComponentFactory import CompFactory
hgtdDetectorTool = CompFactory.HGTD_DetectorTool("HGTD_DetectorTool")
hgtdDetectorTool.Alignable = False
hgtdDetectorTool.DetectorName = "HGTD"
hgtdDetectorTool.PrintModuleNumberPerRow = False
geoModelSvc.DetectorTools += [ hgtdDetectorTool ]
return acc
def HGTD_ReadoutGeometryCfg(flags):
# main GeoModel config
acc = HGTD_GeometryCfg(flags)
from HGTD_ConditionsAlgorithms.HGTD_ConditionsAlgorithmsConfig import HGTD_DetectorElementCondAlgCfg
acc.merge(HGTD_DetectorElementCondAlgCfg(flags))
return acc
......@@ -81,7 +81,10 @@ HGTD_DetectorFactory::HGTD_DetectorFactory( HGTD_GeoModelAthenaComps* athComps )
// fail already here if no HGTD info exists in db
ATH_MSG_ERROR( "No HGTD child tag in global geo tag. HGTD will not be built.");
}
// Create SiCommonItems. These are items that are shared by all elements
m_commonItems = std::make_unique<const InDetDD::SiCommonItems>(m_athComps->getIdHelper());
// temporarily hardcode the HGTD version to build until the geo db has been updated with tables for 3-ring layout
// m_geomVersion = 0; // two-ring layout
m_geomVersion = 1; // three-ring layout
......@@ -128,6 +131,9 @@ void HGTD_DetectorFactory::create(GeoPhysVol* world) {
GeoVPhysVol* endcapNeg = build( negativeEndcapLogicalVolume, false);
world->add( endcapNeg );
m_detectorManager->addTreeTop( endcapNeg );
// Add SiCommonItems to HGTD_DetectorManager to hold and delete it.
m_detectorManager->setCommonItems(std::move(m_commonItems));
return;
}
......@@ -618,10 +624,6 @@ GeoVPhysVol* HGTD_DetectorFactory::build( const GeoLogVol* logicalEnvelope, bool
mirrorPositionsAroundYaxis(positions);
// for now create the SiCommonItems here
// These are items that are shared by all detector elements
std::unique_ptr<SiCommonItems> commonItems{std::make_unique<SiCommonItems>(m_athComps->getIdHelper())};
for (int layer = 0; layer < 4; layer++) {
if (m_outputIdfr) cout << "Layer #" << layer << std::endl;
// select from front vs back side of a disk
......@@ -715,7 +717,7 @@ GeoVPhysVol* HGTD_DetectorFactory::build( const GeoLogVol* logicalEnvelope, bool
ATH_MSG_DEBUG( " HGTD Module: " << m_boxVolPars[c].name+module_string << ", posX: " << myx << ", posY: " << myy << ", rot: " << quadrot + myrot );
}
InDetDD::HGTD_DetectorElement* detElement = new InDetDD::HGTD_DetectorElement(idwafer, moduleDesign, sensorCompPhysicalVol, commonItems.get());
InDetDD::HGTD_DetectorElement* detElement = new InDetDD::HGTD_DetectorElement(idwafer, moduleDesign, sensorCompPhysicalVol, m_commonItems.get());
m_detectorManager->addDetectorElement( detElement );
GeoTrf::Transform3D sensorTransform = GeoTrf::TranslateZ3D(m_boxVolPars[c].zOffsetLocal)*GeoTrf::TranslateX3D(xOffsetLocal);
......@@ -756,9 +758,6 @@ GeoVPhysVol* HGTD_DetectorFactory::build( const GeoLogVol* logicalEnvelope, bool
ATH_MSG_DEBUG( "Done placing modules for layer " << layer );
}
// Add SiCommonItems to HGTD_DetectorManager to hold and delete it.
m_detectorManager->setCommonItems(std::move(commonItems));
ATH_MSG_INFO( "**************************************************" );
ATH_MSG_INFO( " Done building HGTD with " << totMod <<" modules " );
ATH_MSG_INFO( "**************************************************" );
......
......@@ -15,4 +15,4 @@ atlas_add_library( HGTD_ReadoutGeometry
INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}
DEFINITIONS ${CLHEP_DEFINITIONS}
LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel SGTools AtlasDetDescr GeoPrimitives Identifier ReadoutGeometryBase GaudiKernel HGTD_Identifier TrkSurfaces StoreGateLib SGtests
PRIVATE_LINK_LIBRARIES AthenaPoolUtilities DetDescrConditions IdDictDetDescr )
PRIVATE_LINK_LIBRARIES AthenaPoolUtilities DetDescrConditions IdDictDetDescr GeoModelUtilities)
......@@ -48,7 +48,8 @@ public:
HGTD_DetectorElement(const Identifier &id,
const HGTD_ModuleDesign *design,
const GeoVFullPhysVol *geophysvol,
SiCommonItems * commonItems);
const SiCommonItems * commonItems,
const GeoAlignmentStore* geoAlignStore=nullptr);
/// Destructor:
virtual ~HGTD_DetectorElement();
......
......@@ -14,6 +14,8 @@
#include <vector>
class IdentifierHash;
namespace InDetDD {
class HGTD_DetectorElement;
......@@ -24,9 +26,14 @@ namespace InDetDD {
*/
class HGTD_DetectorElementCollection : public std::vector<HGTD_DetectorElement *>
{};
class HGTD_DetectorElementCollection : public std::vector<HGTD_DetectorElement *>
{};
} // namespace InDetDD
#include "AthenaKernel/CLASS_DEF.h"
CLASS_DEF( InDetDD::HGTD_DetectorElementCollection, 1266958207, 1)
#include "AthenaKernel/CondCont.h"
CONDCONT_MIXED_DEF( InDetDD::HGTD_DetectorElementCollection, 1258619755);
#endif // HGTD_READOUTGEOMETRY_HGTD_DETECTORELEMENTCOLLECTION_H
......@@ -18,8 +18,7 @@
#include "HGTD_Identifier/HGTD_ID.h"
// Message Stream Member
#include "AthenaKernel/MsgStreamMember.h"
#include "AthenaBaseComps/AthMessaging.h"
class StoreGateSvc;
......@@ -31,7 +30,7 @@ class StoreGateSvc;
*/
class HGTD_DetectorManager : public GeoVDetectorManager {
class HGTD_DetectorManager : public GeoVDetectorManager, public AthMessaging {
public:
/** Constructor */
......@@ -79,13 +78,7 @@ public:
/** Set SiCommonItems */
void setCommonItems(std::unique_ptr<const InDetDD::SiCommonItems>&& commonItems);
/** Declaring the Message method for further use */
MsgStream& msg (MSG::Level lvl) const { return m_msg.get() << lvl; }
/** Declaring the Method providing Verbosity Level */
bool msgLvl (MSG::Level lvl) const { return m_msg.get().level() <= lvl; }
private:
/** Prevent copy and assignment */
......@@ -101,9 +94,6 @@ private:
std::unique_ptr<const InDetDD::SiCommonItems> m_commonItems;
//Declaring private message stream member.
mutable Athena::MsgStreamMember m_msg;
};
#ifndef GAUDI_NEUTRAL
......
......@@ -6,6 +6,7 @@
#include "HGTD_Identifier/HGTD_ID.h"
#include "GeoModelKernel/GeoVFullPhysVol.h"
#include "GeoModelUtilities/GeoAlignmentStore.h"
#include "AtlasDetDescr/AtlasDetectorID.h"
#include "TrkSurfaces/PlaneSurface.h"
......@@ -16,8 +17,9 @@ namespace InDetDD {
HGTD_DetectorElement::HGTD_DetectorElement(const Identifier &id,
const HGTD_ModuleDesign *design,
const GeoVFullPhysVol *geophysvol,
SiCommonItems * commonItems) :
SolidStateDetectorElementBase(id, design, geophysvol, commonItems),
const SiCommonItems * commonItems,
const GeoAlignmentStore* geoAlignStore) :
SolidStateDetectorElementBase(id, design, geophysvol, commonItems, geoAlignStore),
m_design(design)
{
const HGTD_ID* hgtdId = dynamic_cast<const HGTD_ID *>(getIdHelper());
......
......@@ -12,7 +12,8 @@ using InDetDD::HGTD_DetectorElement;
using InDetDD::SiCommonItems;
HGTD_DetectorManager::HGTD_DetectorManager(StoreGateSvc* detStore)
: m_idHelper(0)
: AthMessaging(Athena::getMessageSvc(), "HGTD_DetectorManager"),
m_idHelper(0)
{
setName("HGTD");
......
################################################################################
# Package: HGTD_TrackingGeometry
################################################################################
# Declare the package name:
atlas_subdir( HGTD_TrackingGeometry )
# External dependencies:
find_package( Boost )
find_package( GeoModel COMPONENTS GeoModelKernel )
# Component(s) in the package:
atlas_add_component( HGTD_TrackingGeometry
src/*.cxx
src/components/*.cxx
PUBLIC_HEADERS HGTD_TrackingGeometry
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaBaseComps GeoPrimitives GaudiKernel TrkDetDescrInterfaces TrkDetDescrUtils TrkGeometry StoreGateLib HGTD_Identifier HGTD_ReadoutGeometry TrkSurfaces SubDetectorEnvelopesLib)
# Install files from the package:
#atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment