ATLAS Offline Software
Loading...
Searching...
No Matches
MomentumHelpers.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8#ifndef COLUMNAR_CORE_MOMENTUM_HELPERS_H
9#define COLUMNAR_CORE_MOMENTUM_HELPERS_H
10
13
14namespace columnar
15{
20
22 inline
23 double deltaPhi( double phiA, double phiB )
24 {
25 return -remainder( -phiA + phiB, 2*M_PI );
26 }
27
28
29
31 template<ContainerIdConcept CI1,ContainerIdConcept CI2,typename CM>
32 double deltaRapidity( const MomentumAccessors<CI1,CM>& momAcc1, ObjectId<CI1,CM> p1, const MomentumAccessors<CI2,CM>& momAcc2, ObjectId<CI2,CM> p2, bool useRapidity=true )
33 {
34 if (useRapidity)
35 return momAcc1.rapidity(p1) - momAcc2.rapidity(p2);
36 else
37 return momAcc1.eta(p1) - momAcc2.eta(p2);
38 }
39
40
41
45 template<ContainerIdConcept CI1,ContainerIdConcept CI2,typename CM>
47 double dR, bool useRapidity=true )
48 {
49 const double dPhi = std::abs( xAOD::P4Helpers::deltaPhi(momAcc1.phi(p1),momAcc2.phi(p2)) ); // in [-pi,pi)
50 if ( CxxUtils::fpcompare::greater(dPhi,dR) ) return false; // <==
51 const double dRapidity = std::abs( deltaRapidity(momAcc1,p1,momAcc2,p2,useRapidity) );
52 if ( CxxUtils::fpcompare::greater(dRapidity,dR) ) return false; // <==
53 const double deltaR2 = dRapidity*dRapidity + dPhi*dPhi;
54 if ( CxxUtils::fpcompare::greater(deltaR2,dR*dR) ) return false; // <==
55 return true;
56 }
57}
58
59#endif
#define M_PI
a handle to hold a IMomentumAccessors object
double rapidity(ObjectId< CI, CM > object) const
double phi(ObjectId< CI, CM > object) const
double eta(ObjectId< CI, CM > object) const
a class representing a single object (electron, muons, etc.)
std::vector< std::string > remainder(const std::vector< std::string > &v1, const std::vector< std::string > &v2)
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition fpcompare.h:140
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
bool isInDeltaR(const MomentumAccessors< CI1, CM > &momAcc1, ObjectId< CI1, CM > p1, const MomentumAccessors< CI2, CM > &momAcc2, ObjectId< CI2, CM > p2, double dR, bool useRapidity=true)
Check if 2 particles are in a cone.
double deltaRapidity(const MomentumAccessors< CI1, CM > &momAcc1, ObjectId< CI1, CM > p1, const MomentumAccessors< CI2, CM > &momAcc2, ObjectId< CI2, CM > p2, bool useRapidity=true)
Computes efficiently .
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[