diff --git a/Reconstruction/MuonIdentification/MuidTrackBuilder/MuidTrackBuilder/CombinedMuonTrackBuilder.h b/Reconstruction/MuonIdentification/MuidTrackBuilder/MuidTrackBuilder/CombinedMuonTrackBuilder.h index 2d12aad72c002a73ca54badba1c58afa9f67bc4a..a2da5f38073357ab4383fa9c88722009d7de30cf 100755 --- a/Reconstruction/MuonIdentification/MuidTrackBuilder/MuidTrackBuilder/CombinedMuonTrackBuilder.h +++ b/Reconstruction/MuonIdentification/MuidTrackBuilder/MuidTrackBuilder/CombinedMuonTrackBuilder.h @@ -98,13 +98,13 @@ class CombinedMuonTrackBuilder : public AthAlgTool, virtual public ICombinedMuon Trk::Track* fit(Trk::Track& track, const Trk::RunOutlierRemoval runOutlier = false, const Trk::ParticleHypothesis particleHypothesis = Trk::muon) const; - /** + /** fit a set of MeasurementBase objects with starting value for perigeeParameters */ Trk::Track* fit(const Trk::MeasurementSet& /*measurementSet*/, const Trk::TrackParameters& /*perigeeStartValue*/, const Trk::RunOutlierRemoval /*runOutlier*/, const Trk::ParticleHypothesis /*particleHypothesis*/) const; - /** + /** combined muon fit */ Trk::Track* fit(const Trk::Track& indetTrack, Trk::Track& extrapolatedTrack, const Trk::RunOutlierRemoval runOutlier = false, @@ -171,29 +171,103 @@ class CombinedMuonTrackBuilder : public AthAlgTool, virtual public ICombinedMuon bool checkTrack(std::string txt, Trk::Track* newTrack, Trk::Track* track) const; // helpers, managers, tools - ToolHandle<Rec::IMuidCaloEnergy> m_caloEnergyParam; - ToolHandle<Rec::IMuidCaloTrackStateOnSurface> m_caloTSOS; - ToolHandle<Muon::IMuonTrackCleaner> m_cleaner; - ToolHandle<Muon::IMuonClusterOnTrackCreator> m_cscRotCreator; - ToolHandle<Trk::IExtrapolator> m_extrapolator; - ToolHandle<Trk::ITrackFitter> m_fitter; // curved track fitter - ToolHandle<Trk::ITrackFitter> m_fitterSL; // straight line fitter - ToolHandle<Trk::IIntersector> m_intersector; - ToolHandle<Trk::IMaterialAllocator> m_materialAllocator; - ToolHandle<Muon::IMdtDriftCircleOnTrackCreator> m_mdtRotCreator; - ToolHandle<Muon::IMuonErrorOptimisationTool> m_muonErrorOptimizer; - ToolHandle<Muon::IMuonHoleRecoveryTool> m_muonHoleRecovery; - ToolHandle<Trk::IPropagator> m_propagator; - ToolHandle<Trk::IPropagator> m_propagatorSL; - ToolHandle<Muon::MuonEDMPrinterTool> m_printer; - ToolHandle<Rec::IMuonTrackQuery> m_trackQuery; - ToolHandle<Trk::ITrackSummaryTool> m_trackSummary; - ToolHandle<Trk::ITrkMaterialProviderTool> m_materialUpdator; - - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; + ToolHandle<Rec::IMuidCaloEnergy> m_caloEnergyParam{ + this, + "CaloEnergyParam", + "Rec::MuidCaloEnergyTool/MuidCaloEnergyToolParam", + }; + ToolHandle<Rec::IMuidCaloTrackStateOnSurface> m_caloTSOS{ + this, + "CaloTSOS", + "Rec::MuidCaloTrackStateOnSurface/MuidCaloTrackStateOnSurface", + }; + ToolHandle<Muon::IMuonTrackCleaner> m_cleaner{ + this, + "Cleaner", + "Muon::MuonTrackCleaner/MuidTrackCleaner", + }; + ToolHandle<Muon::IMuonClusterOnTrackCreator> m_cscRotCreator{ + this, + "CscRotCreator", + "", + }; + ToolHandle<Trk::IExtrapolator> m_extrapolator{ + this, + "Extrapolator", + "Trk::Extrapolator/AtlasExtrapolator", + }; + ToolHandle<Trk::ITrackFitter> m_fitter{ + this, + "Fitter", + "Trk::iPatFitter/iPatFitter", + }; // curved track fitter + ToolHandle<Trk::ITrackFitter> m_fitterSL{ + this, + "SLFitter", + "Trk::iPatFitter/iPatSLFitter", + }; // straight line fitter + ToolHandle<Trk::IIntersector> m_intersector{ + this, + "Intersector", + "Trk::RungeKuttaIntersector/RungeKuttaIntersector", + }; + ToolHandle<Trk::IMaterialAllocator> m_materialAllocator{ + this, + "MaterialAllocator", + "", + }; + ToolHandle<Muon::IMdtDriftCircleOnTrackCreator> m_mdtRotCreator{ + this, + "MdtRotCreator", + "", + }; + ToolHandle<Muon::IMuonErrorOptimisationTool> m_muonErrorOptimizer{ + this, + "MuonErrorOptimizer", + "Muon::MuonErrorOptimisationTool/MuidErrorOptimisationTool", + }; + ToolHandle<Muon::IMuonHoleRecoveryTool> m_muonHoleRecovery{ + this, + "MuonHoleRecovery", + "Muon::MuonChamberHoleRecoveryTool/MuonChamberHoleRecoveryTool", + }; + ToolHandle<Trk::IPropagator> m_propagator{ + this, + "Propagator", + "Trk::IntersectorWrapper/IntersectorWrapper", + }; + ToolHandle<Trk::IPropagator> m_propagatorSL{ + this, + "SLPropagator", + "Trk::StraightLinePropagator/MuonStraightLinePropagator", + }; + ToolHandle<Muon::MuonEDMPrinterTool> m_printer{ + this, + "Printer", + "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool", + }; + ToolHandle<Rec::IMuonTrackQuery> m_trackQuery{ + this, + "TrackQuery", + "Rec::MuonTrackQuery/MuonTrackQuery", + }; + ToolHandle<Trk::ITrackSummaryTool> m_trackSummary{ + this, + "TrackSummaryTool", + "Trk::TrackSummaryTool/MuidTrackSummaryTool", + }; + ToolHandle<Trk::ITrkMaterialProviderTool> m_materialUpdator{ + this, + "CaloMaterialProvider", + "Trk::TrkMaterialProviderTool/TrkMaterialProviderTool", + }; + + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", + "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; // Read handle for conditions object to get the field cache - SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey{ + this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc; // init with callback ServiceHandle<Trk::ITrackingVolumesSvc> m_trackingVolumesSvc; @@ -231,8 +305,8 @@ class CombinedMuonTrackBuilder : public AthAlgTool, virtual public ICombinedMuon bool m_inputSlimming; // constants - const Trk::Volume* m_calorimeterVolume; - const Trk::Volume* m_indetVolume; + const Trk::Volume* m_calorimeterVolume; + const Trk::Volume* m_indetVolume; const Trk::TrackingVolume* m_spectrometerEntrance; // vertex region and phi modularity for pseudo-measurement constraints diff --git a/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx b/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx index bf23fea72aea1662a1191fa558f8cdc6d7c0e772..0cc8a195bbb3241a5ec9bf782cdfeb8f5ed3694d 100755 --- a/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx +++ b/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx @@ -18,7 +18,6 @@ #include <iomanip> #include <memory> - #include "AthenaKernel/Units.h" #include "EventPrimitives/EventPrimitivesHelpers.h" #include "EventPrimitives/EventPrimitivesToStringConverter.h" @@ -59,24 +58,6 @@ namespace Rec { CombinedMuonTrackBuilder::CombinedMuonTrackBuilder(const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type, name, parent), - m_caloEnergyParam("Rec::MuidCaloEnergyTool/MuidCaloEnergyToolParam", this), - m_caloTSOS("Rec::MuidCaloTrackStateOnSurface/MuidCaloTrackStateOnSurface", this), - m_cleaner("Muon::MuonTrackCleaner/MuidTrackCleaner", this), - m_cscRotCreator("", this), - m_extrapolator("Trk::Extrapolator/AtlasExtrapolator", this), - m_fitter("Trk::iPatFitter/iPatFitter", this), - m_fitterSL("Trk::iPatFitter/iPatSLFitter", this), - m_intersector("Trk::RungeKuttaIntersector/RungeKuttaIntersector", this), - m_materialAllocator("", this), - m_mdtRotCreator("", this), - m_muonErrorOptimizer("Muon::MuonErrorOptimisationTool/MuidErrorOptimisationTool", this), - m_muonHoleRecovery("Muon::MuonChamberHoleRecoveryTool/MuonChamberHoleRecoveryTool", this), - m_propagator("Trk::IntersectorWrapper/IntersectorWrapper", this), - m_propagatorSL("Trk::StraightLinePropagator/MuonStraightLinePropagator", this), - m_printer("Muon::MuonEDMPrinterTool/MuonEDMPrinterTool", this), - m_trackQuery("Rec::MuonTrackQuery/MuonTrackQuery", this), - m_trackSummary("Trk::TrackSummaryTool/MuidTrackSummaryTool", this), - m_materialUpdator("Trk::TrkMaterialProviderTool/TrkMaterialProviderTool", this), m_trackingGeometrySvc("TrackingGeometrySvc/AtlasTrackingGeometrySvc", name), m_trackingVolumesSvc("TrackingVolumesSvc/TrackingVolumesSvc", name), m_magFieldProperties(Trk::FullField), @@ -132,22 +113,7 @@ CombinedMuonTrackBuilder::CombinedMuonTrackBuilder(const std::string& type, cons m_messageHelper = new MessageHelper(*this); declareInterface<ICombinedMuonTrackBuilder>(this); - declareProperty("CaloEnergyParam", m_caloEnergyParam); - declareProperty("CaloTSOS", m_caloTSOS); - declareProperty("Cleaner", m_cleaner); - declareProperty("CscRotCreator", m_cscRotCreator); - declareProperty("Extrapolator", m_extrapolator); - declareProperty("Fitter", m_fitter); - declareProperty("SLFitter", m_fitterSL); - declareProperty("Intersector", m_intersector); - declareProperty("MaterialAllocator", m_materialAllocator); - declareProperty("MdtRotCreator", m_mdtRotCreator); - declareProperty("MuonErrorOptimizer", m_muonErrorOptimizer); - declareProperty("MuonHoleRecovery", m_muonHoleRecovery); - declareProperty("Propagator", m_propagator); - declareProperty("SLPropagator", m_propagatorSL); declareProperty("TrackingVolumesSvc", m_trackingVolumesSvc); - declareProperty("TrackSummaryTool", m_trackSummary); declareProperty("AllowCleanerVeto", m_allowCleanerVeto); declareProperty("CleanCombined", m_cleanCombined); declareProperty("CleanStandalone", m_cleanStandalone); @@ -178,14 +144,12 @@ CombinedMuonTrackBuilder::CombinedMuonTrackBuilder(const std::string& type, cons declareProperty("UpdateWithCaloTG", m_updateWithCaloTG); declareProperty("UseCaloTG", m_useCaloTG); - declareProperty("CaloMaterialProvider", m_materialUpdator); declareProperty("IterateCombinedTrackFit", m_iterateCombinedTrackFit); declareProperty("RefineELossCombinedTrackFit", m_refineELossCombinedTrackFit); declareProperty("RefineELossStandAloneTrackFit", m_refineELossStandAloneTrackFit); declareProperty("AddElossID", m_addElossID); declareProperty("AddIDMSerrors", m_addIDMSerrors); declareProperty("UseRefitTrackError", m_useRefitTrackError); - declareProperty("TrackQuery", m_trackQuery); } @@ -294,7 +258,7 @@ CombinedMuonTrackBuilder::initialize() ATH_CHECK(m_intersector.retrieve()); ATH_MSG_DEBUG("Retrieved tool " << m_intersector); /// handle to the magnetic field cache - ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); + ATH_CHECK(m_fieldCacheCondObjInputKey.initialize()); ATH_MSG_DEBUG("Setup handle for key " << m_fieldCacheCondObjInputKey); if (!m_materialAllocator.empty()) { @@ -371,8 +335,8 @@ CombinedMuonTrackBuilder::initialize() // missing TrackingGeometrySvc - no perigee will be added at MS entrance m_messageHelper->printWarning(41); } else { - const Trk::TrackingGeometry* trkGeo = m_trackingGeometrySvc->trackingGeometry(); - if (trkGeo) m_spectrometerEntrance = trkGeo->trackingVolume("MuonSpectrometerEntrance"); + const Trk::TrackingGeometry* trkGeo = m_trackingGeometrySvc->trackingGeometry(); + if (trkGeo) m_spectrometerEntrance = trkGeo->trackingVolume("MuonSpectrometerEntrance"); } return StatusCode::SUCCESS; @@ -449,18 +413,19 @@ CombinedMuonTrackBuilder::combinedFit(const Trk::Track& indetTrack, const Trk::T // match extrapolated indet track to inner calorimeter scattering surface // provided momentum defined (solenoid on) - MagField::AtlasFieldCache fieldCache; + MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); - return nullptr; + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); + return nullptr; } - fieldCondObj->getInitializedCache (fieldCache); - + fieldCondObj->getInitializedCache(fieldCache); + if (surface && fieldCache.solenoidOn() && !m_updateWithCaloTG) { const Trk::TrackStateOnSurface* innerTSOS = nullptr; @@ -517,14 +482,15 @@ CombinedMuonTrackBuilder::combinedFit(const Trk::Track& indetTrack, const Trk::T // such as need to replace calorimeter material or presence of pseudomeasurements if (!surface) { // extrapolate outwards to associate calorimeter material effects ATH_MSG_VERBOSE("Calling createMuonTrack from " << __func__ << " at line " << __LINE__); - muonTrack = createMuonTrack( - extrapolatedTrack, indetTrack.perigeeParameters(), nullptr, extrapolatedTrack.trackStateOnSurfaces()->begin(), - extrapolatedTrack.trackStateOnSurfaces()->end(), extrapolatedTrack.trackStateOnSurfaces()->size()); - } else if (m_trackQuery->numberPseudoMeasurements(extrapolatedTrack) > 1) { // remove pseudo meas - ATH_MSG_VERBOSE("Calling createMuonTrack from " << __func__ << " at line " << __LINE__); - muonTrack = createMuonTrack(extrapolatedTrack, nullptr, nullptr, extrapolatedTrack.trackStateOnSurfaces()->begin(), + muonTrack = createMuonTrack(extrapolatedTrack, indetTrack.perigeeParameters(), nullptr, + extrapolatedTrack.trackStateOnSurfaces()->begin(), extrapolatedTrack.trackStateOnSurfaces()->end(), extrapolatedTrack.trackStateOnSurfaces()->size()); + } else if (m_trackQuery->numberPseudoMeasurements(extrapolatedTrack) > 1) { // remove pseudo meas + ATH_MSG_VERBOSE("Calling createMuonTrack from " << __func__ << " at line " << __LINE__); + muonTrack = createMuonTrack( + extrapolatedTrack, nullptr, nullptr, extrapolatedTrack.trackStateOnSurfaces()->begin(), + extrapolatedTrack.trackStateOnSurfaces()->end(), extrapolatedTrack.trackStateOnSurfaces()->size()); } else { // otherwise can just copy the extrapolated track ATH_MSG_VERBOSE("Calling createMuonTrack from " << __func__ << " at line " << __LINE__); muonTrack = createMuonTrack(extrapolatedTrack, extrapolatedTrack.perigeeParameters(), nullptr, @@ -809,18 +775,19 @@ CombinedMuonTrackBuilder::indetExtension(const Trk::Track& indetTrack, // fail when solenoid off and toroid on (as extrapolation from ID is not the correct strategy) ToolHandle<Trk::IPropagator> propagator = m_propagatorSL; - MagField::AtlasFieldCache fieldCache; + MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); - return 0; + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); + return 0; } - fieldCondObj->getInitializedCache (fieldCache); - + fieldCondObj->getInitializedCache(fieldCache); + if (fieldCache.toroidOn()) { // fail when solenoid off and toroid on - as extrapolation from ID is not the correct strategy // for material effects, fit starting value etc @@ -975,17 +942,18 @@ CombinedMuonTrackBuilder::standaloneFit(const Trk::Track& inputSpectrometerTrack float bs_x, float bs_y, float bs_z) const { - MagField::AtlasFieldCache fieldCache; + MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); - return 0; + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); + return 0; } - fieldCondObj->getInitializedCache (fieldCache); + fieldCondObj->getInitializedCache(fieldCache); // no SA fit with vertex constraint for Toroid off data if (m_trackQuery->isLineFit(inputSpectrometerTrack) && !fieldCache.toroidOn()) { @@ -1179,14 +1147,14 @@ CombinedMuonTrackBuilder::standaloneFit(const Trk::Track& inputSpectrometerTrack (beamAxisCovariance)(0, 0) = m_vertex2DSigmaRPhi * m_vertex2DSigmaRPhi; (beamAxisCovariance)(1, 1) = m_vertex2DSigmaRPhi * m_vertex2DSigmaRPhi; (beamAxisCovariance)(2, 2) = m_vertex2DSigmaZ * m_vertex2DSigmaZ; - mbeamAxis = std::make_unique<Trk::RecVertex>(origin, beamAxisCovariance); + mbeamAxis = std::make_unique<Trk::RecVertex>(origin, beamAxisCovariance); AmgSymMatrix(3) vertexRegionCovariance; vertexRegionCovariance.setZero(); (vertexRegionCovariance)(0, 0) = m_vertex3DSigmaRPhi * m_vertex3DSigmaRPhi; (vertexRegionCovariance)(1, 1) = m_vertex3DSigmaRPhi * m_vertex3DSigmaRPhi; (vertexRegionCovariance)(2, 2) = m_vertex3DSigmaZ * m_vertex3DSigmaZ; - mvertex = std::make_unique<Trk::RecVertex>(origin, vertexRegionCovariance); + mvertex = std::make_unique<Trk::RecVertex>(origin, vertexRegionCovariance); } parameters = @@ -1417,7 +1385,8 @@ CombinedMuonTrackBuilder::standaloneFit(const Trk::Track& inputSpectrometerTrack type.set(Trk::TrackStateOnSurface::Outlier); } - *t = new const Trk::TrackStateOnSurface(updatedRot, (**t).trackParameters()->clone(), nullptr, nullptr, type); + *t = new const Trk::TrackStateOnSurface(updatedRot, (**t).trackParameters()->clone(), nullptr, nullptr, + type); delete tsos; } } @@ -1716,18 +1685,19 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float countAEOTs(&combinedTrack, " in standalone Refit input combinedTrack "); - MagField::AtlasFieldCache fieldCache; + MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); - return 0; + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); + return 0; } - fieldCondObj->getInitializedCache (fieldCache); - + fieldCondObj->getInitializedCache(fieldCache); + if (!fieldCache.toroidOn()) { // no standalone refit for Toroid off return nullptr; @@ -2052,7 +2022,8 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> type; type.set(Trk::TrackStateOnSurface::Measurement); - trackStateOnSurfaces->push_back(new const Trk::TrackStateOnSurface(vertexInFit, nullptr, nullptr, nullptr, type)); + trackStateOnSurfaces->push_back( + new const Trk::TrackStateOnSurface(vertexInFit, nullptr, nullptr, nullptr, type)); } @@ -2212,13 +2183,13 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float return nullptr; } - //eventually this whole tool will use unique_ptrs - //in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them + // eventually this whole tool will use unique_ptrs + // in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them std::unique_ptr<Trk::Track> refittedTrackUnique(refittedTrack); if (refittedTrackUnique) { if (!refittedTrackUnique->fitQuality()) { - delete vertex; - return nullptr; + delete vertex; + return nullptr; } if (!m_trackQuery->isCaloAssociated(*refittedTrackUnique)) { @@ -2237,19 +2208,20 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float { ATH_MSG_VERBOSE(" perform spectrometer error optimization after cleaning "); - std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(refittedTrackUnique.get()); + std::unique_ptr<Trk::Track> optimizedTrack = + m_muonErrorOptimizer->optimiseErrors(refittedTrackUnique.get()); if (optimizedTrack) { - if (checkTrack("standaloneRefitOpt", optimizedTrack.get(), refittedTrackUnique.get())) { - refittedTrackUnique.swap(optimizedTrack); - countAEOTs(refittedTrackUnique.get(), " standaloneRefit alignment errors Track "); - } + if (checkTrack("standaloneRefitOpt", optimizedTrack.get(), refittedTrackUnique.get())) { + refittedTrackUnique.swap(optimizedTrack); + countAEOTs(refittedTrackUnique.get(), " standaloneRefit alignment errors Track "); + } } } } delete vertex; - //have to release it until the whole tool is migrated to unique_ptr + // have to release it until the whole tool is migrated to unique_ptr return refittedTrackUnique.release(); } @@ -2273,17 +2245,18 @@ CombinedMuonTrackBuilder::fit(Trk::Track& track, const Trk::RunOutlierRemoval ru bool isCombined = m_trackQuery->isCombined(track); // select straightLine fitter when magnets downstream of leading measurement are off ToolHandle<Trk::ITrackFitter> fitter = m_fitter; - MagField::AtlasFieldCache fieldCache; + MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); - return 0; + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); + return 0; } - fieldCondObj->getInitializedCache (fieldCache); + fieldCondObj->getInitializedCache(fieldCache); if (!fieldCache.toroidOn() && !(isCombined && fieldCache.solenoidOn())) { @@ -2380,25 +2353,25 @@ CombinedMuonTrackBuilder::fit(Trk::Track& track, const Trk::RunOutlierRemoval ru return nullptr; } - //eventually this whole tool will use unique_ptrs - //in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them + // eventually this whole tool will use unique_ptrs + // in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them std::unique_ptr<Trk::Track> fittedTrackUnique(fittedTrack); // track cleaning if (runOutlier) { - // fit with optimized spectrometer errors + // fit with optimized spectrometer errors if (!m_muonErrorOptimizer.empty() && !fittedTrackUnique->info().trackProperties(Trk::TrackInfo::StraightTrack) && optimizeErrors(fittedTrackUnique.get())) { ATH_MSG_VERBOSE(" perform spectrometer error optimization after cleaning "); - std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(fittedTrackUnique.get()); + std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(fittedTrackUnique.get()); if (optimizedTrack) { - if (checkTrack("fitInterface1Opt", optimizedTrack.get(), fittedTrackUnique.get())) { - fittedTrackUnique.swap(optimizedTrack); - countAEOTs(fittedTrackUnique.get(), " re fit scaled errors Track "); - } + if (checkTrack("fitInterface1Opt", optimizedTrack.get(), fittedTrackUnique.get())) { + fittedTrackUnique.swap(optimizedTrack); + countAEOTs(fittedTrackUnique.get(), " re fit scaled errors Track "); + } } } @@ -2423,7 +2396,7 @@ CombinedMuonTrackBuilder::fit(Trk::Track& track, const Trk::RunOutlierRemoval ru if (m_allowCleanerVeto && chi2Before > m_badFitChi2) { ATH_MSG_DEBUG(" cleaner veto A "); ++m_countStandaloneCleanerVeto; - fittedTrackUnique.reset(); + fittedTrackUnique.reset(); } else { ATH_MSG_DEBUG(" keep original standalone track despite cleaner veto "); } @@ -2432,7 +2405,7 @@ CombinedMuonTrackBuilder::fit(Trk::Track& track, const Trk::RunOutlierRemoval ru if (chi2After < m_badFitChi2 || chi2After < chi2Before) { ATH_MSG_VERBOSE(" found and removed spectrometer outlier(s) "); - fittedTrackUnique.swap(cleanTrack); + fittedTrackUnique.swap(cleanTrack); } else { ATH_MSG_VERBOSE(" keep original track despite cleaning "); } @@ -2445,11 +2418,11 @@ CombinedMuonTrackBuilder::fit(Trk::Track& track, const Trk::RunOutlierRemoval ru } } - //have to use release until the whole tool uses unique_ptr + // have to use release until the whole tool uses unique_ptr return fittedTrackUnique.release(); } -/** +/** fit a set of MeasurementBase objects with starting value for perigeeParameters */ Trk::Track* CombinedMuonTrackBuilder::fit(const Trk::MeasurementSet& measurementSet, const Trk::TrackParameters& perigeeStartValue, @@ -2466,17 +2439,18 @@ CombinedMuonTrackBuilder::fit(const Trk::MeasurementSet& measurementSet, const T } // select straightLine fitter when magnets downstream of leading measurement are off - MagField::AtlasFieldCache fieldCache; + MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); - return 0; + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); + return 0; } - fieldCondObj->getInitializedCache (fieldCache); + fieldCondObj->getInitializedCache(fieldCache); ToolHandle<Trk::ITrackFitter> fitter = m_fitter; if (!fieldCache.toroidOn() || std::abs(perigeeStartValue.position().z()) > m_zECToroid) { @@ -2516,8 +2490,8 @@ CombinedMuonTrackBuilder::fit(const Trk::MeasurementSet& measurementSet, const T return nullptr; } - //eventually this whole tool will use unique_ptrs - //in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them + // eventually this whole tool will use unique_ptrs + // in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them std::unique_ptr<Trk::Track> fittedTrackUnique(fittedTrack); // track cleaning if (runOutlier) { @@ -2528,12 +2502,12 @@ CombinedMuonTrackBuilder::fit(const Trk::MeasurementSet& measurementSet, const T { ATH_MSG_VERBOSE(" perform spectrometer error optimization after cleaning "); - std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(fittedTrackUnique.get()); + std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(fittedTrackUnique.get()); if (optimizedTrack) { - if (checkTrack("fitInterface2Opt", optimizedTrack.get(), fittedTrackUnique.get())) { - fittedTrackUnique.swap(optimizedTrack); - countAEOTs(fittedTrackUnique.get(), " fit mstSet scaled errors Track "); - } + if (checkTrack("fitInterface2Opt", optimizedTrack.get(), fittedTrackUnique.get())) { + fittedTrackUnique.swap(optimizedTrack); + countAEOTs(fittedTrackUnique.get(), " fit mstSet scaled errors Track "); + } } } @@ -2557,7 +2531,7 @@ CombinedMuonTrackBuilder::fit(const Trk::MeasurementSet& measurementSet, const T if (m_allowCleanerVeto && chi2Before > m_badFitChi2) { ATH_MSG_DEBUG(" cleaner veto B"); ++m_countExtensionCleanerVeto; - fittedTrackUnique.reset(); + fittedTrackUnique.reset(); } else { ATH_MSG_DEBUG(" keep original extension track despite cleaner veto "); } @@ -2565,7 +2539,7 @@ CombinedMuonTrackBuilder::fit(const Trk::MeasurementSet& measurementSet, const T double chi2After = normalizedChi2(*cleanTrack); if (chi2After < m_badFitChi2 || chi2After < chi2Before) { ATH_MSG_VERBOSE(" found and removed spectrometer outlier(s) "); - fittedTrackUnique.swap(cleanTrack); + fittedTrackUnique.swap(cleanTrack); } else { ATH_MSG_VERBOSE(" keep original track despite cleaning "); } @@ -2574,7 +2548,7 @@ CombinedMuonTrackBuilder::fit(const Trk::MeasurementSet& measurementSet, const T // FIXME: provide indet cleaner ATH_MSG_VERBOSE(" finished cleaning"); } - //have to use release until the whole code uses unique_ptr + // have to use release until the whole code uses unique_ptr return fittedTrackUnique.release(); } @@ -2596,17 +2570,18 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& indetTrack, Trk::Track& extrapol // select straightLine fitter when solenoid and toroid are off ToolHandle<Trk::ITrackFitter> fitter = m_fitter; - MagField::AtlasFieldCache fieldCache; + MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); - return 0; + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); + return 0; } - fieldCondObj->getInitializedCache (fieldCache); + fieldCondObj->getInitializedCache(fieldCache); if (!fieldCache.toroidOn() && !fieldCache.solenoidOn()) { @@ -2637,8 +2612,8 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& indetTrack, Trk::Track& extrapol if (!fittedTrack) return nullptr; - //eventually this whole tool will use unique_ptrs - //in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them + // eventually this whole tool will use unique_ptrs + // in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them std::unique_ptr<Trk::Track> fittedTrackUnique(fittedTrack); // track cleaning @@ -2649,11 +2624,11 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& indetTrack, Trk::Track& extrapol && optimizeErrors(fittedTrackUnique.get())) { ATH_MSG_VERBOSE(" perform spectrometer error optimization after cleaning "); - std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(fittedTrackUnique.get()); + std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(fittedTrackUnique.get()); if (optimizedTrack) { - fittedTrackUnique.swap(optimizedTrack); - countAEOTs(fittedTrackUnique.get(), " cbfit scaled errors Track "); + fittedTrackUnique.swap(optimizedTrack); + countAEOTs(fittedTrackUnique.get(), " cbfit scaled errors Track "); } } @@ -2665,7 +2640,7 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& indetTrack, Trk::Track& extrapol << m_printer->printStations(*fittedTrackUnique)); if (fittedTrackUnique) { - countAEOTs(fittedTrackUnique.get(), " cb before clean Track "); + countAEOTs(fittedTrackUnique.get(), " cb before clean Track "); } std::unique_ptr<Trk::Track> cleanTrack = m_cleaner->clean(*fittedTrackUnique); if (cleanTrack) { @@ -2676,7 +2651,7 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& indetTrack, Trk::Track& extrapol if (m_allowCleanerVeto && chi2Before > m_badFitChi2) { ATH_MSG_DEBUG(" cleaner veto C"); ++m_countCombinedCleanerVeto; - fittedTrackUnique.reset(); + fittedTrackUnique.reset(); } else { ATH_MSG_DEBUG(" keep original combined track despite cleaner veto "); } @@ -2684,7 +2659,7 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& indetTrack, Trk::Track& extrapol double chi2After = normalizedChi2(*cleanTrack); if (chi2After < m_badFitChi2 || chi2After < chi2Before) { ATH_MSG_VERBOSE(" found and removed spectrometer outlier(s) "); - fittedTrackUnique.swap(cleanTrack); + fittedTrackUnique.swap(cleanTrack); } else { ATH_MSG_VERBOSE(" keep original track despite cleaning "); } @@ -2693,7 +2668,7 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& indetTrack, Trk::Track& extrapol // FIXME: provide indet cleaner ATH_MSG_VERBOSE(" finished cleaning"); } - //have to use release until the whole code uses unique_ptr + // have to use release until the whole code uses unique_ptr return fittedTrackUnique.release(); } @@ -3247,17 +3222,18 @@ CombinedMuonTrackBuilder::createExtrapolatedTrack(const Trk::Track& sp // if association OK, create perigee surface and back-track to it if (caloAssociated) { - MagField::AtlasFieldCache fieldCache; + MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); return 0; } - fieldCondObj->getInitializedCache (fieldCache); + fieldCondObj->getInitializedCache(fieldCache); if (fieldCache.toroidOn()) { const Trk::TrackParameters* oldParameters = caloTSOS->front()->trackParameters(); @@ -3411,7 +3387,8 @@ CombinedMuonTrackBuilder::createExtrapolatedTrack(const Trk::Track& sp std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> type; type.set(Trk::TrackStateOnSurface::Measurement); - trackStateOnSurfaces->push_back(new const Trk::TrackStateOnSurface(vertexInFit, nullptr, nullptr, nullptr, type)); + trackStateOnSurfaces->push_back( + new const Trk::TrackStateOnSurface(vertexInFit, nullptr, nullptr, nullptr, type)); } } @@ -3925,7 +3902,7 @@ CombinedMuonTrackBuilder::entrancePerigee(const Trk::TrackParameters* parameters if (!entranceParameters) return nullptr; - Trk::PerigeeSurface surface(entranceParameters->position()); + Trk::PerigeeSurface surface(entranceParameters->position()); const Trk::TrackParameters* trackParameters = m_extrapolator->extrapolateDirectly(*entranceParameters, surface); delete entranceParameters; @@ -3993,15 +3970,16 @@ CombinedMuonTrackBuilder::extrapolatedParameters(bool& badlyDeterminedCurvature, ToolHandle<Trk::IPropagator> propagator = m_propagator; MagField::AtlasFieldCache fieldCache; // Get field cache object - EventContext ctx = Gaudi::Hive::currentContext(); + EventContext ctx = Gaudi::Hive::currentContext(); SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " + << m_fieldCacheCondObjInputKey.key()); return 0; } - fieldCondObj->getInitializedCache (fieldCache); + fieldCondObj->getInitializedCache(fieldCache); if (!fieldCache.toroidOn()) { curvatureOK = true; propagator = m_propagatorSL; @@ -4277,25 +4255,25 @@ CombinedMuonTrackBuilder::finalTrackBuild(Trk::Track*& track) const ATH_MSG_VERBOSE(" finished hole recovery procedure "); } - //eventually this whole tool will use unique_ptrs - //in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them + // eventually this whole tool will use unique_ptrs + // in the meantime, this allows the MuonErrorOptimisationTool and MuonRefitTool to use them std::unique_ptr<Trk::Track> trackUnique(track); // final fit with optimized spectrometer errors if (!m_muonErrorOptimizer.empty() && !trackUnique->info().trackProperties(Trk::TrackInfo::StraightTrack) && countAEOTs(trackUnique.get(), " before optimize ") == 0) { ATH_MSG_VERBOSE(" perform spectrometer error optimization... "); - std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(trackUnique.get()); + std::unique_ptr<Trk::Track> optimizedTrack = m_muonErrorOptimizer->optimiseErrors(trackUnique.get()); if (optimizedTrack && checkTrack("finalTrackBuild2", optimizedTrack.get(), trackUnique.get())) { - trackUnique.swap(optimizedTrack); - countAEOTs(track, " finalTrackBuilt alignment errors Track "); + trackUnique.swap(optimizedTrack); + countAEOTs(track, " finalTrackBuilt alignment errors Track "); } } // add the track summary m_trackSummary->updateTrack(*trackUnique); - //have to use release until the whole code uses unique_ptr - track=trackUnique.release(); + // have to use release until the whole code uses unique_ptr + track = trackUnique.release(); } Trk::Track*