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::Constraint Class Reference

Represent a mass constraint equation. Mass constraints come in two varieties, either saying that the sum of a set of labels should equal a constant:
More...

#include <Constraint.h>

Public Member Functions

 Constraint (std::string s)
 
 Constraint (const Constraint &c)
 
int has_labels (int ilabel, int jlabel) const
 
Constraintoperator= (const Constraint &c)
 
double sum_mass_terms (const Fourvec_Event &ev) const
 
 ~Constraint ()
 

Private Attributes

std::auto_ptr
< Constraint_Intermed
_lhs
 
std::auto_ptr
< Constraint_Intermed
_rhs
 

Friends

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

Detailed Description

Represent a mass constraint equation. Mass constraints come in two varieties, either saying that the sum of a set of labels should equal a constant:

$(1 + 2) = C$.

or that two such sums should be equal to each other:

$(1 + 2) = (3 + 4)$.

We represent such a constraint equation by two Constraint_Intermed instances, each of which represents one side of the equation.

Definition at line 79 of file Constraint.h.

Constructor & Destructor Documentation

hitfit::Constraint::Constraint ( std::string  s)

Constructor.

Parameters
sThe string to parse describing the constraint.

Definition at line 85 of file Constraint.cc.

References _lhs, _rhs, i, and hitfit::make_constraint_intermed().

93 {
94  // Split it at the equals sign.
95  string::size_type i = s.find ('=');
96  assert (i != string::npos);
97 
98  // And then build the two halves.
99  {
100  auto_ptr<Constraint_Intermed> ci =
101  make_constraint_intermed (s.substr (0, i));
102  _lhs = ci;
103  }
104  {
105  auto_ptr<Constraint_Intermed> ci =
106  make_constraint_intermed (s.substr (i+1));
107  _rhs = ci;
108  }
109 }
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< Constraint_Intermed > _rhs
Definition: Constraint.h:160
std::auto_ptr< Constraint_Intermed > make_constraint_intermed(std::string s)
std::auto_ptr< Constraint_Intermed > _lhs
Definition: Constraint.h:155
uint16_t size_type
hitfit::Constraint::Constraint ( const Constraint c)

Copy constructor.

Parameters
cThe original object to be copied.

Definition at line 48 of file Constraint.cc.

55  : _lhs (c._lhs->clone ()),
56  _rhs (c._rhs->clone ())
57 {
58 }
std::auto_ptr< Constraint_Intermed > _rhs
Definition: Constraint.h:160
std::auto_ptr< Constraint_Intermed > _lhs
Definition: Constraint.h:155
hitfit::Constraint::~Constraint ( )
inline

Destructor.

Definition at line 106 of file Constraint.h.

106 {}

Member Function Documentation

int hitfit::Constraint::has_labels ( int  ilabel,
int  jlabel 
) const

See if this guy references both labels ilabel and jlabel on a single single side of the constraint equation.

Parameters
ilabelThe first label to test.
jlabelThe second label to test.
Return:
  • +1 if the LHS references both.
  • -1 if the RHS references both.
  • 0 if neither reference both.

Definition at line 112 of file Constraint.cc.

126 {
127  if (_lhs->has_labels (ilabel, jlabel))
128  return 1;
129  else if (_rhs->has_labels (ilabel, jlabel))
130  return -1;
131  else
132  return 0;
133 }
std::auto_ptr< Constraint_Intermed > _rhs
Definition: Constraint.h:160
std::auto_ptr< Constraint_Intermed > _lhs
Definition: Constraint.h:155
Constraint & hitfit::Constraint::operator= ( const Constraint c)

Assignment operator.

Parameters
cThe original object to be copied.

Definition at line 61 of file Constraint.cc.

References _lhs, and _rhs.

71 {
72  {
73  auto_ptr<Constraint_Intermed> ci = c._lhs->clone ();
74  _lhs = ci;
75  }
76  {
77  auto_ptr<Constraint_Intermed> ci = c._rhs->clone ();
78  _rhs = ci;
79  }
80 
81  return *this;
82 }
std::auto_ptr< Constraint_Intermed > _rhs
Definition: Constraint.h:160
std::auto_ptr< Constraint_Intermed > _lhs
Definition: Constraint.h:155
double hitfit::Constraint::sum_mass_terms ( const Fourvec_Event ev) const

Evaluate the mass constraint, using the data in ev.

Parameters
evThe event for which the constraint should be evaluated.
Return:
$ \frac{m(\rm{lhs})^{2}}{2} - \frac{m(\rm{rhs})^{2}}{2}$

Definition at line 136 of file Constraint.cc.

References ev.

147 {
148  return _lhs->sum_mass_terms (ev) - _rhs->sum_mass_terms (ev);
149 }
std::auto_ptr< Constraint_Intermed > _rhs
Definition: Constraint.h:160
std::auto_ptr< Constraint_Intermed > _lhs
Definition: Constraint.h:155
bool ev

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const Constraint c 
)
friend

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

Parameters
sThe stream to which to write.
cThe instance of Constraint to be printed.

Definition at line 162 of file Constraint.cc.

173 {
174  s << *c._lhs.get() << " = " << *c._rhs.get();
175  return s;
176 }

Member Data Documentation

std::auto_ptr<Constraint_Intermed> hitfit::Constraint::_lhs
private

Left hand side of the constraint.

Definition at line 155 of file Constraint.h.

Referenced by Constraint(), hitfit::operator<<(), and operator=().

std::auto_ptr<Constraint_Intermed> hitfit::Constraint::_rhs
private

Right hand side of the constraint.

Definition at line 160 of file Constraint.h.

Referenced by Constraint(), hitfit::operator<<(), and operator=().