14#include "GaudiKernel/ConcurrencyFlags.h"
17#include "Math/Vector3D.h"
27 const std::string& name,
28 const IInterface* parent):
36 declareInterface< ITwoTrackVertexSelector >(
this);
57 std::unique_ptr<TFile> rootFile(TFile::Open(rootFilePath.c_str(),
"READ"));
60 return StatusCode::FAILURE;
62 std::unique_ptr<TTree> training((TTree*)rootFile->Get(
"BDT"));
63 m_SV2T_BDT = std::make_unique<MVAUtils::BDT>(training.get());
65 return StatusCode::SUCCESS;
73 return StatusCode::SUCCESS;
78 const std::pair<const xAOD::TrackParticle*,const xAOD::TrackParticle*> iTrks,
80 std::pair<ROOT::Math::XYZTVector,ROOT::Math::XYZTVector> moms,
84 return isgood(ctx, iTrks, candV, moms,tPV,quality);
88 const std::pair<const xAOD::TrackParticle*,const xAOD::TrackParticle*> iTrks,
90 std::pair<ROOT::Math::XYZTVector,ROOT::Math::XYZTVector> moms,
92 float & quality)
const
95 double Prob2v=TMath::Prob(candV.
chiSquared(),1);
98 auto sumMom=moms.first+moms.second;
104 ROOT::Math::XYZVector vSVPV(candV.
x()-tPV.
x(),candV.
y()-tPV.
y(),candV.
z()-tPV.
z());
105 double cosSVPV=vSVPV.Unit().Dot(sumMom.Vect().Unit());
114 if(
m_do2TrkIBLChecks && ( (ihitIBL==0&&jhitIBL>0) || (ihitIBL>0&&jhitIBL==0) ) )
return false;
115 int ihitBL =
getBLHit (iTrks.first);
116 int jhitBL =
getBLHit (iTrks.second);
119 if( ihitIBL<1 && ihitBL<1)
return false;
120 if( jhitIBL<1 && jhitBL<1)
return false;
122 float ihitR = iTrks.first->radiusOfFirstHit();
123 float jhitR = iTrks.second->radiusOfFirstHit();
124 if(std::abs(ihitR-jhitR)>50.)
return false;
125 if( vrtR-std::min(ihitR,jhitR) > 50.)
return false;
126 if(ihitR-vrtR > 180.+2.*vrtRErr)
return false;
127 if(jhitR-vrtR > 180.+2.*vrtRErr)
return false;
130 if(std::abs(ihitR-jhitR)>12.)
return false;
131 if( ihitR-vrtR > 36.)
return false;
132 if( jhitR-vrtR > 36.)
return false;
133 if( ihitR-vrtR <-2.*vrtRErr)
return false;
134 if( jhitR-vrtR <-2.*vrtRErr)
return false;
137 std::vector<double> impact,impactError;
138 m_fitSvc->VKalGetImpact( ctx, iTrks.first, tPV.
position(), 1, impact, impactError);
139 float trk1Signif = sqrt( impact[0]*impact[0]/impactError[0] + impact[1]*impact[1]/impactError[2]);
140 m_fitSvc->VKalGetImpact( ctx, iTrks.second, tPV.
position(), 1, impact, impactError);
141 float trk2Signif = sqrt( impact[0]*impact[0]/impactError[0] + impact[1]*impact[1]/impactError[2]);
142 float minPtT = std::min(iTrks.first->pt(),iTrks.second->pt());
143 std::vector<float> VARS(10);
145 VARS[1]=log(sumMom.Pt());
147 VARS[3]=log(vrtR<20. ? vSVPV.Rho() : vrtR);
148 VARS[4]=log(std::min(trk1Signif,trk2Signif));
149 VARS[5]=log(std::max(trk1Signif,trk2Signif));
151 VARS[7]=sqrt(std::abs(1.-cosSVPV*cosSVPV));
153 VARS[9]=std::max(ihitR,jhitR);
165 double DirX=SecVrt.x(), DirY=SecVrt.y();
166 double Covar = DirX*VrtErr[0]*DirX
167 +2.*DirX*VrtErr[1]*DirY
168 +DirY*VrtErr[2]*DirY;
169 Covar /= DirX*DirX + DirY*DirY;
170 Covar=std::sqrt(std::abs(Covar));
171 if(Covar != Covar) Covar = 0.;
178 uint8_t IBLhit,IBLexp;
180 if( IBLexp==0 )
return -1;
189 if( BLexp==0 )
return -1;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_FATAL(x,...)
Define macros for attributes used to control the static checker.
static std::string find_calib_file(const std::string &logical_file_name)
Gaudi::Property< bool > m_useVertexCleaning
Gaudi::Property< float > m_vrt2TrMassLimit
Gaudi::Property< float > m_maxSVRadiusCut
ToolHandle< Trk::TrkVKalVrtFitter > m_fitSvc
std::unique_ptr< MVAUtils::BDT > m_SV2T_BDT
virtual ~TwoTrackVrtBDTSelector()
virtual StatusCode initialize() override
static int getIBLHit(const xAOD::TrackParticle *Part)
virtual bool isgood(const EventContext &ctx, const std::pair< const xAOD::TrackParticle *, const xAOD::TrackParticle * > tracks, const xAOD::Vertex &candV, std::pair< ROOT::Math::XYZTVector, ROOT::Math::XYZTVector > moms, const xAOD::Vertex &tPV) const override final
virtual StatusCode finalize() override
Gaudi::Property< float > m_cosSVPVCut
Gaudi::Property< float > m_vrt2TrPtMin
Gaudi::Property< bool > m_do2TrkIBLChecks
Gaudi::Property< std::string > m_calibFileName
static int getBLHit(const xAOD::TrackParticle *Part)
Gaudi::Property< float > m_firstPixelLayerR
Gaudi::Property< float > m_sel2VrtProbCut
Gaudi::Property< float > m_vrt2TrPtMax
static double vrtRadiusError(const Amg::Vector3D &secVrt, const std::vector< float > &vrtErr)
std::string m_instanceName
TwoTrackVrtBDTSelector(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< float > m_v2tBDTCut
float z() const
Returns the z position.
float y() const
Returns the y position.
float chiSquared() const
Returns the of the vertex fit as float.
const Amg::Vector3D & position() const
Returns the 3-pos.
float x() const
Returns the x position.
const std::vector< float > & covariance() const
Returns the covariance matrix as a simple vector of values.
Eigen::Matrix< double, 3, 1 > Vector3D
namespace for combined reconstruction tools and interfaces
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
@ numberOfNextToInnermostPixelLayerHits
these are the hits in the 1st pixel barrel layer
@ expectNextToInnermostPixelLayerHit
Do we expect a 1st-layer barrel hit for this track?
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer