CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Friends
hitfit::Fit_Result_Vec Class Reference

Holds pointers to a set of Fit_Result objects, resulting from different jet permutation with some consistent selection. The results are ordered by increasing $\chi^{2}$ values. A maximum length for the list of Fit_Result objects may be specified; when new results, those with the largest $\chi^{2}$ value fall off the end. More...

#include <Fit_Result_Vec.h>

Public Member Functions

 Fit_Result_Vec (const Fit_Result_Vec &vec)
 Copy constructor. More...
 
 Fit_Result_Vec (std::vector< std::shared_ptr< Fit_Result >>::size_type max_len)
 Constructor. More...
 
Fit_Result_Vecoperator= (const Fit_Result_Vec &vec)
 Assignment operator. More...
 
const Fit_Resultoperator[] (std::vector< std::shared_ptr< Fit_Result >>::size_type i) const
 Return the i-th element of the Fit_Result objects in the vector. More...
 
void push (std::shared_ptr< Fit_Result > res)
 Add a new Fit_Result to the list. More...
 
std::vector< std::shared_ptr< Fit_Result > >::size_type size () const
 Return the number of Fit_Result objects in the list. More...
 
 ~Fit_Result_Vec ()
 Destructor. More...
 

Private Attributes

std::vector< std::shared_ptr< Fit_Result > >::size_type _max_len
 
std::vector< std::shared_ptr< Fit_Result > > _v
 

Friends

std::ostream & operator<< (std::ostream &s, const Fit_Result_Vec &resvec)
 Output stream operator, print the content of this Fit_Result_Vec to an output stream. More...
 

Detailed Description

Holds pointers to a set of Fit_Result objects, resulting from different jet permutation with some consistent selection. The results are ordered by increasing $\chi^{2}$ values. A maximum length for the list of Fit_Result objects may be specified; when new results, those with the largest $\chi^{2}$ value fall off the end.

The Fit_Result object are reference counted, in order to allow then to be entered in multiple vectors.

Definition at line 67 of file Fit_Result_Vec.h.

Constructor & Destructor Documentation

◆ Fit_Result_Vec() [1/2]

hitfit::Fit_Result_Vec::Fit_Result_Vec ( std::vector< std::shared_ptr< Fit_Result >>::size_type  max_len)

Constructor.

Parameters
max_lenThe maximum length of the list. Must be a positive integer.

Definition at line 48 of file Fit_Result_Vec.cc.

55  : _max_len(max_len) {
56  assert(max_len > 0);
57  _v.reserve(max_len + 1);
58  }

References _v, and cms::cuda::assert().

◆ ~Fit_Result_Vec()

hitfit::Fit_Result_Vec::~Fit_Result_Vec ( )

Destructor.

Definition at line 69 of file Fit_Result_Vec.cc.

73  {}

◆ Fit_Result_Vec() [2/2]

hitfit::Fit_Result_Vec::Fit_Result_Vec ( const Fit_Result_Vec vec)

Copy constructor.

Parameters
vecThe list to copy.

Definition at line 60 of file Fit_Result_Vec.cc.

67  : _v(vec._v), _max_len(vec._max_len) {}

Member Function Documentation

◆ operator=()

Fit_Result_Vec & hitfit::Fit_Result_Vec::operator= ( const Fit_Result_Vec vec)

Assignment operator.

Parameters
vecThe list to copy.

Definition at line 75 of file Fit_Result_Vec.cc.

85  {
86  _v = vec._v;
87  _max_len = vec._max_len;
88  return *this;
89  }

References _max_len, and _v.

◆ operator[]()

const Fit_Result & hitfit::Fit_Result_Vec::operator[] ( std::vector< std::shared_ptr< Fit_Result >>::size_type  i) const

Return the i-th element of the Fit_Result objects in the vector.

Parameters
iThe index of the desired Fit_Result object.

Definition at line 102 of file Fit_Result_Vec.cc.

112  {
113  assert(i < _v.size());
114  return *_v[i];
115  }

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

◆ push()

void hitfit::Fit_Result_Vec::push ( std::shared_ptr< Fit_Result res)

Add a new Fit_Result to the list.

Parameters
resThe new Fit_Result object to be added into the list of Fit_Result object.

Definition at line 131 of file Fit_Result_Vec.cc.

138  {
139  // Find where to add it.
140  vector<std::shared_ptr<Fit_Result>>::iterator it = lower_bound(_v.begin(), _v.end(), res, Compare_Fitresptr());
141 
142  // Insert it.
143  _v.insert(it, res);
144 
145  // Knock off the guy at the end if we've exceeded our maximum size.
146  if (_v.size() > _max_len) {
147  _v.erase(_v.end() - 1);
148  }
149  }

References _max_len, _v, and pfDeepBoostedJetPreprocessParams_cfi::lower_bound.

◆ size()

std::vector< std::shared_ptr< Fit_Result > >::size_type hitfit::Fit_Result_Vec::size ( void  ) const

Return the number of Fit_Result objects in the list.

Definition at line 91 of file Fit_Result_Vec.cc.

98  {
99  return _v.size();
100  }

References _v.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  s,
const Fit_Result_Vec resvec 
)
friend

Output stream operator, print the content of this Fit_Result_Vec to an output stream.

Parameters
sThe output stream to which to write.
resvecThe instance of Fit_Result_Vec to be printed.

Definition at line 159 of file Fit_Result_Vec.cc.

170  {
171  for (std::vector<std::shared_ptr<Fit_Result>>::size_type i = 0; i < resvec._v.size(); i++)
172  s << "Entry " << i << "\n" << *resvec._v[i];
173  return s;
174  }

Member Data Documentation

◆ _max_len

std::vector<std::shared_ptr<Fit_Result> >::size_type hitfit::Fit_Result_Vec::_max_len
private

Maximum number of Fit_Result pointers in the list.

Definition at line 138 of file Fit_Result_Vec.h.

Referenced by operator=(), and push().

◆ _v

std::vector<std::shared_ptr<Fit_Result> > hitfit::Fit_Result_Vec::_v
private

The list of Fit_Result pointers.

Definition at line 133 of file Fit_Result_Vec.h.

Referenced by Fit_Result_Vec(), hitfit::operator<<(), operator=(), push(), and size().

mps_fire.i
i
Definition: mps_fire.py:428
cms::cuda::assert
assert(be >=bs)
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
hitfit::Fit_Result_Vec::_v
std::vector< std::shared_ptr< Fit_Result > > _v
Definition: Fit_Result_Vec.h:133
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
res
Definition: Electron.h:6
hitfit::Fit_Result_Vec::_max_len
std::vector< std::shared_ptr< Fit_Result > >::size_type _max_len
Definition: Fit_Result_Vec.h:138