438 {
439 size_t topoN = 4;
441
443 ATH_MSG_FATAL(
"Incorrect number of output cascade vertices");
444 return StatusCode::FAILURE;
445 }
446
447 std::array<SG::WriteHandle<xAOD::VertexContainer>, 4> VtxWriteHandles; int ikey(0);
449 VtxWriteHandles[ikey] = SG::WriteHandle<xAOD::VertexContainer>(key, ctx);
450 ATH_CHECK( VtxWriteHandles[ikey].record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>()) );
451 ikey++;
452 }
453
454
455
456
459 ATH_CHECK( defaultPVContainer.isValid() );
460 if (defaultPVContainer.cptr()->size()==0) {
461 ATH_MSG_WARNING(
"You have no primary vertices: " << defaultPVContainer.cptr()->size());
462 return StatusCode::RECOVERABLE;
463 }
464 else primaryVertex = (*defaultPVContainer.cptr())[0];
465
466
467
468
469 SG::WriteHandle<xAOD::VertexContainer> refPvContainer;
472 ATH_CHECK( refPvContainer.
record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>()) );
473 }
474
475
478
479
480 std::vector<const xAOD::TrackParticleContainer*> trackCols;
482 SG::ReadHandle<xAOD::TrackParticleContainer>
handle(key, ctx);
484 trackCols.push_back(
handle.cptr());
485 }
486
487
488 SG::WriteHandle<xAOD::VertexContainer> V0OutputContainer;
490 V0OutputContainer = SG::WriteHandle<xAOD::VertexContainer>(
m_v0VtxOutputKey, ctx);
491 ATH_CHECK( V0OutputContainer.
record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>()) );
492 }
493
494
495
498 if(jxContainer->size()==0) return StatusCode::SUCCESS;
499
500
501 std::vector<const xAOD::TrackParticle*> tracksDisplaced;
504
510 if(!
m_useTRT && nclus == 0)
continue;
511
512 bool trk_cut = false;
513 if(nclus != 0) trk_cut = true;
514 if(nclus == 0 && TP->pt()>=
m_ptTRT) trk_cut =
true;
515 if(!trk_cut) continue;
516
517
518 if(!
d0Pass(TP,primaryVertex))
continue;
519
520 tracksDisplaced.push_back(TP);
521 }
522 }
523 }
524
525 SG::AuxElement::Accessor<std::string> mAcc_type("Type_V0Vtx");
526 SG::AuxElement::Accessor<int> mAcc_gfit("gamma_fit");
527 SG::AuxElement::Accessor<float> mAcc_gmass("gamma_mass");
528 SG::AuxElement::Accessor<float> mAcc_gchisq("gamma_chisq");
529 SG::AuxElement::Accessor<int> mAcc_gndof("gamma_ndof");
530
531 std::vector<std::pair<const xAOD::Vertex*,V0Enum> > selectedV0Candidates;
532
537
539 std::string type_V0Vtx;
540 if(mAcc_type.isAvailable(*vtx)) type_V0Vtx = mAcc_type(*vtx);
541
543 if(type_V0Vtx == "Lambda") {
547 }
548 else if(type_V0Vtx == "Lambdabar") {
552 }
553 else if(type_V0Vtx == "Ks") {
557 }
558
563 }
564
565 int gamma_fit = mAcc_gfit.isAvailable(*vtx) ? mAcc_gfit(*vtx) : 0;
566 double gamma_mass = mAcc_gmass.isAvailable(*vtx) ? mAcc_gmass(*vtx) : -1;
567 double gamma_chisq = mAcc_gchisq.isAvailable(*vtx) ? mAcc_gchisq(*vtx) : 999999;
568 double gamma_ndof = mAcc_gndof.isAvailable(*vtx) ? mAcc_gndof(*vtx) : 0;
570
571 selectedV0Candidates.push_back(std::pair<const xAOD::Vertex*,V0Enum>{vtx,
opt});
572 }
573 }
574 else {
575
577
579 std::string type_V0Vtx;
580 if(mAcc_type.isAvailable(*vtx)) type_V0Vtx = mAcc_type(*vtx);
581
583 if(type_V0Vtx == "Lambda") {
587 }
588 else if(type_V0Vtx == "Lambdabar") {
592 }
593 else if(type_V0Vtx == "Ks") {
597 }
598
603 }
604
605 int gamma_fit = mAcc_gfit.isAvailable(*vtx) ? mAcc_gfit(*vtx) : 0;
606 double gamma_mass = mAcc_gmass.isAvailable(*vtx) ? mAcc_gmass(*vtx) : -1;
607 double gamma_chisq = mAcc_gchisq.isAvailable(*vtx) ? mAcc_gchisq(*vtx) : 999999;
608 double gamma_ndof = mAcc_gndof.isAvailable(*vtx) ? mAcc_gndof(*vtx) : 0;
610
611 selectedV0Candidates.push_back(std::pair<const xAOD::Vertex*,V0Enum>{vtx,
opt});
612 }
613 }
614
615
616 std::sort( selectedV0Candidates.begin(), selectedV0Candidates.end(), [](std::pair<const xAOD::Vertex*,V0Enum>&
a, std::pair<const xAOD::Vertex*,V0Enum>& b) { return a.first->chiSquared()/a.first->numberDoF() < b.first->chiSquared()/b.first->numberDoF(); } );
618 selectedV0Candidates.erase(selectedV0Candidates.begin()+
m_maxV0Candidates, selectedV0Candidates.end());
619 }
620 if(selectedV0Candidates.size()==0) return StatusCode::SUCCESS;
621
622 std::vector<Trk::VxCascadeInfo*> cascadeinfoContainer;
624
625
626 std::sort( cascadeinfoContainer.begin(), cascadeinfoContainer.end(), [](Trk::VxCascadeInfo*
a, Trk::VxCascadeInfo* b) { return a->fitChi2()/a->nDoF() < b->fitChi2()/b->nDoF(); } );
628 for(
auto it=cascadeinfoContainer.begin()+
m_maxMainVCandidates; it!=cascadeinfoContainer.end(); it++)
delete *
it;
629 cascadeinfoContainer.erase(cascadeinfoContainer.begin()+
m_maxMainVCandidates, cascadeinfoContainer.end());
630 }
631
636
637
638 SG::AuxElement::Decorator<VertexLinkVector> CascadeLinksDecor("CascadeVertexLinks");
639 SG::AuxElement::Decorator<float> chi2_decor("ChiSquared");
640 SG::AuxElement::Decorator<int> ndof_decor("nDoF");
641 SG::AuxElement::Decorator<float> Pt_decor("Pt");
642 SG::AuxElement::Decorator<float> PtErr_decor("PtErr");
643
644 SG::AuxElement::Decorator<float> lxy_SV1_decor("lxy_SV1");
645 SG::AuxElement::Decorator<float> lxyErr_SV1_decor("lxyErr_SV1");
646 SG::AuxElement::Decorator<float> a0xy_SV1_decor("a0xy_SV1");
647 SG::AuxElement::Decorator<float> a0xyErr_SV1_decor("a0xyErr_SV1");
648 SG::AuxElement::Decorator<float> a0z_SV1_decor("a0z_SV1");
649 SG::AuxElement::Decorator<float> a0zErr_SV1_decor("a0zErr_SV1");
650
651 SG::AuxElement::Decorator<float> lxy_SV2_decor("lxy_SV2");
652 SG::AuxElement::Decorator<float> lxyErr_SV2_decor("lxyErr_SV2");
653 SG::AuxElement::Decorator<float> a0xy_SV2_decor("a0xy_SV2");
654 SG::AuxElement::Decorator<float> a0xyErr_SV2_decor("a0xyErr_SV2");
655 SG::AuxElement::Decorator<float> a0z_SV2_decor("a0z_SV2");
656 SG::AuxElement::Decorator<float> a0zErr_SV2_decor("a0zErr_SV2");
657
658 SG::AuxElement::Decorator<float> lxy_SV3_decor("lxy_SV3");
659 SG::AuxElement::Decorator<float> lxyErr_SV3_decor("lxyErr_SV3");
660 SG::AuxElement::Decorator<float> a0xy_SV3_decor("a0xy_SV3");
661 SG::AuxElement::Decorator<float> a0xyErr_SV3_decor("a0xyErr_SV3");
662 SG::AuxElement::Decorator<float> a0z_SV3_decor("a0z_SV3");
663 SG::AuxElement::Decorator<float> a0zErr_SV3_decor("a0zErr_SV3");
664
665 SG::AuxElement::Decorator<float> chi2_V3_decor("ChiSquared_V3");
666 SG::AuxElement::Decorator<int> ndof_V3_decor("nDoF_V3");
667
668 for(auto cascade_info : cascadeinfoContainer) {
669 if(cascade_info==nullptr) {
671 continue;
672 }
673
674 const std::vector<xAOD::Vertex*> &cascadeVertices = cascade_info->vertices();
675 if(cascadeVertices.size() != topoN)
ATH_MSG_ERROR(
"Incorrect number of vertices");
676 for(
size_t i=0;
i<topoN;
i++) {
677 if(cascadeVertices[i]==
nullptr)
ATH_MSG_ERROR(
"Error null vertex");
678 }
679
680 cascade_info->setSVOwnership(false);
681 const auto mainVertex = cascadeVertices[topoN-1];
682 const std::vector< std::vector<TLorentzVector> > &moms = cascade_info->getParticleMoms();
683
684
689 else jxVtx =
FindVertex<2>(jxContainer.ptr(), cascadeVertices[ijx]);
690
691 xAOD::BPhysHypoHelper vtx(
m_hypoName, mainVertex);
692
693
695 vtx.setPass(true);
696
697
698
699
700
701
704
706 PtErr_decor(*mainVertex) =
m_CascadeTools->pTError(moms[topoN-1],cascade_info->getCovariance()[topoN-1]);
707
708 chi2_decor(*mainVertex) = cascade_info->fitChi2();
709 ndof_decor(*mainVertex) = cascade_info->nDoF();
710
711
712 lxy_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->lxy(moms[0],cascadeVertices[0],mainVertex);
713 lxyErr_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->lxyError(moms[0],cascade_info->getCovariance()[0],cascadeVertices[0],mainVertex);
714 a0z_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->a0z(moms[0],cascadeVertices[0],mainVertex);
715 a0zErr_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->a0zError(moms[0],cascade_info->getCovariance()[0],cascadeVertices[0],mainVertex);
716 a0xy_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->a0xy(moms[0],cascadeVertices[0],mainVertex);
717 a0xyErr_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->a0xyError(moms[0],cascade_info->getCovariance()[0],cascadeVertices[0],mainVertex);
718
720 lxy_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->lxy(moms[1],cascadeVertices[1],cascadeVertices[2]);
721 lxyErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->lxyError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],cascadeVertices[2]);
722 a0z_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0z(moms[1],cascadeVertices[1],cascadeVertices[2]);
723 a0zErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0zError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],cascadeVertices[2]);
724 a0xy_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0xy(moms[1],cascadeVertices[1],cascadeVertices[2]);
725 a0xyErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0xyError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],cascadeVertices[2]);
726 }
727 else {
728 lxy_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->lxy(moms[1],cascadeVertices[1],mainVertex);
729 lxyErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->lxyError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],mainVertex);
730 a0z_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0z(moms[1],cascadeVertices[1],mainVertex);
731 a0zErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0zError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],mainVertex);
732 a0xy_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0xy(moms[1],cascadeVertices[1],mainVertex);
733 a0xyErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0xyError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],mainVertex);
734 }
735
737 lxy_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->lxy(moms[2],cascadeVertices[2],mainVertex);
738 lxyErr_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->lxyError(moms[2],cascade_info->getCovariance()[2],cascadeVertices[2],mainVertex);
739 a0z_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->a0z(moms[2],cascadeVertices[2],mainVertex);
740 a0zErr_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->a0zError(moms[2],cascade_info->getCovariance()[2],cascadeVertices[2],mainVertex);
741 a0xy_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->a0xy(moms[2],cascadeVertices[2],mainVertex);
742 a0xyErr_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->a0xyError(moms[2],cascade_info->getCovariance()[2],cascadeVertices[2],mainVertex);
743 }
744
745 chi2_V3_decor(*cascadeVertices[2]) =
m_V0Tools->chisq(jxVtx);
746 ndof_V3_decor(*cascadeVertices[2]) =
m_V0Tools->ndof(jxVtx);
747
750 }
751
752 for(
size_t i=0;
i<topoN;
i++) {
753 VtxWriteHandles[
i].ptr()->push_back(cascadeVertices[i]);
754 }
755
756
761 if( vertexLink1.
isValid() ) cascadeVertexLinks.push_back( vertexLink1 );
765 if( vertexLink2.
isValid() ) cascadeVertexLinks.push_back( vertexLink2 );
766 if(topoN==4) {
770 if( vertexLink3.
isValid() ) cascadeVertexLinks.push_back( vertexLink3 );
771 }
772 CascadeLinksDecor(*mainVertex) = cascadeVertexLinks;
773 }
774
775
776 for (auto cascade_info : cascadeinfoContainer) {
777 if(cascade_info) delete cascade_info;
778 }
779
780 return StatusCode::SUCCESS;
781 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_FATAL(x,...)
#define BPHYS_CHECK(EXP)
Useful CHECK macro.
std::vector< double > m_massesV0_pip
std::vector< double > m_massesV0_ppi
std::vector< double > m_massesV0_pipi
bool d0Pass(const xAOD::TrackParticle *track, const xAOD::Vertex *PV) const
const xAOD::Vertex * FindVertex(const xAOD::VertexContainer *cont, const xAOD::Vertex *v) const
void fitV0Container(xAOD::VertexContainer *V0ContainerNew, const std::vector< const xAOD::TrackParticle * > &selectedTracks, const std::vector< const xAOD::TrackParticleContainer * > &trackCols) const
StatusCode performSearch(std::vector< Trk::VxCascadeInfo * > &cascadeinfoContainer, const std::vector< std::pair< const xAOD::Vertex *, V0Enum > > &selectedV0Candidates, const EventContext &ctx) const
bool setElement(ElementType element)
Set link to point to an Element (slowest).
bool isValid() const
Check if the element can be found.
bool setStorableObject(BaseConstReference data, bool replace=false)
Set link storable to data object pointed by data (slower).
const_pointer_type cptr() const
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
virtual void handle(const Incident &inc)
Handle end of run incidents to save the metadata at that point.
ElementLink< xAOD::VertexContainer > VertexLink
std::vector< VertexLink > VertexLinkVector
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].