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 35 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 90 of file MkFitGeometryESProducer.cc.

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

Referenced by add_current().

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

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

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

◆ print_gaps()

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

Definition at line 151 of file MkFitGeometryESProducer.cc.

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

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

◆ reset_current()

void MkFitGeometryESProducer::GapCollector::reset_current ( )
inline

◆ sqrt_elements()

void MkFitGeometryESProducer::GapCollector::sqrt_elements ( )

Definition at line 126 of file MkFitGeometryESProducer.cc.

References mathSSE::sqrt().

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

Member Data Documentation

◆ m_coverage

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

Definition at line 53 of file MkFitGeometryESProducer.cc.

Referenced by add_interval().

◆ m_current

Interval MkFitGeometryESProducer::GapCollector::m_current

Definition at line 54 of file MkFitGeometryESProducer.cc.

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