CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Constrained_Z.cc
Go to the documentation of this file.
1 //
2 //
3 // File: Constrained_Z.cc
4 // Purpose: Do kinematic fitting for a (Z->ll)+jets event.
5 // Created: Apr, 2004, sss
6 //
7 // CMSSW File : src/Constrained_Z.cc
8 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
9 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
10 //
11 
40 #include <ostream>
41 #include <cassert>
42 #include <cstdio>
43 
44 namespace hitfit {
45 
46  //*************************************************************************
47  // Argument handling.
48  //
49 
51  //
52  // Purpose: Constructor.
53  //
54  // Inputs:
55  // defs - The Defaults instance from which to initialize.
56  //
57  : _zmass(defs.get_float("zmass")), _fourvec_constrainer_args(defs) {}
58 
60  //
61  // Purpose: Return the zmass parameter.
62  // See the header for documentation.
63  //
64  {
65  return _zmass;
66  }
67 
69  //
70  // Purpose: Return the contained subobject parameters.
71  //
72  {
74  }
75 
76  //*************************************************************************
77 
79  //
80  // Purpose: Constructor.
81  //
82  // Inputs:
83  // args - The parameter settings for this instance.
84  //
85  : _args(args), _constrainer(args.fourvec_constrainer_args()) {
86  char buf[256];
87  sprintf(buf, "(%d) = %f", lepton_label, _args.zmass());
89  }
90 
91  namespace {
92 
107  FE_Obj make_fe_obj(const Lepjets_Event_Lep& obj, double mass, int type)
108  //
109  // Purpose: Helper to create an object to put into the Fourvec_Event.
110  //
111  // Inputs:
112  // obj - The input object.
113  // mass - The mass to which it should be constrained.
114  // type - The type to assign it.
115  //
116  // Returns:
117  // The constructed FE_Obj.
118  //
119  {
120  return FE_Obj(obj.p(), mass, type, obj.p_sigma(), obj.eta_sigma(), obj.phi_sigma(), obj.res().p_res().inverse());
121  }
122 
138  void do_import(const Lepjets_Event& ev, Fourvec_Event& fe)
139  //
140  // Purpose: Convert from a Lepjets_Event to a Fourvec_Event.
141  //
142  // Inputs:
143  // ev - The input event.
144  //
145  // Outputs:
146  // fe - The initialized Fourvec_Event.
147  //
148  {
149  assert(ev.nleps() >= 2);
150  fe.add(make_fe_obj(ev.lep(0), 0, lepton_label));
151  fe.add(make_fe_obj(ev.lep(1), 0, lepton_label));
152 
153  for (std::vector<Lepjets_Event_Jet>::size_type j = 0; j < ev.njets(); j++)
154  fe.add(make_fe_obj(ev.jet(j), 0, isr_label));
155 
156  Fourvec kt = ev.kt();
157  fe.set_kt_error(ev.kt_res().sigma(kt.x()), ev.kt_res().sigma(kt.y()), 0);
158  fe.set_x_p(ev.met());
159  }
160 
177  void do_export(const Fourvec_Event& fe, Lepjets_Event& ev)
178  //
179  // Purpose: Convert from a Fourvec_Event to a Lepjets_Event.
180  //
181  // Inputs:
182  // fe - The input event.
183  // ev - The original Lepjets_Event.
184  //
185  // Outputs:
186  // ev - The updated Lepjets_Event.
187  //
188  {
189  ev.lep(0).p() = fe.obj(0).p;
190  ev.lep(1).p() = fe.obj(1).p;
191 
192  for (std::vector<Lepjets_Event_Jet>::size_type j = 0, k = 1; j < ev.njets(); j++)
193  ev.jet(j).p() = fe.obj(k++).p;
194 
195  Fourvec nu;
196  ev.met() = nu;
197  }
198 
199  } // unnamed namespace
200 
202  //
203  // Purpose: Do a constrained fit for EV.
204  // Returns the pull quantities in PULL.
205  // Returns the chisq; this will be < 0 if the fit failed
206  // to converge.
207  //
208  // Inputs:
209  // ev - The event we're fitting.
210  //
211  // Outputs:
212  // ev - The fitted event.
213  // pull - Pull quantities for well-measured variables.
214  //
215  // Returns:
216  // The fit chisq, or < 0 if the fit didn't converge.
217  //
218  {
219  Fourvec_Event fe;
220  do_import(ev, fe);
221  Column_Vector pully;
222  double m, sigm;
223  double chisq = _constrainer.constrain(fe, m, sigm, pull, pully);
224  do_export(fe, ev);
225 
226  return chisq;
227  }
228 
236  std::ostream& operator<<(std::ostream& s, const Constrained_Z& cz)
237  //
238  // Purpose: Print the object to S.
239  //
240  // Inputs:
241  // s - The stream to which to write.
242  // cz - The object to write.
243  //
244  // Returns:
245  // The stream S.
246  //
247  {
248  return s << cz._constrainer;
249  }
250 
251 } // namespace hitfit
const Constrained_Z_Args & _args
Define an abstract interface for getting parameter settings.
Represent a lepton in an instance of Lepjets_Event class. This class hold the following information: ...
Represent an event for kinematic fitting as a collection of four-momenta. Each object is represented ...
bool inverse() const
Return the setting of the inverse flag.
Definition: Resolution.cc:144
CLHEP::HepVector Column_Vector
Definition: matutil.h:63
bool ev
assert(be >=bs)
uint16_t size_type
double eta_sigma() const
Return the uncertainty in pseudorapidity .
Do a constrained kinematic fitting for a event.
Do a constrained kinematic fit of a event.
const Vector_Resolution & res() const
Return a constant reference to the resolution.
double phi_sigma() const
Return the uncertainty in azimuthal angle .
Fourvec_Constrainer _constrainer
double p_sigma() const
Return the uncertainty in momentum or ( or if the lepton is a tracking object).
Represent a simple event consisting of lepton(s) and jet(s).
Represent a simple event consisting of lepton(s) and jet(s). An instance of this class holds a list o...
Definition: Lepjets_Event.h:62
CLHEP::HepLorentzVector Fourvec
Typedef for a HepLorentzVector.
Definition: fourvec.h:55
double constrain(Lepjets_Event &ev, Column_Vector &pull)
Do a constrained fit of event. Returns the pull quantities in pull. Returns the , this will be negative if the fit failed to converge.
const Resolution & p_res() const
Return a constant reference to the momentum resolution.
Fourvec_Constrainer_Args _fourvec_constrainer_args
Definition: Constrained_Z.h:92
Constrained_Z(const Constrained_Z_Args &args)
Constructor, create an instance of the Constrained_Z object from the argument object.
Hold on to parameters for the Constrained_Z class.
Definition: Constrained_Z.h:49
Fourvec & p()
Return a reference to the four-momentum.
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...
const Fourvec_Constrainer_Args & fourvec_constrainer_args() const
Define an interface for getting parameter settings.
Definition: Defaults.h:57
std::ostream & operator<<(std::ostream &s, const Constraint_Intermed &ci)
Output stream operator, print the content of this Constraint_Intermed to an output stream...
Represent a single object in a Fourvec_Event, this is just a dumb data container. Each object in a Fo...
Definition: Fourvec_Event.h:90
Constrained_Z_Args(const Defaults &defs)
Constructor, initialize from a Defaults object.
void add_constraint(std::string s)
Specify an additional constraint s for the problem. The format for s is described in the class descri...
Hold on to parameters for the Fourvec_Constrainer class.
Represent an event for kinematic fitting as a collection of four-momenta.