diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GsfMeasurementUpdator.h b/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GsfMeasurementUpdator.h index 6957884f715b5b7df619d36cf4160496a12853f6..be5341413d3fb2aa519254a611b9ac27cd9affef 100755 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GsfMeasurementUpdator.h +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GsfMeasurementUpdator.h @@ -73,11 +73,6 @@ class GsfMeasurementUpdator : public AthAlgTool, virtual public IMultiStateMeasu const MultiComponentState* calculateFilterStep( const MultiComponentState&, const MeasurementBase&, std::unique_ptr<FitQualityOnSurface>& fitQoS ) const; - - bool invalidComponent(const Trk::TrackParameters* trackParameters ) const; - - Trk::MultiComponentState* rebuildState(const Trk::MultiComponentState& stateBeforeUpdate) const; - private: int m_outputlevel; //!< to cache current output level diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfMeasurementUpdator.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfMeasurementUpdator.cxx index 6b58c49827743890c290895b0cef7b628cc46f90..d80b72b412026021b05c23822d67da9c015ee014 100755 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfMeasurementUpdator.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfMeasurementUpdator.cxx @@ -47,30 +47,31 @@ StatusCode Trk::GsfMeasurementUpdator::initialize() // Request the Chrono Service if ( m_chronoSvc.retrieve().isFailure() ) { - ATH_MSG_FATAL("Failed to retrieve service " << m_chronoSvc); + msg(MSG::FATAL) << "Failed to retrieve service " << m_chronoSvc << endmsg; return StatusCode::FAILURE; } else - ATH_MSG_INFO("Retrieved service " << m_chronoSvc); + msg(MSG::INFO) << "Retrieved service " << m_chronoSvc << endmsg; // Retrieve the updator tool if ( m_updator.retrieve().isFailure() ){ - ATH_MSG_FATAL("Could not retrieve measurement updator AlgTool ... Exiting!"); + msg(MSG::FATAL) + << "Could not retrieve measurement updator AlgTool ... Exiting!" << endmsg; return StatusCode::FAILURE; } // Retrieve the Posterior Weights Calculator if ( m_posteriorWeightsCalculator.retrieve().isFailure() ){ - ATH_MSG_FATAL("Could not find the Posterior Weights Calculator Service... Exiting!"); + msg(MSG::FATAL) << "Could not find the Posterior Weights Calculator Service... Exiting!" << endmsg; return StatusCode::FAILURE; } // Request an instance of the MultiComponentStateAssembler if ( m_stateAssembler.retrieve().isFailure() ){ - ATH_MSG_ERROR("Could not access the MultiComponentStateAssembler Service"); + msg(MSG::ERROR) << "Could not access the MultiComponentStateAssembler Service" << endmsg; return StatusCode::FAILURE; } - ATH_MSG_INFO("Initialisation of " << name() << " was successful"); + msg(MSG::INFO) << "Initialisation of " << name() << " was successful" << endmsg; return StatusCode::SUCCESS; } @@ -78,7 +79,7 @@ StatusCode Trk::GsfMeasurementUpdator::initialize() StatusCode Trk::GsfMeasurementUpdator::finalize() { - ATH_MSG_INFO("Finalisation of " << name() << " was successful"); + msg(MSG::INFO) << "Finalisation of " << name() << " was successful" << endmsg; return StatusCode::SUCCESS; } @@ -86,7 +87,8 @@ StatusCode Trk::GsfMeasurementUpdator::finalize() const Trk::MultiComponentState* Trk::GsfMeasurementUpdator::update (const Trk::MultiComponentState& stateBeforeUpdate, const Trk::MeasurementBase& measurement) const { - ATH_MSG_VERBOSE( "Updating using GsfMeasurementUpdator"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Updating using GsfMeasurementUpdator" << endmsg; const Trk::MultiComponentState* updatedState = 0; @@ -94,20 +96,72 @@ const Trk::MultiComponentState* Trk::GsfMeasurementUpdator::update (const Trk::M Updator updator = &Trk::IUpdator::addToState; // Check all components have associated error matricies + double weight = 0.; + + const Trk::TrackParameters* trackParameters = 0; + const AmgSymMatrix(5)* measuredCov = 0; Trk::MultiComponentState::const_iterator component = stateBeforeUpdate.begin(); bool rebuildStateWithErrors = false; // Perform initial check of state awaiting update. If all states have associated error matricies then no need to perform the rebuild for ( ; component != stateBeforeUpdate.end(); ++component ) { - rebuildStateWithErrors = rebuildStateWithErrors || invalidComponent( component->first ) ; + + trackParameters = component->first; + + measuredCov = trackParameters->covariance(); + + if ( !measuredCov ){ + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Component in the state awaiting update has no error matrix... rebuilding the entire state" << endmsg; + rebuildStateWithErrors = true; + } + } if ( rebuildStateWithErrors ){ - ATH_MSG_VERBOSE( "Rebuilding state with errors"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Rebuilding state with errors" << endmsg; + + Trk::MultiComponentState* stateWithInsertedErrors = new Trk::MultiComponentState(); + const Trk::TrackParameters* trackParametersWithError = 0; + + component = stateBeforeUpdate.begin(); + + for ( ; component != stateBeforeUpdate.end(); ++component ){ + + trackParameters = component->first; + weight = component->second; - Trk::MultiComponentState* stateWithInsertedErrors = rebuildState( stateBeforeUpdate ); + measuredCov = trackParameters->covariance(); + + + if ( !measuredCov ){ + + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "No measurement associated with track parameters, creating a big one" << endmsg; + AmgSymMatrix(5)* bigNewCovarianceMatrix = new AmgSymMatrix(5); + bigNewCovarianceMatrix->setZero(); + double covarianceScaler = 1.; + (*bigNewCovarianceMatrix)(0,0) = 250. * covarianceScaler; + (*bigNewCovarianceMatrix)(1,1) = 250. * covarianceScaler; + (*bigNewCovarianceMatrix)(2,2) = 0.25; + (*bigNewCovarianceMatrix)(3,3) = 0.25; + (*bigNewCovarianceMatrix)(4,4) = 0.001 * 0.001; + + const AmgVector(5)& par = trackParameters->parameters(); + trackParametersWithError = trackParameters->associatedSurface().createTrackParameters(par[Trk::loc1],par[Trk::loc2],par[Trk::phi],par[Trk::theta],par[Trk::qOverP], bigNewCovarianceMatrix ); + + Trk::ComponentParameters componentParametersWithError( trackParametersWithError, weight ); + stateWithInsertedErrors->push_back( componentParametersWithError ); + + } + + else + stateWithInsertedErrors->push_back( *component ); + + } // Perform the measurement update with the modified state updatedState = calculateFilterStep(*stateWithInsertedErrors, measurement, updator); @@ -115,7 +169,8 @@ const Trk::MultiComponentState* Trk::GsfMeasurementUpdator::update (const Trk::M delete stateWithInsertedErrors; if ( !updatedState ) { - ATH_MSG_DEBUG("Updated state could not be calculated... Returning 0" ); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Updated state could not be calculated... Returning 0" << endmsg; return 0; } @@ -127,7 +182,8 @@ const Trk::MultiComponentState* Trk::GsfMeasurementUpdator::update (const Trk::M updatedState = calculateFilterStep(stateBeforeUpdate, measurement, updator); if ( !updatedState ) { - ATH_MSG_DEBUG("Updated state could not be calculated... Returning 0" ); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Updated state could not be calculated... Returning 0" << endmsg; return 0; } @@ -156,7 +212,7 @@ Trk::GsfMeasurementUpdator::fitQuality (const MultiComponentState& updatedState, // Fit quality assumes that a state that has been updated by the measurement updator has been supplied to it if ( updatedState.empty() ){ - ATH_MSG_WARNING( "Attempting to calculate chi2 of a hit with respect to an empty multiple-component state" ); + msg(MSG::WARNING) << "Attempting to calculate chi2 of a hit with respect to an empty multiple-component state" << endmsg; return 0; } @@ -199,7 +255,8 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& const Updator updator) const { - ATH_MSG_VERBOSE( "Calculate Filter Step"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Calculate Filter Step" << endmsg; // Start the timer //Chrono chrono( &(*m_chronoSvc), "GsfMeasurementUpdate" ); @@ -208,12 +265,13 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& bool isAssemblerReset = m_stateAssembler->reset(); if ( !isAssemblerReset ){ - ATH_MSG_DEBUG("Could not reset the state assembler... returning 0"); + if (m_outputlevel <= 0) + msg(MSG::ERROR) << "Could not reset the state assembler... returning 0" << endmsg; return 0; } if ( stateBeforeUpdate.empty() ){ - ATH_MSG_WARNING("Cannot update multi-state with no components!"); + msg(MSG::WARNING) << "Cannot update multi-state with no components!" << endmsg; return 0; } @@ -223,11 +281,13 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& stateWithNewWeights = m_posteriorWeightsCalculator->weights(stateBeforeUpdate, measurement); if ( !stateWithNewWeights ) { - ATH_MSG_DEBUG( "Cacluation of state posterior weights failed... Exiting!"); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Cacluation of state posterior weights failed... Exiting!" << endmsg; return 0; } else - ATH_MSG_VERBOSE( "Calculation of state posterior weights successful"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Calculation of state posterior weights successful" << endmsg; // Update each component using the specified updator Trk::MultiComponentState::const_iterator component = stateWithNewWeights->begin(); @@ -236,7 +296,8 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& const Trk::TrackParameters* updatedTrackParameters = 0; - ATH_MSG_VERBOSE( "Performing update of predicted component state with measurement..."); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Performing update of predicted component state with measurement..." << endmsg; Trk::FitQualityOnSurface* fitQuality = 0; @@ -247,13 +308,21 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& //updatedTrackParameters = m_updator->addToState( *(*component).first, measurement.localParameters(), measurement.localCovariance(), fitQuality ); if ( !updatedTrackParameters ) { - ATH_MSG_DEBUG( "Update of state with Measurement has failed 1... Exiting!"); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Update of state with Measurement has failed 1... Exiting!" << endmsg; if ( fitQuality ) delete fitQuality; continue; } + + //std::cout << " A \n " << *updatedTrackParameters <<std::endl; + //std::cout << " B \n" << *updatedTrackParameters2 <<std::endl; + //delete updatedTrackParameters2; + //delete fitQuality2; + if ( fitQuality && fitQuality->chiSquared() <= 0. ){ - ATH_MSG_DEBUG( "Fit quality of update failed... Exiting!"); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Fit quality of update failed... Exiting!" << endmsg; delete updatedTrackParameters; delete fitQuality; continue; @@ -262,7 +331,8 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& // Clean up memory delete fitQuality; - ATH_MSG_VERBOSE( "Successful measurement update with Measurement"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Successful measurement update with Measurement" << endmsg; // Updator does not change the weighting Trk::ComponentParameters updatedComponentParameters(updatedTrackParameters, component->second); @@ -271,7 +341,8 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& bool componentAdded = m_stateAssembler->addComponent(updatedComponentParameters); if ( !componentAdded ) - ATH_MSG_DEBUG( "Component could not be added to the state in the assembler"); + if (m_outputlevel <= 0) + msg(MSG::WARNING) << "Component could not be added to the state in the assembler" << endmsg; delete updatedTrackParameters; @@ -293,7 +364,8 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& delete assembledUpdatedState; - ATH_MSG_VERBOSE( "Successful calculation of filter step"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Successful calculation of filter step" << endmsg; return renormalisedUpdatedState; @@ -305,33 +377,85 @@ Trk::GsfMeasurementUpdator::update (const Trk::MultiComponentState& stateBeforeU std::unique_ptr<FitQualityOnSurface>& fitQoS ) const { - ATH_MSG_VERBOSE( "Updating using GsfMeasurementUpdator"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Updating using GsfMeasurementUpdator" << endmsg; const Trk::MultiComponentState* updatedState = 0; // Check all components have associated error matricies + double weight = 0.; + + const Trk::TrackParameters* trackParameters = 0; + const AmgSymMatrix(5)* measuredCov = 0; Trk::MultiComponentState::const_iterator component = stateBeforeUpdate.begin(); bool rebuildStateWithErrors = false; // Perform initial check of state awaiting update. If all states have associated error matricies then no need to perform the rebuild for ( ; component != stateBeforeUpdate.end(); ++component ) { - rebuildStateWithErrors = rebuildStateWithErrors || invalidComponent( component->first ) ; + + trackParameters = component->first; + + measuredCov = trackParameters->covariance(); + + if ( !measuredCov ){ + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Component in the state awaiting update has no error matrix... rebuilding the entire state" << endmsg; + rebuildStateWithErrors = true; + } } if ( rebuildStateWithErrors ){ - ATH_MSG_VERBOSE( "Rebuilding state with errors"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Rebuilding state with errors" << endmsg; + + Trk::MultiComponentState* stateWithInsertedErrors = new Trk::MultiComponentState(); + const Trk::TrackParameters* trackParametersWithError = 0; + + component = stateBeforeUpdate.begin(); + + for ( ; component != stateBeforeUpdate.end(); ++component ){ + + trackParameters = component->first; + weight = component->second; + + measuredCov = trackParameters->covariance(); + + + if ( !measuredCov ){ + + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "No measurement associated with track parameters, creating a big one" << endmsg; + AmgSymMatrix(5)* bigNewCovarianceMatrix = new AmgSymMatrix(5); + bigNewCovarianceMatrix->setZero(); + double covarianceScaler = 1.; + (*bigNewCovarianceMatrix)(0,0) = 250. * covarianceScaler; + (*bigNewCovarianceMatrix)(1,1) = 250. * covarianceScaler; + (*bigNewCovarianceMatrix)(2,2) = 0.25; + (*bigNewCovarianceMatrix)(3,3) = 0.25; + (*bigNewCovarianceMatrix)(4,4) = 0.001 * 0.001; + + AmgVector(5) par = trackParameters->parameters(); + trackParametersWithError = trackParameters->associatedSurface().createTrackParameters(par[Trk::loc1],par[Trk::loc2],par[Trk::phi],par[Trk::theta],par[Trk::qOverP], bigNewCovarianceMatrix ); + Trk::ComponentParameters componentParametersWithError( trackParametersWithError, weight ); + stateWithInsertedErrors->push_back( componentParametersWithError ); + + } + + else + stateWithInsertedErrors->push_back( *component ); + + } - Trk::MultiComponentState* stateWithInsertedErrors = rebuildState( stateBeforeUpdate ); - // Perform the measurement update with the modified state updatedState = calculateFilterStep(*stateWithInsertedErrors, measurement, fitQoS); delete stateWithInsertedErrors; if ( !updatedState ) { - ATH_MSG_DEBUG( "Updated state could not be calculated... Returning 0"); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Updated state could not be calculated... Returning 0" << endmsg; fitQoS.reset(); return 0; } @@ -344,7 +468,8 @@ Trk::GsfMeasurementUpdator::update (const Trk::MultiComponentState& stateBeforeU updatedState = calculateFilterStep(stateBeforeUpdate, measurement, fitQoS); if ( !updatedState ) { - ATH_MSG_DEBUG( "Updated state could not be calculated... Returning 0"); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Updated state could not be calculated... Returning 0" << endmsg; fitQoS.reset(); return 0; } @@ -360,7 +485,8 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& std::unique_ptr<FitQualityOnSurface>& fitQoS) const { - ATH_MSG_VERBOSE( "Calculate Filter Step"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Calculate Filter Step" << endmsg; // Start the timer //Chrono chrono( &(*m_chronoSvc), "GsfMeasurementUpdate" ); @@ -369,12 +495,13 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& bool isAssemblerReset = m_stateAssembler->reset(); if ( !isAssemblerReset ){ - ATH_MSG_ERROR("Could not reset the state assembler... returning 0"); + if (m_outputlevel <= 0) + msg(MSG::ERROR) << "Could not reset the state assembler... returning 0" << endmsg; return 0; } if ( stateBeforeUpdate.empty() ){ - ATH_MSG_WARNING( "Cannot update multi-state with no components!"); + msg(MSG::WARNING) << "Cannot update multi-state with no components!" << endmsg; return 0; } @@ -384,11 +511,13 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& stateWithNewWeights = m_posteriorWeightsCalculator->weights(stateBeforeUpdate, measurement); if ( !stateWithNewWeights ) { - ATH_MSG_DEBUG( "Cacluation of state posterior weights failed... Exiting!"); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Cacluation of state posterior weights failed... Exiting!" << endmsg; return 0; } else - ATH_MSG_VERBOSE( "Calculation of state posterior weights successful"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Calculation of state posterior weights successful" << endmsg; // Update each component using the specified updator Trk::MultiComponentState::const_iterator component = stateWithNewWeights->begin(); @@ -401,11 +530,12 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& const Trk::TrackParameters* updatedTrackParameters = 0; - ATH_MSG_VERBOSE( "Performing update of predicted component state with measurement..."); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Performing update of predicted component state with measurement..." << endmsg; if (fabs((*component).first->parameters()[Trk::qOverP])>0.033333) { //GC: protection against low momentum tracks getting lost - // cutoff is 30MeV - ATH_MSG_DEBUG( "About to update component with p<30MeV...skipping component! (2)"); + if (m_outputlevel<=0) // cutoff is 30MeV + msg(MSG::DEBUG) << "About to update component with p<50MeV...skipping component! (2)"<<endmsg; continue; } @@ -415,28 +545,21 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& updatedTrackParameters = m_updator->addToState( *(*component).first, measurement.localParameters(), measurement.localCovariance(), componentFitQuality ); if ( !updatedTrackParameters ) { - ATH_MSG_DEBUG( "Update of state with Measurement has failed 2... Exiting!"); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Update of state with Measurement has failed 2... Exiting!" << endmsg; if ( componentFitQuality ) delete componentFitQuality; continue; } - - if( invalidComponent(updatedTrackParameters) ){ - ATH_MSG_DEBUG( "Invalid cov matrix after update... Exiting!"); - ATH_MSG_VERBOSE("Original TP \n" << *(*component).first ); - if((*component).first->covariance()) - ATH_MSG_VERBOSE("Original has a COV\n " << *(*component).first->covariance() ); - ATH_MSG_VERBOSE("Measurement \n" << measurement ); - ATH_MSG_VERBOSE("Result \n" << *updatedTrackParameters ); - if(updatedTrackParameters->covariance()) - ATH_MSG_VERBOSE("Result has a COV\n" << *updatedTrackParameters->covariance() ); - - delete updatedTrackParameters; - delete componentFitQuality; - continue; - } + + //std::cout << " A \n " << *updatedTrackParameters <<std::endl; + //std::cout << " B \n" << *updatedTrackParameters2 <<std::endl; + //delete updatedTrackParameters2; + //delete fitQuality2; + if ( !componentFitQuality || componentFitQuality->chiSquared() <= 0. ){ - ATH_MSG_DEBUG( "Fit quality of update failed... Exiting!"); + if (m_outputlevel <= 0) + msg(MSG::DEBUG) << "Fit quality of update failed... Exiting!" << endmsg; delete updatedTrackParameters; delete componentFitQuality; continue; @@ -453,7 +576,8 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& // Clean up memory delete componentFitQuality; - ATH_MSG_VERBOSE( "Successful measurement update with Measurement"); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Successful measurement update with Measurement" << endmsg; // Updator does not change the weighting Trk::ComponentParameters updatedComponentParameters(updatedTrackParameters, component->second); @@ -462,7 +586,8 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& bool componentAdded = m_stateAssembler->addComponent(updatedComponentParameters); if ( !componentAdded ) - ATH_MSG_DEBUG( "Component could not be added to the state in the assembler"); + if (m_outputlevel <= 0) + msg(MSG::WARNING) << "Component could not be added to the state in the assembler" << endmsg; delete updatedTrackParameters; @@ -488,69 +613,10 @@ Trk::GsfMeasurementUpdator::calculateFilterStep( const Trk::MultiComponentState& delete assembledUpdatedState; - ATH_MSG_VERBOSE( "Successful calculation of filter step: " << renormalisedUpdatedState->size()); + if (m_outputlevel < 0) + msg(MSG::VERBOSE) << "Successful calculation of filter step: " << renormalisedUpdatedState->size() << endmsg; return renormalisedUpdatedState; } -bool Trk::GsfMeasurementUpdator::invalidComponent(const Trk::TrackParameters* trackParameters ) const -{ - auto measuredCov = trackParameters->covariance(); - bool rebuildCov = false; - if (!measuredCov){ - rebuildCov = true; - } else { - for (int i(0); i<5; ++i){ - if( (*measuredCov)(i,i) <= 0.) - rebuildCov = true; - } - } - - return rebuildCov; -} - -Trk::MultiComponentState* Trk::GsfMeasurementUpdator::rebuildState(const Trk::MultiComponentState& stateBeforeUpdate) const -{ - Trk::MultiComponentState* stateWithInsertedErrors = new Trk::MultiComponentState(); - const Trk::TrackParameters* trackParametersWithError = 0; - - auto component = stateBeforeUpdate.begin(); - - for ( ; component != stateBeforeUpdate.end(); ++component ){ - - auto trackParameters = component->first; - auto weight = component->second; - - bool rebuildCov = invalidComponent(trackParameters); - - if ( rebuildCov ){ - - if (m_outputlevel <= 0) - ATH_MSG_DEBUG( "No measurement associated with track parameters, creating a big one"); - AmgSymMatrix(5)* bigNewCovarianceMatrix = new AmgSymMatrix(5); - bigNewCovarianceMatrix->setZero(); - double covarianceScaler = 1.; - (*bigNewCovarianceMatrix)(0,0) = 250. * covarianceScaler; - (*bigNewCovarianceMatrix)(1,1) = 250. * covarianceScaler; - (*bigNewCovarianceMatrix)(2,2) = 0.25; - (*bigNewCovarianceMatrix)(3,3) = 0.25; - (*bigNewCovarianceMatrix)(4,4) = 0.001 * 0.001; - - AmgVector(5) par = trackParameters->parameters(); - trackParametersWithError = trackParameters->associatedSurface().createTrackParameters(par[Trk::loc1],par[Trk::loc2],par[Trk::phi],par[Trk::theta],par[Trk::qOverP], bigNewCovarianceMatrix ); - Trk::ComponentParameters componentParametersWithError( trackParametersWithError, weight ); - stateWithInsertedErrors->push_back( componentParametersWithError ); - - } - - else - stateWithInsertedErrors->push_back( *component ); - - } - - return stateWithInsertedErrors; -} - - - diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfSmoother.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfSmoother.cxx index e0985d5ecc608afcf10a8760863e2d25c6a87199..2170bdc36bd75e983868dcf2bb0f882b2b5d7284 100755 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfSmoother.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfSmoother.cxx @@ -49,17 +49,17 @@ StatusCode Trk::GsfSmoother::initialize() // Retrieve an instance of the component merger if ( m_merger.retrieve().isFailure() ){ - ATH_MSG_FATAL("Could not retrieve the component merger tool... Exiting!"); + msg(MSG::FATAL) << "Could not retrieve the component merger tool... Exiting!" << endmsg; return StatusCode::FAILURE; } // Request an instance of the state combiner if ( m_combiner.retrieve().isFailure() ){ - ATH_MSG_FATAL("Could not retrieve an instance of the multi component state combiner... Exiting!"); + msg(MSG::FATAL) << "Could not retrieve an instance of the multi component state combiner... Exiting!" << endmsg; return StatusCode::FAILURE; } - ATH_MSG_INFO("Initialisation of " << name() << " was successful"); + msg(MSG::INFO) << "Initialisation of " << name() << " was successful" << endmsg; return StatusCode::SUCCESS; @@ -68,7 +68,7 @@ StatusCode Trk::GsfSmoother::initialize() StatusCode Trk::GsfSmoother::finalize() { - ATH_MSG_INFO("Finalisation of " << name() << " was successful"); + msg(MSG::INFO) << "Finalisation of " << name() << " was successful" << endmsg; return StatusCode::SUCCESS; @@ -80,7 +80,7 @@ StatusCode Trk::GsfSmoother::configureTools(const ToolHandle<IMultiStateExtrapol m_extrapolator = extrapolator; m_updator = measurementUpdator; - ATH_MSG_INFO("Configuration of " << name() << " was successful"); + msg(MSG::INFO) << "Configuration of " << name() << " was successful" << endmsg; return StatusCode::SUCCESS; @@ -91,32 +91,33 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward const Trk::CaloCluster_OnTrack * ccot ) const { - ATH_MSG_VERBOSE("This is the GSF Smoother!"); + if (m_outputlevel<0) + msg(MSG::VERBOSE) << "This is the GSF Smoother!" << endmsg; // Check that extrapolator and updator are instansiated if (!m_updator) { - ATH_MSG_ERROR("The measurement updator is not configured... Exiting!"); + msg(MSG::ERROR) << "The measurement updator is not configured... Exiting!" << endmsg; return 0; } if (!m_extrapolator) { - ATH_MSG_ERROR("The extrapolator is not configured... Exiting!"); + msg(MSG::ERROR) << "The extrapolator is not configured... Exiting!" << endmsg; return 0; } // Check that the forward trajectory is filled if ( forwardTrajectory.empty() ){ - ATH_MSG_ERROR("Attempting to smooth an empty forward trajectory... Exiting!"); + msg(MSG::ERROR) << "Attempting to smooth an empty forward trajectory... Exiting!" << endmsg; return 0; } if (m_outputlevel<0){ if ( particleHypothesis == Trk::nonInteracting ) - ATH_MSG_VERBOSE("Material effects are switched off in the Gsf Smoother"); + msg(MSG::VERBOSE) << "Material effects are switched off in the Gsf Smoother" << endmsg; else - ATH_MSG_VERBOSE("Material effects are switched on in the Gsf Smoother (type): " << particleHypothesis); + msg(MSG::VERBOSE) << "Material effects are switched on in the Gsf Smoother (type): " << particleHypothesis << endmsg; } @@ -139,7 +140,7 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward const Trk::MultiComponentStateOnSurface* smootherPredictionMultiStateOnSurface = dynamic_cast<const Trk::MultiComponentStateOnSurface*>(smootherPredictionStateOnSurface); if (!smootherPredictionMultiStateOnSurface) { - ATH_MSG_DEBUG("GSF smoother has a single component state as starting point"); + msg(MSG::DEBUG) << "GSF smoother has a single component state as starting point" << endmsg; // Build new multi-component state Trk::ComponentParameters smootherPredictionComponent(smootherPredictionStateOnSurface->trackParameters(), 1.); @@ -159,7 +160,7 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward const Trk::MeasurementBase* firstSmootherMeasurementOnTrack = smootherPredictionStateOnSurface->measurementOnTrack()->clone(); if ( !firstSmootherMeasurementOnTrack ){ - ATH_MSG_WARNING("Initial state on surface in smoother does not have an associated MeasurementBase object... returning 0"); + msg(MSG::WARNING) << "Initial state on surface in smoother does not have an associated MeasurementBase object... returning 0" << endmsg; return 0; } @@ -172,7 +173,8 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward if (!smootherPredictionMultiStateOnSurface) delete smootherPredictionMultiState; - ATH_MSG_DEBUG("First GSF smoothing update failed... Exiting!"); + if (m_outputlevel<=0) + msg(MSG::DEBUG) << "First GSF smoothing update failed... Exiting!" << endmsg; return 0; } @@ -207,7 +209,7 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward // ============================================================================================================================= if ( !firstSmoothedState->isMeasured() ){ - ATH_MSG_WARNING("Updated state is not measured. Rejecting smoothed state... returning 0"); + msg(MSG::WARNING) << "Updated state is not measured. Rejecting smoothed state... returning 0" << endmsg; return 0; } @@ -218,7 +220,7 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward std::unique_ptr<const Trk::MultiComponentState> (firstSmoothedState->cloneWithScaledError( 15., 5., 15., 5., 15. )); if ( !smoothedStateWithScaledError ){ - ATH_MSG_WARNING("Covariance scaling could not be performed... returning 0"); + msg(MSG::WARNING) << "Covariance scaling could not be performed... returning 0" << endmsg; return 0; } @@ -227,7 +229,7 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward std::unique_ptr<const Trk::MultiComponentState> (m_updator->update(*smoothedStateWithScaledError, *firstSmootherMeasurementOnTrack)); if ( !updatedState ){ - ATH_MSG_WARNING("Smoother prediction could not be determined... returning 0"); + msg(MSG::WARNING) << "Smoother prediction could not be determined... returning 0" << endmsg; return 0; } @@ -251,7 +253,7 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward const Trk::MeasurementBase* measurement_in = (*trackStateOnSurface)->measurementOnTrack(); if ( !measurement_in ){ - ATH_MSG_WARNING("MeasurementBase object could not be extracted from a measurement... continuing"); + msg(MSG::WARNING) << "MeasurementBase object could not be extracted from a measurement... continuing" << endmsg; continue; } @@ -308,11 +310,11 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward varQoverP = (*measuredCov)(Trk::qOverP,Trk::qOverP); } - ATH_MSG_DEBUG("Finishing extrapolation parameters:\t" + msg(MSG::DEBUG) << "Finishing extrapolation parameters:\t" << combinedState->parameters()[Trk::phi] << "\t" << combinedState->parameters()[Trk::theta] << "\t" << combinedState->parameters()[Trk::qOverP] << "\t" - << varQoverP); + << varQoverP << endmsg; } // Original measurement was flagged as an outlier @@ -334,7 +336,7 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward updatedState = std::unique_ptr<const Trk::MultiComponentState> (m_updator->update( *extrapolatedState, *measurement, fitQuality ) ); if (!updatedState) { - ATH_MSG_WARNING("Could not update the multi-component state... rejecting track!"); + msg(MSG::WARNING) << "Could not update the multi-component state... rejecting track!" << endmsg; return 0; } @@ -351,12 +353,12 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward varQoverP = (*measuredCov)(Trk::qOverP,Trk::qOverP); } - ATH_MSG_DEBUG("Update finished parameters:\t\t" + msg(MSG::DEBUG) << "Update finished parameters:\t\t" << combinedState->parameters()[Trk::phi] << "\t" << combinedState->parameters()[Trk::theta] << "\t" << combinedState->parameters()[Trk::qOverP] << "\t" - << varQoverP); - ATH_MSG_DEBUG("-----------------------------------------------------------------------------"); + << varQoverP << endmsg; + msg(MSG::DEBUG) << "-----------------------------------------------------------------------------" << endmsg; } /* ============================================================= @@ -388,7 +390,7 @@ Trk::SmoothedTrajectory* Trk::GsfSmoother::fit (const ForwardTrajectory& forward // delete forwardsMultiState; if (!combinedState2) { - ATH_MSG_WARNING("Could not combine state from forward fit with smoother state... rejecting track!"); + msg(MSG::WARNING) << "Could not combine state from forward fit with smoother state... rejecting track!" << endmsg; // delete updatedState; // delete measurement; // delete smoothedTrajectory; @@ -465,7 +467,7 @@ const Trk::MultiComponentState* Trk::GsfSmoother::combine (const Trk::MultiCompo const AmgSymMatrix(5)* forwardMeasuredCov = forwardsComponent->first->covariance(); if ( !forwardMeasuredCov ) - ATH_MSG_DEBUG("No measurement associated with forwards component... continuing for now"); + msg(MSG::DEBUG) << "No measurement associated with forwards component... continuing for now" << endmsg; /* ==================================================== Loop over all components in the smoother multi-state @@ -479,13 +481,13 @@ const Trk::MultiComponentState* Trk::GsfSmoother::combine (const Trk::MultiCompo const AmgSymMatrix(5)* smootherMeasuredCov = smootherComponent->first->covariance(); if ( !smootherMeasuredCov && !forwardMeasuredCov ){ - ATH_MSG_WARNING("Cannot combine two components both without associated errors... returning 0"); + msg(MSG::WARNING) << "Cannot combine two components both without associated errors... returning 0" << endmsg; return 0; } if ( !forwardMeasuredCov ){ if (m_outputlevel<=0) - ATH_MSG_DEBUG("Forwards state without error matrix... using smoother state only"); + msg(MSG::DEBUG) << "Forwards state without error matrix... using smoother state only" << endmsg; Trk::ComponentParameters smootherComponentOnly( smootherComponent->first->clone(), smootherComponent->second ); combinedMultiState->push_back( smootherComponentOnly ); continue; @@ -493,7 +495,7 @@ const Trk::MultiComponentState* Trk::GsfSmoother::combine (const Trk::MultiCompo if ( !smootherMeasuredCov ){ if (m_outputlevel<=0) - ATH_MSG_DEBUG("Smoother state withour error matrix... using forwards state only"); + msg(MSG::DEBUG) << "Smoother state withour error matrix... using forwards state only" << endmsg; Trk::ComponentParameters forwardComponentOnly( forwardsComponent->first->clone(), forwardsComponent->second ); combinedMultiState->push_back( forwardComponentOnly ); continue; @@ -504,7 +506,7 @@ const Trk::MultiComponentState* Trk::GsfSmoother::combine (const Trk::MultiCompo const AmgSymMatrix(5) K = *forwardMeasuredCov * summedCovariance.inverse(); //if (matrixInversionError) { - // ATH_MSG_WARNING("Matrix inversion failed... Exiting!"); + // msg(MSG::WARNING) << "Matrix inversion failed... Exiting!" << endmsg; // return 0; //} @@ -525,7 +527,7 @@ const Trk::MultiComponentState* Trk::GsfSmoother::combine (const Trk::MultiCompo const AmgSymMatrix(5) invertedSummedCovariance = summedCovariance.inverse(); //if ( matrixInversionError ){ - // ATH_MSG_WARNING("Matrix inversion failed... exiting"); + // msg(MSG::WARNING) << "Matrix inversion failed... exiting" << endmsg; // return 0; //} @@ -557,7 +559,7 @@ const Trk::MultiComponentState* Trk::GsfSmoother::combine (const Trk::MultiCompo delete mergedState; if (m_outputlevel<0) - ATH_MSG_VERBOSE("Size of combined state from smoother: " << renormalisedMergedState->size()); + msg(MSG::VERBOSE) << "Size of combined state from smoother: " << renormalisedMergedState->size() << endmsg; return renormalisedMergedState; diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/MultiComponentStateCombiner.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/MultiComponentStateCombiner.cxx index 8687b37ef7c3e70f21d306366f1573ff8e39153d..b705ca5dd83b63aabf0664918c1cab0edb717300 100755 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/MultiComponentStateCombiner.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/MultiComponentStateCombiner.cxx @@ -46,7 +46,7 @@ StatusCode Trk::MultiComponentStateCombiner::initialize() // Request the mode calculator if ( m_modeCalculator.retrieve().isFailure() ){ - ATH_MSG_FATAL( "Unable to retrieve the mode calculator... Exiting!" ); + msg(MSG::FATAL) << "Unable to retrieve the mode calculator... Exiting!" << endmsg; return StatusCode::FAILURE; } @@ -62,7 +62,7 @@ StatusCode Trk::MultiComponentStateCombiner::initialize() m_fractionPDFused = 1; } - if (msgLvl(MSG::VERBOSE)) ATH_MSG_VERBOSE( "Initialisation of " << name() << " was successful" ); + if (msgLvl(MSG::VERBOSE)) msg() << "Initialisation of " << name() << " was successful" << endmsg; return StatusCode::SUCCESS; @@ -71,11 +71,11 @@ StatusCode Trk::MultiComponentStateCombiner::initialize() StatusCode Trk::MultiComponentStateCombiner::finalize() { - ATH_MSG_INFO("-----------------------------------------------"); - ATH_MSG_INFO(" GSF MCS Combiner Statistics "); - ATH_MSG_INFO("-----------------------------------------------"); - ATH_MSG_INFO("Number of Calls " << m_NumberOfCalls ); - ATH_MSG_INFO("Finalisation of " << name() << " was successful" ); + msg(MSG::INFO) << "-----------------------------------------------"<< endmsg; + msg(MSG::INFO) << " GSF MCS Combiner Statistics "<< endmsg; + msg(MSG::INFO) << "-----------------------------------------------"<< endmsg; + msg(MSG::INFO) << "Number of Calls " << m_NumberOfCalls << endmsg; + msg(MSG::INFO) << "Finalisation of " << name() << " was successful" << endmsg; return StatusCode::SUCCESS; @@ -102,7 +102,7 @@ const Trk::ComponentParameters* Trk::MultiComponentStateCombiner::compute( const { ++m_NumberOfCalls; if ( uncombinedState->empty() ){ - ATH_MSG_WARNING( "Trying to collapse state with zero components" ); + msg(MSG::WARNING) << "Trying to collapse state with zero components" << endmsg; return 0; } @@ -226,7 +226,7 @@ const Trk::ComponentParameters* Trk::MultiComponentStateCombiner::compute( const modes = m_modeCalculator->calculateMode( *uncombinedState ); if ( msgLvl(MSG::VERBOSE) && modes[4] ) - ATH_MSG_VERBOSE( "Calculated mode q/p is: " << modes[4] ); + msg(MSG::VERBOSE) << "Calculated mode q/p is: " << modes[4] << endmsg; // Replace mean with mode if qOverP mode is not 0 if (modes[4] != 0){ @@ -293,7 +293,7 @@ const Trk::ComponentParameters* Trk::MultiComponentStateCombiner::compute( const } } else { - if (msgLvl(MSG::DEBUG)) ATH_MSG_DEBUG( " Dimension != 5 not updating q/p to mode q/p"); + if (msgLvl(MSG::DEBUG)) msg() << " Dimension != 5 not updating q/p to mode q/p"<< endmsg; }