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

Class to build pairs of XY values. More...

#include <PairBuilder.h>

Collaboration diagram for PairBuilder:

Public Types

typedef std::pair< int, int > XYPair
typedef std::vector< XYPairPairVector
typedef std::set< int > IntSet

Public Member Functions

 PairBuilder ()
 ~PairBuilder ()
void inputx (const int xstrip)
 Input a new x value.
void inputy (const int ystrip)
 Input a new y value.
void inputxy (const int ystrip)
 Input a new y value.
int numberOfPairs () const
 Return the number of XY pairs made.
const PairVectorpairs () const
 Return the pairs as a vector of pairs of integers.
float weight () const
 Return the 'weight', = 1/(number of pairs)
XYPair pairAtIndex (const int indx) const
 Return a specific XY pair at some vector index.
int xOfPairAt (const int indx) const
 Return the X value of a specific pair.
int yOfPairAt (const int indx) const
 Return the Y value of a specific pair.

Private Member Functions

Functions which form the pairs.
void formNewPairsWithX (const int xval)
void formNewPairsWithY (const int yval)

Private Attributes

Sets to hold x values and y values.
IntSet m_yvalues
IntSet m_xvalues
 use sets to avoid duplicate values
PairVector m_pairs
 Vector to hold the pairs produced.

Detailed Description

Class to build pairs of XY values.

Given a sequence of x and y integer values, PairBuilder will make all possible XY pairs and return the pairs in vector.

Definition at line 30 of file PairBuilder.h.

Member Typedef Documentation

◆ IntSet

typedef std::set<int> PairBuilder::IntSet

Definition at line 37 of file PairBuilder.h.

◆ PairVector

typedef std::vector< XYPair > PairBuilder::PairVector

Definition at line 36 of file PairBuilder.h.

◆ XYPair

typedef std::pair<int, int> PairBuilder::XYPair

Definition at line 35 of file PairBuilder.h.

Constructor & Destructor Documentation

◆ PairBuilder()

PairBuilder::PairBuilder ( )

Definition at line 15 of file PairBuilder.cxx.

16{
17}

◆ ~PairBuilder()

PairBuilder::~PairBuilder ( )

Definition at line 18 of file PairBuilder.cxx.

19{
20
21}

Member Function Documentation

◆ formNewPairsWithX()

void PairBuilder::formNewPairsWithX ( const int xval)
private

Definition at line 60 of file PairBuilder.cxx.

60 {
61 IntSet::iterator pthisY;
62 for(pthisY = m_yvalues.begin(); pthisY != m_yvalues.end(); ++pthisY) {
63 m_pairs.push_back(XYPair(xval,*pthisY));
64 }
65}
IntSet m_yvalues
Definition PairBuilder.h:61
PairVector m_pairs
Vector to hold the pairs produced.
Definition PairBuilder.h:66
std::pair< int, int > XYPair
Definition PairBuilder.h:35

◆ formNewPairsWithY()

void PairBuilder::formNewPairsWithY ( const int yval)
private

Definition at line 66 of file PairBuilder.cxx.

66 {
67 IntSet::iterator pthisX;
68 for(pthisX = m_xvalues.begin(); pthisX != m_xvalues.end(); ++pthisX) {
69 m_pairs.push_back(XYPair(*pthisX, yval));
70 }
71}
IntSet m_xvalues
use sets to avoid duplicate values
Definition PairBuilder.h:63

◆ inputx()

void PairBuilder::inputx ( const int xstrip)

Input a new x value.

Definition at line 23 of file PairBuilder.cxx.

23 {
24 bool xValueInserted = m_xvalues.insert(xstrip).second;
25 if ((not m_yvalues.empty()) and xValueInserted) formNewPairsWithX(xstrip);
26}
void formNewPairsWithX(const int xval)

◆ inputxy()

void PairBuilder::inputxy ( const int ystrip)

Input a new y value.

Definition at line 31 of file PairBuilder.cxx.

31 {
32 bool xValueInserted = m_xvalues.insert(xystrip).second;
33 bool yValueInserted = m_yvalues.insert(xystrip).second;
34 if ((not m_xvalues.empty()) and (not m_yvalues.empty()) and xValueInserted and yValueInserted) {
35 formNewPairsWithX(xystrip);
36 formNewPairsWithY(xystrip);
37 }
38}
void formNewPairsWithY(const int yval)

◆ inputy()

void PairBuilder::inputy ( const int ystrip)

Input a new y value.

Definition at line 27 of file PairBuilder.cxx.

27 {
28 bool yValueInserted = m_yvalues.insert(ystrip).second;
29 if ((not m_xvalues.empty()) and yValueInserted) formNewPairsWithY(ystrip);
30}

◆ numberOfPairs()

int PairBuilder::numberOfPairs ( ) const

Return the number of XY pairs made.

Definition at line 39 of file PairBuilder.cxx.

39 {
40 return m_pairs.size();
41}

◆ pairAtIndex()

PairBuilder::XYPair PairBuilder::pairAtIndex ( const int indx) const

Return a specific XY pair at some vector index.

Definition at line 48 of file PairBuilder.cxx.

48 {
49 return m_pairs.at(indx);
50}

◆ pairs()

const PairBuilder::PairVector & PairBuilder::pairs ( ) const

Return the pairs as a vector of pairs of integers.

Definition at line 42 of file PairBuilder.cxx.

42 {
43 return m_pairs;
44}

◆ weight()

float PairBuilder::weight ( ) const

Return the 'weight', = 1/(number of pairs)

Definition at line 45 of file PairBuilder.cxx.

45 {
46 return 1.0/numberOfPairs();
47}
int numberOfPairs() const
Return the number of XY pairs made.

◆ xOfPairAt()

int PairBuilder::xOfPairAt ( const int indx) const

Return the X value of a specific pair.

Definition at line 52 of file PairBuilder.cxx.

52 {
53 return pairAtIndex(indx).first;
54}
XYPair pairAtIndex(const int indx) const
Return a specific XY pair at some vector index.

◆ yOfPairAt()

int PairBuilder::yOfPairAt ( const int indx) const

Return the Y value of a specific pair.

Definition at line 56 of file PairBuilder.cxx.

56 {
57 return pairAtIndex(indx).second;
58}

Member Data Documentation

◆ m_pairs

PairVector PairBuilder::m_pairs
private

Vector to hold the pairs produced.

Definition at line 66 of file PairBuilder.h.

◆ m_xvalues

IntSet PairBuilder::m_xvalues
private

use sets to avoid duplicate values

Definition at line 63 of file PairBuilder.h.

◆ m_yvalues

IntSet PairBuilder::m_yvalues
private

Definition at line 61 of file PairBuilder.h.


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