CMS 3D CMS Logo

List of all members | 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

Public Member Functions

std::unique_ptr< Constraint_Intermedclone () const override
 
 Constraint_Intermed_Labels (const std::vector< int > &labels)
 
 Constraint_Intermed_Labels (const Constraint_Intermed_Labels &c)
 
bool has_labels (int ilabel, int jlabel) const override
 
void print (std::ostream &s) const override
 
double sum_mass_terms (const Fourvec_Event &ev) const override
 
 ~Constraint_Intermed_Labels () override
 
- Public Member Functions inherited from hitfit::Constraint_Intermed
 Constraint_Intermed ()
 
virtual ~Constraint_Intermed ()
 

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 245 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 133 of file Constraint_Intermed.cc.

References _labels.

Referenced by clone(), and hitfit::make_constraint_intermed().

140  : _labels(labels) {
141  // Sort them.
142  stable_sort(_labels.begin(), _labels.end());
143  }
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 145 of file Constraint_Intermed.cc.

hitfit::Constraint_Intermed_Labels::~Constraint_Intermed_Labels ( )
inlineoverride

Member Function Documentation

unique_ptr< Constraint_Intermed > hitfit::Constraint_Intermed_Labels::clone ( void  ) const
overridevirtual

Clone function to copy the instance.

Implements hitfit::Constraint_Intermed.

Definition at line 244 of file Constraint_Intermed.cc.

References Constraint_Intermed_Labels().

251  {
252  return unique_ptr<Constraint_Intermed>(new Constraint_Intermed_Labels(*this));
253  }
Constraint_Intermed_Labels(const std::vector< int > &labels)
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 230 of file Constraint_Intermed.cc.

References _labels, spr::find(), and label.

Referenced by sum_mass_terms().

240  {
241  return find(_labels.begin(), _labels.end(), label) != _labels.end();
242  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
char const * label
bool hitfit::Constraint_Intermed_Labels::has_labels ( int  ilabel,
int  jlabel 
) const
overridevirtual

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 154 of file Constraint_Intermed.cc.

References _labels, mps_fire::i, and edm::swap().

165  {
166  if (ilabel > jlabel)
167  swap(ilabel, jlabel);
168 
169  unsigned sz = _labels.size();
170  unsigned i;
171  for (i = 0; i < sz; i++) {
172  if (_labels[i] == ilabel)
173  break;
174  }
175 
176  if (i == sz)
177  return false;
178 
179  for (; i < sz; i++) {
180  if (_labels[i] == jlabel)
181  break;
182  }
183 
184  if (i == sz)
185  return false;
186 
187  return true;
188  }
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
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
overridevirtual

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 213 of file Constraint_Intermed.cc.

References _labels, mps_fire::i, and alignCSCRings::s.

220  {
221  s << "(";
222  for (unsigned i = 0; i < _labels.size(); i++) {
223  if (i > 0)
224  s << "+";
225  s << _labels[i];
226  }
227  s << ")";
228  }
double hitfit::Constraint_Intermed_Labels::sum_mass_terms ( const Fourvec_Event ev) const
overridevirtual

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 190 of file Constraint_Intermed.cc.

References ev, has_label(), mps_fire::i, hitfit::FE_Obj::label, hitfit::FE_Obj::mass, and EcalTangentSkim_cfg::o.

201  {
202  int nobjs = ev.nobjs();
203  double sum = 0;
204  for (int i = 0; i < nobjs; i++) {
205  const FE_Obj& o = ev.obj(i);
206  if (has_label(o.label))
207  sum += o.mass * o.mass / 2;
208  }
209 
210  return sum;
211  }
bool ev

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 321 of file Constraint_Intermed.h.

Referenced by validation.SimpleValidation::_doPlots(), Constraint_Intermed_Labels(), plotting.PlotFolder::draw(), has_label(), has_labels(), and print().