29 const IInterface* p) :
48 declareProperty(
"TrackContainerName",
m_trackContainer =
"InDetTrackParticles");
63 declareProperty(
"SubVertexTrackIndices",
m_indices);
67 declareProperty(
"RefitPV" ,
m_refitPV =
false);
70 declareProperty(
"MaxPVrefit" ,
m_PV_max = 1000);
74 declareProperty(
"Do3d" ,
m_do3d =
false);
77 declareProperty(
"BMassUpper",
m_BMassUpper = std::numeric_limits<double>::max() );
78 declareProperty(
"BMassLower",
m_BMassLower = std::numeric_limits<double>::min() );
79 declareProperty(
"Chi2Cut",
m_chi2cut = std::numeric_limits<double>::max() );
89 return StatusCode::FAILURE;
96 if(
m_VKVFitter==
nullptr)
return StatusCode::FAILURE;
106 return StatusCode::SUCCESS;
112 ATH_CHECK(vtxContainer.
record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>()));
140 for(
size_t i =0; i<Ntracks; i++)
143 if(trackN >= v->nTrackParticles())
146 return StatusCode::FAILURE;
148 fitpair[i] = v->trackParticle(trackN);
154 for (
auto trkItr=importedTrackCollection->cbegin(); trkItr!=importedTrackCollection->cend(); ++trkItr) {
156 fitpair.back() =
nullptr;
162 std::abs((tp)->z0() + (tp)->vz() - v->z()) >
m_trkDeltaZ )
177 if(not evt.isValid())
ATH_MSG_ERROR(
"Cannot Retrieve " << evt.key() );
187 ATH_CHECK(refPvContainer.
record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>()));
189 if(vtxContainer->size() >0){
193 if(pvContainer->size()==0) {
204 std::vector<const xAOD::TrackParticleContainer*> trackCols;
207 trackCols.push_back(handle.cptr());
209 if(not trackCols.empty()){
213 }
catch(std::runtime_error
const& e){
215 return StatusCode::FAILURE;
219 return StatusCode::SUCCESS;
226 const std::vector<const xAOD::TrackParticle*> &inputTracks,
230 std::unique_ptr<xAOD::Vertex> ptr(
fit(ctx, inputTracks, importedTrackCollection,
nullptr));
233 double chi2DOF = ptr->chiSquared()/ptr->numberDoF();
236 if(!chi2CutPassed) {
ATH_MSG_DEBUG(
"Chi Cut failed!");
return; }
241 double bMass = bMomentum.M();
243 if(!passesCuts)
return;
247 std::vector<const xAOD::Vertex*> thePreceding;
248 thePreceding.push_back(v);
252 if (!closestRefPV.
get())
return;
253 std::unique_ptr<xAOD::Vertex> ptrPV(
fit(ctx, inputTracks, importedTrackCollection, closestRefPV.
get()));
256 double chi2DOFPV = ptrPV->chiSquared()/ptrPV->numberDoF();
259 if(!chi2CutPassed) {
ATH_MSG_DEBUG(
"Chi Cut failed!");
return; }
264 double bMass = bMomentumPV.M();
266 if(!passesCuts)
return;
270 vtxContainer->
push_back(ptrPV.release());
284 const std::vector<const xAOD::TrackParticle*> &inputTracks,
288 std::unique_ptr<Trk::IVKalState> state =
m_VKVFitter->makeState(ctx);
296 m_VKVFitter->setVertexForConstraint(pv->position().x(),
298 pv->position().z(), *state);
309 const Trk::Perigee& aPerigee1 = inputTracks[0]->perigeeParameters();
310 const Trk::Perigee& aPerigee2 = inputTracks[1]->perigeeParameters();
314 if (errorcode != 0) {startingPoint(0) = 0.0; startingPoint(1) = 0.0; startingPoint(2) = 0.0;}
315 std::unique_ptr<xAOD::Vertex> theResult =
m_VKVFitter->fit(inputTracks, startingPoint, *state);
319 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
320 for(
unsigned int i=0; i< theResult->trackParticleLinks().
size(); i++)
324 newLinkVector.push_back( mylink );
326 theResult->clearTracks();
327 theResult->setTrackParticleLinks( newLinkVector );
#define ATH_CHECK
Evaluate an expression and check for errors.
: B-physics xAOD helpers.
size_t size() const
Number of registered mappings.
const xAOD::Vertex * get() const
static void RelinkVertexTracks(std::span< const xAOD::TrackParticleContainer *const > trkcols, xAOD::Vertex *vtx)
static Analysis::CleanUpVertex ClosestRefPV(xAOD::BPhysHelper &, const xAOD::VertexContainer *, const Analysis::PrimaryVertexRefitter *)
static bool isContainedIn(const xAOD::TrackParticle *, std::span< const xAOD::TrackParticle *const >) noexcept
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Trk::TrkVKalVrtFitter * m_VKVFitter
PublicToolHandle< Analysis::PrimaryVertexRefitter > m_pvRefitter
SG::ReadHandleKey< xAOD::VertexContainer > m_defaultPVContainerName
std::vector< int > m_indices
virtual StatusCode initialize() override
ToolHandle< InDet::VertexPointEstimator > m_vertexEstimator
std::vector< std::string > m_hypoNames
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
PublicToolHandle< Trk::V0Tools > m_v0Tools
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackContainer
ReVertex(const std::string &t, const std::string &n, const IInterface *p)
void fitAndStore(const EventContext &ctx, xAOD::VertexContainer *vtxContainer, const xAOD::Vertex *v, const xAOD::VertexContainer *InVtxContainer, const std::vector< const xAOD::TrackParticle * > &inputTracks, const xAOD::TrackParticleContainer *importedTrackCollection, const xAOD::VertexContainer *pvContainer) const
ToolHandle< Trk::IVertexFitter > m_iVertexFitter
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_CollectionsToCheck
bool m_useAdditionalTrack
bool m_vertexFittingWithPV
std::vector< double > m_trkMasses
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_RelinkContainers
std::unique_ptr< xAOD::Vertex > fit(const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &inputTracks, const xAOD::TrackParticleContainer *importedTrackCollection, const xAOD::Vertex *pv) const
SG::WriteHandleKey< xAOD::VertexContainer > m_refPVContainerName
std::vector< int > m_TrackIndices
SG::WriteHandleKey< xAOD::VertexContainer > m_OutputContainerName
SG::ReadHandleKey< xAOD::VertexContainer > m_pvContainerName
SG::ReadHandleKey< xAOD::VertexContainer > m_inputContainerName
virtual StatusCode addBranches(const EventContext &ctx) const override
ElementLink implementation for ROOT usage.
bool setStorableObject(BaseConstReference data, bool replace=false)
Set link storable to data object pointed by data (slower).
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
bool setPrecedingVertices(const std::vector< const xAOD::Vertex * > &vertices, const xAOD::VertexContainer *vertexContainer)
Sets links to preceding vertices.
bool setRefTrks(std::vector< float > px, std::vector< float > py, std::vector< float > pz)
Sets refitted track momenta.
TVector3 totalP()
: Returns total 3-momentum calculated from the refitted tracks
bool pass() const
get the pass flag for this hypothesis
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ z
global position (cartesian)
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".