CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Constrained_Z.cc
Go to the documentation of this file.
1 //
2 // $Id: Constrained_Z.cc,v 1.1 2011/05/26 09:46:59 mseidel Exp $
3 //
4 // File: Constrained_Z.cc
5 // Purpose: Do kinematic fitting for a (Z->ll)+jets event.
6 // Created: Apr, 2004, sss
7 //
8 // CMSSW File : src/Constrained_Z.cc
9 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
10 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
11 //
12 
42 #include <ostream>
43 #include <cassert>
44 #include <stdio.h>
45 
46 
47 namespace hitfit {
48 
49 
50 //*************************************************************************
51 // Argument handling.
52 //
53 
54 
56 //
57 // Purpose: Constructor.
58 //
59 // Inputs:
60 // defs - The Defaults instance from which to initialize.
61 //
62  : _zmass (defs.get_float ("zmass")),
63  _fourvec_constrainer_args (defs)
64 {
65 }
66 
67 
69 //
70 // Purpose: Return the zmass parameter.
71 // See the header for documentation.
72 //
73 {
74  return _zmass;
75 }
76 
77 
80 //
81 // Purpose: Return the contained subobject parameters.
82 //
83 {
85 }
86 
87 
88 //*************************************************************************
89 
90 
92 //
93 // Purpose: Constructor.
94 //
95 // Inputs:
96 // args - The parameter settings for this instance.
97 //
98  : _args (args),
99  _constrainer (args.fourvec_constrainer_args())
100 {
101  char buf[256];
102  sprintf (buf, "(%d) = %f", lepton_label, _args.zmass());
104 }
105 
106 
107 namespace {
108 
109 
124 FE_Obj make_fe_obj (const Lepjets_Event_Lep& obj, double mass, int type)
125 //
126 // Purpose: Helper to create an object to put into the Fourvec_Event.
127 //
128 // Inputs:
129 // obj - The input object.
130 // mass - The mass to which it should be constrained.
131 // type - The type to assign it.
132 //
133 // Returns:
134 // The constructed FE_Obj.
135 //
136 {
137  return FE_Obj (obj.p(), mass, type,
138  obj.p_sigma(), obj.eta_sigma(), obj.phi_sigma(),
139  obj.res().p_res().inverse());
140 }
141 
142 
158 void do_import (const Lepjets_Event& ev, Fourvec_Event& fe)
159 //
160 // Purpose: Convert from a Lepjets_Event to a Fourvec_Event.
161 //
162 // Inputs:
163 // ev - The input event.
164 //
165 // Outputs:
166 // fe - The initialized Fourvec_Event.
167 //
168 {
169  assert (ev.nleps() >= 2);
170  fe.add (make_fe_obj (ev.lep(0), 0, lepton_label));
171  fe.add (make_fe_obj (ev.lep(1), 0, lepton_label));
172 
173  for (std::vector<Lepjets_Event_Jet>::size_type j=0; j < ev.njets(); j++)
174  fe.add (make_fe_obj (ev.jet(j), 0, isr_label));
175 
176  Fourvec kt = ev.kt ();
177  fe.set_kt_error (ev.kt_res().sigma (kt.x()),
178  ev.kt_res().sigma (kt.y()),
179  0);
180  fe.set_x_p (ev.met());
181 }
182 
183 
200 void do_export (const Fourvec_Event& fe, Lepjets_Event& ev)
201 //
202 // Purpose: Convert from a Fourvec_Event to a Lepjets_Event.
203 //
204 // Inputs:
205 // fe - The input event.
206 // ev - The original Lepjets_Event.
207 //
208 // Outputs:
209 // ev - The updated Lepjets_Event.
210 //
211 {
212  ev.lep(0).p() = fe.obj(0).p;
213  ev.lep(1).p() = fe.obj(1).p;
214 
215  for (std::vector<Lepjets_Event_Jet>::size_type j=0, k=1; j < ev.njets(); j++)
216  ev.jet(j).p() = fe.obj(k++).p;
217 
218  Fourvec nu;
219  ev.met() = nu;
220 }
221 
222 
223 } // unnamed namespace
224 
225 
227 //
228 // Purpose: Do a constrained fit for EV.
229 // Returns the pull quantities in PULL.
230 // Returns the chisq; this will be < 0 if the fit failed
231 // to converge.
232 //
233 // Inputs:
234 // ev - The event we're fitting.
235 //
236 // Outputs:
237 // ev - The fitted event.
238 // pull - Pull quantities for well-measured variables.
239 //
240 // Returns:
241 // The fit chisq, or < 0 if the fit didn't converge.
242 //
243 {
244  Fourvec_Event fe;
245  do_import (ev, fe);
246  Column_Vector pully;
247  double m, sigm;
248  double chisq = _constrainer.constrain (fe, m, sigm, pull, pully);
249  do_export (fe, ev);
250 
251  return chisq;
252 }
253 
254 
262 std::ostream& operator<< (std::ostream& s, const Constrained_Z& cz)
263 //
264 // Purpose: Print the object to S.
265 //
266 // Inputs:
267 // s - The stream to which to write.
268 // cz - The object to write.
269 //
270 // Returns:
271 // The stream S.
272 //
273 {
274  return s << cz._constrainer;
275 }
276 
277 
278 } // namespace hitfit
type
Definition: HCALResponse.h:22
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:172
CLHEP::HepVector Column_Vector
Definition: matutil.h:67
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:67
CLHEP::HepLorentzVector Fourvec
Typedef for a HepLorentzVector.
Definition: fourvec.h:58
int j
Definition: DBlmapReader.cc:9
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.
int k[5][pyjets_maxn]
Fourvec_Constrainer_Args _fourvec_constrainer_args
Definition: Constrained_Z.h:99
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:56
string const
Definition: compareJSON.py:14
Fourvec & p()
Return a reference to the four-momentum.
dictionary args
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:62
tuple mass
Definition: scaleCards.py:27
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:95
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.