CMS 3D CMS Logo

CaloRectangle.h
Go to the documentation of this file.
1 #ifndef RecoCaloTools_Navigation_CaloRectangle_H
2 #define RecoCaloTools_Navigation_CaloRectangle_H
3 
6 
7 /*
8  * CaloRectangle is a class to create a rectangular range of DetIds around a
9  * central DetId. Meant to be used for range-based loops to calculate cluster
10  * shape variables.
11  */
12 
13 struct CaloRectangle {
14  const int iEtaOrIXMin;
15  const int iEtaOrIXMax;
16  const int iPhiOrIYMin;
17  const int iPhiOrIYMax;
18 
19  template <class T>
20  auto operator()(T home, CaloTopology const& topology);
21 };
22 
23 template <class T>
24 T offsetBy(T start, CaloSubdetectorTopology const& topo, int dIEtaOrIX, int dIPhiOrIY) {
25  for (int i = 0; i < std::abs(dIEtaOrIX) && start != T(0); i++) {
26  start = dIEtaOrIX > 0 ? topo.goEast(start) : topo.goWest(start);
27  }
28 
29  for (int i = 0; i < std::abs(dIPhiOrIY) && start != T(0); i++) {
30  start = dIPhiOrIY > 0 ? topo.goNorth(start) : topo.goSouth(start);
31  }
32  return start;
33 }
34 
35 template <class T>
37 public:
38  class Iterator {
39  public:
40  Iterator(T const& home,
41  int iEtaOrIX,
42  int iPhiOrIY,
43  CaloRectangle const rectangle,
46 
50  iEtaOrIX_++;
51  } else
52  ++iPhiOrIY_;
53  return *this;
54  }
55 
56  int iEtaOrIX() const { return iEtaOrIX_; }
57  int iPhiOrIY() const { return iPhiOrIY_; }
58 
59  bool operator==(Iterator const& other) const {
60  return iEtaOrIX_ == other.iEtaOrIX() && iPhiOrIY_ == other.iPhiOrIY();
61  }
62  bool operator!=(Iterator const& other) const {
63  return iEtaOrIX_ != other.iEtaOrIX() || iPhiOrIY_ != other.iPhiOrIY();
64  }
65 
67 
68  private:
69  const T home_;
70 
73 
74  int iEtaOrIX_;
75  int iPhiOrIY_;
76  };
77 
78 public:
80  : home_(home), rectangle_(rectangle), topology_(*topology.getSubdetectorTopology(home)) {}
81 
84 
87 
88 private:
89  const T home_;
92 };
93 
94 template <class T>
96  return CaloRectangleRange<T>(*this, home, topology);
97 }
98 
99 #endif
mps_fire.i
i
Definition: mps_fire.py:428
start
Definition: start.py:1
CaloSubdetectorTopology::goNorth
virtual DetId goNorth(const DetId &id) const
Definition: CaloSubdetectorTopology.h:59
CaloRectangleRange
Definition: CaloRectangle.h:36
CaloRectangle::iEtaOrIXMin
const int iEtaOrIXMin
Definition: CaloRectangle.h:14
CaloRectangleRange::Iterator::rectangle_
const CaloRectangle rectangle_
Definition: CaloRectangle.h:71
CaloRectangleRange::CaloRectangleRange
CaloRectangleRange(CaloRectangle rectangle, T home, CaloTopology const &topology)
Definition: CaloRectangle.h:79
CaloRectangleRange::Iterator::Iterator
Iterator(T const &home, int iEtaOrIX, int iPhiOrIY, CaloRectangle const rectangle, CaloSubdetectorTopology const &topology)
Definition: CaloRectangle.h:40
CaloRectangleRange::Iterator::iPhiOrIY
int iPhiOrIY() const
Definition: CaloRectangle.h:57
CaloRectangle::operator()
auto operator()(T home, CaloTopology const &topology)
Definition: CaloRectangle.h:95
CaloRectangleRange::rectangle_
const CaloRectangle rectangle_
Definition: CaloRectangle.h:90
CaloRectangleRange::home_
const T home_
Definition: CaloRectangle.h:89
CaloTopology
Definition: CaloTopology.h:19
CaloRectangleRange::Iterator::operator==
bool operator==(Iterator const &other) const
Definition: CaloRectangle.h:59
CaloRectangle::iPhiOrIYMin
const int iPhiOrIYMin
Definition: CaloRectangle.h:16
cms::Iterator
TGeoIterator Iterator
Definition: DDFilteredView.h:54
CaloSubdetectorTopology::goSouth
virtual DetId goSouth(const DetId &id) const
Definition: CaloSubdetectorTopology.h:63
CaloRectangleRange::CaloRectangleRange
CaloRectangleRange(int size, T home, CaloTopology const &topology)
Definition: CaloRectangle.h:82
CaloRectangleRange::Iterator::topology_
CaloSubdetectorTopology const & topology_
Definition: CaloRectangle.h:72
ecaldqm::topology
const CaloTopology * topology(nullptr)
CaloRectangleRange::Iterator::operator*
T operator*() const
Definition: CaloRectangle.h:66
CaloRectangle::iPhiOrIYMax
const int iPhiOrIYMax
Definition: CaloRectangle.h:17
trackingPlots.other
other
Definition: trackingPlots.py:1467
CaloRectangle
Definition: CaloRectangle.h:13
CaloSubdetectorTopology::goEast
virtual DetId goEast(const DetId &id) const
Definition: CaloSubdetectorTopology.h:51
CaloRectangleRange::Iterator
Definition: CaloRectangle.h:38
CaloRectangleRange::Iterator::iPhiOrIY_
int iPhiOrIY_
Definition: CaloRectangle.h:75
CaloTopology::getSubdetectorTopology
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
CaloRectangleRange::Iterator::iEtaOrIX
int iEtaOrIX() const
Definition: CaloRectangle.h:56
CaloRectangleRange::topology_
CaloSubdetectorTopology const & topology_
Definition: CaloRectangle.h:91
CaloRectangleRange::Iterator::iEtaOrIX_
int iEtaOrIX_
Definition: CaloRectangle.h:74
offsetBy
T offsetBy(T start, CaloSubdetectorTopology const &topo, int dIEtaOrIX, int dIPhiOrIY)
Definition: CaloRectangle.h:24
CaloSubdetectorTopology
Definition: CaloSubdetectorTopology.h:17
CaloSubdetectorTopology::goWest
virtual DetId goWest(const DetId &id) const
Definition: CaloSubdetectorTopology.h:55
CaloRectangleRange::Iterator::operator++
Iterator & operator++()
Definition: CaloRectangle.h:47
CaloTopology.h
CaloSubdetectorTopology.h
CaloRectangleRange::begin
auto begin()
Definition: CaloRectangle.h:85
T
long double T
Definition: Basic3DVectorLD.h:48
CaloRectangle::iEtaOrIXMax
const int iEtaOrIXMax
Definition: CaloRectangle.h:15
CaloRectangleRange::Iterator::operator!=
bool operator!=(Iterator const &other) const
Definition: CaloRectangle.h:62
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
command_line.start
start
Definition: command_line.py:167
CaloRectangleRange::end
auto end()
Definition: CaloRectangle.h:86
CaloRectangleRange::Iterator::home_
const T home_
Definition: CaloRectangle.h:69
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443