CMS 3D CMS Logo

List of all members | Public Member Functions
npstat::ArrayRange Struct Reference

#include <ArrayRange.h>

Inheritance diagram for npstat::ArrayRange:
npstat::BoxND< unsigned >

Public Member Functions

 ArrayRange ()
 
 ArrayRange (const ArrayShape &shape)
 
 ArrayRange (const unsigned *shape, unsigned shapeLen)
 
 ArrayRange (unsigned dim)
 
 ArrayRange (unsigned dim, const Interval< unsigned > &r1)
 
bool isCompatible (const ArrayShape &shape) const
 
bool isCompatible (const unsigned *shape, unsigned shapeLen) const
 
void lowerLimits (unsigned *limits, unsigned limitsLen) const
 
bool operator< (const ArrayRange &) const
 
void rangeLength (unsigned *range, unsigned rangeLen) const
 
unsigned long rangeSize () const
 
ArrayShape shape () const
 
ArrayRangestripOuterLayer ()
 
void upperLimits (unsigned *limits, unsigned limitsLen) const
 
- Public Member Functions inherited from npstat::BoxND< unsigned >
 BoxND ()
 
 BoxND (const BoxND< Num2 > &r)
 
 BoxND (const std::vector< Num2 > &limits)
 
 BoxND (const unsigned long dim)
 
 BoxND (const unsigned long dim, const Interval< unsigned > &v)
 
gs::ClassId classId () const
 
BoxNDcopyFrom (const BoxND< Num2 > &r)
 
BoxND< unsigned > & copyFrom (const BoxND< Num2 > &r)
 
unsigned long dim () const
 
BoxNDexpand (const double *scales, unsigned long lenScales)
 
BoxNDexpand (const std::vector< double > &scales)
 
BoxNDexpand (double r)
 
void getMidpoint (unsigned *coord, unsigned long coordLen) const
 
bool isInside (const Num2 *coord, unsigned long coordLen) const
 
bool isInsideLower (const Num2 *coord, unsigned long coordLen) const
 
bool isInsideUpper (const Num2 *coord, unsigned long coordLen) const
 
bool isInsideWithBounds (const Num2 *coord, unsigned long coordLen) const
 
BoxNDmoveToOrigin ()
 
BoxNDoperator*= (const std::vector< double > &scales)
 
BoxNDoperator*= (double r)
 
BoxNDoperator+= (const std::vector< Num2 > &shifts)
 
BoxND< unsigned > & operator+= (const std::vector< Num2 > &shifts)
 
BoxNDoperator-= (const std::vector< Num2 > &shifts)
 
BoxND< unsigned > & operator-= (const std::vector< Num2 > &shifts)
 
BoxNDoperator/= (const std::vector< double > &scales)
 
BoxNDoperator/= (double r)
 
double overlapFraction (const BoxND &r) const
 
unsigned overlapVolume (const BoxND &r) const
 
BoxND< unsigned > & shift (const Num2 *shifts, const unsigned long shiftsLen)
 
BoxNDshift (const Num2 *shifts, unsigned long lenShifts)
 
unsigned volume () const
 
bool write (std::ostream &of) const
 

Additional Inherited Members

- Static Public Member Functions inherited from npstat::BoxND< unsigned >
static BoxND allSpace (unsigned long ndim)
 
static const char * classname ()
 
static void restore (const gs::ClassId &id, std::istream &in, BoxND *box)
 
static BoxND sizeTwoBox (unsigned long ndim)
 
static BoxND unitBox (unsigned long ndim)
 
static unsigned version ()
 

Detailed Description

Utility class for use in certain array iterations

Definition at line 21 of file ArrayRange.h.

Constructor & Destructor Documentation

◆ ArrayRange() [1/5]

npstat::ArrayRange::ArrayRange ( )
inline

Definition at line 22 of file ArrayRange.h.

22 {}

◆ ArrayRange() [2/5]

npstat::ArrayRange::ArrayRange ( unsigned  dim)
inlineexplicit

Constructor from a given number of dimensions

Definition at line 25 of file ArrayRange.h.

