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 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

virtual std::auto_ptr
< Constraint_Intermed
clone () const
 
 Constraint_Intermed_Labels (const std::vector< int > &labels)
 
 Constraint_Intermed_Labels (const Constraint_Intermed_Labels &c)
 
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 ()
 
- 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 257 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 154 of file Constraint_Intermed.cc.

Referenced by clone().

161  : _labels (labels)
162 {
163  // Sort them.
164  stable_sort (_labels.begin(), _labels.end());
165 }
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 169 of file Constraint_Intermed.cc.

176  : _labels (c._labels)
177 {
178 }
virtual hitfit::Constraint_Intermed_Labels::~Constraint_Intermed_Labels ( )
inlinevirtual

Destructor.

Definition at line 276 of file Constraint_Intermed.h.

276 {};

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

References Constraint_Intermed_Labels().

283 {
284  return auto_ptr<Constraint_Intermed>
285  (new Constraint_Intermed_Labels (*this));
286 }
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 261 of file Constraint_Intermed.cc.

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

271 {
272  return find (_labels.begin(), _labels.end(), label) != _labels.end();
273 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
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 181 of file Constraint_Intermed.cc.

References i, and swap().

192 {
193  if (ilabel > jlabel)
194  swap (ilabel, jlabel);
195 
196  unsigned sz = _labels.size();
197  unsigned i;
198  for (i=0; i < sz; i++) {
199  if (_labels[i] == ilabel)
200  break;
201  }
202 
203  if (i == sz)
204  return false;
205 
206  for (; i < sz; i++) {
207  if (_labels[i] == jlabel)
208  break;
209  }
210 
211  if (i == sz)
212  return false;
213 
214  return true;
215 }
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
int i
Definition: DBlmapReader.cc:9
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 243 of file Constraint_Intermed.cc.

References i, and alignCSCRings::s.

250 {
251  s << "(";
252  for (unsigned i = 0; i < _labels.size(); i++) {
253  if (i > 0)
254  s << "+";
255  s << _labels[i];
256  }
257  s << ")";
258 }
int i
Definition: DBlmapReader.cc:9
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 219 of file Constraint_Intermed.cc.

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

230 {
231  int nobjs = ev.nobjs();
232  double sum = 0;
233  for (int i = 0; i < nobjs; i++) {
234  const FE_Obj& o = ev.obj (i);
235  if (has_label (o.label))
236  sum += o.mass * o.mass / 2;
237  }
238 
239  return sum;
240 }
int i
Definition: DBlmapReader.cc:9

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