Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
JCALIBRATE::JCombinatorics_t Struct Reference

PMT combinatorics for optical module. More...

#include <JCalibrateK40.hh>

Inheritance diagram for JCALIBRATE::JCombinatorics_t:
JTOOLS::JCombinatorics JCALIBRATE::JModel

Public Member Functions

 JCombinatorics_t ()
 Default constructor. More...
 
 JCombinatorics_t (const JModule &module)
 Constructor. More...
 
const JCombinatoricsgetCombinatorics () const
 Get combinatorics. More...
 
void configure (const int numberOfIndices)
 Configure. More...
 
size_t getNumberOfIndices () const
 Get number of indices. More...
 
size_t getNumberOfPairs () const
 Get number of pairs. More...
 
int getIndex (const int first, const int second) const
 Get index of pair of indices. More...
 
int getIndex (const pair_type &pair) const
 Get index of pair. More...
 
const pair_typegetPair (const int index) const
 Get pair of indices for given index. More...
 
template<class JComparator_t >
void sort (JComparator_t comparator)
 Sort address pairs. More...
 

Static Public Member Functions

static int getSign (const int first, const int second)
 Sign of pair of indices. More...
 
static int getSign (const pair_type &pair)
 Sign of pair of indices. More...
 

Protected Attributes

std::vector< pair_typezbuf1D
 
std::vector< std::vector< int > > zbuf2D
 

Detailed Description

PMT combinatorics for optical module.

Definition at line 102 of file JCalibrateK40.hh.

Constructor & Destructor Documentation

◆ JCombinatorics_t() [1/2]

JCALIBRATE::JCombinatorics_t::JCombinatorics_t ( )
inline

Default constructor.

Definition at line 108 of file JCalibrateK40.hh.

109  {}

◆ JCombinatorics_t() [2/2]

JCALIBRATE::JCombinatorics_t::JCombinatorics_t ( const JModule module)
inline

Constructor.

Parameters
moduledetector module

Definition at line 117 of file JCalibrateK40.hh.

118  {
119  this->configure(module.size());
120 
121  this->sort(JPairwiseComparator(module));
122  }
void configure(const int numberOfIndices)
Configure.
void sort(JComparator_t comparator)
Sort address pairs.
Auxiliary class to sort pairs of PMT addresses within optical module.

Member Function Documentation

◆ getCombinatorics()

const JCombinatorics& JTOOLS::JCombinatorics::getCombinatorics ( ) const
inlineinherited

Get combinatorics.

Returns
combinatorics

Definition at line 89 of file JCombinatorics.hh.

90  {
91  return *this;
92  }

◆ configure()

void JTOOLS::JCombinatorics::configure ( const int  numberOfIndices)
inlineinherited

Configure.

Parameters
numberOfIndicesnumber of indices

Definition at line 100 of file JCombinatorics.hh.

101  {
102  zbuf1D.clear();
103 
104  zbuf2D.resize(numberOfIndices);
105 
106  for (int i = 0; i != numberOfIndices; ++i) {
107  zbuf2D[i].resize(numberOfIndices);
108  }
109 
110  for (int i = 0; i != numberOfIndices; ++i) {
111 
112  zbuf2D[i][i] = -1;
113 
114  for (int j = i; ++j != numberOfIndices; ) {
115 
116  zbuf2D[i][j] = zbuf1D.size();
117  zbuf2D[j][i] = zbuf1D.size();
118 
119  zbuf1D.push_back(pair_type(i,j));
120  }
121  }
122  }
std::vector< pair_type > zbuf1D
std::vector< std::vector< int > > zbuf2D
JCombinatorics::pair_type pair_type
int j
Definition: JPolint.hh:792

◆ getNumberOfIndices()

size_t JTOOLS::JCombinatorics::getNumberOfIndices ( ) const
inlineinherited

Get number of indices.

Returns
number of indices

Definition at line 130 of file JCombinatorics.hh.

131  {
132  return zbuf2D.size();
133  }

◆ getNumberOfPairs()

size_t JTOOLS::JCombinatorics::getNumberOfPairs ( ) const
inlineinherited

Get number of pairs.

Returns
number of pairs

Definition at line 141 of file JCombinatorics.hh.

142  {
143  return zbuf1D.size();
144  }

◆ getIndex() [1/2]

int JTOOLS::JCombinatorics::getIndex ( const int  first,
const int  second 
) const
inlineinherited

Get index of pair of indices.

Parameters
firstfirst address
secondsecond address
Returns
index (-1 if first and second address are equal)

Definition at line 154 of file JCombinatorics.hh.

155  {
156  return zbuf2D[first][second];
157  }

◆ getIndex() [2/2]

int JTOOLS::JCombinatorics::getIndex ( const pair_type pair) const
inlineinherited

Get index of pair.

Parameters
pairpair
Returns
index (-1 if first and second address are equal)

Definition at line 166 of file JCombinatorics.hh.

167  {
168  return getIndex(pair.first, pair.second);
169  }
int getIndex(const int first, const int second) const
Get index of pair of indices.

◆ getPair()

const pair_type& JTOOLS::JCombinatorics::getPair ( const int  index) const
inlineinherited

Get pair of indices for given index.

Parameters
indexindex
Returns
pair of indices

Definition at line 178 of file JCombinatorics.hh.

179  {
180  return zbuf1D[index];
181  }

◆ sort()

template<class JComparator_t >
void JTOOLS::JCombinatorics::sort ( JComparator_t  comparator)
inlineinherited

Sort address pairs.

Parameters
comparatorcomparator for pairs

Definition at line 190 of file JCombinatorics.hh.

191  {
192  std::stable_sort(zbuf1D.begin(), zbuf1D.end(), comparator);
193 
194  for (int i = 0; i != (int) zbuf1D.size(); ++i) {
195 
196  const pair_type pair = zbuf1D[i];
197 
198  zbuf2D[pair.first][pair.second] = i;
199  zbuf2D[pair.second][pair.first] = i;
200  }
201 
202  for (int i = 0; i != (int) zbuf2D.size(); ++i) {
203  zbuf2D[i][i] = -1;
204  }
205  }

◆ getSign() [1/2]

static int JTOOLS::JCombinatorics::getSign ( const int  first,
const int  second 
)
inlinestaticinherited

Sign of pair of indices.

Parameters
firstfirst address
secondsecond address
Returns
+1 if second >= first; else -1

Definition at line 215 of file JCombinatorics.hh.

216  {
217  return (second >= first ? +1 : -1);
218  }

◆ getSign() [2/2]

static int JTOOLS::JCombinatorics::getSign ( const pair_type pair)
inlinestaticinherited

Sign of pair of indices.

Parameters
pairpair of indices
Returns
+1 if second >= first; else -1

Definition at line 227 of file JCombinatorics.hh.

228  {
229  return getSign(pair.first, pair.second);
230  }
static int getSign(const int first, const int second)
Sign of pair of indices.

Member Data Documentation

◆ zbuf1D

std::vector<pair_type> JTOOLS::JCombinatorics::zbuf1D
protectedinherited

Definition at line 234 of file JCombinatorics.hh.

◆ zbuf2D

std::vector<std::vector<int> > JTOOLS::JCombinatorics::zbuf2D
protectedinherited

Definition at line 235 of file JCombinatorics.hh.


The documentation for this struct was generated from the following file: