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;
225 const std::vector<const xAOD::TrackParticle*> &inputTracks,
229 std::unique_ptr<xAOD::Vertex> ptr(
fit(inputTracks, importedTrackCollection,
nullptr));
232 double chi2DOF = ptr->chiSquared()/ptr->numberDoF();
235 if(!chi2CutPassed) {
ATH_MSG_DEBUG(
"Chi Cut failed!");
return; }
240 double bMass = bMomentum.M();
242 if(!passesCuts)
return;
246 std::vector<const xAOD::Vertex*> thePreceding;
247 thePreceding.push_back(v);
251 if (!closestRefPV.
get())
return;
252 std::unique_ptr<xAOD::Vertex> ptrPV(
fit(inputTracks, importedTrackCollection, closestRefPV.
get()));
255 double chi2DOFPV = ptrPV->chiSquared()/ptrPV->numberDoF();
258 if(!chi2CutPassed) {
ATH_MSG_DEBUG(
"Chi Cut failed!");
return; }
263 double bMass = bMomentumPV.M();
265 if(!passesCuts)
return;
269 vtxContainer->
push_back(ptrPV.release());
286 std::unique_ptr<Trk::IVKalState> state =
m_VKVFitter->makeState();
294 m_VKVFitter->setVertexForConstraint(pv->position().x(),
296 pv->position().z(), *state);
307 const Trk::Perigee& aPerigee1 = inputTracks[0]->perigeeParameters();
308 const Trk::Perigee& aPerigee2 = inputTracks[1]->perigeeParameters();
312 if (errorcode != 0) {startingPoint(0) = 0.0; startingPoint(1) = 0.0; startingPoint(2) = 0.0;}
317 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
322 newLinkVector.push_back( mylink );
#define ATH_CHECK
Evaluate an expression and check for errors.
: B-physics xAOD helpers.
const xAOD::Vertex * get() const
static bool isContainedIn(const xAOD::TrackParticle *, const std::vector< const xAOD::TrackParticle * > &)
static Analysis::CleanUpVertex ClosestRefPV(xAOD::BPhysHelper &, const xAOD::VertexContainer *, const Analysis::PrimaryVertexRefitter *)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
static void RelinkVertexTracks(const std::vector< const xAOD::TrackParticleContainer * > &trkcols, xAOD::Vertex *vtx)
Trk::TrkVKalVrtFitter * m_VKVFitter
xAOD::Vertex * fit(const std::vector< const xAOD::TrackParticle * > &inputTracks, const xAOD::TrackParticleContainer *importedTrackCollection, const xAOD::Vertex *pv) const
SG::ReadHandleKey< xAOD::VertexContainer > m_defaultPVContainerName
std::vector< int > m_indices
virtual StatusCode initialize() override
void fitAndStore(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< InDet::VertexPointEstimator > m_vertexEstimator
std::vector< std::string > m_hypoNames
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackContainer
ReVertex(const std::string &t, const std::string &n, const IInterface *p)
ToolHandle< Trk::IVertexFitter > m_iVertexFitter
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_CollectionsToCheck
bool m_useAdditionalTrack
ToolHandle< Trk::V0Tools > m_v0Tools
bool m_vertexFittingWithPV
std::vector< double > m_trkMasses
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_RelinkContainers
SG::WriteHandleKey< xAOD::VertexContainer > m_refPVContainerName
ToolHandle< Analysis::PrimaryVertexRefitter > m_pvRefitter
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, IProxyDict *sg=0)
Set link to point to a new container (storable).
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
void setTrackParticleLinks(const TrackParticleLinks_t &trackParticles)
Set all track particle links at once.
void clearTracks()
Remove all tracks from the vertex.
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
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".