ATLAS Offline Software
Loading...
Searching...
No Matches
MultiRange Class Reference

A MultiRange combines several Ranges. More...

#include <MultiRange.h>

Collaboration diagram for MultiRange:

Classes

class  const_identifier_factory
class  identifier_factory
 This factory is able to generate all possible identifiers, from a
fully bounded Range. More...

Public Types

using range_vector = std::vector<Range>
using element_type = ExpandedIdentifier::element_type
using size_type = ExpandedIdentifier::size_type
using const_iterator = range_vector::const_iterator

Public Member Functions

 MultiRange ()=default
 MultiRange (const Range &r, const Range &s)
 Construct a non-overlapping MultiRange from two overlapping ones.
void clear ()
void add (const Range &range)
void add (Range &&range)
 Add with move semantics.
void add (const ExpandedIdentifier &id)
 Add a Range made from a single ExpandedIdentifier.
void remove_range (const ExpandedIdentifier &id)
 Remove a Range made from a single ExpandedIdentifier.
Rangeback ()
 Get the last entered Range.
int match (const ExpandedIdentifier &id) const
 Match an identifier.
const Rangeoperator[] (size_type index) const
 Accessors.
size_type size () const
const_iterator begin () const
const_iterator end () const
size_type cardinality () const
 Computes a possible cardinality from all ranges.
size_type cardinalityUpTo (const ExpandedIdentifier &id) const
bool has_overlap () const
 Check if there are overlaps between any couple of Ranges.
identifier_factory factory_begin ()
const_identifier_factory factory_begin () const
identifier_factory factory_end ()
const_identifier_factory factory_end () const
void show (std::ostream &s=std::cout) const
void show (MsgStream &out) const
 operator std::string () const
 Generate a textual representation of the multirange using the input format.

Private Types

using id_vec = std::vector<ExpandedIdentifier>

Private Attributes

range_vector m_ranges

Friends

class identifier_factory
class const_identifier_factory

Detailed Description

A MultiRange combines several Ranges.

Definition at line 17 of file MultiRange.h.

Member Typedef Documentation

◆ const_iterator

using MultiRange::const_iterator = range_vector::const_iterator

Definition at line 22 of file MultiRange.h.

◆ element_type

◆ id_vec

using MultiRange::id_vec = std::vector<ExpandedIdentifier>
private

Definition at line 130 of file MultiRange.h.

◆ range_vector

using MultiRange::range_vector = std::vector<Range>

Definition at line 19 of file MultiRange.h.

◆ size_type

Constructor & Destructor Documentation

◆ MultiRange() [1/2]

MultiRange::MultiRange ( )
default

◆ MultiRange() [2/2]

MultiRange::MultiRange ( const Range & r,
const Range & s )

Construct a non-overlapping MultiRange from two overlapping ones.

Definition at line 13 of file MultiRange.cxx.

13 {
14 m_ranges.push_back (r);
15 m_ranges.push_back (s);
16}
range_vector m_ranges
Definition MultiRange.h:131
int r
Definition globals.cxx:22

Member Function Documentation

◆ add() [1/3]

void MultiRange::add ( const ExpandedIdentifier & id)

Add a Range made from a single ExpandedIdentifier.

Definition at line 40 of file MultiRange.cxx.

40 {
41 m_ranges.emplace_back (id);
42}

◆ add() [2/3]

void MultiRange::add ( const Range & range)

Definition at line 24 of file MultiRange.cxx.

24 {
25 // Add new range ONLY if an equivalent does NOT exist
26 if (std::ranges::find(m_ranges, range) == m_ranges.end()) {
27 m_ranges.push_back(range);
28 }
29}

◆ add() [3/3]

void MultiRange::add ( Range && range)

Add with move semantics.

Definition at line 32 of file MultiRange.cxx.

32 {
33 // Add new range ONLY if an equivalent does NOT exist
34 if (std::ranges::find(m_ranges, range) == m_ranges.end()) {
35 m_ranges.emplace_back (std::move(range));
36 }
37}

◆ back()

Range & MultiRange::back ( )

Get the last entered Range.

Definition at line 54 of file MultiRange.cxx.

54 {
55 return (m_ranges.back());
56}

◆ begin()

MultiRange::const_iterator MultiRange::begin ( ) const

Definition at line 76 of file MultiRange.cxx.

76 {
77 return (m_ranges.begin ());
78}

◆ cardinality()

MultiRange::size_type MultiRange::cardinality ( ) const

Computes a possible cardinality from all ranges.

Definition at line 84 of file MultiRange.cxx.

84 {
85 size_type init = 0;
86 return std::accumulate(m_ranges.begin(), m_ranges.end(), init,
87 [](size_type a, const Range& b){return a + b.cardinality();});
88}
static Double_t a
ExpandedIdentifier::size_type size_type
Definition MultiRange.h:21
init(v_theApp, v_rootStream=None)
Definition PyKernel.py:45

◆ cardinalityUpTo()

MultiRange::size_type MultiRange::cardinalityUpTo ( const ExpandedIdentifier & id) const