25 : BoxND<unsigned>(dim) {}

◆ ArrayRange() [3/5]

npstat::ArrayRange::ArrayRange ( unsigned  dim,
const Interval< unsigned > &  r1 
)
inline

The given interval is repeated for every dimension

Definition at line 28 of file ArrayRange.h.

28 : BoxND<unsigned>(dim, r1) {}

◆ ArrayRange() [4/5]

npstat::ArrayRange::ArrayRange ( const ArrayShape shape)
inlineexplicit

Constructor which creates a range out of a shape which is used to represent the upper limit. The lower limit in each dimension is set to 0.

Definition at line 36 of file ArrayRange.h.

36 : BoxND<unsigned>(shape) {}

◆ ArrayRange() [5/5]

npstat::ArrayRange::ArrayRange ( const unsigned *  shape,
unsigned  shapeLen 
)

Definition at line 5 of file ArrayRange.cc.

5  {
6  if (imax) {
7  assert(ishape);
8  this->reserve(imax);
9  for (unsigned i = 0; i < imax; ++i)
10  this->push_back(Interval<unsigned>(ishape[i]));
11  }
12  }

References cms::cuda::assert(), and mps_fire::i.

Member Function Documentation

◆ isCompatible() [1/2]

bool npstat::ArrayRange::isCompatible ( const ArrayShape shape) const

Check for compatibility with a shape

Definition at line 14 of file ArrayRange.cc.

14  {
15  const unsigned imax = ishape.size();
16  return isCompatible(imax ? &ishape[0] : (unsigned*)nullptr, imax);
17  }

◆ isCompatible() [2/2]

bool npstat::ArrayRange::isCompatible ( const unsigned *  shape,
unsigned  shapeLen 
) const

Definition at line 19 of file ArrayRange.cc.

19  {
20  if (this->size() != imax)
21  return false;
22  if (imax) {
23  assert(ishape);
24  for (unsigned i = 0; i < imax; ++i)
25  if ((*this)[i].length() == 0U)
26  return true;
27  for (unsigned i = 0; i < imax; ++i)
28  if ((*this)[i].max() > ishape[i])
29  return false;
30  }
31  return true;
32  }

References cms::cuda::assert(), mps_fire::i, SiStripPI::max, findQualityFiles::size, and mitigatedMETSequence_cff::U.

◆ lowerLimits()

void npstat::ArrayRange::lowerLimits ( unsigned *  limits,
unsigned  limitsLen 
) const

Get the lower range limits into an array. The length of the limit array should be at least equal to the dimensionality.

Definition at line 86 of file ArrayRange.cc.

86  {
87  const unsigned imax = this->size();
88  if (limitsLen < imax)
90  "In npstat::ArrayRange::lowerLimits: "
91  "insufficient size of the output buffer");
92  if (imax) {
93  assert(limits);
94  const Interval<unsigned>* data = &(*this)[0];
95  for (unsigned i = 0; i < imax; ++i)
96  limits[i] = data[i].min();
97  }
98  }

References cms::cuda::assert(), data, mps_fire::i, TH2PolyOfflineMaps::limits, min(), and findQualityFiles::size.

◆ operator<()

bool npstat::ArrayRange::operator< ( const ArrayRange r) const

Operator for use with maps

Definition at line 34 of file ArrayRange.cc.

34  {
35  const unsigned mysize = this->size();
36  const unsigned othersize = r.size();
37  if (mysize < othersize)
38  return true;
39  if (mysize > othersize)
40  return false;
41  for (unsigned i = 0; i < mysize; ++i) {
42  const Interval<unsigned>& left((*this)[i]);
43  const Interval<unsigned>& right(r[i]);
44  if (left.min() < right.min())
45  return true;
46  if (left.min() > right.min())
47  return false;
48  if (left.max() < right.max())
49  return true;
50  if (left.max() > right.max())
51  return false;
52  }
53  return false;
54  }

References mps_fire::i, npstat::Interval< Numeric >::max(), npstat::Interval< Numeric >::min(), alignCSCRings::r, and findQualityFiles::size.

◆ rangeLength()

void npstat::ArrayRange::rangeLength ( unsigned *  range,
unsigned  rangeLen 
) const

Get the range into an array

Definition at line 114 of file ArrayRange.cc.

114  {
115  const unsigned imax = this->size();
116  if (limitsLen < imax)
118  "In npstat::ArrayRange::rangeLength: "
119  "insufficient size of the output buffer");
120  if (imax) {
121  assert(limits);
122  const Interval<unsigned>* data = &(*this)[0];
123  for (unsigned i = 0; i < imax; ++i)
124  limits[i] = data[i].length();
125  }
126  }

References cms::cuda::assert(), data, mps_fire::i, TH2PolyOfflineMaps::limits, and findQualityFiles::size.

◆ rangeSize()

unsigned long npstat::ArrayRange::rangeSize ( ) const

How many elements will be iterated over?

Definition at line 67 of file ArrayRange.cc.

67  {
68  unsigned long result = 0UL;
69  const unsigned imax = this->size();
70  if (imax) {
71  result = 1UL;
72  for (unsigned i = 0; i < imax; ++i)
73  result *= (*this)[i].length();
74  }
75  return result;
76  }

References mps_fire::i, mps_fire::result, and findQualityFiles::size.

◆ shape()

ArrayShape npstat::ArrayRange::shape ( void  ) const

The shape which corresponds to this range (i.e., max - min in all dimensions)

Definition at line 78 of file ArrayRange.cc.

78  {
79  const unsigned imax = this->size();
80  ArrayShape oshape(imax);
81  for (unsigned i = 0; i < imax; ++i)
82  oshape[i] = (*this)[i].length();
83  return oshape;
84  }

References mps_fire::i, and findQualityFiles::size.

◆ stripOuterLayer()

ArrayRange & npstat::ArrayRange::stripOuterLayer ( )

This method changes the range of this object so that for each dimension the minimum becomes larger by 1 and the maximum smaller by 1.

Definition at line 56 of file ArrayRange.cc.

56  {
57  const unsigned mysize = this->size();
58  for (unsigned i = 0; i < mysize; ++i) {
59  (*this)[i].setMin((*this)[i].min() + 1U);
60  const unsigned uplim = (*this)[i].max();
61  if (uplim)
62  (*this)[i].setMax(uplim - 1U);
63  }
64  return *this;
65  }

References mps_fire::i, min(), findQualityFiles::size, and mitigatedMETSequence_cff::U.

◆ upperLimits()

void npstat::ArrayRange::upperLimits ( unsigned *  limits,
unsigned  limitsLen 
) const

Get the upper range limits into an array

Definition at line 100 of file ArrayRange.cc.

100  {
101  const unsigned imax = this->size();
102  if (limitsLen < imax)
104  "In npstat::ArrayRange::upperLimits: "
105  "insufficient size of the output buffer");
106  if (imax) {
107  assert(limits);
108  const Interval<unsigned>* data = &(*this)[0];
109  for (unsigned i = 0; i < imax; ++i)
110  limits[i] = data[i].max();
111  }
112  }

References cms::cuda::assert(), data, mps_fire::i, TH2PolyOfflineMaps::limits, SiStripPI::max, and findQualityFiles::size.

npstat::ArrayRange::shape
ArrayShape shape() const
Definition: ArrayRange.cc:78
mps_fire.i
i
Definition: mps_fire.py:355
min
T min(T a, T b)
Definition: MathUtil.h:58
npstat::ArrayRange::isCompatible
bool isCompatible(const ArrayShape &shape) const
Definition: ArrayRange.cc:14
cms::cuda::assert
assert(be >=bs)
npstat::ArrayShape
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
npstat::NpstatInvalidArgument
Definition: NpstatException.h:38
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
alignCSCRings.r
r
Definition: alignCSCRings.py:93
TH2PolyOfflineMaps.limits
limits
Definition: TH2PolyOfflineMaps.py:45
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
npstat::BoxND< unsigned >::dim
unsigned long dim() const
Definition: BoxND.h:54
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
mps_fire.result
result
Definition: mps_fire.py:303
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443