ATLAS Offline Software
Functions
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. More...
 
const xAOD::VertexselectPV (SG::ReadHandle< xAOD::VertexContainer > &container)
 Finds the Primary Vertex. More...
 
const xAOD::JetfindLeadingJet (SG::ReadHandle< xAOD::JetContainer > &container)
 Find leading jet. More...
 

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  }

◆ 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)); }

◆ 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  }

◆ 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  }

◆ 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 }

◆ 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 }
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
Utils::deltaPhi
double deltaPhi(double phi1, double phi2)
Definition: CaloCellSelectorUtils.cxx:11
xAOD::TrackParticle_v1::vz
float vz() const
The z origin for the parameters.
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::TrackParticle_v1::z0
float z0() const
Returns the parameter.
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:530
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
xAOD::Vertex_v1::z
float z() const
Returns the z position.
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Trk::CaloExtension::caloLayerIntersections
const std::vector< CurvilinearParameters > & caloLayerIntersections() const
access to the intersections with the calorimeter layers.
Definition: CaloExtension.h:76
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:525
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition: AmgMatrixBasePlugin.h:30
xAOD::TrackParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Utils::deltaR2
double deltaR2(double eta1, double eta2, double phi1, double phi2)
Definition: CaloCellSelectorUtils.cxx:17