ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::JpsiUpsilonCommon Class Reference

#include <JpsiUpsilonCommon.h>

Collaboration diagram for DerivationFramework::JpsiUpsilonCommon:

Static Public Member Functions

static double getInvariantMass (const xAOD::TrackParticle *trk1, double mass1, const xAOD::TrackParticle *trk2, double mass2)
static double getInvariantMass (std::span< const xAOD::TrackParticle * > trk, std::span< const double > masses)
static double getPt (std::span< const xAOD::TrackParticle *const > tracks)
template<typename... Tracks>
static double getPt (const xAOD::TrackParticle *first, const Tracks *... rest)
static bool isContainedIn (const xAOD::TrackParticle *, std::span< const xAOD::TrackParticle *const >) noexcept
static bool isContainedIn (const xAOD::TrackParticle *, const xAOD::MuonContainer *)
static bool cutRangeOR (std::span< double const > values, double min, double max) noexcept
static bool cutRange (double value, double min, double max) noexcept
static bool cutAcceptGreaterOR (std::span< double const > values, double min) noexcept
static bool cutAcceptGreater (double value, double min) noexcept
static Analysis::CleanUpVertex ClosestRefPV (xAOD::BPhysHelper &, const xAOD::VertexContainer *, const Analysis::PrimaryVertexRefitter *)
static void RelinkVertexTracks (std::span< const xAOD::TrackParticleContainer *const > trkcols, xAOD::Vertex *vtx)
static void RelinkVertexMuons (std::span< const xAOD::MuonContainer *const > muoncols, xAOD::Vertex *vtx)

Detailed Description

Definition at line 41 of file JpsiUpsilonCommon.h.

Member Function Documentation

◆ ClosestRefPV()

Definition at line 97 of file JpsiUpsilonCommon.cxx.

99 {
100 const xAOD::Vertex* vtx_closest = nullptr; // vertex closest to bVertex track
101 if(importedPVerticesCollection->empty()) return Analysis::CleanUpVertex(nullptr, false);
102 double dc = 1e10;
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) {
107 const xAOD::Vertex* refPV = pvRefitter ? pvRefitter->refitVertex(PV, bHelper.vtx(), false) : nullptr;
108 const xAOD::Vertex* vtx = refPV ? refPV : PV;
109 if(refPV) tocleanup.push_back(refPV);
110 TVector3 posPV(vtx->position().x(),vtx->position().y(),vtx->position().z());
111 auto &helperpos = bHelper.vtx()->position();
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));
117 if (d<dc) {
118 dc = d;
119 vtx_closest = vtx;
120 vertexrefitted = (vtx_closest == refPV);
121 }
122 }
123 for(auto ptr : tocleanup){
124 if(ptr != vtx_closest) delete ptr;
125 }
126 return Analysis::CleanUpVertex(vtx_closest, vertexrefitted);
127 }
xAOD::Vertex * refitVertex(const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
TVector3 totalP()
: Returns total 3-momentum calculated from the refitted tracks
const Amg::Vector3D & position() const
Returns the 3-pos.
void * ptr(T *p)
Definition SGImplSvc.cxx:74
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ cutAcceptGreater()

bool Analysis::JpsiUpsilonCommon::cutAcceptGreater ( double value,
double min )
staticnoexcept

Definition at line 86 of file JpsiUpsilonCommon.cxx.

86 {
87 return (min <=0.0 || value >= min);
88 }
#define min(a, b)
Definition cfImp.cxx:40

◆ cutAcceptGreaterOR()

bool Analysis::JpsiUpsilonCommon::cutAcceptGreaterOR ( std::span< double const > values,
double min )
staticnoexcept

Definition at line 90 of file JpsiUpsilonCommon.cxx.

90 {
91 for(double m : values) {
92 if(min <=0.0 || m >= min) return true;
93 }
94 return false;
95 }

◆ cutRange()

bool Analysis::JpsiUpsilonCommon::cutRange ( double value,
double min,
double max )
staticnoexcept

Definition at line 75 of file JpsiUpsilonCommon.cxx.

75 {
76 return (min<=0.0 || value >= min) && (max <= 0.0 || value <= max);
77 }
#define max(a, b)
Definition cfImp.cxx:41

◆ cutRangeOR()

bool Analysis::JpsiUpsilonCommon::cutRangeOR ( std::span< double const > values,
double min,
double max )
staticnoexcept

Definition at line 79 of file JpsiUpsilonCommon.cxx.

79 {
80 for(double m : values) {
81 if( (min<=0.0 || m >= min) && (max <= 0.0 || m <= max)) return true;
82 }
83 return false;
84 }

◆ getInvariantMass() [1/2]

double Analysis::JpsiUpsilonCommon::getInvariantMass ( const xAOD::TrackParticle * trk1,
double mass1,
const xAOD::TrackParticle * trk2,
double mass2 )
static

Definition at line 34 of file JpsiUpsilonCommon.cxx.

35 {
36 auto mom1 = trk1->genvecP4();
37 mom1.SetM(mass1);
38 auto mom2 = trk2->genvecP4();
39 mom2.SetM(mass2);
40 return (mom1 + mom2).M();
41 }
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector form.

◆ getInvariantMass() [2/2]

double Analysis::JpsiUpsilonCommon::getInvariantMass ( std::span< const xAOD::TrackParticle * > trk,
std::span< const double > masses )
static

Definition at line 43 of file JpsiUpsilonCommon.cxx.

45 {
46 assert(tracks.size() == masses.size());
47 // Start with the four-momentum of the first track
48 auto Totalmomentum = tracks[0]->genvecP4();
49 Totalmomentum.SetM(masses[0]);
50
51 for (size_t i = 1; i < tracks.size(); ++i) {
52 auto momentum = tracks[i]->genvecP4();
53 momentum.SetM(masses[i]);
54 Totalmomentum += momentum;
55 }
56 return Totalmomentum.M();
57 }

◆ getPt() [1/2]

template<typename... Tracks>
double Analysis::JpsiUpsilonCommon::getPt ( const xAOD::TrackParticle * first,
const Tracks *... rest )
inlinestatic

Definition at line 58 of file JpsiUpsilonCommon.h.

59 {
60 // Start with the four-momentum of the first track
61 auto momentum = first->genvecP4();
62
63 // Fold the rest of the tracks into the sum using +=
64 // (The expansion applies += to each subsequent genvecP4())
65 ( (momentum += rest->genvecP4()), ... );
66
67 return std::sqrt(momentum.Perp2());
68 }
bool first
Definition DeMoScan.py:534

◆ getPt() [2/2]

double Analysis::JpsiUpsilonCommon::getPt ( std::span< const xAOD::TrackParticle *const > tracks)
static

Definition at line 17 of file JpsiUpsilonCommon.cxx.

18 {
19 if (tracks.empty()) {
20 return 0.0;
21 }
22
23 // Start with the four-momentum of the first track
24 auto momentum = tracks[0]->genvecP4();
25
26 // Add the rest
27 for (size_t i = 1; i < tracks.size(); ++i) {
28 momentum += tracks[i]->genvecP4();
29 }
30
31 return std::sqrt(momentum.Perp2());
32 }

◆ isContainedIn() [1/2]

Definition at line 69 of file JpsiUpsilonCommon.cxx.

69 {
70 return std::find_if(theColl->begin(), theColl->end(), [theTrack](const xAOD::Muon* muon){
71 return muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) == theTrack;
72 }) != theColl->end();
73 }
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.
Muon_v1 Muon
Reference the current persistent version:

