ATLAS Offline Software
Loading...
Searching...
No Matches
PairBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
12
13#include "PairBuilder.h"
14
15PairBuilder :: PairBuilder()
16{
17}
18PairBuilder ::~ PairBuilder()
19{
20
21}
22
23void PairBuilder ::inputx(const int xstrip){
24 bool xValueInserted = m_xvalues.insert(xstrip).second;
25 if ((not m_yvalues.empty()) and xValueInserted) formNewPairsWithX(xstrip);
26}
27void PairBuilder ::inputy(const int ystrip){
28 bool yValueInserted = m_yvalues.insert(ystrip).second;
29 if ((not m_xvalues.empty()) and yValueInserted) formNewPairsWithY(ystrip);
30}
31void PairBuilder ::inputxy(const int xystrip){
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}
40 return m_pairs.size();
41}
43 return m_pairs;
44}
45float PairBuilder::weight() const {
46 return 1.0/numberOfPairs();
47}
49 return m_pairs.at(indx);
50}
51
52int PairBuilder::xOfPairAt(const int indx) const {
53 return pairAtIndex(indx).first;
54}
55
56int PairBuilder::yOfPairAt(const int indx) const {
57 return pairAtIndex(indx).second;
58}
59
60void PairBuilder::formNewPairsWithX(const int xval){
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}
66void PairBuilder::formNewPairsWithY(const int yval){
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}
72
73std::ostream & operator<< (std::ostream &os, const PairBuilder &e) {
74 int arrSize = e.numberOfPairs();
75 for(int i=0; i<arrSize;++i){
76 os << "( " << e.xOfPairAt(i) << ", " << e.yOfPairAt(i) << " )" << std::endl;
77 }
78 return os;
79}
std::ostream & operator<<(std::ostream &os, const PairBuilder &e)
Overloaded "operator <<" for output of PairBuilder objects.
Contains class declaration for PairBuilder, and overloaded "operator <<" for output of same.
Class to build pairs of XY values.
Definition PairBuilder.h:30
int xOfPairAt(const int indx) const
Return the X value of a specific pair.
IntSet m_yvalues
Definition PairBuilder.h:61
void formNewPairsWithY(const int yval)
int numberOfPairs() const
Return the number of XY pairs made.
const PairVector & pairs() const
Return the pairs as a vector of pairs of integers.
float weight() const
Return the 'weight', = 1/(number of pairs)
int yOfPairAt(const int indx) const
Return the Y value of a specific pair.
std::vector< XYPair > PairVector
Definition PairBuilder.h:36
void formNewPairsWithX(const int xval)
PairVector m_pairs
Vector to hold the pairs produced.
Definition PairBuilder.h:66
std::pair< int, int > XYPair
Definition PairBuilder.h:35
XYPair pairAtIndex(const int indx) const
Return a specific XY pair at some vector index.
IntSet m_xvalues
use sets to avoid duplicate values
Definition PairBuilder.h:63