CMS 3D CMS Logo

IsoDepositDirection.h
Go to the documentation of this file.
1 #ifndef RecoCandidate_IsoDepositDirection_H
2 #define RecoCandidate_IsoDepositDirection_H
3 
9 #include <cmath>
10 #include <sstream>
11 #include <iostream>
12 
15 
16 namespace reco {
17  namespace isodeposit {
18 
19  class Direction {
20  public:
21  struct Distance {
22  float deltaR;
24  bool operator<(const Distance& rd2) const { return deltaR < rd2.deltaR; };
25  };
26 
27  Direction(double eta = 0., double phi = 0.) : theEta(eta), thePhi(phi) {
28  while (thePhi < 0.0)
29  thePhi += 2 * M_PI;
30  while (thePhi >= 2 * M_PI)
31  thePhi -= 2 * M_PI;
32  };
33 
34  double eta() const { return theEta; }
35  double phi() const { return thePhi; }
36  double theta() const { return acos(tanh(theEta)); }
37 
38  inline bool operator==(const Direction& d2) {
39  if (this == &d2)
40  return true;
41  if (deltaR(d2) < 1.e-4)
42  return true;
43  return false;
44  }
45 
46  inline double deltaR2(const Direction& dir2) const { return reco::deltaR2(*this, dir2); }
47  inline double deltaR(const Direction& dir2) const { return reco::deltaR(*this, dir2); }
48 
49  Distance operator-(const Direction& dir2) const {
51  double dR = deltaR(dir2);
52  double dEta = theEta - dir2.eta();
53  double dPhi = reco::deltaPhi(thePhi, dir2.phi());
54 
55  result.relativeAngle = (dR > 1.e-4) ? atan2(dPhi, dEta) : 0.;
56  result.deltaR = dR;
57  return result;
58  }
59 
60  Direction operator+(const Distance& relDir) const {
61  double eta = theEta + relDir.deltaR * cos(relDir.relativeAngle);
62  double phi = thePhi + relDir.deltaR * sin(relDir.relativeAngle);
63  return Direction(eta, phi);
64  }
65 
66  std::string print() const {
67  std::ostringstream str;
68  str << " (Eta=" << theEta << ","
69  << "Phi=" << thePhi << ")";
70  return str.str();
71  }
72 
73  private:
74  float theEta;
75  float thePhi;
76  };
77 
78  } //namespace isodeposit
79 } //namespace reco
80 
81 #endif
reco::isodeposit::Direction::print
std::string print() const
Definition: IsoDepositDirection.h:66
L1TDiffHarvesting_cfi.dir2
dir2
Definition: L1TDiffHarvesting_cfi.py:12
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
reco::isodeposit::Direction::eta
double eta() const
Definition: IsoDepositDirection.h:34
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HLT_2018_cff.dEta
dEta
Definition: HLT_2018_cff.py:12289
reco::isodeposit::Direction::theta
double theta() const
Definition: IsoDepositDirection.h:36
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
deltaR.h
reco::isodeposit::Direction::operator==
bool operator==(const Direction &d2)
Definition: IsoDepositDirection.h:38
reco::isodeposit::Direction::deltaR2
double deltaR2(const Direction &dir2) const
Definition: IsoDepositDirection.h:46
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
reco::isodeposit::Direction::theEta
float theEta
Definition: IsoDepositDirection.h:74
HLT_2018_cff.dPhi
dPhi
Definition: HLT_2018_cff.py:12290
str
#define str(s)
Definition: TestProcessor.cc:48
reco::isodeposit::Direction::operator+
Direction operator+(const Distance &relDir) const
Definition: IsoDepositDirection.h:60
reco::isodeposit::Direction::operator-
Distance operator-(const Direction &dir2) const
Definition: IsoDepositDirection.h:49
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::isodeposit::Direction::deltaR
double deltaR(const Direction &dir2) const
Definition: IsoDepositDirection.h:47
reco::isodeposit::Direction::Distance::deltaR
float deltaR
Definition: IsoDepositDirection.h:22
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
reco::isodeposit::Direction::Distance::operator<
bool operator<(const Distance &rd2) const
Definition: IsoDepositDirection.h:24
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
reco::isodeposit::Direction::thePhi
float thePhi
Definition: IsoDepositDirection.h:75
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
mps_fire.result
result
Definition: mps_fire.py:303
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
reco::isodeposit::Direction::Direction
Direction(double eta=0., double phi=0.)
Definition: IsoDepositDirection.h:27
reco::isodeposit::Direction::Distance::relativeAngle
float relativeAngle
Definition: IsoDepositDirection.h:23
deltaPhi.h
reco::isodeposit::Direction::phi
double phi() const
Definition: IsoDepositDirection.h:35
reco::isodeposit::Direction::Distance
Definition: IsoDepositDirection.h:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37