00001 // 00002 // $Id: Fourvec_Constrainer.h,v 1.1 2011/05/26 09:46:53 mseidel Exp $ 00003 // 00004 // File: hitfit/Fourvec_Constrainer.h 00005 // Purpose: Do a kinematic fit for a set of 4-vectors, given a set 00006 // of mass constraints. 00007 // Created: Jul, 2000, sss, based on run 1 mass analysis code. 00008 // 00009 // Do a constrained fit on a set of 4-vectors. 00010 // The input is in a Fourvec_Event instance. This consists 00011 // of a collection of objects, each of which has a 4-momentum 00012 // and an integer label. (Also uncertainties, etc.) 00013 // 00014 // We also have a set of mass constraints, based on sums of objects 00015 // with specified labels. A constraint can either require that the 00016 // invariant mass of a set of objects is constant, or that the masses 00017 // of two sets be equal to each other. For example, the constraint 00018 // 00019 // (1 2) = 80 00020 // 00021 // says that the sum of all objects with labels 1 and 2 should have 00022 // a mass of 80. And the constraint 00023 // 00024 // (1 2) = (3 4) 00025 // 00026 // says that the sum of all objects with labels 1 and 2 should 00027 // have an invariant mass the same as the sum of all objects with 00028 // labels 3 and 4. 00029 // 00030 // All the objects are fixed to constant masses for the fit. 00031 // (These masses are attributes of the objects in the Fourvec_Event.) 00032 // This is done by scaling either the 4-vector's 3-momentum or energy, 00033 // depending on the setting of the `use_e' parameter. 00034 // 00035 // If there is no neutrino present in the event, two additional constraints 00036 // are automatically added for total pt balance, unless the parameter 00037 // ignore_met has been set. 00038 // 00039 // When the fit completes, this object can compute an invariant mass 00040 // out of some combination of the objects, including an uncertainty. 00041 // The particular combination is specified through the method mass_contraint(); 00042 // it gets a constraint string like normal; the lhs of the constraint 00043 // is the mass that will be calculated. (The rhs should be zero.) 00044 // 00045 // CMSSW File : interface/Fourvec_Constrainer.h 00046 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0 00047 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch> 00048 // 00049 00050 00074 #ifndef HITFIT_FOURVEC_CONSTRAINER_H 00075 #define HITFIT_FOURVEC_CONSTRAINER_H 00076 00077 00078 #include <string> 00079 #include <vector> 00080 #include <iosfwd> 00081 #include "TopQuarkAnalysis/TopHitFit/interface/Constraint.h" 00082 #include "TopQuarkAnalysis/TopHitFit/interface/Chisq_Constrainer.h" 00083 #include "TopQuarkAnalysis/TopHitFit/interface/matutil.h" 00084 00085 00086 namespace hitfit { 00087 00088 00089 class Defaults; 00090 class Fourvec_Event; 00091 class Pair_Table; 00092 00093 00099 class Fourvec_Constrainer_Args 00100 // 00101 // Purpose: Hold on to parameters for the Fourvec_Constrainer class. 00102 // 00103 // Parameters controlling the operation of the fitter: 00104 // bool use_e - If true, then when rescaling the 4-vectors 00105 // for a given mass, keep the measured energy 00106 // and scale the 3-momentum. Otherwise, keep 00107 // the 3-momentum and scale the energy. 00108 // float e_com - The center-of-mass energy. 00109 // (Used only to keep the fit from venturing 00110 // into completely unphysical regions.) 00111 // bool ignore_met - If this is true and the event does not 00112 // have a neutrino, then the fit will be done 00113 // without the overall transverse momentum 00114 // constraint (and thus the missing Et information 00115 // will be ignored). If the event does have 00116 // a neutrino, this parameter is ignored. 00117 // 00118 { 00119 public: 00120 // Constructor. Initialize from a Defaults object. 00130 Fourvec_Constrainer_Args (const Defaults& defs); 00131 00132 // Retrieve parameter values. 00136 bool use_e () const; 00137 00141 double e_com () const; 00142 00146 bool ignore_met () const; 00147 00148 00149 // Arguments for subobjects. 00150 const Chisq_Constrainer_Args& chisq_constrainer_args () const; 00151 00152 00153 private: 00154 // Hold on to parameter values. 00160 bool _use_e; 00161 00166 double _e_com; 00167 00175 bool _ignore_met; 00176 00180 Chisq_Constrainer_Args _chisq_constrainer_args; 00181 }; 00182 00183 00184 //************************************************************************* 00185 00186 00230 class Fourvec_Constrainer 00231 // 00232 // Purpose: Do a kinematic fit for a set of 4-vectors, given a set 00233 // of mass constraints. 00234 // 00235 { 00236 public: 00237 // Constructor. 00238 // ARGS holds the parameter settings for this instance. 00244 Fourvec_Constrainer (const Fourvec_Constrainer_Args& args); 00245 00246 // Specify an additional constraint S for the problem. 00247 // The format for S is described above. 00254 void add_constraint (std::string s); 00255 00256 // Specify the combination of objects that will be returned by 00257 // constrain() as the mass. The format of S is the same as for 00258 // normal constraints. The LHS specifies the mass to calculate; 00259 // the RHS should be zero. 00260 // This should only be called once. 00270 void mass_constraint (std::string s); 00271 00272 // Do a constrained fit for EV. Returns the requested mass and 00273 // its error in M and SIGM, and the pull quantities in PULLX and 00274 // PULLY. Returns the chisq; this will be < 0 if the fit failed 00275 // to converge. 00306 double constrain (Fourvec_Event& ev, 00307 double& m, 00308 double& sigm, 00309 Column_Vector& pullx, 00310 Column_Vector& pully); 00311 00312 // Dump the internal state. 00313 friend std::ostream& operator<< (std::ostream& s, 00314 const Fourvec_Constrainer& c); 00315 00316 00317 private: 00318 // Parameter settings. 00322 const Fourvec_Constrainer_Args _args; 00323 00324 // The constraints for this problem. 00328 std::vector<Constraint> _constraints; 00329 00330 // The constraint giving the mass to be calculated. This 00331 // should have no more than one entry. 00336 std::vector<Constraint> _mass_constraint; 00337 }; 00338 00339 00340 } // namespace hitfit 00341 00342 00343 #endif // not HITFIT_FOURVEC_CONSTRAINER_H