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 // $Id: Fourvec_Constrainer.h,v 1.1 2011/05/26 09:46:53 mseidel Exp $
3 //
4 // File: hitfit/Fourvec_Constrainer.h
5 // Purpose: Do a kinematic fit for a set of 4-vectors, given a set
6 // of mass constraints.
7 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
8 //
9 // Do a constrained fit on a set of 4-vectors.
10 // The input is in a Fourvec_Event instance. This consists
11 // of a collection of objects, each of which has a 4-momentum
12 // and an integer label. (Also uncertainties, etc.)
13 //
14 // We also have a set of mass constraints, based on sums of objects
15 // with specified labels. A constraint can either require that the
16 // invariant mass of a set of objects is constant, or that the masses
17 // of two sets be equal to each other. For example, the constraint
18 //
19 // (1 2) = 80
20 //
21 // says that the sum of all objects with labels 1 and 2 should have
22 // a mass of 80. And the constraint
23 //
24 // (1 2) = (3 4)
25 //
26 // says that the sum of all objects with labels 1 and 2 should
27 // have an invariant mass the same as the sum of all objects with
28 // labels 3 and 4.
29 //
30 // All the objects are fixed to constant masses for the fit.
31 // (These masses are attributes of the objects in the Fourvec_Event.)
32 // This is done by scaling either the 4-vector's 3-momentum or energy,
33 // depending on the setting of the `use_e' parameter.
34 //
35 // If there is no neutrino present in the event, two additional constraints
36 // are automatically added for total pt balance, unless the parameter
37 // ignore_met has been set.
38 //
39 // When the fit completes, this object can compute an invariant mass
40 // out of some combination of the objects, including an uncertainty.
41 // The particular combination is specified through the method mass_contraint();
42 // it gets a constraint string like normal; the lhs of the constraint
43 // is the mass that will be calculated. (The rhs should be zero.)
44 //
45 // CMSSW File : interface/Fourvec_Constrainer.h
46 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
47 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
48 //
49 
50 
74 #ifndef HITFIT_FOURVEC_CONSTRAINER_H
75 #define HITFIT_FOURVEC_CONSTRAINER_H
76 
77 
78 #include <string>
79 #include <vector>
80 #include <iosfwd>
84 
85 
86 namespace hitfit {
87 
88 
89 class Defaults;
90 class Fourvec_Event;
91 class Pair_Table;
92 
93 
100 //
101 // Purpose: Hold on to parameters for the Fourvec_Constrainer class.
102 //
103 // Parameters controlling the operation of the fitter:
104 // bool use_e - If true, then when rescaling the 4-vectors
105 // for a given mass, keep the measured energy
106 // and scale the 3-momentum. Otherwise, keep
107 // the 3-momentum and scale the energy.
108 // float e_com - The center-of-mass energy.
109 // (Used only to keep the fit from venturing
110 // into completely unphysical regions.)
111 // bool ignore_met - If this is true and the event does not
112 // have a neutrino, then the fit will be done
113 // without the overall transverse momentum
114 // constraint (and thus the missing Et information
115 // will be ignored). If the event does have
116 // a neutrino, this parameter is ignored.
117 //
118 {
119 public:
120  // Constructor. Initialize from a Defaults object.
130  Fourvec_Constrainer_Args (const Defaults& defs);
131 
132  // Retrieve parameter values.
136  bool use_e () const;
137 
141  double e_com () const;
142 
146  bool ignore_met () const;
147 
148 
149  // Arguments for subobjects.
151 
152 
153 private:
154  // Hold on to parameter values.
160  bool _use_e;
161 
166  double _e_com;
167 
176 
181 };
182 
183 
184 //*************************************************************************
185 
186 
231 //
232 // Purpose: Do a kinematic fit for a set of 4-vectors, given a set
233 // of mass constraints.
234 //
235 {
236 public:
237  // Constructor.
238  // ARGS holds the parameter settings for this instance.
245 
246  // Specify an additional constraint S for the problem.
247  // The format for S is described above.
254  void add_constraint (std::string s);
255 
256  // Specify the combination of objects that will be returned by
257  // constrain() as the mass. The format of S is the same as for
258  // normal constraints. The LHS specifies the mass to calculate;
259  // the RHS should be zero.
260  // This should only be called once.
270  void mass_constraint (std::string s);
271 
272  // Do a constrained fit for EV. Returns the requested mass and
273  // its error in M and SIGM, and the pull quantities in PULLX and
274  // PULLY. Returns the chisq; this will be < 0 if the fit failed
275  // to converge.
306  double constrain (Fourvec_Event& ev,
307  double& m,
308  double& sigm,
309  Column_Vector& pullx,
310  Column_Vector& pully);
311 
312  // Dump the internal state.
313  friend std::ostream& operator<< (std::ostream& s,
314  const Fourvec_Constrainer& c);
315 
316 
317 private:
318  // Parameter settings.
323 
324  // The constraints for this problem.
328  std::vector<Constraint> _constraints;
329 
330  // The constraint giving the mass to be calculated. This
331  // should have no more than one entry.
336  std::vector<Constraint> _mass_constraint;
337 };
338 
339 
340 } // namespace hitfit
341 
342 
343 #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:67
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
dictionary 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:62
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.