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 42 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 123 of file MkFitGeometryESProducer.cc.

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

Referenced by add_current().

123  {
124  if (x > y)
125  std::swap(x, y);
126  bool handled = false;
127  for (auto i = m_coverage.begin(); i != m_coverage.end(); ++i) {
128  if (y < i->x) { // fully on 'left'
129  m_coverage.insert(i, {x, y});
130  handled = true;
131  break;
132  } else if (x > i->y) { // fully on 'right'
133  continue;
134  } else if (x < i->x) { // sticking out on 'left'
135  i->x = x;
136  handled = true;
137  break;
138  } else if (y > i->y) { // sticking out on 'right'
139  i->y = y;
140  // check for overlap with the next interval, potentially merge
141  auto j = i;
142  ++j;
143  if (j != m_coverage.end() && i->y >= j->x) {
144  i->y = j->y;
145  m_coverage.erase(j);
146  }
147  handled = true;
148  break;
149  } else { // contained in current interval
150  handled = true;
151  break;
152  }
153  }
154  if (!handled) {
155  m_coverage.push_back({x, y});
156  }
157 }
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 166 of file MkFitGeometryESProducer.cc.

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

166  {
167  auto i = m_coverage.begin();
168  while (i != m_coverage.end()) {
169  auto j = i;
170  ++j;
171  if (j != m_coverage.end()) {
172  if (j->x - i->y > eps) {
173  itvl = {i->y, j->x};
174  return true;
175  }
176  i = j;
177  } else {
178  break;
179  }
180  }
181  return false;
182 }

◆ print_gaps()

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

Definition at line 184 of file MkFitGeometryESProducer.cc.

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

184  {
185  auto i = m_coverage.begin();
186  while (i != m_coverage.end()) {
187  auto j = i;
188  ++j;
189  if (j != m_coverage.end()) {
190  ostr << "(" << i->y << ", " << j->x << ")->" << j->x - i->y;
191  i = j;
192  } else {
193  break;
194  }
195  }
196 }

◆ reset_current()

void MkFitGeometryESProducer::GapCollector::reset_current ( )
inline

◆ sqrt_elements()

void MkFitGeometryESProducer::GapCollector::sqrt_elements ( )

Definition at line 159 of file MkFitGeometryESProducer.cc.

References mathSSE::sqrt().

159  {
160  for (auto &itvl : m_coverage) {
161  itvl.x = std::sqrt(itvl.x);
162  itvl.y = std::sqrt(itvl.y);
163  }
164 }
T sqrt(T t)
Definition: SSEVec.h:23

Member Data Documentation

◆ m_coverage

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

Definition at line 60 of file MkFitGeometryESProducer.cc.

Referenced by add_interval().

◆ m_current

Interval MkFitGeometryESProducer::GapCollector::m_current

Definition at line 61 of file MkFitGeometryESProducer.cc.

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