22 const std::string&
t,
const std::string &
name,
const IInterface*
p
24 m_countNumberOfFits (0),
25 m_countNumberOfFitsFailed (0),
26 m_countNumberOfFitsInvalid(0)
28 declareInterface<Prompt::IVertexFittingTool>(
this);
36 if(m_doSeedVertexFit) {
40 m_distToPriVtx = std::make_unique<SG::AuxElement::Decorator<float> > (m_distToPriVtxName);
41 m_normDistToPriVtx = std::make_unique<SG::AuxElement::Decorator<float> > (m_normDistToPriVtxName);
42 m_distToRefittedPriVtx = std::make_unique<SG::AuxElement::Decorator<float> > (m_distToRefittedPriVtxName);
43 m_normDistToRefittedPriVtx = std::make_unique<SG::AuxElement::Decorator<float> > (m_normDistToRefittedPriVtxName);
44 m_distToRefittedRmLepPriVtx = std::make_unique<SG::AuxElement::Decorator<float> > (m_distToRefittedRmLepPriVtxName);
45 m_normDistToRefittedRmLepPriVtx = std::make_unique<SG::AuxElement::Decorator<float> > (m_normDistToRefittedRmLepPriVtxName);
49 ATH_MSG_DEBUG(
"VertexFittingSvc::initialize - doSeedVertexFit = " << m_doSeedVertexFit);
50 ATH_MSG_DEBUG(
"VertexFittingSvc::initialize - vertexFitter = " << m_vertexFitter.name());
52 return StatusCode::SUCCESS;
63 ATH_MSG_INFO(
"VertexFittingSvc::finalize - number of total fits: " << m_countNumberOfFits);
64 ATH_MSG_INFO(
"VertexFittingSvc::finalize - number of failed fits: " << m_countNumberOfFitsFailed);
65 ATH_MSG_INFO(
"VertexFittingSvc::finalize - number of invalid vtxs: " << m_countNumberOfFitsInvalid);
68 return StatusCode::SUCCESS;
74 const std::vector<const xAOD::TrackParticle* > &tracks,
82 m_countNumberOfFits++;
90 std::unique_ptr<xAOD::Vertex> secondaryVtx = getSecondaryVertexWithSeed(
91 tracks,
input.inDetTracks,
input.priVtx->position()
95 m_countNumberOfFitsFailed++;
100 if(!isValidVertex(secondaryVtx.get())) {
101 m_countNumberOfFitsInvalid++;
103 ATH_MSG_WARNING(
"fitVertexWithPrimarySeed -- failed to get valid vertex");
107 m_secondaryVertexIndex++;
113 indexAcc(*secondaryVtx) = m_secondaryVertexIndex;
114 typeAcc(*secondaryVtx) =
static_cast<int>(vtxType);
116 decorateNewSecondaryVertex(
input, secondaryVtx.get());
124 const std::vector<const xAOD::TrackParticle* > &tracks,
133 m_countNumberOfFits++;
135 std::unique_ptr<xAOD::Vertex> secondaryVtx = getSecondaryVertexWithSeed(
136 tracks,
input.inDetTracks, seed
140 m_countNumberOfFitsFailed++;
146 if(!isValidVertex(secondaryVtx.get())) {
147 m_countNumberOfFitsInvalid++;
153 m_secondaryVertexIndex++;
159 indexAcc(*secondaryVtx) = m_secondaryVertexIndex;
160 typeAcc(*secondaryVtx) =
static_cast<int>(vtxType);
162 decorateNewSecondaryVertex(
input, secondaryVtx.get());
173 bool bad_vtx =
false;
176 ATH_MSG_WARNING(
"VertexFittingSvc::Validate_Vertex -- invalid vtx pointer!!!");
182 ATH_MSG_WARNING(
"VertexFittingSvc::Validate_Vertex -- empty vtx covariance!!!");
185 float chisquared = -9999;
187 if(!
getVar(vtx, chisquared,
"chiSquared")) {
189 ATH_MSG_WARNING(
"VertexFittingSvc::Validate_Vertex -- not valid vtx chiSquared!!!");
192 float numberdof = -9999;
194 if(!
getVar(vtx, numberdof,
"numberDoF")) {
196 ATH_MSG_WARNING(
"VertexFittingSvc::Validate_Vertex -- not valid vtx numberDoF!!!");
199 if(std::isnan(vtx->
x()) || std::isnan(vtx->
y()) || std::isnan(vtx->
z())) {
201 ATH_MSG_WARNING(
"VertexFittingSvc::Validate_Vertex -- vertex coordinate is nan");
215 const unsigned nbefore = tracks.size();
217 sort(tracks.begin(), tracks.end());
221 tracks.erase(TransfEnd, tracks.end());
223 if(nbefore != tracks.size()) {
224 ATH_MSG_DEBUG(
"removeDoubleEntries nbefore != tracks.size()): " << nbefore <<
" != " << tracks.size());
245 float distToPriVtx = -1;
246 float normDistToPriVtx = -1;
247 float distToRefittedPriVtx = -1;
248 float normDistToRefittedPriVtx = -1;
249 float distToRefittedRmLepPriVtx = -1;
250 float normDistToRefittedRmLepPriVtx = -1;
257 if(
input.refittedPriVtx) {
262 if(
input.refittedPriVtxWithoutLep) {
267 (*m_distToPriVtx) (*secVtx) = distToPriVtx;
268 (*m_normDistToPriVtx) (*secVtx) = normDistToPriVtx;
269 (*m_distToRefittedPriVtx) (*secVtx) = distToRefittedPriVtx;
270 (*m_normDistToRefittedPriVtx) (*secVtx) = normDistToRefittedPriVtx;
271 (*m_distToRefittedRmLepPriVtx) (*secVtx) = distToRefittedRmLepPriVtx;
272 (*m_normDistToRefittedRmLepPriVtx)(*secVtx) = normDistToRefittedRmLepPriVtx;
279 const std::vector<const xAOD::TrackParticle*> &tracks,
287 std::vector<const xAOD::TrackParticle*> tracksForFit(tracks);
289 ATH_MSG_DEBUG(
"getSecondaryVertexWithSeed -- before remove " << tracksForFit.size());
291 removeDoubleEntries(tracksForFit);
293 ATH_MSG_DEBUG(
"getSecondaryVertexWithSeed -- after remove " << tracksForFit.size());
295 if(tracksForFit.size() < 2) {
296 ATH_MSG_WARNING(
"getSecondaryVertexWithSeed -- cannot fit vertex with one or zero input track: ntrack=" << tracksForFit.size());
303 ATH_MSG_DEBUG(
name() <<
"::getSecondaryVertexWithSeed -- N tracks = " << tracksForFit.size());
311 std::unique_ptr<xAOD::Vertex> seedVertex;
313 if(m_doSeedVertexFit) {
314 seedVertex = std::unique_ptr<xAOD::Vertex>(m_seedVertexFitter->fit(tracksForFit, seed));
316 if(seedVertex.get() && !isValidVertex(seedVertex.get())) {
317 ATH_MSG_DEBUG(
"getSecondaryVertexWithSeed -- failed to fit seed vertex");
323 if(seedVertex.get()) {
324 newVertex = m_vertexFitter->fit(tracksForFit, seedVertex->
position());
327 newVertex = m_vertexFitter->fit(tracksForFit, seed);
331 ATH_MSG_INFO(
"getSecondaryVertexWithSeed -- failed to fit vertex and fitter returned null xAOD::Vertex pointer");
338 std::vector<ElementLink< xAOD::TrackParticleContainer> > tpLinks;
348 tpLinks.push_back(tpLink);
354 TLorentzVector Momentum;
357 Momentum +=
static_cast<TLorentzVector
>(
track->p4());
367 std::unique_ptr<xAOD::Vertex> returnPtr(newVertex);