Skip to content
Snippets Groups Projects

Prototype of new alignment configuration

Merged Florian Reiss requested to merge pyconf into master
Compare and Show latest version
12 files
+ 6968
776
Compare changes
  • Side-by-side
  • Inline
Files
12
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
// Gaudi
#include "GaudiKernel/ToolHandle.h"
#include "GaudiAlg/GaudiAlgorithm.h"
// track interfaces
#include "TrackInterfaces/ITrackKalmanFilter.h"
#include "TrackKernel/TrackFunctors.h"
// event
#include "Event/FitNode.h"
#include "Event/Track.h"
#include "Event/TrackFitResult.h"
#include <string>
class TrackDoubleHitPruner : public GaudiAlgorithm {
public:
// Constructors and destructor
TrackDoubleHitPruner( const std::string& name, ISvcLocator* pSvcLocator );
virtual ~TrackDoubleHitPruner();
StatusCode execute() override;
StatusCode initialize() override;
StatusCode finalize() override;
private:
std::string m_inputLocation;
ToolHandle<ITrackKalmanFilter> m_kalmanFilter;
};
DECLARE_COMPONENT( TrackDoubleHitPruner )
TrackDoubleHitPruner::TrackDoubleHitPruner( const std::string& name, ISvcLocator* pSvcLocator )
: GaudiAlgorithm( name, pSvcLocator ), m_kalmanFilter( "TrackKalmanFilter", this ) {
// constructor
declareProperty( "TrackLocation", m_inputLocation = LHCb::TrackLocation::Default );
}
TrackDoubleHitPruner::~TrackDoubleHitPruner() {
// destructor
}
StatusCode TrackDoubleHitPruner::initialize() {
StatusCode sc = GaudiAlgorithm::initialize();
sc = m_kalmanFilter.retrieve();
return sc;
}
StatusCode TrackDoubleHitPruner::finalize() {
m_kalmanFilter.release().ignore();
return GaudiAlgorithm::finalize();
}
bool sameOTMonoLayer( const LHCb::OTChannelID& rhs, const LHCb::OTChannelID& lhs ) {
return rhs.sequentialUniqueLayer() == lhs.sequentialUniqueLayer() && rhs.straw() / 32 == lhs.straw() / 32;
}
bool sameSTModule( const LHCb::STChannelID& rhs, const LHCb::STChannelID& lhs ) {
return rhs.station() == lhs.station() && rhs.layer() == lhs.layer() && rhs.detRegion() == lhs.detRegion() &&
rhs.sector() == lhs.sector();
}
bool sameVeloSensor( const LHCb::VeloChannelID& rhs, const LHCb::VeloChannelID& lhs ) {
return rhs.sensor() == lhs.sensor();
}
StatusCode TrackDoubleHitPruner::execute() {
// get them as a range .... hen const-cast:-)
LHCb::Track::Range tracks = get<LHCb::Track::Range>( m_inputLocation );
for ( const LHCb::Track* track : tracks ) {
// we assume that the nodes are sorted. we now check if there are
// neighbouring nodes in the same detector layer. this is rather
// detector specific.
if ( track->fitResult() ) {
const LHCb::FitNode* prevnode( 0 );
bool trackWasModified( false );
for ( const LHCb::FitNode* node : nodes( *track ) ) {
if ( node->type() == LHCb::FitNode::Type::HitOnTrack ) {
if ( prevnode ) {
LHCb::LHCbID idA = prevnode->measurement().lhcbID();
LHCb::LHCbID idB = node->measurement().lhcbID();
if ( idA.detectorType() == idB.detectorType() ) {
bool samelayer( false );
if ( idA.isVelo() )
samelayer = sameVeloSensor( idA.veloID(), idB.veloID() );
else if ( idA.isTT() || idA.isIT() )
samelayer = sameSTModule( idA.stID(), idB.stID() );
// if( idA.isOT() )
// samelayer = sameOTMonoLayer( idA.otID(), idB.otID()) ;
if ( samelayer ) {
if ( std::abs( node->residual() ) > std::abs( prevnode->residual() ) )
const_cast<LHCb::FitNode*>( node )->setType( LHCb::FitNode::Type::Outlier );
else
const_cast<LHCb::FitNode*>( prevnode )->setType( LHCb::FitNode::Type::Outlier );
trackWasModified = true;
}
}
}
prevnode = node;
} else {
prevnode = 0;
}
}
counter( "Fraction of modified tracks" ) += trackWasModified;
if ( trackWasModified ) {
LHCb::Track* nctrack = const_cast<LHCb::Track*>( track );
StatusCode sc = m_kalmanFilter->fit( *nctrack );
if ( sc.isFailure() ) nctrack->setFitStatus( LHCb::Track::FitStatus::FitFailed );
}
}
}
return StatusCode::SUCCESS;
}
Loading