CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (std::vector< Fit_Result * >::size_type max_len)
 Constructor. More...
 
 Fit_Result_Vec (const Fit_Result_Vec &vec)
 Copy constructor. More...
 
Fit_Result_Vecoperator= (const Fit_Result_Vec &vec)
 Assignment operator. More...
 
const Fit_Resultoperator[] (std::vector< Fit_Result * >::size_type i) const
 Return the i-th element of the Fit_Result objects in the vector. More...
 
void push (Fit_Result *res)
 Add a new Fit_Result to the list. More...
 
std::vector< 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< Fit_Result * >
::size_type 
_max_len
 
std::vector< 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 71 of file Fit_Result_Vec.h.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 52 of file Fit_Result_Vec.cc.

References _v.

59  : _max_len (max_len)
60 {
61  assert (max_len > 0);
62  _v.reserve (max_len + 1);
63 }
std::vector< Fit_Result * >::size_type _max_len
std::vector< Fit_Result * > _v
hitfit::Fit_Result_Vec::~Fit_Result_Vec ( )

Destructor.

Definition at line 82 of file Fit_Result_Vec.cc.

References _v, and i.

86 {
87  for (std::vector<Fit_Result*>::size_type i=0; i < _v.size(); i++)
88  _v[i]->decref ();
89 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
std::vector< Fit_Result * > _v
hitfit::Fit_Result_Vec::Fit_Result_Vec ( const Fit_Result_Vec vec)

Copy constructor.

Parameters
vecThe list to copy.

Definition at line 66 of file Fit_Result_Vec.cc.

References _v, and i.

73  : _v (vec._v),
74  _max_len (vec._max_len)
75 {
76  // Gotta increase the reference count on the contents.
77  for (std::vector<Fit_Result*>::size_type i=0; i < _v.size(); i++)
78  _v[i]->incref ();
79 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
std::vector< Fit_Result * >::size_type _max_len
std::vector< Fit_Result * > _v

Member Function Documentation

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

Assignment operator.

Parameters
vecThe list to copy.

Definition at line 92 of file Fit_Result_Vec.cc.

References _max_len, _v, and i.

102 {
103  for (std::vector<Fit_Result*>::size_type i=0; i < _v.size(); i++)
104  _v[i]->decref ();
105  _v = vec._v;
106  _max_len = vec._max_len;
107  for (std::vector<Fit_Result*>::size_type i=0; i < _v.size(); i++)
108  _v[i]->incref ();
109  return *this;
110 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
std::vector< Fit_Result * >::size_type _max_len
std::vector< Fit_Result * > _v
const Fit_Result & hitfit::Fit_Result_Vec::operator[] ( std::vector< 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 125 of file Fit_Result_Vec.cc.

References i.

135 {
136  assert (i < _v.size());
137  return *_v[i];
138 }
int i
Definition: DBlmapReader.cc:9
std::vector< Fit_Result * > _v
void hitfit::Fit_Result_Vec::push ( 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 159 of file Fit_Result_Vec.cc.

References _max_len, _v, and hitfit::Refcount::incref().

166 {
167  // Find where to add it.
168  vector<Fit_Result*>::iterator it = lower_bound (_v.begin(),
169  _v.end(),
170  res,
171  Compare_Fitresptr());
172 
173  // Insert it.
174  _v.insert (it, res);
175  res->incref ();
176 
177  // Knock off the guy at the end if we've exceeded our maximum size.
178  if (_v.size() > _max_len) {
179  _v.back()->decref ();
180  _v.erase (_v.end()-1);
181  }
182 }
std::vector< Fit_Result * >::size_type _max_len
std::vector< Fit_Result * > _v
std::vector< Fit_Result * >::size_type hitfit::Fit_Result_Vec::size ( void  ) const

Return the number of Fit_Result objects in the list.

Definition at line 113 of file Fit_Result_Vec.cc.

References _v.

120 {
121  return _v.size ();
122 }
std::vector< Fit_Result * > _v

Friends And Related Function Documentation

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 193 of file Fit_Result_Vec.cc.

204 {
205  for (std::vector<Fit_Result*>::size_type i=0; i < resvec._v.size(); i++)
206  s << "Entry " << i << "\n" << *resvec._v[i];
207  return s;
208 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type

Member Data Documentation

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

Maximum number of Fit_Result pointers in the list.

Definition at line 143 of file Fit_Result_Vec.h.

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

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

The list of Fit_Result pointers.

Definition at line 138 of file Fit_Result_Vec.h.

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