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 (unsigned dim)
 
 ArrayRange (unsigned dim, const Interval< unsigned > &r1)
 
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
 
 ArrayRange (const ArrayShape &shape)
 
 ArrayRange (const unsigned *shape, unsigned shapeLen)
 
bool isCompatible (const ArrayShape &shape) const
 
bool isCompatible (const unsigned *shape, unsigned shapeLen) const
 
- Public Member Functions inherited from npstat::BoxND< unsigned >
 BoxND ()
 
 BoxND (const unsigned long dim)
 
 BoxND (const unsigned long dim, const Interval< unsigned > &v)
 
 BoxND (const std::vector< Num2 > &limits)
 
 BoxND (const BoxND< Num2 > &r)
 
BoxNDcopyFrom (const BoxND< Num2 > &r)
 
BoxND< unsigned > & copyFrom (const BoxND< Num2 > &r)
 
unsigned long dim () const
 
BoxNDexpand (double r)
 
void getMidpoint (unsigned *coord, unsigned long coordLen) const
 
BoxNDmoveToOrigin ()
 
BoxND< unsigned > & operator+= (const std::vector< Num2 > &shifts)
 
BoxND< unsigned > & operator-= (const std::vector< Num2 > &shifts)
 
double overlapFraction (const BoxND &r) const
 
unsigned overlapVolume (const BoxND &r) const
 
BoxND< unsigned > & shift (const Num2 *shifts, const unsigned long shiftsLen)
 
unsigned volume () 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
 
bool isInside (const Num2 *coord, unsigned long coordLen) const
 
BoxNDoperator*= (double r)
 
BoxNDoperator/= (double r)
 
BoxNDoperator*= (const std::vector< double > &scales)
 
BoxNDoperator/= (const std::vector< double > &scales)
 
BoxNDexpand (const std::vector< double > &scales)
 
BoxNDexpand (const double *scales, unsigned long lenScales)
 
BoxNDoperator+= (const std::vector< Num2 > &shifts)
 
BoxNDoperator-= (const std::vector< Num2 > &shifts)
 
BoxNDshift (const Num2 *shifts, unsigned long lenShifts)
 
gs::ClassId classId () 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) {}
unsigned long dim() const
Definition: BoxND.h:54

◆ 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) {}
unsigned long dim() const
Definition: BoxND.h:54

◆ 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) {}
ArrayShape shape() const
Definition: ArrayRange.cc:78

◆ ArrayRange() [5/5]

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

Definition at line 5 of file ArrayRange.cc.

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

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  }
assert(be >=bs)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})

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  }
bool isCompatible(const ArrayShape &shape) const
Definition: ArrayRange.cc:14

◆ isCompatible() [2/2]

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

Definition at line 19 of file ArrayRange.cc.

References cms::cuda::assert(), mps_fire::i, WZElectronSkims53X_cff::max, and mitigatedMETSequence_cff::U.

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  }
size
Write out results.
assert(be >=bs)

◆ 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.

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

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  }
size
Write out results.
assert(be >=bs)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ operator<()

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

Operator for use with maps

Definition at line 34 of file ArrayRange.cc.

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

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  }
size
Write out results.

◆ rangeLength()

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

Get the range into an array

Definition at line 114 of file ArrayRange.cc.

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

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  }
size
Write out results.
assert(be >=bs)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ rangeSize()

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

How many elements will be iterated over?

Definition at line 67 of file ArrayRange.cc.

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

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  }
size
Write out results.

◆ 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.

References mps_fire::i.

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  }
size
Write out results.
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ 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.

References mps_fire::i, SiStripPI::min, and mitigatedMETSequence_cff::U.

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  }
size
Write out results.

◆ 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.

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

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  }
size
Write out results.
assert(be >=bs)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80