ATLAS Offline Software
Loading...
Searching...
No Matches
Utils Namespace Reference

Functions

double deltaPhi (double phi1, double phi2)
double deltaR2 (double eta1, double eta2, double phi1, double phi2)
double deltaR (double eta1, double eta2, double phi1, double phi2)
void findNearestPoint (const Amg::Vector3D &inputPos, const Trk::CaloExtension *caloExtension, int &nearestIdx, Amg::Vector3D &nearestPos, Amg::Vector3D &nearestMom)
double z0wrtPV (const xAOD::TrackParticle *trk, const xAOD::Vertex *vtx)
 Provide the trk DCA w.r.t. the PV.
const xAOD::VertexselectPV (SG::ReadHandle< xAOD::VertexContainer > &container)
 Finds the Primary Vertex.
const xAOD::JetfindLeadingJet (SG::ReadHandle< xAOD::JetContainer > &container)
 Find leading jet.

Function Documentation

◆ deltaPhi()

double Utils::deltaPhi ( double phi1,
double phi2 )

Definition at line 11 of file CaloCellSelectorUtils.cxx.

11 {
12 double dPhi = std::fabs(phi1 - phi2);
13 if (dPhi > M_PI) dPhi = 2 * M_PI - dPhi;
14 return dPhi;
15 }
#define M_PI

◆ deltaR()

double Utils::deltaR ( double eta1,
double eta2,
double phi1,
double phi2 )

Definition at line 23 of file CaloCellSelectorUtils.cxx.

23{ return std::sqrt(deltaR2(eta1, eta2, phi1, phi2)); }
double deltaR2(double eta1, double eta2, double phi1, double phi2)

◆ deltaR2()

double Utils::deltaR2 ( double eta1,
double eta2,
double phi1,
double phi2 )

Definition at line 17 of file CaloCellSelectorUtils.cxx.

17 {
18 double dPhi = deltaPhi(phi1, phi2);
19 double dEta = std::fabs(eta1 - eta2);
20 return dEta * dEta + dPhi * dPhi;
21 }
double deltaPhi(double phi1, double phi2)

◆ findLeadingJet()

const xAOD::Jet * Utils::findLeadingJet ( SG::ReadHandle< xAOD::JetContainer > & container)

Find leading jet.

Definition at line 26 of file Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/Utils.cxx.

26 {
27 auto compareJetPt = [](const auto& jet1, const auto& jet2) { return jet1->pt() < jet2->pt(); };
28
29 const auto leadingJet = std::max_element(container->begin(), container->end(), compareJetPt);
30 if (leadingJet == container->end()) {
31 return nullptr;
32 }
33
34 return *leadingJet;
35}

◆ findNearestPoint()

void Utils::findNearestPoint ( const Amg::Vector3D & inputPos,
const Trk::CaloExtension * caloExtension,
int & nearestIdx,
Amg::Vector3D & nearestPos,
Amg::Vector3D & nearestMom )

Definition at line 25 of file CaloCellSelectorUtils.cxx.

26 {
27 const std::vector<Trk::CurvilinearParameters>& intersections = caloExtension->caloLayerIntersections();
28 int nPts = intersections.size();
29
30 int idxL, idxR, idxMid;
31 Amg::Vector3D pos(0, 0, 0), mom(0, 0, 0); // initialization should be(?) unnecessary, just to suppress scary warning msg...
32 Amg::Vector3D posL(0, 0, 0), momL(0, 0, 0);
33 Amg::Vector3D posR(0, 0, 0), momR(0, 0, 0);
34
35 // find nearest crossing point
36 idxL = 0;
37 idxR = nPts - 1;
38 while ((idxR - idxL) > 1) {
39 idxMid = (idxL + idxR) / 2;
40 pos = intersections[idxMid].position();
41 mom = intersections[idxMid].momentum();
42
43 if ((inputPos - pos).dot(mom) > 0) {
44 idxL = idxMid;
45 std::swap(posL, pos);
46 std::swap(momL, mom);
47 } else {
48 idxR = idxMid;
49 std::swap(posR, pos);
50 std::swap(momR, mom);
51 }
52 }
53
54 if (idxL == 0) {
55 posL = intersections[0].position();
56 momL = intersections[0].momentum();
57 }
58 if (idxR == (nPts - 1)) {
59 posR = intersections[nPts - 1].position();
60 momR = intersections[nPts - 1].momentum();
61 }
62
63 float mag2L = (inputPos - posL).mag2();
64 float mag2R = (inputPos - posR).mag2();
65 nearestIdx = (mag2L < mag2R) ? idxL : idxR;
66 nearestPos = (mag2L < mag2R) ? posL : posR;
67 nearestMom = (mag2L < mag2R) ? momL : momR;
68 }
Scalar mag2() const
mag2 method - forward to squaredNorm()
const std::vector< CurvilinearParameters > & caloLayerIntersections() const
access to the intersections with the calorimeter layers.
Eigen::Matrix< double, 3, 1 > Vector3D
Definition dot.py:1
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)

◆ selectPV()

const xAOD::Vertex * Utils::selectPV ( SG::ReadHandle< xAOD::VertexContainer > & container)

Finds the Primary Vertex.

Definition at line 12 of file Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/Utils.cxx.

12 {
13 if (not container.isValid()) {
14 return nullptr;
15 }
16
17 for (const xAOD::Vertex* vtx : *container) {
18 if (vtx->vertexType() == xAOD::VxType::PriVtx) {
19 return vtx;
20 }
21 }
22
23 return nullptr;
24}
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ z0wrtPV()

double Utils::z0wrtPV ( const xAOD::TrackParticle * trk,
const xAOD::Vertex * vtx )

Provide the trk DCA w.r.t. the PV.

Definition at line 8 of file Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/Utils.cxx.

8 {
9 return (trk->z0() + trk->vz() - vtx->z()) * std::sin(trk->theta());
10}
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
float vz() const
The z origin for the parameters.
float z() const
Returns the z position.