CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Fourvec_Constrainer.h
Go to the documentation of this file.
1 //
2 //
3 // File: hitfit/Fourvec_Constrainer.h
4 // Purpose: Do a kinematic fit for a set of 4-vectors, given a set
5 // of mass constraints.
6 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
7 //
8 // Do a constrained fit on a set of 4-vectors.
9 // The input is in a Fourvec_Event instance. This consists
10 // of a collection of objects, each of which has a 4-momentum
11 // and an integer label. (Also uncertainties, etc.)
12 //
13 // We also have a set of mass constraints, based on sums of objects
14 // with specified labels. A constraint can either require that the
15 // invariant mass of a set of objects is constant, or that the masses
16 // of two sets be equal to each other. For example, the constraint
17 //
18 // (1 2) = 80
19 //
20 // says that the sum of all objects with labels 1 and 2 should have
21 // a mass of 80. And the constraint
22 //
23 // (1 2) = (3 4)
24 //
25 // says that the sum of all objects with labels 1 and 2 should
26 // have an invariant mass the same as the sum of all objects with
27 // labels 3 and 4.
28 //
29 // All the objects are fixed to constant masses for the fit.
30 // (These masses are attributes of the objects in the Fourvec_Event.)
31 // This is done by scaling either the 4-vector's 3-momentum or energy,
32 // depending on the setting of the `use_e' parameter.
33 //
34 // If there is no neutrino present in the event, two additional constraints
35 // are automatically added for total pt balance, unless the parameter
36 // ignore_met has been set.
37 //
38 // When the fit completes, this object can compute an invariant mass
39 // out of some combination of the objects, including an uncertainty.
40 // The particular combination is specified through the method mass_contraint();
41 // it gets a constraint string like normal; the lhs of the constraint
42 // is the mass that will be calculated. (The rhs should be zero.)
43 //
44 // CMSSW File : interface/Fourvec_Constrainer.h
45 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
46 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
47 //
48 
49 
73 #ifndef HITFIT_FOURVEC_CONSTRAINER_H
74 #define HITFIT_FOURVEC_CONSTRAINER_H
75 
76 
77 #include <string>
78 #include <vector>
79 #include <iosfwd>
83 
84 
85 namespace hitfit {
86 
87 
88 class Defaults;
89 class Fourvec_Event;
90 class Pair_Table;
91 
92 
99 //
100 // Purpose: Hold on to parameters for the Fourvec_Constrainer class.
101 //
102 // Parameters controlling the operation of the fitter:
103 // bool use_e - If true, then when rescaling the 4-vectors
104 // for a given mass, keep the measured energy
105 // and scale the 3-momentum. Otherwise, keep
106 // the 3-momentum and scale the energy.
107 // float e_com - The center-of-mass energy.
108 // (Used only to keep the fit from venturing
109 // into completely unphysical regions.)
110 // bool ignore_met - If this is true and the event does not
111 // have a neutrino, then the fit will be done
112 // without the overall transverse momentum
113 // constraint (and thus the missing Et information
114 // will be ignored). If the event does have
115 // a neutrino, this parameter is ignored.
116 //
117 {
118 public:
119  // Constructor. Initialize from a Defaults object.
129  Fourvec_Constrainer_Args (const Defaults& defs);
130 
131  // Retrieve parameter values.
135  bool use_e () const;
136 
140  double e_com () const;
141 
145  bool ignore_met () const;
146 
147 
148  // Arguments for subobjects.
150 
151 
152 private:
153  // Hold on to parameter values.
159  bool _use_e;
160 
165  double _e_com;
166 
175 
180 };
181 
182 
183 //*************************************************************************
184 
185 
230 //
231 // Purpose: Do a kinematic fit for a set of 4-vectors, given a set
232 // of mass constraints.
233 //
234 {
235 public:
236  // Constructor.
237  // ARGS holds the parameter settings for this instance.
244 
245  // Specify an additional constraint S for the problem.
246  // The format for S is described above.
254 
255  // Specify the combination of objects that will be returned by
256  // constrain() as the mass. The format of S is the same as for
257  // normal constraints. The LHS specifies the mass to calculate;
258  // the RHS should be zero.
259  // This should only be called once.
269  void mass_constraint (std::string s);
270 
271  // Do a constrained fit for EV. Returns the requested mass and
272  // its error in M and SIGM, and the pull quantities in PULLX and
273  // PULLY. Returns the chisq; this will be < 0 if the fit failed
274  // to converge.
305  double constrain (Fourvec_Event& ev,
306  double& m,
307  double& sigm,
308  Column_Vector& pullx,
309  Column_Vector& pully);
310 
311  // Dump the internal state.
312  friend std::ostream& operator<< (std::ostream& s,
313  const Fourvec_Constrainer& c);
314 
315 
316 private:
317  // Parameter settings.
322 
323  // The constraints for this problem.
327  std::vector<Constraint> _constraints;
328 
329  // The constraint giving the mass to be calculated. This
330  // should have no more than one entry.
335  std::vector<Constraint> _mass_constraint;
336 };
337 
338 
339 } // namespace hitfit
340 
341 
342 #endif // not HITFIT_FOURVEC_CONSTRAINER_H
friend std::ostream & operator<<(std::ostream &s, const Fourvec_Constrainer &c)
Output stream operator, print the content of this Fourvec_Constrainer to an output stream...
Represent an event for kinematic fitting as a collection of four-momenta. Each object is represented ...
Fourvec_Constrainer(const Fourvec_Constrainer_Args &args)
Constructor.
CLHEP::HepVector Column_Vector
Definition: matutil.h:66
bool ev
Define matrix types for the HitFit package, and supply a few additional operations.
Fourvec_Constrainer_Args(const Defaults &defs)
Constructor, initialize from a Defaults object.
Minimize a subject to a set of constraints, based on the SQUAW algorithm.
const Chisq_Constrainer_Args & chisq_constrainer_args() const
Hold on to parameters for the Chisq_Constrainer class.
const Fourvec_Constrainer_Args _args
std::vector< Constraint > _mass_constraint
Represent a mass constraint equation.
Chisq_Constrainer_Args _chisq_constrainer_args
std::vector< Constraint > _constraints
double constrain(Fourvec_Event &ev, double &m, double &sigm, Column_Vector &pullx, Column_Vector &pully)
Do a constrained fit for event ev. Returns the requested mass and its uncertainty in m and sigm...
Define an interface for getting parameter settings.
Definition: Defaults.h:61
void mass_constraint(std::string s)
Specify a combination of objects that will be returned by the constrain() method as mass...
void add_constraint(std::string s)
Specify an additional constraint s for the problem. The format for s is described in the class descri...
Do a kinematic fit for a set of four-momenta, given a set of mass constraints.
Hold on to parameters for the Fourvec_Constrainer class.