◆ isContainedIn() [2/2]

bool Analysis::JpsiUpsilonCommon::isContainedIn ( const xAOD::TrackParticle * theTrack,
std::span< const xAOD::TrackParticle *const > theColl )
staticnoexcept

Definition at line 65 of file JpsiUpsilonCommon.cxx.

65 {
66 return std::find(theColl.begin(), theColl.end(), theTrack) != theColl.end();
67 }

◆ RelinkVertexMuons()

Definition at line 151 of file JpsiUpsilonCommon.cxx.

151 {
152 using MuonLink = ElementLink<xAOD::MuonContainer>;
153 using MuonLinkVector = std::vector<MuonLink>;
154 static const SG::AuxElement::Decorator<MuonLinkVector> muonLinksDecor("MuonLinks");
155 const MuonLinkVector &mlinksold = muonLinksDecor(*vtx);
156 auto size = mlinksold.size();
157 MuonLinkVector newmulinks;
158 for(size_t i = 0; i<size; i++){
159 const xAOD::Muon* mylink= *(mlinksold[i]);
160 for(const xAOD::MuonContainer* mucol : muoncols){
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 );
166 break;
167 }
168 }
169 }
170 if(size != newmulinks.size()){
171 throw std::runtime_error("JpsiUpsilonCommon::RelinkVertexMuons: Could not relink all tracks");
172 }
173 muonLinksDecor(*vtx) = std::move(newmulinks);
174 }
std::vector< MuonLink > MuonLinkVector
ElementLink< xAOD::MuonContainer > MuonLink
size_t size() const
Number of registered mappings.
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".

◆ RelinkVertexTracks()

Definition at line 129 of file JpsiUpsilonCommon.cxx.

129 {
130 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
131 auto size = vtx->trackParticleLinks().size();
132 for(size_t i = 0; i<size; i++){
133 const xAOD::TrackParticle* mylink= *(vtx->trackParticleLinks()[i]);
134 for(const xAOD::TrackParticleContainer* trkcol : trkcols){
135 auto itr = std::find(trkcol->begin(), trkcol->end(), mylink);
136 if(itr != trkcol->end()){
137 auto mylink=vtx->trackParticleLinks()[i];
138 mylink.setStorableObject(*trkcol, true);
139 newLinkVector.push_back( mylink );
140 break;
141 }
142 }
143 }
144 if(size != newLinkVector.size()){
145 throw std::runtime_error("JpsiUpsilonCommon::RelinkVertexTracks: Could not relink all tracks");
146 }
147 vtx->clearTracks();
148 vtx->setTrackParticleLinks( newLinkVector );
149 }
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.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".

The documentation for this class was generated from the following files: