test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Fourvec_Event.cc
Go to the documentation of this file.
1 //
2 //
3 // File: src/Fourvec_Event.cc
4 // Purpose: Represent an event for kinematic fitting as a collection
5 // of 4-vectors.
6 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
7 //
8 // CMSSW File : src/Fourvec_Event.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 
13 
15 #include <cassert>
16 #include <ostream>
17 
18 
42 using std::ostream;
43 
44 
45 namespace hitfit {
46 
47 
48 FE_Obj::FE_Obj (const Fourvec& the_p,
49  double the_mass,
50  int the_label,
51  double the_p_error,
52  double the_phi_error,
53  double the_eta_error,
54  bool the_muon_p)
55 //
56 // Purpose: Contructor.
57 //
58 // Inputs:
59 // the_p - 4-momentum.
60 // the_mass - The mass of the object.
61 // The constrained fit will fix the mass to this value.
62 // the_p_error - Uncertainty in p (or, if the_muon_p is set, in 1/p).
63 // the_phi_error-Uncertainty in phi.
64 // the_eta_error-Uncertainty in eta.
65 // the_muon_p - If true, the `p' uncertainty is in 1/p, and 1/p
66 // should be used as the fit variable instead of p.
67 //
68  : p (the_p),
69  mass (the_mass),
70  label (the_label),
71  p_error (the_p_error),
72  phi_error (the_phi_error),
73  eta_error (the_eta_error),
74  muon_p (the_muon_p)
75 {
76 }
77 
78 
87 std::ostream& operator<< (std::ostream& s, const FE_Obj& o)
88 //
89 // Purpose: Print the object to S.
90 //
91 // Inputs:
92 // s - The stream to which to write.
93 // o - The object to write.
94 //
95 // Returns:
96 // The stream S.
97 //
98 {
99  s << o.p << " - " << o.mass << " - " << o.label << "\n";
100  s << " errors: " << o.p_error << " " << o.phi_error << " " << o.eta_error;
101  if (o.muon_p)
102  s << " (mu)";
103  s << "\n";
104  return s;
105 }
106 
107 
108 //************************************************************************
109 
110 
112 //
113 // Purpose: Constructor.
114 //
115  : _kt_x_error (0),
116  _kt_y_error (0),
117  _kt_xy_covar (0),
118  _has_neutrino (false)
119 {
120 }
121 
122 
124 //
125 // Purpose: Return true if this event has a neutrino.
126 //
127 // Returns:
128 // True if this event has a neutrino.
129 //
130 {
131  return _has_neutrino;
132 }
133 
134 
136 //
137 // Purpose: Return the number of objects in the event, not including
138 // any neutrino.
139 //
140 // Returns:
141 // The number of objects in the event, not including any neutrino.
142 //
143 {
144  return _objs.size() - (_has_neutrino ? 1 : 0);
145 }
146 
147 
149 //
150 // Purpose: Return the number of objects in the event, including any neutrino.
151 //
152 // Returns:
153 // The number of objects in the event, including any neutrino.
154 //
155 {
156  return _objs.size();
157 }
158 
159 
161 //
162 // Purpose: Access object I.
163 //
164 // Inputs:
165 // i - The index of the desired object (0-based indexing).
166 //
167 {
168  assert (i < _objs.size ());
169  return _objs[i];
170 }
171 
172 
174 //
175 // Purpose: Access the neutrino 4-vector.
176 //
177 {
179  return _objs.back().p;
180 }
181 
182 
184 //
185 // Purpose: Access the kt 4-vector.
186 //
187 {
188  return _kt;
189 }
190 
191 
193 //
194 // Purpose: Access the X 4-vector.
195 //
196 {
197  return _x;
198 }
199 
200 
202 //
203 // Purpose: Return the X uncertainty in kt.
204 //
205 // Returns:
206 // The X uncertainty in kt.
207 //
208 {
209  return _kt_x_error;
210 }
211 
212 
214 //
215 // Purpose: Return the Y uncertainty in kt.
216 //
217 // Returns:
218 // The Y uncertainty in kt.
219 //
220 {
221  return _kt_y_error;
222 }
223 
224 
226 //
227 // Purpose: Return the kt XY covariance.
228 //
229 // Returns:
230 // The kt XY covariance.
231 //
232 {
233  return _kt_xy_covar;
234 }
235 
236 
245 std::ostream& operator<< (std::ostream& s, const Fourvec_Event& fe)
246 //
247 // Purpose: Print out the contents of the class.
248 //
249 // Inputs:
250 // s - The stream to which to write.
251 // fe - The object to write.
252 //
253 // Returns:
254 // The stream S.
255 //
256 {
257  s << "kt: (" << fe._kt.x() << ", " << fe._kt.y() << "); "
258  << " error: " << fe._kt_x_error << " " << fe._kt_y_error << " "
259  << fe._kt_xy_covar << "\n";
260  s << "x: " << fe._x << "\n";
261  for (unsigned i = 0; i < fe._objs.size(); i++)
262  s << i+1 << ": " << fe._objs[i];
263  return s;
264 }
265 
266 
268 //
269 // Purpose: Add an object to the event.
270 //
271 // Inputs:
272 // obj - The object to add.
273 // It should not be a neutrino.
274 //
275 {
276  assert (obj.label != nu_label);
277 
278  // Add to the end of the list, but before any neutrino.
279  if (_has_neutrino) {
280  assert (_objs.size() > 0);
281  _objs.insert (_objs.begin() + _objs.size() - 1, obj);
282  }
283  else
284  _objs.push_back (obj);
285 
286  // Maintain kt.
287  _kt += obj.p;
288 }
289 
290 
292 //
293 // Purpose: Set the neutrino 4-momentum to P.
294 // This adds a neutrino if there wasn't one there already.
295 //
296 // Inputs:
297 // p - The new 4-momentum of the neutrino.
298 //
299 {
300  if (_has_neutrino) {
301  _kt -= _objs.back().p;
302  _objs.back().p = p;
303  }
304  else {
305  _has_neutrino = true;
306  _objs.push_back (FE_Obj (p, 0, nu_label, 0, 0, 0, false));
307  }
308 
309  _kt += p;
310 }
311 
312 
314 //
315 // Purpose: Set object I's 4-momentum to P.
316 //
317 // Inputs:
318 // i - The index of the object to change (0-based indexing).
319 // p - The new 4-momentum.
320 //
321 {
322  assert (i < _objs.size ());
323  _kt -= _objs[i].p;
324  _objs[i].p = p;
325  _kt += p;
326 }
327 
328 
330 //
331 // Purpose: Set the momentum of the X object to P.
332 //
333 // Inputs:
334 // p - The new 4-momentum.
335 //
336 {
337  _kt -= _x;
338  _x = p;
339  _kt += p;
340 }
341 
342 
343 void Fourvec_Event::set_kt_error (double kt_x_error,
344  double kt_y_error,
345  double kt_xy_covar)
346 //
347 // Purpose: Set the kt uncertainties.
348 //
349 // Inputs:
350 // kt_x_error - The uncertainty in the X component of kt.
351 // kt_y_error - The uncertainty in the Y component of kt.
352 // kt_xy_covar - The covariance between the X and Y components.
353 //
354 {
358 }
359 
360 
361 } // namespace hitfit
362 
int i
Definition: DBlmapReader.cc:9
Fourvec_Event()
Default constructor.
void set_kt_error(double kt_x_error, double kt_y_error, double kt_xy_covar)
Set the uncertainties on .
Represent an event for kinematic fitting as a collection of four-momenta. Each object is represented ...
void add(const FE_Obj &obj)
Add an object to the event. The object should not be a neutrino, use the method set_nu_p for that...
assert(m_qm.get())
const int nu_label
const FE_Obj & obj(std::vector< FE_Obj >::size_type i) const
Access object at index i, with the convention that the index starts at 0.
uint16_t size_type
int nobjs() const
Return the number of objects in the event not including any neutrinos.
std::vector< FE_Obj > _objs
double kt_y_error() const
Return the y uncertainty in .
double kt_xy_covar() const
Return the xy covariance in .
CLHEP::HepLorentzVector Fourvec
Typedef for a HepLorentzVector.
Definition: fourvec.h:57
int nobjs_all() const
Return the number of objects in the event including any neutrinos.
void set_nu_p(const Fourvec &p)
Set the neutrino four-momentum to . This method adds a neutrino if there wasn&#39;t already one...
void set_obj_p(std::vector< FE_Obj >::size_type i, const Fourvec &p)
Set the four-momentum of object at index i to .
void set_x_p(const Fourvec &p)
Set the four-momentum of the object.
const Fourvec & kt() const
Access the four-momentum.
string const
Definition: compareJSON.py:14
std::ostream & operator<<(std::ostream &s, const Constraint_Intermed &ci)
Output stream operator, print the content of this Constraint_Intermed to an output stream...
FE_Obj(const Fourvec &the_p, double the_mass, int the_label, double the_p_error, double the_phi_error, double the_eta_error, bool the_muon_p)
Constructor.
volatile std::atomic< bool > shutdown_flag false
double kt_x_error() const
Return the x uncertainty in .
Represent a single object in a Fourvec_Event, this is just a dumb data container. Each object in a Fo...
Definition: Fourvec_Event.h:94
const Fourvec & x() const
Access the four-momentum.
const Fourvec & nu() const
Access the neutrino four-momentum.
Represent an event for kinematic fitting as a collection of four-momenta.
bool has_neutrino() const
Return TRUE is this event contains a neutrino, otherwise returns FALSE.