CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Public Attributes
MkFitGeometryESProducer::GapCollector Struct Reference

Classes

struct  Interval
 

Public Member Functions

void add_current ()
 
void add_interval (float x, float y)
 
void extend_current (float q)
 
bool find_gap (Interval &itvl, float eps)
 
void print_gaps (std::ostream &ostr)
 
void reset_current ()
 
void sqrt_elements ()
 

Public Attributes

std::list< Intervalm_coverage
 
Interval m_current
 

Detailed Description

Definition at line 39 of file MkFitGeometryESProducer.cc.

Member Function Documentation

◆ add_current()

void MkFitGeometryESProducer::GapCollector::add_current ( )
inline

◆ add_interval()

void MkFitGeometryESProducer::GapCollector::add_interval ( float  x,
float  y 
)

Definition at line 111 of file MkFitGeometryESProducer.cc.

References mps_fire::i, dqmiolumiharvest::j, m_coverage, edm::swap(), x, and y.

Referenced by add_current().

111  {
112  if (x > y)
113  std::swap(x, y);
114  bool handled = false;
115  for (auto i = m_coverage.begin(); i != m_coverage.end(); ++i) {
116  if (y < i->x) { // fully on 'left'
117  m_coverage.insert(i, {x, y});
118  handled = true;
119  break;
120  } else if (x > i->y) { // fully on 'right'
121  continue;
122  } else if (x < i->x) { // sticking out on 'left'
123  i->x = x;
124  handled = true;
125  break;
126  } else if (y > i->y) { // sticking out on 'right'
127  i->y = y;
128  // check for overlap with the next interval, potentially merge
129  auto j = i;
130  ++j;
131  if (j != m_coverage.end() && i->y >= j->x) {
132  i->y = j->y;
133  m_coverage.erase(j);
134  }
135  handled = true;
136  break;
137  } else { // contained in current interval
138  handled = true;
139  break;
140  }
141  }
142  if (!handled) {
143  m_coverage.push_back({x, y});
144  }
145 }
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112

◆ extend_current()

void MkFitGeometryESProducer::GapCollector::extend_current ( float  q)
inline

◆ find_gap()

bool MkFitGeometryESProducer::GapCollector::find_gap ( Interval itvl,
float  eps 
)

Definition at line 154 of file MkFitGeometryESProducer.cc.

References HLT_2024v14_cff::eps, mps_fire::i, and dqmiolumiharvest::j.

154  {
155  auto i = m_coverage.begin();
156  while (i != m_coverage.end()) {
157  auto j = i;
158  ++j;
159  if (j != m_coverage.end()) {
160  if (j->x - i->y > eps) {
161  itvl = {i->y, j->x};
162  return true;
163  }
164  i = j;
165  } else {
166  break;
167  }
168  }
169  return false;
170 }

◆ print_gaps()

void MkFitGeometryESProducer::GapCollector::print_gaps ( std::ostream &  ostr)

Definition at line 172 of file MkFitGeometryESProducer.cc.

References mps_fire::i, and dqmiolumiharvest::j.

172  {
173  auto i = m_coverage.begin();
174  while (i != m_coverage.end()) {
175  auto j = i;
176  ++j;
177  if (j != m_coverage.end()) {
178  ostr << "(" << i->y << ", " << j->x << ")->" << j->x - i->y;
179  i = j;
180  } else {
181  break;
182  }
183  }
184 }

◆ reset_current()

void MkFitGeometryESProducer::GapCollector::reset_current ( )
inline

◆ sqrt_elements()

void MkFitGeometryESProducer::GapCollector::sqrt_elements ( )

Definition at line 147 of file MkFitGeometryESProducer.cc.

References mathSSE::sqrt().

147  {
148  for (auto &itvl : m_coverage) {
149  itvl.x = std::sqrt(itvl.x);
150  itvl.y = std::sqrt(itvl.y);
151  }
152 }
T sqrt(T t)
Definition: SSEVec.h:23

Member Data Documentation

◆ m_coverage

std::list<Interval> MkFitGeometryESProducer::GapCollector::m_coverage

Definition at line 57 of file MkFitGeometryESProducer.cc.

Referenced by add_interval().

◆ m_current

Interval MkFitGeometryESProducer::GapCollector::m_current

Definition at line 58 of file MkFitGeometryESProducer.cc.

Referenced by add_current(), extend_current(), and reset_current().