440 {
441 size_t topoN = 4;
443
445 ATH_MSG_FATAL(
"Incorrect number of output cascade vertices");
446 return StatusCode::FAILURE;
447 }
448
449 std::array<SG::WriteHandle<xAOD::VertexContainer>, 4> VtxWriteHandles; int ikey(0);
451 VtxWriteHandles[ikey] = SG::WriteHandle<xAOD::VertexContainer>(key, ctx);
452 ATH_CHECK( VtxWriteHandles[ikey].record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>()) );
453 ikey++;
454 }
455
456
457
458
461 ATH_CHECK( defaultPVContainer.isValid() );
462 if (defaultPVContainer.cptr()->size()==0) {
463 ATH_MSG_WARNING(
"You have no primary vertices: " << defaultPVContainer.cptr()->size());
464 return StatusCode::RECOVERABLE;
465 }
466 else primaryVertex = (*defaultPVContainer.cptr())[0];
467
468
469
470
471 SG::WriteHandle<xAOD::VertexContainer> refPvContainer;
474 ATH_CHECK( refPvContainer.
record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>()) );
475 }
476
477
480
481
482 std::vector<const xAOD::TrackParticleContainer*> trackCols;
484 SG::ReadHandle<xAOD::TrackParticleContainer> handle(key, ctx);
486 trackCols.push_back(handle.cptr());
487 }
488
489
490 SG::WriteHandle<xAOD::VertexContainer> V0OutputContainer;
492 V0OutputContainer = SG::WriteHandle<xAOD::VertexContainer>(
m_v0VtxOutputKey, ctx);
493 ATH_CHECK( V0OutputContainer.
record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>()) );
494 }
495
496
497
500 if(jxContainer->size()==0) return StatusCode::SUCCESS;
501
502
503 std::vector<const xAOD::TrackParticle*> tracksDisplaced;
506
512 if(!
m_useTRT && nclus == 0)
continue;
513
514 bool trk_cut = false;
515 if(nclus != 0) trk_cut = true;
516 if(nclus == 0 && TP->pt()>=
m_ptTRT) trk_cut =
true;
517 if(!trk_cut) continue;
518
519
520 if(!
d0Pass(TP,primaryVertex))
continue;
521
522 tracksDisplaced.push_back(TP);
523 }
524 }
525 }
526
529 SG::AuxElement::Accessor<float> mAcc_gmass("gamma_mass");
530 SG::AuxElement::Accessor<float> mAcc_gchisq("gamma_chisq");
532
533 std::vector<std::pair<const xAOD::Vertex*,V0Enum> > selectedV0Candidates;
534
539
541 std::string type_V0Vtx;
542 if(mAcc_type.isAvailable(*vtx)) type_V0Vtx = mAcc_type(*vtx);
543
545 if(type_V0Vtx == "Lambda") {
549 }
550 else if(type_V0Vtx == "Lambdabar") {
554 }
555 else if(type_V0Vtx == "Ks") {
559 }
560
565 }
566
567 int gamma_fit = mAcc_gfit.isAvailable(*vtx) ? mAcc_gfit(*vtx) : 0;
568 double gamma_mass = mAcc_gmass.isAvailable(*vtx) ? mAcc_gmass(*vtx) : -1;
569 double gamma_chisq = mAcc_gchisq.isAvailable(*vtx) ? mAcc_gchisq(*vtx) : 999999;
570 double gamma_ndof = mAcc_gndof.isAvailable(*vtx) ? mAcc_gndof(*vtx) : 0;
572
573 selectedV0Candidates.push_back(std::pair<const xAOD::Vertex*,V0Enum>{vtx,
opt});
574 }
575 }
576 else {
577
579
581 std::string type_V0Vtx;
582 if(mAcc_type.isAvailable(*vtx)) type_V0Vtx = mAcc_type(*vtx);
583
585 if(type_V0Vtx == "Lambda") {
589 }
590 else if(type_V0Vtx == "Lambdabar") {
594 }
595 else if(type_V0Vtx == "Ks") {
599 }
600
605 }
606
607 int gamma_fit = mAcc_gfit.isAvailable(*vtx) ? mAcc_gfit(*vtx) : 0;
608 double gamma_mass = mAcc_gmass.isAvailable(*vtx) ? mAcc_gmass(*vtx) : -1;
609 double gamma_chisq = mAcc_gchisq.isAvailable(*vtx) ? mAcc_gchisq(*vtx) : 999999;
610 double gamma_ndof = mAcc_gndof.isAvailable(*vtx) ? mAcc_gndof(*vtx) : 0;
612
613 selectedV0Candidates.push_back(std::pair<const xAOD::Vertex*,V0Enum>{vtx,
opt});
614 }
615 }
616
617
618 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(); } );
620 selectedV0Candidates.erase(selectedV0Candidates.begin()+
m_maxV0Candidates, selectedV0Candidates.end());
621 }
622 if(selectedV0Candidates.size()==0) return StatusCode::SUCCESS;
623
624 std::vector<Trk::VxCascadeInfo*> cascadeinfoContainer;
626
627
628 std::sort( cascadeinfoContainer.begin(), cascadeinfoContainer.end(), [](Trk::VxCascadeInfo*
a, Trk::VxCascadeInfo* b) { return a->fitChi2()/a->nDoF() < b->fitChi2()/b->nDoF(); } );
630 for(
auto it=cascadeinfoContainer.begin()+
m_maxMainVCandidates; it!=cascadeinfoContainer.end(); it++)
delete *
it;
631 cascadeinfoContainer.erase(cascadeinfoContainer.begin()+
m_maxMainVCandidates, cascadeinfoContainer.end());
632 }
633
638
639
641 SG::AuxElement::Decorator<float> chi2_decor("ChiSquared");
642 SG::AuxElement::Decorator<int> ndof_decor("nDoF");
643 SG::AuxElement::Decorator<float> Pt_decor("Pt");
644 SG::AuxElement::Decorator<float> PtErr_decor("PtErr");
645
646 SG::AuxElement::Decorator<float> lxy_SV1_decor("lxy_SV1");
647 SG::AuxElement::Decorator<float> lxyErr_SV1_decor("lxyErr_SV1");
648 SG::AuxElement::Decorator<float> a0xy_SV1_decor("a0xy_SV1");
649 SG::AuxElement::Decorator<float> a0xyErr_SV1_decor("a0xyErr_SV1");
650 SG::AuxElement::Decorator<float> a0z_SV1_decor("a0z_SV1");
651 SG::AuxElement::Decorator<float> a0zErr_SV1_decor("a0zErr_SV1");
652
653 SG::AuxElement::Decorator<float> lxy_SV2_decor("lxy_SV2");
654 SG::AuxElement::Decorator<float> lxyErr_SV2_decor("lxyErr_SV2");
655 SG::AuxElement::Decorator<float> a0xy_SV2_decor("a0xy_SV2");
656 SG::AuxElement::Decorator<float> a0xyErr_SV2_decor("a0xyErr_SV2");
657 SG::AuxElement::Decorator<float> a0z_SV2_decor("a0z_SV2");
658 SG::AuxElement::Decorator<float> a0zErr_SV2_decor("a0zErr_SV2");
659
660 SG::AuxElement::Decorator<float> lxy_SV3_decor("lxy_SV3");
661 SG::AuxElement::Decorator<float> lxyErr_SV3_decor("lxyErr_SV3");
662 SG::AuxElement::Decorator<float> a0xy_SV3_decor("a0xy_SV3");
663 SG::AuxElement::Decorator<float> a0xyErr_SV3_decor("a0xyErr_SV3");
664 SG::AuxElement::Decorator<float> a0z_SV3_decor("a0z_SV3");
665 SG::AuxElement::Decorator<float> a0zErr_SV3_decor("a0zErr_SV3");
666
667 SG::AuxElement::Decorator<float> chi2_V3_decor("ChiSquared_V3");
668 SG::AuxElement::Decorator<int> ndof_V3_decor("nDoF_V3");
669
670 for(auto cascade_info : cascadeinfoContainer) {
671 if(cascade_info==nullptr) {
673 continue;
674 }
675
676 const std::vector<xAOD::Vertex*> &cascadeVertices = cascade_info->vertices();
677 if(cascadeVertices.size() != topoN)
ATH_MSG_ERROR(
"Incorrect number of vertices");
678 for(
size_t i=0;
i<topoN;
i++) {
679 if(cascadeVertices[i]==
nullptr)
ATH_MSG_ERROR(
"Error null vertex");
680 }
681
682 cascade_info->setSVOwnership(false);
683 const auto mainVertex = cascadeVertices[topoN-1];
684 const std::vector< std::vector<TLorentzVector> > &moms = cascade_info->getParticleMoms();
685
686
691 else jxVtx =
FindVertex<2>(jxContainer.ptr(), cascadeVertices[ijx]);
692
693 xAOD::BPhysHypoHelper vtx(
m_hypoName, mainVertex);
694
695
697 vtx.setPass(true);
698
699
700
701
702
703
706
708 PtErr_decor(*mainVertex) =
m_CascadeTools->pTError(moms[topoN-1],cascade_info->getCovariance()[topoN-1]);
709
710 chi2_decor(*mainVertex) = cascade_info->fitChi2();
711 ndof_decor(*mainVertex) = cascade_info->nDoF();
712
713
714 lxy_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->lxy(moms[0],cascadeVertices[0],mainVertex);
715 lxyErr_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->lxyError(moms[0],cascade_info->getCovariance()[0],cascadeVertices[0],mainVertex);
716 a0z_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->a0z(moms[0],cascadeVertices[0],mainVertex);
717 a0zErr_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->a0zError(moms[0],cascade_info->getCovariance()[0],cascadeVertices[0],mainVertex);
718 a0xy_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->a0xy(moms[0],cascadeVertices[0],mainVertex);
719 a0xyErr_SV1_decor(*cascadeVertices[0]) =
m_CascadeTools->a0xyError(moms[0],cascade_info->getCovariance()[0],cascadeVertices[0],mainVertex);
720
722 lxy_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->lxy(moms[1],cascadeVertices[1],cascadeVertices[2]);
723 lxyErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->lxyError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],cascadeVertices[2]);
724 a0z_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0z(moms[1],cascadeVertices[1],cascadeVertices[2]);
725 a0zErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0zError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],cascadeVertices[2]);
726 a0xy_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0xy(moms[1],cascadeVertices[1],cascadeVertices[2]);
727 a0xyErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0xyError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],cascadeVertices[2]);
728 }
729 else {
730 lxy_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->lxy(moms[1],cascadeVertices[1],mainVertex);
731 lxyErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->lxyError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],mainVertex);
732 a0z_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0z(moms[1],cascadeVertices[1],mainVertex);
733 a0zErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0zError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],mainVertex);
734 a0xy_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0xy(moms[1],cascadeVertices[1],mainVertex);
735 a0xyErr_SV2_decor(*cascadeVertices[1]) =
m_CascadeTools->a0xyError(moms[1],cascade_info->getCovariance()[1],cascadeVertices[1],mainVertex);
736 }
737
739 lxy_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->lxy(moms[2],cascadeVertices[2],mainVertex);
740 lxyErr_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->lxyError(moms[2],cascade_info->getCovariance()[2],cascadeVertices[2],mainVertex);
741 a0z_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->a0z(moms[2],cascadeVertices[2],mainVertex);
742 a0zErr_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->a0zError(moms[2],cascade_info->getCovariance()[2],cascadeVertices[2],mainVertex);
743 a0xy_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->a0xy(moms[2],cascadeVertices[2],mainVertex);
744 a0xyErr_SV3_decor(*cascadeVertices[2]) =
m_CascadeTools->a0xyError(moms[2],cascade_info->getCovariance()[2],cascadeVertices[2],mainVertex);
745 }
746
747 chi2_V3_decor(*cascadeVertices[2]) =
m_V0Tools->chisq(jxVtx);
748 ndof_V3_decor(*cascadeVertices[2]) =
m_V0Tools->ndof(jxVtx);
749
752 }
753
754 for(
size_t i=0;
i<topoN;
i++) {
755 VtxWriteHandles[
i].ptr()->push_back(cascadeVertices[i]);
756 }
757
758
763 if( vertexLink1.
isValid() ) cascadeVertexLinks.push_back( vertexLink1 );
767 if( vertexLink2.
isValid() ) cascadeVertexLinks.push_back( vertexLink2 );
768 if(topoN==4) {
772 if( vertexLink3.
isValid() ) cascadeVertexLinks.push_back( vertexLink3 );
773 }
774 CascadeLinksDecor(*mainVertex) = cascadeVertexLinks;
775 }
776
777
778 for (auto cascade_info : cascadeinfoContainer) {
779 if(cascade_info) delete cascade_info;
780 }
781
782 return StatusCode::SUCCESS;
783 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(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 to point to an element.
bool setStorableObject(BaseConstReference data, bool replace=false, IProxyDict *sg=0)
Set link to point to a new container (storable).
bool isValid() const
Test to see if the link can be dereferenced.
SG::Decorator< T, ALLOC > Decorator
SG::Accessor< T, ALLOC > Accessor
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.
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].