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 37 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 92 of file MkFitGeometryESProducer.cc.

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

Referenced by add_current().

92  {
93  if (x > y)
94  std::swap(x, y);
95  bool handled = false;
96  for (auto i = m_coverage.begin(); i != m_coverage.end(); ++i) {
97  if (y < i->x) { // fully on 'left'
98  m_coverage.insert(i, {x, y});
99  handled = true;
100  break;
101  } else if (x > i->y) { // fully on 'right'
102  continue;
103  } else if (x < i->x) { // sticking out on 'left'
104  i->x = x;
105  handled = true;
106  break;
107  } else if (y > i->y) { // sticking out on 'right'
108  i->y = y;
109  // check for overlap with the next interval, potentially merge
110  auto j = i;
111  ++j;
112  if (j != m_coverage.end() && i->y >= j->x) {
113  i->y = j->y;
114  m_coverage.erase(j);
115  }
116  handled = true;
117  break;
118  } else { // contained in current interval
119  handled = true;
120  break;
121  }
122  }
123  if (!handled) {
124  m_coverage.push_back({x, y});
125  }
126 }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)

◆ extend_current()

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

◆ find_gap()

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

Definition at line 135 of file MkFitGeometryESProducer.cc.

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

135  {
136  auto i = m_coverage.begin();
137  while (i != m_coverage.end()) {
138  auto j = i;
139  ++j;
140  if (j != m_coverage.end()) {
141  if (j->x - i->y > eps) {
142  itvl = {i->y, j->x};
143  return true;
144  }
145  i = j;
146  } else {
147  break;
148  }
149  }
150  return false;
151 }

◆ print_gaps()

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

Definition at line 153 of file MkFitGeometryESProducer.cc.

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

153  {
154  auto i = m_coverage.begin();
155  while (i != m_coverage.end()) {
156  auto j = i;
157  ++j;
158  if (j != m_coverage.end()) {
159  ostr << "(" << i->y << ", " << j->x << ")->" << j->x - i->y;
160  i = j;
161  } else {
162  break;
163  }
164  }
165 }

◆ reset_current()

void MkFitGeometryESProducer::GapCollector::reset_current ( )
inline

◆ sqrt_elements()

void MkFitGeometryESProducer::GapCollector::sqrt_elements ( )

Definition at line 128 of file MkFitGeometryESProducer.cc.

References mathSSE::sqrt().

128  {
129  for (auto &itvl : m_coverage) {
130  itvl.x = std::sqrt(itvl.x);
131  itvl.y = std::sqrt(itvl.y);
132  }
133 }
T sqrt(T t)
Definition: SSEVec.h:19

Member Data Documentation

◆ m_coverage

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

Definition at line 55 of file MkFitGeometryESProducer.cc.

Referenced by add_interval().

◆ m_current

Interval MkFitGeometryESProducer::GapCollector::m_current

Definition at line 56 of file MkFitGeometryESProducer.cc.

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