24 #include "HepPDT/ParticleDataTable.hh"
38 declareInterface<InDetV0FinderTool>(
this);
118 for (
const std::string
beam : {
"beamPosX",
"beamPosY",
"beamPosZ"}) {
157 ATH_MSG_FATAL(
"The vertex fitter passed is not a V0 Vertex Fitter");
158 return StatusCode::FAILURE;
166 return StatusCode::SUCCESS;
175 const EventContext& ctx
180 std::vector<const xAOD::TrackParticleContainer*> trackCols;
183 trackCols.push_back(handle.
cptr());
190 if ( !TPC.isValid() )
193 return StatusCode::SUCCESS;
195 ATH_MSG_DEBUG(
"Track particle container size " << TPC->size());
203 beamspot = beamSpotHandle->beamPos();
208 beamspot =
Amg::Vector3D(beamPosX(0), beamPosY(0), beamPosZ(0));
211 std::vector<const xAOD::TrackParticle*> posTracks; posTracks.clear();
212 std::vector<const xAOD::TrackParticle*> negTracks; negTracks.clear();
214 if (
m_pv && primaryVertex) vx = primaryVertex;
216 if (TPC->size() > 1) {
218 for ( tpIt=TPC->begin(); tpIt!=TPC->end(); ++tpIt )
226 posTracks.push_back(TP);
227 negTracks.push_back(TP);
230 posTracks.push_back(*tpIt);
232 negTracks.push_back(*tpIt);
238 ATH_MSG_DEBUG(
"number of tracks passing preselection, positive " << posTracks.size() <<
" negative " << negTracks.size());
240 if (!posTracks.empty() && !negTracks.empty())
243 if (!vertices.isValid())
246 return StatusCode::SUCCESS;
260 std::vector<const xAOD::TrackParticle*>::const_iterator tpIt1;
261 std::vector<const xAOD::TrackParticle*>::const_iterator tpIt2;
263 for (tpIt1 = posTracks.begin(); tpIt1 != posTracks.end(); ++tpIt1)
270 double pt1 = TP1->
pt();
275 for (
const auto *
const vx : *vertices)
285 if (foundVertex1)
break;
289 for (tpIt2 = negTracks.begin(); tpIt2 != negTracks.end(); ++tpIt2)
291 if (*tpIt1 == *tpIt2)
continue;
299 ATH_MSG_DEBUG(
"nclus1 " << (
int)nclus1 <<
" nclus2 " << (
int)nclus2);
304 double pt2 = TP2->
pt();
309 for (
const auto *
const vx : *vertices)
319 if (foundVertex2)
break;
322 bool usepair =
false;
324 if (
m_useorigin && foundVertex1 ==
nullptr && foundVertex2 ==
nullptr) usepair =
true;
325 if (!usepair)
continue;
327 bool trk_cut1 =
false;
328 bool trk_cut2 =
false;
329 if (nclus1 != 0) trk_cut1 =
true;
330 if (nclus1 == 0 && pt1 >=
m_ptTRT) trk_cut1 =
true;
331 if (!trk_cut1)
continue;
332 if (nclus2 != 0) trk_cut2 =
true;
333 if (nclus2 == 0 && pt2 >=
m_ptTRT) trk_cut2 =
true;
334 if (!trk_cut2)
continue;
342 if (errorcode != 0) {startingPoint(0) = 0.0; startingPoint(1) = 0.0; startingPoint(2) = 0.0;}
343 bool errorCode =
false;
344 if (errorcode == 0 || errorcode == 5 || errorcode == 6 || errorcode == 8) errorCode =
true;
345 if (!errorCode)
continue;
347 bool d0wrtVertex =
true;
349 if ( !
d0Pass(TP1,TP2,vertColl, ctx) ) d0wrtVertex =
false;
353 if ( !
d0Pass(TP1,TP2,primaryVertex, ctx) ) d0wrtVertex =
false;
355 if ( !
d0Pass(TP1,TP2,beamspot, ctx) ) d0wrtVertex =
false;
358 if (!d0wrtVertex)
continue;
362 if (
doFit(TP1,TP2,startingPoint, ctx) )
364 std::vector<const xAOD::TrackParticle*> pairV0;
366 pairV0.push_back(TP1);
367 pairV0.push_back(TP2);
372 std::unique_ptr<xAOD::Vertex> myVxCandidate;
376 myVxCandidate = std::unique_ptr<xAOD::Vertex>(
m_iVKVertexFitter->fit(pairV0, startingPoint) );
384 bool doKshortFit =
false;
385 doKshortFit =
doMassFit(myVxCandidate.get(),310);
386 bool doLambdaFit =
false;
387 doLambdaFit =
doMassFit(myVxCandidate.get(),3122);
388 bool doLambdabarFit =
false;
389 doLambdabarFit =
doMassFit(myVxCandidate.get(),-3122);
390 if (doKshortFit || doLambdaFit || doLambdabarFit)
392 bool pointAtVert =
true;
397 if ( !
pointAtVertex(myVxCandidate.get(),primaryVertex) ) pointAtVert =
false;
404 std::unique_ptr<xAOD::Vertex> myKshort;
405 std::unique_ptr<xAOD::Vertex> myLambda;
406 std::unique_ptr<xAOD::Vertex> myLambdabar;
407 std::unique_ptr<xAOD::Vertex> myGamma;
408 bool foundKshort =
false;
409 bool foundLambda =
false;
410 bool foundLambdabar =
false;
413 myKshort = std::unique_ptr<xAOD::Vertex>(
massFit(310, pairV0,
vertex) );
423 myLambda = std::unique_ptr<xAOD::Vertex>(
massFit(3122, pairV0,
vertex) );
433 myLambdabar = std::unique_ptr<xAOD::Vertex>(
massFit(-3122, pairV0,
vertex));
437 foundLambdabar =
true;
442 bool doGamma =
false;
444 double gamma_prob = -1., gamma_mass = -1., gamma_massErr = -1.;
445 if (foundKshort || foundLambda || foundLambdabar) doGamma =
true;
459 v0Container->
push_back(myVxCandidate.release());
468 ksContainer->
push_back(myKshort.release());
472 v0LinksDecorks(*(ksContainer->
back())) = v0Link;
476 v0_ksLinksDecor(*(v0Container->
back())) = ksLink;
478 v0_ksLinksDecor(*(v0Container->
back())) = ksLink;
487 laContainer->
push_back(myLambda.release());
491 v0LinksDecorlb(*(laContainer->
back())) = v0Link;
495 v0_laLinksDecor(*(v0Container->
back())) = laLink;
497 v0_laLinksDecor(*(v0Container->
back())) = laLink;
506 lbContainer->
push_back(myLambdabar.release());
510 v0LinksDecorlbb(*(lbContainer->
back())) = v0Link;
514 v0_lbLinksDecor(*(v0Container->
back())) = lbLink;
516 v0_lbLinksDecor(*(v0Container->
back())) = lbLink;
519 myGamma = std::unique_ptr<xAOD::Vertex>(
massFit(22, pairV0,
vertex) );
522 gamma_prob =
m_V0Tools->vertexProbability(myGamma.get());
527 mDecor_gfit( *(v0Container->
back()) ) = gamma_fit;
528 mDecor_gmass( *(v0Container->
back()) ) = gamma_mass;
529 mDecor_gmasserr( *(v0Container->
back()) ) = gamma_massErr;
530 mDecor_gprob( *(v0Container->
back()) ) = gamma_prob;
552 if (v0Container->
empty())
ATH_MSG_DEBUG(
"No Candidates found. Empty container returned");
553 if (ksContainer->
empty())
ATH_MSG_DEBUG(
"No Kshort Candidates found. Empty container returned");
554 if (laContainer->
empty())
ATH_MSG_DEBUG(
"No Lambda Candidates found. Empty container returned");
555 if (lbContainer->
empty())
ATH_MSG_DEBUG(
"No Lambdabar Candidates found. Empty container returned");
557 return StatusCode::SUCCESS;
563 <<
"----------------------------------------------------------------------------------------------------------------------------------------------" <<
endmsg
570 msg(
MSG::DEBUG) <<
"----------------------------------------------------------------------------------------------------------------------------------------------" <<
endmsg;
572 return StatusCode::SUCCESS;
585 double srxy = startingPoint.perp();
588 double massKshort_i=2000001., massLambda_i=2000001., massLambdabar_i=2000001.;
591 std::vector<std::unique_ptr<const Trk::TrackParameters> > cleanup;
595 if (extrapolatedPerigee1 ==
nullptr) extrapolatedPerigee1 = &track1->
perigeeParameters();
596 else cleanup.push_back(std::unique_ptr<const Trk::TrackParameters>(extrapolatedPerigee1));
599 if (extrapolatedPerigee2 ==
nullptr) extrapolatedPerigee2 = &track2->
perigeeParameters();
600 else cleanup.push_back(std::unique_ptr<const Trk::TrackParameters>(extrapolatedPerigee2));
602 if (extrapolatedPerigee1 !=
nullptr && extrapolatedPerigee2 !=
nullptr) {
608 (massLambdabar_i >=
m_ulamin && massLambdabar_i <=
m_ulamax)) ) pass =
true;
619 for (
auto vItr=vertColl->
begin(); vItr!=vertColl->
end(); ++vItr )
623 if (per1 ==
nullptr)
continue;
625 if (per2 ==
nullptr)
continue;
627 double sig_d0_1 = sqrt((*per1->covariance())(0,0));
628 double d0_2 = per2->parameters()[
Trk::d0];
629 double sig_d0_2 = sqrt((*per2->covariance())(0,0));
630 if (std::abs(d0_1/sig_d0_1) >
m_d0_cut &&
631 std::abs(d0_2/sig_d0_2) >
m_d0_cut)
return true;
641 if (per1 ==
nullptr)
return pass;
643 if (per2 ==
nullptr) {
646 double d0_1 = per1->parameters()[
Trk::d0];
647 double sig_d0_1 = sqrt((*per1->covariance())(0,0));
649 double sig_d0_2 = sqrt((*per2->covariance())(0,0));
650 if (std::abs(d0_1/sig_d0_1) >
m_d0_cut &&
651 std::abs(d0_2/sig_d0_2) >
m_d0_cut) pass =
true;
659 if (per1 ==
nullptr)
return pass;
661 if (per2 ==
nullptr) {
664 double d0_1 = per1->parameters()[
Trk::d0];
665 double sig_d0_1 = sqrt((*per1->covariance())(0,0));
667 double sig_d0_2 = sqrt((*per2->covariance())(0,0));
668 if (std::abs(d0_1/sig_d0_1) >
m_d0_cut && std::abs(d0_2/sig_d0_2) >
m_d0_cut) pass =
true;
697 double e1 = (e1sq>0.) ? sqrt(e1sq) : 0.;
699 double e2 = (e2sq>0.) ? sqrt(e2sq) : 0.;
702 double mass = (msq>0.) ? sqrt(msq) : 0.;
709 double mass = 1000000000.;
710 double error = 1000000001.;
711 bool in_mass_window =
false;
712 double winmass_min = 0., winmass_max = 0.;
720 }
else if (pdgID == 3122 || pdgID == -3122) {
726 }
else if (pdgID == -3122) {
732 if (in_mass_window) pass =
true;
740 std::vector<double>
masses;
744 }
else if (pdgID == 3122) {
747 }
else if (pdgID == -3122) {
750 }
else if (pdgID == 22) {
772 if (pdgID == -3122) {
784 const std::vector<const xAOD::TrackParticleContainer*>& trackcols)
const
788 bool elementSet =
false;
789 if(trackcols.empty()){
795 if(itr != trkcol->end()){
802 if(!elementSet)
ATH_MSG_ERROR(
"Track was not found when linking");