Definition at line 90 of file MultiRange.cxx.

90 {
91 // Loop over ranges in MultiRange and calculate hash for each
92 // range
93 size_type init = 0;
94 return std::accumulate(m_ranges.begin(), m_ranges.end(), init,
95 [&id](size_type a, const Range& b){return a + b.cardinalityUpTo(id);});
96}

◆ clear()

void MultiRange::clear ( )

Definition at line 19 of file MultiRange.cxx.

19 {
20 m_ranges.clear ();
21}

◆ end()

MultiRange::const_iterator MultiRange::end ( ) const

Definition at line 80 of file MultiRange.cxx.

80 {
81 return (m_ranges.end ());
82}

◆ factory_begin() [1/2]

MultiRange::identifier_factory MultiRange::factory_begin ( )

Definition at line 114 of file MultiRange.cxx.

114 {
115 const MultiRange& me = *this;
116 return (identifier_factory (me));
117}
This factory is able to generate all possible identifiers, from a fully bounded Range.
Definition MultiRange.h:30
MultiRange()=default

◆ factory_begin() [2/2]

MultiRange::const_identifier_factory MultiRange::factory_begin ( ) const

Definition at line 120 of file MultiRange.cxx.

120 {
121 const MultiRange& me = *this;
122 return (const_identifier_factory (me));
123}

◆ factory_end() [1/2]

MultiRange::identifier_factory MultiRange::factory_end ( )

Definition at line 126 of file MultiRange.cxx.

126 {
127 static const identifier_factory factory(*this);
128 return (factory);
129}

◆ factory_end() [2/2]

MultiRange::const_identifier_factory MultiRange::factory_end ( ) const

Definition at line 132 of file MultiRange.cxx.

132 {
133 static const const_identifier_factory factory;
134 return (factory);
135}

◆ has_overlap()

bool MultiRange::has_overlap ( ) const

Check if there are overlaps between any couple of Ranges.

Definition at line 100 of file MultiRange.cxx.

100 {
101 range_vector::size_type i;
102 range_vector::size_type j;
103 for (i = 0; i < m_ranges.size (); ++i) {
104 const Range& r = m_ranges[i];
105 for (j = i + 1; j < m_ranges.size (); ++j) {
106 const Range& s = m_ranges[j];
107 if (r.overlaps_with (s)) return (true);
108 }
109 }
110 return (false);
111}
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ match()

int MultiRange::match ( const ExpandedIdentifier & id) const

Match an identifier.

Definition at line 59 of file MultiRange.cxx.

59 {
60 bool result = std::ranges::any_of(m_ranges, [&id](const Range & r){return r.match(id);});
61 return result ? 1:0;
62}

◆ operator std::string()

MultiRange::operator std::string ( ) const

Generate a textual representation of the multirange using the input format.

Definition at line 256 of file MultiRange.cxx.

256 {
257 std::string result;
258 range_vector::size_type i{};
259 for ( ; i < m_ranges.size (); ++i){
260 if (i > 0) result += " | ";
261 const Range& r = m_ranges[i];
262 result += (std::string) r;
263 }
264 return (result);
265}

◆ operator[]()

const Range & MultiRange::operator[] ( MultiRange::size_type index) const

Accessors.

Definition at line 65 of file MultiRange.cxx.

65 {
66 static const Range null_range;
67 if (index >= m_ranges.size ()) return (null_range);
68 return (m_ranges[index]);
69}

◆ remove_range()

void MultiRange::remove_range ( const ExpandedIdentifier & id)

Remove a Range made from a single ExpandedIdentifier.

Definition at line 45 of file MultiRange.cxx.

45 {
46 // Remove all ranges for which id matches
47 [[maybe_unused]] auto erased = std::erase_if (m_ranges,
48 [&id] (const Range& r) { return r.match(id); });
49}
std::size_t erase_if(T_container &container, T_Func pred)

◆ show() [1/2]

void MultiRange::show ( MsgStream & out) const

Definition at line 249 of file MultiRange.cxx.

249 {
250 std::ostringstream os;
251 show(os);
252 out << os.str();
253}
void show(std::ostream &s=std::cout) const

◆ show() [2/2]

void MultiRange::show ( std::ostream & s = std::cout) const

Definition at line 240 of file MultiRange.cxx.

240 {
241 range_vector::size_type i;
242 for (i = 0; i < m_ranges.size (); ++i) {
243 if (i > 0) s << std::endl;
244 const Range& r = m_ranges[i];
245 r.show (s);
246 }
247}

◆ size()

MultiRange::size_type MultiRange::size ( ) const

Definition at line 72 of file MultiRange.cxx.

72 {
73 return (m_ranges.size ());
74}

◆ const_identifier_factory

friend class const_identifier_factory
friend

Definition at line 129 of file MultiRange.h.

◆ identifier_factory

friend class identifier_factory
friend

Definition at line 128 of file MultiRange.h.

Member Data Documentation

◆ m_ranges

range_vector MultiRange::m_ranges
private

Definition at line 131 of file MultiRange.h.


The documentation for this class was generated from the following files: