CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

hitfit::Constraint_Intermed_Labels Class Reference

Concrete class for one side of mass constraint equation of the type:
$(1 + 2) = (3 + 4)$. More...

#include <Constraint_Intermed.h>

Inheritance diagram for hitfit::Constraint_Intermed_Labels:
hitfit::Constraint_Intermed

List of all members.

Public Member Functions

virtual std::auto_ptr
< Constraint_Intermed
clone () const
 Constraint_Intermed_Labels (const Constraint_Intermed_Labels &c)
 Constraint_Intermed_Labels (const std::vector< int > &labels)
virtual bool has_labels (int ilabel, int jlabel) const
virtual void print (std::ostream &s) const
virtual double sum_mass_terms (const Fourvec_Event &ev) const
virtual ~Constraint_Intermed_Labels ()

Private Member Functions

bool has_label (int label) const
Constraint_Intermedoperator= (const Constraint_Intermed &)

Private Attributes

std::vector< int > _labels

Detailed Description

Concrete class for one side of mass constraint equation of the type:
$(1 + 2) = (3 + 4)$.

Definition at line 258 of file Constraint_Intermed.h.


Constructor & Destructor Documentation

hitfit::Constraint_Intermed_Labels::Constraint_Intermed_Labels ( const std::vector< int > &  labels)

Constructor.

Parameters:
labelsThe labels used by this side of mass constraint.

Definition at line 155 of file Constraint_Intermed.cc.

Referenced by clone().

  : _labels (labels)
{
  // Sort them.
  stable_sort (_labels.begin(), _labels.end());
}
hitfit::Constraint_Intermed_Labels::Constraint_Intermed_Labels ( const Constraint_Intermed_Labels c)

Copy constructor.

Parameters:
cThe instance of Constraint_Intermed_Labels to be copied.

Definition at line 170 of file Constraint_Intermed.cc.

   : _labels (c._labels)
{
}
virtual hitfit::Constraint_Intermed_Labels::~Constraint_Intermed_Labels ( ) [inline, virtual]

Destructor.

Definition at line 277 of file Constraint_Intermed.h.

{};

Member Function Documentation

auto_ptr< Constraint_Intermed > hitfit::Constraint_Intermed_Labels::clone ( void  ) const [virtual]

Clone function to copy the instance.

Implements hitfit::Constraint_Intermed.

Definition at line 277 of file Constraint_Intermed.cc.

References Constraint_Intermed_Labels().

{
  return auto_ptr<Constraint_Intermed> 
    (new Constraint_Intermed_Labels (*this));
}
bool hitfit::Constraint_Intermed_Labels::has_label ( int  label) const [private]

Test to see if label is used by this side of the mass constraint.

Parameters:
labelThe label for which to search.
Return:
true is this constraint use the label. false if this constraint doesn't use the label.

Definition at line 262 of file Constraint_Intermed.cc.

References spr::find(), and label.

{
  return find (_labels.begin(), _labels.end(), label) != _labels.end();
}
bool hitfit::Constraint_Intermed_Labels::has_labels ( int  ilabel,
int  jlabel 
) const [virtual]

Check the instance for reference of ilabel and jlabel.

Parameters:
ilabelThe first label to test.
jlabelThe second label to test.
Return:
true if this instance references both labels ilabel and jlabel.
false if this instance doesn't reference both labels.

Implements hitfit::Constraint_Intermed.

Definition at line 182 of file Constraint_Intermed.cc.

References i, and swap().

{
  if (ilabel > jlabel)
    swap (ilabel, jlabel);

  unsigned sz = _labels.size();
  unsigned i;
  for (i=0; i < sz; i++) {
    if (_labels[i] == ilabel)
      break;
  }

  if (i == sz)
    return false;

  for (; i < sz; i++) {
    if (_labels[i] == jlabel)
      break;
  }

  if (i == sz)
    return false;

  return true;
}
Constraint_Intermed& hitfit::Constraint_Intermed_Labels::operator= ( const Constraint_Intermed ) [private]

Disallow assignment by NOT defining the assignment operation.

void hitfit::Constraint_Intermed_Labels::print ( std::ostream &  s) const [virtual]

Print out the instance to the output stream.

Parameters:
sThe output stream to which the instance is printed.

Implements hitfit::Constraint_Intermed.

Definition at line 244 of file Constraint_Intermed.cc.

References i, and alignCSCRings::s.

{
  s << "(";
  for (unsigned i = 0; i < _labels.size(); i++) {
    if (i > 0)
      s << "+";
    s << _labels[i];
  }
  s << ")";
}
double hitfit::Constraint_Intermed_Labels::sum_mass_terms ( const Fourvec_Event ev) const [virtual]

Evaluate this half of the mass constraint, using the data in ev.

Parameters:
evThe event for which the mass constraint is to be evaluated.
Return:
$\frac{m^{2}}{2}$.

Implements hitfit::Constraint_Intermed.

Definition at line 220 of file Constraint_Intermed.cc.

References i, hitfit::FE_Obj::label, hitfit::FE_Obj::mass, and python::connectstrParser::o.

{
  int nobjs = ev.nobjs();
  double sum = 0;
  for (int i = 0; i < nobjs; i++) {
    const FE_Obj& o = ev.obj (i);
    if (has_label (o.label))
      sum += o.mass * o.mass / 2;
  }

  return sum;
}

Member Data Documentation

std::vector<int> hitfit::Constraint_Intermed_Labels::_labels [private]

List of the labels for this side of mass constraint, kept in sorted order.

Definition at line 337 of file Constraint_Intermed.h.