Skip to content
Snippets Groups Projects
Commit d44accd7 authored by Wouter Hulsbergen's avatar Wouter Hulsbergen
Browse files

use veloid derived from lhcbids for unbiasing

parent 8592bc6d
No related branches found
No related tags found
1 merge request!4299add PV pointer to particle, update v2 PV event model
......@@ -606,19 +606,18 @@ namespace LHCb {
}
/// routine to collect all velo-segment IDs from the decay chain of a particle.
boost::container::small_vector<int, 16> collectVeloSegmentIDs( const Particle& p,
const LHCb::Event::PV::PrimaryVertexContainer& PVs );
boost::container::small_vector<uint32_t, 16> collectVeloSegmentIDs( const Particle& p );
inline std::optional<Event::PV::PrimaryVertex> unbiasedBestPV( const LHCb::Event::PV::PrimaryVertexContainer& PVs,
const Particle& particle ) {
inline std::optional<PrimaryVertex> unbiasedBestPV( const LHCb::Event::PV::PrimaryVertexContainer& PVs,
const Particle& particle ) {
if ( PVs.empty() ) return {};
auto ids = collectVeloSegmentIDs( particle, PVs );
return LHCb::Event::PV::unbiasedVertex( PVs, bestPVIndex( PVs, particle ), ids );
auto ids = collectVeloSegmentIDs( particle );
return LHCb::Event::PV::unbiasedVertex( PVs, bestPVIndex( PVs, particle ), LHCb::span<const uint32_t>(ids) );
}
inline auto unbiasedPVs( const LHCb::Event::PV::PrimaryVertexContainer& PVs, const LHCb::Particle& particle ) {
auto ids = collectVeloSegmentIDs( particle, PVs );
return LHCb::Event::PV::unbiasedVertices( PVs, ids );
auto ids = collectVeloSegmentIDs( particle );
return LHCb::Event::PV::unbiasedVertices( PVs, LHCb::span<const uint32_t>(ids) );
}
} // namespace LHCb
......
......@@ -144,52 +144,25 @@ const GaudiUtils::VectorMap<std::string, LHCb::Particle::additionalInfo>& LHCb::
}
namespace {
template <typename TrackType>
const TrackType* findPrPixelAncestor( const TrackType& track ) {
if ( track.history() == TrackType::History::PrPixel )
return &track;
else {
for ( const auto& a : track.ancestors() ) {
const auto dau = findPrPixelAncestor( *a );
if ( dau ) return dau;
}
}
return nullptr;
}
template <typename IndexContainer, typename VeloTracks>
inline void collectVeloIndices( const LHCb::Particle& p, const VeloTracks& pvtracks, IndexContainer& veloindices ) {
// this can be very much simplified once every track has a velo index. then we also do not need the pvtracks
// argument anymore
template <typename IndexContainer>
inline void collectVeloIndices( const LHCb::Particle& p, IndexContainer& veloindices ) {
if ( p.isBasicParticle() ) {
const LHCb::ProtoParticle* proto = p.proto();
if ( proto ) {
const LHCb::Track* track = proto->track();
if ( track ) {
// for the future, just use here index stored in track.
std::vector<LHCb::LHCbID> veloIDs;
std::copy_if( track->lhcbIDs().begin(), track->lhcbIDs().end(), std::back_inserter( veloIDs ),
[]( const auto id ) { return id.isVP(); } );
// now find the track. this will take for ever.
for ( const auto& pv_velotrack : pvtracks ) {
auto vtrack = pv_velotrack.veloTrack();
if ( veloIDs == vtrack.lhcbIDs() ) {
veloindices.emplace_back( pv_velotrack.offset() );
break;
}
}
}
if ( track && track->lhcbIDs().size()>0) {
veloindices.emplace_back( LHCb::Event::PV::uniqueVeloSegmentID( track->lhcbIDs() ) ) ;
}
}
} else {
for ( const auto& dau : p.daughters() ) collectVeloIndices( *dau, pvtracks, veloindices );
for ( const auto& dau : p.daughters() ) collectVeloIndices( *dau, veloindices );
}
}
} // namespace
boost::container::small_vector<int, 16>
LHCb::collectVeloSegmentIDs( const LHCb::Particle& particle, const LHCb::Event::PV::PrimaryVertexContainer& PVs ) {
boost::container::small_vector<int, 16> veloindices;
collectVeloIndices( particle, PVs.tracks.scalar(), veloindices );
boost::container::small_vector<uint32_t,16>
LHCb::collectVeloSegmentIDs( const LHCb::Particle& particle ) {
boost::container::small_vector<uint32_t,16> veloindices;
collectVeloIndices( particle, veloindices );
return veloindices;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment