CMS 3D CMS Logo

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 (const Constraint &c)
 
 Constraint (std::string s)
 
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::unique_ptr< Constraint_Intermed_lhs
 
std::unique_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 73 of file Constraint.h.

Constructor & Destructor Documentation

◆ Constraint() [1/2]

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

Constructor.

Parameters
sThe string to parse describing the constraint.

Definition at line 77 of file Constraint.cc.

85  {
86  // Split it at the equals sign.
87  string::size_type i = s.find('=');
88  assert(i != string::npos);
89 
90  // And then build the two halves.
91  {
92  unique_ptr<Constraint_Intermed> ci = make_constraint_intermed(s.substr(0, i));
93  _lhs = std::move(ci);
94  }
95  {
96  unique_ptr<Constraint_Intermed> ci = make_constraint_intermed(s.substr(i + 1));
97  _rhs = std::move(ci);
98  }
99  }

References _lhs, _rhs, cms::cuda::assert(), mps_fire::i, hitfit::make_constraint_intermed(), eostools::move(), and alignCSCRings::s.

◆ Constraint() [2/2]

hitfit::Constraint::Constraint ( const Constraint c)

Copy constructor.

Parameters
cThe original object to be copied.

Definition at line 45 of file Constraint.cc.

52  : _lhs(c._lhs->clone()), _rhs(c._rhs->clone()) {}

◆ ~Constraint()

hitfit::Constraint::~Constraint ( )
inline

Destructor.

Definition at line 99 of file Constraint.h.

99 {}

Member Function Documentation

◆ has_labels()

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 101 of file Constraint.cc.

115  {
116  if (_lhs->has_labels(ilabel, jlabel))
117  return 1;
118  else if (_rhs->has_labels(ilabel, jlabel))
119  return -1;
120  else
121  return 0;
122  }

◆ operator=()

Constraint & hitfit::Constraint::operator= ( const Constraint c)

Assignment operator.

Parameters
cThe original object to be copied.

Definition at line 54 of file Constraint.cc.

64  {
65  {
66  unique_ptr<Constraint_Intermed> ci = c._lhs->clone();
67  _lhs = std::move(ci);
68  }
69  {
70  unique_ptr<Constraint_Intermed> ci = c._rhs->clone();
71  _rhs = std::move(ci);
72  }
73 
74  return *this;
75  }

References _lhs, _rhs, HltBtagPostValidation_cff::c, and eostools::move().

◆ sum_mass_terms()

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 124 of file Constraint.cc.

135  {
136  return _lhs->sum_mass_terms(ev) - _rhs->sum_mass_terms(ev);
137  }

References ev.

Friends And Related Function Documentation

◆ operator<<

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 149 of file Constraint.cc.

160  {
161  s << *c._lhs.get() << " = " << *c._rhs.get();
162  return s;
163  }

Member Data Documentation

◆ _lhs

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

Left hand side of the constraint.

Definition at line 147 of file Constraint.h.

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

◆ _rhs

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

Right hand side of the constraint.

Definition at line 152 of file Constraint.h.

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

mps_fire.i
i
Definition: mps_fire.py:428
cms::cuda::assert
assert(be >=bs)
hitfit::Constraint::_rhs
std::unique_ptr< Constraint_Intermed > _rhs
Definition: Constraint.h:152
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
hitfit::make_constraint_intermed
std::unique_ptr< Constraint_Intermed > make_constraint_intermed(std::string s)
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
eostools.move
def move(src, dest)
Definition: eostools.py:511
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
hitfit::Constraint::_lhs
std::unique_ptr< Constraint_Intermed > _lhs
Definition: Constraint.h:147