Skip to content
Snippets Groups Projects
Commit 6f4e8558 authored by Christos Anastopoulos's avatar Christos Anastopoulos Committed by Frank Winklmeier
Browse files

Use ServiceHandle for the TGSvc, rm unused variables , cleanup

Use ServiceHandle for the TGSvc, rm unused variables , cleanup
parent b1c25f71
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
from ISF_Config.ISF_jobProperties import ISF_Flags
def FastCaloSimFactory(name="FastCaloSimFactory", **kwargs):
from AthenaCommon.Logging import logging
......@@ -17,26 +14,13 @@ def FastCaloSimFactory(name="FastCaloSimFactory", **kwargs):
ToolSvc += niPropagator
mlog.info("configure nono-interacting propagator finished")
from TrkExTools.TrkExToolsConf import Trk__Navigator
navigator = None
from AthenaCommon.AlgSequence import AthSequencer
condSeq = AthSequencer("AthCondSeq")
if ISF_Flags.UseTrackingGeometryCond:
if not hasattr(condSeq, 'AtlasTrackingGeometryCondAlg'):
from TrackingGeometryCondAlg.AtlasTrackingGeometryCondAlg import (
ConfiguredTrackingGeometryCondAlg)
TrkGeoCondAlg = ConfiguredTrackingGeometryCondAlg(
'AtlasTrackingGeometryCondAlg')
condSeq += TrkGeoCondAlg
navigator = Trk__Navigator(
name="FCSNavigator",
TrackingGeometryKey=condSeq.AtlasTrackingGeometryCondAlg.TrackingGeometryWriteKey)
else:
navigator = Trk__Navigator(name="FCSNavigator", TrackingGeometryKey="")
# use NI navigator method checks for
# ISF_Flags.UseTrackingGeometryCond
from TrkExTools.TimedExtrapolator import getNINavigator
navigator = getNINavigator (name="FCSNavigator")
ToolSvc += navigator
mlog.info("now configure the TimedExtrapolator...")
......
......@@ -21,25 +21,13 @@
#include "TrkParameters/TrackParameters.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "TrkGeometry/TrackingGeometry.h"
#include "TrkDetDescrInterfaces/ITrackingGeometrySvc.h"
// STD
#include <cstring>
#include <exception>
#include <Gaudi/Accumulators.h>
namespace Trk {
class ITrackingGeometrySvc;
/** Exception to be thrown when TrackingGeometry not found */
class NavigatorException : public std::exception
{
const char* what() const throw()
{ return "Problem with TrackingGeometry loading"; }
};
class IGeometryBuilder;
class IPropagator;
class Surface;
......@@ -66,12 +54,10 @@ namespace Trk {
/** Constructor */
Navigator(const std::string&, const std::string&, const IInterface*);
/** Destructor */
virtual ~Navigator();
virtual ~Navigator() = default;
/** AlgTool initialize method.*/
virtual StatusCode initialize() override;
/** AlgTool finalize method */
virtual StatusCode finalize() override;
/** INavigator interface method - returns the TrackingGeometry used for
* navigation */
......@@ -139,7 +125,11 @@ namespace Trk {
};
/// ToolHandle to the TrackingGeometrySvc
ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc;
ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc{
this,
"TrackingGeometrySvc",
""
};
/// Name of the TrackingGeometry as given in Detector Store
std::string m_trackingGeometryName;
/******************************************************************/
......@@ -155,19 +145,6 @@ namespace Trk {
bool m_searchWithDistance;
//------------ Magnetic field properties
bool m_fastField;
// ------ PERFORMANCE STATISTICS -------------------------------- //
/* All performance stat counters are atomic (the simplest solution perhaps
* not the most performant one)*/
mutable Gaudi::Accumulators::Counter<> m_forwardCalls; //!< counter for forward nextBounday calls
mutable Gaudi::Accumulators::Counter<> m_forwardFirstBoundSwitch; //!< counter for failed first forward nextBounday calls
mutable Gaudi::Accumulators::Counter<> m_forwardSecondBoundSwitch; //!< counter for failed second forward nextBounday calls
mutable Gaudi::Accumulators::Counter<> m_forwardThirdBoundSwitch; //!< counter for failed third forward nextBounday calls
mutable Gaudi::Accumulators::Counter<> m_backwardCalls; //!< counter for backward nextBounday calls
mutable Gaudi::Accumulators::Counter<> m_backwardFirstBoundSwitch; //!< counter for failed first backward nextBounday calls
mutable Gaudi::Accumulators::Counter<> m_backwardSecondBoundSwitch; //!< counter for failed second backward nextBounday calls
mutable Gaudi::Accumulators::Counter<> m_backwardThirdBoundSwitch; //!< counter for failed third backward nextBounday calls
mutable Gaudi::Accumulators::Counter<> m_outsideVolumeCase; //!< counter for navigation-break in outside volume cases (ovc)
mutable Gaudi::Accumulators::Counter<> m_sucessfulBackPropagation; //!< counter for sucessful recovery of navigation-break in ovc
};
} // end of namespace
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -12,7 +12,6 @@
#include "TrkEventUtils/TrkParametersComparisonFunction.h"
#include "TrkExUtils/IntersectionSolution.h"
#include "TrkExUtils/RungeKuttaUtils.h"
#include "TrkDetDescrInterfaces/ITrackingGeometrySvc.h"
#include "TrkDetDescrInterfaces/IGeometryBuilder.h"
#include "TrkDetDescrUtils/ObjectAccessor.h"
#include "TrkGeometry/MagneticFieldProperties.h"
......@@ -33,6 +32,7 @@
#include "EventPrimitives/EventPrimitives.h"
#include "GeoPrimitives/GeoPrimitives.h"
#include <exception>
namespace{
const Trk::MagneticFieldProperties s_zeroMagneticField(Trk::NoField);
}
......@@ -40,27 +40,15 @@ const Trk::MagneticFieldProperties s_zeroMagneticField(Trk::NoField);
// constructor
Trk::Navigator::Navigator(const std::string &t, const std::string &n, const IInterface *p) :
AthAlgTool(t, n, p),
m_trackingGeometrySvc("AtlasTrackingGeometrySvc", n),
m_trackingGeometryName("AtlasTrackingGeometry"),
m_insideVolumeTolerance(1. * Gaudi::Units::mm),
m_isOnSurfaceTolerance(0.005 * Gaudi::Units::mm),
m_useStraightLineApproximation(false),
m_searchWithDistance(true),
m_fastField(false),
m_forwardCalls{},
m_forwardFirstBoundSwitch{},
m_forwardSecondBoundSwitch{},
m_forwardThirdBoundSwitch{},
m_backwardCalls{},
m_backwardFirstBoundSwitch{},
m_backwardSecondBoundSwitch{},
m_backwardThirdBoundSwitch{},
m_outsideVolumeCase{},
m_sucessfulBackPropagation{}
m_fastField(false)
{
declareInterface<INavigator>(this);
// steering of algorithms
declareProperty("TrackingGeometrySvc", m_trackingGeometrySvc);
declareProperty("InsideVolumeTolerance", m_insideVolumeTolerance);
declareProperty("IsOnSurfaceTolerance", m_isOnSurfaceTolerance);
declareProperty("UseStraightLineApproximation", m_useStraightLineApproximation);
......@@ -70,19 +58,13 @@ Trk::Navigator::Navigator(const std::string &t, const std::string &n, const IInt
declareProperty("MagneticFieldProperties", m_fastField);
}
// destructor
Trk::Navigator::~Navigator() = default;
// Athena standard methods
// initialize
StatusCode
Trk::Navigator::initialize() {
//We can use conditions when the key is not empty
m_useConditions=!m_trackingGeometryReadKey.key().empty();
// get the TrackingGeometrySvc
// get the TrackingGeometry
if (!m_useConditions) {
if (m_trackingGeometrySvc.retrieve().isSuccess()) {
ATH_MSG_DEBUG("Successfully retrieved " << m_trackingGeometrySvc);
......@@ -122,7 +104,6 @@ Trk::Navigator::nextBoundarySurface(const EventContext& ctx,
Trk::PropDirection dir) const
{
const Trk::TrackingVolume* trackingVolume = volume(ctx,parms.position());
if (trackingVolume) {
return (nextBoundarySurface(ctx,prop, parms, dir, *trackingVolume));
}
......@@ -185,12 +166,6 @@ Trk::Navigator::nextBoundarySurface(const EventContext& ctx,
}
}
// check the insideStatus
bool insideVolume = vol.inside(parms.position());
if (!insideVolume) {
++m_outsideVolumeCase;
}
return nullptr;
}
......@@ -202,13 +177,6 @@ Trk::Navigator::nextTrackingVolume(const EventContext& ctx,
const Trk::TrackingVolume& vol) const
{
// ---------------------------------------------------
if (dir == Trk::alongMomentum) {
++m_forwardCalls;
} else {
++m_backwardCalls;
}
bool first = false;
bool second = false;
......@@ -240,13 +208,6 @@ Trk::Navigator::nextTrackingVolume(const EventContext& ctx,
// loop over boundary surfaces
int tryBoundary = 0;
/* local counted to increment in the loop*/
auto forwardFirstBoundSwitch = m_forwardFirstBoundSwitch.buffer();
auto forwardSecondBoundSwitch = m_forwardSecondBoundSwitch.buffer();
auto forwardThirdBoundSwitch = m_forwardThirdBoundSwitch.buffer();
auto backwardFirstBoundSwitch = m_backwardFirstBoundSwitch.buffer();
auto backwardSecondBoundSwitch = m_backwardSecondBoundSwitch.buffer();
auto backwardThirdBoundSwitch = m_backwardThirdBoundSwitch.buffer();
for (const Trk::ObjectAccessor::value_type& surface_id : surfAcc) {
++tryBoundary;
......@@ -307,21 +268,15 @@ Trk::Navigator::nextTrackingVolume(const EventContext& ctx,
// ---------------------------------------------------
if (!first && searchDir == Trk::alongMomentum) {
++forwardFirstBoundSwitch;
first = true;
} else if (!second && searchDir == Trk::alongMomentum) {
++forwardSecondBoundSwitch;
second = true;
} else if (searchDir == Trk::alongMomentum) {
++forwardThirdBoundSwitch;
} else if (!first && searchDir == Trk::oppositeMomentum) {
++backwardFirstBoundSwitch;
first = true;
} else if (!second && searchDir == Trk::oppositeMomentum) {
++backwardSecondBoundSwitch;
second = true;
} else if (searchDir == Trk::oppositeMomentum) {
++backwardThirdBoundSwitch;
}
// ---------------------------------------------------
}
......@@ -489,8 +444,6 @@ Trk::Navigator::closestParameters(const EventContext& ctx,
return currentClosestParameters;
}
const Trk::CylinderSurface *ccsf = dynamic_cast<const Trk::CylinderSurface *>(&sf);
if (ccsf) {
Trk::TrkParametersComparisonFunction tParFinderCylinder(ccsf->bounds().r());
......@@ -519,37 +472,15 @@ Trk::Navigator::closestParameters(const EventContext& ctx,
return closestTrackParameters;
}
// finalize
StatusCode
Trk::Navigator::finalize() {
if (msgLvl(MSG::DEBUG)) {
ATH_MSG_DEBUG("[N] " << name() << " Perfomance Statistics : --------------------------------");
ATH_MSG_DEBUG(" -> Number of forward calls : " << m_forwardCalls);
ATH_MSG_DEBUG(" - 1st forward bound switch : " << m_forwardFirstBoundSwitch);
ATH_MSG_DEBUG(" - 2nd forward bound switch : " << m_forwardSecondBoundSwitch);
ATH_MSG_DEBUG(" - 3rd forward bound switch : " << m_forwardThirdBoundSwitch);
ATH_MSG_DEBUG(" -> Number of backward calls : " << m_backwardCalls);
ATH_MSG_DEBUG(" - 1st backward bound switch : " << m_backwardFirstBoundSwitch);
ATH_MSG_DEBUG(" - 2nd backward bound switch : " << m_backwardSecondBoundSwitch);
ATH_MSG_DEBUG(" - 3rd backward bound switch : " << m_backwardThirdBoundSwitch);
ATH_MSG_DEBUG(" -> Number of outsideVolume cases : " << m_outsideVolumeCase);
ATH_MSG_DEBUG(" - successfully recovered : " << m_sucessfulBackPropagation);
ATH_MSG_DEBUG(" ---------------------------------------------------------------------");
}
return StatusCode::SUCCESS;
}
const Trk::TrackingGeometry*
Trk::Navigator::trackingGeometry(const EventContext& ctx) const
{
if (m_useConditions) {
SG::ReadCondHandle<TrackingGeometry> handle(m_trackingGeometryReadKey, ctx);
if (!handle.isValid()) {
ATH_MSG_FATAL(
"Could not retrieve TrackingGeometry from Conditions Store.");
throw Trk::NavigatorException();
throw std::runtime_error{
"Could not retrieve TrackingGeometry from Conditions Store."
};
}
return handle.cptr();
} else {
......@@ -557,8 +488,9 @@ Trk::Navigator::trackingGeometry(const EventContext& ctx) const
if (detStore()
->retrieve(trackingGeometry, m_trackingGeometryName)
.isFailure()) {
ATH_MSG_FATAL("Could not retrieve TrackingGeometry from DetectorStore.");
throw Trk::NavigatorException();
throw std::runtime_error{
"Could not retrieve TrackingGeometry from Detector Store."
};
}
return trackingGeometry;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment