Commit 003ce795 authored by Rosen Matev's avatar Rosen Matev
Browse files

Merge branch 'Claire_FTParticleSelector' into 'master'

Algorithm that selects the particles used in the FlavourTagging

See merge request !1002
parents d76d8801 b6a25f50
Pipeline #3166638 passed with stage
in 27 seconds
......@@ -22,6 +22,7 @@ gaudi_add_header_only_library(FlavourTaggingLib
gaudi_add_module(FlavourTagging
SOURCES
src/GetFlavourTaggingParticles.cpp
src/BTagging.cpp
src/BTaggingTool.cpp
src/Classification/TaggingClassifierTMVA.cpp
......
/*****************************************************************************\
* (c) Copyright 2000-2021 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. *
\*****************************************************************************/
#include "GetFlavourTaggingParticles.h"
// Declaration of the Algorithm Factory
DECLARE_COMPONENT( GetFlavourTaggingParticles )
LHCb::Particle::Selection GetFlavourTaggingParticles::operator()( const LHCb::Particles& bCandidates,
const LHCb::Particle::Range& taggingParticles,
const LHCb::RecVertices& primaryVertices,
const DetectorElement& lhcbDetector ) const {
auto& geometry = *lhcbDetector.geometry();
LHCb::Particle::Selection selectedParticles;
for ( const auto& particle : taggingParticles ) {
const LHCb::VertexBase* bestParticlePV = m_relatedPVTool->relatedPV( particle, primaryVertices );
for ( const auto& bCand : bCandidates ) {
const LHCb::VertexBase* bestbCandPV = m_relatedPVTool->relatedPV( bCand, primaryVertices );
if ( bestbCandPV == bestParticlePV ) {
selectedParticles.insert( particle );
break;
}
auto minIpChi2 = calcMinIpChi2( *particle, primaryVertices, geometry );
if ( minIpChi2.has_value() ) {
if ( minIpChi2.value() > m_minIpChi2 ) {
selectedParticles.insert( particle );
break;
}
}
}
}
m_inCount += taggingParticles.size();
m_outCount += selectedParticles.size();
return selectedParticles;
}
std::optional<double> GetFlavourTaggingParticles::calcMinIpChi2( const LHCb::Particle& part,
const LHCb::RecVertices& vertices,
const IGeometryInfo& geometry ) const {
double minIpChi2 = std::numeric_limits<double>::max();
for ( auto const* vertex : vertices ) {
auto tempIpChi2 = calcIpChi2( part, *vertex, geometry );
if ( tempIpChi2.has_value() ) {
if ( tempIpChi2.value() < minIpChi2 ) { minIpChi2 = tempIpChi2.value(); }
}
}
if ( minIpChi2 < std::numeric_limits<double>::max() ) return minIpChi2;
return std::nullopt;
}
std::optional<double> GetFlavourTaggingParticles::calcIpChi2( const LHCb::Particle& part,
const LHCb::VertexBase& vertex,
const IGeometryInfo& geometry ) const {
double ip = -100.0;
double ipChi2 = 0;
StatusCode sc = m_distCalcTool->distance( &part, &vertex, ip, ipChi2, geometry );
if ( sc ) return ipChi2;
return std::nullopt;
}
\ No newline at end of file
/*****************************************************************************\
* (c) Copyright 2000-2021 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. *
\*****************************************************************************/
#pragma once
// from Gaudi
#include "GaudiAlg/Transformer.h"
// from LHCb
#include "DetDesc/DetectorElement.h"
#include "DetDesc/GenericConditionAccessorHolder.h"
#include "Event/Particle.h"
#include "Event/RecVertex.h"
#include "Kernel/IDistanceCalculator.h"
#include "Kernel/IRelatedPVFinder.h"
class GetFlavourTaggingParticles
: public Gaudi::Functional::Transformer<LHCb::Particle::Selection(
const LHCb::Particles&, const LHCb::Particle::Range&,
const LHCb::RecVertices&, const DetectorElement& ),
LHCb::DetDesc::usesConditions<DetectorElement>> {
public:
/// Standard constructor
GetFlavourTaggingParticles( const std::string& name, ISvcLocator* pSvcLocator )
: Transformer( name, pSvcLocator,
{KeyValue{"BCandidates", ""}, KeyValue{"TaggingParticles", ""}, KeyValue{"PrimaryVertices", ""},
KeyValue{"StandardGeometry", "/dd/Structure/LHCb"}},
KeyValue{"FlavourTaggingParticles", ""} ) {}
LHCb::Particle::Selection operator()( const LHCb::Particles& bCandidates,
const LHCb::Particle::Range& taggingParticles,
const LHCb::RecVertices& primaryVertices,
const DetectorElement& ) const override;
private:
Gaudi::Property<double> m_minIpChi2{this, "MinIpChi2", 6.,
"Tagging particle requirement: Minimum IPChi2 wrt to all PVs"};
std::optional<double> calcMinIpChi2( const LHCb::Particle& part, const LHCb::RecVertices& vertices,
const IGeometryInfo& geometry ) const;
std::optional<double> calcIpChi2( const LHCb::Particle& part, const LHCb::VertexBase& vertex,
const IGeometryInfo& geometry ) const;
ToolHandle<IRelatedPVFinder> m_relatedPVTool{
this, "RelatedPVFinderTool", "GenericParticle2PVRelator__p2PVWithIPChi2_OnlineDistanceCalculatorName_"};
ToolHandle<IDistanceCalculator> m_distCalcTool{this, "DistanceCalculatorTool", "LoKi::TrgDistanceCalculator"};
mutable Gaudi::Accumulators::SummingCounter<> m_inCount{this, "#InputParticles"};
mutable Gaudi::Accumulators::SummingCounter<> m_outCount{this, "#OutputParticles"};
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment