6#include "TLorentzVector.h"
24 auto momentum = tracks[0]->genvecP4();
27 for (
size_t i = 1; i < tracks.size(); ++i) {
28 momentum += tracks[i]->genvecP4();
31 return std::sqrt(momentum.Perp2());
40 return (mom1 + mom2).M();
44 std::span<const double> masses)
46 assert(tracks.size() == masses.size());
48 auto Totalmomentum = tracks[0]->genvecP4();
49 Totalmomentum.SetM(masses[0]);
51 for (
size_t i = 1; i < tracks.size(); ++i) {
52 auto momentum = tracks[i]->genvecP4();
53 momentum.SetM(masses[i]);
54 Totalmomentum += momentum;
56 return Totalmomentum.M();
66 return std::find(theColl.begin(), theColl.end(), theTrack) != theColl.end();
70 return std::find_if(theColl->
begin(), theColl->
end(), [theTrack](
const xAOD::Muon* muon){
71 return muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) == theTrack;
80 for(
double m : values) {
91 for(
double m : values) {
103 std::vector<const xAOD::Vertex*> tocleanup;
104 if(pvRefitter) tocleanup.reserve(importedPVerticesCollection->
size());
105 bool vertexrefitted =
false;
106 for (
const xAOD::Vertex* PV : *importedPVerticesCollection) {
109 if(refPV) tocleanup.push_back(refPV);
112 TVector3 posV(helperpos.x(), helperpos.y(), helperpos.z());
113 TVector3 nV = bHelper.
totalP().Unit();
114 TVector3 dposV = posPV-posV;
115 double dposVnV = dposV*nV;
116 double d = std::sqrt(std::abs(dposV.Mag2()-dposVnV*dposVnV));
120 vertexrefitted = (vtx_closest == refPV);
123 for(
auto ptr : tocleanup){
124 if(ptr != vtx_closest)
delete ptr;
130 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
132 for(
size_t i = 0; i<
size; i++){
135 auto itr = std::find(trkcol->begin(), trkcol->end(), mylink);
136 if(itr != trkcol->end()){
138 mylink.setStorableObject(*trkcol,
true);
139 newLinkVector.push_back( mylink );
144 if(
size != newLinkVector.size()){
145 throw std::runtime_error(
"JpsiUpsilonCommon::RelinkVertexTracks: Could not relink all tracks");
154 static const SG::AuxElement::Decorator<MuonLinkVector> muonLinksDecor(
"MuonLinks");
156 auto size = mlinksold.size();
158 for(
size_t i = 0; i<
size; i++){
161 auto itr = std::find(mucol->begin(), mucol->end(), mylink);
162 if(itr != mucol->end()){
163 auto mylink=mlinksold[i];
164 mylink.setStorableObject(*mucol,
true);
165 newmulinks.push_back( mylink );
170 if(
size != newmulinks.size()){
171 throw std::runtime_error(
"JpsiUpsilonCommon::RelinkVertexMuons: Could not relink all tracks");
173 muonLinksDecor(*vtx) = std::move(newmulinks);
std::vector< MuonLink > MuonLinkVector
ElementLink< xAOD::MuonContainer > MuonLink
: B-physics xAOD helpers.
size_t size() const
Number of registered mappings.
static bool cutRange(double value, double min, double max) noexcept
static void RelinkVertexMuons(std::span< const xAOD::MuonContainer *const > muoncols, xAOD::Vertex *vtx)
static double getInvariantMass(const xAOD::TrackParticle *trk1, double mass1, const xAOD::TrackParticle *trk2, double mass2)
static void RelinkVertexTracks(std::span< const xAOD::TrackParticleContainer *const > trkcols, xAOD::Vertex *vtx)
static bool cutAcceptGreaterOR(std::span< double const > values, double min) noexcept
static Analysis::CleanUpVertex ClosestRefPV(xAOD::BPhysHelper &, const xAOD::VertexContainer *, const Analysis::PrimaryVertexRefitter *)
static bool cutRangeOR(std::span< double const > values, double min, double max) noexcept
static bool isContainedIn(const xAOD::TrackParticle *, std::span< const xAOD::TrackParticle *const >) noexcept
static double getPt(std::span< const xAOD::TrackParticle *const > tracks)
static bool cutAcceptGreater(double value, double min) noexcept
xAOD::Vertex * refitVertex(const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
ElementLink implementation for ROOT usage.
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
TVector3 totalP()
: Returns total 3-momentum calculated from the refitted tracks
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector form.
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.
const Amg::Vector3D & position() const
Returns the 3-pos.
The namespace of all packages in PhysicsAnalysis/JetTagging.
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".
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".