diff --git a/MuonSpectrometer/MuonCalib/MuonCalibPatRec/src/MuonSegmentToCalibSegment.cxx b/MuonSpectrometer/MuonCalib/MuonCalibPatRec/src/MuonSegmentToCalibSegment.cxx index 085871bd0d8597ef43544a68cf2152312586d331..6d9d8e77cb683c36f7b01746e854ab2e7229550b 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibPatRec/src/MuonSegmentToCalibSegment.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibPatRec/src/MuonSegmentToCalibSegment.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonCalibPatRec/MuonSegmentToCalibSegment.h" @@ -211,7 +211,7 @@ namespace MuonCalib { unsigned int nstations = (*sit)->numberOfStations(); for(unsigned int i=0; i!=nstations; ++i){ - const Muon::MuonSegmentCombination::SegmentVec* stationSegs = (*sit)->stationSegments( i ) ; + Muon::MuonSegmentCombination::SegmentVec* stationSegs = (*sit)->stationSegments( i ) ; ATH_MSG_VERBOSE( "New station with " << stationSegs->size() << " segments " ); @@ -220,11 +220,11 @@ namespace MuonCalib { // continue; // } - Muon::MuonSegmentCombination::SegmentVec::const_iterator segit = stationSegs->begin(); - Muon::MuonSegmentCombination::SegmentVec::const_iterator segit_end = stationSegs->end(); + Muon::MuonSegmentCombination::SegmentVec::iterator segit = stationSegs->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator segit_end = stationSegs->end(); for( ; segit!=segit_end;++segit ){ - const Muon::MuonSegment* seg = *segit; + Muon::MuonSegment* seg = (*segit).get(); if( !seg ) { ATH_MSG_WARNING( " go NULL pointer for MuonSegment " ); @@ -346,7 +346,7 @@ namespace MuonCalib { unsigned int nstations = (*sit)->numberOfStations(); for(unsigned int i=0; i!=nstations; ++i){ - const Muon::MuonSegmentCombination::SegmentVec* stationSegs = (*sit)->stationSegments( i ) ; + Muon::MuonSegmentCombination::SegmentVec* stationSegs = (*sit)->stationSegments( i ) ; ATH_MSG_VERBOSE( "New Csc station with " << stationSegs->size() << " segments " ); @@ -355,11 +355,11 @@ namespace MuonCalib { // continue; // } - Muon::MuonSegmentCombination::SegmentVec::const_iterator segit = stationSegs->begin(); - Muon::MuonSegmentCombination::SegmentVec::const_iterator segit_end = stationSegs->end(); + Muon::MuonSegmentCombination::SegmentVec::iterator segit = stationSegs->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator segit_end = stationSegs->end(); for( ; segit!=segit_end;++segit) { - const Muon::MuonSegment* seg = *segit; + Muon::MuonSegment* seg = (*segit).get(); if( !seg ) { ATH_MSG_WARNING( " go NULL pointer for MuonSegment " ); diff --git a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonCombinePatternTools/MuonCombinePatternTools/MuonCombinePatternTool.h b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonCombinePatternTools/MuonCombinePatternTools/MuonCombinePatternTool.h index 59dfdae251d43afc6f81d93d16d30241cbdf8bc1..3b2c693a388adaa53657447a412feb8ca97ada50 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonCombinePatternTools/MuonCombinePatternTools/MuonCombinePatternTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonCombinePatternTools/MuonCombinePatternTools/MuonCombinePatternTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONCOMBINEPATTERNTOOLS_MUONCOMBINEPATTERNTOOL_H @@ -57,7 +57,7 @@ class MuonCombinePatternTool : public AthAlgTool, virtual public Muon::IMuonComb /** converts MuonPrdPatterns into MuonPatternCombinationCollection * MuonPatternCombinationCollection are default output for PatternFinder */ - virtual const MuonPatternCombinationCollection* makePatternCombinations(const MuonPrdPatternCollection* muonpatterns)const; + virtual MuonPatternCombinationCollection* makePatternCombinations(const MuonPrdPatternCollection* muonpatterns)const; /** method to set association map between phi and eta hits */ virtual void setPhiEtaHitAssMap(std::map <const Trk::PrepRawData*, std::set<const Trk::PrepRawData*,Muon::IdentifierPrdLess> >*); diff --git a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonCombinePatternTools/src/MuonCombinePatternTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonCombinePatternTools/src/MuonCombinePatternTool.cxx index 1c169d7fb00eec7035ed8b80055f7525a1489544..ff2675d4c9491e6fdf65f924c6b8f1f10c52eae7 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonCombinePatternTools/src/MuonCombinePatternTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonCombinePatternTools/src/MuonCombinePatternTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonCombinePatternTools/MuonCombinePatternTool.h" @@ -1659,7 +1659,7 @@ const Amg::Vector3D& MuonCombinePatternTool::globalPrdPos( const Trk::PrepRawDat return prd->detectorElement()->surface(prd->identify()).center(); } -const MuonPatternCombinationCollection* MuonCombinePatternTool::makePatternCombinations(const MuonPrdPatternCollection* muonpatterns)const +MuonPatternCombinationCollection* MuonCombinePatternTool::makePatternCombinations(const MuonPrdPatternCollection* muonpatterns)const { ATH_MSG_DEBUG("makePatternCombinations"); diff --git a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonHoughPatternFinderTool.h b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonHoughPatternFinderTool.h index 2d1aa92c5c6f74e1c8345ce5030100e790fc6865..93c103996b46c1dca3a9cf8c56d872ac80313677 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonHoughPatternFinderTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonHoughPatternFinderTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONHOUGHPATTERNALGS_MUONHOUGHPATTERNFINDERTOOL_H @@ -58,11 +58,11 @@ namespace Muon { virtual StatusCode finalize(); /** find patterns for a give set of MuonPrepData collections + optionally CSC segment combinations */ - const MuonPatternCombinationCollection* find( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols, - const MuonSegmentCombinationCollection* cscSegmentCombis ) const; + MuonPatternCombinationCollection* find( const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + const MuonSegmentCombinationCollection* cscSegmentCombis ) const; private: @@ -80,7 +80,7 @@ namespace Muon { void cleanUp() const; /** analyse hits */ - const MuonPatternCombinationCollection* analyse( const MuonHoughHitContainer& hitcontainer ) const; + MuonPatternCombinationCollection* analyse( const MuonHoughHitContainer& hitcontainer ) const; private: diff --git a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonLayerHoughTool.h b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonLayerHoughTool.h index 137373d9c9c2b595cdaaf12b0bc787c222bb12f3..2eeeb29b503e6eb832df6ae05375668345a5363f 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonLayerHoughTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonLayerHoughTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONHOUGHPATTERNTOOLS_MUONLAYERHOUGHTOOL_H @@ -165,11 +165,11 @@ namespace Muon { const MMPrepDataContainer* mmCont ) const; /** find patterns for a give set of MuonPrepData collections + optionally CSC segment combinations */ - const MuonPatternCombinationCollection* find( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols, - const MuonSegmentCombinationCollection* ) const; + MuonPatternCombinationCollection* find( const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + const MuonSegmentCombinationCollection* ) const; void reset() const; void getSectors( const Amg::Vector3D& pos, std::vector<int>& sectors ) const; diff --git a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonHoughPatternFinderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonHoughPatternFinderTool.cxx index aaacc02e6c3a62dc932bcb0807cc8b85530e7f63..982b08c53923a0dd57f50cb44bd365ee04b2838a 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonHoughPatternFinderTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonHoughPatternFinderTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonHoughPatternTools/MuonHoughPatternFinderTool.h" @@ -157,16 +157,16 @@ namespace Muon { return StatusCode::SUCCESS; } - const MuonPatternCombinationCollection* MuonHoughPatternFinderTool::find( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols, - const MuonSegmentCombinationCollection* cscSegmentCombis ) const { + MuonPatternCombinationCollection* MuonHoughPatternFinderTool::find( const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + const MuonSegmentCombinationCollection* cscSegmentCombis ) const { // read event_data: const MuonHoughHitContainer* hitcontainer = getAllHits( mdtCols, cscCols, tgcCols, rpcCols, cscSegmentCombis ); // analyse data - const MuonPatternCombinationCollection* patCombiCol = 0; + MuonPatternCombinationCollection* patCombiCol = 0; if( hitcontainer ) { patCombiCol = analyse( *hitcontainer ); }else{ @@ -229,7 +229,7 @@ namespace Muon { return StatusCode::SUCCESS; } - const MuonPatternCombinationCollection* MuonHoughPatternFinderTool::analyse( const MuonHoughHitContainer& hitcontainer ) const { + MuonPatternCombinationCollection* MuonHoughPatternFinderTool::analyse( const MuonHoughHitContainer& hitcontainer ) const { ATH_MSG_DEBUG ("size of event: " << hitcontainer.size()); @@ -251,7 +251,7 @@ namespace Muon { const MuonPrdPatternCollection* combinedpatterns = 0; - const MuonPatternCombinationCollection* patterncombinations = 0; + MuonPatternCombinationCollection* patterncombinations = 0; // make + write muonpatterncombinations if ( !etapatterns->empty() ) { @@ -318,14 +318,14 @@ namespace Muon { ATH_MSG_VERBOSE ("CSC combo segments loop, segmentcombo " << (*msc)); for (unsigned int ss=0; ss<(*msc)->numberOfStations(); ss++) { - const Muon::MuonSegmentCombination::SegmentVec* segmentsInCombo = (*msc)->stationSegments(ss); + Muon::MuonSegmentCombination::SegmentVec* segmentsInCombo = (*msc)->stationSegments(ss); - Muon::MuonSegmentCombination::SegmentVec::const_iterator ms = segmentsInCombo->begin(); - Muon::MuonSegmentCombination::SegmentVec::const_iterator ms_end = segmentsInCombo->end(); + Muon::MuonSegmentCombination::SegmentVec::iterator ms = segmentsInCombo->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator ms_end = segmentsInCombo->end(); for (; ms != ms_end; ++ms) { - ATH_MSG_VERBOSE ("CSC segments loop, segment: " << (*ms)); + ATH_MSG_VERBOSE ("CSC segments loop, segment: " << (*ms).get()); std::set<const Trk::PrepRawData*,Muon::IdentifierPrdLess> phi_set; std::vector<const Trk::PrepRawData*> eta_vector; std::pair<std::set<const Trk::PrepRawData*,Muon::IdentifierPrdLess>::iterator,bool> phi_pair; diff --git a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonLayerHoughTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonLayerHoughTool.cxx index c8cbaaaec1fd3489eaa755bf9159b8044774a61e..7b343ec98af23b969b5827158b5b02e505e5cea8 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonLayerHoughTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonLayerHoughTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonHoughPatternTools/MuonLayerHoughTool.h" @@ -254,11 +254,11 @@ namespace Muon { } - const MuonPatternCombinationCollection* MuonLayerHoughTool::find( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& , - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols, - const MuonSegmentCombinationCollection* ) const { + MuonPatternCombinationCollection* MuonLayerHoughTool::find( const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& , + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + const MuonSegmentCombinationCollection* ) const { reset(); ATH_MSG_DEBUG("MuonLayerHoughTool::find"); @@ -322,7 +322,6 @@ namespace Muon { return analyse(); } - // Still used? MuonPatternCombinationCollection* MuonLayerHoughTool::analyse( const MdtPrepDataContainer* mdtCont, const CscPrepDataContainer* cscCont, const TgcPrepDataContainer* tgcCont, diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegmentCombination.h b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegmentCombination.h index 83bd5cd0613439fb9cf3696d49a5a3184f4cbb34..c8b1500306d8e8fb11437c5f82575e4699284b5e 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegmentCombination.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegmentCombination.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -13,12 +13,9 @@ namespace Trk { class Segment; } -namespace Muon { - class MuonSegment; -} - #include <vector> - +#include <memory> +#include "MuonSegment/MuonSegment.h" namespace Muon { @@ -32,8 +29,8 @@ namespace Muon { */ class MuonSegmentCombination { public: - typedef std::vector< const MuonSegment* > SegmentVec; - typedef std::vector< SegmentVec* > SegmentVecVec; + typedef std::vector< std::unique_ptr<MuonSegment> > SegmentVec; + typedef std::vector< std::unique_ptr<SegmentVec> > SegmentVecVec; public: /** Default constructor */ MuonSegmentCombination(); @@ -53,13 +50,13 @@ namespace Muon { whether there are already segments for the given station. This is up to the user. */ - bool addSegments( SegmentVec* ); + bool addSegments( std::unique_ptr<SegmentVec> ); /** Number of stations with segment */ unsigned int numberOfStations() const; /** Access to segments in a given station */ - const SegmentVec* stationSegments( unsigned int index ) const; + SegmentVec* stationSegments( unsigned int index ) const; /** Number of ambiguities */ unsigned int numberOfAmbiguities() const; @@ -102,9 +99,9 @@ namespace Muon { return m_nGood[isEta]; } - inline bool MuonSegmentCombination::addSegments( SegmentVec* segs ) + inline bool MuonSegmentCombination::addSegments( std::unique_ptr<SegmentVec> segs ) { - m_segmentsPerStation.push_back( segs ); + m_segmentsPerStation.push_back( std::move(segs) ); return true; } @@ -113,10 +110,10 @@ namespace Muon { return m_segmentsPerStation.size(); } - inline const MuonSegmentCombination::SegmentVec* + inline MuonSegmentCombination::SegmentVec* MuonSegmentCombination::stationSegments( unsigned int index ) const { - if( index < numberOfStations() ) return m_segmentsPerStation[index]; + if( index < numberOfStations() ) return m_segmentsPerStation[index].get(); return 0; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/src/MuonSegmentCombination.cxx b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/src/MuonSegmentCombination.cxx index de108643f31c09ebbedd4080f59cddb8b773d63c..27e25bf5c6222ab08f1ab4317e14cb8ae33b0c03 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/src/MuonSegmentCombination.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/src/MuonSegmentCombination.cxx @@ -1,9 +1,8 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonSegment/MuonSegmentCombination.h" -#include "MuonSegment/MuonSegment.h" #include "TrkSegment/Segment.h" namespace Muon { @@ -40,9 +39,9 @@ namespace Muon { for( unsigned int i=0;i<nst;++i ){ SegmentVec::const_iterator vit = segc.stationSegments( i )->begin(); SegmentVec::const_iterator vit_end = segc.stationSegments( i )->end(); - SegmentVec* newsegs = new SegmentVec(); - for( ; vit!=vit_end; ++vit ) newsegs->push_back( (*vit)->clone() ); - m_segmentsPerStation.push_back(newsegs); + std::unique_ptr<SegmentVec> newsegs(new SegmentVec()); + for( ; vit!=vit_end; ++vit ) newsegs->push_back( std::unique_ptr<MuonSegment>((*vit)->clone()) ); + m_segmentsPerStation.push_back(std::move(newsegs)); } } @@ -54,8 +53,9 @@ namespace Muon { for( ; it!=it_end; ++it ){ SegmentVec::iterator vit = (*it)->begin(); SegmentVec::iterator vit_end = (*it)->end(); - for( ; vit!=vit_end; ++vit ) delete *vit; - delete *it; + for( ; vit!=vit_end; ++vit ) (*vit).reset(); + (*it)->clear(); + (*it).reset(); } m_segmentsPerStation.clear(); } diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonStandalone.py b/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonStandalone.py index c5e7150d61e8d31c14a86b600d228e68b43be7ab..5112d2624c7226a4a8658d32879305e405d01652 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonStandalone.py +++ b/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonStandalone.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration __doc__ = """Configuration of Muon Spectrometer Standalone muon reconstruction""" @@ -136,7 +136,6 @@ class MuonStandalone(ConfiguredMuonRec): DoMdtSegments=False,DoSegmentCombinations=False,DoSegmentCombinationCleaning=False), MuonPatternCombinationLocation = "NCB_MuonHoughPatternCombinations", MuonSegmentOutputLocation = "NCB_MuonSegments", - MuonSegmentCombinationOutputLocation = "NCB_MooreSegmentCombinations", UseCSC = muonRecFlags.doCSCs(), UseMDT = False, UseRPC = False, diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/MuonRecHelperTools/MuonEDMPrinterTool.h b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/MuonRecHelperTools/MuonEDMPrinterTool.h index a800c1a8a127ce5bbc1cd12842c8d93105f9c97e..07da18199dc9ceb8b9f1866b69786512698181a4 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/MuonRecHelperTools/MuonEDMPrinterTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/MuonRecHelperTools/MuonEDMPrinterTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONRECHELPERTOOLS_H @@ -84,6 +84,7 @@ namespace Muon{ /** @brief print vector of segments */ std::string print( const std::vector< const MuonSegment* >& segs ) const; + std::string print( std::vector< std::unique_ptr<MuonSegment> >& segs ) const; /** @brief print Muon MeasurementBase to string */ std::string print( const Trk::MeasurementBase& measurement ) const; diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/src/MuonEDMPrinterTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/src/MuonEDMPrinterTool.cxx index e22e820fa562312364da819e83af5852925909dc..0cc7571ac5e0d42cc28d7342b96e7d8c56da008e 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/src/MuonEDMPrinterTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/src/MuonEDMPrinterTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonRecHelperTools/MuonEDMPrinterTool.h" @@ -497,6 +497,25 @@ namespace Muon { return sout.str(); } + std::string MuonEDMPrinterTool::print( std::vector< std::unique_ptr< MuonSegment> >& segs ) const { + + std::ostringstream sout; + + std::vector< std::unique_ptr<MuonSegment> >::iterator it = segs.begin(); + std::vector< std::unique_ptr<MuonSegment> >::iterator it_end = segs.end(); + std::vector< std::unique_ptr<MuonSegment> >::iterator it_last = it_end; --it_last; + for( ;it!=it_end;++it ){ + if(!*it) { + sout << " WARNING, zero pointer detected in MuonSegment vector!!! " << std::endl; + continue; + } + sout << print(**it); + if( it != it_last ) sout << std::endl; + } + + return sout.str(); + } + std::string MuonEDMPrinterTool::print( const MuonSegmentCombinationCollection& combiCol ) const { std::ostringstream sout; @@ -525,7 +544,7 @@ namespace Muon { for(unsigned int i=0; i<nstations; ++i){ // loop over segments in station - const MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; + MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; // check if not empty if( !stationSegs || stationSegs->empty() ) continue; diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/CMakeLists.txt b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/CMakeLists.txt index a52ed19f71ff16560f136b360c08b188cfbb88d7..b7b63bf22183e6748c4e3bcf3a8d5db435ce910a 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/CMakeLists.txt +++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/CMakeLists.txt @@ -30,6 +30,7 @@ atlas_depends_on_subdirs( PUBLIC Tracking/TrkEvent/TrkPrepRawData Tracking/TrkEvent/TrkTrack Tracking/TrkEvent/TrkTruthData + Tracking/TrkEvent/TrkSegment Tracking/TrkTools/TrkCompetingRIOsOnTrackTool Tracking/TrkTools/TrkToolInterfaces Tracking/TrkUtilityPackages/TrkDriftCircleMath ) diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonCombinePatternTool.h b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonCombinePatternTool.h index f3357cf791ae6b8f72b8e1a51279de73acf8becf..c789c95105935883c2816b3d5d4337b7b85bbfeb 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonCombinePatternTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonCombinePatternTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "GaudiKernel/IAlgTool.h" @@ -39,7 +39,7 @@ namespace Muon { virtual void setPhiEtaHitAssMap(std::map <const Trk::PrepRawData*, std::set<const Trk::PrepRawData*,IdentifierPrdLess> >*)=0; /** @brief create a collection of Muon::MuonPatternCombination from a collection of Muon::MuonPrdPattern objects */ - virtual const MuonPatternCombinationCollection* makePatternCombinations(const MuonPrdPatternCollection* combinedpatterns)const=0; + virtual MuonPatternCombinationCollection* makePatternCombinations(const MuonPrdPatternCollection* combinedpatterns)const=0; }; inline const InterfaceID& IMuonCombinePatternTool::interfaceID() diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonHoughPatternFinderTool.h b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonHoughPatternFinderTool.h index fa6292c485fbb4623837f65ffabc232c09347454..19f7b023ac504c9ca1bd46842683bf6cd10385e8 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonHoughPatternFinderTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonHoughPatternFinderTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_IMUONHOUGHPATTERNFINDERTOOL_H @@ -33,11 +33,11 @@ namespace Muon { static const InterfaceID& interfaceID(); /** find patterns for a give set of MuonPrepData collections + optionally CSC segment combinations */ - virtual const MuonPatternCombinationCollection* find( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols, - const MuonSegmentCombinationCollection* cscSegmentCombis ) const = 0; + virtual MuonPatternCombinationCollection* find( const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + const MuonSegmentCombinationCollection* cscSegmentCombis ) const = 0; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonSeededSegmentFinder.h b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonSeededSegmentFinder.h index 61d4ddebe52974919bee4e69ceb4e2afd6c9d6da..a2aa5edbbd22433a46714e43247098ae0e17e1e9 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonSeededSegmentFinder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonSeededSegmentFinder.h @@ -9,7 +9,7 @@ #include "TrkParameters/TrackParameters.h" #include "Identifier/Identifier.h" #include "Identifier/IdentifierHash.h" - +#include "TrkSegment/SegmentCollection.h" #include "MuonPrepRawData/MuonPrepDataContainer.h" #include "MuonPrepRawData/MdtPrepDataCollection.h" #include "MuonPrepRawData/RpcPrepDataCollection.h" @@ -38,13 +38,13 @@ public: static const InterfaceID& interfaceID(); /** @brief find segments in a set of chambers starting from seeding TrackParameters */ - virtual std::vector<const MuonSegment*>* find( const Trk::TrackParameters& pars, const std::set<Identifier>& chIds ) const = 0; + virtual std::unique_ptr<Trk::SegmentCollection> find( const Trk::TrackParameters& pars, const std::set<Identifier>& chIds ) const = 0; /** @brief find segments in a set of chambers starting from seeding TrackParameters (version with Hashes) */ - virtual std::vector<const MuonSegment*>* find( const Trk::TrackParameters& pars, const std::set<IdentifierHash>& chIdHs ) const = 0; + virtual std::unique_ptr<Trk::SegmentCollection> find( const Trk::TrackParameters& pars, const std::set<IdentifierHash>& chIdHs ) const = 0; /** @brief find segments in a set of MdtPrepData starting from seeding TrackParameters */ - virtual std::vector<const MuonSegment*>* find( const Trk::TrackParameters& pars, const std::vector<const MdtPrepData*>& mdtPrds ) const = 0; + virtual std::unique_ptr<Trk::SegmentCollection> find( const Trk::TrackParameters& pars, const std::vector<const MdtPrepData*>& mdtPrds ) const = 0; /** @brief retrieve MDT PRD collections for the given hashes */ diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonSegmentMaker.h b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonSegmentMaker.h index bfdd6a7b5d6c16caf19a3cc5728136cabb46c3bf..929a20c542a43e7c714ad84e699df852c46314d2 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonSegmentMaker.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonSegmentMaker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_IMUONSEGMENTMAKER_H @@ -8,6 +8,7 @@ #include <vector> #include "GaudiKernel/IAlgTool.h" #include "GeoPrimitives/GeoPrimitives.h" +#include "TrkSegment/SegmentCollection.h" static const InterfaceID IID_IMuonSegmentMaker ("Muon::IMuonSegmentMaker",1,0); @@ -73,28 +74,28 @@ namespace Muon { /** @brief find segments starting from a list of Trk::RIO_OnTrack objects @param rios a vector of Trk::RIO_OnTrack objects - @return a pointer to a vector of Muon::MuonSegment objects, zero if no segments found. - The ownership of the segments is passed to the client calling the tool. + @param segColl a Trk::SegmentCollection to store the segments + The ownership of the segments is passed to the SegmentCollection */ - virtual std::vector<const MuonSegment*>* find( const std::vector<const Trk::RIO_OnTrack*>& rios ) const =0; + virtual void find( const std::vector<const Trk::RIO_OnTrack*>& rios, Trk::SegmentCollection* segColl=nullptr ) const =0; /** @brief find segments starting from two lists of Trk::RIO_OnTrack objects in two neighbouring chambers @param rios1 a vector of Trk::RIO_OnTrack objects in the first chamber @param rios2 a vector of Trk::RIO_OnTrack objects in the second chamber - @return a pointer to a vector of Muon::MuonSegment objects, zero if no segments found. - The ownership of the segments is passed to the client calling the tool. + Note: this interface is deprecated! */ - virtual std::vector<const MuonSegment*>* find( const std::vector<const Trk::RIO_OnTrack*>& rios1, - const std::vector<const Trk::RIO_OnTrack*>& rios2 ) const =0; + virtual void find( const std::vector<const Trk::RIO_OnTrack*>& rios1, + const std::vector<const Trk::RIO_OnTrack*>& rios2 ) const =0; /** @brief find segments starting from a list of MdtDriftCircleOnTrack objects and a list of MuonClusterOnTrack objects @param mdts a vector of Muon::MdtDriftCircleOnTrack obejcts @param clusters a vector of Muon::MuonClusterOnTrack obejcts - @return a pointer to a vector of Muon::MuonSegment objects, zero if no segments found. - The ownership of the segments is passed to the client calling the tool. + @param segColl a Trk::SegmentCollection to store the segments + The ownership of the segments is passed to the SegmentCollection */ - virtual std::vector<const MuonSegment*>* find( const std::vector<const MdtDriftCircleOnTrack*>& mdts, - const std::vector<const MuonClusterOnTrack*>& clusters) const =0; + virtual void find( const std::vector<const MdtDriftCircleOnTrack*>& mdts, + const std::vector<const MuonClusterOnTrack*>& clusters, + Trk::SegmentCollection* segColl=nullptr) const =0; /** @brief seeded segment search starting from a list of MdtDriftCircleOnTrack objects and a list of MuonClusterOnTrack objects @@ -106,15 +107,14 @@ namespace Muon { @f$ \phi @f$-direction of the segment @param momentum for low momentum tracks the segment finders may increase the errors on the measurements to allow for multiple scattering - - @return a pointer to a vector of Muon::MuonSegment objects, zero if no segments found. - The ownership of the segments is passed to the client calling the tool. + @param segColl a Trk::SegmentCollection to store the segments + The ownership of the segments is passed to the SegmentCollection */ - virtual std::vector<const MuonSegment*>* find( const Amg::Vector3D& gpos, const Amg::Vector3D& gdir, - const std::vector<const MdtDriftCircleOnTrack*>& mdts, - const std::vector<const MuonClusterOnTrack*>& clusters, - bool updatePhi=false, double momentum = 1e9 ) const =0; + virtual void find( const Amg::Vector3D& gpos, const Amg::Vector3D& gdir, + const std::vector<const MdtDriftCircleOnTrack*>& mdts, + const std::vector<const MuonClusterOnTrack*>& clusters, + bool updatePhi=false, Trk::SegmentCollection* segColl=nullptr, double momentum = 1e9, double sinAngleCut=0. ) const =0; /** @brief seeded segment search starting from a list of MdtDriftCircleOnTrack objects and a list of MuonClusterOnTrack objects @param road an estimate of the position and direction of the muon in the chamber @@ -122,16 +122,18 @@ namespace Muon { @param clusters a vector of Muon::MuonClusterOnTrack obejcts @param updatePhi a boolean to indicate whether the external prediction should be used to set the @f$ \phi @f$-direction of the segment + @param segColl: if a Trk::SegmentCollection is passed (should be the case if segments will go into SG), store the segments in here directly @param momentum for low momentum tracks the segment finders may increase the errors on the measurements - to allow for multiple scattering + to allow for multiple scattering - @return a pointer to a vector of Muon::MuonSegment objects, zero if no segments found. - The ownership of the segments is passed to the client calling the tool. + @param segColl a Trk::SegmentCollection to store the segments + The ownership of the segments is passed to the SegmentCollection */ - virtual std::vector<const MuonSegment*>* find( const Trk::TrackRoad& road, - const std::vector< std::vector< const MdtDriftCircleOnTrack* > >& mdts, - const std::vector< std::vector< const MuonClusterOnTrack* > >& clusters, - bool updatePhi=false, double momentum = 1e9 ) const =0; + virtual void find( const Trk::TrackRoad& road, + const std::vector< std::vector< const MdtDriftCircleOnTrack* > >& mdts, + const std::vector< std::vector< const MuonClusterOnTrack* > >& clusters, + Trk::SegmentCollection* segColl, + bool updatePhi=false, double momentum = 1e9 ) const =0; }; inline const InterfaceID& IMuonSegmentMaker::interfaceID() diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.cxx index fdd892b8396832fba4647c8b58718efa554e2429..fd52784056e1330053ff5243e020c586ea9cca53 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -13,7 +13,6 @@ #include "MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h" #include "MuonSegmentCombinerToolInterfaces/IMuonSegmentCombinationCleanerTool.h" #include "MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h" -#include "MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h" #include "MuonSegmentMakerToolInterfaces/IMuonSegmentSelectionTool.h" #include "MuonRecHelperTools/MuonEDMPrinterTool.h" #include "MuonRecHelperTools/MuonEDMHelperTool.h" @@ -55,7 +54,6 @@ Muon::MooSegmentCombinationFinder::MooSegmentCombinationFinder(const std::string m_patternSegmentMaker("Muon::MuonPatternSegmentMaker/MuonPatternSegmentMaker"), m_curvedSegmentCombiner("Muon::MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner"), m_segmentCombinationCleaner("Muon::MuonSegmentCombinationCleanerTool/MuonSegmentCombinationCleanerTool"), - m_overlapRemovalTool("Muon::MuonSegmentOverlapRemovalTool/MuonSegmentOverlapRemovalTool"), m_segmentSelector("Muon::MuonSegmentSelectionTool/MuonSegmentSelectionTool"), m_nevents(0), m_ncsc2SegmentCombinations(0), @@ -67,7 +65,6 @@ Muon::MooSegmentCombinationFinder::MooSegmentCombinationFinder(const std::string m_nsegments(0), m_nsegmentsStraight(0), m_nsegmentsCurved(0), - m_nremovedSegments(0), m_nremovedBadSegments(0) { @@ -81,12 +78,11 @@ Muon::MooSegmentCombinationFinder::MooSegmentCombinationFinder(const std::string declareProperty("MdtSegmentMaker", m_patternSegmentMaker); declareProperty("SegmentCombiner", m_curvedSegmentCombiner); declareProperty("SegmentCombinationCleaner", m_segmentCombinationCleaner); - declareProperty("SegmentOverlapRemovalTool", m_overlapRemovalTool, "tool to removal overlaps in segment combinations" ); declareProperty("DoCscSegments", m_doCscSegments = true ); declareProperty("DoMdtSegments", m_doMdtSegments = true ); - declareProperty("DoSegmentCombinations", m_doSegmentCombinations = true ); - declareProperty("DoSegmentCombinationCleaning", m_doSegmentCombinationCleaning = true ); + declareProperty("DoSegmentCombinations", m_doSegmentCombinations = false ); + declareProperty("DoSegmentCombinationCleaning", m_doSegmentCombinationCleaning = false ); declareProperty("CloneSegments", m_cloneSegments = false ); } @@ -121,12 +117,10 @@ Muon::MooSegmentCombinationFinder::initialize() if( m_doMdtSegments ){ ATH_CHECK( m_houghPatternFinder.retrieve() ); ATH_CHECK( m_patternSegmentMaker.retrieve() ); - ATH_CHECK( m_overlapRemovalTool.retrieve() ); } else{ m_houghPatternFinder.disable(); m_patternSegmentMaker.disable(); - m_overlapRemovalTool.disable(); } ATH_CHECK( m_segmentSelector.retrieve() ); @@ -167,7 +161,6 @@ Muon::MooSegmentCombinationFinder::finalize() << " Segments: " << std::setw(12) << m_nsegments << " per event " << m_nsegments/nevents << std::endl << " straight: " << std::setw(12) << m_nsegmentsStraight << " per event " << m_nsegmentsStraight/nevents << std::endl << " curved: " << std::setw(12) << m_nsegmentsCurved << " per event " << m_nsegmentsCurved/nevents << std::endl - << " Discarded overlap segments: " << std::setw(12) << m_nremovedSegments << " per event " << m_nremovedSegments/nevents << std::endl << " Discarded bad segments: " << std::setw(12) << m_nremovedBadSegments << " per event " << m_nremovedBadSegments/nevents); return StatusCode::SUCCESS; @@ -188,11 +181,11 @@ void Muon::MooSegmentCombinationFinder::auditorAfter( IAlgTool* /*tool*/, bool / } -Muon::IMooSegmentCombinationFinder::Output* -Muon::MooSegmentCombinationFinder::findSegments( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols ) +void Muon::MooSegmentCombinationFinder::findSegments( const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + Muon::IMooSegmentCombinationFinder::Output& output) { // Super tool has various different stages. // 1. 2d Csc segment making, which produces MuonSegmentCombinations that are passed to the 4D segment maker, and the MuonCurvedSegmentCombiner @@ -201,76 +194,62 @@ Muon::MooSegmentCombinationFinder::findSegments( const std::vector<const MdtPrep // 4. MuonPatternSegmentMaker, which takes in the remaining PRD types, and outputs MuonSegmentCombinations and seg-pattern associations. // 5. MuonCurvedSegmentCombiner, which produces a MuonSegmentCombination // 6. MuonSegmentCombinationCleaner - - // 1. 2s Csc Segment Making - MuonSegmentCombinationCollection* finalSegmentCombinations = 0; - Trk::SegmentCollection* finalSegmentCollection = 0; + // 1. 2s Csc Segment Making - MuonSegmentCombinationCollection* csc2dSegmentCombinations = 0; - MuonSegmentCombinationCollection* csc4dSegmentCombinations = 0; + std::unique_ptr<MuonSegmentCombinationCollection> csc2dSegmentCombinations(new MuonSegmentCombinationCollection); + std::unique_ptr<MuonSegmentCombinationCollection> csc4dSegmentCombinations(new MuonSegmentCombinationCollection); if( m_doCscSegments ){ // reconstruct segments in the CSC eta and phi plane auditorBefore( m_csc2dSegmentFinder ); csc2dSegmentCombinations = m_csc2dSegmentFinder->find( cscCols ); - auditorAfter( m_csc2dSegmentFinder, csc2dSegmentCombinations ); - printSummary( "CSC 2D segment finding", csc2dSegmentCombinations ); + auditorAfter( m_csc2dSegmentFinder, csc2dSegmentCombinations.get() ); + printSummary( "CSC 2D segment finding", csc2dSegmentCombinations.get() ); // combine CSC segments in eta and phi plane if any were found if (csc2dSegmentCombinations) { auditorBefore( m_csc4dSegmentFinder ); csc4dSegmentCombinations = m_csc4dSegmentFinder->find( *csc2dSegmentCombinations ); - auditorAfter( m_csc4dSegmentFinder, csc4dSegmentCombinations ); - printSummary( "CSC 4D segment finding", csc4dSegmentCombinations ); - } else { - csc4dSegmentCombinations = 0; + auditorAfter( m_csc4dSegmentFinder, csc4dSegmentCombinations.get() ); + printSummary( "CSC 4D segment finding", csc4dSegmentCombinations.get() ); } if( csc4dSegmentCombinations ){ - if( !finalSegmentCollection ) finalSegmentCollection = new Trk::SegmentCollection(); - extractSegmentCollection( *csc4dSegmentCombinations, *finalSegmentCollection ); + extractSegmentCollection( csc4dSegmentCombinations.get(), *(output.segmentCollection) ); } - finalSegmentCombinations = csc4dSegmentCombinations; - } - const MuonPatternCombinationCollection* patternCombinations = 0; - MuonSegmentCombinationCollection* mdtSegmentCombinations = 0; + std::unique_ptr<MuonSegmentCombinationCollection> mdtSegmentCombinations(new MuonSegmentCombinationCollection); if( m_doMdtSegments ){ // search for global patterns auditorBefore( m_houghPatternFinder ); - patternCombinations = m_houghPatternFinder->find( mdtCols, cscCols, tgcCols, rpcCols, csc4dSegmentCombinations ); - auditorAfter( m_houghPatternFinder, patternCombinations ); - printSummary( "Pattern finding", patternCombinations ); + output.patternCombinations = m_houghPatternFinder->find( mdtCols, cscCols, tgcCols, rpcCols, csc4dSegmentCombinations.get() ); + auditorAfter( m_houghPatternFinder, output.patternCombinations ); + printSummary( "Pattern finding", output.patternCombinations ); // search for MDT segments - if (patternCombinations) { + if (output.patternCombinations) { auditorBefore( m_patternSegmentMaker ); - mdtSegmentCombinations = m_patternSegmentMaker->find( *patternCombinations, &m_segmentPatternMap ); - auditorAfter( m_patternSegmentMaker, mdtSegmentCombinations ); - if( msgLvl(MSG::DEBUG) ) printSummary( "MDT segment finding", mdtSegmentCombinations ); - } else { - mdtSegmentCombinations = 0; + mdtSegmentCombinations = m_patternSegmentMaker->find( output.patternCombinations, &m_segmentPatternMap, rpcCols, tgcCols); + auditorAfter( m_patternSegmentMaker, mdtSegmentCombinations.get() ); + if( msgLvl(MSG::DEBUG) ) printSummary( "MDT segment finding", mdtSegmentCombinations.get() ); } - finalSegmentCombinations = mdtSegmentCombinations; - if( mdtSegmentCombinations ){ - if( !finalSegmentCollection ) finalSegmentCollection = new Trk::SegmentCollection(); - extractSegmentCollection( *mdtSegmentCombinations, *finalSegmentCollection ); + extractSegmentCollection( mdtSegmentCombinations.get(), *(output.segmentCollection) ); } - printSummary( "MDT segment finding", finalSegmentCollection ); + printSummary( "MDT segment finding", output.segmentCollection ); } - MuonSegmentCombinationCollection* curvedSegmentCombinations = 0; - MuonSegmentCombinationCollection* cleanedSegmentCombinations = 0; + std::unique_ptr<MuonSegmentCombinationCollection> curvedSegmentCombinations; + std::unique_ptr<MuonSegmentCombinationCollection> cleanedSegmentCombinations; if( m_doSegmentCombinations ){ // create dummy collections if CSCs are missing - if( !csc2dSegmentCombinations ) csc2dSegmentCombinations = new MuonSegmentCombinationCollection(); - if( !csc4dSegmentCombinations ) csc4dSegmentCombinations = new MuonSegmentCombinationCollection(); + if( !csc2dSegmentCombinations ) csc2dSegmentCombinations = std::unique_ptr<MuonSegmentCombinationCollection>(new MuonSegmentCombinationCollection); + if( !csc4dSegmentCombinations ) csc4dSegmentCombinations = std::unique_ptr<MuonSegmentCombinationCollection>(new MuonSegmentCombinationCollection); // combine MDT and CSC segments if ( mdtSegmentCombinations ) { @@ -279,71 +258,69 @@ Muon::MooSegmentCombinationFinder::findSegments( const std::vector<const MdtPrep *csc4dSegmentCombinations, *csc2dSegmentCombinations, &m_segmentPatternMap); - auditorAfter( m_curvedSegmentCombiner, curvedSegmentCombinations ); - if( msgLvl(MSG::DEBUG) ) printSummary( "Segment combining", curvedSegmentCombinations ); + auditorAfter( m_curvedSegmentCombiner, curvedSegmentCombinations.get() ); + if( msgLvl(MSG::DEBUG) ) printSummary( "Segment combining", curvedSegmentCombinations.get() ); - } else { - curvedSegmentCombinations = 0; } - finalSegmentCombinations = curvedSegmentCombinations; } if( m_doSegmentCombinationCleaning ){ // clean segment combinations - if ( finalSegmentCombinations ) { + MuonSegmentCombinationCollection* finalComb=curvedSegmentCombinations.get(); + if(!finalComb) finalComb=mdtSegmentCombinations.get(); + if(!finalComb) finalComb=csc4dSegmentCombinations.get(); + if(finalComb){ auditorBefore( m_segmentCombinationCleaner ); - cleanedSegmentCombinations = m_segmentCombinationCleaner->clean(*finalSegmentCombinations, &m_segmentPatternMap); - auditorAfter( m_segmentCombinationCleaner, cleanedSegmentCombinations ); - printSummary( "Segment combination cleaning", cleanedSegmentCombinations ); + cleanedSegmentCombinations = m_segmentCombinationCleaner->clean(*finalComb, &m_segmentPatternMap); + auditorAfter( m_segmentCombinationCleaner, cleanedSegmentCombinations.get() ); + printSummary( "Segment combination cleaning", cleanedSegmentCombinations.get() ); - } else { - cleanedSegmentCombinations = 0; } - finalSegmentCombinations = cleanedSegmentCombinations; + } + + if( m_doSummary || msgLvl(MSG::DEBUG) ) msg() << endmsg; // increase counters, assume that the tools is only called once per event ++m_nevents; if( csc2dSegmentCombinations ) m_ncsc2SegmentCombinations += csc2dSegmentCombinations->size(); if( csc4dSegmentCombinations ) m_ncsc4SegmentCombinations += csc4dSegmentCombinations->size(); - if( patternCombinations ) m_npatternCombinations += patternCombinations->size(); + if( output.patternCombinations ) m_npatternCombinations += output.patternCombinations->size(); if( mdtSegmentCombinations ) m_nmdtSegmentCombinations += mdtSegmentCombinations->size(); if( curvedSegmentCombinations ) m_ncombinedSegmentCombinations += curvedSegmentCombinations->size(); - if( finalSegmentCollection ){ - m_nsegments += finalSegmentCollection->size(); - Trk::SegmentCollection::const_iterator sit = finalSegmentCollection->begin(); - Trk::SegmentCollection::const_iterator sit_end = finalSegmentCollection->end(); + if( output.segmentCollection->size() ){ + m_nsegments += output.segmentCollection->size(); + Trk::SegmentCollection::const_iterator sit = output.segmentCollection->begin(); + Trk::SegmentCollection::const_iterator sit_end = output.segmentCollection->end(); for( ;sit!=sit_end;++sit ){ if( (*sit)->localParameters().contains(Trk::qOverP) ) ++m_nsegmentsCurved; else ++m_nsegmentsStraight; } } - if( m_doSegmentCombinationCleaning && finalSegmentCombinations ) m_ncleanedSegmentCombinations += finalSegmentCombinations->size(); + if( m_doSegmentCombinationCleaning ) m_ncleanedSegmentCombinations += cleanedSegmentCombinations->size(); // clean up intermediate steps if( csc2dSegmentCombinations ) - postProcess( csc2dSegmentCombinations ); + postProcess( csc2dSegmentCombinations.get() ); - if( csc4dSegmentCombinations && finalSegmentCombinations != csc4dSegmentCombinations ) - postProcess( csc4dSegmentCombinations ); + if( csc4dSegmentCombinations) + postProcess( csc4dSegmentCombinations.get() ); - if( mdtSegmentCombinations && finalSegmentCombinations != mdtSegmentCombinations ) - postProcess( mdtSegmentCombinations ); + if( mdtSegmentCombinations) + postProcess( mdtSegmentCombinations.get() ); - if( curvedSegmentCombinations && finalSegmentCombinations != curvedSegmentCombinations ) - postProcess( curvedSegmentCombinations ); + if( curvedSegmentCombinations) + postProcess( curvedSegmentCombinations.get() ); + + if(cleanedSegmentCombinations) + postProcess(cleanedSegmentCombinations.get()); m_segmentPatternMap.clear(); - Muon::IMooSegmentCombinationFinder::Output* output = new Muon::IMooSegmentCombinationFinder::Output(); - output->patternCombinations = patternCombinations; - output->segmentCollection = finalSegmentCollection; - output->segmentCombinations = finalSegmentCombinations; - return output; - } +} void Muon::MooSegmentCombinationFinder::postProcess( MuonSegmentCombinationCollection* col){ @@ -352,7 +329,6 @@ Muon::MooSegmentCombinationFinder::postProcess( MuonSegmentCombinationCollectio for(; cit!=cit_end;++cit ){ m_segmentPatternMap.erase(*cit); } - delete col; return; } @@ -410,22 +386,20 @@ Muon::MooSegmentCombinationFinder::printSummary( std::string stageTag, const Muo } void -Muon::MooSegmentCombinationFinder::extractSegmentCollection( const MuonSegmentCombinationCollection& combiCol, Trk::SegmentCollection& segmentCol ) const { - +Muon::MooSegmentCombinationFinder::extractSegmentCollection( const MuonSegmentCombinationCollection* combiCol, Trk::SegmentCollection& segmentCol ) const { // store single segments per chamber layer - typedef std::vector<const Muon::MuonSegment*> SegVec; + typedef std::vector<std::unique_ptr<Muon::MuonSegment> > SegVec; //typedef SegVec::iterator SegVecIt; - typedef std::map<Muon::MuonStationIndex::ChIndex, SegVec > RSMap; + typedef std::map<Muon::MuonStationIndex::ChIndex, std::unique_ptr<SegVec> > RSMap; typedef RSMap::iterator RSMapIt; RSMap segMap; - unsigned int nremovedSegments(0); unsigned int nremovedBadSegments(0); unsigned int naccepted(0); - MuonSegmentCombinationCollection::const_iterator cit = combiCol.begin(); - MuonSegmentCombinationCollection::const_iterator cit_end = combiCol.end(); + MuonSegmentCombinationCollection::const_iterator cit = combiCol->begin(); + MuonSegmentCombinationCollection::const_iterator cit_end = combiCol->end(); for(; cit!=cit_end;++cit ){ if( !*cit ) { ATH_MSG_DEBUG(" empty MuonSegmentCombination!!! "); @@ -446,7 +420,7 @@ Muon::MooSegmentCombinationFinder::extractSegmentCollection( const MuonSegmentCo for(unsigned int i=0; i<nstations; ++i){ // loop over segments in station - const Muon::MuonSegmentCombination::SegmentVec* segments = combi.stationSegments( i ) ; + Muon::MuonSegmentCombination::SegmentVec* segments = combi.stationSegments( i ) ; // check if not empty if( !segments || segments->empty() ) continue; @@ -458,41 +432,42 @@ Muon::MooSegmentCombinationFinder::extractSegmentCollection( const MuonSegmentCo // add segments to region segment map, remove ambigueties (missing at the moment) RSMapIt rsit = segMap.find( chIndex ); if( rsit == segMap.end() ){ - SegVec segs; + std::unique_ptr<SegVec> segs(new SegVec); // loop over new segments, copy them into collection - Muon::MuonSegmentCombination::SegmentVec::const_iterator sit = segments->begin(); - Muon::MuonSegmentCombination::SegmentVec::const_iterator sit_end = segments->end(); + Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); for( ; sit!=sit_end;++sit){ + Muon::MuonSegment* seg=(*sit).get(); // remove bad segments - if( !m_segmentSelector->select( **sit, ignoreHoles, quality, useEta, usePhi ) ){ + if( !m_segmentSelector->select( *seg, ignoreHoles, quality, useEta, usePhi ) ){ if( msgLvl(MSG::VERBOSE) ) { - int q = m_segmentSelector->quality(**sit,ignoreHoles,useEta,usePhi); - msg(MSG::VERBOSE) << " bad segment " << m_edmPrinter->print(**sit) << " quality " << q << endmsg; + int q = m_segmentSelector->quality(*seg,ignoreHoles,useEta,usePhi); + msg(MSG::VERBOSE) << " bad segment " << m_edmPrinter->print(*seg) << " quality " << q << endmsg; } ++nremovedBadSegments; continue; } - segs.push_back( *sit ); + segs->push_back( std::move(*sit) ); } - segMap.insert( std::make_pair( chIndex, segs ) ); + segMap.insert( std::make_pair( chIndex, std::move(segs) ) ); }else{ - SegVec& segs = rsit->second; // loop over new segments, copy them into collection - Muon::MuonSegmentCombination::SegmentVec::const_iterator sit = segments->begin(); - Muon::MuonSegmentCombination::SegmentVec::const_iterator sit_end = segments->end(); + Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); for( ; sit!=sit_end;++sit){ + Muon::MuonSegment* seg=(*sit).get(); // remove bad segments - if( !m_segmentSelector->select( **sit, ignoreHoles, quality,useEta,usePhi ) ){ + if( !m_segmentSelector->select( *seg, ignoreHoles, quality,useEta,usePhi ) ){ if( msgLvl(MSG::VERBOSE) ) { - int q = m_segmentSelector->quality(**sit,ignoreHoles,useEta,usePhi); - msg(MSG::VERBOSE) << " bad segment " << m_edmPrinter->print(**sit) << " quality " << q << endmsg; + int q = m_segmentSelector->quality(*seg,ignoreHoles,useEta,usePhi); + msg(MSG::VERBOSE) << " bad segment " << m_edmPrinter->print(*seg) << " quality " << q << endmsg; } ++nremovedBadSegments; continue; } - segs.push_back( *sit ); + rsit->second->push_back( std::move(*sit) ); } } } @@ -502,35 +477,27 @@ Muon::MooSegmentCombinationFinder::extractSegmentCollection( const MuonSegmentCo RSMapIt rsit = segMap.begin(); RSMapIt rsit_end = segMap.end(); for( ;rsit!=rsit_end;++rsit){ - SegVec& segs = rsit->second; - - if( msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << "Working on new chamber layer with " << segs.size() + if( msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << "Working on new chamber layer with " << rsit->second->size() << " segments" << std::endl; - // sort segments according to they number of hits - std::stable_sort( segs.begin(), segs.end(), SortSegmentsByNumberOfHits() ); + // sort segments according to the number of hits + std::stable_sort( rsit->second->begin(), rsit->second->end(), SortSegmentsByNumberOfHits() ); - // remove duplicates - SegVec goodSegments = m_overlapRemovalTool->removeDuplicates(segs); - - // insert remaining segments into segment collection, cast away const as Trk::SegmentCollection contains none const pointers - segmentCol.reserve( segmentCol.size()+goodSegments.size()); - IMuonSegmentOverlapRemovalTool::SegCit sit = goodSegments.begin(); - IMuonSegmentOverlapRemovalTool::SegCit sit_end = goodSegments.end(); + // insert remaining segments into segment collection, cast away const as Trk::SegmentCollection contains non const pointers + naccepted += rsit->second->size(); + segmentCol.reserve( segmentCol.size()+rsit->second->size()); + SegVec::iterator sit = rsit->second->begin(); + SegVec::iterator sit_end = rsit->second->end(); for( ;sit!=sit_end;++sit ) { - segmentCol.push_back( m_cloneSegments ? (*sit)->clone() : new Muon::MuonSegment(**sit) ); + segmentCol.push_back( (*sit).release()); //releasing here, but the segmentCol immediately takes ownership } - nremovedSegments += segs.size() - goodSegments.size(); - naccepted += goodSegments.size(); - } ATH_MSG_DEBUG(" Accepted " << naccepted - << " segments and removed: overlap " << nremovedSegments << " bad " << nremovedBadSegments); - m_nremovedSegments += nremovedSegments; + << " segments and removed " << nremovedBadSegments); m_nremovedBadSegments += nremovedBadSegments; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.h index 0b8f1fecc220d17b2481a574c1f1c361bdb4f1aa..a06ffaf7a9f9dc5bf282a538519e10e902fc17f4 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -37,7 +37,6 @@ namespace Muon class IMuonPatternSegmentMaker; class IMuonCurvedSegmentCombiner; class IMuonSegmentCombinationCleanerTool; - class IMuonSegmentOverlapRemovalTool; class IMuonSegmentSelectionTool; class MuonEDMPrinterTool; class MuonEDMHelperTool; @@ -67,11 +66,11 @@ namespace Muon /** standard Athena-Algorithm method */ virtual StatusCode finalize (); - IMooSegmentCombinationFinder::Output* - findSegments( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols ); + void findSegments(const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + IMooSegmentCombinationFinder::Output& output); private: @@ -85,7 +84,7 @@ namespace Muon void postProcess( MuonSegmentCombinationCollection* col); /** extract a segment collection from a segment combination collection */ - void extractSegmentCollection( const MuonSegmentCombinationCollection& combiCol, Trk::SegmentCollection& segments ) const; + void extractSegmentCollection( const MuonSegmentCombinationCollection* combiCol, Trk::SegmentCollection& segments ) const; /** select segment on quality */ bool goodSegment( const MuonSegment& segment ) const; @@ -103,7 +102,6 @@ namespace Muon void auditorBefore( IAlgTool* tool ); void auditorAfter( IAlgTool* tool, bool status ); - /** class member version of retrieving MsgStream */ bool m_doSummary; //<! print summary after each stage @@ -122,14 +120,13 @@ namespace Muon ToolHandle<IMuonPatternSegmentMaker> m_patternSegmentMaker; ToolHandle<IMuonCurvedSegmentCombiner> m_curvedSegmentCombiner; ToolHandle<IMuonSegmentCombinationCleanerTool> m_segmentCombinationCleaner; - ToolHandle<IMuonSegmentOverlapRemovalTool> m_overlapRemovalTool; ToolHandle<IMuonSegmentSelectionTool> m_segmentSelector; MuonSegmentCombPatternCombAssociationMap m_segmentPatternMap; bool m_cloneSegments; /** counters */ - mutable unsigned int m_nevents; + unsigned int m_nevents; mutable unsigned int m_ncsc2SegmentCombinations; mutable unsigned int m_ncsc4SegmentCombinations; mutable unsigned int m_npatternCombinations; @@ -139,10 +136,10 @@ namespace Muon mutable unsigned int m_nsegments; mutable unsigned int m_nsegmentsStraight; mutable unsigned int m_nsegmentsCurved; - mutable unsigned int m_nremovedSegments; mutable unsigned int m_nremovedBadSegments; - }; + }; + } // end of namespace #endif diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.cxx index 1e5b839a066653f4fe09303ca18164d18e44a8fd..a8b32b9951542a10c439b20528c378d332bbbcf9 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.cxx @@ -1,16 +1,15 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MooSegmentFinderAlg.h" #include "MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h" #include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h" +#include "MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h" #include "MuonSegment/MuonSegment.h" -#include "MuonSegment/MuonSegmentCombination.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonPrepRawData/MuonPrepDataContainer.h" #include "StoreGate/StoreGateSvc.h" @@ -25,9 +24,9 @@ MooSegmentFinderAlg::MooSegmentFinderAlg(const std::string& name, ISvcLocator* p m_keyMdt("MDT_DriftCircles"), m_patternCombiLocation("MuonHoughPatternCombinations"), m_segmentLocation("MooreSegments"), - m_segmentCombiLocation("MooreSegmentCombinations"), m_segmentFinder("Muon::MooSegmentCombinationFinder/MooSegmentCombinationFinder"), - m_clusterSegMaker("Muon::MuonClusterSegmentFinder/MuonClusterSegmentFinder") + m_clusterSegMaker("Muon::MuonClusterSegmentFinder/MuonClusterSegmentFinder"), + m_overlapRemovalTool("Muon::MuonSegmentOverlapRemovalTool/MuonSegmentOverlapRemovalTool") { declareProperty("UseRPC",m_useRpc = true); declareProperty("UseTGC",m_useTgc = true); @@ -49,10 +48,10 @@ MooSegmentFinderAlg::MooSegmentFinderAlg(const std::string& name, ISvcLocator* p declareProperty("MuonPatternCombinationLocation", m_patternCombiLocation); declareProperty("MuonSegmentOutputLocation", m_segmentLocation ); - declareProperty("MuonSegmentCombinationOutputLocation",m_segmentCombiLocation); declareProperty("SegmentFinder", m_segmentFinder ); declareProperty("MuonClusterSegmentFinderTool",m_clusterSegMaker); + declareProperty("SegmentOverlapRemovalTool", m_overlapRemovalTool, "tool to removal overlaps in segment combinations" ); } MooSegmentFinderAlg::~MooSegmentFinderAlg() @@ -64,6 +63,7 @@ StatusCode MooSegmentFinderAlg::initialize() ATH_CHECK( m_segmentFinder.retrieve() ); ATH_CHECK( m_clusterSegMaker.retrieve() ); + ATH_CHECK( m_overlapRemovalTool.retrieve() ); ATH_CHECK( m_keyMdt.initialize(m_useMdt) ); //Nullify key from scheduler if not needed ATH_CHECK( m_keyCsc.initialize(m_useCsc) ); @@ -77,7 +77,6 @@ StatusCode MooSegmentFinderAlg::initialize() ATH_CHECK( m_patternCombiLocation.initialize() ); ATH_CHECK( m_segmentLocation.initialize() ); - ATH_CHECK( m_segmentCombiLocation.initialize() ); return StatusCode::SUCCESS; } @@ -96,12 +95,30 @@ StatusCode MooSegmentFinderAlg::execute() if( m_useTgcNextBC ) retrieveCollections(tgcCols,m_keyTgcNextBC); if( m_useRpc ) retrieveCollections(rpcCols,m_keyRpc); - Muon::IMooSegmentCombinationFinder::Output* output = m_segmentFinder->findSegments( mdtCols, cscCols, tgcCols, rpcCols ); + Muon::IMooSegmentCombinationFinder::Output output; + + SG::WriteHandle<Trk::SegmentCollection> segHandle(m_segmentLocation); + + if (segHandle.record(std::make_unique<Trk::SegmentCollection>()).isSuccess() ){ + ATH_MSG_VERBOSE("stored MuonSegmentCollection at "<<m_segmentLocation.key()); + }else{ + ATH_MSG_ERROR("Failed to store MuonSegmentCollection "); + } + output.segmentCollection=segHandle.ptr(); + + SG::WriteHandle<MuonPatternCombinationCollection> patHandle(m_patternCombiLocation); + + if( patHandle.record(std::make_unique<MuonPatternCombinationCollection>()).isSuccess() ){ + ATH_MSG_VERBOSE("stored MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); + }else{ + ATH_MSG_ERROR("Failed to store MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); + } + output.patternCombinations=patHandle.ptr(); + + m_segmentFinder->findSegments( mdtCols, cscCols, tgcCols, rpcCols, output ); //do cluster based segment finding - std::vector<const Muon::MuonSegment*>* segs(NULL); if (m_doTGCClust || m_doRPCClust){ - SG::ReadHandle<Muon::MdtPrepDataContainer> mdtPrds(m_keyMdt); const PRD_MultiTruthCollection* tgcTruthColl=0; const PRD_MultiTruthCollection* rpcTruthColl=0; if(m_doClusterTruth){ @@ -110,56 +127,11 @@ StatusCode MooSegmentFinderAlg::execute() tgcTruthColl=tgcTruth.cptr(); rpcTruthColl=rpcTruth.cptr(); } - segs = m_clusterSegMaker->getClusterSegments(mdtPrds.cptr(), m_doTGCClust ? &tgcCols : 0, m_doRPCClust ? &rpcCols : 0, tgcTruthColl, rpcTruthColl); - } - MuonSegmentCombinationCollection* segmentCombinations = output ? const_cast<MuonSegmentCombinationCollection*>(output->segmentCombinations) : 0; - if( !segmentCombinations ) segmentCombinations = new MuonSegmentCombinationCollection(); - - - SG::WriteHandle<MuonSegmentCombinationCollection> segCombiHandle(m_segmentCombiLocation); - if( segCombiHandle.record(std::unique_ptr<MuonSegmentCombinationCollection > (segmentCombinations)).isSuccess() ){ - ATH_MSG_VERBOSE("stored MuonSegmentCombinationCollection " << segmentCombinations->size() - << " at " << m_segmentCombiLocation.key()); - }else{ - ATH_MSG_ERROR("Failed to store MuonSegmentCombinationCollection at " << m_segmentCombiLocation.key()); - } - - //FIXME FIX CONST_CASTS LATER - Trk::SegmentCollection* segmentCollection = output ? const_cast<Trk::SegmentCollection*>(output->segmentCollection) : 0; - if( !segmentCollection ) segmentCollection = new Trk::SegmentCollection(); - - //add the cluster segments to the segmentCollection - if (segs){ - for( std::vector<const Muon::MuonSegment*>::iterator sit = segs->begin(); sit!=segs->end();++sit ){ - Muon::MuonSegment* nonConstIt = const_cast<Muon::MuonSegment*>(*sit); - Trk::Segment* trkSeg = nonConstIt; - segmentCollection->push_back(trkSeg); - } - delete segs; - } - - SG::WriteHandle<Trk::SegmentCollection> segHandle(m_segmentLocation); - - if (segHandle.record(std::unique_ptr<Trk::SegmentCollection>(segmentCollection)).isSuccess() ){ - ATH_MSG_VERBOSE("stored MuonSegmentCollection at " << m_segmentLocation.key() - << " size " << segmentCollection->size()); - }else{ - ATH_MSG_ERROR("Failed to store MuonSegmentCollection "); + SG::ReadHandle<Muon::MdtPrepDataContainer> mdth(m_keyMdt); + m_clusterSegMaker->getClusterSegments(mdth.cptr(), m_doTGCClust ? &tgcCols : 0, m_doRPCClust ? &rpcCols : 0, tgcTruthColl, rpcTruthColl, segHandle.ptr()); } - MuonPatternCombinationCollection* patternCombinations = output ? const_cast<MuonPatternCombinationCollection*>(output->patternCombinations) : 0; - if( !patternCombinations ) patternCombinations = new MuonPatternCombinationCollection(); - - SG::WriteHandle<MuonPatternCombinationCollection> patHandle(m_patternCombiLocation); - - if( patHandle.record(std::unique_ptr<MuonPatternCombinationCollection>(patternCombinations)).isSuccess() ){ - ATH_MSG_VERBOSE("stored MuonPatternCombinationCollection " << patternCombinations->size() - << " at " << m_patternCombiLocation.key()); - }else{ - ATH_MSG_ERROR("Failed to store MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); - } - - delete output; + m_overlapRemovalTool->removeDuplicates(segHandle.ptr()); return StatusCode::SUCCESS; } // execute diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.h index 330722a3d8bd2304e18cd399bb83919e19e3f42c..781784d425d570660786ca6e59609b547af34437 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MOOSEGMENTFINDERS_MOOSEGMENTFINDERALGS_H @@ -25,6 +25,7 @@ class StoreGateSvc; namespace Muon { class IMuonClusterSegmentFinder; class IMooSegmentCombinationFinder; + class IMuonSegmentOverlapRemovalTool; } class MooSegmentFinderAlg : public AthAlgorithm @@ -40,7 +41,7 @@ class MooSegmentFinderAlg : public AthAlgorithm private: template<class T, class Y> - void retrieveCollections( std::vector<const T*>& cols, SG::ReadHandleKey<Y>& key ); + void retrieveCollections( std::vector<const T*>& cols, SG::ReadHandleKey<Y>& key ); /** extract segments from a MuonSegmentCombinationCollection */ Trk::SegmentCollection* extractSegmentCollection( const MuonSegmentCombinationCollection& segmentCombinations ) const; @@ -71,15 +72,15 @@ class MooSegmentFinderAlg : public AthAlgorithm SG::WriteHandleKey<MuonPatternCombinationCollection> m_patternCombiLocation; SG::WriteHandleKey<Trk::SegmentCollection> m_segmentLocation; - SG::WriteHandleKey<MuonSegmentCombinationCollection> m_segmentCombiLocation; ToolHandle<Muon::IMooSegmentCombinationFinder> m_segmentFinder; //<! pointer to the segment finder ToolHandle<Muon::IMuonClusterSegmentFinder> m_clusterSegMaker; + ToolHandle<Muon::IMuonSegmentOverlapRemovalTool> m_overlapRemovalTool; }; template <class T, class Y> -void MooSegmentFinderAlg::retrieveCollections( std::vector<const T*>& cols, SG::ReadHandleKey<Y>& key ) { + void MooSegmentFinderAlg::retrieveCollections( std::vector<const T*>& cols, SG::ReadHandleKey<Y>& key ) { SG::ReadHandle<Y> cscPrds (key); if (cscPrds.isValid()==false) { @@ -94,4 +95,5 @@ void MooSegmentFinderAlg::retrieveCollections( std::vector<const T*>& cols, SG:: } + #endif diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx index 9135dd72fc434b1e51844ca286f826d6dc1834b5..64d0d0f7d46fd5f40a31c6d7c2ff652df4b9d52e 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonSegmentFinderAlg.h" @@ -94,9 +94,9 @@ StatusCode MuonSegmentFinderAlg::initialize() ATH_CHECK( m_segmentCollectionKey.initialize() ); ATH_CHECK( m_cscPrdsKey.initialize() ); - ATH_CHECK( m_mdtPrdsKey.initialize(m_doTGCClust || m_doRPCClust) ); - ATH_CHECK( m_rpcPrdsKey.initialize(m_doRPCClust) ); - ATH_CHECK( m_tgcPrdsKey.initialize(m_doTGCClust) ); + ATH_CHECK( m_mdtPrdsKey.initialize(m_doTGCClust || m_doRPCClust)); + ATH_CHECK( m_rpcPrdsKey.initialize()); + ATH_CHECK( m_tgcPrdsKey.initialize()); ATH_CHECK( m_patternCollKey.initialize() ); ATH_CHECK( m_tgcTruth.initialize(m_doClusterTruth) ); ATH_CHECK( m_rpcTruth.initialize(m_doClusterTruth) ); @@ -108,7 +108,13 @@ StatusCode MuonSegmentFinderAlg::execute() { // vector to hold segments - std::vector<const Muon::MuonSegment*> segs; + SG::WriteHandle<Trk::SegmentCollection> handle(m_segmentCollectionKey); + ATH_CHECK(handle.record(std::make_unique<Trk::SegmentCollection>())); + + SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrds(m_tgcPrdsKey); + const Muon::TgcPrepDataContainer* tgcPrdCont=tgcPrds.cptr(); + SG::ReadHandle<Muon::RpcPrepDataContainer> rpcPrds(m_rpcPrdsKey); + const Muon::RpcPrepDataContainer* rpcPrdCont=rpcPrds.cptr(); SG::ReadHandle<MuonPatternCombinationCollection> patternColl(m_patternCollKey); if(!patternColl.isValid()) { @@ -120,9 +126,19 @@ StatusCode MuonSegmentFinderAlg::execute() for(MuonPatternCombinationCollection::const_iterator patt=patternColl->begin(); patt!=patternColl->end(); ++patt) { ATH_MSG_DEBUG( "Working on pattern combination " << m_printer->print( **patt ) ); - //check the technology & call the corresponding segment finder - createSegmentsWithMDTs( *patt, segs ); - createSegmentsFromClusters( *patt, segs ); + //check the technology & call the corresponding segment finder + std::vector<const Muon::TgcPrepDataCollection*> tgcCols; + std::vector<const Muon::RpcPrepDataCollection*> rpcCols; + tgcCols.reserve(tgcPrdCont->size()); + for(auto p : *tgcPrdCont){ + if(!p->empty()) tgcCols.push_back(p); + } + rpcCols.reserve(rpcPrdCont->size()); + for(auto p : *rpcPrdCont){ + if(!p->empty()) rpcCols.push_back(p); + } + createSegmentsWithMDTs( *patt, handle.ptr(), rpcCols, tgcCols ); + createSegmentsFromClusters( *patt, handle.ptr() ); }//end loop on pattern combinations } @@ -131,53 +147,31 @@ StatusCode MuonSegmentFinderAlg::execute() } //do cluster based segment finding - std::vector<const Muon::MuonSegment*>* clustSegs(NULL); if (m_doTGCClust || m_doRPCClust){ SG::ReadHandle<Muon::MdtPrepDataContainer> mdtPrds(m_mdtPrdsKey); - const Muon::RpcPrepDataContainer* rpcPrdCont=0; - const Muon::TgcPrepDataContainer* tgcPrdCont=0; const PRD_MultiTruthCollection* tgcTruthColl=0; const PRD_MultiTruthCollection* rpcTruthColl=0; - if(m_doTGCClust){ - SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrds(m_tgcPrdsKey); - tgcPrdCont=tgcPrds.cptr(); - } - if(m_doRPCClust){ - SG::ReadHandle<Muon::RpcPrepDataContainer> rpcPrds(m_rpcPrdsKey); - rpcPrdCont=rpcPrds.cptr(); - } if(m_doClusterTruth){ SG::ReadHandle<PRD_MultiTruthCollection> tgcTruth(m_tgcTruth); SG::ReadHandle<PRD_MultiTruthCollection> rpcTruth(m_rpcTruth); tgcTruthColl=tgcTruth.cptr(); rpcTruthColl=rpcTruth.cptr(); } - clustSegs = m_clusterSegMaker->getClusterSegments(mdtPrds.cptr(),rpcPrdCont,tgcPrdCont,tgcTruthColl,rpcTruthColl); - } - if (clustSegs) { - segs.insert(segs.end(),clustSegs->begin(),clustSegs->end()); - delete clustSegs; + m_clusterSegMaker->getClusterSegments(mdtPrds.cptr(),m_doRPCClust ? rpcPrdCont : 0,m_doTGCClust ? tgcPrdCont : 0,tgcTruthColl,rpcTruthColl,handle.ptr()); } - std::vector<const Muon::MuonSegment*> resolvedSegments = m_segmentOverlapRemovalTool->removeDuplicates(segs); + ATH_MSG_DEBUG("segments before overlap removal: "<<handle->size()); + m_segmentOverlapRemovalTool->removeDuplicates(handle.ptr()); - //create a new SG container to store the segments - std::unique_ptr<Trk::SegmentCollection> segmentCollection = std::unique_ptr<Trk::SegmentCollection>( new Trk::SegmentCollection()); - segmentCollection->reserve(resolvedSegments.size()); - for( std::vector<const Muon::MuonSegment*>::iterator sit = resolvedSegments.begin(); sit!=resolvedSegments.end();++sit ){ - segmentCollection->push_back( const_cast<Muon::MuonSegment*>(*sit) ); - if( !m_truthSummaryTool.empty() ) m_truthSummaryTool->add(**sit,3); - } - ATH_MSG_DEBUG(" Segments after overlap removal: " << resolvedSegments.size() << " removed " << segs.size() - resolvedSegments.size() ); - - // need to delete removed segments - if( segs.size() != resolvedSegments.size() ){ - for( auto seg : segs ){ - auto pos = std::find(resolvedSegments.begin(),resolvedSegments.end(),seg); - if( pos == resolvedSegments.end() ) delete seg; + if(!m_truthSummaryTool.empty()){ + for(unsigned int i=0;i<handle.ptr()->size();i++){ + Trk::Segment* tseg=handle.ptr()->at(i); + m_truthSummaryTool->add(*(dynamic_cast<const Muon::MuonSegment*>(tseg)),3); } } + ATH_MSG_DEBUG(" Segments after overlap removal: " << handle->size()); + if( !m_csc2dSegmentFinder.empty() && !m_csc4dSegmentFinder.empty() ){ std::vector<const Muon::CscPrepDataCollection*> cscCols; @@ -195,11 +189,10 @@ StatusCode MuonSegmentFinderAlg::execute() } ATH_MSG_DEBUG("Retrieved CscPrepDataContainer " << cscCols.size()); // reconstruct segments in the CSC eta and phi plane - MuonSegmentCombinationCollection* csc2dSegmentCombinations = m_csc2dSegmentFinder->find( cscCols ); + std::unique_ptr<MuonSegmentCombinationCollection> csc2dSegmentCombinations = m_csc2dSegmentFinder->find( cscCols ); // combine CSC segments in eta and phi plane if any were found if (csc2dSegmentCombinations) { - MuonSegmentCombinationCollection* csc4dSegmentCombinations = m_csc4dSegmentFinder->find( *csc2dSegmentCombinations ); - delete csc2dSegmentCombinations; + std::unique_ptr<MuonSegmentCombinationCollection> csc4dSegmentCombinations = m_csc4dSegmentFinder->find( *csc2dSegmentCombinations ); if( csc4dSegmentCombinations ){ // now copy the segments into the collection, not optimal as unneeded copy @@ -217,30 +210,26 @@ StatusCode MuonSegmentFinderAlg::execute() for(unsigned int i=0; i<nstations; ++i){ // loop over segments in station - const Muon::MuonSegmentCombination::SegmentVec* segments = combi.stationSegments( i ) ; - + Muon::MuonSegmentCombination::SegmentVec* segments = combi.stationSegments( i ) ; + // check if not empty if( !segments || segments->empty() ) continue; // loop over new segments, copy them into collection - Muon::MuonSegmentCombination::SegmentVec::const_iterator sit = segments->begin(); - Muon::MuonSegmentCombination::SegmentVec::const_iterator sit_end = segments->end(); - for( ; sit!=sit_end;++sit) segmentCollection->push_back( new Muon::MuonSegment(**sit) ); + Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); + for( ; sit!=sit_end;++sit) handle->push_back( (*sit).release()); //releasing so the handle can take ownership } } - delete csc4dSegmentCombinations; } } } } - if( m_printSummary || msgLvl(MSG::DEBUG) ){ - msg() << msg().level() << "Number of segments found " << resolvedSegments.size() << std::endl << m_printer->print(resolvedSegments) << endmsg; + ATH_MSG_DEBUG("Number of segments found " << handle->size()); + for(unsigned int i=0;i<handle.ptr()->size();i++){ + Trk::Segment* tseg=handle.ptr()->at(i); + ATH_MSG_DEBUG(m_printer->print(*(dynamic_cast<Muon::MuonSegment*>(tseg)))); } - SG::WriteHandle<Trk::SegmentCollection> handle(m_segmentCollectionKey); - - //Add the segments to store gate - ATH_CHECK( handle.record(std::move(segmentCollection)) ); - return StatusCode::SUCCESS; } // execute @@ -250,7 +239,7 @@ StatusCode MuonSegmentFinderAlg::finalize() return AthAlgorithm::finalize(); } -void MuonSegmentFinderAlg::createSegmentsFromClusters(const Muon::MuonPatternCombination* patt, std::vector<const Muon::MuonSegment*>& segments ) { +void MuonSegmentFinderAlg::createSegmentsFromClusters(const Muon::MuonPatternCombination* patt, Trk::SegmentCollection* segments ) { //turn the PRD into MuonCluster std::map<int,std::vector<const Muon::MuonClusterOnTrack*> > clustersPerSector; std::vector< Muon::MuonPatternChamberIntersect >::const_iterator it = patt->chamberData().begin(); @@ -274,21 +263,19 @@ void MuonSegmentFinderAlg::createSegmentsFromClusters(const Muon::MuonPatternCom std::map<int,std::vector<const Muon::MuonClusterOnTrack*> >::iterator sit_end = clustersPerSector.end(); for( ;sit!=sit_end;++sit ){ std::vector<const Muon::MuonClusterOnTrack*>& clusters = sit->second; - std::vector<const Muon::MuonSegment*>* segs = m_clusterSegMakerNSW->find(clusters); + std::vector<Muon::MuonSegment*> segVec; + m_clusterSegMakerNSW->find(clusters,segVec,segments); //cleanup the memory for(std::vector<const Muon::MuonClusterOnTrack*>::iterator cit = clusters.begin(); cit!=clusters.end(); ++cit) { delete *cit; } - if( segs ){ - segments.insert(segments.end(),segs->begin(),segs->end()); - delete segs; - } } } -void MuonSegmentFinderAlg::createSegmentsWithMDTs(const Muon::MuonPatternCombination* patcomb, std::vector<const Muon::MuonSegment*>& segments ) { +void MuonSegmentFinderAlg::createSegmentsWithMDTs(const Muon::MuonPatternCombination* patcomb, Trk::SegmentCollection* segs, + const std::vector<const Muon::RpcPrepDataCollection*> rpcCols, const std::vector<const Muon::TgcPrepDataCollection*> tgcCols) { if( m_useNSWMode ){ @@ -340,11 +327,8 @@ void MuonSegmentFinderAlg::createSegmentsWithMDTs(const Muon::MuonPatternCombina if( mdtit->empty() ) continue; ATH_MSG_VERBOSE("Calling segment finding for sector " << m_idHelperTool->toString(mdtit->front()->identify()) ); //fit the segments - std::vector<const Muon::MuonSegment*>* segs = m_segmentMaker->find( rotit->regionPos, rotit->regionDir, *mdtit, rotit->clusters, - hasPhiMeasurements, rotit->regionDir.mag() ); - if(!segs) continue; - segments.insert(segments.end(),segs->begin(), segs->end()); - delete segs; + m_segmentMaker->find( rotit->regionPos, rotit->regionDir, *mdtit, rotit->clusters, + hasPhiMeasurements, segs, rotit->regionDir.mag() ); }//end loop on hits per region @@ -357,19 +341,6 @@ void MuonSegmentFinderAlg::createSegmentsWithMDTs(const Muon::MuonPatternCombina }//end loop on chambers in the pattern }else{ - Muon::MuonSegmentCombination* segmentCombi = m_patternSegmentMaker->find(*patcomb); - if( segmentCombi ){ - // loop over stations - unsigned int nst = segmentCombi->numberOfStations(); - for( unsigned int i = 0 ;i<nst;++i ){ - if( !segmentCombi->stationSegments(i) ) continue; - - // loop over segments - for( auto sit : *segmentCombi->stationSegments(i) ){ - segments.push_back( sit->clone() ); - } - } - delete segmentCombi; - } + m_patternSegmentMaker->find(*patcomb, rpcCols, tgcCols, segs); } } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h index 9a62f1ba8af198a7e7dbcacbdc2dbace1dd43fc2..bbb612f92374d832a0a6c25960910b5b1b29d75f 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MOOSEGMENTFINDERS_MUOSEGMENTFINDERALGS_H @@ -29,6 +29,8 @@ #include "MuonRecToolInterfaces/IMuonTruthSummaryTool.h" #include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinderTool.h" #include "MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h" +#include "MuonPrepRawData/RpcPrepDataCollection.h" +#include "MuonPrepRawData/TgcPrepDataCollection.h" namespace Muon { class IMuonClusterSegmentFinder; @@ -75,8 +77,9 @@ class MuonSegmentFinderAlg : public AthAlgorithm SG::ReadHandleKey<PRD_MultiTruthCollection> m_tgcTruth{this,"TGCTruth","TGC_TruthMap","TGC PRD Multi-truth Collection"}; SG::ReadHandleKey<PRD_MultiTruthCollection> m_rpcTruth{this,"RPCTruth","RPC_TruthMap","RPC PRD Multi-truth Collection"}; - void createSegmentsWithMDTs(const Muon::MuonPatternCombination* patt,std::vector<const Muon::MuonSegment*>& segs ); - void createSegmentsFromClusters(const Muon::MuonPatternCombination* patt,std::vector<const Muon::MuonSegment*>& segs); + void createSegmentsWithMDTs(const Muon::MuonPatternCombination* patt,Trk::SegmentCollection* segs, + const std::vector<const Muon::RpcPrepDataCollection*> rpcCols, const std::vector<const Muon::TgcPrepDataCollection*> tgcCols); + void createSegmentsFromClusters(const Muon::MuonPatternCombination* patt,Trk::SegmentCollection* segments); bool m_printSummary; bool m_useNSWMode; @@ -87,7 +90,6 @@ class MuonSegmentFinderAlg : public AthAlgorithm bool m_doClusterTruth; }; - #endif /* LocalWords: ifndef diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h index 3016434a4763f9f32e00983abc8fff09cba09ece..76dfb1175eecaf299ff59c54701b9ad5a67bd025 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ @@ -64,30 +64,30 @@ namespace Muon virtual StatusCode finalize (); /** INSERT main method here.*/ - MuonSegmentCombinationCollection* combineSegments( const MuonSegmentCombinationCollection& mdtCombiColl, - const MuonSegmentCombinationCollection& csc4DCombiColl, - const MuonSegmentCombinationCollection& csc2DCombiColl, - MuonSegmentCombPatternCombAssociationMap* segPattMap); + std::unique_ptr<MuonSegmentCombinationCollection> combineSegments( const MuonSegmentCombinationCollection& mdtCombiColl, + const MuonSegmentCombinationCollection& csc4DCombiColl, + const MuonSegmentCombinationCollection& csc2DCombiColl, + MuonSegmentCombPatternCombAssociationMap* segPattMap); - void trackParameters( const Muon::MuonSegment& seg ,double &theta,double &curvature,int &imeth ); + void trackParameters( Muon::MuonSegment& seg ,double &theta,double &curvature,int &imeth ); // void fulltrackParameters( const Muon::MuonSegment& seg ,HepMatrix & T , HepMatrix & CovT ,int &imeth ); - void extrapolateSegment( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); + void extrapolateSegment( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); - void fit2Segments( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); - void fit2SegmentsC( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); - void fit2SegmentsSL( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); + void fit2Segments( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); + void fit2SegmentsC( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); + void fit2SegmentsSL( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); private: - MuonSegmentCombinationCollection* processCombinationCollection(const MuonSegmentCombinationCollection& mdtCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap); + std::unique_ptr<MuonSegmentCombinationCollection> processCombinationCollection(const MuonSegmentCombinationCollection& mdtCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap); void processCscCombinationCollection( const MuonSegmentCombinationCollection& cscCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap) ; void process2DCscCombinationCollection( const MuonSegmentCombinationCollection& csc2DcombiCol); void muonCurvedSegmentCombinations(MuonSegmentCombinationCollection* curvedCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap); - Muon::MCSCSegmentInfo segInfo( const Muon::MuonSegment* seg ); + Muon::MCSCSegmentInfo segInfo( Muon::MuonSegment* seg ); - unsigned int missedHits( const Muon::MuonSegment* segment ); + unsigned int missedHits( Muon::MuonSegment* segment ); @@ -117,7 +117,7 @@ namespace Muon double m_phiAssociationCut2; bool m_addUnassociatedMiddleEndcapSegments; - typedef std::map<const Muon::MuonSegment*,Muon::MCSCSegmentInfo> SegInfoMap; + typedef std::map<Muon::MuonSegment*,Muon::MCSCSegmentInfo> SegInfoMap; typedef SegInfoMap::iterator SegInfoIt; int m_segmentIndex; SegInfoMap m_segInfoMap; @@ -126,7 +126,7 @@ namespace Muon SegInfoMap m_seg4DCscInfoMap; SegInfoMap m_segMdtInfoMap; - std::map<const Muon::MuonSegment*, const MuonPatternCombination* > m_segAssoMap; + std::map<Muon::MuonSegment*, const MuonPatternCombination* > m_segAssoMap; std::set <Identifier> m_cscIdSet; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/src/MuonCurvedSegmentCombiner.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/src/MuonCurvedSegmentCombiner.cxx index d6f23cbf5538670635f89064ff9fa71fffe640c4..a4ffc0690f64c8e315e47a31fa59dbad0fac4689 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/src/MuonCurvedSegmentCombiner.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/src/MuonCurvedSegmentCombiner.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ ////////////////////////////////////////////////////////////////// @@ -140,7 +140,7 @@ StatusCode Muon::MuonCurvedSegmentCombiner::finalize() //============================================================================================ -MuonSegmentCombinationCollection* +std::unique_ptr<MuonSegmentCombinationCollection> Muon::MuonCurvedSegmentCombiner::combineSegments( const MuonSegmentCombinationCollection& mdtCombiColl, const MuonSegmentCombinationCollection& csc4DCombiColl, const MuonSegmentCombinationCollection& csc2DCombiColl, @@ -186,10 +186,10 @@ Muon::MuonCurvedSegmentCombiner::combineSegments( const MuonSegmentCombination } -MuonSegmentCombinationCollection* Muon::MuonCurvedSegmentCombiner::processCombinationCollection(const MuonSegmentCombinationCollection& mdtCol, - MuonSegmentCombPatternCombAssociationMap* segPattMap){ +std::unique_ptr<MuonSegmentCombinationCollection> Muon::MuonCurvedSegmentCombiner::processCombinationCollection(const MuonSegmentCombinationCollection& mdtCol, + MuonSegmentCombPatternCombAssociationMap* segPattMap){ - MuonSegmentCombinationCollection* curvedCombiCol = new MuonSegmentCombinationCollection(); + std::unique_ptr<MuonSegmentCombinationCollection> curvedCombiCol(new MuonSegmentCombinationCollection); int nmdtsegments = 0; int ncscsegments = m_seg2DCscInfoMap.size() + m_seg4DCscInfoMap.size(); @@ -229,7 +229,7 @@ MuonSegmentCombinationCollection* Muon::MuonCurvedSegmentCombiner::processCombin SegInfoIt seg_it = m_seg4DCscInfoMap.begin(); SegInfoIt seg_it_end = m_seg4DCscInfoMap.end(); for(; seg_it != seg_it_end; ++seg_it){ - const Muon::MuonSegment* segm = seg_it->first; + Muon::MuonSegment* segm = seg_it->first; if( m_seg4DCscInfoMap[segm].contains(pattern)) { // Add 4D Csc segment associated to this pattern Muon::MCSCSegmentInfo info = seg_it->second; @@ -239,35 +239,35 @@ MuonSegmentCombinationCollection* Muon::MuonCurvedSegmentCombiner::processCombin } bool addedMdtSegments = false; for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<const Muon::MuonSegment*>& segs = *combi->stationSegments(i); + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; for(unsigned int si=0;si<segs.size();++si){ - if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si] << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; + if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; bool is_mdt=true; for (unsigned int ri=0;ri<segs[si]->numberOfContainedROTs(); ri++){ if (m_mdtIdHelper->is_mdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; if (m_cscIdHelper->is_csc(segs[si]->rioOnTrack(ri)->identify()) == true) {is_mdt = false; break;} } if (is_mdt == false) continue; - std::map<const Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si]); + std::map<Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si].get()); nmdtsegments++; if( it == m_segAssoMap.end() ){ - m_segAssoMap[segs[si]] = pattern; + m_segAssoMap[segs[si].get()] = pattern; }else{ if( it->second != pattern ) ATH_MSG_INFO(" MDT Segment pointers should only be found once!! "); it->second=pattern; } - Muon::MCSCSegmentInfo info = segInfo(segs[si]); + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); // Add Mdt segment associated to this pattern m_segmentIndex++; info.index = m_segmentIndex; - m_segInfoMap[segs[si]] = info; - m_segMdtInfoMap[segs[si]] = info; + m_segInfoMap[segs[si].get()] = info; + m_segMdtInfoMap[segs[si].get()] = info; addedMdtSegments = true; } } - if ( addedMdtSegments ) muonCurvedSegmentCombinations(curvedCombiCol,segPattMap); + if ( addedMdtSegments ) muonCurvedSegmentCombinations(curvedCombiCol.get(),segPattMap); } if (m_debug) std::cout << " First stage muonCurvedSegmentCombinations " << curvedCombiCol->size() << " Mdt segments " << nmdtsegments << " Csc segments " << ncscsegments << std::endl; @@ -380,13 +380,13 @@ MuonSegmentCombinationCollection* Muon::MuonCurvedSegmentCombiner::processCombin bool compatible = false; for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<const Muon::MuonSegment*>& segs = *combi->stationSegments(i); + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); if (!segs.empty()) { const Amg::Vector3D& segpos = segs[0]->globalPosition(); double dotprod = segpos.x()*patternDir.x() + segpos.y()*patternDir.y() + segpos.z()*patternDir.z(); for(unsigned int j=0;j<combi1->numberOfStations();++j){ - const std::vector<const Muon::MuonSegment*>& segs1 = *combi1->stationSegments(j); + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs1 = *combi1->stationSegments(j); if (!segs1.empty()) { const Amg::Vector3D& segpos1 = segs1[0]->globalPosition(); double dotprod1 = segpos1.x()*patternDir1.x() + segpos1.y()*patternDir1.y() + segpos1.z()*patternDir1.z(); @@ -414,7 +414,7 @@ MuonSegmentCombinationCollection* Muon::MuonCurvedSegmentCombiner::processCombin SegInfoIt seg_it = m_seg4DCscInfoMap.begin(); SegInfoIt seg_it_end = m_seg4DCscInfoMap.end(); for(; seg_it != seg_it_end; ++seg_it){ - const Muon::MuonSegment* segm = seg_it->first; + Muon::MuonSegment* segm = seg_it->first; if( m_seg4DCscInfoMap[segm].contains(pattern) || m_seg4DCscInfoMap[segm].contains(pattern1)) { // Add 4D Csc segment associated to this pattern Muon::MCSCSegmentInfo info = seg_it->second; @@ -424,10 +424,10 @@ MuonSegmentCombinationCollection* Muon::MuonCurvedSegmentCombiner::processCombin } bool addedMdtSegments = false; for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<const Muon::MuonSegment*>& segs = *combi->stationSegments(i); + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; for(unsigned int si=0;si<segs.size();++si){ - if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si] << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; + if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; bool is_mdt=true; for (unsigned int ri=0;ri<segs[si]->numberOfContainedROTs(); ri++){ if (m_mdtIdHelper->is_mdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; @@ -435,46 +435,46 @@ MuonSegmentCombinationCollection* Muon::MuonCurvedSegmentCombiner::processCombin } if (is_mdt == false)continue; - std::map<const Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si]); + std::map<Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si].get()); if( it == m_segAssoMap.end() ){ - m_segAssoMap[segs[si]] = patternSelect; + m_segAssoMap[segs[si].get()] = patternSelect; }else{ it->second=patternSelect; } - Muon::MCSCSegmentInfo info = segInfo(segs[si]); + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); // Add Mdt segment associated to this pattern - m_segInfoMap[segs[si]] = info; - m_segMdtInfoMap[segs[si]] = info; + m_segInfoMap[segs[si].get()] = info; + m_segMdtInfoMap[segs[si].get()] = info; addedMdtSegments = true; } } for(unsigned int i=0;i<combi1->numberOfStations();++i){ - const std::vector<const Muon::MuonSegment*>& segs = *combi1->stationSegments(i); + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi1->stationSegments(i); if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; for(unsigned int si=0;si<segs.size();++si){ - if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si] << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; + if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; bool is_mdt=true; for (unsigned int ri=0;ri<segs[si]->numberOfContainedROTs(); ri++){ if (m_mdtIdHelper->is_mdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; if (m_cscIdHelper->is_csc(segs[si]->rioOnTrack(ri)->identify()) == true) {is_mdt = false; break;} } if (is_mdt == false)continue; - std::map<const Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si]); + std::map<Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si].get()); if( it == m_segAssoMap.end() ){ - m_segAssoMap[segs[si]] = patternSelect; + m_segAssoMap[segs[si].get()] = patternSelect; }else{ it->second=patternSelect; } - Muon::MCSCSegmentInfo info = segInfo(segs[si]); + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); // Add Mdt segment associated to this pattern - m_segInfoMap[segs[si]] = info; - m_segMdtInfoMap[segs[si]] = info; + m_segInfoMap[segs[si].get()] = info; + m_segMdtInfoMap[segs[si].get()] = info; addedMdtSegments = true; } } - if ( addedMdtSegments ) muonCurvedSegmentCombinations(curvedCombiCol,segPattMap); + if ( addedMdtSegments ) muonCurvedSegmentCombinations(curvedCombiCol.get(),segPattMap); } } if (m_debug) std::cout << " Second stage muonCurvedSegmentCombinations " << curvedCombiCol->size() << std::endl; @@ -512,7 +512,7 @@ Muon::MuonCurvedSegmentCombiner::processCscCombinationCollection( const MuonSegm const MuonPatternCombination* pattern = (*(range.first)).second; for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<const Muon::MuonSegment*>& segs = *combi->stationSegments(i); + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); if(m_debug) std::cout << " station " << i << " has Csc segments: " << segs.size() << std::endl; for(unsigned int si=0;si<segs.size();++si){ if(m_debug) std::cout << " Store Csc segment " << si << std::endl; @@ -525,14 +525,14 @@ Muon::MuonCurvedSegmentCombiner::processCscCombinationCollection( const MuonSegm } } if (is_csc == false) continue; - std::map<const Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si]); + std::map<Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si].get()); if( it == m_segAssoMap.end() ){ - m_segAssoMap[segs[si]] = pattern; + m_segAssoMap[segs[si].get()] = pattern; }else{ it->second=pattern; } // 4D Csc segments can be on more than 1 pattern - Muon::MCSCSegmentInfo info = segInfo(segs[si]); + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); m_segmentIndex++; info.index = m_segmentIndex; MuonSegmentCombPatternCombAssociationMap::const_iterator ia_it = range.first; @@ -540,7 +540,7 @@ Muon::MuonCurvedSegmentCombiner::processCscCombinationCollection( const MuonSegm for(; ia_it != ia_it_end; ++ia_it){ info.patPointers.push_back((*ia_it).second); } - m_seg4DCscInfoMap[segs[si]] = info; + m_seg4DCscInfoMap[segs[si].get()] = info; if(m_debug) std::cout << " Store Csc segment " << " associated pattern size " << info.patPointers.size() << std::endl; } } @@ -560,7 +560,7 @@ Muon::MuonCurvedSegmentCombiner::process2DCscCombinationCollection( const MuonSe } for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<const Muon::MuonSegment*>& segs = *combi->stationSegments(i); + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); if(m_debug) std::cout << " station " << i << " has Csc segments: " << segs.size() << std::endl; for(unsigned int si=0;si<segs.size();++si){ if(m_debug) std::cout << " Store Csc segment? " << si << std::endl; @@ -580,11 +580,11 @@ Muon::MuonCurvedSegmentCombiner::process2DCscCombinationCollection( const MuonSe // 2D Csc segments are NOT associated to Pattern - m_segAssoMap[segs[si]] = 0; - Muon::MCSCSegmentInfo info = segInfo(segs[si]); + m_segAssoMap[segs[si].get()] = 0; + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); m_segmentIndex++; info.index = m_segmentIndex; - m_seg2DCscInfoMap[segs[si]] = info; + m_seg2DCscInfoMap[segs[si].get()] = info; //if(m_debug) std::cout << " Store Csc eta segment " << " associated pattern size " << combiAssos.size() << std::endl; } } @@ -623,7 +623,7 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC SegInfoIt seg_it_end = m_segInfoMap.end(); int nSegments = 0; for(; seg_it != seg_it_end; ++seg_it){ - const Muon::MuonSegment* segm = seg_it->first; + Muon::MuonSegment* segm = seg_it->first; int npSize = 0; if (m_segAssoMap.count(segm)>0) { npSize = npSize + m_segAssoMap.count(segm); @@ -634,7 +634,7 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC } // Vectors for storing segment information - std::vector<const Muon::MuonSegment*> segment(nSegments); + std::vector<Muon::MuonSegment*> segment(nSegments); std::vector<std::string> station(nSegments); // station string std::vector<int> iPhiPatHits(nSegments); // phi hits on pattern std::vector<double> patPhi(nSegments); // phi value of pattern @@ -650,8 +650,8 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC // // Order the segments according to stationcode, missed (trigger) hits, and chi2 // - std::map<double , const Muon::MuonSegment*> checkSegments; - std::map<int , const Muon::MuonSegment*> checkSegmentsIndex; + std::map<double , Muon::MuonSegment*> checkSegments; + std::map<int , Muon::MuonSegment*> checkSegmentsIndex; // // assign an integer to each pattern needed to count segments per pattern per chamber // @@ -662,7 +662,7 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC int patIn = -1; int patInlast = -1; for(; seg_it != seg_it_end; ++seg_it){ - const Muon::MuonSegment* segm = seg_it->first; + Muon::MuonSegment* segm = seg_it->first; const Muon::MCSCSegmentInfo& info = m_segInfoMap[segm]; if (info.patPoint!=0) { if (patIndex.count(info.patPoint)!=1) { @@ -724,13 +724,13 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC } } - std::map<double , const Muon::MuonSegment*>::iterator ic_it = checkSegments.begin(); - std::map<double , const Muon::MuonSegment*>::iterator ic_it_end= checkSegments.end(); + std::map<double , Muon::MuonSegment*>::iterator ic_it = checkSegments.begin(); + std::map<double , Muon::MuonSegment*>::iterator ic_it_end= checkSegments.end(); if (m_debug) { std::cout << " Check Input Segments " << checkSegments.size() << std::endl ; for(; ic_it != ic_it_end; ++ic_it){ - const Muon::MuonSegment* seg = ic_it->second; + Muon::MuonSegment* seg = ic_it->second; const Muon::MCSCSegmentInfo& info = m_segInfoMap[seg]; std::string st = info.station; int code = info.stationCode; @@ -741,11 +741,11 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC // Order segments according to key including multiplicity per pattern and chamber - std::map<int , const Muon::MuonSegment*> orderSegments; + std::map<int , Muon::MuonSegment*> orderSegments; int i = 0; ic_it = checkSegments.begin(); for(; ic_it != ic_it_end; ++ic_it){ - const Muon::MuonSegment* segm = ic_it->second; + Muon::MuonSegment* segm = ic_it->second; const Muon::MCSCSegmentInfo& info = m_segInfoMap[segm]; // Built key from ordered segments per station and missed hits @@ -793,8 +793,8 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC // Reset nSegments - std::map<int , const Muon::MuonSegment*>::iterator io_it = orderSegments.begin(); - std::map<int , const Muon::MuonSegment*>::iterator io_it_end= orderSegments.end(); + std::map<int , Muon::MuonSegment*>::iterator io_it = orderSegments.begin(); + std::map<int , Muon::MuonSegment*>::iterator io_it_end= orderSegments.end(); // Store segments and stations if (m_debug) std::cout << " Summary Input Segments " << nSegments << std::endl ; @@ -802,7 +802,7 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC int j0 =0; int code0 =0; for(; io_it != io_it_end; ++io_it){ - const Muon::MuonSegment* seg = io_it->second; + Muon::MuonSegment* seg = io_it->second; const Muon::MCSCSegmentInfo& info = m_segInfoMap[seg]; std::string st = info.station; segment[i] = seg; @@ -1247,7 +1247,7 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC i++; // create MuonSegmentCombination for one track candidate Muon::MuonSegmentCombination* combination = new Muon::MuonSegmentCombination(); - typedef std::map <std::string , std::vector<const Muon::MuonSegment*>* > ChamberSort; + typedef std::map <std::string , std::unique_ptr<std::vector<std::unique_ptr<Muon::MuonSegment> > > > ChamberSort; typedef ChamberSort::iterator ChamberSortIt; ChamberSort chamberSort; @@ -1258,30 +1258,28 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC for (unsigned int k = 0 ; k < combi.size() ; ++k ) { if (patPoint[combi[k]]) patc = patPoint[combi[k]]; if (m_debug){ - const Muon::MuonSegment* seg = segment[combi[k]]; + Muon::MuonSegment* seg = segment[combi[k]]; //const Muon::MCSCSegmentInfo& info = m_segInfoMap[seg]; double phisp = atan2( seg->globalPosition().y(), seg->globalPosition().x()); std::cout << " Segment position x " << seg->globalPosition().x() << " y " << seg->globalPosition().y() << " z " << seg->globalPosition().z()<< " phi " << seg->globalDirection().phi() << " phi space " << phisp << " theta " << seg->globalDirection().theta() <<std::endl; //std::cout << info << std::endl; } std::string st = station[combi[k]]; - std::vector<const Muon::MuonSegment*>* segPerStation = 0; ChamberSortIt pos = chamberSort.find(st); if (pos == chamberSort.end()) { - segPerStation = new std::vector<const Muon::MuonSegment*>(); - chamberSort[st] = segPerStation; + chamberSort[st] = std::make_unique<std::vector<std::unique_ptr<Muon::MuonSegment> > >(); + chamberSort[st]->push_back(std::unique_ptr<Muon::MuonSegment>(segment[combi[k]]->clone())); // if (m_debug) std::cout << " First segment in Station " << st << std::endl; } else { - segPerStation = pos->second; + pos->second->push_back(std::unique_ptr<Muon::MuonSegment>(segment[combi[k]]->clone())); // if (m_debug) std::cout << " Next segment in Station " << st << " size " << segPerStation->size() << std::endl; } - segPerStation->push_back(segment[combi[k]]->clone()); } ChamberSortIt cit = chamberSort.begin(); ChamberSortIt cit_end = chamberSort.end(); - for (;cit !=cit_end; ++cit) { - combination->addSegments( cit->second ); - } + for (;cit !=cit_end; ++cit) { + combination->addSegments( std::move(cit->second) ); + } // if (patc) assCurvedMap->addAssociation( patternCol, patc, combiCol, combination ); segPattMap->insert(std::make_pair(combination, patc)); @@ -1297,7 +1295,7 @@ void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentC } unsigned int -Muon::MuonCurvedSegmentCombiner::missedHits( const Muon::MuonSegment* seg) { +Muon::MuonCurvedSegmentCombiner::missedHits( Muon::MuonSegment* seg) { // try to dynamic_cast to MdtSegmentQuality in order to obtain quality const Muon::MuonSegmentQuality* q = dynamic_cast<const Muon::MuonSegmentQuality*>(seg->fitQuality()); @@ -1320,7 +1318,7 @@ Muon::MuonCurvedSegmentCombiner::missedHits( const Muon::MuonSegment* seg) { } Muon::MCSCSegmentInfo -Muon::MuonCurvedSegmentCombiner::segInfo( const Muon::MuonSegment* seg ){ +Muon::MuonCurvedSegmentCombiner::segInfo( Muon::MuonSegment* seg ){ Muon::MCSCSegmentInfo info; @@ -1584,7 +1582,7 @@ Muon::MuonCurvedSegmentCombiner::segInfo( const Muon::MuonSegment* seg ){ } void -Muon::MuonCurvedSegmentCombiner::trackParameters( const Muon::MuonSegment& seg ,double &theta,double &invcurvature,int &imeth ){ +Muon::MuonCurvedSegmentCombiner::trackParameters( Muon::MuonSegment& seg ,double &theta,double &invcurvature,int &imeth ){ // Determine track parameters in Rz plane (theta and inverse curvature) from the input segment @@ -1709,7 +1707,7 @@ Muon::MuonCurvedSegmentCombiner::trackParameters( const Muon::MuonSegment& seg , } void -Muon::MuonCurvedSegmentCombiner::fit2SegmentsSL( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { +Muon::MuonCurvedSegmentCombiner::fit2SegmentsSL( Muon::MuonSegment& seg , Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { // Fit 2 segments to a straightline (no Interaction Point constraint) @@ -1917,7 +1915,7 @@ Muon::MuonCurvedSegmentCombiner::fit2SegmentsSL( const Muon::MuonSegment& seg , } void -Muon::MuonCurvedSegmentCombiner::fit2Segments( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { +Muon::MuonCurvedSegmentCombiner::fit2Segments( Muon::MuonSegment& seg , Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { // Fit 2 segments to one track and determine residuals and pulls @@ -2146,7 +2144,7 @@ Muon::MuonCurvedSegmentCombiner::fit2Segments( const Muon::MuonSegment& seg , co << " cottan theta 2 fit " << -(Res[3]+ym(4,0)) << std::endl; } -void Muon::MuonCurvedSegmentCombiner::fit2SegmentsC( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { +void Muon::MuonCurvedSegmentCombiner::fit2SegmentsC( Muon::MuonSegment& seg , Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { // Fit two segments for cosmics with loose IP constraint and free curvature @@ -2381,7 +2379,7 @@ void Muon::MuonCurvedSegmentCombiner::fit2SegmentsC( const Muon::MuonSegment& se } } -void Muon::MuonCurvedSegmentCombiner::extrapolateSegment( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { +void Muon::MuonCurvedSegmentCombiner::extrapolateSegment( Muon::MuonSegment& seg , Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { // extrapolate segment seg* to segment sege* and determine residuals and pulls diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h index 5c303131f92a22e6ede762204eca963175b1ecd9..e25899196ac3cf8058e1ecbc0c26ea45828f7369 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -13,9 +13,8 @@ #include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonPattern/MuonPatternCombinationCollection.h" #include "TrkSegment/SegmentCollection.h" - -#include "MuonPrepRawData/CscPrepDataCollection.h" #include "MuonPrepRawData/MdtPrepDataCollection.h" +#include "MuonPrepRawData/CscPrepDataCollection.h" #include "MuonPrepRawData/RpcPrepDataCollection.h" #include "MuonPrepRawData/TgcPrepDataCollection.h" @@ -29,20 +28,20 @@ namespace Muon public: struct Output { - const MuonPatternCombinationCollection* patternCombinations; - const Trk::SegmentCollection* segmentCollection; - const MuonSegmentCombinationCollection* segmentCombinations; - - Output() : patternCombinations(0),segmentCollection(0),segmentCombinations(0) {} + MuonPatternCombinationCollection* patternCombinations; + Trk::SegmentCollection* segmentCollection; + + Output() : patternCombinations(0),segmentCollection(0) {} }; static const InterfaceID& interfaceID( ) ; // enter declaration of your interface-defining member functions here - virtual Output* findSegments( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols ) = 0; + virtual void findSegments( const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + Output& output) = 0; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h index 081bb5e72658b60045e872125703b257b087d12b..4b7a65a771111aa6e431f1c4210a4aa23aaac5b1 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -20,10 +20,10 @@ namespace Muon public: static const InterfaceID& interfaceID( ) ; - virtual MuonSegmentCombinationCollection* combineSegments( const MuonSegmentCombinationCollection& mdtCombiColl, - const MuonSegmentCombinationCollection& csc4DCombiColl, - const MuonSegmentCombinationCollection& csc2DCombiColl, - MuonSegmentCombPatternCombAssociationMap* segPattMap)=0; + virtual std::unique_ptr<MuonSegmentCombinationCollection> combineSegments( const MuonSegmentCombinationCollection& mdtCombiColl, + const MuonSegmentCombinationCollection& csc4DCombiColl, + const MuonSegmentCombinationCollection& csc2DCombiColl, + MuonSegmentCombPatternCombAssociationMap* segPattMap)=0; }; inline const InterfaceID& Muon::IMuonCurvedSegmentCombiner::interfaceID() diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMuonSegmentCombinationCleanerTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMuonSegmentCombinationCleanerTool.h index 9170361c5599a46c455e16fbd5a0f5e79fb318cf..4c11ab76a695aaddaf9744048bbc69970a1095e9 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMuonSegmentCombinationCleanerTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonSegmentCombinerToolInterfaces/MuonSegmentCombinerToolInterfaces/IMuonSegmentCombinationCleanerTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_IMUONSEGMENTCOMBINATIONCLEANERTOOL_H @@ -26,7 +26,7 @@ namespace Muon { static const InterfaceID& interfaceID(); /** clean phi hits on a segment combination */ - virtual MuonSegmentCombinationCollection* clean( const MuonSegmentCombinationCollection& combiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap ) = 0; + virtual std::unique_ptr<MuonSegmentCombinationCollection> clean( const MuonSegmentCombinationCollection& combiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap ) = 0; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/CscSegmentMakers/ICscSegmentFinder.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/CscSegmentMakers/ICscSegmentFinder.h index 34bbca13be085996616de286da8d1e050c93e721..ac237ed6b669db3fad0464f3b85f46b873f43a58 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/CscSegmentMakers/ICscSegmentFinder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/CscSegmentMakers/ICscSegmentFinder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // ICscSegmentFinder.h @@ -45,10 +45,10 @@ public: // Interface methods // virtual Muon::MuonSegmentCombination* find( const Muon::CscPrepDataCollection& pcol) =0; // using Muon::IMuonSegmentMaker::find; - virtual MuonSegmentCombinationCollection* find( const std::vector<const Muon::CscPrepDataCollection*>& pcols) const =0; + virtual std::unique_ptr<MuonSegmentCombinationCollection> find( const std::vector<const Muon::CscPrepDataCollection*>& pcols) const =0; // for 4d SegmentMaker - virtual MuonSegmentCombinationCollection* find( const MuonSegmentCombinationCollection& segcols) const =0; + virtual std::unique_ptr<MuonSegmentCombinationCollection> find( const MuonSegmentCombinationCollection& segcols) const =0; /* virtual std::vector<const Muon::MuonSegment*>* find( const Trk::TrackRoad& road, diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/CscSegmentMakers/ICscSegmentUtilTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/CscSegmentMakers/ICscSegmentUtilTool.h index 0b444ec7f11dad84f578573de457f3cfb762df5c..0febb869fd07e10a8a0be867e74f7aa801ffc255 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/CscSegmentMakers/ICscSegmentUtilTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/CscSegmentMakers/ICscSegmentUtilTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // ICscSegmentUtilTool.h @@ -69,7 +69,7 @@ public: // Interface methods virtual Muon::MuonSegmentCombination* get4dMuonSegmentCombination(const Muon::MuonSegmentCombination* Muon2dSegComb) const=0; - virtual std::vector<const Muon::MuonSegment*>* + virtual std::unique_ptr<std::vector<std::unique_ptr<Muon::MuonSegment> > > getMuonSegments(Identifier eta_id, Identifier phi_id, ICscSegmentFinder::ChamberTrkClusters& eta_clus, ICscSegmentFinder::ChamberTrkClusters& phi_clus, diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc2dSegmentMaker.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc2dSegmentMaker.cxx index bb1a2b391c4736e1022f3d7bc8cab44dfbf35606..71a36c76e097400e95ea8361463d77aec5c0aabf 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc2dSegmentMaker.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc2dSegmentMaker.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "Csc2dSegmentMaker.h" @@ -143,23 +143,18 @@ StatusCode Csc2dSegmentMaker::initialize(){ //****************************************************************************** -MuonSegmentCombinationCollection* Csc2dSegmentMaker::find( const std::vector<const Muon::CscPrepDataCollection*>& pcols) const +std::unique_ptr<MuonSegmentCombinationCollection> Csc2dSegmentMaker::find( const std::vector<const Muon::CscPrepDataCollection*>& pcols) const { // Construct output segment collection. - MuonSegmentCombinationCollection* mpsegs = 0; + std::unique_ptr<MuonSegmentCombinationCollection> mpsegs(new MuonSegmentCombinationCollection); - bool haveElement = false; for ( unsigned int icol=0; icol <pcols.size(); ++icol) { const CscPrepDataCollection* clus = pcols[icol]; if (clus->size() == 0) continue; // skip zero cluster collection - haveElement = true; break; } - if (haveElement) - mpsegs = new MuonSegmentCombinationCollection; - unsigned int col_count = 0; // Loop over collections in the container. for ( unsigned int icol=0; icol <pcols.size(); ++icol) { @@ -176,7 +171,8 @@ MuonSegmentCombinationCollection* Csc2dSegmentMaker::find( const std::vector<con } } - if(mpsegs) ATH_MSG_DEBUG("found "<<mpsegs->size()<<" 2d csc segments"); + if(!mpsegs->empty()) ATH_MSG_DEBUG("found "<<mpsegs->size()<<" 2d csc segments"); + else mpsegs.reset(); return mpsegs; } @@ -334,9 +330,9 @@ MuonSegmentCombination* Csc2dSegmentMaker::findSegmentCombination(const CscPrepD //****************************************************************************** -MuonSegmentCombinationCollection* Csc2dSegmentMaker::find( const MuonSegmentCombinationCollection& ) const +std::unique_ptr<MuonSegmentCombinationCollection> Csc2dSegmentMaker::find( const MuonSegmentCombinationCollection& ) const { - return 0; + return std::unique_ptr<MuonSegmentCombinationCollection>(); } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc2dSegmentMaker.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc2dSegmentMaker.h index bb585c8d9c9ad142118b20588a102dc14ca65c55..518136f6a84f079f1dd53b8032cb8d279ef7df55 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc2dSegmentMaker.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc2dSegmentMaker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // Csc2dSegmentMaker.h @@ -60,8 +60,8 @@ public: // methods // Finalization. StatusCode finalize(); - MuonSegmentCombinationCollection* find( const std::vector<const Muon::CscPrepDataCollection*>& pcols) const; - MuonSegmentCombinationCollection* find( const MuonSegmentCombinationCollection& ) const; + std::unique_ptr<MuonSegmentCombinationCollection> find( const std::vector<const Muon::CscPrepDataCollection*>& pcols) const; + std::unique_ptr<MuonSegmentCombinationCollection> find( const MuonSegmentCombinationCollection& ) const; private: // methods diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc4dSegmentMaker.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc4dSegmentMaker.cxx index a009660bb65621e30eba443c987245a6051543cc..2998fd6f6117a2a0e6db54138f60839c65d70d4e 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc4dSegmentMaker.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc4dSegmentMaker.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "Csc4dSegmentMaker.h" @@ -64,7 +64,6 @@ Csc4dSegmentMaker(const std::string& type, const std::string& aname, const IInte { declareInterface<ICscSegmentFinder>(this); - declareInterface<Muon::IMuonSegmentMaker>(this); declareProperty("dump_count", m_dumpcount =-1); declareProperty("max_chisquare", m_max_chisquare = 25); declareProperty("max_slope_r", m_max_slope_r = 0.2); @@ -119,7 +118,7 @@ StatusCode Csc4dSegmentMaker::initialize(){ //****************************************************************************** -MuonSegmentCombinationCollection* +std::unique_ptr<MuonSegmentCombinationCollection> Csc4dSegmentMaker::find( const MuonSegmentCombinationCollection& segcols) const { @@ -127,10 +126,11 @@ Csc4dSegmentMaker::find( const MuonSegmentCombinationCollection& segcols) const m_dump = m_dumped < m_dumpcount || m_dumpcount < 0; if ( m_dump ) ++m_dumped; - MuonSegmentCombinationCollection* pcols = 0; - if ( segcols.empty() ) return pcols; - - pcols = new MuonSegmentCombinationCollection; + std::unique_ptr<MuonSegmentCombinationCollection> pcols(new MuonSegmentCombinationCollection); + if ( segcols.empty() ){ + pcols.reset(); + return pcols; + } for ( MuonSegmentCombinationCollection::const_iterator icom=segcols.begin(); icom!=segcols.end(); ++icom ) { @@ -156,102 +156,6 @@ Csc4dSegmentMaker::find( const MuonSegmentCombinationCollection& segcols) const return pcols; } -//****************************************************************************** -// For MuGirls... Seeded SegmentMaker part.... -//Note: this code was used by the old MuGirl but is not part of the current reconstruction -std::vector<const MuonSegment*>* Csc4dSegmentMaker::find( const Amg::Vector3D& /*gpos*/, const Amg::Vector3D& /*gdir*/, - const std::vector< const MdtDriftCircleOnTrack* > & , - const std::vector< const MuonClusterOnTrack* > & pcots, - bool, double) const { - - if( pcots.empty() ) return 0; - const Muon::CscClusterOnTrack* csc = dynamic_cast<const Muon::CscClusterOnTrack*>(pcots.front()); - if( !csc ){ - ATH_MSG_WARNING("Cluster input should only contain CSC hits"); - return 0; - } - const MuonGM::CscReadoutElement* detEl = csc->detectorElement(); - if( !detEl ){ - ATH_MSG_WARNING("Failed to obtain CscReadoutElement for cluster"); - return 0; - } - Amg::Transform3D gToLocal = detEl->GlobalToAmdbLRSTransform(); - Amg::Vector3D lpos000 = gToLocal*Amg::Vector3D(0.0, 0.0, 0.0); - - ChamberTrkClusters etaclus, phiclus; - Identifier eta_id, phi_id, chid; - for ( unsigned int icot=0; icot<pcots.size(); ++icot ) { - - const Muon::CscClusterOnTrack* csc = dynamic_cast<const Muon::CscClusterOnTrack*>(pcots[icot]); - if( !csc ){ - ATH_MSG_WARNING("Failed to obtain CscReadoutElement for cluster"); - return 0; - } - ATH_MSG_VERBOSE ( " +++++++++ Errors from prio " << Amg::error(csc->localCovariance(),Trk::locX) << " "); - - Amg::Vector3D lpos = gToLocal*csc->globalPosition(); - const Identifier& id = csc->identify(); - bool measphi = m_phelper->measuresPhi(id); - int iwlay = m_phelper->wireLayer(id); - if ( measphi ) { - phi_id = id; - phiclus[iwlay-1].push_back(Cluster(lpos,csc,measphi)); - } else { - eta_id = id; - etaclus[iwlay-1].push_back(Cluster(lpos,csc,measphi)); - } - } - - std::vector<const MuonSegment*>* segments = 0; - // std::vector<const MuonSegment*>* segments = 0 - - - int nHitLayer_eta =0; - int nHitLayer_phi =0; - for (int i=0; i<4; ++i) { - // ATH_MSG_DEBUG ( "No of clusters in layer " << i << " " << eta_clus[i].size() << " " << phi_clus[i].size() ); - if (etaclus[i].size() >0) ++nHitLayer_eta; - if (phiclus[i].size() >0) ++nHitLayer_phi; - } - - if (nHitLayer_eta >=2 || nHitLayer_phi >=2) { - ATH_MSG_DEBUG( "Csc4dSegment calls getMuonSegments!!! " << nHitLayer_eta << " " << nHitLayer_phi ); - segments = m_segmentTool->getMuonSegments(eta_id, phi_id, etaclus, phiclus,lpos000); - } - - return segments; - -} //find - -//Note: this code was used by the old MuGirl but is not part of the current reconstruction -//****************************************************************************** -std::vector<const MuonSegment*>* Csc4dSegmentMaker::find( const Trk::TrackRoad& road, - const std::vector< std::vector< const MdtDriftCircleOnTrack* > >& , - const std::vector< std::vector< const MuonClusterOnTrack* > >& clusters, - bool, double) const { - - // Here, according to give TrackRoad, I do re-estimate errors of each COT and repeat segment fit - - // Reference - // MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx#553 - - const Amg::Vector3D& gpos = road.globalPosition(); - const Amg::Vector3D& gdir = road.globalDirection(); - - // copy all clusters into one vector - std::vector< const MdtDriftCircleOnTrack* > pmots; - std::vector< const MuonClusterOnTrack* > pcots; - std::vector< std::vector< const MuonClusterOnTrack* > >::const_iterator cit = clusters.begin(); - std::vector< std::vector< const MuonClusterOnTrack* > >::const_iterator cit_end = clusters.end(); - for(; cit!=cit_end;++cit ){ - std::copy( cit->begin(), cit->end(), std::back_inserter(pcots) ); - } - - return find(gpos, gdir, pmots, pcots, false, 0.0); - -} - - //****************************************************************************** @@ -259,23 +163,10 @@ StatusCode Csc4dSegmentMaker::finalize() { ATH_MSG_DEBUG ( "Goodbye" ); return StatusCode::SUCCESS; } - - -//************dummy function for interface****************************************************************** - -MuonSegmentCombinationCollection* Csc4dSegmentMaker::find(const std::vector<const Muon::CscPrepDataCollection*>& /*pcols*/) const { - return 0; -} -std::vector<const MuonSegment*>* Csc4dSegmentMaker::find( const std::vector<const Trk::RIO_OnTrack*>& /*rios*/ ) const { - return 0; -} +//****************************************************************************** -std::vector<const MuonSegment*>* Csc4dSegmentMaker::find( const std::vector<const Trk::RIO_OnTrack*>& /*rios1*/, - const std::vector<const Trk::RIO_OnTrack*>& /*rios2*/ ) const { - return 0; -} -std::vector<const MuonSegment*>* Csc4dSegmentMaker::find( const std::vector<const MdtDriftCircleOnTrack*>& /*mdts*/, - const std::vector<const MuonClusterOnTrack*>& /*clusters*/) const { +//dummy ICscSegmentFinder interface +std::unique_ptr<MuonSegmentCombinationCollection> Csc4dSegmentMaker::find(const std::vector<const Muon::CscPrepDataCollection*>& ) const { return 0; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc4dSegmentMaker.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc4dSegmentMaker.h index 8e817aca183feec89b2f0b4047fa67b284022b8e..cf09d90f058fded0c0e4202dd9c7fc927bf32018 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc4dSegmentMaker.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/Csc4dSegmentMaker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef Csc4dSegmentMaker_H @@ -16,7 +16,6 @@ #include "GaudiKernel/ToolHandle.h" #include "Identifier/Identifier.h" #include "CscSegmentMakers/ICscSegmentFinder.h" //including MuonSegmentCombination(Collection).h CscPrepDataContainer.h" -#include "MuonRecToolInterfaces/IMuonSegmentMaker.h" // added.. class ICscSegmentUtilTool; @@ -36,7 +35,7 @@ namespace Muon { class MuonSegment; } -class Csc4dSegmentMaker : virtual public ICscSegmentFinder, virtual public Muon::IMuonSegmentMaker, public AthAlgTool { +class Csc4dSegmentMaker : virtual public ICscSegmentFinder, public AthAlgTool { public: // methods @@ -52,25 +51,8 @@ public: // methods // Finalization. StatusCode finalize(); - MuonSegmentCombinationCollection* find( const std::vector<const Muon::CscPrepDataCollection*>& pcols) const; - MuonSegmentCombinationCollection* find( const MuonSegmentCombinationCollection& ) const ; - - // Only for Csc4dSegmentMaker - std::vector<const Muon::MuonSegment*>* find( const Trk::TrackRoad &, - const std::vector< std::vector< const Muon::MdtDriftCircleOnTrack* > > &, - const std::vector< std::vector< const Muon::MuonClusterOnTrack* > > & , - bool, double) const ; - std::vector<const Muon::MuonSegment*>* find( const Amg::Vector3D&, const Amg::Vector3D&, - const std::vector< const Muon::MdtDriftCircleOnTrack* > &, - const std::vector< const Muon::MuonClusterOnTrack* > & , - bool, double) const; - - std::vector<const Muon::MuonSegment*>* find( const std::vector<const Trk::RIO_OnTrack*>& /*rios*/ ) const; - std::vector<const Muon::MuonSegment*>* find( const std::vector<const Trk::RIO_OnTrack*>& /*rios1*/, - const std::vector<const Trk::RIO_OnTrack*>& /*rios2*/ ) const ; - std::vector<const Muon::MuonSegment*>* find( const std::vector<const Muon::MdtDriftCircleOnTrack*>& /*mdts*/, - const std::vector<const Muon::MuonClusterOnTrack*>& /*clusters*/) const; - + std::unique_ptr<MuonSegmentCombinationCollection> find( const MuonSegmentCombinationCollection& ) const ; + std::unique_ptr<MuonSegmentCombinationCollection> find( const std::vector<const Muon::CscPrepDataCollection*>& pcols) const; //not used here private: // data diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentMaker.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentMaker.cxx index 829d5d29c614bc1175e96fa259a3305eade6c0a1..faad123911ff0c7c8a6070b16e810b4db725f358 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentMaker.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentMaker.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "CscSegmentMaker.h" @@ -49,8 +49,8 @@ CscSegmentMaker(const std::string& aname, ISvcLocator* pSvcLocator) m_dumped(0), m_dump(false), m_2dseg_finder(""), m_4dseg_finder(""), - m_psegs(0), - m_psegs4d(0) + m_psegs(std::unique_ptr<MuonSegmentCombinationCollection>()), + m_psegs4d(std::unique_ptr<MuonSegmentCombinationCollection>()) { declareProperty("dump_count", m_dumpcount =5); declareProperty("sg_inkey", m_sg_inkey = ""); @@ -131,23 +131,21 @@ StatusCode CscSegmentMaker::execute(){ ATH_MSG_ERROR ( " Failed to build segments " ); } - sc = evtStore()->record(m_psegs, m_sg_outkey); + sc = evtStore()->record(m_psegs.release(), m_sg_outkey); if (sc.isFailure()) { ATH_MSG_ERROR ( " Cannot record CSC segment collection " << m_sg_outkey ); } else { if ( m_dump ) ATH_MSG_DEBUG ( " Created " << m_psegs->size() << " 2D segments and " ); } - m_psegs =0; - sc = evtStore()->record(m_psegs4d, m_sg_4d_outkey); + sc = evtStore()->record(m_psegs4d.release(), m_sg_4d_outkey); if (sc.isFailure()) { ATH_MSG_ERROR ( " Cannot record CSC segment collection " << m_sg_4d_outkey ); } else { if ( m_dump ) ATH_MSG_DEBUG ( m_psegs4d->size() << " 4D segments." ); } - m_psegs4d =0; return StatusCode::SUCCESS; @@ -177,14 +175,8 @@ StatusCode CscSegmentMaker::build_segments() { if (m_psegs) { if (m_psegs->size() > 1) { m_psegs4d = m_4dseg_finder->find(*m_psegs); - } else { - m_psegs4d = new MuonSegmentCombinationCollection; } - } else { - m_psegs4d = new MuonSegmentCombinationCollection; - m_psegs = new MuonSegmentCombinationCollection; // needs to make a memory allocation for moore.. } - } return StatusCode::SUCCESS; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentMaker.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentMaker.h index c05f3ac921c3e74210b84dda69b609aacc01f046..639661ada01dbc714a0417f84baa7565ade6e2b8 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentMaker.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentMaker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // Csc2dSegmentMaker.h @@ -63,8 +63,8 @@ private: // data ToolHandle<ICscSegmentFinder> m_4dseg_finder; // Output container. - MuonSegmentCombinationCollection* m_psegs; - MuonSegmentCombinationCollection* m_psegs4d; + std::unique_ptr<MuonSegmentCombinationCollection> m_psegs; + std::unique_ptr<MuonSegmentCombinationCollection> m_psegs4d; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentUtilTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentUtilTool.cxx index 5471e54d5bebc3dacf49005454e7dd0d0d003513..33929ae26cbed3fc4d8a621253b122c3be5e247b 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentUtilTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentUtilTool.cxx @@ -188,7 +188,7 @@ StatusCode CscSegmentUtilTool::initialize() /////////////////// //Note: this code was required for old MuGirl but is not used by the current reconstruction //Leaving it in place for backwards compatibility -std::vector<const MuonSegment*>* CscSegmentUtilTool:: +std::unique_ptr<std::vector<std::unique_ptr<MuonSegment> > > CscSegmentUtilTool:: getMuonSegments(Identifier eta_id, Identifier phi_id, ICscSegmentFinder::ChamberTrkClusters& eta_clus, ICscSegmentFinder::ChamberTrkClusters& phi_clus, @@ -196,7 +196,7 @@ getMuonSegments(Identifier eta_id, Identifier phi_id, if (! enoughHitLayers(eta_clus, phi_clus) ) { ATH_MSG_DEBUG (" Could not find at least two individual layer hits! "); - std::vector<const MuonSegment*>* segments = 0; + std::unique_ptr<std::vector< std::unique_ptr<MuonSegment> > > segments; return segments; } @@ -204,14 +204,11 @@ getMuonSegments(Identifier eta_id, Identifier phi_id, ATH_MSG_DEBUG ( "getMuonSegments2: No of clusters in layer " << i << " " << eta_clus[i].size() << " " << phi_clus[i].size() ); ATH_MSG_DEBUG ("getMuonSegments called get2dMuonSegmentCombination"); - MuonSegmentCombination* Muon2dSegComb - = get2dMuonSegmentCombination(eta_id, phi_id, eta_clus, phi_clus, lpos000); + std::unique_ptr<MuonSegmentCombination> Muon2dSegComb(get2dMuonSegmentCombination(eta_id, phi_id, eta_clus, phi_clus, lpos000)); ATH_MSG_DEBUG ("getMuonSegments called get4dMuonSegmentCombination"); - MuonSegmentCombination* Muon4dSegComb - = get4dMuonSegmentCombination(Muon2dSegComb); + std::unique_ptr<MuonSegmentCombination> Muon4dSegComb(get4dMuonSegmentCombination(Muon2dSegComb.get())); - delete Muon2dSegComb; // delete 4dMuonSegComb; WP careful... // Add the case for only 2d segments following the idea below ?? @@ -224,19 +221,17 @@ getMuonSegments(Identifier eta_id, Identifier phi_id, return segments; } */ - std::vector<const MuonSegment*>* segments_clone = 0; + std::unique_ptr<std::vector<std::unique_ptr<MuonSegment> > > segments_clone (new std::vector<std::unique_ptr<MuonSegment> >); if (Muon4dSegComb) { - const std::vector<const MuonSegment*>* segments = Muon4dSegComb->stationSegments(0); + std::vector<std::unique_ptr<MuonSegment> >* segments = Muon4dSegComb->stationSegments(0); if (!segments->empty()) { - segments_clone = new std::vector<const MuonSegment*>; for (unsigned int i=0; i<segments->size(); ++i){ - segments_clone->push_back( (*segments)[i]->clone()); + segments_clone->push_back(std::move(segments->at(i))); } } - - delete Muon4dSegComb; + } return segments_clone; @@ -272,29 +267,29 @@ get2dMuonSegmentCombination( Identifier eta_id, Identifier phi_id, // get2dSegments does : find_2dsegments -> find_2dseg3hit -> add_2dsegments get2dSegments(eta_id, phi_id, eta_clus, phi_clus, eta_segs, phi_segs, lpos000, etaStat, phiStat); - MuonSegmentCombination::SegmentVec* psegs = new MuonSegmentCombination::SegmentVec; + std::unique_ptr<MuonSegmentCombination::SegmentVec> psegs (new MuonSegmentCombination::SegmentVec); for ( ICscSegmentFinder::Segments::const_iterator iseg=eta_segs.begin(); iseg!=eta_segs.end(); ++iseg ) { - MuonSegment* pseg = build_segment(*iseg, false, eta_id, nGoodEta==2); // build_segment does getRios + std::unique_ptr<MuonSegment> pseg(build_segment(*iseg, false, eta_id, nGoodEta==2)); // build_segment does getRios if (pseg) { - psegs->push_back(pseg); + psegs->push_back(std::move(pseg)); ATH_MSG_DEBUG( " =============================> get2dMuonSegmentCombination:: MuonSegment time (eta) from build_segment is " << pseg->time() ); // pseg->dump(cout); } } - pcol->addSegments(psegs); + pcol->addSegments(std::move(psegs)); ATH_MSG_DEBUG("added "<<psegs->size()<<" eta segments"); // Insert phi-segments. - psegs = new MuonSegmentCombination::SegmentVec; + std::unique_ptr<MuonSegmentCombination::SegmentVec> phisegs(new MuonSegmentCombination::SegmentVec); for ( ICscSegmentFinder::Segments::const_iterator iseg=phi_segs.begin(); iseg!=phi_segs.end(); ++iseg ) { - MuonSegment* pseg = build_segment(*iseg, true, phi_id, nGoodPhi==2); + std::unique_ptr<MuonSegment> pseg(build_segment(*iseg, true, phi_id, nGoodPhi==2)); if (pseg) { - psegs->push_back(pseg); + phisegs->push_back(std::move(pseg)); ATH_MSG_DEBUG( " get2dMuonSegmentCombination:: MuonSegment time (phi) from build_segment is " << pseg->time() ); } } - pcol->addSegments(psegs); - ATH_MSG_DEBUG("added "<<psegs->size()<<" phi segments"); + pcol->addSegments(std::move(phisegs)); + ATH_MSG_DEBUG("added "<<phisegs->size()<<" phi segments"); // Add to SG container. ATH_MSG_DEBUG ( "Added " << eta_segs.size() << " r-segments and " @@ -1839,7 +1834,7 @@ get4dMuonSegmentCombination( const MuonSegmentCombination* insegs ) const { SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfo); - ICscSegmentFinder::SegmentVec* pnewsegs = new ICscSegmentFinder::SegmentVec; + std::unique_ptr<ICscSegmentFinder::SegmentVec> pnewsegs(new ICscSegmentFinder::SegmentVec); if(insegs->useStripsInSegment(1) && insegs->useStripsInSegment(0)){ for ( ICscSegmentFinder::SegmentVec::const_iterator irsg=rsegs.begin(); irsg!=rsegs.end(); ++irsg ) { @@ -1877,10 +1872,10 @@ get4dMuonSegmentCombination( const MuonSegmentCombination* insegs ) const { continue; } //if don't use phi, make segments from eta only; if don't use eta, make segments from phi only; else make segments from both - MuonSegment* pseg=make_4dMuonSegment(rsg, psg, insegs->use2LayerSegments(1), insegs->use2LayerSegments(0)); + std::unique_ptr<MuonSegment> pseg(make_4dMuonSegment(rsg, psg, insegs->use2LayerSegments(1), insegs->use2LayerSegments(0))); if( pseg ){ ATH_MSG_DEBUG("created new 4d segment"); - pnewsegs->push_back(pseg); + pnewsegs->push_back(std::move(pseg)); } } // for phisegs } // for rsegs @@ -1894,9 +1889,9 @@ get4dMuonSegmentCombination( const MuonSegmentCombination* insegs ) const { ATH_MSG_DEBUG("only "<<rsg.containedROTs().size()<<", RIO's, insufficient to build the 4d segment from a single eta segment"); continue; } - MuonSegment* pseg=new MuonSegment(rsg); + std::unique_ptr<MuonSegment> pseg(new MuonSegment(rsg)); ATH_MSG_DEBUG("created new 4d segment from eta hits only"); - pnewsegs->push_back(pseg); + pnewsegs->push_back(std::move(pseg)); } } else if(!insegs->useStripsInSegment(1)){ @@ -1908,21 +1903,19 @@ get4dMuonSegmentCombination( const MuonSegmentCombination* insegs ) const { ATH_MSG_DEBUG("only "<<psg.containedROTs().size()<<", RIO's, insufficient to build the 4d segment from a single phi segment"); continue; } - MuonSegment* pseg=new MuonSegment(psg); + std::unique_ptr<MuonSegment> pseg(new MuonSegment(psg)); ATH_MSG_DEBUG("created new 4d segment from phi hits only"); - pnewsegs->push_back(pseg); + pnewsegs->push_back(std::move(pseg)); } } if (pnewsegs->empty()) { - delete pnewsegs; - pnewsegs=0; return pcol; } else ATH_MSG_DEBUG("created "<<pnewsegs->size()<<" new 4d segments"); pcol =new MuonSegmentCombination; - pcol->addSegments(pnewsegs); + pcol->addSegments(std::move(pnewsegs)); return pcol; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentUtilTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentUtilTool.h index 4aee3db63ec47f37030e7efdae599e488fd19919..b4d10378cc06f1a1a92a8e4b77143cbc926c44b4 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentUtilTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers/src/CscSegmentUtilTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef CscSegmentUtilTool_H @@ -52,7 +52,7 @@ public: // calls get2dMuonSegmentCombination and get4dMuonSegmentCombination with 2d segments!! - std::vector<const Muon::MuonSegment*>* + std::unique_ptr<std::vector<std::unique_ptr<Muon::MuonSegment> > > getMuonSegments(Identifier eta_id, Identifier phi_id, ICscSegmentFinder::ChamberTrkClusters& eta_clus, ICscSegmentFinder::ChamberTrkClusters& phi_clus, diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx index 51538e0f7e73d7e4671e4409e0e1ce2235a6cfaf..9180ce34ff8b905c6a6050680316c7f7acb63139 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "DCMathSegmentMaker.h" @@ -93,13 +93,6 @@ namespace Muon { m_segmentFitter("Muon::MuonSegmentFittingTool/MuonSegmentFittingTool"), m_segmentSelectionTool("Muon::MuonSegmentSelectionTool/MuonSegmentSelectionTool"), m_dcslFitProvider(""), - m_multiGeo(0), - m_dcslFitter(0), - m_phimin(0.), - m_phimax(0.), - m_refit(false), - m_isEndcap(false), - m_nmultipleHitWarnings(0), m_rpcKey("RPC_Measurements"), m_tgcKey("TGC_Measurements"), m_mdtKey("MDT_DriftCircles") @@ -179,7 +172,6 @@ namespace Muon { if( !m_dcslFitProvider.empty() ){ ATH_CHECK( m_dcslFitProvider.retrieve() ); - m_dcslFitter = m_dcslFitProvider->getFitter(); ATH_MSG_INFO(" Using " << m_dcslFitProvider); } @@ -203,11 +195,6 @@ namespace Muon { StatusCode DCMathSegmentMaker::finalize() { - // delete member pointers - for(std::vector<const Trk::MeasurementBase*>::iterator it=m_measurementsToBeDeleted.begin(); it!=m_measurementsToBeDeleted.end(); it++) - delete (*it); - m_measurementsToBeDeleted.clear(); - return StatusCode::SUCCESS; } @@ -225,11 +212,36 @@ namespace Muon { if( mdt ) mdts.push_back(mdt); } + // global to local transformation for chamber + Amg::Transform3D gToStation = seg.associatedSurface().transform().inverse(); + + // set to get Identifiers of chambers with hits + std::set<Identifier> chamberSet; + for( std::vector<const MdtDriftCircleOnTrack*>::const_iterator it=mdts.begin();it!=mdts.end();++it){ + Identifier dcid = (*it)->identify(); + Identifier elId = m_idHelperTool->mdtIdHelper().elementID( dcid ); + chamberSet.insert(elId); + } + std::unique_ptr<TrkDriftCircleMath::MdtMultiChamberGeometry> multiGeo; + if( m_doGeometry ) { + // vector to store chamber geometries + std::vector<TrkDriftCircleMath::MdtChamberGeometry> geos; + + // loop over chambers + std::set<Identifier>::iterator it = chamberSet.begin(); + std::set<Identifier>::iterator it_end = chamberSet.end(); + for( ;it!=it_end;++it ){ + geos.push_back( createChamberGeometry( *it, gToStation ) ); + } + + // create new geometry + multiGeo = std::unique_ptr<TrkDriftCircleMath::MdtMultiChamberGeometry>(new TrkDriftCircleMath::MdtMultiChamberGeometry(geos)); + } + if( mdts.size() < 2 )return 0; const MdtDriftCircleOnTrack* firstRot = findFirstRotInChamberWithMostHits(mdts); if( !firstRot ) { - if( m_nmultipleHitWarnings < 3 ) ATH_MSG_WARNING(" no Mdt selected, returning 0 "); return 0; } @@ -244,34 +256,34 @@ namespace Muon { Identifier chid = firstRot->identify(); // endcap or barrel - m_isEndcap = m_idHelperTool->mdtIdHelper().isEndcap(chid); - - // global to local transformation for chamber - m_gToStation = seg.associatedSurface().transform().inverse(); + bool isEndcap = m_idHelperTool->mdtIdHelper().isEndcap(chid); // define axis of chamber in global coordinates - m_amdbToGlobal = seg.associatedSurface().transform(); + Amg::Transform3D amdbToGlobal = seg.associatedSurface().transform(); std::vector<const MuonClusterOnTrack*> clusters = clus; + std::vector<const Trk::MeasurementBase*> measToBeDeleted; // if requested, retrieve trigger eta hits if( includeEtaHits ) { - addEtaHits(clusters); + measToBeDeleted=addEtaHits(clusters,isEndcap); ATH_MSG_DEBUG("adding eta hits: original clusters " << clus.size() << " extended " << clusters.size() ); } /* ***** create cluster hits ******** */ - TrkDriftCircleMath::CLVec cls = createClusterVec( clusters, chid ); + ClusterVecPair spVecs; + if( m_doSpacePoints ) spVecs = create2DClusters( clusters ); + else spVecs = create1DClusters( clusters ); + TrkDriftCircleMath::CLVec cls = createClusterVec( chid, spVecs.first, gToStation ); /* ***** create MDT hits ************ */ ATH_MSG_DEBUG(" adding mdts " << mdts.size()); TrkDriftCircleMath::DCOnTrackVec dcs; // reset chamber statistics - m_dcStatistics.clear(); bool firstMdt = true; - m_phimin = 9999.; - m_phimax = -9999.; + double phimin = 9999.; + double phimax = -9999.; unsigned index = 0; std::vector<const Trk::MeasurementBase*>::const_iterator it = seg.containedMeasurements().begin(); std::vector<const Trk::MeasurementBase*>::const_iterator it_end = seg.containedMeasurements().end(); @@ -285,7 +297,7 @@ namespace Muon { Identifier id = mdt->identify(); // calculate local AMDB position - Amg::Vector3D locPos = m_gToStation*mdt->prepRawData()->globalPosition(); + Amg::Vector3D locPos = gToStation*mdt->prepRawData()->globalPosition(); TrkDriftCircleMath::LocPos lpos(locPos.y(),locPos.z()); double r = mdt->localParameters()[Trk::locR]; @@ -300,13 +312,13 @@ namespace Muon { TrkDriftCircleMath::DCOnTrack dcOnTrack(dc,1.,1.); ATH_MSG_VERBOSE(" new MDT hit " << m_idHelperTool->toString( id ) << " x " << lpos.x() << " y " << lpos.y() ); - TubeEnds tubeEnds = localTubeEnds(*mdt,m_gToStation,m_amdbToGlobal); + TubeEnds tubeEnds = localTubeEnds(*mdt,gToStation,amdbToGlobal); if( firstMdt ){ - m_phimin = tubeEnds.phimin; - m_phimax = tubeEnds.phimax; + phimin = tubeEnds.phimin; + phimax = tubeEnds.phimax; firstMdt = false; }else{ - updatePhiRanges(tubeEnds.phimin,tubeEnds.phimax,m_phimin,m_phimax); + updatePhiRanges(tubeEnds.phimin,tubeEnds.phimax,phimin,phimax); } dcs.push_back( dcOnTrack ); @@ -316,7 +328,7 @@ namespace Muon { // create line double angleYZ = seg.localDirection().angleYZ(); - const Amg::Vector3D lpos = m_gToStation*seg.globalPosition(); + const Amg::Vector3D lpos = gToStation*seg.globalPosition(); TrkDriftCircleMath::LocPos segPos(lpos.y(),lpos.z()); TrkDriftCircleMath::Line segPars(segPos,angleYZ); @@ -329,35 +341,37 @@ namespace Muon { segment.clusters(cls); segment.hitsOnTrack(6); // hack just putting a number above the cut of at least 2 - MuonSegment* newSeg = createSegment(segment,chid,seg.globalPosition(),seg.globalDirection(),mdts,true); - for(std::vector<const Trk::MeasurementBase*>::iterator it=m_measurementsToBeDeleted.begin(); it!=m_measurementsToBeDeleted.end(); it++) + segmentCreationInfo sInfo(spVecs,multiGeo.get(),gToStation,amdbToGlobal,phimin,phimax); + MuonSegment* newSeg = createSegment(segment,chid,seg.globalPosition(),seg.globalDirection(),mdts,true,sInfo); + for(std::vector<const Trk::MeasurementBase*>::iterator it=measToBeDeleted.begin(); it!=measToBeDeleted.end(); it++) delete (*it); - m_measurementsToBeDeleted.clear(); + measToBeDeleted.clear(); return newSeg; } - void DCMathSegmentMaker::addEtaHits( std::vector<const MuonClusterOnTrack*>& clusters ) const { + std::vector<const Trk::MeasurementBase*> DCMathSegmentMaker::addEtaHits( std::vector<const MuonClusterOnTrack*>& clusters, bool isEndcap ) const { std::set<IdentifierHash> chIdHs; + std::vector<const Trk::MeasurementBase*> measurementsToBeDeleted; std::vector<const MuonClusterOnTrack*>::iterator cit = clusters.begin(); std::vector<const MuonClusterOnTrack*>::iterator cit_end = clusters.end(); for( ;cit!=cit_end;++cit ) chIdHs.insert((*cit)->collectionHash()); ATH_MSG_VERBOSE("Number of collections " << chIdHs.size() ); - if( m_isEndcap ){ + if( isEndcap ){ const Muon::TgcPrepDataContainer* prdContainer = 0; SG::ReadHandle<Muon::TgcPrepDataContainer> TgcCont(m_tgcKey); if( !TgcCont.isValid() ) { ATH_MSG_WARNING("Cannot retrieve TgcPrepDataContainer "); - return; + return measurementsToBeDeleted; } else { prdContainer = TgcCont.cptr(); } if(!prdContainer){ ATH_MSG_WARNING("No TGC prd container retrieved"); - return; + return measurementsToBeDeleted; } // loop over chambers and get collections @@ -381,7 +395,7 @@ namespace Muon { if( clus ) { ATH_MSG_VERBOSE(" adding hit: " << m_idHelperTool->toString(clus->identify()) ); clusters.push_back(clus); - m_measurementsToBeDeleted.push_back(clus); + measurementsToBeDeleted.push_back(clus); } } } @@ -391,14 +405,14 @@ namespace Muon { SG::ReadHandle<Muon::RpcPrepDataContainer> RpcCont(m_rpcKey); if(!RpcCont.isValid()){ ATH_MSG_WARNING("Cannot retrieve RpcPrepDataContainer "); - return; + return measurementsToBeDeleted; } else{ prdContainer = RpcCont.cptr(); } if(!prdContainer){ ATH_MSG_WARNING("No RPC prd container retrieved"); - return; + return measurementsToBeDeleted; } // loop over chambers and get collections @@ -417,59 +431,59 @@ namespace Muon { const MuonClusterOnTrack* clus = m_clusterCreator->createRIO_OnTrack(**hit,(*hit)->globalPosition()); if( clus ) { clusters.push_back(clus); - m_measurementsToBeDeleted.push_back(clus); + measurementsToBeDeleted.push_back(clus); } } } } + return measurementsToBeDeleted; } - std::vector<const MuonSegment*>* DCMathSegmentMaker::find( const Amg::Vector3D& roadpos, const Amg::Vector3D& roaddir, - const std::vector<const MdtDriftCircleOnTrack*>& mdts, - const std::vector<const MuonClusterOnTrack*>& clusters, - bool hasPhiMeasurements, double momentum) const + void DCMathSegmentMaker::find( const Amg::Vector3D& roadpos, const Amg::Vector3D& roaddir, + const std::vector<const MdtDriftCircleOnTrack*>& mdts, + const std::vector<const MuonClusterOnTrack*>& clusters, + bool hasPhiMeasurements, Trk::SegmentCollection* segColl, double momentum, double sinAngleCut) const { if (m_doTimeOutChecks && Athena::Timeout::instance().reached() ) { ATH_MSG_DEBUG("Timeout reached. Aborting sequence."); - return 0; + return; } ATH_MSG_DEBUG("In find, passed "<<mdts.size() <<" RIO_OnTracks"); - if( mdts.size() < 3 )return 0; + if( mdts.size() < 3 ) return; const MdtDriftCircleOnTrack* firstRot = findFirstRotInChamberWithMostHits(mdts); if( !firstRot ) { - if( m_nmultipleHitWarnings < 3 ) ATH_MSG_WARNING(" no Mdt selected, returning 0 "); - return 0; + return; } const MuonGM::MdtReadoutElement* detEl = firstRot->detectorElement(); if( !detEl ) { ATH_MSG_WARNING(" no MdtReadoutElement found, returning 0 "); - return 0; + return; } // identifier Identifier chid = firstRot->identify(); // endcap or barrel - m_isEndcap = m_idHelperTool->mdtIdHelper().isEndcap(chid); + bool isEndcap = m_idHelperTool->mdtIdHelper().isEndcap(chid); // global to local transformation for chamber - m_gToStation = detEl->GlobalToAmdbLRSTransform(); + Amg::Transform3D gToStation = detEl->GlobalToAmdbLRSTransform(); // define axis of chamber in global coordinates - m_amdbToGlobal = detEl->AmdbLRSToGlobalTransform(); + Amg::Transform3D amdbToGlobal = detEl->AmdbLRSToGlobalTransform(); // transform nominal pointing chamber position into surface frame Amg::Vector3D globalDirCh = Amg::Vector3D(detEl->center().x(),detEl->center().y(),detEl->center().z()); - Amg::Vector3D dirCh(m_gToStation.linear()*globalDirCh); + Amg::Vector3D dirCh(gToStation.linear()*globalDirCh); double chamber_angleYZ = atan2(dirCh.z(),dirCh.y()); Amg::Vector3D roaddir2=roaddir; @@ -477,13 +491,13 @@ namespace Muon { if (dotprod<0) roaddir2=-roaddir2; // transform the global direction into the surface frame - Amg::Vector3D d(m_gToStation.linear()*roaddir2); + Amg::Vector3D d(gToStation.linear()*roaddir2); // calculate the local road angles in the surface frame double road_angleXZ = atan2(d.z(),d.x()); double road_angleYZ = atan2(d.z(),d.y()); if( !hasPhiMeasurements ) road_angleXZ = acos(0.); // if no phi, take phi perpendicular to plane - ATH_MSG_VERBOSE("global road dir " << Amg::toString(roaddir2) << " XZ " << road_angleXZ << " YZ " << road_angleYZ << " isEndcap " << m_isEndcap + ATH_MSG_VERBOSE("global road dir " << Amg::toString(roaddir2) << " XZ " << road_angleXZ << " YZ " << road_angleYZ << " isEndcap " << isEndcap << " central phi " << detEl->center().phi() << " r " << detEl->center().perp() << " z " << detEl->center().z() ); // rescale errors for low momentum @@ -492,65 +506,81 @@ namespace Muon { /* ***** create cluster hits ******** */ ATH_MSG_DEBUG(" adding clusters " << clusters.size()); - TrkDriftCircleMath::CLVec cls = createClusterVec( clusters, chid ); + ClusterVecPair spVecs; + if( m_doSpacePoints ) spVecs = create2DClusters( clusters ); + else spVecs = create1DClusters( clusters ); + TrkDriftCircleMath::CLVec cls = createClusterVec( chid, spVecs.first, gToStation ); /* ***** create MDT hits ************ */ ATH_MSG_DEBUG(" adding mdts " << mdts.size()); - TrkDriftCircleMath::DCVec dcs = createDCVec( mdts, errorScale ); + // set to get Identifiers of chambers with hits + std::set<Identifier> chamberSet; + double phimin=-9999,phimax=9999; + TrkDriftCircleMath::DCStatistics dcStatistics; // statistics on chamber occupancy + TrkDriftCircleMath::DCVec dcs = createDCVec( mdts, errorScale, chamberSet, phimin, phimax, dcStatistics, gToStation, amdbToGlobal ); - TrkDriftCircleMath::Road road(TrkDriftCircleMath::LocPos(0.,0.),road_angleYZ,chamber_angleYZ,m_sinAngleCut); + //create geometry + std::unique_ptr<TrkDriftCircleMath::MdtMultiChamberGeometry> multiGeo; + if( m_doGeometry ) { + + ATH_MSG_VERBOSE(" using chamber geometry with #chambers " << chamberSet.size()); + + // vector to store chamber geometries + std::vector<TrkDriftCircleMath::MdtChamberGeometry> geos; + + // loop over chambers + std::set<Identifier>::iterator it = chamberSet.begin(); + std::set<Identifier>::iterator it_end = chamberSet.end(); + for( ;it!=it_end;++it ){ + + // this does not work yet.... + // get geometry of chamber + //const Muon::MuonIntersectGeometry* intersectGeometry = m_intersectSvc->getChamberGeometry( *it ); + + //const MdtIntersectGeometry* mdtGeo = dynamic_cast<const MdtIntersectGeometry*>(intersectGeometry); + //if( !mdtGeo ) continue; + //geos.push_back( *mdtGeo->mdtChamberGeometry() ); + + geos.push_back( createChamberGeometry( *it, gToStation ) ); + } + + // create new geometry + multiGeo = std::unique_ptr<TrkDriftCircleMath::MdtMultiChamberGeometry>( new TrkDriftCircleMath::MdtMultiChamberGeometry(geos) ); + } + + double angle=m_sinAngleCut; + if(sinAngleCut>0) angle=sinAngleCut; + TrkDriftCircleMath::Road road(TrkDriftCircleMath::LocPos(0.,0.),road_angleYZ,chamber_angleYZ,angle); // call segment finder - TrkDriftCircleMath::SegVec segs = m_segmentFinder->findSegments(dcs,cls,road,m_dcStatistics,m_multiGeo); + TrkDriftCircleMath::SegVec segs = m_segmentFinder->findSegments(dcs,cls,road,dcStatistics,multiGeo.get()); ATH_MSG_DEBUG("Found " << segs.size() <<" segments"); - // clean up and return + // return if( segs.empty() ) { - delete m_multiGeo; - m_multiGeo = 0; - for(std::vector<const Trk::MeasurementBase*>::iterator it=m_measurementsToBeDeleted.begin(); it!=m_measurementsToBeDeleted.end(); it++) - delete (*it); - m_measurementsToBeDeleted.clear(); - return 0; + return; } - /* **** convert found segment into MuonSegments ***** */ - - std::vector<const MuonSegment*>* segments = new std::vector<const MuonSegment*>(); - segments->reserve( segs.size() ); - - // loop over segments TrkDriftCircleMath::SegIt sit = segs.begin(); TrkDriftCircleMath::SegIt sit_end = segs.end(); + segmentCreationInfo sInfo(spVecs,multiGeo.get(),gToStation,amdbToGlobal,phimin,phimax); for( ;sit!=sit_end;++sit ){ - MuonSegment* segment = createSegment(*sit,chid,roadpos,roaddir2,mdts,hasPhiMeasurements); - if( segment ) segments->push_back( segment ); + MuonSegment* segment = createSegment(*sit,chid,roadpos,roaddir2,mdts,hasPhiMeasurements,sInfo); + if( segment ) segColl->push_back(segment); } ATH_MSG_DEBUG(" Done "); - delete m_multiGeo; - m_multiGeo = 0; - - for(std::vector<const Trk::MeasurementBase*>::iterator it=m_measurementsToBeDeleted.begin(); it!=m_measurementsToBeDeleted.end(); it++) - delete (*it); - m_measurementsToBeDeleted.clear(); - - if( segments->empty() ){ - delete segments; - return 0; - } - - return segments; } MuonSegment* DCMathSegmentMaker::createSegment( TrkDriftCircleMath::Segment& segment, const Identifier& chid, const Amg::Vector3D& roadpos, const Amg::Vector3D& roaddir2, const std::vector<const MdtDriftCircleOnTrack*>& mdts, - bool hasPhiMeasurements ) const { + bool hasPhiMeasurements, segmentCreationInfo& sInfo) const { + bool isEndcap = m_idHelperTool->isEndcap(chid); //find all curved segments bool isCurvedSegment(false); MuonStationIndex::ChIndex chIndex = m_idHelperTool->chamberIndex(chid); @@ -573,8 +603,8 @@ namespace Muon { << " associated clusters " << segment.clusters().size()); // local position along x from road - Amg::Vector3D lroadpos = m_gToStation*roadpos; - Amg::Vector3D lroaddir = m_gToStation.linear()*roaddir2; + Amg::Vector3D lroadpos = sInfo.globalTrans*roadpos; + Amg::Vector3D lroaddir = sInfo.globalTrans.linear()*roaddir2; // local x position of first tube used if no phi measurement is present double lxroad = 0.; @@ -586,7 +616,7 @@ namespace Muon { double sphi = 0.; double cphi = lroaddir.x(); // swap local y and z in the endcaps - if ( m_isEndcap ) { + if ( isEndcap ) { sphi = lroaddir.y(); lxroad = lroadpos.x()+(-lroadpos.y()+line.position().x())*cphi/sphi; }else{ @@ -614,17 +644,17 @@ namespace Muon { lxroad = shortestTubeLen; } }else{ - lxroad = (m_gToStation*mdts[0]->prepRawData()->detectorElement()->surface(mdts[0]->identify()).center()).x(); + lxroad = (sInfo.globalTrans*mdts[0]->prepRawData()->detectorElement()->surface(mdts[0]->identify()).center()).x(); } // calculate local direction vector Amg::Vector3D lpos( lxroad,line.position().x(),line.position().y() ); // global position segment - Amg::Vector3D gpos = m_amdbToGlobal*lpos; + Amg::Vector3D gpos = sInfo.amdbTrans*lpos; // create new surface - Amg::Transform3D* surfaceTransform = new Amg::Transform3D(m_amdbToGlobal.rotation()); + Amg::Transform3D* surfaceTransform = new Amg::Transform3D(sInfo.amdbTrans.rotation()); surfaceTransform->pretranslate(gpos); double surfDim = 500.; Trk::PlaneSurface* surf = new Trk::PlaneSurface( surfaceTransform, surfDim, surfDim ); @@ -637,29 +667,34 @@ namespace Muon { Amg::Vector3D gdir = updateDirection( linephi, *surf, roaddir2, isCurvedSegment ); // extract RIO_OnTracks - m_rioDistVec.clear(); + std::vector<std::pair<double,const Trk::MeasurementBase*> > rioDistVec; //vector to store the distance of a ROT to the segment // associate MDT hits to segment - associateMDTsToSegment( gdir, segment, mdts ); + std::set<Identifier> deltaVec; + std::set<Identifier> outoftimeVec; + std::vector<const Trk::MeasurementBase*> measToBeDeleted=associateMDTsToSegment( gdir, segment, mdts, sInfo.geom, sInfo.globalTrans, sInfo.amdbTrans, deltaVec, outoftimeVec, rioDistVec ); + + TrkDriftCircleMath::DCSLHitSelector hitSelector; if( m_redo2DFit && !isCurvedSegment ){ // refit segment after recalibration - bool goodFit = m_defaultFitter.fit( line, segment.dcs(), m_hitSelector.selectHitsOnTrack(segment.dcs()) ); + TrkDriftCircleMath::DCSLFitter defaultFitter; + bool goodFit = defaultFitter.fit( line, segment.dcs(), hitSelector.selectHitsOnTrack(segment.dcs()) ); if( goodFit ){ - if( fabs(segment.line().phi() - m_defaultFitter.result().line().phi()) > 0.01 || - fabs(segment.line().x0() - m_defaultFitter.result().line().x0()) > 0.01 || - fabs(segment.line().y0() - m_defaultFitter.result().line().y0()) > 0.01 ) { + if( fabs(segment.line().phi() - defaultFitter.result().line().phi()) > 0.01 || + fabs(segment.line().x0() - defaultFitter.result().line().x0()) > 0.01 || + fabs(segment.line().y0() - defaultFitter.result().line().y0()) > 0.01 ) { // update local position and global - linephi = m_defaultFitter.result().line().phi(); - lpos[1] = m_defaultFitter.result().line().position().x() ; - lpos[2] = m_defaultFitter.result().line().position().y() ; - gpos = m_amdbToGlobal*lpos; + linephi = defaultFitter.result().line().phi(); + lpos[1] = defaultFitter.result().line().position().x() ; + lpos[2] = defaultFitter.result().line().position().y() ; + gpos = sInfo.amdbTrans*lpos; // recreate surface delete surf; - surfaceTransform = new Amg::Transform3D(m_amdbToGlobal.rotation()); + surfaceTransform = new Amg::Transform3D(sInfo.amdbTrans.rotation()); surfaceTransform->pretranslate(gpos); surf = new Trk::PlaneSurface( surfaceTransform, surfDim, surfDim ); @@ -681,18 +716,18 @@ namespace Muon { << " gdir " << gdir.phi() << " lphi " << linephi << " seg " << segLocDir.angleYZ() ); } - // associate Clusters to segment, uses m_spVec and m_phiVec to get clusters - std::pair<int,int> netaPhiHits = associateClustersToSegment( segment, chid ); + // associate Clusters to segment, uses spVecs to get clusters + std::pair<std::pair<int,int>,bool> netaPhiHits = associateClustersToSegment( segment, chid, sInfo.globalTrans, sInfo.clusters, sInfo.phimin, sInfo.phimax, rioDistVec ); // copy hits into vector - DataVector<const Trk::MeasurementBase>* rioVec = createROTVec(); + DataVector<const Trk::MeasurementBase>* rioVec = createROTVec(rioDistVec); double dlocx = 1000.; double dangleXZ = 1000.; double qoverp = -99999.; double dqoverp = -99999.; bool hasMeasuredCoordinate = false; - if( m_refitParameters && m_refit ){ + if( m_refitParameters && netaPhiHits.second ){ ATH_MSG_DEBUG(" distance between first and last phi hit sufficient to perform 4D fit: phi " << gdir.phi() << " theta " << gdir.theta()); @@ -722,7 +757,7 @@ namespace Muon { if( track->measurementsOnTrack() && rioVec->size() != track->measurementsOnTrack()->size() ){ ATH_MSG_DEBUG(" ROT vector size changed after fit, updating "); delete rioVec; - m_rioDistVec.clear(); + rioDistVec.clear(); rioVec = new DataVector<const Trk::MeasurementBase>(); rioVec->reserve(track->measurementsOnTrack()->size()); DataVector<const Trk::TrackStateOnSurface>::const_iterator tsit = track->trackStateOnSurfaces()->begin(); @@ -742,20 +777,20 @@ namespace Muon { const Trk::MeasurementBase* measNew = meas->clone(); rioVec->push_back( measNew ); double dist = (pars->position()-firstPars->position()).dot(firstPars->momentum().unit()); - m_rioDistVec.push_back( std::make_pair(dist,measNew) ); + rioDistVec.push_back( std::make_pair(dist,measNew) ); } } delete track; }else { ATH_MSG_DEBUG(" refit of segment failed!! "); - m_refit = false; + netaPhiHits.second = false; } } // optional update of phi position and direction, only performed if the segment was not refitted and there are phi hits - if( m_updatePhiUsingPhiHits && !m_refit ){ - if( updateSegmentPhi( gpos, gdir, segLocPos, segLocDir, *surf, rioVec->stdcont() ) ){ + if( m_updatePhiUsingPhiHits && !netaPhiHits.second ){ + if( updateSegmentPhi( gpos, gdir, segLocPos, segLocDir, *surf, rioVec->stdcont(), sInfo.phimin, sInfo.phimax ) ){ surf->localToGlobal(segLocPos,gpos,gpos); surf->localToGlobalDirection(segLocDir,gdir); hasMeasuredCoordinate = true; @@ -766,8 +801,8 @@ namespace Muon { if( msgLvl(MSG::DEBUG) ){ - ATH_MSG_DEBUG(" number of hits " << rioVec->size() << " of which trigger " << netaPhiHits.first - << " eta and " << netaPhiHits.second << " phi "); + ATH_MSG_DEBUG(" number of hits " << rioVec->size() << " of which trigger " << netaPhiHits.first.first + << " eta and " << netaPhiHits.first.second << " phi "); DataVector<const Trk::MeasurementBase>::const_iterator mit = rioVec->begin(); DataVector<const Trk::MeasurementBase>::const_iterator mit_end = rioVec->end(); for( ;mit!=mit_end;++mit ){ @@ -790,19 +825,20 @@ namespace Muon { } } // recalculate holes - - calculateHoles( chid, gpos, gdir, hasMeasuredCoordinate ); + std::vector<Identifier> holeVec=calculateHoles( chid, gpos, gdir, hasMeasuredCoordinate, deltaVec, outoftimeVec, rioDistVec ); // currently not taking into account masked channels - m_holeVec.insert(m_holeVec.end(),m_outoftimeVec.begin(),m_outoftimeVec.end()); - MuonSegmentQuality* quality = new MuonSegmentQuality( segment.chi2(), segment.ndof(), m_holeVec ); + if(!outoftimeVec.empty()) holeVec.insert(holeVec.end(),outoftimeVec.begin(),outoftimeVec.end()); + MuonSegmentQuality* quality = new MuonSegmentQuality( segment.chi2(), segment.ndof(), holeVec ); + + TrkDriftCircleMath::DCSLFitter* dcslFitter = m_dcslFitProvider->getFitter(); - if( m_dcslFitter && !segment.hasT0Shift() && m_outputFittedT0 ){ - if( !m_dcslFitter->fit( segment.line(), segment.dcs(), m_hitSelector.selectHitsOnTrack( segment.dcs() ) ) ) { + if( dcslFitter && !segment.hasT0Shift() && m_outputFittedT0 ){ + if( !dcslFitter->fit( segment.line(), segment.dcs(), hitSelector.selectHitsOnTrack( segment.dcs() ) ) ) { ATH_MSG_DEBUG( " T0 refit failed "); }else{ if( msgLvl(MSG::DEBUG) ) { - if( m_dcslFitter->result().hasT0Shift() ) ATH_MSG_DEBUG(" Fitted T0 " << m_dcslFitter->result().t0Shift()); + if( dcslFitter->result().hasT0Shift() ) ATH_MSG_DEBUG(" Fitted T0 " << dcslFitter->result().t0Shift()); else ATH_MSG_DEBUG(" No fitted T0 "); } } @@ -810,14 +846,14 @@ namespace Muon { bool hasFittedT0 = false; double fittedT0 = 0; double errorFittedT0 = 1.; - if( m_outputFittedT0 && ( segment.hasT0Shift() || ( m_dcslFitter && m_dcslFitter->result().hasT0Shift() ) ) ){ + if( m_outputFittedT0 && ( segment.hasT0Shift() || ( dcslFitter && dcslFitter->result().hasT0Shift() ) ) ){ hasFittedT0 = true; if( segment.hasT0Shift() ){ fittedT0 = segment.t0Shift(); errorFittedT0 = segment.t0Error(); - }else if( m_dcslFitter && m_dcslFitter->result().hasT0Shift() ) { - fittedT0 = m_dcslFitter->result().t0Shift(); - errorFittedT0 = m_dcslFitter->result().t0Error(); + }else if( dcslFitter && dcslFitter->result().hasT0Shift() ) { + fittedT0 = dcslFitter->result().t0Shift(); + errorFittedT0 = dcslFitter->result().t0Error(); }else{ ATH_MSG_WARNING(" Failed to access fitted t0 "); hasFittedT0 = false; @@ -892,11 +928,14 @@ namespace Muon { delete msegment; msegment = 0; } + for(std::vector<const Trk::MeasurementBase*>::iterator it=measToBeDeleted.begin(); it!=measToBeDeleted.end(); it++) + delete (*it); + measToBeDeleted.clear(); return msegment; } - std::vector<const MuonSegment*>* DCMathSegmentMaker::find( const std::vector<const Trk::RIO_OnTrack*>& rios) const + void DCMathSegmentMaker::find( const std::vector<const Trk::RIO_OnTrack*>& rios, Trk::SegmentCollection* segColl) const { std::vector<const MdtDriftCircleOnTrack*> mdts; std::vector<const MuonClusterOnTrack*> clusters; @@ -920,40 +959,43 @@ namespace Muon { clusters.push_back(clus); } } - return find(mdts,clusters); + find(mdts,clusters,segColl); } - std::vector<const MuonSegment*>* DCMathSegmentMaker::find( const std::vector<const MdtDriftCircleOnTrack*>& mdts, - const std::vector<const MuonClusterOnTrack*>& clusters) const + void DCMathSegmentMaker::find( const std::vector<const MdtDriftCircleOnTrack*>& mdts, + const std::vector<const MuonClusterOnTrack*>& clusters, + Trk::SegmentCollection* segColl) const { - if( mdts.empty() ) return 0; + if( mdts.empty() ) return; const MdtDriftCircleOnTrack* mdt = mdts.front(); - if( !mdt ) return 0; + if( !mdt ) return; bool hasPhiMeasurements = false; Amg::Vector3D gpos = mdt->globalPosition(); Amg::Vector3D gdir = Amg::Vector3D(gpos.x(),gpos.y(),gpos.z()).unit(); - return find( gpos, - gdir, - mdts, - clusters, - hasPhiMeasurements ); + find( gpos, + gdir, + mdts, + clusters, + hasPhiMeasurements, + segColl); } - std::vector<const MuonSegment*>* DCMathSegmentMaker::find( const std::vector<const Trk::RIO_OnTrack*>& rios1, - const std::vector<const Trk::RIO_OnTrack*>& rios2 ) const + void DCMathSegmentMaker::find( const std::vector<const Trk::RIO_OnTrack*>& rios1, + const std::vector<const Trk::RIO_OnTrack*>& rios2 ) const { std::vector<const Trk::RIO_OnTrack*> rios = rios1; rios.insert( rios.end(), rios2.begin(), rios2.end() ); - return find(rios); + find(rios); } - std::vector<const MuonSegment*>* DCMathSegmentMaker::find( const Trk::TrackRoad& road, - const std::vector< std::vector< const MdtDriftCircleOnTrack* > >& mdts, - const std::vector< std::vector< const MuonClusterOnTrack* > >& clusters, - bool hasPhiMeasurements, double momentum ) const + void DCMathSegmentMaker::find( const Trk::TrackRoad& road, + const std::vector< std::vector< const MdtDriftCircleOnTrack* > >& mdts, + const std::vector< std::vector< const MuonClusterOnTrack* > >& clusters, + Trk::SegmentCollection* segColl, + bool hasPhiMeasurements, double momentum ) const { // copy all mdt hits into one vector std::vector< const MdtDriftCircleOnTrack* > all_mdts; @@ -971,21 +1013,17 @@ namespace Muon { std::copy( cit->begin(), cit->end(), std::back_inserter(all_clus) ); } - // set angle cut from road, keep old value - double sinAngleCut = m_sinAngleCut; - // FIXME - probably need to change interface to pass in sinAngleCut. EJWM. - m_sinAngleCut = road.deltaEta(); - const Amg::Vector3D& gpos = road.globalPosition(); const Amg::Vector3D& gdir = road.globalDirection(); - std::vector<const MuonSegment*>* segments = find( gpos, - gdir, - all_mdts, - all_clus, - hasPhiMeasurements, - momentum ); - m_sinAngleCut = sinAngleCut; - return segments; + find( gpos, + gdir, + all_mdts, + all_clus, + hasPhiMeasurements, + segColl, + momentum, + road.deltaEta()); + } @@ -1030,8 +1068,9 @@ namespace Muon { // simple division of MuonSpectrometer in regions using barrel/endcap seperation plus // inner/middle/outer seperation + bool isEndcap = m_idHelperTool->isEndcap(id); - if( m_isEndcap ){ + if( isEndcap ){ std::string stName = m_idHelperTool->mdtIdHelper().stationNameString(m_idHelperTool->mdtIdHelper().stationName(id) ); if( stName[1] == 'I' ) return true; @@ -1045,15 +1084,16 @@ namespace Muon { } - DCMathSegmentMaker::ClusterVec DCMathSegmentMaker::create1DClusters( const std::vector<const MuonClusterOnTrack*>& clusters ) const + DCMathSegmentMaker::ClusterVecPair DCMathSegmentMaker::create1DClusters( const std::vector<const MuonClusterOnTrack*>& clusters ) const { // if empty return - if( clusters.empty() ) return ClusterVec(); + if( clusters.empty() ) return ClusterVecPair(); // some useful typedefs... typedef std::vector<const MuonClusterOnTrack*>::const_iterator ROTCit; // create a vector to hold the clusters ClusterVec clVec; + ClusterVec phiVec; clVec.reserve(clusters.size()); ROTCit cit = clusters.begin(); @@ -1064,22 +1104,22 @@ namespace Muon { int measuresPhi = m_idHelperTool->measuresPhi(id); if( measuresPhi ) { - m_phiVec.push_back( createSpacePoint( gasGapId, 0, *cit ) ); - if( m_phiVec.back().corrupt() ) m_phiVec.pop_back(); + phiVec.push_back( createSpacePoint( gasGapId, 0, *cit ) ); + if( phiVec.back().corrupt() ) phiVec.pop_back(); }else{ clVec.push_back( createSpacePoint( gasGapId, *cit, 0 ) ); if( clVec.back().corrupt() ) clVec.pop_back(); } } - return clVec; + return ClusterVecPair(clVec,phiVec); } - DCMathSegmentMaker::ClusterVec DCMathSegmentMaker::create2DClusters( const std::vector<const MuonClusterOnTrack*>& clusters ) const + DCMathSegmentMaker::ClusterVecPair DCMathSegmentMaker::create2DClusters( const std::vector<const MuonClusterOnTrack*>& clusters ) const { // if empty return - if( clusters.empty() ) return ClusterVec(); + if( clusters.empty() ) return ClusterVecPair(); ChIdHitMap gasGapHitMap; @@ -1143,11 +1183,12 @@ namespace Muon { } } - DCMathSegmentMaker::ClusterVec DCMathSegmentMaker::createSpacePoints( DCMathSegmentMaker::ChIdHitMap& chIdHitMap ) const { + DCMathSegmentMaker::ClusterVecPair DCMathSegmentMaker::createSpacePoints( DCMathSegmentMaker::ChIdHitMap& chIdHitMap ) const { // vector to store output - ClusterVec clusters; - clusters.reserve(20); + ClusterVecPair clusterVecs; + clusterVecs.first.reserve(20); + clusterVecs.second.reserve(20); // loop over chambers ChIdHitMapIt cit = chIdHitMap.begin(); @@ -1155,18 +1196,21 @@ namespace Muon { for( ;cit!=cit_end;++cit ){ // create clusters per chamber and copy them in to result vector - ClusterVec cls = createSpacePoints( cit->second ); - std::copy( cls.begin(), cls.end(), std::back_inserter(clusters) ); + ClusterVecPair cls = createSpacePoints( cit->second ); + std::copy( cls.first.begin(), cls.first.end(), std::back_inserter(clusterVecs.first) ); + std::copy( cls.second.begin(), cls.second.end(), std::back_inserter(clusterVecs.second) ); //handleChamber( cit->second ); } - return clusters; + return clusterVecs; } - DCMathSegmentMaker::ClusterVec DCMathSegmentMaker::createSpacePoints( DCMathSegmentMaker::IdHitMap& gasGapHitMap ) const { + DCMathSegmentMaker::ClusterVecPair DCMathSegmentMaker::createSpacePoints( DCMathSegmentMaker::IdHitMap& gasGapHitMap ) const { ClusterVec spacePoints; + ClusterVec phiVec; + bool isEndcap=m_idHelperTool->isEndcap((*(gasGapHitMap.begin())).first); ATH_MSG_VERBOSE(" creating Space points for " << gasGapHitMap.size() << " gas gaps "); @@ -1194,7 +1238,7 @@ namespace Muon { if( m_debugSpacePoints ) ATH_MSG_VERBOSE(" Eta hit " << m_idHelperTool->toString((*etaIt)->identify())); - if( m_isEndcap ) { + if( isEndcap ) { // check whether match with phi hits was found bool foundSP = false; @@ -1235,8 +1279,8 @@ namespace Muon { } } - if( m_isEndcap ){ - // loop over flag vector and add unmatched phi hits to m_phiVec; + if( isEndcap ){ + // loop over flag vector and add unmatched phi hits to phiVec; Identifier prevPhiId; for( unsigned int i=0;i<flagPhihit.size();++i ){ if( flagPhihit[i] ) continue; @@ -1247,14 +1291,14 @@ namespace Muon { Cluster2D sp = createTgcSpacePoint( git->first, 0, git->second.second[i] ); if( sp.corrupt() ) continue; - m_phiVec.push_back( sp ); + phiVec.push_back( sp ); } }else if( git->second.first.empty() && !git->second.second.empty() ) { // if there were no eta hits create one phi spacePoint of all phi hits in gasgap Cluster2D sp = createRpcSpacePoint( git->first, 0, git->second.second ); if( sp.corrupt() ) continue; - m_phiVec.push_back( sp ); + phiVec.push_back( sp ); } } @@ -1262,12 +1306,13 @@ namespace Muon { ATH_MSG_VERBOSE(" Creating space points, number of gas-gaps " << gasGapHitMap.size() << " space points " << spacePoints.size()); - return spacePoints; + return ClusterVecPair(spacePoints,phiVec); } DCMathSegmentMaker::Cluster2D DCMathSegmentMaker::createSpacePoint( const Identifier& gasGapId, const MuonClusterOnTrack* etaHit, const MuonClusterOnTrack* phiHit ) const { + bool isEndcap=m_idHelperTool->isEndcap(gasGapId); double error(1.); double lpx(0.); double lpy(0.); @@ -1279,7 +1324,7 @@ namespace Muon { lpx = etaHit->localParameters()[Trk::locX]; error = Amg::error(etaHit->localCovariance(),Trk::locX); }else if( etaHit && phiHit ) { - if( m_isEndcap ){ + if( isEndcap ){ return createTgcSpacePoint( gasGapId,etaHit,phiHit ); }else{ std::vector<const MuonClusterOnTrack*> phiVec; @@ -1434,21 +1479,17 @@ namespace Muon { } - TrkDriftCircleMath::CLVec DCMathSegmentMaker::createClusterVec( const std::vector<const MuonClusterOnTrack*>& clusters, const Identifier& chid ) const { + TrkDriftCircleMath::CLVec DCMathSegmentMaker::createClusterVec( const Identifier& chid, ClusterVec& spVec, Amg::Transform3D gToStation ) const { TrkDriftCircleMath::CLVec cls; - m_spVec.clear(); - m_phiVec.clear(); - if( m_doSpacePoints ) m_spVec = create2DClusters( clusters ); - else m_spVec = create1DClusters( clusters ); int chPhi = m_idHelperTool->mdtIdHelper().stationPhi(chid); // loop over clusters - ClusterIt cit=m_spVec.begin(); - ClusterIt cit_end=m_spVec.end(); + ClusterIt cit=spVec.begin(); + ClusterIt cit_end=spVec.end(); int index = 0; - cls.reserve(m_spVec.size()); + cls.reserve(spVec.size()); for( ; cit!=cit_end;++cit ){ const MuonClusterOnTrack* meas = cit->etaHit ? cit->etaHit : cit->phiHit; @@ -1469,7 +1510,7 @@ namespace Muon { TrkDriftCircleMath::ClusterId clid( name,eta,phi,isTgc,measuresPhi ); // calculate local cluster position - Amg::Vector3D locPos = m_gToStation*cit->globalPos; + Amg::Vector3D locPos = gToStation*cit->globalPos; TrkDriftCircleMath::LocPos lp(locPos.y(),locPos.z()); if( fabs(lp.y()) > m_maxAssociateClusterDistance ) { @@ -1490,7 +1531,9 @@ namespace Muon { - TrkDriftCircleMath::DCVec DCMathSegmentMaker::createDCVec( const std::vector<const MdtDriftCircleOnTrack*>& mdts, double errorScale ) const { + TrkDriftCircleMath::DCVec DCMathSegmentMaker::createDCVec( const std::vector<const MdtDriftCircleOnTrack*>& mdts, double errorScale, std::set<Identifier>& chamberSet, + double phimin, double phimax, TrkDriftCircleMath::DCStatistics& dcStatistics, + Amg::Transform3D gToStation, Amg::Transform3D amdbToGlobal) const { TrkDriftCircleMath::DCVec dcs; /* ******** Mdt hits ******** */ @@ -1499,16 +1542,8 @@ namespace Muon { // typedef GeoMap::iterator GeoIt; // GeoMap geoMap; - // reset chamber statistics - m_dcStatistics.clear(); bool firstMdt = true; - m_phimin = 9999.; - m_phimax = -9999.; - // set to get Identifiers of chambers with hits - std::set<Identifier> chamberSet; - - unsigned index = 0; for( std::vector<const MdtDriftCircleOnTrack*>::const_iterator it=mdts.begin();it!=mdts.end();++it){ @@ -1531,7 +1566,7 @@ namespace Muon { // calculate local AMDB position - Amg::Vector3D locPos = m_gToStation*rot->prepRawData()->globalPosition(); + Amg::Vector3D locPos = gToStation*rot->prepRawData()->globalPosition(); TrkDriftCircleMath::LocPos lpos(locPos.y(),locPos.z()); double r = rot->localParameters()[Trk::locR]; @@ -1551,13 +1586,13 @@ namespace Muon { - TubeEnds tubeEnds = localTubeEnds(*rot,m_gToStation,m_amdbToGlobal); + TubeEnds tubeEnds = localTubeEnds(*rot,gToStation,amdbToGlobal); if( firstMdt ){ - m_phimin = tubeEnds.phimin; - m_phimax = tubeEnds.phimax; + phimin = tubeEnds.phimin; + phimax = tubeEnds.phimax; firstMdt = false; }else{ - updatePhiRanges(tubeEnds.phimin,tubeEnds.phimax,m_phimin,m_phimax); + updatePhiRanges(tubeEnds.phimin,tubeEnds.phimax,phimin,phimax); } if( msgLvl(MSG::VERBOSE) ) { @@ -1570,41 +1605,12 @@ namespace Muon { chamberSet.insert(elId); - ++m_dcStatistics[detEl]; + ++dcStatistics[detEl]; ++index; } - if( m_doGeometry ) { - - ATH_MSG_VERBOSE(" using chamber geometry with #chambers " << chamberSet.size()); - - // set to remove duplicate geometry descriptions, will happen if hits in multiple chambers are present - std::set<const Muon::MuonIntersectGeometry*> geoSet; - - // vector to store chamber geometries - std::vector<TrkDriftCircleMath::MdtChamberGeometry> geos; - - // loop over chambers - std::set<Identifier>::iterator it = chamberSet.begin(); - std::set<Identifier>::iterator it_end = chamberSet.end(); - for( ;it!=it_end;++it ){ - - // this does not work yet.... - // get geometry of chamber - //const Muon::MuonIntersectGeometry* intersectGeometry = m_intersectSvc->getChamberGeometry( *it ); - - //const MdtIntersectGeometry* mdtGeo = dynamic_cast<const MdtIntersectGeometry*>(intersectGeometry); - //if( !mdtGeo ) continue; - //geos.push_back( *mdtGeo->mdtChamberGeometry() ); - - geos.push_back( createChamberGeometry( *it, m_gToStation ) ); - } - - // create new geometry - m_multiGeo = new TrkDriftCircleMath::MdtMultiChamberGeometry( geos ); - } return dcs; } @@ -1683,12 +1689,15 @@ namespace Muon { } - void DCMathSegmentMaker::associateMDTsToSegment( const Amg::Vector3D& gdir, TrkDriftCircleMath::Segment& segment, - const std::vector<const MdtDriftCircleOnTrack*>& mdts ) const { + std::vector<const Trk::MeasurementBase*> DCMathSegmentMaker::associateMDTsToSegment( const Amg::Vector3D& gdir, TrkDriftCircleMath::Segment& segment, + const std::vector<const MdtDriftCircleOnTrack*>& mdts, + TrkDriftCircleMath::MdtMultiChamberGeometry* multiGeo, + Amg::Transform3D gToStation, Amg::Transform3D amdbToGlobal, + std::set<Identifier>& deltaVec, std::set<Identifier>& outoftimeVec, + std::vector<std::pair<double,const Trk::MeasurementBase*> >& rioDistVec) const { // clear result vectors - m_deltaVec.clear(); - m_outoftimeVec.clear(); + std::vector<const Trk::MeasurementBase*> measurementsToBeDeleted; // convert segment parameters + x position from road const TrkDriftCircleMath::Line& line = segment.line(); @@ -1699,8 +1708,8 @@ namespace Muon { double ml2phi = line.phi() - segment.deltaAlpha(); TrkDriftCircleMath::LocDir ml2dir(cos(ml2phi),sin(ml2phi)); //ml2 segment position - const TrkDriftCircleMath::LocPos ml1LocPos = m_multiGeo->tubePosition(0,m_multiGeo->nlay(),0); - const TrkDriftCircleMath::LocPos ml2LocPos = m_multiGeo->tubePosition(1,1,0); + const TrkDriftCircleMath::LocPos ml1LocPos = multiGeo->tubePosition(0,multiGeo->nlay(),0); + const TrkDriftCircleMath::LocPos ml2LocPos = multiGeo->tubePosition(1,1,0); double chamberMidPtY = (ml1LocPos.y() + ml2LocPos.y())/2.0; TrkDriftCircleMath::LocPos ml2pos(segment.deltab(),chamberMidPtY); //construct the new ml2 segment line & transform @@ -1714,11 +1723,11 @@ namespace Muon { for( TrkDriftCircleMath::DCOnTrackIt dcit = segment.dcs().begin();dcit!=segment.dcs().end();++dcit ){ if( dcit->state() == TrkDriftCircleMath::DCOnTrack::Delta ) { - m_deltaVec.insert( mdts[dcit->index()]->identify() ); + deltaVec.insert( mdts[dcit->index()]->identify() ); } if( dcit->state() == TrkDriftCircleMath::DCOnTrack::OutOfTime ){ - m_outoftimeVec.insert( mdts[dcit->index()]->identify() ); + outoftimeVec.insert( mdts[dcit->index()]->identify() ); } if( dcit->state() != TrkDriftCircleMath::DCOnTrack::OnTrack ) continue; @@ -1740,14 +1749,14 @@ namespace Muon { TrkDriftCircleMath::LocPos pointOnLineAMDB = toLine.toLocal( pointOnLine ); // get position along wire from ROT - Amg::Vector3D posAlong = m_gToStation*riodc->globalPosition(); + Amg::Vector3D posAlong = gToStation*riodc->globalPosition(); // set yz components posAlong[1] = pointOnLineAMDB.x(); posAlong[2] = pointOnLineAMDB.y(); // back to global - Amg::Vector3D mdtGP = m_amdbToGlobal*posAlong; + Amg::Vector3D mdtGP = amdbToGlobal*posAlong; const Trk::StraightLineSurface* surf = dynamic_cast<const Trk::StraightLineSurface*>( &riodc->associatedSurface() ); if( ! surf ){ @@ -1780,7 +1789,7 @@ namespace Muon { // update the drift radius after recalibration, keep error MdtDriftCircleOnTrack *new_drift_circle=new MdtDriftCircleOnTrack(*constDC); - m_measurementsToBeDeleted.push_back(new_drift_circle); + measurementsToBeDeleted.push_back(new_drift_circle); TrkDriftCircleMath::DriftCircle new_dc(dcit->position(), fabs(constDC->driftRadius()), dcit->dr(), dcit->drPrecise(), static_cast<TrkDriftCircleMath::DriftCircle *>(&(*dcit))->state() , dcit->id(), dcit->index(),new_drift_circle); @@ -1801,9 +1810,9 @@ namespace Muon { } m_mdtCreator->updateSign( *dcOn, side ); double dist = pointOnHit.x(); - m_rioDistVec.push_back( std::make_pair(dist,dcOn) ); + rioDistVec.push_back( std::make_pair(dist,dcOn) ); } - ATH_MSG_DEBUG(" Segment phi range: min " << m_phimin << " max " << m_phimax); + return measurementsToBeDeleted; } @@ -1852,35 +1861,38 @@ namespace Muon { } }; - std::pair<int,int> DCMathSegmentMaker::associateClustersToSegment( const TrkDriftCircleMath::Segment& segment, const Identifier& chid ) const { + std::pair<std::pair<int,int>,bool> DCMathSegmentMaker::associateClustersToSegment( const TrkDriftCircleMath::Segment& segment, const Identifier& chid, + Amg::Transform3D gToStation, ClusterVecPair& spVecs, double phimin, double phimax, + std::vector<std::pair<double,const Trk::MeasurementBase*> >& rioDistVec ) const { typedef IdDataVec<std::pair<double,Cluster2D> > GasGapData; typedef IdDataVec<GasGapData> ChamberData; typedef std::vector<ChamberData> ChamberDataVec; typedef ChamberDataVec::iterator ChamberDataIt; ChamberDataVec chamberDataVec; + bool isEndcap=m_idHelperTool->isEndcap(chid); // keep track of the number of eta/phi hits on the segment - m_refit = false; - std::pair<int,int> netaPhiHits(0,0); + bool refit = false; + std::pair<std::pair<int,int>,bool> netaPhiHits(std::pair<int,int>(0,0),false); if( segment.clusters().empty() ) return netaPhiHits; std::vector<const Trk::MeasurementBase*> phiHits; // only refit if there are sufficient phi hits and no multiple phi hits per surface - m_refit = true; + refit = true; // keep track of detector elements which space points added to the track std::set<Identifier> detElOnSegments; std::set<MuonStationIndex::PhiIndex> phiIndices; - ATH_MSG_DEBUG(" Associating clusters: " << segment.clusters().size() << " number of space points " << m_spVec.size()); + ATH_MSG_DEBUG(" Associating clusters: " << segment.clusters().size() << " number of space points " << spVecs.first.size()); // associate space points and sort them per detector element and gas gap for( TrkDriftCircleMath::CLCit ccit = segment.clusters().begin();ccit!=segment.clusters().end();++ccit ){ ATH_MSG_VERBOSE(" accessing cluster: " << ccit->index()); - const Cluster2D& spacePoint = m_spVec[ccit->index()]; + const Cluster2D& spacePoint = spVecs.first[ccit->index()]; // skip corrupt space points if( spacePoint.corrupt() ) { @@ -1892,13 +1904,13 @@ namespace Muon { ATH_MSG_DEBUG(" Rejecting 1D tgc space point " << m_idHelperTool->toString(spacePoint.identify())); continue; } - if( m_assumePointingPhi && spacePoint.is2D() && !checkPhiConsistency(spacePoint.globalPos.phi()) ){ + if( m_assumePointingPhi && spacePoint.is2D() && !checkPhiConsistency(spacePoint.globalPos.phi(), phimin, phimax) ){ ATH_MSG_DEBUG(" Inconsistent phi angle, dropping space point: phi " << spacePoint.globalPos.phi() - << " range " << m_phimin << " " << m_phimax); + << " range " << phimin << " " << phimax); continue; } - std::pair<double,double> resPull = residualAndPullWithSegment( segment, spacePoint ); + std::pair<double,double> resPull = residualAndPullWithSegment( segment, spacePoint, gToStation ); // if empty or new chamber, add chamber if( chamberDataVec.empty() || chamberDataVec.back().id != spacePoint.detElId ){ @@ -1957,7 +1969,7 @@ namespace Muon { Cluster2D& sp = clit->second; // calculate distance to segment - double dist = distanceToSegment( segment, sp.globalPos ); + double dist = distanceToSegment( segment, sp.globalPos, gToStation ); ATH_MSG_VERBOSE(" selected space point: " << m_idHelperTool->toString( sp.identify() ) << " pull " << fabs(clit->first) << " distance to segment " << dist << " phi " << sp.globalPos.phi()); @@ -1969,8 +1981,8 @@ namespace Muon { if( m_createCompetingROTsEta ) etaClusterVec.push_back( sp.etaHit->prepRawData() ); else{ - m_rioDistVec.push_back( std::make_pair(dist,sp.etaHit->clone()) ); - ++netaPhiHits.first; + rioDistVec.push_back( std::make_pair(dist,sp.etaHit->clone()) ); + ++netaPhiHits.first.first; } } } @@ -1983,23 +1995,23 @@ namespace Muon { }else{ // can have multiple phi hits per cluster, loop over phi hits and add them for( std::vector<const MuonClusterOnTrack*>::iterator pit = sp.phiHits.begin();pit!=sp.phiHits.end();++pit ){ - m_rioDistVec.push_back( std::make_pair(dist,(*pit)->clone()) ); - ++netaPhiHits.second; + rioDistVec.push_back( std::make_pair(dist,(*pit)->clone()) ); + ++netaPhiHits.first.second; phiHits.push_back(*pit); // calculate position - double phiPos = m_isEndcap ? fabs( (*pit)->globalPosition().z() ) : fabs( (*pit)->globalPosition().perp() ); + double phiPos = isEndcap ? fabs( (*pit)->globalPosition().z() ) : fabs( (*pit)->globalPosition().perp() ); if( phiPos < posFirstPhiStation ) posFirstPhiStation = phiPos; if( phiPos > posLastPhiStation ) posLastPhiStation = phiPos; } - if( sp.phiHits.size() > 1 ) m_refit = false; + if( sp.phiHits.size() > 1 ) refit = false; } } ++nassociatedSp; ++clit; } // multiple clusters in same gas gap, don't refit - if( !m_createCompetingROTsPhi && nassociatedSp > 1 ) m_refit = false; + if( !m_createCompetingROTsPhi && nassociatedSp > 1 ) refit = false; } if( m_createCompetingROTsEta ){ @@ -2009,9 +2021,9 @@ namespace Muon { if( !etaCompCluster ){ ATH_MSG_DEBUG(" failed to create competing ETA ROT " << etaClusterVec.size()); }else{ - double dist = distanceToSegment( segment, etaCompCluster->globalPosition() ); - m_rioDistVec.push_back( std::make_pair(dist,etaCompCluster) ); - ++netaPhiHits.first; + double dist = distanceToSegment( segment, etaCompCluster->globalPosition(), gToStation ); + rioDistVec.push_back( std::make_pair(dist,etaCompCluster) ); + ++netaPhiHits.first.first; if( msgLvl(MSG::VERBOSE) ){ msg(MSG::VERBOSE) << " selected cluster: " << m_idHelperTool->toString( etaClusterVec.front()->identify() ) << endmsg; @@ -2030,10 +2042,10 @@ namespace Muon { if( !phiCompCluster ) { ATH_MSG_DEBUG(" failed to create competing PHI ROT " << phiClusterVec.size()); }else{ - double dist = distanceToSegment( segment, phiCompCluster->globalPosition() ); - m_rioDistVec.push_back( std::make_pair(dist,phiCompCluster) ); + double dist = distanceToSegment( segment, phiCompCluster->globalPosition(), gToStation ); + rioDistVec.push_back( std::make_pair(dist,phiCompCluster) ); phiHits.push_back(phiCompCluster); - ++netaPhiHits.second; + ++netaPhiHits.first.second; if( msgLvl(MSG::VERBOSE) ){ msg(MSG::VERBOSE) << " selected cluster: " << m_idHelperTool->toString( phiClusterVec.front()->identify() ) << endmsg; @@ -2043,7 +2055,7 @@ namespace Muon { } // calculate position - double phiPos = m_isEndcap ? fabs( phiCompCluster->globalPosition().z() ) : fabs( phiCompCluster->globalPosition().perp() ); + double phiPos = isEndcap ? fabs( phiCompCluster->globalPosition().z() ) : fabs( phiCompCluster->globalPosition().perp() ); if( phiPos < posFirstPhiStation ) posFirstPhiStation = phiPos; if( phiPos > posLastPhiStation ) posLastPhiStation = phiPos; } @@ -2052,7 +2064,7 @@ namespace Muon { } // add phi hits that were not associated with an eta hit (only in barrel) - if( (!m_phiVec.empty()||m_recoverBadRpcCabling) && m_addUnassociatedPhiHits && !m_idHelperTool->isEndcap(chid) ) { + if( (!spVecs.second.empty()||m_recoverBadRpcCabling) && m_addUnassociatedPhiHits && !isEndcap ) { TrkDriftCircleMath::ResidualWithSegment resWithSegment(segment); @@ -2060,11 +2072,11 @@ namespace Muon { std::set<const MuonClusterOnTrack*> selectedClusters; std::vector<Cluster2D*> phiClusters; - phiClusters.reserve(m_phiVec.size()); + phiClusters.reserve(spVecs.second.size()); // create lists of PrepRawData per detector element - ClusterIt pit = m_phiVec.begin(); - ClusterIt pit_end = m_phiVec.end(); + ClusterIt pit = spVecs.second.begin(); + ClusterIt pit_end = spVecs.second.end(); for( ;pit!=pit_end;++pit ){ if( !pit->phiHit || pit->corrupt() ) { ATH_MSG_WARNING(" phi clusters without phi hit!!"); @@ -2077,8 +2089,8 @@ namespace Muon { unsigned int recoveredUnassociatedPhiHits(0); if( m_recoverBadRpcCabling ){ // now loop over 2D space points and add the phi hits to the list if the detEl is not yet added to the segment - ClusterIt spit = m_spVec.begin(); - ClusterIt spit_end = m_spVec.end(); + ClusterIt spit = spVecs.first.begin(); + ClusterIt spit_end = spVecs.first.end(); for( ;spit!=spit_end;++spit ){ // skip clusters without phi hit @@ -2129,7 +2141,7 @@ namespace Muon { if( phiIndices.count(phiIndex) ) continue; // calculate local cluster position - Amg::Vector3D locPos = m_gToStation*(*cit)->globalPos; + Amg::Vector3D locPos = gToStation*(*cit)->globalPos; // calculate intersect of segment with cluster TrkDriftCircleMath::Cluster cl(TrkDriftCircleMath::LocPos(locPos.y(),locPos.z()),1.); @@ -2175,16 +2187,16 @@ namespace Muon { if( !phiCompCluster ) { ATH_MSG_DEBUG(" failed to create competing PHI ROT " << prds.size()); }else{ - double dist = distanceToSegment( segment, phiCompCluster->globalPosition() ); + double dist = distanceToSegment( segment, phiCompCluster->globalPosition(), gToStation ); if( fabs(dist) > m_maxAssociateClusterDistance ){ delete phiCompCluster; ATH_MSG_VERBOSE(" rejected unassociated cluster: " << m_idHelperTool->toString( prds.front()->identify() ) << " distance to segment " << dist); continue; } - m_rioDistVec.push_back( std::make_pair(dist,phiCompCluster) ); + rioDistVec.push_back( std::make_pair(dist,phiCompCluster) ); phiHits.push_back(phiCompCluster); - ++netaPhiHits.second; + ++netaPhiHits.first.second; ++addedPhiHits; if( msgLvl(MSG::VERBOSE) ){ msg(MSG::VERBOSE) << " selected unassociated cluster: " << m_idHelperTool->toString( prds.front()->identify() ) << " distance to segment " << dist << endmsg; @@ -2194,19 +2206,20 @@ namespace Muon { } } } - ATH_MSG_VERBOSE("Added " << addedPhiHits << " unass phi hits out of " << m_phiVec.size() << " phi hits without eta hit and " + ATH_MSG_VERBOSE("Added " << addedPhiHits << " unass phi hits out of " << spVecs.second.size() << " phi hits without eta hit and " << recoveredUnassociatedPhiHits << " with unassociated eta hit "); } // calculate distance between first and last phi trigger hit, refit if there is a good constraint on phi double phiDistanceMax = posLastPhiStation - posFirstPhiStation; - if( m_isEndcap && phiDistanceMax < 1000. ) m_refit = false; - else if( phiDistanceMax < 400. ) m_refit = false; - + if( isEndcap && phiDistanceMax < 1000. ) refit = false; + else if( phiDistanceMax < 400. ) refit = false; + + netaPhiHits.second=refit; return netaPhiHits; } - double DCMathSegmentMaker::distanceToSegment( const TrkDriftCircleMath::Segment& segment, const Amg::Vector3D& hitPos ) const + double DCMathSegmentMaker::distanceToSegment( const TrkDriftCircleMath::Segment& segment, const Amg::Vector3D& hitPos, Amg::Transform3D gToStation ) const { const TrkDriftCircleMath::Line& line = segment.line(); @@ -2214,7 +2227,7 @@ namespace Muon { double cos_sinLine = cos( line.phi() )/sin( line.phi() ); // calculate local AMDB position - Amg::Vector3D locPos = m_gToStation*hitPos; + Amg::Vector3D locPos = gToStation*hitPos; TrkDriftCircleMath::LocPos lpos(locPos.y(),locPos.z()); @@ -2231,22 +2244,22 @@ namespace Muon { } - DataVector<const Trk::MeasurementBase>* DCMathSegmentMaker::createROTVec() const { + DataVector<const Trk::MeasurementBase>* DCMathSegmentMaker::createROTVec(std::vector<std::pair<double,const Trk::MeasurementBase*> >& rioDistVec) const { // sort hits according to they distance to the segment position - std::sort( m_rioDistVec.begin(),m_rioDistVec.end(),SortByDistanceToSegment() ); + std::sort( rioDistVec.begin(),rioDistVec.end(),SortByDistanceToSegment() ); DataVector<const Trk::MeasurementBase>* rioVec = new DataVector<const Trk::MeasurementBase>(); - rioVec->reserve(m_rioDistVec.size()); - std::vector<std::pair<double,const Trk::MeasurementBase*> >::iterator rdit = m_rioDistVec.begin(); - std::vector<std::pair<double,const Trk::MeasurementBase*> >::iterator rdit_end = m_rioDistVec.end(); + rioVec->reserve(rioDistVec.size()); + std::vector<std::pair<double,const Trk::MeasurementBase*> >::iterator rdit = rioDistVec.begin(); + std::vector<std::pair<double,const Trk::MeasurementBase*> >::iterator rdit_end = rioDistVec.end(); for( ;rdit!=rdit_end;++rdit ){ rioVec->push_back( rdit->second ); } return rioVec; } - std::pair<double,double> DCMathSegmentMaker::residualAndPullWithSegment( const TrkDriftCircleMath::Segment& segment, const Cluster2D& spacePoint ) const + std::pair<double,double> DCMathSegmentMaker::residualAndPullWithSegment( const TrkDriftCircleMath::Segment& segment, const Cluster2D& spacePoint, Amg::Transform3D gToStation ) const { const TrkDriftCircleMath::Line& line = segment.line(); double phi = line.phi(); @@ -2259,7 +2272,7 @@ namespace Muon { double cos_sinLine = cos( phi )/sin( phi ); // calculate sp postion in AMDB reference frame - Amg::Vector3D locPos = m_gToStation*spacePoint.globalPos; + Amg::Vector3D locPos = gToStation*spacePoint.globalPos; TrkDriftCircleMath::LocPos lpos(locPos.y(),locPos.z()); // calculate distance of segment to measurement surface @@ -2276,7 +2289,9 @@ namespace Muon { - void DCMathSegmentMaker::calculateHoles( Identifier chid, Amg::Vector3D gpos, Amg::Vector3D gdir, bool hasMeasuredCoordinate ) const { + std::vector<Identifier> DCMathSegmentMaker::calculateHoles( Identifier chid, Amg::Vector3D gpos, Amg::Vector3D gdir, bool hasMeasuredCoordinate, + std::set<Identifier>& deltaVec, std::set<Identifier>& outoftimeVec, + std::vector<std::pair<double,const Trk::MeasurementBase*> >& rioDistVec) const { // calculate crossed tubes const MuonStationIntersect& intersect = m_intersectSvc->tubesCrossedByTrack(chid, gpos, gdir ); @@ -2287,8 +2302,8 @@ namespace Muon { std::set<Identifier> chambersOnSegment; int firstLayer = -1; int lastLayer = -1; - std::vector<std::pair<double,const Trk::MeasurementBase*> >::iterator rdit = m_rioDistVec.begin(); - std::vector<std::pair<double,const Trk::MeasurementBase*> >::iterator rdit_end = m_rioDistVec.end(); + std::vector<std::pair<double,const Trk::MeasurementBase*> >::iterator rdit = rioDistVec.begin(); + std::vector<std::pair<double,const Trk::MeasurementBase*> >::iterator rdit_end = rioDistVec.end(); for( ;rdit!=rdit_end;++rdit ){ const MdtDriftCircleOnTrack* mdt = dynamic_cast<const MdtDriftCircleOnTrack*>(rdit->second); if( mdt ) { @@ -2311,7 +2326,7 @@ namespace Muon { if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " Tube layer ranges: " << firstLayer << " -- " << lastLayer << " crossed tubes " << intersect.tubeIntersects().size() << std::endl; // clear hole vector - m_holeVec.clear(); + std::vector<Identifier> holeVec; for( unsigned int ii=0;ii<intersect.tubeIntersects().size();++ii ){ const MuonTubeIntersect& tint = intersect.tubeIntersects()[ii]; @@ -2338,7 +2353,7 @@ namespace Muon { } // check whether there is a delta electron in this tube if( m_removeDeltas ){ - if( m_deltaVec.count( tint.tubeId ) ) { + if( deltaVec.count( tint.tubeId ) ) { if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " removing delta, distance to wire " << tint.rIntersect << " dist to tube end " << tint.xIntersect << " " << m_idHelperTool->toString(tint.tubeId) << std::endl; continue; @@ -2353,17 +2368,18 @@ namespace Muon { } if( msgLvl(MSG::VERBOSE) ) { std::string holeType = "hole "; - if( m_outoftimeVec.count(tint.tubeId) ) holeType = "Out-of-time "; + if( outoftimeVec.count(tint.tubeId) ) holeType = "Out-of-time "; msg(MSG::VERBOSE) << holeType << " distance to wire " << tint.rIntersect << " dist to tube end " << tint.xIntersect << " " << m_idHelperTool->toString(tint.tubeId); if( !notBetweenHits ) msg(MSG::VERBOSE) << " between hits"; msg(MSG::VERBOSE) << std::endl; } - m_holeVec.push_back( tint.tubeId ); + holeVec.push_back( tint.tubeId ); } } if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << endmsg; + return holeVec; } const MdtPrepData* DCMathSegmentMaker::findMdt( const Identifier& id ) const { @@ -2415,8 +2431,6 @@ namespace Muon { if( currentSector == -1 ){ currentSector = sector; }else if( sector != currentSector ){ - ++m_nmultipleHitWarnings; - if( m_nmultipleHitWarnings < 3 ) ATH_MSG_WARNING("Found multiple sectors on input, cannot process data "); return 0; } int& hitsInCh = hitsPerChamber[chId]; @@ -2531,7 +2545,8 @@ namespace Muon { bool DCMathSegmentMaker::updateSegmentPhi( const Amg::Vector3D& gpos, const Amg::Vector3D& gdir, Amg::Vector2D& segLocPos, Trk::LocalDirection& segLocDir, - Trk::PlaneSurface& surf, const std::vector<const Trk::MeasurementBase*>& rots ) const { + Trk::PlaneSurface& surf, const std::vector<const Trk::MeasurementBase*>& rots, + double seg_phimin, double seg_phimax) const { bool hasUpdated = false; @@ -2670,9 +2685,9 @@ namespace Muon { phimax = phimin; // check whether phi is consistent with segment phi range - bool phiOk = checkPhiConsistency(phimin); + bool phiOk = checkPhiConsistency(phimin,seg_phimin,seg_phimax); if( !phiOk ){ - if(msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << " Inconsistent phi " << phimin << " range " << m_phimin << " " << m_phimax << std::endl; + if(msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << " Inconsistent phi " << phimin << " range " << seg_phimin << " " << seg_phimax << std::endl; } } } @@ -2841,28 +2856,28 @@ namespace Muon { } } - bool DCMathSegmentMaker::checkPhiConsistency( double phi ) const { + bool DCMathSegmentMaker::checkPhiConsistency( double phi, double phimin, double phimax ) const { // only if assuming pointing phi if( !m_assumePointingPhi ) return true; bool phiOk = true; double offset = 0.05; - if( m_phimin*m_phimax < 0. ){ + if( phimin*phimax < 0. ){ if( phi < 0. ){ if( phi > -1.1 ){ - if( phi < m_phimin - offset ) phiOk = false; + if( phi < phimin - offset ) phiOk = false; }else{ - if( phi > m_phimin + offset ) phiOk = false; + if( phi > phimin + offset ) phiOk = false; } }else{ if( phi > 1.1 ){ - if( phi < m_phimax - offset ) phiOk = false; + if( phi < phimax - offset ) phiOk = false; }else{ - if( phi > m_phimax + offset ) phiOk = false; + if( phi > phimax + offset ) phiOk = false; } } }else{ - if( phi < m_phimin - offset || phi > m_phimax + offset ) phiOk = false; + if( phi < phimin - offset || phi > phimax + offset ) phiOk = false; } return phiOk; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.h index 90ef6160925cf48bd55e426e365828f04429086b..896f7029eefdf958420b4414962a66adc51f5c56 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef DCMATHSEGMENTMAKER_H @@ -192,6 +192,7 @@ class MdtDriftCircleOnTrack; typedef std::vector<Cluster2D> ClusterVec; typedef ClusterVec::iterator ClusterIt; typedef ClusterVec::const_iterator ClusterCit; + typedef std::pair<ClusterVec,ClusterVec> ClusterVecPair; struct TubeEnds { TubeEnds() : lxmin(0), lxmax(0), phimin(0), phimax(0) {} @@ -201,6 +202,23 @@ class MdtDriftCircleOnTrack; double phimax; }; + struct segmentCreationInfo {//miscellaneous objects needed for segment creation + segmentCreationInfo(ClusterVecPair& spVecs, TrkDriftCircleMath::MdtMultiChamberGeometry* multiGeo, Amg::Transform3D gToStation, Amg::Transform3D amdbToGlobal, double pmin, double pmax): + geom(multiGeo),phimin(pmin),phimax(pmax){ + ClusterVec spacePoints=spVecs.first; + ClusterVec phiHits=spVecs.second; + clusters=ClusterVecPair(spacePoints,phiHits); + globalTrans=gToStation; + amdbTrans=amdbToGlobal; + } + ClusterVecPair clusters; + TrkDriftCircleMath::MdtMultiChamberGeometry* geom; + Amg::Transform3D globalTrans; + Amg::Transform3D amdbTrans; + double phimin; + double phimax; + }; + public: /** default AlgTool constructor */ DCMathSegmentMaker(const std::string&,const std::string&,const IInterface*); @@ -222,7 +240,7 @@ class MdtDriftCircleOnTrack; const std::vector<const MdtDriftCircleOnTrack*>& mdts, const std::vector<const MuonClusterOnTrack*>& clusters, bool hasPhiMeasurements); */ - std::vector<const MuonSegment*>* find( const std::vector<const Trk::RIO_OnTrack*>& rios ) const ; + void find( const std::vector<const Trk::RIO_OnTrack*>& rios, Trk::SegmentCollection* segColl=nullptr ) const ; /** find segments starting from a list of RIO_OnTrack objects in multiple chambers, implementation of IMuonSegmentMaker interface routine Will call: @@ -231,8 +249,8 @@ class MdtDriftCircleOnTrack; const std::vector<const MdtDriftCircleOnTrack*>& mdts, const std::vector<const MuonClusterOnTrack*>& clusters, bool hasPhiMeasurements); */ - std::vector<const MuonSegment*>* find( const std::vector<const Trk::RIO_OnTrack*>& rios1, - const std::vector<const Trk::RIO_OnTrack*>& rios2 ) const ; + void find( const std::vector<const Trk::RIO_OnTrack*>& rios1, + const std::vector<const Trk::RIO_OnTrack*>& rios2 ) const ; /** find segments starting from: - a list of MdtDriftCircleOnTrack objects @@ -247,8 +265,9 @@ class MdtDriftCircleOnTrack; const std::vector<const MuonClusterOnTrack*>& clusters, bool hasPhiMeasurements, double momentum ); */ - std::vector<const MuonSegment*>* find(const std::vector<const MdtDriftCircleOnTrack*>& mdts, - const std::vector<const MuonClusterOnTrack*>& clusters) const ; + void find(const std::vector<const MdtDriftCircleOnTrack*>& mdts, + const std::vector<const MuonClusterOnTrack*>& clusters, + Trk::SegmentCollection* segColl=nullptr) const ; /** find segments starting from: - an estimate of the global position and direction of the particle in the chamber @@ -260,10 +279,10 @@ class MdtDriftCircleOnTrack; The global direction is used to perform a seeded search for segments. */ - std::vector<const MuonSegment*>* find( const Amg::Vector3D& gpos, const Amg::Vector3D& gdir, - const std::vector<const MdtDriftCircleOnTrack*>& mdts, - const std::vector<const MuonClusterOnTrack*>& clusters, - bool hasPhiMeasurements = false, double momentum = 1e9 ) const; + void find( const Amg::Vector3D& gpos, const Amg::Vector3D& gdir, + const std::vector<const MdtDriftCircleOnTrack*>& mdts, + const std::vector<const MuonClusterOnTrack*>& clusters, + bool hasPhiMeasurements = false, Trk::SegmentCollection* segColl=nullptr, double momentum = 1e9, double sinAngleCut=0 ) const; /** find segments starting from: - a track prediction @@ -279,10 +298,11 @@ class MdtDriftCircleOnTrack; const std::vector<const MuonClusterOnTrack*>& clusters, bool hasPhiMeasurements, double momentum ); */ - std::vector<const MuonSegment*>* find( const Trk::TrackRoad& road, - const std::vector< std::vector< const MdtDriftCircleOnTrack* > >& mdts, - const std::vector< std::vector< const MuonClusterOnTrack* > >& clusters, - bool hasPhiMeasurements = false, double momentum = 1e9) const; + void find( const Trk::TrackRoad& road, + const std::vector< std::vector< const MdtDriftCircleOnTrack* > >& mdts, + const std::vector< std::vector< const MuonClusterOnTrack* > >& clusters, + Trk::SegmentCollection* segColl, + bool hasPhiMeasurements = false, double momentum = 1e9) const; /** associate trigger hits to an existing segment @@ -307,27 +327,34 @@ class MdtDriftCircleOnTrack; /** calculate error scaling factor */ double errorScaleFactor( const Identifier& id, double curvature, bool hasPhiMeasurements ) const; - void calculateHoles( Identifier chid, Amg::Vector3D gpos, Amg::Vector3D gdir, bool hasMeasuredCoordinate ) const; + std::vector<Identifier> calculateHoles( Identifier chid, Amg::Vector3D gpos, Amg::Vector3D gdir, bool hasMeasuredCoordinate, + std::set<Identifier>& deltaVec, std::set<Identifier>& outoftimeVec, std::vector<std::pair<double,const Trk::MeasurementBase*> >& rioDistVec ) const; - TrkDriftCircleMath::DCVec createDCVec( const std::vector<const MdtDriftCircleOnTrack*>& mdts, double errorScale ) const; - ClusterVec create1DClusters( const std::vector<const MuonClusterOnTrack*>& clusters ) const; - ClusterVec create2DClusters( const std::vector<const MuonClusterOnTrack*>& clusters ) const; + TrkDriftCircleMath::DCVec createDCVec( const std::vector<const MdtDriftCircleOnTrack*>& mdts, double errorScale, std::set<Identifier>& chamberSet, + double phimin, double phimax, TrkDriftCircleMath::DCStatistics& dcStatistics, Amg::Transform3D gToStation, Amg::Transform3D amdbToGlobal ) const; + ClusterVecPair create1DClusters( const std::vector<const MuonClusterOnTrack*>& clusters ) const; + ClusterVecPair create2DClusters( const std::vector<const MuonClusterOnTrack*>& clusters ) const; void handleChamber( IdHitMap& gasGapHitMap ) const; - ClusterVec createSpacePoints( ChIdHitMap& chIdHitMap ) const; - ClusterVec createSpacePoints( IdHitMap& gasGapHitMap ) const; + ClusterVecPair createSpacePoints( ChIdHitMap& chIdHitMap ) const; + ClusterVecPair createSpacePoints( IdHitMap& gasGapHitMap ) const; Cluster2D createSpacePoint( const Identifier& gasGapId, const MuonClusterOnTrack* etaHit, const MuonClusterOnTrack* phiHit ) const; Cluster2D createRpcSpacePoint( const Identifier& gasGapId, const MuonClusterOnTrack* etaHit, const std::vector<const MuonClusterOnTrack*>& phiHits ) const; Cluster2D createTgcSpacePoint( const Identifier& gasGapId, const MuonClusterOnTrack* etaHit, const MuonClusterOnTrack* phiHit ) const; - TrkDriftCircleMath::CLVec createClusterVec( const std::vector<const MuonClusterOnTrack*>& clusters, const Identifier& chid ) const; + TrkDriftCircleMath::CLVec createClusterVec( const Identifier& chid, ClusterVec& spVec, Amg::Transform3D gToStation ) const; - void associateMDTsToSegment( const Amg::Vector3D& gdir, TrkDriftCircleMath::Segment& segment, - const std::vector<const MdtDriftCircleOnTrack*>& mdts ) const; - std::pair<int,int> associateClustersToSegment( const TrkDriftCircleMath::Segment& segment, const Identifier& chid ) const; - DataVector<const Trk::MeasurementBase>* createROTVec() const; - - double distanceToSegment( const TrkDriftCircleMath::Segment& segment, const Amg::Vector3D& hitPos ) const; - std::pair<double,double> residualAndPullWithSegment( const TrkDriftCircleMath::Segment& segment, const Cluster2D& spacePoint ) const; + std::vector<const Trk::MeasurementBase*> associateMDTsToSegment( const Amg::Vector3D& gdir, TrkDriftCircleMath::Segment& segment, + const std::vector<const MdtDriftCircleOnTrack*>& mdts, TrkDriftCircleMath::MdtMultiChamberGeometry* multiGeo, + Amg::Transform3D gToStation, Amg::Transform3D amdbToGlobal, + std::set<Identifier>& deltaVec, std::set<Identifier>& outoftimeVec, + std::vector<std::pair<double,const Trk::MeasurementBase*> >& rioDistVec ) const; + std::pair<std::pair<int,int>,bool> associateClustersToSegment( const TrkDriftCircleMath::Segment& segment, const Identifier& chid, Amg::Transform3D gToStation, + ClusterVecPair& spVecs, double phimin, double phimax, + std::vector<std::pair<double,const Trk::MeasurementBase*> >& rioDistVec) const; + DataVector<const Trk::MeasurementBase>* createROTVec(std::vector<std::pair<double,const Trk::MeasurementBase*> >& rioDistVec) const; + + double distanceToSegment( const TrkDriftCircleMath::Segment& segment, const Amg::Vector3D& hitPos, Amg::Transform3D gToStation ) const; + std::pair<double,double> residualAndPullWithSegment( const TrkDriftCircleMath::Segment& segment, const Cluster2D& spacePoint, Amg::Transform3D gToStation ) const; TrkDriftCircleMath::MdtChamberGeometry createChamberGeometry( const Identifier& chid, const Amg::Transform3D& gToStation ) const; @@ -335,7 +362,8 @@ class MdtDriftCircleOnTrack; bool updateSegmentPhi( const Amg::Vector3D& gpos, const Amg::Vector3D& gdir, Amg::Vector2D& segLocPos, Trk::LocalDirection& segLocDir, - Trk::PlaneSurface& surf, const std::vector<const Trk::MeasurementBase*>& rots ) const; + Trk::PlaneSurface& surf, const std::vector<const Trk::MeasurementBase*>& rots, + double phimin, double phimax) const; /** rotate the angle XZ until all hits are in bounds. returns a pair of bool, double, the bool is false if the code did not update the dXdZ. the double is the updated dXdZ */ @@ -351,20 +379,19 @@ class MdtDriftCircleOnTrack; void updatePhiRanges( double phiminNew, double phimaxNew, double& phiminRef, double& phimaxRef ) const; /** check whether phi is consistent with segment phi */ - bool checkPhiConsistency( double phi ) const; + bool checkPhiConsistency( double phi, double phimin, double phimax ) const; /** update the global direction, keeping the phi of the input road direction but using the local angle YZ */ Amg::Vector3D updateDirection( double linephi, const Trk::PlaneSurface& surf, const Amg::Vector3D& roaddir, bool isCurvedSegment ) const; - void addEtaHits( std::vector<const MuonClusterOnTrack*>& clusters ) const; - + std::vector<const Trk::MeasurementBase*> addEtaHits( std::vector<const MuonClusterOnTrack*>& clusters, bool isEndcap ) const; MuonSegment* createSegment( TrkDriftCircleMath::Segment& segment, const Identifier& chid, const Amg::Vector3D& roadpos, const Amg::Vector3D& roaddir2, const std::vector<const MdtDriftCircleOnTrack*>& mdts, - bool hasPhiMeasurements ) const; + bool hasPhiMeasurements, segmentCreationInfo& sInfo ) const; const MdtPrepData* findMdt( const Identifier& id ) const; @@ -386,7 +413,7 @@ class MdtDriftCircleOnTrack; ToolHandle<IMuonSegmentSelectionTool> m_segmentSelectionTool; //<! segment selection tool ToolHandle<IDCSLFitProvider> m_dcslFitProvider; - mutable double m_sinAngleCut; //<! cut on the angle between the segment and the prediction + double m_sinAngleCut; //<! cut on the angle between the segment and the prediction bool m_debugSpacePoints; //<! additional debug output for space point formation bool m_doGeometry; //<! use chamber geometry in segment finding bool m_curvedErrorScaling; //<! rescale errors for low momenta @@ -409,29 +436,6 @@ class MdtDriftCircleOnTrack; bool m_assumePointingPhi; bool m_redo2DFit; - mutable ClusterVec m_spVec; //<! vector to store space points - mutable ClusterVec m_phiVec; //<! vector to store phi clusters not used to create space points - - mutable TrkDriftCircleMath::MdtMultiChamberGeometry* m_multiGeo; //<! pointer to MDT chamber geometry - mutable TrkDriftCircleMath::DCStatistics m_dcStatistics; //<! cache statistics on chamber occupancy - mutable TrkDriftCircleMath::DCSLFitter* m_dcslFitter; //<! pointer to selected fitter - mutable TrkDriftCircleMath::DCSLFitter m_defaultFitter; //<! default fitter - mutable TrkDriftCircleMath::DCSLHitSelector m_hitSelector; //<! hit selector - - mutable double m_phimin; - mutable double m_phimax; - mutable std::set<Identifier> m_deltaVec; //<! list of tubes with a delta electron - mutable std::set<Identifier> m_outoftimeVec; //<! list of tubes with a out-of-time hit - mutable std::vector<Identifier> m_holeVec; //<! list of tubes with a hole - mutable std::vector<std::pair<double,const Trk::MeasurementBase*> > m_rioDistVec; //<! vector to store the distance of a ROT to the segment - - mutable bool m_refit; //<! if true the segment will be refitted with a 3D fit - mutable bool m_isEndcap; //<! are we in the barrel or endcap? - mutable Amg::Transform3D m_gToStation; //<! global to station transform - mutable Amg::Transform3D m_amdbToGlobal; //<! station to global transform - mutable std::vector<const Trk::MeasurementBase*> m_measurementsToBeDeleted; - mutable unsigned int m_nmultipleHitWarnings; - SG::ReadHandleKey <Muon::RpcPrepDataContainer> m_rpcKey; SG::ReadHandleKey <Muon::TgcPrepDataContainer> m_tgcKey; SG::ReadHandleKey <Muon::MdtPrepDataContainer> m_mdtKey; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.cxx index 705871a7a8a7897e260f46fed129973a8d17ef76..2b752873fe44c1e5a7e00859717336e9bba8e593 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonClusterSegmentFinderTool.h" @@ -59,20 +59,17 @@ namespace Muon { } - std::vector<const Muon::MuonSegment*>* MuonClusterSegmentFinderTool::find(std::vector< const Muon::MuonClusterOnTrack* >& muonClusters) const { - ATH_MSG_DEBUG("Entering MuonClusterSegmentFinderTool with " << muonClusters.size() << " clusters to be fit" ); - if(belowThreshold(muonClusters,4)) return 0; - std::vector<const Muon::MuonSegment*>* segs = findPrecisionSegments(muonClusters); - if(segs == 0) return 0; - if(segs->size() == 0) + void MuonClusterSegmentFinderTool::find(std::vector< const Muon::MuonClusterOnTrack* >& muonClusters, std::vector<Muon::MuonSegment*>& segments, Trk::SegmentCollection* segColl) const { + ATH_MSG_DEBUG("Entering MuonClusterSegmentFinderTool with " << muonClusters.size() << " clusters to be fit" ); + if(belowThreshold(muonClusters,4)) return; + std::vector<Muon::MuonSegment*> etaSegs; + findPrecisionSegments(muonClusters,etaSegs); + if(etaSegs.size() == 0) { - delete segs; - return 0; + return; } - std::vector<const Muon::MuonSegment*>* segments = find3DSegments(muonClusters,segs); + find3DSegments(muonClusters,etaSegs,segments,segColl); - - return segments; } StatusCode MuonClusterSegmentFinderTool::finalize() { @@ -80,17 +77,17 @@ namespace Muon { } //find the precision (eta) segments - std::vector<const Muon::MuonSegment*>* MuonClusterSegmentFinderTool::findPrecisionSegments(std::vector< const Muon::MuonClusterOnTrack* >& muonClusters) const { + void MuonClusterSegmentFinderTool::findPrecisionSegments(std::vector< const Muon::MuonClusterOnTrack* >& muonClusters, std::vector<Muon::MuonSegment*>& etaSegs) const { //clean the muon clusters -- select only the eta hits bool selectPhiHits(false); std::vector< const Muon::MuonClusterOnTrack* > clusters = cleanClusters(muonClusters,selectPhiHits); ATH_MSG_VERBOSE("After hit cleaning, there are " << clusters.size() << " 2D clusters to be fit" ); if(belowThreshold(clusters,4)){ - return 0; + return; } - TrackCollection* segTrkColl = new TrackCollection; + std::unique_ptr<TrackCollection> segTrkColl(new TrackCollection); //std::vector< const Muon::MuonClusterOnTrack* > clusters = muonClusters; //order the muon clusters by layer std::vector< std::vector<const Muon::MuonClusterOnTrack*> > orderedClusters = orderByLayer(clusters); @@ -234,15 +231,13 @@ namespace Muon { } if( segTrkColl->empty() ){ - delete segTrkColl; - return 0; + return; } - TrackCollection* resolvedTracks = m_ambiTool->process(segTrkColl); + TrackCollection* resolvedTracks = m_ambiTool->process(segTrkColl.get()); ATH_MSG_DEBUG("Resolved track candidates: old size " << segTrkColl->size() << " new size " << resolvedTracks->size() ); //store the resolved segments - std::vector<const Muon::MuonSegment*>* segments = new std::vector<const Muon::MuonSegment*>; for(TrackCollection::const_iterator it=resolvedTracks->begin(); it!=resolvedTracks->end(); ++it) { MuonSegment* seg = m_trackToSegmentTool->convert( **it ); if( !seg ) { @@ -250,28 +245,38 @@ namespace Muon { } else { ATH_MSG_DEBUG(" adding " << m_printer->print(*seg) << std::endl << m_printer->print( seg->containedMeasurements() ) ); - segments->push_back(seg); + etaSegs.push_back(seg); } } //memory cleanup delete resolvedTracks; - delete segTrkColl; - return segments; } - std::vector<const Muon::MuonSegment*>* MuonClusterSegmentFinderTool::find3DSegments(std::vector< const Muon::MuonClusterOnTrack* >& muonClusters, - std::vector<const Muon::MuonSegment*>* etaSegs) const { + void MuonClusterSegmentFinderTool::find3DSegments(std::vector< const Muon::MuonClusterOnTrack* >& muonClusters, + std::vector<Muon::MuonSegment*>& etaSegs, + std::vector<Muon::MuonSegment*>& segments, + Trk::SegmentCollection* segColl) const { bool selectPhiHits(true); std::vector< const Muon::MuonClusterOnTrack* > clusters = cleanClusters(muonClusters,selectPhiHits); std::vector< const Muon::MuonClusterOnTrack* > etaClusters = cleanClusters(muonClusters,false); ATH_MSG_DEBUG("After hit cleaning, there are " << clusters.size() << " 3D clusters to be fit" ); if(belowThreshold(clusters,4)) { ATH_MSG_DEBUG("Not enough phi hits present, cannot perform the fit!"); - return etaSegs; + if(segColl){ + for(std::vector<Muon::MuonSegment*>::iterator vsit=etaSegs.begin();vsit!=etaSegs.end();++vsit){ + segColl->push_back(*vsit); + etaSegs.erase(vsit); + } + } + else{ + for(std::vector<Muon::MuonSegment*>::iterator vsit=etaSegs.begin();vsit!=etaSegs.end();++vsit){ + segments.push_back(*vsit); + etaSegs.erase(vsit); + } + } } - std::vector<const Muon::MuonSegment*>* segments = new std::vector<const Muon::MuonSegment*>; TrackCollection* segTrkColl = new TrackCollection; //order the clusters by layer bool useWires(true); @@ -291,7 +296,7 @@ namespace Muon { ATH_MSG_DEBUG("Found " << seeds.size() << " 3D seeds from Wires for phi direction" ); } //loop on the seeds and combine with the eta segments - for(std::vector<const Muon::MuonSegment*>::const_iterator sit=etaSegs->begin(); sit!=etaSegs->end(); ++sit) { + for(std::vector<Muon::MuonSegment*>::const_iterator sit=etaSegs.begin(); sit!=etaSegs.end(); ++sit) { bool is3Dseg(false); if(!useWires) seeds = segmentSeedFromPads(orderedClusters,*sit); if(!useWires) ATH_MSG_DEBUG("Found " << seeds.size() << " 3D seeds from Pads for phi direction" ); @@ -347,7 +352,7 @@ namespace Muon { continue; } } - phiHitsPrevious.clear(); + phiHitsPrevious.clear(); for(unsigned int k=0; k<phiHits.size(); ++k) { phiHitsPrevious.push_back(phiHits[k]); } @@ -438,7 +443,10 @@ namespace Muon { } if(m_ipConstraint) delete pseudoVtx; }//end loop on phi seeds - if( !is3Dseg ) segments->push_back( (*sit)->clone() ); + if( !is3Dseg ){ + if(!segColl) segments.push_back( (*sit)->clone() ); + else segColl->push_back( (*sit)->clone() ); + } }//end loop on precision plane segments TrackCollection* resolvedTracks = m_ambiTool->process(segTrkColl); @@ -450,7 +458,8 @@ namespace Muon { ATH_MSG_VERBOSE("Segment conversion failed, no segment created. "); } else { - segments->push_back(seg); + if(!segColl) segments.push_back(seg); + else segColl->push_back(seg); } } @@ -458,12 +467,10 @@ namespace Muon { delete segTrkColl; delete resolvedTracks; - for(std::vector<const Muon::MuonSegment*>::const_iterator sit=etaSegs->begin(); sit!=etaSegs->end(); ++sit) { + for(std::vector<Muon::MuonSegment*>::iterator sit=etaSegs.begin(); sit!=etaSegs.end(); ++sit) { delete *sit; } - delete etaSegs; - - return segments; + } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.h index a44180d22bca7fbdae78b5b05829c44cccdb089f..39a12a44fab94a9300f4d6729caeff39db21fa2a 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONROADFINDERTOOL_H @@ -59,13 +59,17 @@ namespace Muon { public: //find segments given a list of MuonCluster - std::vector<const Muon::MuonSegment*>* find(std::vector< const Muon::MuonClusterOnTrack* >& clusters) const override; + //segments can be added directly to a SegmentCollection, if they are to be written to SG, or returned in a list for further processing + void find(std::vector< const Muon::MuonClusterOnTrack* >& clusters, std::vector<Muon::MuonSegment*>& segments, Trk::SegmentCollection* segColl=0) const override; private: //reconstruct the segments in the precision (eta) plane - std::vector<const Muon::MuonSegment*>* findPrecisionSegments(std::vector< const Muon::MuonClusterOnTrack* >& MuonClusters) const; + void findPrecisionSegments(std::vector< const Muon::MuonClusterOnTrack* >& MuonClusters, std::vector<Muon::MuonSegment*>& etaSegs) const; //recontruct 3D segments - std::vector<const Muon::MuonSegment*>* find3DSegments(std::vector< const Muon::MuonClusterOnTrack* >& MuonClusters, std::vector<const Muon::MuonSegment*>* etaSegs) const; + void find3DSegments(std::vector< const Muon::MuonClusterOnTrack* >& MuonClusters, + std::vector<Muon::MuonSegment*>& etaSegs, + std::vector<Muon::MuonSegment*>& segments, + Trk::SegmentCollection* segColl=0) const; //clean the clusters std::vector< const Muon::MuonClusterOnTrack* > cleanClusters(std::vector< const Muon::MuonClusterOnTrack* >& MuonClusters, bool selectPhiClusters=false) const ; //order the clusters diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx index ef35ef18bde13133db30faaf180244c4007104c4..d340cad59724336660e8f3f2fad09a652515e4b2 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonClusterSegmentFinder.h" @@ -139,11 +139,11 @@ return (fabs(i.z()) < fabs(j.z()));} return false; } - std::vector<const Muon::MuonSegment*>* MuonClusterSegmentFinder::getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, - std::vector<const Muon::TgcPrepDataCollection*>* tgcCols, - std::vector<const Muon::RpcPrepDataCollection*>* rpcCols, - const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl) const { - std::vector<const Muon::MuonSegment*>* segs = new std::vector<const Muon::MuonSegment*>; + void MuonClusterSegmentFinder::getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, + std::vector<const Muon::TgcPrepDataCollection*>* tgcCols, + std::vector<const Muon::RpcPrepDataCollection*>* rpcCols, + const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl, + Trk::SegmentCollection* segColl) const { if(tgcCols){ Muon::TgcPrepDataContainer* clusterPRD=new Muon::TgcPrepDataContainer(m_idHelper->tgcIdHelper().module_hash_max()); @@ -162,7 +162,7 @@ return (fabs(i.z()) < fabs(j.z()));} theTGCs.push_back(*theIt); } - findSegments(theTGCs,mdtPrdCont,segs,tgcTruthColl); + findSegments(theTGCs,mdtPrdCont,segColl,tgcTruthColl); }//end if TGC if(rpcCols){ @@ -182,17 +182,16 @@ return (fabs(i.z()) < fabs(j.z()));} theRPCs.push_back(*theIt); } - findSegments(theRPCs,mdtPrdCont,segs,rpcTruthColl); + findSegments(theRPCs,mdtPrdCont,segColl,rpcTruthColl); }//end if RPC - return segs; } - std::vector<const Muon::MuonSegment*>* MuonClusterSegmentFinder::getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, - const Muon::RpcPrepDataContainer* rpcPrdCont, const Muon::TgcPrepDataContainer* tgcPrdCont, - const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl) const { - std::vector<const Muon::MuonSegment*>* segs = new std::vector<const Muon::MuonSegment*>; - + void MuonClusterSegmentFinder::getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, + const Muon::RpcPrepDataContainer* rpcPrdCont, const Muon::TgcPrepDataContainer* tgcPrdCont, + const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl, + Trk::SegmentCollection* segColl) const { + if (tgcPrdCont) { Muon::TgcPrepDataContainer* clusterPRD = m_clusterTool->cluster(*tgcPrdCont); @@ -207,7 +206,7 @@ return (fabs(i.z()) < fabs(j.z()));} theTGCs.push_back(*theIt); } - findSegments(theTGCs,mdtPrdCont,segs,tgcTruthColl); + findSegments(theTGCs,mdtPrdCont,segColl,tgcTruthColl); }//end if TGC if (rpcPrdCont) { @@ -224,15 +223,15 @@ return (fabs(i.z()) < fabs(j.z()));} theRPCs.push_back(*theIt); } - findSegments(theRPCs,mdtPrdCont,segs,rpcTruthColl); + findSegments(theRPCs,mdtPrdCont,segColl,rpcTruthColl); }//end if rpc - return segs; } void MuonClusterSegmentFinder::findSegments( std::vector<const TgcPrepDataCollection*>& tgcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, - std::vector<const Muon::MuonSegment*>* segments, const PRD_MultiTruthCollection* tgcTruthColl) const { + Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* tgcTruthColl) const { ATH_MSG_INFO ("Executing " << name() << "..."); + ATH_MSG_DEBUG("start with "<<segColl->size()<<" segments"); candEvent* thisEvent = new candEvent; @@ -250,14 +249,10 @@ return (fabs(i.z()) < fabs(j.z()));} findOverlap(themap,thisEvent); resolveCollections(themap,thisEvent); - std::vector<const MuonSegment*> resolvedSegments = getSegments(thisEvent, mdtPrdCont); + getSegments(thisEvent, mdtPrdCont, segColl); - ATH_MSG_DEBUG("the size of resolved segments " << resolvedSegments.size() ); + ATH_MSG_DEBUG("now have " << segColl->size()<<" segments" ); - for( auto seg : resolvedSegments ){ - segments->push_back(seg); - } - if (m_doNtuple) { m_ntuple->fill(thisEvent->Clust()); m_tree->Fill(); @@ -266,8 +261,9 @@ return (fabs(i.z()) < fabs(j.z()));} } void MuonClusterSegmentFinder::findSegments(std::vector<const RpcPrepDataCollection*>& rpcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, - std::vector<const Muon::MuonSegment*>* segments, const PRD_MultiTruthCollection* rpcTruthColl ) const { + Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* rpcTruthColl ) const { ATH_MSG_INFO ("Executing " << name() << "..."); + ATH_MSG_DEBUG("start with "<<segColl->size()<<" segments"); candEvent * thisEvent = new candEvent; @@ -277,7 +273,6 @@ return (fabs(i.z()) < fabs(j.z()));} ATH_MSG_DEBUG("the size of Clust is " << thisEvent->Clust().size() ); std::vector<std::vector<ClusterSeg::SpacePoint>> sPoints = theAnalysis.analyse(thisEvent->Clust()); - processSpacePoints(thisEvent,sPoints); if(thisEvent->segTrkColl()->size() > 0) ATH_MSG_DEBUG( "it made at least one track " ); else ATH_MSG_DEBUG("processSpacePoints didn't make anything"); @@ -286,13 +281,9 @@ return (fabs(i.z()) < fabs(j.z()));} findOverlap(themap,thisEvent); resolveCollections(themap,thisEvent); - std::vector<const MuonSegment*> resolvedSegments = getSegments(thisEvent,mdtPrdCont); + getSegments(thisEvent,mdtPrdCont,segColl); - ATH_MSG_DEBUG("the size of resolved segments " << resolvedSegments.size() ); - - for( auto seg : resolvedSegments ){ - segments->push_back(seg); - } + ATH_MSG_DEBUG("now have " << segColl->size()<<" segments" ); if (m_doNtuple) { m_ntuple->fill(thisEvent->Clust()); @@ -485,7 +476,7 @@ return (fabs(i.z()) < fabs(j.z()));} ATH_MSG_DEBUG("Resolved track candidates: old size " << theEvent->segTrkColl()->size() << " new size " << theEvent->resolvedTracks()->size() ); } - std::vector<const MuonSegment*> MuonClusterSegmentFinder::getSegments(candEvent* theEvent, const Muon::MdtPrepDataContainer* mdtPrdCont) const { + void MuonClusterSegmentFinder::getSegments(candEvent* theEvent, const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl) const { std::vector<const Muon::MuonSegment*> appendSegments; @@ -528,15 +519,14 @@ return (fabs(i.z()) < fabs(j.z()));} } } ATH_MSG_DEBUG("Running mdt segment finding: MDTs " << MDTs.size() << " MCOTs " << MCOTs.size()); - std::vector<const MuonSegment*>* segments = m_segmentMaker->find(theEvent->resolvedTrackSeeds()[i].first,theEvent->resolvedTrackSeeds()[i].second,MDTs,MCOTs); - if(segments && segments->size() > 0){ - appendSegments.insert(appendSegments.end(),segments->begin(),segments->end()); - ATH_MSG_DEBUG( "the size of the segment collection is " << segments->size() ); - for(unsigned int j = 0;j< segments->size();j++){ATH_MSG_DEBUG( "the " << j << "th segment contains " << (*segments)[j]->numberOfContainedROTs() << " ROTs " );} - } else ATH_MSG_DEBUG("finding of the muon segments failed"); + m_segmentMaker->find(theEvent->resolvedTrackSeeds()[i].first,theEvent->resolvedTrackSeeds()[i].second,MDTs,MCOTs,false,segColl); + ATH_MSG_DEBUG( "the size of the segment collection is " << segColl->size() ); + for(unsigned int j = 0;j< segColl->size();j++){ + Trk::Segment* tseg=segColl->at(j); + ATH_MSG_DEBUG( "the " << j << "th segment contains " << (dynamic_cast<MuonSegment*>(tseg))->numberOfContainedROTs() << " ROTs " ); + } } } - return m_segmentOverlapRemovalTool->removeDuplicates(appendSegments); } bool MuonClusterSegmentFinder::getLayerData( int sector, MuonStationIndex::DetectorRegionIndex regionIndex,MuonStationIndex::LayerIndex layerIndex, diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.h index a2aebb83f09e5332186237b9a10d2474678160e2..39a497faab21e254b52b501dbecda44bd598fd33 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////////// @@ -104,19 +104,21 @@ namespace Muon { StatusCode initialize(); StatusCode finalize(); - std::vector<const Muon::MuonSegment*>* getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, - const Muon::RpcPrepDataContainer* rpcPrdCont, const Muon::TgcPrepDataContainer* tgcPrdCont, - const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl) const; + void getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, + const Muon::RpcPrepDataContainer* rpcPrdCont, const Muon::TgcPrepDataContainer* tgcPrdCont, + const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl, + Trk::SegmentCollection* segColl) const; - std::vector<const Muon::MuonSegment*>* getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, - std::vector<const Muon::TgcPrepDataCollection*>* tgcCols, std::vector<const Muon::RpcPrepDataCollection*>* rpcCols, - const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl) const; + void getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, + std::vector<const Muon::TgcPrepDataCollection*>* tgcCols, std::vector<const Muon::RpcPrepDataCollection*>* rpcCols, + const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl, + Trk::SegmentCollection* segColl) const; /** tgc segment finding */ - void findSegments(std::vector<const TgcPrepDataCollection*>& tgcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, std::vector<const Muon::MuonSegment*>* segments, + void findSegments(std::vector<const TgcPrepDataCollection*>& tgcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* tgcTruthColl) const; /** rpc segment finding */ - void findSegments(std::vector<const RpcPrepDataCollection*>& rpcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, std::vector<const Muon::MuonSegment*>* segments, + void findSegments(std::vector<const RpcPrepDataCollection*>& rpcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* tgcTruthColl) const; private: @@ -147,7 +149,7 @@ namespace Muon { void findOverlap(std::map<int,bool>& themap,candEvent* theEvent) const; void processSpacePoints(candEvent* theEvent,std::vector<std::vector<ClusterSeg::SpacePoint>>& sPoints) const; void resolveCollections(std::map<int,bool> themap,candEvent* theEvent) const; - std::vector<const MuonSegment*> getSegments(candEvent* theEvent, const Muon::MdtPrepDataContainer* mdtPrdCont) const; + void getSegments(candEvent* theEvent, const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl) const; bool getLayerData( int sector, MuonStationIndex::DetectorRegionIndex regionIndex, MuonStationIndex::LayerIndex layerIndex, const Muon::MdtPrepDataContainer* input, std::vector<const MdtPrepDataCollection*>& output ) const; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/CMakeLists.txt b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/CMakeLists.txt index cbac1e42fc7dce09fc0f19053215e6d3e8e55b82..fef32369ef2a5cffa3cdaf1f47836f3f0c8f3e0e 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/CMakeLists.txt +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/CMakeLists.txt @@ -22,11 +22,12 @@ atlas_depends_on_subdirs( PUBLIC MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonLayerHough MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerAlgs/CscSegmentMakers - MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces ) + MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces + Tracking/TrkEvent/TrkSegment ) # Component(s) in the package: atlas_add_component( MuonLayerSegmentMakerTools src/*.cxx src/components/*.cxx - LINK_LIBRARIES GaudiKernel AthenaBaseComps EventPrimitives MuonPrepRawDataProviderToolsLib MuonDetDescrUtils MuonIdHelpersLib MuonHoughPatternToolsLib MuonLayerEvent MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonLayerHough ) + LINK_LIBRARIES GaudiKernel AthenaBaseComps EventPrimitives MuonPrepRawDataProviderToolsLib MuonDetDescrUtils MuonIdHelpersLib MuonHoughPatternToolsLib MuonLayerEvent MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonLayerHough TrkSegment ) diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.cxx index c513872412b734dc1f70e7cd0a9852dd4efc974b..0c0f8c58498b02fa2a9dcbd7d383d759e1cdf42b 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonLayerSegmentFinderTool.h" @@ -13,7 +13,7 @@ #include "MuonHoughPatternTools/MuonLayerHoughTool.h" #include "MuonLayerHough/MuonLayerHough.h" #include "MuonRecToolInterfaces/IMuonRecoValidationTool.h" - +#include "TrkSegment/SegmentCollection.h" #include "MuonSegment/MuonSegment.h" #include "MuonRIO_OnTrack/MdtDriftCircleOnTrack.h" #include "MuonRIO_OnTrack/MuonClusterOnTrack.h" @@ -269,13 +269,19 @@ namespace Muon { if( mdts.size() > 2 ){ // run segment finder - std::unique_ptr<std::vector<const MuonSegment*> > foundSegments(m_segmentMaker->find( intersection.trackParameters->position(),intersection.trackParameters->momentum(), - mdts, clusters, - !clusters.empty(), intersection.trackParameters->momentum().mag() )); - if( foundSegments ){ - for( auto seg : *foundSegments ){ - ATH_MSG_DEBUG( " " << m_printer->print(*seg) ); - segments.push_back( std::shared_ptr<const MuonSegment>(seg) ); + std::unique_ptr<Trk::SegmentCollection> segColl(new Trk::SegmentCollection(SG::VIEW_ELEMENTS)); + m_segmentMaker->find( intersection.trackParameters->position(),intersection.trackParameters->momentum(), + mdts, clusters, + !clusters.empty(), segColl.get(), intersection.trackParameters->momentum().mag() ); + + if( segColl ){ + Trk::SegmentCollection::iterator sit = segColl->begin(); + Trk::SegmentCollection::iterator sit_end = segColl->end(); + for( ; sit!=sit_end;++sit){ + Trk::Segment* tseg=*sit; + MuonSegment* mseg=dynamic_cast<MuonSegment*>(tseg); + ATH_MSG_DEBUG( " " << m_printer->print(*mseg)); + segments.push_back( std::shared_ptr<const MuonSegment>(mseg) ); } } } @@ -322,9 +328,10 @@ namespace Muon { } } - std::unique_ptr< std::vector<const MuonSegment*> > foundSegments ( m_clusterSegMakerNSW->find(clusters) ); - if( foundSegments ) { - for( auto seg : *foundSegments ){ + std::vector<MuonSegment*> foundSegments; + m_clusterSegMakerNSW->find(clusters,foundSegments); + if( foundSegments.size()>0 ) { + for( auto seg : foundSegments ){ ATH_MSG_DEBUG( " NSW segment " << m_printer->print(*seg) ); segments.push_back( std::shared_ptr<const MuonSegment>(seg) ); ATH_MSG_DEBUG( " total segments " << segments.size() ); @@ -335,11 +342,11 @@ namespace Muon { void MuonLayerSegmentFinderTool::findCscSegments( const MuonLayerPrepRawData& layerPrepRawData, std::vector< std::shared_ptr<const Muon::MuonSegment> >& segments ) const { // run 2d segment finder - MuonSegmentCombinationCollection* combi2D = m_csc2dSegmentFinder->find(layerPrepRawData.cscs); + std::unique_ptr<MuonSegmentCombinationCollection> combi2D = m_csc2dSegmentFinder->find(layerPrepRawData.cscs); if( combi2D ){ // run 4d segment finder - MuonSegmentCombinationCollection* combi4D = m_csc4dSegmentFinder->find( *combi2D ); + std::unique_ptr<MuonSegmentCombinationCollection> combi4D = m_csc4dSegmentFinder->find( *combi2D ); if( combi4D ){ // extract segments and clean-up memory @@ -365,9 +372,7 @@ namespace Muon { } } } - delete combi4D; } - delete combi2D; } } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonPatternSegmentMaker/MuonPatternSegmentMaker/MuonPatternSegmentMaker.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonPatternSegmentMaker/MuonPatternSegmentMaker/MuonPatternSegmentMaker.h index 7a3a84e6d1134849f4e441603b76e95fd488e3bb..1a7c9202ad251378b7f27c0de540b47b963a3826 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonPatternSegmentMaker/MuonPatternSegmentMaker/MuonPatternSegmentMaker.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonPatternSegmentMaker/MuonPatternSegmentMaker/MuonPatternSegmentMaker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_MUONPATTERNSEGMENTMAKER_MUONPATTERNSEGMENTMAKER_H #define MUON_MUONPATTERNSEGMENTMAKER_MUONPATTERNSEGMENTMAKER_H @@ -26,8 +26,6 @@ #include "Identifier/Identifier.h" -#include "MuonPrepRawData/MuonPrepDataContainer.h" - class StoreGate; class MsgStream; @@ -122,12 +120,15 @@ namespace Muon { virtual StatusCode initialize(); virtual StatusCode finalize(); - MuonSegmentCombination* find( const MuonPatternCombination& pattern ) const; + void find( const MuonPatternCombination& pattern, const std::vector<const RpcPrepDataCollection*>& rpcCols, const std::vector<const TgcPrepDataCollection*>& tgcCols, + Trk::SegmentCollection* segColl) const; - MuonSegmentCombinationCollection* find( const MuonPatternCombinationCollection& patternCol, MuonSegmentCombPatternCombAssociationMap* segPattMap) const; + std::unique_ptr<MuonSegmentCombinationCollection> find( const MuonPatternCombinationCollection* patternCol, MuonSegmentCombPatternCombAssociationMap* segPattMap, + const std::vector<const RpcPrepDataCollection*>& rpcCols, const std::vector<const TgcPrepDataCollection*>& tgcCols) const; private: - void createRegionMap( const MuonPatternCombination& pat, RegionMap& regionMap, bool hasPhiMeasurements ) const; + void createRegionMap( const MuonPatternCombination& pat, RegionMap& regionMap, bool hasPhiMeasurements, + const std::vector<const RpcPrepDataCollection*>& rpcCols, const std::vector<const TgcPrepDataCollection*>& tgcCols) const; void insertCluster( const MuonCluster& mdt, RegionMap& regionMap, const Amg::Vector3D& patpose, const Amg::Vector3D& patdire, @@ -147,9 +148,6 @@ namespace Muon { const MuonSegment* isSubSet( const MuonSegment* seg1, const MuonSegment* seg2 ) const; int getRegionId( const Identifier& id ) const ; - void retrieveTriggerHitContainers() const; - - ToolHandle<IMuonSegmentMaker> m_segmentMaker; //<! pointer to muon segment maker. ToolHandle<IMdtDriftCircleOnTrackCreator> m_mdtCreator; //<! pointer to mdt rio ontrack creator @@ -167,11 +165,6 @@ namespace Muon { bool m_recoverTriggerHits; bool m_removeDoubleMdtHits; - SG::ReadHandleKey <Muon::RpcPrepDataContainer> m_keyRpc; - SG::ReadHandleKey <Muon::TgcPrepDataContainer> m_keyTgc; - mutable const Muon::RpcPrepDataContainer* m_rpcPrdContainer; - mutable const Muon::TgcPrepDataContainer* m_tgcPrdContainer; - }; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonPatternSegmentMaker/src/MuonPatternSegmentMaker.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonPatternSegmentMaker/src/MuonPatternSegmentMaker.cxx index cdd900833f0de94419b7bd024904d4916cd06f73..c2cd7409b95669f873a65594f9c215aa4c8cb2e8 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonPatternSegmentMaker/src/MuonPatternSegmentMaker.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonPatternSegmentMaker/src/MuonPatternSegmentMaker.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonPatternSegmentMaker/MuonPatternSegmentMaker.h" @@ -42,9 +42,7 @@ namespace Muon { m_mdtCreator("Muon::MdtDriftCircleOnTrackCreator/MdtDriftCircleOnTrackCreator"), m_clusterCreator("Muon::MuonClusterOnTrackCreator/MuonClusterOnTrackCreator"), m_printer("Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"), - m_idHelper("Muon::MuonIdHelperTool/MuonIdHelperTool"), - m_keyRpc("RPC_Measurements"), - m_keyTgc("TGC_Measurements") + m_idHelper("Muon::MuonIdHelperTool/MuonIdHelperTool") { declareInterface<IMuonPatternSegmentMaker>(this); @@ -56,8 +54,6 @@ namespace Muon { declareProperty("DropDistance",m_dropDistance = 1500.); declareProperty("AngleCutPhi",m_phiAngleCut = 1e9 ); declareProperty("FullFinder",m_doFullFinder = true); - declareProperty("RpcPrepDataContainer", m_keyRpc); - declareProperty("TgcPrepDataContainer", m_keyTgc); declareProperty("DoSummary",m_doSummary = false); declareProperty("RecoverTriggerHits",m_recoverTriggerHits = true); declareProperty("RemoveDoubleMdtHits",m_removeDoubleMdtHits = true); @@ -95,26 +91,19 @@ namespace Muon { return StatusCode::FAILURE; } - if(!m_keyRpc.initialize()){ - ATH_MSG_ERROR("Couldn't initalize RPC ReadHandleKey"); - return StatusCode::FAILURE; - } - if(!m_keyTgc.initialize()){ - ATH_MSG_ERROR("Couldn't initalize TGC ReadHandleKey"); - return StatusCode::FAILURE; - } return StatusCode::SUCCESS; } - MuonSegmentCombinationCollection* MuonPatternSegmentMaker::find( const MuonPatternCombinationCollection& patterns, MuonSegmentCombPatternCombAssociationMap* segPattMap ) const { + std::unique_ptr<MuonSegmentCombinationCollection> MuonPatternSegmentMaker::find( const MuonPatternCombinationCollection* patterns, + MuonSegmentCombPatternCombAssociationMap* segPattMap, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols) const { - if( m_recoverTriggerHits ) retrieveTriggerHitContainers(); - - MuonSegmentCombinationCollection* combiCol = new MuonSegmentCombinationCollection(); + std::unique_ptr<MuonSegmentCombinationCollection> combiCol(new MuonSegmentCombinationCollection); - MuonPatternCombinationCollection::const_iterator it = patterns.begin(); - for( ; it!=patterns.end();++it ){ + MuonPatternCombinationCollection::const_iterator it = patterns->begin(); + for( ; it!=patterns->end();++it ){ const MuonPatternCombination* pattern = *it; @@ -122,31 +111,47 @@ namespace Muon { continue; } - MuonSegmentCombination* combi = find( *pattern ); + std::unique_ptr<Trk::SegmentCollection> segCol(new Trk::SegmentCollection(SG::VIEW_ELEMENTS)); + find( *pattern, rpcCols, tgcCols, segCol.get() ); + + if(!segCol->empty()){ + MuonSegmentCombination* combi=new MuonSegmentCombination(); //dynamically assigning memory here, but this object will be immediately added to the collection, which will take ownership + std::unique_ptr<std::vector<std::unique_ptr<MuonSegment> > > segVec (new std::vector<std::unique_ptr< MuonSegment> >); + Trk::SegmentCollection::iterator sit = segCol->begin(); + Trk::SegmentCollection::iterator sit_end = segCol->end(); + for( ; sit!=sit_end;++sit){ + Trk::Segment* tseg=*sit; + MuonSegment* mseg=dynamic_cast<MuonSegment*>(tseg); + segVec->push_back(std::unique_ptr<MuonSegment>(mseg)); + } + combi->addSegments(std::move(segVec)); - // insert new combination into collection - combiCol->push_back( combi ); + // insert new combination into collection + combiCol->push_back( combi ); - // create link between pattern and segment combination - segPattMap->insert(std::make_pair( combi, pattern) ); + // create link between pattern and segment combination + segPattMap->insert(std::make_pair( combi, pattern) ); + } } // end loop over patterns + if(combiCol->empty()) combiCol.reset(); return combiCol; } - MuonSegmentCombination* MuonPatternSegmentMaker::find( const MuonPatternCombination& pattern ) const { + void MuonPatternSegmentMaker::find( const MuonPatternCombination& pattern, const std::vector<const RpcPrepDataCollection*>& rpcCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, Trk::SegmentCollection* segColl) const { - if( pattern.chamberData().empty() ) return 0; // 0 at the moment! we need convention howto fill this, JS + if( pattern.chamberData().empty() ) return; ATH_MSG_DEBUG(" New global Pattern: pos " << pattern.chamberData().front().intersectPosition() << " dir " << pattern.chamberData().front().intersectDirection()); bool hasPhiMeasurements = checkForPhiMeasurements( pattern ); - // sort hits per region + // sort hits per region RegionMap regionMap; - createRegionMap( pattern, regionMap, hasPhiMeasurements ); + createRegionMap( pattern, regionMap, hasPhiMeasurements, rpcCols, tgcCols ); // printout region Map if( msgLvl(MSG::DEBUG) || m_doSummary ) printRegionMap( regionMap ); @@ -157,10 +162,6 @@ namespace Muon { //if( m_doNtuple ) xxx_EventNtWriter->fill( hitsPerRegion, &pattern, hasPhiMeasurements ); - // create MuonSegmentCombintation for the given pattern - MuonSegmentCombination* combi = new MuonSegmentCombination(); - - ROTsPerRegionIt rit = hitsPerRegion.begin(); ROTsPerRegionIt rit_end = hitsPerRegion.end(); @@ -174,36 +175,28 @@ namespace Muon { if( mdtit->size() < 3 ) continue; - std::vector<const MuonSegment*>* segments = 0; - if( m_doFullFinder ){ - segments = m_segmentMaker->find( rit->regionPos, rit->regionDir, *mdtit, rit->clusters, - hasPhiMeasurements, rit->regionDir.mag() ); + m_segmentMaker->find( rit->regionPos, rit->regionDir, *mdtit, rit->clusters, + hasPhiMeasurements, segColl, rit->regionDir.mag() ); }else{ std::vector<const Trk::RIO_OnTrack*> rios; rios.insert( rios.begin(), mdtit->begin(), mdtit->end() ); - segments = m_segmentMaker->find(rios); + m_segmentMaker->find(rios,segColl); } ATH_MSG_VERBOSE(" search in " << m_idHelper->toStringChamber(mdtit->front()->identify()) << " nhits " << mdtit->size()); - - if( segments ) { - ATH_MSG_VERBOSE(" found segments " << segments->size()); - - combi->addSegments( segments ); - - }else{ + if(segColl->empty()){ ATH_MSG_VERBOSE(" no segments found "); } + else ATH_MSG_VERBOSE("now have "<<segColl->size()<<" segments"); }// end loop over MDTs } // end loop over regions - + // delete pointer to ROT in region mapx clearRotsPerRegion( hitsPerRegion ); - return combi; } @@ -243,8 +236,8 @@ namespace Muon { return false; } - void MuonPatternSegmentMaker::createRegionMap( const MuonPatternCombination& pat, RegionMap& regionMap, - bool hasPhiMeasurements ) const { + void MuonPatternSegmentMaker::createRegionMap( const MuonPatternCombination& pat, RegionMap& regionMap, bool hasPhiMeasurements, + const std::vector<const RpcPrepDataCollection*>& rpcCols, const std::vector<const TgcPrepDataCollection*>& tgcCols) const { if( hasPhiMeasurements ) ATH_MSG_DEBUG(" pattern has phi measurements using extrapolation to determine second coordinate "); @@ -266,8 +259,8 @@ namespace Muon { - count the number of eta and phi clusters per collection */ - std::map<int,EtaPhiHits> etaPhiHitsPerChamber; - std::set<Identifier> clusterIds; + std::map<unsigned int,EtaPhiHits> etaPhiHitsPerChamber; + std::set<Identifier> clusterIds; @@ -329,7 +322,7 @@ namespace Muon { if( m_recoverTriggerHits ){ bool measuresPhi = m_idHelper->measuresPhi(id); - int colHash = clus->collectionHash(); + unsigned int colHash = clus->collectionHash(); EtaPhiHits& hitsPerChamber = etaPhiHitsPerChamber[colHash]; if( measuresPhi ) ++hitsPerChamber.nphi; @@ -339,40 +332,47 @@ namespace Muon { } } if( !etaPhiHitsPerChamber.empty() ){ - std::map<int,EtaPhiHits>::iterator chit = etaPhiHitsPerChamber.begin(); - std::map<int,EtaPhiHits>::iterator chit_end = etaPhiHitsPerChamber.end(); + std::map<unsigned int,EtaPhiHits>::iterator chit = etaPhiHitsPerChamber.begin(); + std::map<unsigned int,EtaPhiHits>::iterator chit_end = etaPhiHitsPerChamber.end(); for( ;chit!=chit_end;++chit ){ EtaPhiHits& hits = chit->second; if( (hits.neta > 0 && hits.nphi == 0) || (hits.nphi > 0 && hits.neta == 0) ){ - if( m_idHelper->isRpc(id) && m_rpcPrdContainer ){ - - RpcPrepDataContainer::const_iterator pos = m_rpcPrdContainer->indexFind(chit->first); - if( pos == m_rpcPrdContainer->end() ){ - ATH_MSG_DEBUG(" RpcPrepDataCollection not found in container!! "); - }else{ - RpcPrepDataCollection::const_iterator rpcit = (*pos)->begin(); - RpcPrepDataCollection::const_iterator rpcit_end = (*pos)->end(); - for( ;rpcit!=rpcit_end;++rpcit ){ - if( clusterIds.count( (*rpcit)->identify() ) ) continue; - const MuonCluster* clus = dynamic_cast<const MuonCluster*>(*rpcit); - insertCluster(*clus,regionMap,patpose,patdire,hasPhiMeasurements); - clusterIds.insert(clus->identify()); + if( m_idHelper->isRpc(id) && !rpcCols.empty() ){ + std::vector<const RpcPrepDataCollection*>::const_iterator rcvit=rpcCols.begin(); + for( ;rcvit!=rpcCols.end();++rcvit){ + if((*rcvit)->identifyHash()==chit->first){ + RpcPrepDataCollection::const_iterator rpcit = (*rcvit)->begin(); + RpcPrepDataCollection::const_iterator rpcit_end = (*rcvit)->end(); + for( ;rpcit!=rpcit_end;++rpcit ){ + if( clusterIds.count( (*rpcit)->identify() ) ) continue; + const MuonCluster* clus = dynamic_cast<const MuonCluster*>(*rpcit); + insertCluster(*clus,regionMap,patpose,patdire,hasPhiMeasurements); + clusterIds.insert(clus->identify()); + } + break; } } - }else if( m_idHelper->isTgc(id) && m_tgcPrdContainer ){ - TgcPrepDataContainer::const_iterator pos = m_tgcPrdContainer->indexFind(chit->first); - if( pos == m_tgcPrdContainer->end() ){ - ATH_MSG_DEBUG(" TgcPrepDataCollection not found in container!! "); - }else{ - TgcPrepDataCollection::const_iterator tgcit = (*pos)->begin(); - TgcPrepDataCollection::const_iterator tgcit_end = (*pos)->end(); - for( ;tgcit!=tgcit_end;++tgcit ){ - if( clusterIds.count( (*tgcit)->identify() ) ) continue; - const MuonCluster* clus = dynamic_cast<const MuonCluster*>(*tgcit); - insertCluster(*clus,regionMap,patpose,patdire,hasPhiMeasurements); - clusterIds.insert(clus->identify()); + if( rcvit == rpcCols.end() ){ + ATH_MSG_DEBUG(" RpcPrepDataCollection not found in container!! "); + } + }else if( m_idHelper->isTgc(id) && !tgcCols.empty()){ + std::vector<const TgcPrepDataCollection*>::const_iterator tcvit=tgcCols.begin(); + for( ;tcvit!=tgcCols.end();++tcvit){ + if((*tcvit)->identifyHash()==chit->first){ + TgcPrepDataCollection::const_iterator tgcit = (*tcvit)->begin(); + TgcPrepDataCollection::const_iterator tgcit_end = (*tcvit)->end(); + for( ;tgcit!=tgcit_end;++tgcit ){ + if( clusterIds.count( (*tgcit)->identify() ) ) continue; + const MuonCluster* clus = dynamic_cast<const MuonCluster*>(*tgcit); + insertCluster(*clus,regionMap,patpose,patdire,hasPhiMeasurements); + clusterIds.insert(clus->identify()); + } + break; } } + if( tcvit == tgcCols.end() ){ + ATH_MSG_DEBUG(" RpcPrepDataCollection not found in container!! "); + } } } } @@ -741,20 +741,4 @@ namespace Muon { return 0; } - void MuonPatternSegmentMaker::retrieveTriggerHitContainers() const { - m_rpcPrdContainer=0; - SG::ReadHandle<Muon::RpcPrepDataContainer> RpcCont(m_keyRpc); - if( !RpcCont.isValid() ) { - ATH_MSG_DEBUG(" Failed to retrieve RpcPrepDataContainer, will not recover rpc trigger hits "); - } - else m_rpcPrdContainer=RpcCont.cptr(); - - m_tgcPrdContainer=0; - SG::ReadHandle<Muon::TgcPrepDataContainer> TgcCont(m_keyTgc); - if(!TgcCont.isValid() ) { - ATH_MSG_DEBUG(" Failed to retrieve TgcPrepDataContainer, will not recover tgc trigger hits "); - } - else m_tgcPrdContainer=TgcCont.cptr(); - - } } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h index 703730a61f7b0226c81b2b0f4c52a825b1004928..a8b91b5142f542d0d6db2ddbb143b337456e7e7e 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_IMUONCLUSTERSEGMENTFINDER_H @@ -12,6 +12,7 @@ #include "MuonPrepRawData/MuonPrepDataContainer.h" #include "TrkTruthData/PRD_MultiTruthCollection.h" #include "MuonRIO_OnTrack/MuonClusterOnTrack.h" +#include "TrkSegment/SegmentCollection.h" static const InterfaceID IID_IMuonClusterSegmentFinder("Muon::IMuonClusterSegmentFinder",1,0); @@ -26,20 +27,22 @@ namespace Muon { /** IAlgTool interface */ static const InterfaceID& interfaceID(); - virtual std::vector<const Muon::MuonSegment*>* getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, - const Muon::RpcPrepDataContainer* rpcPrdCont, const Muon::TgcPrepDataContainer* tgcPrdCont, - const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl) const = 0; + virtual void getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, + const Muon::RpcPrepDataContainer* rpcPrdCont, const Muon::TgcPrepDataContainer* tgcPrdCont, + const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl, + Trk::SegmentCollection* segColl) const = 0; - virtual std::vector<const Muon::MuonSegment*>* getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, - std::vector<const Muon::TgcPrepDataCollection*>* tgcCols, std::vector<const Muon::RpcPrepDataCollection*>* rpcCols, - const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl) const = 0; + virtual void getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, + std::vector<const Muon::TgcPrepDataCollection*>* tgcCols, std::vector<const Muon::RpcPrepDataCollection*>* rpcCols, + const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl, + Trk::SegmentCollection* segColl) const = 0; /** @brief Find tgc + mdt segments for a given set of TGC hit collections */ - virtual void findSegments( std::vector<const TgcPrepDataCollection*>& tgcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, std::vector<const Muon::MuonSegment*>* segments, + virtual void findSegments( std::vector<const TgcPrepDataCollection*>& tgcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* tgcTruthColl) const = 0; /** @brief Find rpc + mdt segments for a given set of RPC hit collections */ - virtual void findSegments( std::vector<const RpcPrepDataCollection*>& rpcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, std::vector<const Muon::MuonSegment*>* segments, + virtual void findSegments( std::vector<const RpcPrepDataCollection*>& rpcCols, const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* rpcTruthColl) const = 0; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinderTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinderTool.h index 22fd2f50bb0e3166962b6e0c2eae82409354546c..a0e2a7bf66505d75d23fcf365d0775f6e77262ce 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinderTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinderTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_IMUONROADFINDERTOOL_H @@ -9,6 +9,7 @@ #include "MuonPattern/MuonPatternCombinationCollection.h" #include "MuonSegment/MuonSegment.h" #include "MuonRIO_OnTrack/MuonClusterOnTrack.h" +#include "TrkSegment/SegmentCollection.h" #include <vector> static const InterfaceID IID_IMuonClusterSegmentFinderTool("Muon::IMuonClusterSegmentFinderTool", 1, 0); @@ -25,7 +26,7 @@ namespace Muon { /** access to tool interface */ static const InterfaceID& interfaceID(); - virtual std::vector<const Muon::MuonSegment*>* find(std::vector< const Muon::MuonClusterOnTrack* >& clusters) const = 0; + virtual void find(std::vector< const Muon::MuonClusterOnTrack* >& clusters, std::vector<Muon::MuonSegment*>& segments, Trk::SegmentCollection* segColl=0) const = 0; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h index 92efbd45ef0b395330ecba62a26b9ea2fd4426ec..9e39a78d47c5b5caacff1b30bcfc888c829801ce 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONSEGMENTMAKETOOLINTERFACES_MUON_IMUONPATTERNSEGMENTMAKER_H @@ -9,6 +9,9 @@ #include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonPattern/MuonPatternCombinationCollection.h" #include "MuonEDM_AssociationObjects/MuonSegmentCombPatternCombAssociationMap.h" +#include "TrkSegment/SegmentCollection.h" +#include "MuonPrepRawData/RpcPrepDataCollection.h" +#include "MuonPrepRawData/TgcPrepDataCollection.h" #include <vector> @@ -32,13 +35,15 @@ namespace Muon { @param combi a reference to a MuonSegmentCombination @return a pointer to a vector of tracks, the ownership of the tracks is passed to the client calling the tool. */ - virtual MuonSegmentCombination* find( const MuonPatternCombination& pattern ) const = 0; + virtual void find( const MuonPatternCombination& pattern, const std::vector<const RpcPrepDataCollection*>& rpcCols, const std::vector<const TgcPrepDataCollection*>& tgcCols, + Trk::SegmentCollection* segColl) const = 0; /** @brief find tracks starting from a MuonSegmentCombinationCollection @param combiCol a reference to a MuonSegmentCombinationCollection @return a pointer to a vector of tracks, the ownership of the tracks is passed to the client calling the tool. */ - virtual MuonSegmentCombinationCollection* find( const MuonPatternCombinationCollection& patterns, MuonSegmentCombPatternCombAssociationMap* segPattMap ) const = 0; + virtual std::unique_ptr<MuonSegmentCombinationCollection> find( const MuonPatternCombinationCollection* patterns, MuonSegmentCombPatternCombAssociationMap* segPattMap, + const std::vector<const RpcPrepDataCollection*>& rpcCols, const std::vector<const TgcPrepDataCollection*>& tgcCols ) const = 0; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h index 65bf672013f8a32b0fdbc341ed75b9a246ee3f5a..9bde078228a5c0e3d61f3391d8dee752739187f2 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h @@ -1,12 +1,12 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_IMUONSEGMENTOVERLAPREMOVALTOOL_H #define MUON_IMUONSEGMENTOVERLAPREMOVALTOOL_H #include "GaudiKernel/IAlgTool.h" - +#include "TrkSegment/SegmentCollection.h" #include <vector> @@ -25,7 +25,7 @@ namespace Muon { */ class IMuonSegmentOverlapRemovalTool : virtual public IAlgTool { public: - typedef std::vector<const MuonSegment*> SegVec; + typedef std::vector<MuonSegment*> SegVec; typedef SegVec::iterator SegIt; typedef SegVec::const_iterator SegCit; public: @@ -33,9 +33,8 @@ namespace Muon { /** @brief access to tool interface */ static const InterfaceID& interfaceID() { return IID_IMuonSegmentOverlapRemovalTool; } - /** @brief remove duplicates from a vector of segments. The caller should take - ownership of the segments */ - virtual SegVec removeDuplicates( const SegVec& segments ) const = 0; + /** @brief remove duplicates from a Trk::SegmentCollection*/ + virtual void removeDuplicates( Trk::SegmentCollection* segments ) const = 0; /** @brief remove duplicates from a MuonSegmentCombination. The callers should take ownership of the new SegmentCombination. If the combination is diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonSegmentPairFittingTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonSegmentPairFittingTool.h index 74a91cacb4a2b6bcdccf9169e72417920d447b64..94dff3b0d54e2db1b0efbcc1fa3e85f514406141 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonSegmentPairFittingTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonSegmentPairFittingTool.h @@ -28,12 +28,12 @@ namespace Muon { static const InterfaceID& interfaceID() { return IID_IMuonSegmentPairFittingTool; } - virtual void trackParameters( const Muon::MuonSegment& seg ,double &theta,double &curvature,int &imeth ) = 0; - virtual void extrapolateSegment( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull ) = 0; + virtual void trackParameters( Muon::MuonSegment& seg ,double &theta,double &curvature,int &imeth ) = 0; + virtual void extrapolateSegment( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull ) = 0; - virtual void fit2Segments( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull ) = 0; - virtual void fit2SegmentsC( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull ) = 0; - virtual void fit2SegmentsSL( const Muon::MuonSegment& seg , const Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull ) = 0; + virtual void fit2Segments( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull ) = 0; + virtual void fit2SegmentsC( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull ) = 0; + virtual void fit2SegmentsSL( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull ) = 0; }; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentCombinationCleanerTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentCombinationCleanerTool.cxx index 8df7ee9ff8b0a7791c64ba44d7dee7dba0cf63f0..f14b4409a9bdebb13115e5abf053f27e035e7893 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentCombinationCleanerTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentCombinationCleanerTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonSegmentCombinationCleanerTool.h" @@ -90,12 +90,12 @@ namespace Muon { return StatusCode::SUCCESS; } - MuonSegmentCombinationCollection* MuonSegmentCombinationCleanerTool::clean( const MuonSegmentCombinationCollection& combiCol, - MuonSegmentCombPatternCombAssociationMap* segPattMap ){ + std::unique_ptr<MuonSegmentCombinationCollection> MuonSegmentCombinationCleanerTool::clean( const MuonSegmentCombinationCollection& combiCol, + MuonSegmentCombPatternCombAssociationMap* segPattMap ){ - MuonSegmentCombinationCollection* combiCleanCol = new MuonSegmentCombinationCollection; + std::unique_ptr<MuonSegmentCombinationCollection> combiCleanCol(new MuonSegmentCombinationCollection); - cleanAndMergeCombis(combiCol,combiCleanCol,segPattMap); + cleanAndMergeCombis(combiCol,combiCleanCol.get(),segPattMap); return combiCleanCol; } @@ -256,12 +256,12 @@ namespace Muon { ATH_MSG_VERBOSE(" -> large overlap, merge candidate "); // set to make sure we are not adding segments twice - std::set<const MuonSegment*> addedSegments; - std::vector< std::vector<const MuonSegment*> > segmentsPerChamberLayer(MuonStationIndex::ChIndexMax); + std::set<MuonSegment*> addedSegments; + std::vector< std::vector<MuonSegment* > > segmentsPerChamberLayer(MuonStationIndex::ChIndexMax); // first add shared segments, take one with best chi2 - std::vector< std::pair<const MuonSegment*,const MuonSegment*> >::iterator shit = overlap.shared.begin(); - std::vector< std::pair<const MuonSegment*,const MuonSegment*> >::iterator shit_end = overlap.shared.end(); + std::vector< std::pair<MuonSegment*,MuonSegment*> >::iterator shit = overlap.shared.begin(); + std::vector< std::pair<MuonSegment*,MuonSegment*> >::iterator shit_end = overlap.shared.end(); for( ;shit!=shit_end;++shit ){ // select segment with best chi2 @@ -269,7 +269,7 @@ namespace Muon { const Trk::FitQuality* fq2 =shit->second->fitQuality(); double chi2First = fq1 ? fq1->chiSquared() : 1e10; double chi2Second = fq2 ? fq2->chiSquared() : 1e10; - const MuonSegment* bestSegment = chi2First < chi2Second ? shit->first : shit->second; + MuonSegment* bestSegment = chi2First < chi2Second ? shit->first : shit->second; // check whether already added if( addedSegments.count(bestSegment) ) continue; @@ -279,11 +279,11 @@ namespace Muon { segmentsPerChamberLayer[chIndex].push_back(bestSegment); } - std::vector<const MuonSegment*>::iterator uit = overlap.uniqueFirst.begin(); - std::vector<const MuonSegment*>::iterator uit_end = overlap.uniqueFirst.end(); + std::vector<MuonSegment*>::iterator uit = overlap.uniqueFirst.begin(); + std::vector<MuonSegment*>::iterator uit_end = overlap.uniqueFirst.end(); for( ;uit!=uit_end;++uit ){ // check whether already added - const MuonSegment* bestSegment = *uit; + MuonSegment* bestSegment = *uit; // check whether already added if( addedSegments.count(bestSegment) ) continue; @@ -297,7 +297,7 @@ namespace Muon { uit_end = overlap.uniqueSecond.end(); for( ;uit!=uit_end;++uit ){ // check whether already added - const MuonSegment* bestSegment = *uit; + MuonSegment* bestSegment = *uit; // check whether already added if( addedSegments.count(bestSegment) ) continue; @@ -311,7 +311,7 @@ namespace Muon { shit_end = overlap.subsetFirst.end(); for( ;shit!=shit_end;++shit ){ // check whether already added - const MuonSegment* bestSegment = shit->second; + MuonSegment* bestSegment = shit->second; // check whether already added if( addedSegments.count(bestSegment) ) continue; @@ -325,7 +325,7 @@ namespace Muon { shit_end = overlap.subsetSecond.end(); for( ;shit!=shit_end;++shit ){ // check whether already added - const MuonSegment* bestSegment = shit->first; + MuonSegment* bestSegment = shit->first; // check whether already added if( addedSegments.count(bestSegment) ) continue; @@ -339,19 +339,19 @@ namespace Muon { MuonSegmentCombination* newCombi = new MuonSegmentCombination(); // loop over layers and add segments - std::vector< std::vector<const MuonSegment*> >::iterator chit = segmentsPerChamberLayer.begin(); - std::vector< std::vector<const MuonSegment*> >::iterator chit_end = segmentsPerChamberLayer.end(); + std::vector< std::vector<MuonSegment*> >::iterator chit = segmentsPerChamberLayer.begin(); + std::vector< std::vector<MuonSegment*> >::iterator chit_end = segmentsPerChamberLayer.end(); for( ;chit!=chit_end;++chit ){ // skip empty ones if( chit->empty() ) continue; - std::vector< const MuonSegment* >* segVec = new std::vector< const MuonSegment* >(); + std::unique_ptr<std::vector< std::unique_ptr<MuonSegment> > > segVec(new std::vector< std::unique_ptr<MuonSegment> >()); segVec->reserve( chit->size() ); - std::vector<const MuonSegment*>::iterator segit = chit->begin(); - std::vector<const MuonSegment*>::iterator segit_end = chit->end(); - for( ;segit!=segit_end;++segit ) segVec->push_back( (*segit)->clone() ); - newCombi->addSegments( segVec ); + std::vector<MuonSegment*>::iterator segit = chit->begin(); + std::vector<MuonSegment*>::iterator segit_end = chit->end(); + for( ;segit!=segit_end;++segit ) segVec->push_back( std::unique_ptr<MuonSegment>((*segit)->clone()) ); + newCombi->addSegments( std::move(segVec) ); } // create new summary @@ -414,8 +414,8 @@ namespace Muon { return summary; } - void MuonSegmentCombinationCleanerTool::resolveLayerOverlap( const std::vector<const MuonSegment*>& chamberVec1, - const std::vector<const MuonSegment*>& chamberVec2, + void MuonSegmentCombinationCleanerTool::resolveLayerOverlap( const std::vector<MuonSegment*>& chamberVec1, + const std::vector<MuonSegment*>& chamberVec2, MuonSegmentCombiOverlapSummary& summary) const { CompareMuonSegmentKeys compareKeys; @@ -423,15 +423,15 @@ namespace Muon { std::vector<int> uniqueSecond(chamberVec2.size(),1); unsigned int index1 = 0; - std::vector<const MuonSegment*>::const_iterator sit1 = chamberVec1.begin(); - std::vector<const MuonSegment*>::const_iterator sit1_end = chamberVec1.end(); + std::vector<MuonSegment*>::const_iterator sit1 = chamberVec1.begin(); + std::vector<MuonSegment*>::const_iterator sit1_end = chamberVec1.end(); for( ;sit1!=sit1_end;++sit1,++index1 ){ // identifier(s) of MDT chambers on segment std::set<Identifier> chIds1 = m_helperTool->chamberIds( **sit1 ); unsigned int index2 = 0; - std::vector<const MuonSegment*>::const_iterator sit2 = chamberVec2.begin(); - std::vector<const MuonSegment*>::const_iterator sit2_end = chamberVec2.end(); + std::vector<MuonSegment*>::const_iterator sit2 = chamberVec2.begin(); + std::vector<MuonSegment*>::const_iterator sit2_end = chamberVec2.end(); for( ;sit2!=sit2_end;++sit2,++index2 ){ if( !uniqueSecond[index2] ) continue; @@ -507,8 +507,8 @@ namespace Muon { } unsigned int index2 = 0; - std::vector<const MuonSegment*>::const_iterator sit2 = chamberVec2.begin(); - std::vector<const MuonSegment*>::const_iterator sit2_end = chamberVec2.end(); + std::vector<MuonSegment*>::const_iterator sit2 = chamberVec2.begin(); + std::vector<MuonSegment*>::const_iterator sit2_end = chamberVec2.end(); for( ;sit2!=sit2_end;++sit2,++index2 ){ if( uniqueSecond[index2] ) summary.uniqueSecond.push_back(*sit2); } @@ -529,12 +529,12 @@ namespace Muon { // loop over segments in station const MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; - + // check if not empty if( !stationSegs || stationSegs->empty() ) continue; - + // get chamber identifier, chamber index and station index - Identifier chid = m_helperTool->chamberId( *stationSegs->front() ); + Identifier chid = m_helperTool->chamberId( *stationSegs->front().get() ); MuonStationIndex::ChIndex chIndex = m_idHelperTool->chamberIndex(chid); MuonStationIndex::StIndex stIndex = MuonStationIndex::toStationIndex( chIndex ); summary.stations.insert(stIndex); @@ -548,13 +548,7 @@ namespace Muon { MuonSegmentCombination::SegmentVec::const_iterator ipsg_end=stationSegs->end(); for (;ipsg!=ipsg_end;++ipsg){ - const MuonSegment* seg = dynamic_cast<const MuonSegment*>(*ipsg); - - if( !seg ){ - ATH_MSG_WARNING(" MuonSegmentCombination contains a segment that is not a MuonSegment!! "); - continue; - } - + MuonSegment* seg=(*ipsg).get(); if( seg->containedROTs().size() > 3 ) { summary.stationsGood.insert(stIndex); } @@ -571,7 +565,7 @@ namespace Muon { CompareMuonSegmentKeys compareKeys; // store pointers to segments that should be kept - std::set<const MuonSegment*> segmentsToBeKept; + std::set<MuonSegment*> segmentsToBeKept; unsigned int nsegments = 0; // total number of segments unsigned int nstations = combi.numberOfStations(); @@ -581,28 +575,21 @@ namespace Muon { for(unsigned int i=0; i<nstations; ++i){ // loop over segments in station - const MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; + MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; // check if not empty if( !stationSegs || stationSegs->empty() ) continue; - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> > keys; + std::vector< std::pair<MuonSegmentKey,MuonSegment*> > keys; keys.reserve(stationSegs->size()); - MuonSegmentCombination::SegmentVec::const_iterator ipsg=stationSegs->begin(); - MuonSegmentCombination::SegmentVec::const_iterator ipsg_end=stationSegs->end(); + MuonSegmentCombination::SegmentVec::iterator ipsg=stationSegs->begin(); + MuonSegmentCombination::SegmentVec::iterator ipsg_end=stationSegs->end(); for (;ipsg!=ipsg_end;++ipsg){ ++nsegments; - const MuonSegment* seg = dynamic_cast<const MuonSegment*>(*ipsg); - - if( !seg ){ - ATH_MSG_WARNING(" MuonSegmentCombination contains a segment that is not a MuonSegment!! "); - continue; - } - - + MuonSegment* seg=(*ipsg).get(); ATH_MSG_VERBOSE(" segment " << m_printer->print(*seg) << std::endl << m_printer->print( seg->containedMeasurements() ) ); // create key @@ -610,8 +597,8 @@ namespace Muon { // loop over already added keys bool addSegment = true; - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator kit = keys.begin(); - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator kit_end = keys.end(); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator kit = keys.begin(); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator kit_end = keys.end(); for( ;kit!=kit_end;++kit ) { CompareMuonSegmentKeys::OverlapResult overlapResult = compareKeys(key,kit->first); @@ -632,8 +619,8 @@ namespace Muon { if( addSegment ) keys.push_back( std::make_pair(key,seg) ); } - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator kit = keys.begin(); - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator kit_end = keys.end(); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator kit = keys.begin(); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator kit_end = keys.end(); for( ;kit!=kit_end;++kit ) segmentsToBeKept.insert( kit->second ); } @@ -649,28 +636,26 @@ namespace Muon { for(unsigned int i=0; i<nstations; ++i){ // loop over segments in station - const MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; + MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; // check if not empty if( !stationSegs || stationSegs->empty() ) continue; - std::vector< const MuonSegment* >* segVec = new std::vector< const MuonSegment* >(); + std::unique_ptr<std::vector< std::unique_ptr< MuonSegment> > > segVec(new std::vector< std::unique_ptr< MuonSegment> >()); segVec->reserve( stationSegs->size() ); - - MuonSegmentCombination::SegmentVec::const_iterator ipsg=stationSegs->begin(); - MuonSegmentCombination::SegmentVec::const_iterator ipsg_end=stationSegs->end(); + MuonSegmentCombination::SegmentVec::iterator ipsg=stationSegs->begin(); + MuonSegmentCombination::SegmentVec::iterator ipsg_end=stationSegs->end(); for (;ipsg!=ipsg_end;++ipsg){ - const MuonSegment* seg = dynamic_cast<const MuonSegment*>(*ipsg); - + MuonSegment* seg=(*ipsg).get(); if( !segmentsToBeKept.count(seg) ){ ATH_MSG_VERBOSE(" dropping segment " << m_printer->print(*seg) ); continue; }else ATH_MSG_VERBOSE(" adding segment " << m_printer->print(*seg) ); - segVec->push_back( seg->clone() ); + segVec->push_back( std::move(*ipsg) ); } - newCombi->addSegments( segVec ); + newCombi->addSegments( std::move(segVec) ); } return newCombi; @@ -693,9 +678,12 @@ namespace Muon { // skip empty layers if( chit->empty() ) continue; - - sout << " Chamber Layer: " << MuonStationIndex::chName((MuonStationIndex::ChIndex)index) << " with " << chit->size() << " segments " << std::endl - << m_printer->print( *chit ) << std::endl; + + sout << " Chamber Layer: " << MuonStationIndex::chName((MuonStationIndex::ChIndex)index) << " with " << chit->size() << " segments " << std::endl; + + std::vector<MuonSegment*>::iterator segit=(*chit).begin(); + std::vector<MuonSegment*>::iterator segit_end=(*chit).end(); + for(;segit!=segit_end;++segit) sout<< m_printer->print( **segit ) << std::endl; ++index; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentCombinationCleanerTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentCombinationCleanerTool.h index 66ed92623c720cb72f968108db3e648f86622053..b2b21657e07721a054f067c8414cffc687ed4a1c 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentCombinationCleanerTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentCombinationCleanerTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONSEGMENTCOMBINATIONCLEANERTOOL_H @@ -44,7 +44,7 @@ namespace Muon { virtual StatusCode finalize(); /** clean segment combination collections */ - MuonSegmentCombinationCollection* clean( const MuonSegmentCombinationCollection& combiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap ); + std::unique_ptr<MuonSegmentCombinationCollection> clean( const MuonSegmentCombinationCollection& combiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap ); /** remove duplicates from a segment combination, returns a pointer to the original combi if unchanged */ MuonSegmentCombination* removeDuplicateSegments( MuonSegmentCombination& combi ) const; @@ -61,7 +61,7 @@ namespace Muon { MuonSegmentCombiOverlapSummary calculateOverlap( MuonSegmentCombiSummary& summary1, MuonSegmentCombiSummary& summary2 ) const; /* resolve overlap between two vectors of segments */ - void resolveLayerOverlap( const std::vector<const MuonSegment*>& chamberVec1, const std::vector<const MuonSegment*>& chamberVec2, + void resolveLayerOverlap( const std::vector<MuonSegment*>& chamberVec1, const std::vector<MuonSegment*>& chamberVec2, MuonSegmentCombiOverlapSummary& summary) const; /** create summary */ diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentOverlapRemovalTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentOverlapRemovalTool.cxx index d39f68cc3380f66fbda681ad014a9fcdd035da78..8b40cc34b5b66f8468048dcd634c9d7a56aa7553 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentOverlapRemovalTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentOverlapRemovalTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonSegmentOverlapRemovalTool.h" @@ -9,7 +9,6 @@ #include "MuonRecHelperTools/MuonEDMPrinterTool.h" #include "MuonSegment/MuonSegment.h" -#include "MuonSegment/MuonSegmentCombination.h" #include "MuonSegmentMakerUtils/MuonSegmentKey.h" #include "MuonSegmentMakerUtils/CompareMuonSegmentKeys.h" @@ -76,39 +75,45 @@ namespace Muon { return sc; } - MuonSegmentOverlapRemovalTool::SegVec - MuonSegmentOverlapRemovalTool::removeDuplicates( const MuonSegmentOverlapRemovalTool::SegVec& segments ) const { + void MuonSegmentOverlapRemovalTool::removeDuplicates( Trk::SegmentCollection* segments ) const { - ATH_MSG_DEBUG(" working on segment vector of size " << segments.size() ); + ATH_MSG_DEBUG(" working on segment vector of size " << segments->size() ); CompareMuonSegmentKeys compareSegmentKeys; // create a vector with pairs of MuonSegmentKey and a pointer to the corresponding segment to resolve ambiguities - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> > goodSegments; - goodSegments.reserve(segments.size()); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> > goodSegments; + goodSegments.reserve(segments->size()); + std::vector<MuonSegment*> segmentsToErase; // loop over new segments, copy them into collection - SegCit sit = segments.begin(); - SegCit sit_end = segments.end(); + Trk::SegmentCollection::iterator sit = segments->begin(); + Trk::SegmentCollection::iterator sit_end = segments->end(); for( ; sit!=sit_end;++sit){ // create segment key object - MuonSegmentKey sk(**sit); - Identifier chId = m_helperTool->chamberId(**sit); + Trk::Segment* tseg=*sit; + MuonSegment* seg=dynamic_cast<MuonSegment*>(tseg); + if(!seg){ + ATH_MSG_WARNING("segment is not MuonSegment"); + continue; + } + MuonSegmentKey sk(*seg); + Identifier chId = m_helperTool->chamberId(*seg); bool isCsc = m_idHelperTool->isCsc(chId); // should this segment be inserted? bool insertAsGood(true); // loop over already accepted segments and compare the current segment with the good ones - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator gsit = goodSegments.begin(); - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator gsit_end = goodSegments.end(); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator gsit = goodSegments.begin(); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator gsit_end = goodSegments.end(); for( ;gsit!=gsit_end;++gsit ){ CompareMuonSegmentKeys::OverlapResult overlapResult = compareSegmentKeys( gsit->first, sk ); if( overlapResult == CompareMuonSegmentKeys::Identical ) { // for now keep the one with the best chi2 const Trk::FitQuality* fq1 = gsit->second->fitQuality(); - const Trk::FitQuality* fq2 = (*sit)->fitQuality(); + const Trk::FitQuality* fq2 = seg->fitQuality(); double chi2good = fq1 ? fq1->chiSquared() : 1e10; double chi2current = fq2 ? fq2->chiSquared() : 1e10; // we should not insert this segment @@ -117,26 +122,30 @@ namespace Muon { << " with " << m_printer->print(**sit) ); // good segment of worse quality, replace it + segmentsToErase.push_back(gsit->second); gsit->first = sk; - gsit->second = *sit; + gsit->second = seg; }else{ - ATH_MSG_VERBOSE(" discarding (chi2) " << m_printer->print(**sit) ); + ATH_MSG_VERBOSE(" discarding (chi2) " << m_printer->print(*seg) ); + segmentsToErase.push_back(seg); } insertAsGood = false; break; }else if( overlapResult == CompareMuonSegmentKeys::SuperSet ){ // good segment of better quality, keep it and discard current segment - ATH_MSG_VERBOSE(" discarding (subset) " << m_printer->print(**sit) ); + ATH_MSG_VERBOSE(" discarding (subset) " << m_printer->print(*seg) ); + segmentsToErase.push_back(seg); insertAsGood = false; break; }else if( overlapResult == CompareMuonSegmentKeys::SubSet ){ // good segment of worse quality, replace it ATH_MSG_VERBOSE(" replacing (superset) " << m_printer->print(*gsit->second) << std::endl - << " with " << m_printer->print(**sit) ); + << " with " << m_printer->print(*seg) ); + segmentsToErase.push_back(gsit->second); gsit->first = sk; - gsit->second = *sit; + gsit->second = seg; insertAsGood = false; break; }else if( overlapResult == CompareMuonSegmentKeys::PartialOverlap && m_removePartialOverlaps ){ @@ -147,25 +156,29 @@ namespace Muon { // partial overlap, for now keep the one most hits if( compareSegmentKeys.segment1Size < compareSegmentKeys.segment2Size ){ ATH_MSG_VERBOSE(" replacing (mdt hits) " << m_printer->print(*gsit->second) << std::endl - << " with " << m_printer->print(**sit) ); + << " with " << m_printer->print(*seg) ); // good segment of worse quality, replace it + segmentsToErase.push_back(gsit->second); gsit->first = sk; - gsit->second = *sit; + gsit->second = seg; + insertAsGood=false; }else if( compareSegmentKeys.segment1Size == compareSegmentKeys.segment2Size ){ // same size // if the original entry has more trigger hits discard current segment if( compareSegmentKeys.segment1SizeTrigger > compareSegmentKeys.segment2SizeTrigger ){ - ATH_MSG_VERBOSE(" discarding (trigger hits) " << m_printer->print(**sit) ); + ATH_MSG_VERBOSE(" discarding (trigger hits) " << m_printer->print(*seg) ); + segmentsToErase.push_back(seg); insertAsGood = false; break; }else if( compareSegmentKeys.segment1SizeTrigger < compareSegmentKeys.segment2SizeTrigger ){ // good segment of worse quality, replace it ATH_MSG_VERBOSE(" replacing (trigger hits) " << m_printer->print(*gsit->second) << std::endl - << " with " << m_printer->print(**sit) ); + << " with " << m_printer->print(*seg) ); + segmentsToErase.push_back(gsit->second); gsit->first = sk; - gsit->second = *sit; + gsit->second = seg; insertAsGood = false; break; }else if( compareSegmentKeys.segment1SizeTrigger == compareSegmentKeys.segment2SizeTrigger ){ @@ -176,14 +189,16 @@ namespace Muon { // calculate the overlap fraction double overlapFraction = (double)compareSegmentKeys.intersectionSize/(double)compareSegmentKeys.segment1Size; if( overlapFraction > m_overlapFractionCut ){ - ATH_MSG_VERBOSE(" discarding (overlap fraction) " << m_printer->print(**sit) ); + ATH_MSG_VERBOSE(" discarding (overlap fraction) " << m_printer->print(*seg) ); + segmentsToErase.push_back(seg); insertAsGood = false; break; } continue; }else{ - ATH_MSG_VERBOSE(" discarding " << m_printer->print(**sit) ); + ATH_MSG_VERBOSE(" discarding " << m_printer->print(*seg) ); + segmentsToErase.push_back(seg); } insertAsGood = false; break; @@ -198,28 +213,32 @@ namespace Muon { // add segment if needed if( insertAsGood ) { - ATH_MSG_VERBOSE(" no overlap " << m_printer->print(**sit) ); - goodSegments.push_back( std::make_pair(sk,*sit) ); + ATH_MSG_VERBOSE(" no overlap " << m_printer->print(*seg) ); + goodSegments.push_back( std::make_pair(sk,seg) ); } } - SegVec cleanedSegments; - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator gsit = goodSegments.begin(); - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator gsit_end = goodSegments.end(); - for( ; gsit!=gsit_end;++gsit){ - cleanedSegments.push_back( gsit->second ); + //erase rejected segments + for(std::vector<MuonSegment*>::iterator vit=segmentsToErase.begin();vit!=segmentsToErase.end();++vit){ + sit = segments->begin(); + for(; sit!=sit_end;++sit){ + //remove bad segments from collection, then delete them + Trk::Segment* tseg=*sit; + if((*vit)==dynamic_cast<MuonSegment*>(tseg)){ + segments->erase(sit); + break; + } + } + if(sit==sit_end) ATH_MSG_WARNING("did not find bad segment for deletion"); } - ATH_MSG_DEBUG(" Segments after removal " << cleanedSegments.size() - << " total number of removed segments " << segments.size() - cleanedSegments.size() ); - - return cleanedSegments; + } const MuonSegmentCombination* MuonSegmentOverlapRemovalTool::removeDuplicates( const MuonSegmentCombination& combi ) const { // store pointers to segments that should be kept - std::set<const MuonSegment*> segmentsToBeKept; + std::set<MuonSegment*> segmentsToBeKept; unsigned int nsegments = 0; // total number of segments unsigned int nstations = combi.numberOfStations(); @@ -232,7 +251,7 @@ namespace Muon { for(unsigned int i=0; i<nstations; ++i){ // loop over segments in station - const MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; + MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; // check if not empty if( !stationSegs || stationSegs->empty() ) continue; @@ -256,12 +275,12 @@ namespace Muon { for(unsigned int i=0; i<nstations; ++i){ // loop over segments in station - const MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; + MuonSegmentCombination::SegmentVec* stationSegs = combi.stationSegments( i ) ; // check if not empty if( !stationSegs || stationSegs->empty() ) continue; - std::vector< const MuonSegment* >* segVec = new std::vector< const MuonSegment* >(); + std::unique_ptr<std::vector< std::unique_ptr<MuonSegment> > > segVec(new std::vector< std::unique_ptr< MuonSegment> >()); segVec->reserve( stationSegs->size() ); // loop over segments and add them if they are in the keep set @@ -269,22 +288,163 @@ namespace Muon { MuonSegmentCombination::SegmentVec::const_iterator ipsg_end=stationSegs->end(); for (;ipsg!=ipsg_end;++ipsg){ - const MuonSegment* seg = dynamic_cast<const MuonSegment*>(*ipsg); + MuonSegment* seg = (*ipsg).get(); if( !segmentsToBeKept.count(seg) ){ continue; }else{ - segVec->push_back( seg->clone() ); + segVec->push_back( std::unique_ptr<MuonSegment>(seg->clone()) ); } } // if not empty add segments - if( !segVec->empty() ) newCombi->addSegments( segVec ); - else delete segVec; + if( !segVec->empty() ) newCombi->addSegments( std::move(segVec) ); } ATH_MSG_DEBUG(" removed " << nsegments-segmentsToBeKept.size() << " duplicates, new size " << segmentsToBeKept.size() ); return newCombi; } + + //this applies only to the case of cleaning MuonSegmentCombinations, above + //currently not used, maybe it can be removed entirely? + MuonSegmentOverlapRemovalTool::SegVec + MuonSegmentOverlapRemovalTool::removeDuplicates( MuonSegmentCombination::SegmentVec& segments ) const { + + ATH_MSG_DEBUG(" working on segment vector of size " << segments.size() ); + + CompareMuonSegmentKeys compareSegmentKeys; + + // create a vector with pairs of MuonSegmentKey and a pointer to the corresponding segment to resolve ambiguities + std::vector< std::pair<MuonSegmentKey,MuonSegment*> > goodSegments; + goodSegments.reserve(segments.size()); + + // loop over new segments, copy them into collection + MuonSegmentCombination::SegmentVec::iterator sit = segments.begin(); + MuonSegmentCombination::SegmentVec::iterator sit_end = segments.end(); + for( ; sit!=sit_end;++sit){ + + // create segment key object + MuonSegment* seg=(*sit).get(); + MuonSegmentKey sk(*seg); + Identifier chId = m_helperTool->chamberId(*seg); + bool isCsc = m_idHelperTool->isCsc(chId); + + // should this segment be inserted? + bool insertAsGood(true); + + // loop over already accepted segments and compare the current segment with the good ones + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator gsit = goodSegments.begin(); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator gsit_end = goodSegments.end(); + for( ;gsit!=gsit_end;++gsit ){ + CompareMuonSegmentKeys::OverlapResult overlapResult = compareSegmentKeys( gsit->first, sk ); + if( overlapResult == CompareMuonSegmentKeys::Identical ) { + // for now keep the one with the best chi2 + const Trk::FitQuality* fq1 = gsit->second->fitQuality(); + const Trk::FitQuality* fq2 = seg->fitQuality(); + double chi2good = fq1 ? fq1->chiSquared() : 1e10; + double chi2current = fq2 ? fq2->chiSquared() : 1e10; + // we should not insert this segment + if( chi2good > chi2current ) { + ATH_MSG_VERBOSE(" replacing (chi2) " << m_printer->print(*gsit->second) << std::endl + << " with " << m_printer->print(*seg) ); + + // good segment of worse quality, replace it + gsit->first = sk; + gsit->second = seg; + + }else{ + ATH_MSG_VERBOSE(" discarding (chi2) " << m_printer->print(*seg) ); + } + insertAsGood = false; + break; + }else if( overlapResult == CompareMuonSegmentKeys::SuperSet ){ + // good segment of better quality, keep it and discard current segment + ATH_MSG_VERBOSE(" discarding (subset) " << m_printer->print(*seg) ); + insertAsGood = false; + break; + }else if( overlapResult == CompareMuonSegmentKeys::SubSet ){ + // good segment of worse quality, replace it + ATH_MSG_VERBOSE(" replacing (superset) " << m_printer->print(*gsit->second) << std::endl + << " with " << m_printer->print(*seg) ); + gsit->first = sk; + gsit->second = seg; + insertAsGood = false; + break; + }else if( overlapResult == CompareMuonSegmentKeys::PartialOverlap && m_removePartialOverlaps ){ + + // keep CSC segments with partial overlap + if( isCsc ) continue; + + // partial overlap, for now keep the one most hits + if( compareSegmentKeys.segment1Size < compareSegmentKeys.segment2Size ){ + ATH_MSG_VERBOSE(" replacing (mdt hits) " << m_printer->print(*gsit->second) << std::endl + << " with " << m_printer->print(*seg) ); + + // good segment of worse quality, replace it + gsit->first = sk; + gsit->second = seg; + }else if( compareSegmentKeys.segment1Size == compareSegmentKeys.segment2Size ){ + // same size + + // if the original entry has more trigger hits discard current segment + if( compareSegmentKeys.segment1SizeTrigger > compareSegmentKeys.segment2SizeTrigger ){ + ATH_MSG_VERBOSE(" discarding (trigger hits) " << m_printer->print(*seg) ); + insertAsGood = false; + break; + }else if( compareSegmentKeys.segment1SizeTrigger < compareSegmentKeys.segment2SizeTrigger ){ + // good segment of worse quality, replace it + ATH_MSG_VERBOSE(" replacing (trigger hits) " << m_printer->print(*gsit->second) << std::endl + << " with " << m_printer->print(*seg) ); + gsit->first = sk; + gsit->second = seg; + insertAsGood = false; + break; + }else if( compareSegmentKeys.segment1SizeTrigger == compareSegmentKeys.segment2SizeTrigger ){ + + // for now look at the overlap fraction + + } + // calculate the overlap fraction + double overlapFraction = (double)compareSegmentKeys.intersectionSize/(double)compareSegmentKeys.segment1Size; + if( overlapFraction > m_overlapFractionCut ){ + ATH_MSG_VERBOSE(" discarding (overlap fraction) " << m_printer->print(*seg) ); + insertAsGood = false; + break; + } + + continue; + }else{ + ATH_MSG_VERBOSE(" discarding " << m_printer->print(*seg) ); + } + insertAsGood = false; + break; + }else if( overlapResult == CompareMuonSegmentKeys::NoOverlap ){ + // no overlap, move on to next segment + continue; + }else if( overlapResult == CompareMuonSegmentKeys::Unknown ){ + ATH_MSG_WARNING(" Got invalid return argument comparing segments: " << compareSegmentKeys.print(overlapResult) ); + continue; + } + } + + // add segment if needed + if( insertAsGood ) { + ATH_MSG_VERBOSE(" no overlap " << m_printer->print(*seg) ); + goodSegments.push_back( std::make_pair(sk,seg) ); + } + } + + SegVec cleanedSegments; + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator gsit = goodSegments.begin(); + std::vector< std::pair<MuonSegmentKey,MuonSegment*> >::iterator gsit_end = goodSegments.end(); + for( ; gsit!=gsit_end;++gsit){ + cleanedSegments.push_back( gsit->second ); + } + ATH_MSG_DEBUG(" Segments after removal " << cleanedSegments.size() + << " total number of removed segments " << segments.size() - cleanedSegments.size() ); + + return cleanedSegments; + } + } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentOverlapRemovalTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentOverlapRemovalTool.h index 8efa81cb0ca2055fbc0d4f3efffc793495cdfafd..54559211052bab497f6285ca33835612cf56d114 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentOverlapRemovalTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentOverlapRemovalTools/src/MuonSegmentOverlapRemovalTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_MUONSEGMENTSOVERLAPREMOVALTOOL_H @@ -9,6 +9,7 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ToolHandle.h" +#include "MuonSegment/MuonSegmentCombination.h" namespace Muon { @@ -37,7 +38,7 @@ namespace Muon { /** @brief remove duplicates from a vector of segments. The caller should take ownership of the segments */ - SegVec removeDuplicates( const SegVec& segments ) const; + void removeDuplicates( Trk::SegmentCollection* segments ) const; /** @brief remove duplicates from a MuonSegmentCombination. The callers should take ownership of the new SegmentCombination. If the combination is @@ -47,6 +48,10 @@ namespace Muon { private: + //this is only needed now by the call to remove duplicates from a MuonSegmentCombination + //cleaning of MuonSegmentCombinations is turned off, so perhaps this can be removed entirely + SegVec removeDuplicates( MuonSegmentCombination::SegmentVec& segments ) const; + ToolHandle<Muon::MuonIdHelperTool> m_idHelperTool; //!< IdHelper tool ToolHandle<Muon::MuonEDMHelperTool> m_helperTool; //!< EDM Helper tool ToolHandle<Muon::MuonEDMPrinterTool> m_printer; //!< EDM printer tool diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool.h index 57755139cc8d45339333e438910a5f0a0ed041b6..01218cd6de124379ac2574b568e5cfedb1885214 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef RPC_LINEARSEGMENTMAKERTOOL_H @@ -24,40 +24,39 @@ public: StatusCode initialize(); StatusCode Finalize(); - virtual std::vector<const Muon::MuonSegment*>* - find(const std::vector<const Trk::RIO_OnTrack*>&) const + virtual void + find(const std::vector<const Trk::RIO_OnTrack*>&, + Trk::SegmentCollection*) const { - return NULL; } - virtual std::vector<const Muon::MuonSegment*>* + virtual void find(const std::vector<const Trk::RIO_OnTrack*>&, const std::vector<const Trk::RIO_OnTrack*>&) const { - return NULL; } - virtual std::vector<const Muon::MuonSegment*>* + virtual void find(const std::vector<const Muon::MdtDriftCircleOnTrack*>&, - const std::vector<const Muon::MuonClusterOnTrack*>&) const + const std::vector<const Muon::MuonClusterOnTrack*>&, + Trk::SegmentCollection*) const { - return NULL; } - virtual std::vector<const Muon::MuonSegment*>* + virtual void find(const Amg::Vector3D&, const Amg::Vector3D&, const std::vector<const Muon::MdtDriftCircleOnTrack*>&, const std::vector<const Muon::MuonClusterOnTrack*>&, - bool,double) const + bool,Trk::SegmentCollection*,double,double) const { - return NULL; } - virtual std::vector<const Muon::MuonSegment*>* + virtual void find(const Trk::TrackRoad& road, const std::vector< std::vector< const Muon::MdtDriftCircleOnTrack* > >& mdts, const std::vector< std::vector< const Muon::MuonClusterOnTrack* > >& clusters, + Trk::SegmentCollection* segCol=0, bool hasPhiMeasurements = false,double momentum=1e9) const; private: diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/RPC_LinearSegmentMakerTool/src/RPC_LinearSegmentMakerTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/RPC_LinearSegmentMakerTool/src/RPC_LinearSegmentMakerTool.cxx index b140d231989b7d168c34c5ac7055e125eeb3fa0d..9579acffb2c2dd03cc4a4d4428f6066407793b2c 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/RPC_LinearSegmentMakerTool/src/RPC_LinearSegmentMakerTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/RPC_LinearSegmentMakerTool/src/RPC_LinearSegmentMakerTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "RPC_LinearSegmentMakerTool/RPC_LinearSegmentMakerTool.h" @@ -82,10 +82,11 @@ static inline double getFirstPointR(const Muon::Fit2D::PointArray& points) return 0.0; } -std::vector<const Muon::MuonSegment*>* +void RPC_LinearSegmentMakerTool::find(const Trk::TrackRoad& road, const std::vector< std::vector< const Muon::MdtDriftCircleOnTrack* > >&, const std::vector< std::vector< const Muon::MuonClusterOnTrack* > >& clusters, + Trk::SegmentCollection*, bool,double) const { ATH_MSG_DEBUG("RPC_LinearSegmentMakerTool::find"); @@ -108,7 +109,7 @@ RPC_LinearSegmentMakerTool::find(const Trk::TrackRoad& road, if (!pReadoutElement) { ATH_MSG_WARNING("Cannot get a RpcReadoutElement via dynamic cast."); - return pMuonSegs; + //return pMuonSegs; } std::set<LayerID> zStations, phiStations; @@ -320,5 +321,5 @@ done: delete zPoints[iZ]; for (unsigned iPhi = 0; iPhi < phiPoints.size(); iPhi++) delete phiPoints[iPhi]; - return pMuonSegs; + //return pMuonSegs; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/TGC_LinearSegmentMakerTool/TGC_LinearSegmentMakerTool/TGC_LinearSegmentMakerTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/TGC_LinearSegmentMakerTool/TGC_LinearSegmentMakerTool/TGC_LinearSegmentMakerTool.h index 5a46ae4bac25ebc03aeaddb57596d1885eca5810..0e67fbc033f2f36b48ca0313bee0c63a53b78a19 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/TGC_LinearSegmentMakerTool/TGC_LinearSegmentMakerTool/TGC_LinearSegmentMakerTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/TGC_LinearSegmentMakerTool/TGC_LinearSegmentMakerTool/TGC_LinearSegmentMakerTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TGC_LINEARSEGMENTMAKERTOOL_H @@ -27,40 +27,40 @@ public: StatusCode initialize(); StatusCode Finalize(); - virtual std::vector<const Muon::MuonSegment*>* - find(const std::vector<const Trk::RIO_OnTrack*>&) const + virtual void + find(const std::vector<const Trk::RIO_OnTrack*>&, + Trk::SegmentCollection*) const { - return NULL; } - virtual std::vector<const Muon::MuonSegment*>* + virtual void find(const std::vector<const Trk::RIO_OnTrack*>&, const std::vector<const Trk::RIO_OnTrack*>&) const { - return NULL; } - virtual std::vector<const Muon::MuonSegment*>* + virtual void find(const std::vector<const Muon::MdtDriftCircleOnTrack*>&, - const std::vector<const Muon::MuonClusterOnTrack*>&) const + const std::vector<const Muon::MuonClusterOnTrack*>&, + Trk::SegmentCollection*) const { - return NULL; } - virtual std::vector<const Muon::MuonSegment*>* + virtual void find(const Amg::Vector3D&, const Amg::Vector3D&, const std::vector<const Muon::MdtDriftCircleOnTrack*>&, const std::vector<const Muon::MuonClusterOnTrack*>&, - bool,double) const + bool,Trk::SegmentCollection*, + double,double) const { - return NULL; } - virtual std::vector<const Muon::MuonSegment*>* + virtual void find(const Trk::TrackRoad& road, const std::vector< std::vector< const Muon::MdtDriftCircleOnTrack* > >& mdts, const std::vector< std::vector< const Muon::MuonClusterOnTrack* > >& clusters, + Trk::SegmentCollection* segColl=0, bool hasPhiMeasurements = false,double momentum=1e9) const; private: diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/TGC_LinearSegmentMakerTool/src/TGC_LinearSegmentMakerTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/TGC_LinearSegmentMakerTool/src/TGC_LinearSegmentMakerTool.cxx index 3ef66949c5ab7adabee489ee5e37b69fa98ddb48..df63b2f8a9ba38798571ce6b9e068e41b2ba2737 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/TGC_LinearSegmentMakerTool/src/TGC_LinearSegmentMakerTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/TGC_LinearSegmentMakerTool/src/TGC_LinearSegmentMakerTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "StoreGate/StoreGateSvc.h" @@ -94,11 +94,11 @@ static inline double getFirstPointZ(const Muon::Fit2D::PointArray& points) return 0.0; } -std::vector<const Muon::MuonSegment*>* -TGC_LinearSegmentMakerTool::find(const Trk::TrackRoad& road, - const std::vector< std::vector< const Muon::MdtDriftCircleOnTrack* > >&, - const std::vector< std::vector< const Muon::MuonClusterOnTrack* > >& clusters, - bool,double) const +void TGC_LinearSegmentMakerTool::find(const Trk::TrackRoad& road, + const std::vector< std::vector< const Muon::MdtDriftCircleOnTrack* > >&, + const std::vector< std::vector< const Muon::MuonClusterOnTrack* > >& clusters, + Trk::SegmentCollection*, + bool,double) const { ATH_MSG_DEBUG("TGC_LinearSegmentMakerTool::find"); @@ -114,7 +114,7 @@ TGC_LinearSegmentMakerTool::find(const Trk::TrackRoad& road, const MuonGM::TgcReadoutElement* pReadoutElement = dynamic_cast<const MuonGM::TgcReadoutElement*>(rios.front()->detectorElement()); - if (!pReadoutElement) return 0; + if (!pReadoutElement) return; std::set<std::string> rhoStations, phiStations; int iHit = 0; @@ -322,6 +322,6 @@ done: delete *itPt; ATH_MSG_DEBUG("TGC_LinearSegmentMakerTool::find ended"); - return pMuonSegs; + //return pMuonSegs; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/MuonSegmentCombiOverlapSummary.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/MuonSegmentCombiOverlapSummary.h index 976a14cd882fca1668f5c2a493deec3543662595..cac313beab1843974fb708775b70b6c26ab2554d 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/MuonSegmentCombiOverlapSummary.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/MuonSegmentCombiOverlapSummary.h @@ -13,15 +13,15 @@ namespace Muon{ class MuonSegmentCombiOverlapSummary { public: - std::vector< std::pair<const MuonSegment*,const MuonSegment*> > shared; //!< segments shared between combies - std::vector<const MuonSegment*> uniqueFirst; //!< segments that are only part of the first combi - std::vector<const MuonSegment*> uniqueSecond; //!< segments that are only part of the second combi + std::vector< std::pair<MuonSegment*,MuonSegment*> > shared; //!< segments shared between combies + std::vector<MuonSegment*> uniqueFirst; //!< segments that are only part of the first combi + std::vector<MuonSegment*> uniqueSecond; //!< segments that are only part of the second combi /** segments that are in both combis, but the one in the first is a subset of the second */ - std::vector< std::pair<const MuonSegment*,const MuonSegment*> > subsetFirst; + std::vector< std::pair<MuonSegment*,MuonSegment*> > subsetFirst; /** segments that are in both combis, but the second in the first is a subset of the first */ - std::vector< std::pair<const MuonSegment*,const MuonSegment*> > subsetSecond; + std::vector< std::pair<MuonSegment*,MuonSegment*> > subsetSecond; }; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/MuonSegmentCombiSummary.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/MuonSegmentCombiSummary.h index d8ae89c1d7180e2710be165c2d9f92fd1b5ad47b..da354bcea16c44796971a840d75fa48e2f3e96be 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/MuonSegmentCombiSummary.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/MuonSegmentCombiSummary.h @@ -18,7 +18,7 @@ namespace Muon{ class MuonSegmentCombiSummary { public: // vector of segments - typedef std::vector<const MuonSegment*> SegVec; + typedef std::vector<MuonSegment*> SegVec; typedef SegVec::iterator SegIt; typedef SegVec::const_iterator SegCit; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/SortSegmentsByNumberOfHits.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/SortSegmentsByNumberOfHits.h index 1330280000fe132a102888b5e69685f8b2353ec9..ab4da1fc6fcace920199d509b5dffcda7e5c5df4 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/SortSegmentsByNumberOfHits.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerUtils/MuonSegmentMakerUtils/SortSegmentsByNumberOfHits.h @@ -12,7 +12,7 @@ namespace Muon { class SortSegmentsByNumberOfHits { public: - bool operator()( const MuonSegment* seg1, const MuonSegment* seg2){ + bool operator()( const std::unique_ptr<MuonSegment>& seg1, const std::unique_ptr<MuonSegment>& seg2){ unsigned int nhits1 = seg1->containedMeasurements().size(); unsigned int nhits2 = seg2->containedMeasurements().size(); diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/CMakeLists.txt b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/CMakeLists.txt index 77571788cc0ec40d6ced6c13971f376719aab72d..74dc44048a2ad29217cdc2ce7b7bf863e882f7fe 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/CMakeLists.txt +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/CMakeLists.txt @@ -44,6 +44,7 @@ atlas_depends_on_subdirs( PRIVATE Tracking/TrkEvent/TrkRIO_OnTrack Tracking/TrkEvent/TrkRoad Tracking/TrkEvent/TrkTrack + Tracking/TrkEvent/TrkSegment Tracking/TrkEvent/TrkTrackSummary Tracking/TrkExtrapolation/TrkExInterfaces Tracking/TrkFitter/TrkFitterInterfaces @@ -59,5 +60,5 @@ atlas_add_component( MuonTrackFinderTools src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests GeoPrimitives IRegionSelector Identifier RoiDescriptor EventPrimitives GaudiKernel MagFieldInterfaces MuonAlignErrorBase MuonReadoutGeometry MuonIdHelpersLib MuonCompetingRIOsOnTrack MuonPrepRawData MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonStationIntersectSvcLib MuonSegmentMakerUtils TrkDetDescrInterfaces TrkDetElementBase TrkGeometry TrkSurfaces TrkVolumes TrkEventPrimitives TrkEventUtils TrkMaterialOnTrack TrkMeasurementBase TrkParameters TrkPseudoMeasurementOnTrack TrkRIO_OnTrack TrkRoad TrkTrack TrkTrackSummary TrkExInterfaces TrkFitterInterfaces TrkToolInterfaces TrkDriftCircleMath ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests GeoPrimitives IRegionSelector Identifier RoiDescriptor EventPrimitives GaudiKernel MagFieldInterfaces MuonAlignErrorBase MuonReadoutGeometry MuonIdHelpersLib MuonCompetingRIOsOnTrack MuonPrepRawData MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonStationIntersectSvcLib MuonSegmentMakerUtils TrkDetDescrInterfaces TrkDetElementBase TrkGeometry TrkSurfaces TrkVolumes TrkEventPrimitives TrkEventUtils TrkMaterialOnTrack TrkMeasurementBase TrkParameters TrkPseudoMeasurementOnTrack TrkRIO_OnTrack TrkRoad TrkTrack TrkSegment TrkTrackSummary TrkExInterfaces TrkFitterInterfaces TrkToolInterfaces TrkDriftCircleMath ) diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx index e499bc0f2f3510a4d3e64832459b805b776a2898..8a81c00576d85594ece9b6fddfee520b5b586f34 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonSeededSegmentFinder.h" @@ -16,7 +16,6 @@ #include "MuonIdHelpers/MuonIdHelperTool.h" #include "MuonRecHelperTools/MuonEDMPrinterTool.h" - #include <iostream> #include "MuonReadoutGeometry/MdtReadoutElement.h" @@ -94,28 +93,28 @@ namespace Muon { } - std::vector<const MuonSegment*>* MuonSeededSegmentFinder::find( const Trk::TrackParameters& pars, const std::set<Identifier>& chIds ) const { + std::unique_ptr<Trk::SegmentCollection> MuonSeededSegmentFinder::find( const Trk::TrackParameters& pars, const std::set<Identifier>& chIds ) const { // get MdtPrepData collections correspondign to the chamber Identifiers std::vector<const MdtPrepData*> mdtPrds = extractPrds( chIds ); if ( mdtPrds.empty() ) { ATH_MSG_DEBUG(" no MdtPrepData found "); - return 0; + return std::unique_ptr<Trk::SegmentCollection>(); } // find segments return find(pars, mdtPrds); } - std::vector<const MuonSegment*>* MuonSeededSegmentFinder::find( const Trk::TrackParameters& pars, const std::set<IdentifierHash>& chIdHs ) const { + std::unique_ptr<Trk::SegmentCollection> MuonSeededSegmentFinder::find( const Trk::TrackParameters& pars, const std::set<IdentifierHash>& chIdHs ) const { // get MdtPrepData collections correspondign to the chamber Identifiers std::vector<const MdtPrepData*> mdtPrds = extractPrds( chIdHs ); if ( mdtPrds.empty() ) { ATH_MSG_DEBUG(" no MdtPrepData found "); - return 0; + return std::unique_ptr<Trk::SegmentCollection>(); } // find segments @@ -123,8 +122,8 @@ namespace Muon { } - std::vector<const MuonSegment*>* MuonSeededSegmentFinder::find( const Trk::TrackParameters& pars, - const std::vector<const MdtPrepData*>& mdtPrds ) const { + std::unique_ptr<Trk::SegmentCollection> MuonSeededSegmentFinder::find( const Trk::TrackParameters& pars, + const std::vector<const MdtPrepData*>& mdtPrds ) const { // are we close to the chamber edge? bool doHoleSearch = true; @@ -155,18 +154,18 @@ namespace Muon { std::vector< std::vector<const MuonClusterOnTrack*> > clusterROTsVec; // call segment finder - std::vector<const MuonSegment*>* segments = doHoleSearch ? - m_segMaker->find( road, mdtROTsVec, clusterROTsVec, true ) : - m_segMakerNoHoles->find( road, mdtROTsVec, clusterROTsVec, true ); + std::unique_ptr<Trk::SegmentCollection> segments(new Trk::SegmentCollection()); + doHoleSearch ? + m_segMaker->find( road, mdtROTsVec, clusterROTsVec, segments.get(), true ) : + m_segMakerNoHoles->find( road, mdtROTsVec, clusterROTsVec, segments.get(), true ); // delete ROTs std::for_each( mdtROTs.begin(), mdtROTs.end(), MuonDeleteObject<const MdtDriftCircleOnTrack>() ); if ( !segments ) { ATH_MSG_DEBUG(" No segments found "); - return 0; } else { - ATH_MSG_DEBUG(" Number of segments found: " << segments->size() << std::endl << m_printer->print(*segments)); + ATH_MSG_DEBUG(" Number of segments found: " << segments->size()); } return segments; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.h b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.h index cdc9b00340635b29a092678018c3efcbd3ed7449..a1a50796bbbc5b43093a133761397977cad7d0b5 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_MUONSEEDEDSEGMENTFINDER_H @@ -74,13 +74,13 @@ public: StatusCode finalize(); /** @brief find segments in a set of chambers starting from seeding TrackParameters */ - std::vector<const MuonSegment*>* find( const Trk::TrackParameters& pars, const std::set<Identifier>& chIds ) const; + std::unique_ptr<Trk::SegmentCollection> find( const Trk::TrackParameters& pars, const std::set<Identifier>& chIds ) const; /** @brief find segments in a set of chambers starting from seeding TrackParameters (version with Hashes) */ - std::vector<const MuonSegment*>* find( const Trk::TrackParameters& pars, const std::set<IdentifierHash>& chIdHs ) const; + std::unique_ptr<Trk::SegmentCollection> find( const Trk::TrackParameters& pars, const std::set<IdentifierHash>& chIdHs ) const; /** @brief find segments in a set of MdtPrepData starting from seeding TrackParameters */ - std::vector<const MuonSegment*>* find( const Trk::TrackParameters& pars, const std::vector<const MdtPrepData*>& mdtPrds ) const; + std::unique_ptr<Trk::SegmentCollection> find( const Trk::TrackParameters& pars, const std::vector<const MdtPrepData*>& mdtPrds ) const; /** @brief retrieve MDT PRD collections for the given hashes */ diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSegmentRegionRecoveryTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSegmentRegionRecoveryTool.cxx index 5bf7c4ed9aa7cb3b0a383100152991059e4eaf0f..901a5c94d32b0ee531e909a244f261717137ba3d 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSegmentRegionRecoveryTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSegmentRegionRecoveryTool.cxx @@ -72,6 +72,7 @@ #include "EventPrimitives/EventPrimitivesHelpers.h" #include "EventPrimitives/EventPrimitivesToStringConverter.h" +#include "TrkSegment/SegmentCollection.h" #include <map> @@ -891,38 +892,41 @@ const Trk::Track* MuonSegmentRegionRecoveryTool::addMissingChambers( const Trk:: } } if ( prds && exParsFirst) { - std::vector<const MuonSegment*>* segments = m_seededSegmentFinder->find(*exParsFirst, *prds ); + std::unique_ptr<Trk::SegmentCollection> segments = m_seededSegmentFinder->find(*exParsFirst, *prds ); if ( segments ) { if ( !segments->empty() ) ATH_MSG_DEBUG("found segments " << segments->size() ); - std::vector<const MuonSegment*>::iterator sit = segments->begin(); - std::vector<const MuonSegment*>::iterator sit_end = segments->end(); + Trk::SegmentCollection::iterator sit = segments->begin(); + Trk::SegmentCollection::iterator sit_end = segments->end(); - const MuonSegment* bestSegment = 0; + MuonSegment* bestSegment = 0; const Trk::TrackParameters* bestSegmentPars = 0; for ( ; sit != sit_end; ++sit ) { + Trk::Segment* tseg=*sit; + MuonSegment* mseg=dynamic_cast<MuonSegment*>(tseg); + if ( m_trackSegmentMatchingTool.empty() ) ATH_MSG_VERBOSE("No track/segment matching"); - else if ( !m_trackSegmentMatchingTool->match(track, **sit, true) ) { + else if ( !m_trackSegmentMatchingTool->match(track, *mseg, true) ) { ATH_MSG_DEBUG(" Segment does not match with track "); continue; } else { ATH_MSG_DEBUG(" Segment/track matched successfully using " << m_trackSegmentMatchingTool ); } - const Trk::TrackParameters* segPars = m_extrapolator->extrapolateDirectly(*exParsFirst, (*sit)->associatedSurface(), + const Trk::TrackParameters* segPars = m_extrapolator->extrapolateDirectly(*exParsFirst, mseg->associatedSurface(), Trk::anyDirection, false, Trk::muon); if ( segPars ) { - double resy = (*sit)->localParameters()[Trk::locY] - segPars->parameters()[Trk::locY]; + double resy = mseg->localParameters()[Trk::locY] - segPars->parameters()[Trk::locY]; Trk::LocalDirection locDir; - (*sit)->associatedSurface().globalToLocalDirection(segPars->momentum(), locDir); - double dangleYZ = (*sit)->localDirection().angleYZ() - locDir.angleYZ(); - ATH_MSG_DEBUG("resy " << resy << " dangleYZ " << dangleYZ << " " << m_printer->print(**sit) ); + mseg->associatedSurface().globalToLocalDirection(segPars->momentum(), locDir); + double dangleYZ = mseg->localDirection().angleYZ() - locDir.angleYZ(); + ATH_MSG_DEBUG("resy " << resy << " dangleYZ " << dangleYZ << " " << m_printer->print(*mseg) ); if ( fabs(dangleYZ) < 0.05 ) { - bestSegment = *sit; + bestSegment = mseg; if ( bestSegmentPars ) delete bestSegmentPars; bestSegmentPars = segPars->clone(); } } else { - ATH_MSG_DEBUG("Did not reach " << m_printer->print(**sit) ); + ATH_MSG_DEBUG("Did not reach " << m_printer->print(*mseg) ); } delete segPars; } @@ -945,8 +949,6 @@ const Trk::Track* MuonSegmentRegionRecoveryTool::addMissingChambers( const Trk:: } } if ( bestSegmentPars ) delete bestSegmentPars; - for ( sit = segments->begin(); sit != sit_end; ++sit ) delete *sit; - delete segments; } } delete exParsFirst; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx index a4db42a13a159b9af51805dea90c6733f4777e3a..f6d016633b8623a787207637d650224f70c024f4 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "AthenaKernel/Timeout.h" @@ -30,6 +30,7 @@ #include "TrkExInterfaces/IPropagator.h" #include "TrkToolInterfaces/IResidualPullCalculator.h" #include "TrkEventPrimitives/ResidualPull.h" +#include "TrkSegment/SegmentCollection.h" #include "MuonRIO_OnTrack/MdtDriftCircleOnTrack.h" #include "MuonRIO_OnTrack/MuonClusterOnTrack.h" @@ -645,66 +646,67 @@ namespace Muon { return tracks; } - std::vector< const MuonSegment*> - MooTrackBuilder::removeDuplicateWithReference( const std::vector< const MuonSegment*>& segments, - const std::vector< const MuonSegment*>& referenceSegments ) const { + void MooTrackBuilder::removeDuplicateWithReference( std::unique_ptr<Trk::SegmentCollection>& segments, + std::vector<const MuonSegment*>& referenceSegments) const { - if( segments.empty() || referenceSegments.empty() ) return std::vector< const MuonSegment*>(); + if( referenceSegments.empty() ) return; - ATH_MSG_DEBUG(" Removing duplicates from segment vector of size " << segments.size() + ATH_MSG_DEBUG(" Removing duplicates from segment vector of size " << segments->size() << " reference size " << referenceSegments.size() ); CompareMuonSegmentKeys compareSegmentKeys; // create a vector with pairs of MuonSegmentKey and a pointer to the corresponding segment to resolve ambiguities - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> > segKeys; - segKeys.reserve(segments.size()); + std::vector< std::pair<MuonSegmentKey,Trk::SegmentCollection::iterator > > segKeys; + segKeys.reserve(segments->size()); // loop over reference segments and make keys - std::vector< const MuonSegment*>::const_iterator sit = segments.begin(); - std::vector< const MuonSegment*>::const_iterator sit_end = segments.end(); - for( ; sit!=sit_end;++sit) segKeys.push_back( std::make_pair(MuonSegmentKey(**sit),*sit) ); + Trk::SegmentCollection::iterator sit = segments->begin(); + Trk::SegmentCollection::iterator sit_end = segments->end(); + for( ; sit!=sit_end;++sit){ + Trk::Segment* tseg=*sit; + MuonSegment* mseg=dynamic_cast<MuonSegment*>(tseg); + segKeys.push_back( std::make_pair(MuonSegmentKey(*mseg),sit)); + } // create a vector with pairs of MuonSegmentKey and a pointer to the corresponding segment to resolve ambiguities - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> > referenceSegKeys; + std::vector< MuonSegmentKey> referenceSegKeys; referenceSegKeys.reserve(referenceSegments.size()); // loop over reference segments and make keys - sit = referenceSegments.begin(); - sit_end = referenceSegments.end(); - for( ; sit!=sit_end;++sit) referenceSegKeys.push_back( std::make_pair(MuonSegmentKey(**sit),*sit) ); - - - std::vector< const MuonSegment*> cleanedSegments; + std::vector<const MuonSegment*>::iterator vit=referenceSegments.begin(); + std::vector<const MuonSegment*>::iterator vit_end=referenceSegments.end(); + for( ; vit!=vit_end;++vit){ + referenceSegKeys.push_back( MuonSegmentKey(**vit) ); + } - // loop over segments and compare the current segment with the reference ones - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator skit = segKeys.begin(); - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator skit_end = segKeys.end(); + std::vector< std::pair<MuonSegmentKey,Trk::SegmentCollection::iterator> >::iterator skit = segKeys.begin(); + std::vector< std::pair<MuonSegmentKey,Trk::SegmentCollection::iterator> >::iterator skit_end = segKeys.end(); for( ;skit!=skit_end;++skit ){ bool isDuplicate = false; - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator rskit = referenceSegKeys.begin(); - std::vector< std::pair<MuonSegmentKey,const MuonSegment*> >::iterator rskit_end = referenceSegKeys.end(); + std::vector<MuonSegmentKey>::iterator rskit = referenceSegKeys.begin(); + std::vector<MuonSegmentKey>::iterator rskit_end = referenceSegKeys.end(); for( ;rskit!=rskit_end;++rskit ){ - CompareMuonSegmentKeys::OverlapResult overlapResult = compareSegmentKeys( rskit->first, skit->first ); + CompareMuonSegmentKeys::OverlapResult overlapResult = compareSegmentKeys( *rskit, skit->first ); if( overlapResult == CompareMuonSegmentKeys::Identical ) { - ATH_MSG_DEBUG(" discarding identical segment" << m_printer->print(*skit->second) ); + ATH_MSG_DEBUG(" discarding identical segment"); isDuplicate = true; break; }else if( overlapResult == CompareMuonSegmentKeys::SuperSet ){ // reference segment superset of current: discard - ATH_MSG_DEBUG(" discarding (subset) " << m_printer->print(*skit->second) ); + ATH_MSG_DEBUG(" discarding (subset) "); isDuplicate = true; break; } } - if( !isDuplicate ) cleanedSegments.push_back(skit->second); } + if( isDuplicate ) segments->erase(skit->second); + } - return cleanedSegments; } @@ -721,7 +723,7 @@ namespace Muon { } // redo segment finding - std::vector<const MuonSegment*>* segments = m_seededSegmentFinder->find(pars,chIds); + std::unique_ptr<Trk::SegmentCollection> segments=m_seededSegmentFinder->find(pars,chIds); // check whether we got segments if( !segments ) { @@ -730,45 +732,42 @@ namespace Muon { } if( segments->empty() ){ ATH_MSG_DEBUG(" got empty vector!! " ); - delete segments; return 0; } - - std::vector< const MuonSegment*> cleanedSegments; + unsigned int nseg=segments->size(); if( m_useExclusionList ){ std::vector<const MuonSegment*> referenceSegments; - referenceSegments.reserve(candidate.excludedSegments().size()); for( std::vector<MuPatSegment*>::const_iterator esit = candidate.excludedSegments().begin(); esit != candidate.excludedSegments().end(); ++esit ) { if( (*esit)->segment ) referenceSegments.push_back((*esit)->segment); } - cleanedSegments = removeDuplicateWithReference( *segments, referenceSegments ); - }else{ - cleanedSegments.insert( cleanedSegments.begin(),segments->begin(),segments->end()); - } + removeDuplicateWithReference( segments, referenceSegments ); + } - if( msgLvl(MSG::DEBUG) && cleanedSegments.size() != segments->size() ) { + if( msgLvl(MSG::DEBUG) && segments->size()!=nseg ) { msg(MSG::DEBUG) << MSG::DEBUG << " Rejected segments based on exclusion list, number of removed segments: " - << segments->size() - cleanedSegments.size() << " total " << segments->size() << endmsg; + << nseg - segments->size() << " total " << segments->size() << endmsg; } std::vector<Trk::Track*>* newTracks = 0; - if( !cleanedSegments.empty() ){ + if( !segments->empty() ){ newTracks = new std::vector<Trk::Track*>; // loop over segments - std::vector<const MuonSegment*>::iterator sit = cleanedSegments.begin(); - std::vector<const MuonSegment*>::iterator sit_end = cleanedSegments.end(); + Trk::SegmentCollection::iterator sit = segments->begin(); + Trk::SegmentCollection::iterator sit_end = segments->end(); for( ;sit!=sit_end;++sit ){ if( !*sit ) continue; + Trk::Segment* tseg=*sit; + MuonSegment* mseg=dynamic_cast<MuonSegment*>(tseg); if( msgLvl(MSG::DEBUG) ){ - msg(MSG::DEBUG) << MSG::DEBUG << " adding segment " << m_printer->print(**sit); + msg(MSG::DEBUG) << MSG::DEBUG << " adding segment " << m_printer->print(*mseg); if( msgLvl(MSG::VERBOSE) ) { - msg(MSG::DEBUG) << std::endl << m_printer->print((*sit)->containedMeasurements()) << endmsg; + msg(MSG::DEBUG) << std::endl << m_printer->print(mseg->containedMeasurements()) << endmsg; if( msgLvl(MSG::VERBOSE) && candidate.track().measurementsOnTrack() ) msg(MSG::DEBUG) << " track " << m_printer->print(candidate.track()) << std::endl << m_printer->print(candidate.track().measurementsOnTrack()->stdcont()) << endmsg; @@ -776,7 +775,7 @@ namespace Muon { msg(MSG::DEBUG) << endmsg; } } - MuPatSegment* segInfo = m_candidateHandler->createSegInfo(**sit); + MuPatSegment* segInfo = m_candidateHandler->createSegInfo(*mseg); if( !m_candidateMatchingTool->match(candidate,*segInfo,true) ){ delete segInfo; @@ -794,14 +793,6 @@ namespace Muon { } } - // loop over segments - std::vector<const MuonSegment*>::iterator sit = segments->begin(); - std::vector<const MuonSegment*>::iterator sit_end = segments->end(); - for( ;sit!=sit_end;++sit ) delete *sit; - - // free memory - delete segments; - if( !newTracks || newTracks->empty() ){ delete newTracks; return 0; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.h b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.h index feee354f88b09c42b306a2a7d3c3487d1a0b9924..4122f12edfd2198d6cbda44de6b861473866866b 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUON_MOOTRACKBUILDER_H @@ -20,6 +20,7 @@ #include "TrkTrack/Track.h" #include "TrkTrack/TrackCollection.h" +#include "TrkSegment/SegmentCollection.h" #include <vector> class MsgStream; @@ -249,8 +250,8 @@ namespace Muon { private: - std::vector< const MuonSegment*> removeDuplicateWithReference( const std::vector< const MuonSegment*>& segments, - const std::vector< const MuonSegment*>& referenceSegments ) const; + void removeDuplicateWithReference( std::unique_ptr<Trk::SegmentCollection>& segments, + std::vector<const MuonSegment*>& referenceSegments ) const; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MuonTrackSteering.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MuonTrackSteering.cxx index 81e2ac016ea089c208adfafe17d930bb4aaf2f6b..91394f93bded88c8ebf428aa48b8111e0da4969c 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MuonTrackSteering.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MuonTrackSteering.cxx @@ -182,7 +182,7 @@ namespace Muon { MuonSegmentCombination::SegmentVec::const_iterator ipsg =stationSegs->begin(); MuonSegmentCombination::SegmentVec::const_iterator ipsg_end=stationSegs->end(); for (; ipsg != ipsg_end; ++ipsg) { - const MuonSegment* seg = dynamic_cast<const MuonSegment*>(*ipsg); + const MuonSegment* seg = dynamic_cast<const MuonSegment*>((*ipsg).get()); if ( 0 != seg ) { // Add segment to the MuonSegmentCollection diff --git a/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/MuonTrackPerformance/MuonTrackPerformanceAlg.h b/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/MuonTrackPerformance/MuonTrackPerformanceAlg.h index cfc7d8b751e73f6f8a207821a0c612f5534e6b58..6916dd38b4342c2aae9fdb919d90546168da50d5 100644 --- a/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/MuonTrackPerformance/MuonTrackPerformanceAlg.h +++ b/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/MuonTrackPerformance/MuonTrackPerformanceAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONTRACKPERFORMANCEALG_H @@ -16,7 +16,6 @@ #include "TrkTrackSummary/TrackSummary.h" #include "TrkParameters/TrackParameters.h" #include "TrkTruthData/TruthTrajectory.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonIdHelpers/MuonStationIndex.h" @@ -206,7 +205,6 @@ private: bool handleTracks(); bool handleTrackTruth( const TrackCollection& trackCollection ); - bool handleSegmentCombinations(); bool handleSegmentCombi( const Muon::MuonSegmentCombination& combi ); bool handleSegmentTruth( const std::vector<const Muon::MuonSegment*>& segments ); @@ -275,7 +273,6 @@ private: bool selectPdg( int pdg ) const { return m_selectedPdgs.count(pdg); } SG::ReadHandleKey<TrackCollection> m_trackKey{this,"TrackInputLocation","MuonSpectrometerTracks","input tracks"}; //!< Location of the track input container - SG::ReadHandleKey<MuonSegmentCombinationCollection> m_segmentCombiKey{this,"SegmentLocation","MuonSegments","segments"}; //!< Location of the segments SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this,"EventInfoKey","EventInfo","EventInfo key"}; const xAOD::EventInfo* m_eventInfo; //!< pointer to the event info diff --git a/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/src/MuonTrackPerformanceAlg.cxx b/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/src/MuonTrackPerformanceAlg.cxx index 56729ac454ee30a67c6e16bc4bd5e2e9a3be22ea..773508fafcc0406c57ff5a3795601a96af3763e5 100644 --- a/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/src/MuonTrackPerformanceAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/src/MuonTrackPerformanceAlg.cxx @@ -121,7 +121,6 @@ StatusCode MuonTrackPerformanceAlg::initialize() } ATH_CHECK(m_trackKey.initialize()); - ATH_CHECK(m_segmentCombiKey.initialize()); ATH_CHECK(m_eventInfoKey.initialize()); ATH_CHECK(m_mcEventColl.initialize(m_doTruth)); @@ -145,58 +144,12 @@ StatusCode MuonTrackPerformanceAlg::execute() } m_eventInfo=evInfo.cptr(); handleTracks(); - if( m_doSegments ) handleSegmentCombinations(); ++m_nevents; return StatusCode::SUCCESS; } -bool MuonTrackPerformanceAlg::handleSegmentCombinations() { - - - SG::ReadHandle<MuonSegmentCombinationCollection> combiCol(m_segmentCombiKey); - - if (!combiCol.isValid() ) { - *m_log << MSG::WARNING << " Could not find MuonSegmentCombinationCollection at " << m_segmentCombiKey.key() <<endmsg; - return true; - }else{ - if( m_debug ) *m_log << MSG::DEBUG << " Retrieved MuonSegmentCombinationCollection " << combiCol->size() << endmsg; - } - - std::vector<const Muon::MuonSegment*> segments; - - - MuonSegmentCombinationCollection::const_iterator cit = combiCol->begin(); - MuonSegmentCombinationCollection::const_iterator cit_end = combiCol->end(); - for(; cit!=cit_end;++cit ){ - const Muon::MuonSegmentCombination* combi = *cit; - if( !combi ) { - if( m_debug ) *m_log << MSG::DEBUG << " empty Mdt MuonSegmentCombination!!! " << endmsg; - continue; - } - handleSegmentCombi(*combi); - - // loop over chambers in combi and extract segments - unsigned int nstations = combi->numberOfStations(); - for(unsigned int i=0; i<nstations; ++i){ - // loop over segments in station - const Muon::MuonSegmentCombination::SegmentVec* stationSegs = combi->stationSegments( i ) ; - // check if not empty - if( !stationSegs || stationSegs->empty() ) continue; - segments.insert(segments.end(),stationSegs->begin(),stationSegs->end()); - } - } - - if( m_doTruth ){ - - handleSegmentTruth(segments); - - } - - return true; -} - bool MuonTrackPerformanceAlg::handleSegmentTruth( const std::vector<const Muon::MuonSegment*>& segments ) { Muon::IMuonTrackTruthTool::SegmentResultVec result = m_truthTool->match(segments); Muon::IMuonTrackTruthTool::SegmentResultVec::iterator rit = result.begin(); @@ -250,7 +203,7 @@ bool MuonTrackPerformanceAlg::handleSegmentCombi( const Muon::MuonSegmentCombina Muon::MuonSegmentCombination::SegmentVec::const_iterator ipsg_end=stationSegs->end(); for (;ipsg!=ipsg_end;++ipsg){ - const Muon::MuonSegment* seg = dynamic_cast<const Muon::MuonSegment*>(*ipsg); + const Muon::MuonSegment* seg = dynamic_cast<const Muon::MuonSegment*>((*ipsg).get()); if( !seg ){ *m_log << MSG::WARNING << " MuonSegmentCombination contains a segment that is not a MuonSegment!! " << endmsg; @@ -259,8 +212,6 @@ bool MuonTrackPerformanceAlg::handleSegmentCombi( const Muon::MuonSegmentCombina } } - - return true; } diff --git a/Reconstruction/MuonIdentification/MuGirlCandidate/src/CSC.cxx b/Reconstruction/MuonIdentification/MuGirlCandidate/src/CSC.cxx index 97de0a284055969ec948dfa98823d0fcf4fb40d0..27ea01d87e66641eab4d314f6becd779a826a39f 100644 --- a/Reconstruction/MuonIdentification/MuGirlCandidate/src/CSC.cxx +++ b/Reconstruction/MuonIdentification/MuGirlCandidate/src/CSC.cxx @@ -220,8 +220,8 @@ void CSC::buildSegments(Candidate* pCand, ChamberList& chambers, double) } if (m_pMuGirl->msgLvl(MSG::DEBUG)) pRoad->dump(m_pMuGirl->msg()); - std::vector<const Muon::MuonSegment*>* pSegments = - m_pMuGirl->cscSegmentMaker()->find(*pRoad, mdts, clusters); + std::vector<const Muon::MuonSegment*>* pSegments = NULL; + m_pMuGirl->cscSegmentMaker()->find(*pRoad, mdts, clusters, 0); if (pSegments != NULL) { for (std::vector<const Muon::MuonSegment*>::const_iterator itSeg = pSegments->begin(); itSeg != pSegments->end(); itSeg++) diff --git a/Reconstruction/MuonIdentification/MuGirlCandidate/src/MDT.cxx b/Reconstruction/MuonIdentification/MuGirlCandidate/src/MDT.cxx index e4baeb9c9fa028d9608a7ec0bba3879a29d761d5..13df92a4a8868a88c18049e91647638a90656552 100644 --- a/Reconstruction/MuonIdentification/MuGirlCandidate/src/MDT.cxx +++ b/Reconstruction/MuonIdentification/MuGirlCandidate/src/MDT.cxx @@ -297,7 +297,8 @@ void MDT::buildSegments(Candidate* pCand, ChamberList& chambers, double QoverP) MdtSegmentMakerInfo* pMdtSegmentMakerInfo = new MdtSegmentMakerInfo(pRoad, mdts); pCand->getMdtSegmentMakerInfo().push_back(pMdtSegmentMakerInfo); } - pSegments = pSegmentMaker->find(*pRoad, mdts, clusters, true, momentum); + pSegments = NULL; + pSegmentMaker->find(*pRoad, mdts, clusters, 0, true, momentum); if (pSegments == NULL || pSegments->empty()) { if (pSegments != NULL) diff --git a/Reconstruction/MuonIdentification/MuGirlCandidate/src/RPC.cxx b/Reconstruction/MuonIdentification/MuGirlCandidate/src/RPC.cxx index 3568f416245eed385f26226f550be1865e2c4d8a..a9ab84ac313472ef9ed8f6c0999315f8a5038210 100644 --- a/Reconstruction/MuonIdentification/MuGirlCandidate/src/RPC.cxx +++ b/Reconstruction/MuonIdentification/MuGirlCandidate/src/RPC.cxx @@ -206,8 +206,8 @@ void RPC::buildSegments(Candidate* pCand, ChamberList& chambers, double) } if (m_pMuGirl->msgLvl(MSG::DEBUG)) pRoad->dump(m_pMuGirl->msg()); - std::vector<const Muon::MuonSegment*>* pSegments = - m_pMuGirl->rpcSegmentMaker()->find(*pRoad, mdts, clusters); + std::vector<const Muon::MuonSegment*>* pSegments = NULL; + m_pMuGirl->rpcSegmentMaker()->find(*pRoad, mdts, clusters, 0); if (pSegments != NULL) { for (std::vector<const Muon::MuonSegment*>::const_iterator itSeg = pSegments->begin(); itSeg != pSegments->end(); itSeg++) diff --git a/Reconstruction/MuonIdentification/MuGirlCandidate/src/TGC.cxx b/Reconstruction/MuonIdentification/MuGirlCandidate/src/TGC.cxx index c32a6385cc23d849f189d0409fe1b95353dee8bf..20845cf5ab1e5e20589743f6599fd13bc7fb3d68 100644 --- a/Reconstruction/MuonIdentification/MuGirlCandidate/src/TGC.cxx +++ b/Reconstruction/MuonIdentification/MuGirlCandidate/src/TGC.cxx @@ -339,8 +339,8 @@ void TGC::buildSegments(Candidate* pCand, ChamberList& chambers, double) } if (m_pMuGirl->msgLvl(MSG::DEBUG)) pRoad->dump(m_pMuGirl->msg()); - std::vector<const Muon::MuonSegment*>* pSegments = - m_pMuGirl->tgcSegmentMaker()->find(*pRoad, mdts, clusters); + std::vector<const Muon::MuonSegment*>* pSegments = NULL; + m_pMuGirl->tgcSegmentMaker()->find(*pRoad, mdts, clusters, 0); if (pSegments != NULL) { for (std::vector<const Muon::MuonSegment*>::const_iterator itSeg = pSegments->begin(); diff --git a/Reconstruction/MuonIdentification/MuGirlStau/src/StauMDT.cxx b/Reconstruction/MuonIdentification/MuGirlStau/src/StauMDT.cxx index 6a2ccaedc0cd3f994ddb617142b1e8863a7f3c5f..ef66377d83fab968da824f24a98791a91124dc61 100644 --- a/Reconstruction/MuonIdentification/MuGirlStau/src/StauMDT.cxx +++ b/Reconstruction/MuonIdentification/MuGirlStau/src/StauMDT.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuGirlStau/StauMDT.h" @@ -146,29 +146,17 @@ void MuGirlNS::StauMDT::findNewSegments(double beta) //build the segments TriggerClusters clusters; - auto pSegments = m_pStau->mdtSegmentMaker()->find(*pRoad, *pMdocotLists, clusters, true, + m_pStau->mdtSegmentMaker()->find(*pRoad, *pMdocotLists, clusters, 0, true, m_pStau->idP()); //choose the best segment and store it, ignore the number of hits const Muon::MuonSegment* pBestSegment = NULL; - bestMdtSegment(pSegments, pBestSegment, true); if (pBestSegment != NULL) m_pStau->newMdtSegments()->push_back(pBestSegment); //delete the MDCOTLists deleteMdcotLists(pMdocotLists); delete pMdocotLists; - //store the best segment and delete the others - if (pSegments != NULL) - { - for (auto pMuonSegment : *pSegments) - { - if (pBestSegment != pMuonSegment) delete pMuonSegment; - } - pSegments->clear(); - delete pSegments; - } - if (m_pStau->doCalibration() && MUGIRLNS_STAUMDT_DO_CALIBRATION) m_segmentNumber++; } LOG_VERBOSE << "done" << endmsg; @@ -200,24 +188,13 @@ void MuGirlNS::StauMDT::processMdtWithBeta(double currentBeta, MdtStepData* mdtD } //build the segments TriggerClusters clusters; - auto pSegments = m_pStau->mdtSegmentMaker()->find(*pRoad, *pMdocotLists, clusters, true, + m_pStau->mdtSegmentMaker()->find(*pRoad, *pMdocotLists, clusters, 0, true, m_pStau->idP()); - //store the data in the iteration - if (pSegments != NULL) fillStationData(mdtData, pSegments); - //delete the MDCOTLists deleteMdcotLists(pMdocotLists); delete pMdocotLists; - //delete the segments - if (pSegments != NULL) - { - for (auto pMuonSegment : *pSegments) - delete pMuonSegment; - pSegments->clear(); - delete pSegments; - } if (m_pStau->doCalibration() && MUGIRLNS_STAUMDT_DO_CALIBRATION) m_segmentNumber++; } @@ -388,24 +365,13 @@ void MuGirlNS::StauMDT::processMdtWithTTrack(double tTrack, MdtStepData* mdtData } //build the segments TriggerClusters clusters; - auto pSegments = m_pStau->mdtSegmentMaker()->find(*pRoad, *pMdocotLists, clusters, true, + m_pStau->mdtSegmentMaker()->find(*pRoad, *pMdocotLists, clusters, 0, true, m_pStau->idP()); - //store the data in the iteration - if (pSegments != NULL) fillStationData(mdtData, pSegments); - //delete the MDCOTLists deleteMdcotLists(pMdocotLists); delete pMdocotLists; - //delete the segments - if (pSegments != NULL) - { - for (auto pMuonSegment : *pSegments) - delete pMuonSegment; - pSegments->clear(); - delete pSegments; - } } //mdtData->dof = mdtData->totNumHits - 2*mdtData->pStationDataList->size(); diff --git a/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonInsideOutRecoTool.cxx b/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonInsideOutRecoTool.cxx index ec7322c6c084ff417453912193ee4b4c690a9454..26fdefbc47e373097a6a9299282de8c869076ac6 100644 --- a/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonInsideOutRecoTool.cxx +++ b/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonInsideOutRecoTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonInsideOutRecoTool.h" @@ -98,7 +98,7 @@ namespace MuonCombined { } void MuonInsideOutRecoTool::handleCandidate( const InDetCandidate& indetCandidate, InDetCandidateToTagMap* tagMap, IMuonCombinedInDetExtensionTool::MuonPrdData prdData, - TrackCollection* combTracks, TrackCollection* meTracks, Trk::SegmentCollection* segments) { + TrackCollection* combTracks, TrackCollection* meTracks, Trk::SegmentCollection* segColl) { if( m_ignoreSiAssocated && indetCandidate.isSiliconAssociated() ) { ATH_MSG_DEBUG(" skip silicon associated track for extension "); @@ -176,7 +176,7 @@ namespace MuonCombined { } // add candidate to indet candidate - addTag(indetCandidate,tagMap,*bestCandidate.first.get(),bestCandidate.second,combTracks,meTracks,segments); + addTag(indetCandidate,tagMap,*bestCandidate.first.get(),bestCandidate.second,combTracks,meTracks,segColl); } diff --git a/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonStauRecoTool.cxx b/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonStauRecoTool.cxx index 40b47c36d218b3e7019f0bffef1a7106d097b293..7f12f50a8d53b8e6c9527ca522dfa63419de0016 100644 --- a/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonStauRecoTool.cxx +++ b/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonStauRecoTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonStauRecoTool.h" @@ -1320,14 +1320,19 @@ namespace MuonCombined { if( mdts.size() > 2 ){ // run segment finder - std::unique_ptr<std::vector<const Muon::MuonSegment*> > foundSegments(segmentMaker->find( intersection.trackParameters->position(), - intersection.trackParameters->momentum(), - mdts, clusters, - !clusters.empty(), intersection.trackParameters->momentum().mag() )); - if( foundSegments ){ - for( auto seg : *foundSegments ){ - ATH_MSG_DEBUG( " " << m_printer->print(*seg) ); - segments.push_back( std::shared_ptr<const Muon::MuonSegment>(seg) ); + std::unique_ptr<Trk::SegmentCollection> segColl(new Trk::SegmentCollection(SG::VIEW_ELEMENTS)); + segmentMaker->find( intersection.trackParameters->position(), + intersection.trackParameters->momentum(), + mdts, clusters, + !clusters.empty(), segColl.get(), intersection.trackParameters->momentum().mag() ); + if( segColl ){ + Trk::SegmentCollection::iterator sit = segColl->begin(); + Trk::SegmentCollection::iterator sit_end = segColl->end(); + for( ; sit!=sit_end;++sit){ + Trk::Segment* tseg=*sit; + Muon::MuonSegment* mseg=dynamic_cast<Muon::MuonSegment*>(tseg); + ATH_MSG_DEBUG( " " << m_printer->print(*mseg) ); + segments.push_back( std::shared_ptr<const Muon::MuonSegment>(mseg) ); } } } diff --git a/Trigger/TrigAlgorithms/TrigMuSuperEF/src/TrigMuSuperEF.cxx b/Trigger/TrigAlgorithms/TrigMuSuperEF/src/TrigMuSuperEF.cxx index dd1d9954390fe55d7960dfb2d663734395b67674..2e66c05e7c0487dbe44d404f4abc0ac7f63907b2 100644 --- a/Trigger/TrigAlgorithms/TrigMuSuperEF/src/TrigMuSuperEF.cxx +++ b/Trigger/TrigAlgorithms/TrigMuSuperEF/src/TrigMuSuperEF.cxx @@ -1,6 +1,6 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include <iomanip> @@ -11,7 +11,6 @@ #include "Particle/TrackParticleContainer.h" #include "MuonRecToolInterfaces/IMuonPatternSegmentAssociationTool.h" #include "MuidEvent/MuidTrackContainer.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonSegment/MuonSegment.h" #include "MuonPattern/MuonPatternCombinationCollection.h" #include "TrkSegment/SegmentCollection.h" @@ -852,10 +851,6 @@ HLT::ErrorCode TrigMuSuperEF::runMSReconstruction(const IRoiDescriptor* muonRoI, // only bail out in case of real problem. So still attach features if no muon found: important for caching! if ( hltStatus != HLT::OK && hltStatus != HLT::MISSING_FEATURE ) return hltStatus; - hltStatus = attachMuonSegmentCombinationCollection(TEout); - if(hltStatus != HLT::OK) - return hltStatus; - hltStatus = attachSegments(TEout); if(hltStatus != HLT::OK) return hltStatus; @@ -884,8 +879,6 @@ HLT::ErrorCode TrigMuSuperEF::runMSReconstruction(const IRoiDescriptor* muonRoI, if(msTrackParticleAuxCont) delete msTrackParticleAuxCont; // always clean up Aux container // record collections - if (m_recordSegments) - m_TrigMuonEF_saTrackTool->recordSegments(); if (m_recordPatterns) m_TrigMuonEF_saTrackTool->recordPatterns(); if (m_recordTracks) @@ -1195,19 +1188,10 @@ HLT::ErrorCode TrigMuSuperEF::runMSSegmentTaggedReconstruction(HLT::TriggerEleme HLT::ErrorCode TrigMuSuperEF::buildSegmentTaggedTracks(InDetCandidateCollection& inDetCandidates) { std::vector<const Muon::MuonSegment*> segments; - auto segmentCombiCollection = m_TrigMuonEF_saTrackTool->segmentCombis(); - for(auto combi : *segmentCombiCollection){ - auto nStations = combi->numberOfStations(); - for(unsigned int i = 0; i < nStations; ++i){ - const Muon::MuonSegmentCombination::SegmentVec* segmentsCombi = combi->stationSegments( i ); - if( !segmentsCombi || segmentsCombi->empty() ) continue; - Muon::MuonSegmentCombination::SegmentVec::const_iterator sit = segmentsCombi->begin(); - Muon::MuonSegmentCombination::SegmentVec::const_iterator sit_end = segmentsCombi->end(); - for( ; sit!=sit_end;++sit){ - const Muon::MuonSegment* muonSegment = *sit; - segments.push_back(muonSegment); - } - } + auto segmentCollection = m_TrigMuonEF_saTrackTool->segments(); + for(auto tseg : *segmentCollection){ + const Muon::MuonSegment* mseg=dynamic_cast<const Muon::MuonSegment*>(tseg); + segments.push_back(mseg); } MuonCombined::InDetCandidateToTagMap* segmentTagMap=new MuonCombined::InDetCandidateToTagMap(); m_tagMaps.push_back(segmentTagMap); @@ -1809,23 +1793,6 @@ void TrigMuSuperEF::setCombinedTimers(HLT::Algo* fexAlgo, std::vector<TrigTimer* timers.push_back( fexAlgo->addTimer("TMEF_CBDataOutputTime") ); } -HLT::ErrorCode TrigMuSuperEF::attachMuonSegmentCombinationCollection(HLT::TriggerElement* TEout){ - const MuonSegmentCombinationCollection* combiCol = m_TrigMuonEF_saTrackTool->segmentCombisToAttach(); - if (combiCol) { - auto hltStatus = attachFeature(TEout, combiCol, "forTB"); - if(hltStatus!=HLT::OK) { - ATH_MSG_WARNING("Attaching SegmentCombinationCollection to TEout unsuccessful"); - delete combiCol; - return hltStatus; - } - else - ATH_MSG_DEBUG("Successfully attached to TEout the container of combined segments with size " << combiCol->size()); - } - else - ATH_MSG_DEBUG("SegmentCombinationCollection pointer zero, not attached to TE"); - return HLT::OK; -} - HLT::ErrorCode TrigMuSuperEF::attachSegments(HLT::TriggerElement* TEout){ const Trk::SegmentCollection* segments = m_TrigMuonEF_saTrackTool->segmentsToAttach(); if(segments) { diff --git a/Trigger/TrigAlgorithms/TrigMuSuperEF/src/TrigMuSuperEF.h b/Trigger/TrigAlgorithms/TrigMuSuperEF/src/TrigMuSuperEF.h index ae9848a6ecef0eb1a768f9792aed618abb4de91d..4464d7241d7626e7cea8739e36d1ef4490700d8a 100644 --- a/Trigger/TrigAlgorithms/TrigMuSuperEF/src/TrigMuSuperEF.h +++ b/Trigger/TrigAlgorithms/TrigMuSuperEF/src/TrigMuSuperEF.h @@ -137,7 +137,6 @@ class TrigMuSuperEF: public virtual HLT::FexAlgo { xAOD::TrackParticleContainer* combinedTrackParticles, xAOD::TrackParticleContainer* extrapolatedTrackParticles, std::unique_ptr<xAOD::MuonContainer> muonContainerOwn); - HLT::ErrorCode attachMuonSegmentCombinationCollection(HLT::TriggerElement* TEout); HLT::ErrorCode attachSegments(HLT::TriggerElement* TEout); HLT::ErrorCode attachMSTracks(HLT::TriggerElement* TEout); HLT::ErrorCode attachTrackParticleContainer(HLT::TriggerElement* TEout); diff --git a/Trigger/TrigAlgorithms/TrigMuonEF/python/TrigMuonEFConfig.py b/Trigger/TrigAlgorithms/TrigMuonEF/python/TrigMuonEFConfig.py index 5f878c33db396d6e5d95d905256305737385d275..125de7775bf5dd3ad9e19e19257d0c1ca48a0f5a 100755 --- a/Trigger/TrigAlgorithms/TrigMuonEF/python/TrigMuonEFConfig.py +++ b/Trigger/TrigAlgorithms/TrigMuonEF/python/TrigMuonEFConfig.py @@ -465,7 +465,7 @@ class TrigMuonEFStandaloneTrackToolConfig (TrigMuonEFStandaloneTrackTool): self.CscClusterProvider = CfgGetter.getPublicTool("CscThresholdClusterBuilderTool") self.SegmentsFinderTool = CfgGetter.getPublicToolClone( "TMEF_SegmentsFinderTool","MooSegmentFinder", - HoughPatternFinder = CfgGetter.getPublicTool("MuonLayerHoughTool"),DoSegmentCombinations=True ) + HoughPatternFinder = CfgGetter.getPublicTool("MuonLayerHoughTool")) CfgGetter.getPublicTool("MuonHoughPatternFinderTool").RecordAll=False CfgGetter.getPublicTool("MuonLayerHoughTool").DoTruth=False diff --git a/Trigger/TrigAlgorithms/TrigMuonEF/src/SegmentCache.cxx b/Trigger/TrigAlgorithms/TrigMuonEF/src/SegmentCache.cxx index 35e72d2cc94062733e79bd67c61c48f24ac0b95d..bfba9e32e7d5c799311d2c76f84d278ce72dfe7d 100644 --- a/Trigger/TrigAlgorithms/TrigMuonEF/src/SegmentCache.cxx +++ b/Trigger/TrigAlgorithms/TrigMuonEF/src/SegmentCache.cxx @@ -1,11 +1,9 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "SegmentCache.h" #include "TrigMuonEvent/TrigMuonEFInfo.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" -#include "MuonSegment/MuonSegmentCombination.h" #include "MuonSegment/MuonSegment.h" #include "MuonPattern/MuonPatternCombinationCollection.h" #include "MuonPattern/MuonPatternCombination.h" @@ -13,7 +11,6 @@ SegmentCache::SegmentCache(){ m_segments=0; m_pattcoll=0; - m_segcoll=0; m_msTracks = 0; m_saTracks = 0; m_nroi=0; @@ -28,11 +25,6 @@ SegmentCache::~SegmentCache(){ } - -void SegmentCache::AddSegmentCollection(const MuonSegmentCombinationCollection* coll) { - m_segcoll = coll; -} - void SegmentCache::AddPatternCollection(const MuonPatternCombinationCollection* pat) { m_pattcoll = pat; } diff --git a/Trigger/TrigAlgorithms/TrigMuonEF/src/SegmentCache.h b/Trigger/TrigAlgorithms/TrigMuonEF/src/SegmentCache.h index 3a70415c2771438c45b92bf4f8b86ba0f835ff3d..e2a9078e3407b90ea101cce5044e0a9996bad55d 100644 --- a/Trigger/TrigAlgorithms/TrigMuonEF/src/SegmentCache.h +++ b/Trigger/TrigAlgorithms/TrigMuonEF/src/SegmentCache.h @@ -1,13 +1,11 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TrigMuonEF_SegmentCache_H__ #define TrigMuonEF_SegmentCache_H__ #include <vector> -#include "MuonSegment/MuonSegmentCombinationCollection.h" -#include "MuonSegment/MuonSegmentCombination.h" #include "MuonPattern/MuonPatternCombinationCollection.h" #include "MuonPattern/MuonPatternCombination.h" #include "TrkSegment/SegmentCollection.h" @@ -26,13 +24,11 @@ class SegmentCache { //void AddMuonInfo(TrigMuonEFInfo* MI); - void AddSegmentCollection(const MuonSegmentCombinationCollection* coll); void AddPatternCollection(const MuonPatternCombinationCollection* pat); void AddSegments(const Trk::SegmentCollection* trk); void SetNROI(int n); void SetSpectrometerTrackCollection( const TrackCollection* msTracks ); void SetExtrapolatedTrackCollection( TrackCollection* saTracks ); - const MuonSegmentCombinationCollection* SegColl() const {return m_segcoll;} const MuonPatternCombinationCollection* PattColl() const {return m_pattcoll;} const Trk::SegmentCollection* Segments() const {return m_segments;} int NROI() const {return m_nroi;} @@ -41,7 +37,6 @@ class SegmentCache { private: - const MuonSegmentCombinationCollection* m_segcoll; const MuonPatternCombinationCollection* m_pattcoll; const Trk::SegmentCollection* m_segments; const TrackCollection* m_msTracks; diff --git a/Trigger/TrigAlgorithms/TrigMuonEF/src/TrigMuonEFStandaloneTrackTool.cxx b/Trigger/TrigAlgorithms/TrigMuonEF/src/TrigMuonEFStandaloneTrackTool.cxx index ed3d342d5930c765081a2be44041017fa5d14df5..ae1d01f3d082686703bf407e4eb016e05ad3812a 100644 --- a/Trigger/TrigAlgorithms/TrigMuonEF/src/TrigMuonEFStandaloneTrackTool.cxx +++ b/Trigger/TrigAlgorithms/TrigMuonEF/src/TrigMuonEFStandaloneTrackTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include <algorithm> // for find @@ -22,7 +22,6 @@ #include "TrkParameters/TrackParameters.h" #include "TrkEventPrimitives/FitQuality.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonSegment/MuonSegment.h" // #include "TrigSteeringEvent/TrigRoiDescriptor.h" @@ -120,11 +119,9 @@ TrigMuonEFStandaloneTrackTool::TrigMuonEFStandaloneTrackTool(const std::string& m_maxMdtHits(0), m_maxRpcHits(0), m_maxTgcHits(0), - m_segmentCombiColl(0), m_patternCombiColl(0), m_segments(0), m_spectrometerTracks(0), - m_segmentCombiCollInternal(0), m_patternCombiCollInternal(0), m_segmentsInternal(0), m_spectrometerTracksInternal(0), @@ -634,14 +631,14 @@ TrigMuonEFStandaloneTrackTool::getSpectrometerTracks(const IRoiDescriptor* muonR /// Making Object to cache pointers for segfinder: SC holds Pointers that are all deleted at end of event - if( not m_segments and not m_segmentCombiColl ) { + if( not m_segments ) { ATH_MSG_DEBUG( "No Muon Segments built. Check configuration! Stop here to process the RoI" ); return HLT::MISSING_FEATURE; } // // build tracks // - return buildTracks(m_segmentCombiColl, m_segments, cache, monVars.MS, timers, 3); + return buildTracks(m_segments, cache, monVars.MS, timers, 3); } @@ -781,10 +778,8 @@ HLT::ErrorCode TrigMuonEFStandaloneTrackTool::findSegments(const IRoiDescriptor* } else msg()<< MSG::DEBUG << " L2 Muon Container retrieved with key " << l2muonKey << endmsg; } // reset cached pointers - m_segmentCombiColl=0; m_patternCombiColl=0; m_segments= 0; - m_segmentCombiCollInternal=0; m_patternCombiCollInternal=0; m_segmentsInternal= 0; m_spectrometerTracks = 0; @@ -1544,7 +1539,6 @@ if (m_useMdtData>0) { if (segFinderTime) segFinderTime->start(); cache = itSCmap->second; - if(cache->SegColl() ) m_segmentCombiCollInternal = cache->SegColl(); if(cache->PattColl()) m_patternCombiCollInternal = cache->PattColl(); if(cache->Segments()) m_segmentsInternal = cache->Segments(); @@ -1575,44 +1569,44 @@ if (m_useMdtData>0) { } } - Muon::IMooSegmentCombinationFinder::Output* output = 0; + Muon::IMooSegmentCombinationFinder::Output output; + std::unique_ptr<MuonPatternCombinationCollection> pattColl(new MuonPatternCombinationCollection()); + output.patternCombinations=pattColl.get(); + std::unique_ptr<Trk::SegmentCollection> segColl(new Trk::SegmentCollection()); + output.segmentCollection=segColl.get(); if(m_useL2Hits){ if(mdtCols2.size()>0){ - output = m_segmentsFinderTool->findSegments(mdtCols2, cscCols, tgcCols, rpcCols); - if(!output || (output->segmentCombinations)->size()==0){ - ATH_MSG_DEBUG("didn't find mstrk with l2 hits, use all mdt hits in roi"); - output = m_segmentsFinderTool->findSegments(mdtCols, cscCols, tgcCols, rpcCols); - } + m_segmentsFinderTool->findSegments(mdtCols2, cscCols, tgcCols, rpcCols, output); + if(output.segmentCollection->size()==0){ + ATH_MSG_DEBUG("didn't find mstrk with l2 hits, use all mdt hits in roi"); + m_segmentsFinderTool->findSegments(mdtCols, cscCols, tgcCols, rpcCols, output); + } } - else output = m_segmentsFinderTool->findSegments(mdtCols, cscCols, tgcCols, rpcCols); - } - else output = m_segmentsFinderTool->findSegments(mdtCols, cscCols, tgcCols, rpcCols); - if ( !output ) { - if (segFinderTime) segFinderTime->stop(); - ATH_MSG_DEBUG("Segment finder return nothing: stop here to process the RoI"); - return HLT::MISSING_FEATURE; + else m_segmentsFinderTool->findSegments(mdtCols, cscCols, tgcCols, rpcCols, output); } - if (!output->segmentCombinations) { + else m_segmentsFinderTool->findSegments(mdtCols, cscCols, tgcCols, rpcCols, output); + if (!output.segmentCollection) { if (segFinderTime) segFinderTime->stop(); - ATH_MSG_WARNING("Segment finder returned an invalid pointer for the segmentCombinations"); + ATH_MSG_WARNING("Segment finder returned an invalid pointer for the segments"); cleanSegmentCollections(); return HLT::ErrorCode(HLT::Action::ABORT_CHAIN); } - + if ( output.segmentCollection->empty() ) { + if (segFinderTime) segFinderTime->stop(); + ATH_MSG_DEBUG("Segment finder return nothing: stop here to process the RoI"); + return HLT::MISSING_FEATURE; + } - /// SegmentCache object takes pointers to be given to m_segmentCombiColl, m_patternCombiColl and segments + /// SegmentCache object takes pointers to be given to m_patternCombiColl and segments ATH_MSG_DEBUG("SegmentCache object taking pointers"); - m_segmentCombiCollInternal=output->segmentCombinations; - m_patternCombiCollInternal=output->patternCombinations; - m_segmentsInternal=output->segmentCollection ; + m_patternCombiCollInternal=pattColl.release(); + m_segmentsInternal=segColl.release(); - delete output; // right now offline tool will not delete it for(auto mdtcoll : mdtCols2) if(mdtcoll) delete mdtcoll; if (m_doCache) { ATH_MSG_DEBUG("Setting up caching"); cache = new SegmentCache(); - cache->AddSegmentCollection(m_segmentCombiCollInternal); cache->AddPatternCollection(m_patternCombiCollInternal); cache->AddSegments(m_segmentsInternal); cache->SetNROI(m_roi_num_seg);//Setting roi number to SC obj for caching info @@ -1624,22 +1618,9 @@ if (m_useMdtData>0) { monVars.wasCached = 0; } - ATH_MSG_DEBUG("m_segmentCombiColl = "<< m_segmentCombiCollInternal); - if(m_segmentCombiCollInternal){ - ATH_MSG_DEBUG("m_segmentCombiColl->size() = "<< m_segmentCombiCollInternal->size()); - // Dump segments - if (msgLvl(MSG::DEBUG)) { - msg() << MSG::DEBUG << "REGTEST MuonEF Found " << m_segmentCombiCollInternal->size() << " combined segment collection" << endmsg; - for(unsigned int nSeg=0; nSeg!=m_segmentCombiCollInternal->size(); nSeg++) { - if((*(m_segmentCombiCollInternal))[nSeg]){ msg() << MSG::DEBUG << "Combined segment collection " << nSeg << " contains " - << ((*(m_segmentCombiCollInternal))[nSeg])->numberOfStations() << " stations" << endmsg; - for(unsigned int nStat=0; nStat!=((*(m_segmentCombiCollInternal))[nSeg])->numberOfStations(); nStat++) { - if(((*(m_segmentCombiCollInternal))[nSeg])->stationSegments(nStat)) msg() << MSG::DEBUG << " - segment collection " << nStat << " contains " - << ((*(m_segmentCombiCollInternal))[nSeg])->stationSegments(nStat)->size() << " segments" << endmsg; - } - } - } - } + ATH_MSG_DEBUG("m_segments = "<< m_segmentsInternal); + if(m_segmentsInternal){ + ATH_MSG_DEBUG("Found "<< m_segmentsInternal->size()<<" segments"); } ATH_MSG_DEBUG("Stopping segFinderTime"); @@ -1650,12 +1631,6 @@ if (m_useMdtData>0) { ATH_MSG_DEBUG("Starting dataOutputTime"); if (dataOutputTime) dataOutputTime->start(); - if(m_segmentCombiCollInternal) { - typedef ConstDataVector<MuonSegmentCombinationCollection> constvec_t; - constvec_t* tmpvec = new constvec_t (m_segmentCombiCollInternal->begin(), - m_segmentCombiCollInternal->end()); - m_segmentCombiColl = tmpvec->asDataVector(); - } if(m_patternCombiCollInternal) { typedef ConstDataVector<MuonPatternCombinationCollection> constvec_t; constvec_t* tmpvec = new constvec_t (m_patternCombiCollInternal->begin(), @@ -1674,15 +1649,11 @@ if (m_useMdtData>0) { ATH_MSG_DEBUG("Doing addElement for m_patternCombiColl"); addElement( m_patternCombisCache, m_patternCombiColl ); addElement( m_patternCombisCache, m_patternCombiCollInternal ); - ATH_MSG_DEBUG("Doing addElement for m_segmentCombiColl"); - addElement( m_segmentCombisCache, m_segmentCombiColl ); - addElement( m_segmentCombisCache, m_segmentCombiCollInternal ); ATH_MSG_DEBUG("Doing addElement for m_segments"); addElement( m_segmentsCache, m_segments ); addElement( m_segmentsCache, m_segmentsInternal ); int nSeg = 0; - if(m_segmentCombiColl) nSeg = segmentMonitoring(m_segmentCombiColl, monVars); if(m_segments){ std::vector<const Muon::MuonSegment*> muonSegCollection; for(Trk::SegmentCollection::const_iterator itSeg = m_segments->begin(); itSeg!= m_segments->end(); ++itSeg){ @@ -1701,7 +1672,7 @@ if (m_useMdtData>0) { //________________________________________________________________________ HLT::ErrorCode -TrigMuonEFStandaloneTrackTool::buildTracks(const MuonSegmentCombinationCollection* segments, const Trk::SegmentCollection* segment_collection, +TrigMuonEFStandaloneTrackTool::buildTracks(const Trk::SegmentCollection* segment_collection, SegmentCache* cache, TrigMuonEFMSMonVars& monVars, std::vector<TrigTimer*>& timers, unsigned int firstTimerIndex ) @@ -1747,21 +1718,7 @@ TrigMuonEFStandaloneTrackTool::buildTracks(const MuonSegmentCombinationCollectio for(Trk::SegmentCollection::const_iterator itSeg = segment_collection->begin(); itSeg!= segment_collection->end(); ++itSeg){ muonSegCollection.push_back(dynamic_cast<const Muon::MuonSegment*>(*itSeg)); } - } else if ( segments and segments->size() ) { - ATH_MSG_VERBOSE("Converting MuonSegmentCombinationCollection into std::vector<const Muon::MuonSegment*>"); - MuonSegmentCombinationCollection::const_iterator itSegComb = segments->begin(), itSegComb_end = segments->end(); - for ( ; itSegComb != itSegComb_end; ++itSegComb ) { - if(!(*itSegComb)) continue; - const MuonSegmentCombination* segComb = *itSegComb; - unsigned int nStations=0; - if(segComb) nStations = segComb->numberOfStations(); - for ( unsigned int iStation = 0; iStation < nStations; ++iStation ) { - const std::vector<const MuonSegment*>* segs = segComb->stationSegments(iStation); - if ( segs ) muonSegCollection.insert(muonSegCollection.end(), segs->begin(), segs->end()); - } - } } - if ( muonSegCollection.size() ) { ATH_MSG_DEBUG("Doing Muon track finding with muon segment collection of size " << muonSegCollection.size()); m_spectrometerTracksInternal = m_trackBuilderTool->find(muonSegCollection); @@ -1787,7 +1744,7 @@ TrigMuonEFStandaloneTrackTool::buildTracks(const MuonSegmentCombinationCollectio // store for deletion at the end of event addElement( m_spectrometerTracksCache, m_spectrometerTracks ); addElement( m_spectrometerTracksCache, m_spectrometerTracksInternal ); - + // Dump tracks if (msgLvl(MSG::DEBUG)) { ATH_MSG_DEBUG("REGTEST MuonEF Found " << m_spectrometerTracks->size() << " tracks"); @@ -2118,36 +2075,6 @@ void TrigMuonEFStandaloneTrackTool::cleanSegmentCollections() /// Before deleting the collections, we check whether the objects within them are stored in the association map. /// If they are then we remove them from the map (see savannah #71203) - if (m_segmentCombiColl) { - if ( m_segmentCombiColl->size() > 0 ) { - const IMuonPatternSegmentAssociationTool::AssociationMap& assMap = m_assocTool->map(); - IMuonPatternSegmentAssociationTool::AssociationMap* nonConstMap = const_cast<IMuonPatternSegmentAssociationTool::AssociationMap*>(&assMap); - bool printedHeader = false; - MuonSegmentCombinationCollection::const_iterator itS = m_segmentCombiColl->begin(), itS_end = m_segmentCombiColl->end(); - for ( ; itS != itS_end; ++itS ) { - const MuonSegmentCombination* combi = *itS; - // bug hunting printout - int n = m_assocTool->count( combi ); - if ( n ) { - // bug hunting printout - if ( !printedHeader ) { - ATH_MSG_INFO(__FUNCTION__ << " Event where by-hand clean-up needed:"); - printedHeader = true; - } - ATH_MSG_INFO(" About to Delete segmentCombi @ " << combi << ",so first remove it from " - << n << " entrie(s) in associationMap"); - } - - // hacky FIX for bug #71203 (clean fix would use assocTool->remove(combi), but that does not exist yet) - if( nonConstMap ) nonConstMap->erase( combi ); - } - if ( printedHeader ) msg() << endmsg; // prints out run,event,etc. - } - - delete m_segmentCombiColl; - m_segmentCombiColl=0; - } - if (m_patternCombiColl) { if ( m_patternCombiColl->size() > 0 ) { const IMuonPatternSegmentAssociationTool::AssociationMap& assMap = m_assocTool->map(); @@ -2184,39 +2111,6 @@ void TrigMuonEFStandaloneTrackTool::cleanSegmentCollections() m_segments=0; } - -//________________________________________________________________________ -void TrigMuonEFStandaloneTrackTool::recordSegments() -{ - // store the MuonSegmentCombinationCollection in StoreGate for debug purposes - MuonSegmentCombinationCollection* segmentCombColl = 0; - std::string segmentCombCollLocation = "TrigMuonEFSegments"; - if( evtStore()->contains<MuonSegmentCombinationCollection>(segmentCombCollLocation) ){ - if (evtStore()->retrieve(segmentCombColl,segmentCombCollLocation).isFailure()){ - msg() << MSG::WARNING << "Could not retrieve MuonSegmentCombinationCollection at " - << segmentCombCollLocation << endmsg; - } - } - else{ - ATH_MSG_DEBUG("Recording new segment combination collection with key " - << segmentCombCollLocation); - segmentCombColl = new MuonSegmentCombinationCollection(); - if(evtStore()->record(segmentCombColl,segmentCombCollLocation,true).isFailure()){ - msg() << MSG::WARNING << "Could not record MuonSegmentCombinationCollection at " - << segmentCombCollLocation << endmsg; - delete segmentCombColl; - segmentCombColl = 0; - } - } - - if (segmentCombColl && m_segmentCombiColl) { - for (MuonSegmentCombinationCollection::const_iterator itSegm = m_segmentCombiColl->begin(); itSegm!= m_segmentCombiColl->end(); ++itSegm) { - const Muon::MuonSegmentCombination* segm = *itSegm; - segmentCombColl->push_back( new Muon::MuonSegmentCombination(*segm) ); - } - } -} - //________________________________________________________________________ void TrigMuonEFStandaloneTrackTool::recordPatterns() { @@ -2427,7 +2321,6 @@ void TrigMuonEFStandaloneTrackTool::handle(const Incident &inc) clearCacheVector( m_spectrometerTracksCache ); clearCacheVector( m_extrapolatedTracksCache ); clearCacheVector( m_patternCombisCache ); - clearCacheVector( m_segmentCombisCache ); clearCacheVector( m_segmentsCache ); clearCacheVector(m_mdtcollCache); @@ -2467,13 +2360,6 @@ TrigMuonEFStandaloneTrackTool::getExtrapolatedTracks(const IRoiDescriptor* muonR return getExtrapolatedTracks( muonRoI, candidateCollection, extrapolatedTracks, cache, monVars, timers ); } -//________________________________________________________________________ -const MuonSegmentCombinationCollection* -TrigMuonEFStandaloneTrackTool::segmentCombis() -{ - return m_segmentCombiColl; -} - //________________________________________________________________________ const MuonPatternCombinationCollection* TrigMuonEFStandaloneTrackTool::patternCombis() @@ -2502,14 +2388,6 @@ TrigMuonEFStandaloneTrackTool::extrapolatedTracks() return m_extrapolatedTracks; } -//________________________________________________________________________ -const MuonSegmentCombinationCollection* -TrigMuonEFStandaloneTrackTool::segmentCombisToAttach() -{ - removeElement(m_segmentCombisCache, m_segmentCombiColl); - return m_segmentCombiColl; -} - //________________________________________________________________________ const MuonPatternCombinationCollection* TrigMuonEFStandaloneTrackTool::patternCombisToAttach() @@ -2637,29 +2515,6 @@ std::vector<std::vector<IdentifierHash> > TrigMuonEFStandaloneTrackTool::getHash } -//________________________________________________________________________ -int TrigMuonEFStandaloneTrackTool::segmentMonitoring(const MuonSegmentCombinationCollection* segmentCombiColl, TrigMuonEFSegmentMonVars& monVars){ - - int nSeg = 0; - if(!segmentCombiColl){ - ATH_MSG_WARNING("MuonSegmentCombinationCollection is empty. Segment monitoring will not be done"); - return nSeg; - } - monVars.numberOfSegComb.push_back(segmentCombiColl->size()); - for (MuonSegmentCombinationCollection::const_iterator sc = segmentCombiColl->begin(); - sc != segmentCombiColl->end(); ++sc){ - if(*sc){ - monVars.numberOfStations.push_back((*sc)->numberOfStations()); - for(unsigned int nStat=0; nStat < (*sc)->numberOfStations(); nStat++) { - const std::vector<const MuonSegment*>* statSegments = (*sc)->stationSegments(nStat); - nSeg += segmentMonitoring(*statSegments, monVars); - } - } - } - - return nSeg; -} - //________________________________________________________________________ int TrigMuonEFStandaloneTrackTool::segmentMonitoring(const std::vector< const MuonSegment*>& segmentVector, TrigMuonEFSegmentMonVars& monVars) { diff --git a/Trigger/TrigAlgorithms/TrigMuonEF/src/TrigMuonEFStandaloneTrackTool.h b/Trigger/TrigAlgorithms/TrigMuonEF/src/TrigMuonEFStandaloneTrackTool.h index 56049847278fa74f3a2ac3bc1d12bb27be3b3f1a..8e1909642b757a5c3ff61ee4a558e0ff254becfb 100644 --- a/Trigger/TrigAlgorithms/TrigMuonEF/src/TrigMuonEFStandaloneTrackTool.h +++ b/Trigger/TrigAlgorithms/TrigMuonEF/src/TrigMuonEFStandaloneTrackTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TRIGMUONEF_TRIGMUONEFSTANDALONETRACKTOOL_H @@ -19,9 +19,7 @@ #include "MuonRecToolInterfaces/IMuonCombiTrackMaker.h" #include "GaudiKernel/IIncidentListener.h" #include "GaudiKernel/ToolHandle.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonPattern/MuonPatternCombinationCollection.h" -#include "MuonSegment/MuonSegmentCombination.h" #include "TrkSegment/SegmentCollection.h" #include "TrigInterfaces/IMonitoredAlgo.h" #include "MuonCnvToolInterfaces/IMuonRawDataProviderTool.h" @@ -128,10 +126,6 @@ class TrigMuonEFStandaloneTrackTool : public AthAlgTool, /** get list of hashIDs used in roi (used for internal caching in TrigMuSuperEF) **/ virtual std::vector<std::vector<IdentifierHash> > getHashList(const IRoiDescriptor* muonRoI); - /** return last created MuonSegmentCombinationCollection. Caller is responsible for deletion of object. - Call this function if you want to attach the object to the TriggerElement */ - virtual const MuonSegmentCombinationCollection* segmentCombisToAttach(); - /** return last created MuonPatternCombinationCollection. Caller is responsible for deletion of object. Call this function if you want to attach the object to the TriggerElement */ virtual const MuonPatternCombinationCollection* patternCombisToAttach(); @@ -153,10 +147,6 @@ class TrigMuonEFStandaloneTrackTool : public AthAlgTool, virtual const xAOD::TrackParticleContainer* trackParticleContainerToAttach(); virtual const xAOD::TrackParticleAuxContainer* trackParticleAuxContainerToAttach(); - /** return last created MuonSegmentCombinationCollection. Object will be deleted by tool at the end of the event. - NB: You can not attach this object to the TriggerElement */ - virtual const MuonSegmentCombinationCollection* segmentCombis(); - /** return last created MuonPatternCombinationCollection. Object will be deleted by tool at the end of the event. NB: You can not attach this object to the TriggerElement */ virtual const MuonPatternCombinationCollection* patternCombis(); @@ -176,12 +166,8 @@ class TrigMuonEFStandaloneTrackTool : public AthAlgTool, int segmentMonitoring(const std::vector<const Muon::MuonSegment*>& segmentVector, TrigMuonEFSegmentMonVars& monVars); - int segmentMonitoring(const MuonSegmentCombinationCollection* segmentCombiColl, - TrigMuonEFSegmentMonVars& monVars); - virtual void handle(const Incident &inc); - virtual void recordSegments(); virtual void recordPatterns(); virtual void recordSpectrometerTracks(); @@ -237,8 +223,7 @@ class TrigMuonEFStandaloneTrackTool : public AthAlgTool, std::vector<TrigTimer*>& timers, unsigned int firstTimerIndex ); /** Build tracks out of input segments */ - HLT::ErrorCode buildTracks(const MuonSegmentCombinationCollection* segments, - const Trk::SegmentCollection* segment_collection, + HLT::ErrorCode buildTracks(const Trk::SegmentCollection* segment_collection, SegmentCache* cache, TrigMuonEFMSMonVars& monVars, std::vector<TrigTimer*>& timers, unsigned int firstTimerIndex ); @@ -350,11 +335,9 @@ class TrigMuonEFStandaloneTrackTool : public AthAlgTool, // features written to TriggerElement // TrigMuonEFInfoContainer* m_myMuonEFInfoCont; - const MuonSegmentCombinationCollection* m_segmentCombiColl; const MuonPatternCombinationCollection* m_patternCombiColl; const Trk::SegmentCollection* m_segments; const TrackCollection* m_spectrometerTracks; - const MuonSegmentCombinationCollection* m_segmentCombiCollInternal; const MuonPatternCombinationCollection* m_patternCombiCollInternal; const Trk::SegmentCollection* m_segmentsInternal; const TrackCollection* m_spectrometerTracksInternal; @@ -376,7 +359,6 @@ class TrigMuonEFStandaloneTrackTool : public AthAlgTool, std::vector<const TrackCollection*> m_spectrometerTracksCache; std::vector<TrackCollection*> m_extrapolatedTracksCache; std::vector<const MuonPatternCombinationCollection*> m_patternCombisCache; - std::vector<const MuonSegmentCombinationCollection*> m_segmentCombisCache; std::vector<const Trk::SegmentCollection*> m_segmentsCache; std::vector<Muon::MdtPrepDataCollection*> m_mdtcollCache; diff --git a/Trigger/TrigHypothesis/TrigMuonHypo/src/TrigMuonEFExtrapolatorNSWHypo.cxx b/Trigger/TrigHypothesis/TrigMuonHypo/src/TrigMuonEFExtrapolatorNSWHypo.cxx index 99b40ae735b84eac5189944e7add43696d86d07f..0c7f3fff21fed06b67f706392ad7c3607921f93e 100644 --- a/Trigger/TrigHypothesis/TrigMuonHypo/src/TrigMuonEFExtrapolatorNSWHypo.cxx +++ b/Trigger/TrigHypothesis/TrigMuonHypo/src/TrigMuonEFExtrapolatorNSWHypo.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "TrigMuonHypo/TrigMuonEFExtrapolatorNSWHypo.h" @@ -7,10 +7,8 @@ #include "CLHEP/Units/SystemOfUnits.h" #include "TrigSteeringEvent/TrigRoiDescriptor.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" -#include "MuonSegment/MuonSegmentCombination.h" +#include "TrkSegment/SegmentCollection.h" #include "MuonSegment/MuonSegment.h" -#include "MuonSegmentMakerUtils/MuonSegmentCombiSummary.h" #include "TrigT1Interfaces/RecMuonRoI.h" class ISvcLocator; @@ -162,105 +160,84 @@ HLT::ErrorCode TrigMuonEFExtrapolatorNSWHypo::hltExecute(const HLT::TriggerEleme int n_seg_sameside = 0; // for monitoring // get MuonSegmentCombinationCollection - std::vector<const MuonSegmentCombinationCollection*> vectorOfSegmentCombination; - if(getFeatures(outputTE, vectorOfSegmentCombination)!=HLT::OK) { - if (debug) msg() << MSG::DEBUG << "No MuonSegmentCombinationCollection found" << endmsg; + std::vector<const Trk::SegmentCollection*> vectorOfSegmentCollection; + if(getFeatures(outputTE, vectorOfSegmentCollection)!=HLT::OK) { + if (debug) msg() << MSG::DEBUG << "No SegmentCollection found" << endmsg; return HLT::MISSING_FEATURE; } else { - if (debug) msg() << MSG::DEBUG << "vector of MuonSegmentCombinationCollection found with size=" << vectorOfSegmentCombination.size() << endmsg; + if (debug) msg() << MSG::DEBUG << "vector of SegmentCollection found with size=" << vectorOfSegmentCollection.size() << endmsg; } // this size should be 1. // loop on MuonSegmentCombination - for (unsigned int i=0; i<vectorOfSegmentCombination.size(); i++) { + for (unsigned int i=0; i<vectorOfSegmentCollection.size(); i++) { - if (debug) msg() << MSG::DEBUG << "++ Element " << i << " of vector of MuonSegmentCombinationCollection ++" << endmsg; + if (debug) msg() << MSG::DEBUG << "++ Element " << i << " of vector of SegmentCollection ++" << endmsg; - const MuonSegmentCombinationCollection* segCombiColl = vectorOfSegmentCombination[i]; - if(!segCombiColl){ - msg() << MSG::ERROR << "Retrieval of MuonSegmentCombinationCollection from vector failed" << endmsg; + const Trk::SegmentCollection* segColl = vectorOfSegmentCollection[i]; + if(!segColl){ + msg() << MSG::ERROR << "Retrieval of SegmentCollection from vector failed" << endmsg; return HLT::NAV_ERROR; } else { - if (debug) msg() << MSG::DEBUG << "MuonSegmentCombinationCollection OK with size=" << segCombiColl->size() << endmsg; + if (debug) msg() << MSG::DEBUG << "SegmentCollection OK with size=" << segColl->size() << endmsg; } - MuonSegmentCombinationCollection::const_iterator segCombiItr = segCombiColl->begin(); - MuonSegmentCombinationCollection::const_iterator segCombiItrE = segCombiColl->end(); - for (int j=0; segCombiItr != segCombiItrE; ++segCombiItr, ++j ) { + Trk::SegmentCollection::const_iterator segItr = segColl->begin(); + Trk::SegmentCollection::const_iterator segItrE = segColl->end(); + for (int j=0; segItr != segItrE; ++segItr, ++j ) { - msg() << MSG::DEBUG << "-- MuonSegmentCombination:" << j << " --" << endmsg; + msg() << MSG::DEBUG << "-- Segment:" << j << " --" << endmsg; - const Muon::MuonSegmentCombination* segCombi = (*segCombiItr); - if (!segCombi) { - if (debug) msg() << MSG::DEBUG << "No MuonSegmentCombination found." << endmsg; - continue; + const Muon::MuonSegment* segment=dynamic_cast<const Muon::MuonSegment*>(*segItr); + + // get chamber identifier, chamber index and station index + Identifier chid = m_edmhelperTool->chamberId( *segment ); + Muon::MuonStationIndex::ChIndex chIndex = m_idhelperTool->chamberIndex(chid); + if (debug) msg() << MSG::DEBUG << " chamber index=" << chIndex << endmsg; + + // only in EI and CSC + if( chIndex!=Muon::MuonStationIndex::EIS && chIndex!=Muon::MuonStationIndex::EIL && + chIndex!=Muon::MuonStationIndex::CSS && chIndex!=Muon::MuonStationIndex::CSL ) { + continue; } - unsigned int nstations = segCombi->numberOfStations(); - if (debug) msg() << MSG::DEBUG << "nr stations=" << nstations << endmsg; - - for(unsigned int i_st=0; i_st<nstations; i_st++) { - - const Muon::MuonSegmentCombination::SegmentVec* stationSegs = segCombi->stationSegments(i_st) ; - // check if not empty - if( !stationSegs || stationSegs->empty() ) continue; - if (debug) msg() << MSG::DEBUG << "i_st=" << i_st << " : n segments=" << stationSegs->size() << endmsg; - - // get chamber identifier, chamber index and station index - Identifier chid = m_edmhelperTool->chamberId( *stationSegs->front() ); - Muon::MuonStationIndex::ChIndex chIndex = m_idhelperTool->chamberIndex(chid); - if (debug) msg() << MSG::DEBUG << " chamber index=" << chIndex << endmsg; - - // only in EI and CSC - if( chIndex!=Muon::MuonStationIndex::EIS && chIndex!=Muon::MuonStationIndex::EIL && - chIndex!=Muon::MuonStationIndex::CSS && chIndex!=Muon::MuonStationIndex::CSL ) { - continue; - } - - // loop on segments - for(unsigned int i_seg=0; i_seg<stationSegs->size(); i_seg++) { - const Muon::MuonSegment* segment = (*stationSegs)[i_seg]; - const Amg::Vector3D& dir = segment->globalDirection(); - const Amg::Vector3D& pos = segment->globalPosition(); - if (debug) { - msg() << MSG::DEBUG << " i_seg=" << i_seg << endmsg; - msg() << MSG::DEBUG << " GlobalDirection eta/phi=" << dir.eta() << "/" << dir.phi() << endmsg; - msg() << MSG::DEBUG << " GlobalPosition x/y/z=" << pos.x() << "/" << pos.y() << "/" << pos.z() << endmsg; - } - - // same side segments only - if( (pos.eta() * roi_eta < 0) ) continue; - - n_seg_sameside++; - - // dTheta: direction and position theta difference - double dTheta = pos.theta() - dir.theta(); - if( roi_eta < 0 ) dTheta *= -1; - bool isPassed_dTheta = dThetaCut(roi_eta, dTheta); - - // dL: NSW position and RoI position difference - double dLeta = fabs(pos.eta() - roi_eta); - double dLphi = fabs(pos.phi() - roi_phi); - if( dLphi > CLHEP::pi ) dLphi = CLHEP::twopi - dLphi; - bool isPassed_dL = dLCut(roi_eta, dLeta, dLphi); - - // monitoring - m_fex_dTheta.push_back(dTheta); - m_fex_dLeta.push_back(dLeta); - m_fex_dLphi.push_back(dLphi); - if(debug) { - msg() << MSG::DEBUG << " dTheta=" << dTheta << ": isPassed=" << isPassed_dTheta << endmsg; - msg() << MSG::DEBUG << " dLeta/phi=" << dLeta << "/" << dLphi << ": isPassed_dL=" << isPassed_dL << endmsg; - } - - // this segment passes cut - if( isPassed_dTheta && isPassed_dL ) n_seg_passed++; - } + const Amg::Vector3D& dir = segment->globalDirection(); + const Amg::Vector3D& pos = segment->globalPosition(); + if (debug) { + msg() << MSG::DEBUG << " GlobalDirection eta/phi=" << dir.eta() << "/" << dir.phi() << endmsg; + msg() << MSG::DEBUG << " GlobalPosition x/y/z=" << pos.x() << "/" << pos.y() << "/" << pos.z() << endmsg; + } - } // end of station loop - } // end of SegComb loop - } // end of vector SegComb loop + // same side segments only + if( (pos.eta() * roi_eta < 0) ) continue; + + n_seg_sameside++; + + // dTheta: direction and position theta difference + double dTheta = pos.theta() - dir.theta(); + if( roi_eta < 0 ) dTheta *= -1; + bool isPassed_dTheta = dThetaCut(roi_eta, dTheta); + + // dL: NSW position and RoI position difference + double dLeta = fabs(pos.eta() - roi_eta); + double dLphi = fabs(pos.phi() - roi_phi); + if( dLphi > CLHEP::pi ) dLphi = CLHEP::twopi - dLphi; + bool isPassed_dL = dLCut(roi_eta, dLeta, dLphi); + + // monitoring + m_fex_dTheta.push_back(dTheta); + m_fex_dLeta.push_back(dLeta); + m_fex_dLphi.push_back(dLphi); + if(debug) { + msg() << MSG::DEBUG << " dTheta=" << dTheta << ": isPassed=" << isPassed_dTheta << endmsg; + msg() << MSG::DEBUG << " dLeta/phi=" << dLeta << "/" << dLphi << ": isPassed_dL=" << isPassed_dL << endmsg; + } + + // this segment passes cut + if( isPassed_dTheta && isPassed_dL ) n_seg_passed++; + } //end of segment loop + } // end of vector SegColl loop // monitoring m_fex_n_seg_passed = n_seg_passed; diff --git a/Trigger/TrigTools/TrigMuonToolInterfaces/TrigMuonToolInterfaces/ITrigMuonStandaloneTrackTool.h b/Trigger/TrigTools/TrigMuonToolInterfaces/TrigMuonToolInterfaces/ITrigMuonStandaloneTrackTool.h index 47cfbcb22c409607fcd26255a30fc4898f34d5ef..4d2e3d0172717d6da4a3e8274ffb650a182fa0ef 100644 --- a/Trigger/TrigTools/TrigMuonToolInterfaces/TrigMuonToolInterfaces/ITrigMuonStandaloneTrackTool.h +++ b/Trigger/TrigTools/TrigMuonToolInterfaces/TrigMuonToolInterfaces/ITrigMuonStandaloneTrackTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TRIGMUONTOOLINTERFACES_ITRIGMUONSTANDALONETRACKTOOL_H @@ -8,7 +8,6 @@ #include "GaudiKernel/IAlgTool.h" #include "TrigSteeringEvent/Enums.h" #include "TrigMuonEvent/CachingFeatureCollection.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonPattern/MuonPatternCombinationCollection.h" #include "TrkSegment/SegmentCollection.h" #include "TrkTrack/TrackCollection.h" @@ -67,10 +66,6 @@ class ITrigMuonStandaloneTrackTool : virtual public IAlgTool { TrigMuonEFMonVars& monvars, std::vector<TrigTimer*>& timers) = 0; - /** return last created MuonSegmentCombinationCollection. Object will be deleted by tool at the end of the event. - NB: You can not attach this object to the TriggerElement */ - virtual const MuonSegmentCombinationCollection* segmentCombis()=0; - /** return last created MuonPatternCombinationCollection. Object will be deleted by tool at the end of the event. NB: You can not attach this object to the TriggerElement */ virtual const MuonPatternCombinationCollection* patternCombis()=0; @@ -88,10 +83,6 @@ class ITrigMuonStandaloneTrackTool : virtual public IAlgTool { virtual const TrackCollection* extrapolatedTracks() = 0; - /** return last created MuonSegmentCombinationCollection. Caller is responsible for deletion of object. - Call this function if you want to attach the object to the TriggerElement */ - virtual const MuonSegmentCombinationCollection* segmentCombisToAttach()=0; - /** return last created MuonPatternCombinationCollection. Caller is responsible for deletion of object. Call this function if you want to attach the object to the TriggerElement */ virtual const MuonPatternCombinationCollection* patternCombisToAttach()=0; @@ -113,7 +104,6 @@ class ITrigMuonStandaloneTrackTool : virtual public IAlgTool { virtual const xAOD::TrackParticleContainer* trackParticleContainerToAttach()=0; virtual const xAOD::TrackParticleAuxContainer* trackParticleAuxContainerToAttach()=0; - virtual void recordSegments() = 0; virtual void recordPatterns() = 0; virtual void recordSpectrometerTracks() = 0;