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 Constraint_Intermed_Labels &c)
 
 Constraint_Intermed_Labels (const std::vector< int > &labels)
 
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

◆ Constraint_Intermed_Labels() [1/2]

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.

140  : _labels(labels) {
141  // Sort them.
142  stable_sort(_labels.begin(), _labels.end());
143  }

References _labels.

Referenced by clone().

◆ Constraint_Intermed_Labels() [2/2]

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.

152  : _labels(c._labels) {}

◆ ~Constraint_Intermed_Labels()

hitfit::Constraint_Intermed_Labels::~Constraint_Intermed_Labels ( )
inlineoverride

Destructor.

Definition at line 261 of file Constraint_Intermed.h.

261 {};

Member Function Documentation

◆ clone()

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.

251  {
252  return unique_ptr<Constraint_Intermed>(new Constraint_Intermed_Labels(*this));
253  }

References Constraint_Intermed_Labels().

◆ has_label()

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.

240  {
241  return find(_labels.begin(), _labels.end(), label) != _labels.end();
242  }

References spr::find(), and label.

◆ has_labels()

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.

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  }

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

◆ operator=()

Constraint_Intermed& hitfit::Constraint_Intermed_Labels::operator= ( const Constraint_Intermed )
private

Disallow assignment by NOT defining the assignment operation.

◆ print()

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.

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  }

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

◆ sum_mass_terms()

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.

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  }

References ev, mps_fire::i, and EcalTangentSkim_cfg::o.

Member Data Documentation

◆ _labels

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(), and plotting.PlotFolder::draw().

SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
mps_fire.i
i
Definition: mps_fire.py:355
edm::swap
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
hitfit::Constraint_Intermed_Labels::Constraint_Intermed_Labels
Constraint_Intermed_Labels(const std::vector< int > &labels)
Definition: Constraint_Intermed.cc:133
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
hitfit::Constraint_Intermed_Labels::has_label
bool has_label(int label) const
Definition: Constraint_Intermed.cc:230
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
hitfit::Constraint_Intermed_Labels::_labels
std::vector< int > _labels
Definition: Constraint_Intermed.h:321
label
const char * label
Definition: PFTauDecayModeTools.cc:11