CMS 3D CMS Logo

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 
14 #include <cassert>
15 #include <ostream>
16 
40 using std::ostream;
41 
42 namespace hitfit {
43 
44  FE_Obj::FE_Obj(const Fourvec& the_p,
45  double the_mass,
46  int the_label,
47  double the_p_error,
48  double the_phi_error,
49  double the_eta_error,
50  bool the_muon_p)
51  //
52  // Purpose: Contructor.
53  //
54  // Inputs:
55  // the_p - 4-momentum.
56  // the_mass - The mass of the object.
57  // The constrained fit will fix the mass to this value.
58  // the_p_error - Uncertainty in p (or, if the_muon_p is set, in 1/p).
59  // the_phi_error-Uncertainty in phi.
60  // the_eta_error-Uncertainty in eta.
61  // the_muon_p - If true, the `p' uncertainty is in 1/p, and 1/p
62  // should be used as the fit variable instead of p.
63  //
64  : p(the_p),
65  mass(the_mass),
66  label(the_label),
67  p_error(the_p_error),
68  phi_error(the_phi_error),
69  eta_error(the_eta_error),
70  muon_p(the_muon_p) {}
71 
80  std::ostream& operator<<(std::ostream& s, const FE_Obj& o)
81  //
82  // Purpose: Print the object to S.
83  //
84  // Inputs:
85  // s - The stream to which to write.
86  // o - The object to write.
87  //
88  // Returns:
89  // The stream S.
90  //
91  {
92  s << o.p << " - " << o.mass << " - " << o.label << "\n";
93  s << " errors: " << o.p_error << " " << o.phi_error << " " << o.eta_error;
94  if (o.muon_p)
95  s << " (mu)";
96  s << "\n";
97  return s;
98  }
99 
100  //************************************************************************
101 
103  //
104  // Purpose: Constructor.
105  //
106  : _kt_x_error(0), _kt_y_error(0), _kt_xy_covar(0), _has_neutrino(false) {}
107 
109  //
110  // Purpose: Return true if this event has a neutrino.
111  //
112  // Returns:
113  // True if this event has a neutrino.
114  //
115  {
116  return _has_neutrino;
117  }
118 
120  //
121  // Purpose: Return the number of objects in the event, not including
122  // any neutrino.
123  //
124  // Returns:
125  // The number of objects in the event, not including any neutrino.
126  //
127  {
128  return _objs.size() - (_has_neutrino ? 1 : 0);
129  }
130 
132  //
133  // Purpose: Return the number of objects in the event, including any neutrino.
134  //
135  // Returns:
136  // The number of objects in the event, including any neutrino.
137  //
138  {
139  return _objs.size();
140  }
141 
143  //
144  // Purpose: Access object I.
145  //
146  // Inputs:
147  // i - The index of the desired object (0-based indexing).
148  //
149  {
150  assert(i < _objs.size());
151  return _objs[i];
152  }
153 
155  //
156  // Purpose: Access the neutrino 4-vector.
157  //
158  {
160  return _objs.back().p;
161  }
162 
164  //
165  // Purpose: Access the kt 4-vector.
166  //
167  {
168  return _kt;
169  }
170 
172  //
173  // Purpose: Access the X 4-vector.
174  //
175  {
176  return _x;
177  }
178 
180  //
181  // Purpose: Return the X uncertainty in kt.
182  //
183  // Returns:
184  // The X uncertainty in kt.
185  //
186  {
187  return _kt_x_error;
188  }
189 
191  //
192  // Purpose: Return the Y uncertainty in kt.
193  //
194  // Returns:
195  // The Y uncertainty in kt.
196  //
197  {
198  return _kt_y_error;
199  }
200 
202  //
203  // Purpose: Return the kt XY covariance.
204  //
205  // Returns:
206  // The kt XY covariance.
207  //
208  {
209  return _kt_xy_covar;
210  }
211 
220  std::ostream& operator<<(std::ostream& s, const Fourvec_Event& fe)
221  //
222  // Purpose: Print out the contents of the class.
223  //
224  // Inputs:
225  // s - The stream to which to write.
226  // fe - The object to write.
227  //
228  // Returns:
229  // The stream S.
230  //
231  {
232  s << "kt: (" << fe._kt.x() << ", " << fe._kt.y() << "); "
233  << " error: " << fe._kt_x_error << " " << fe._kt_y_error << " " << fe._kt_xy_covar << "\n";
234  s << "x: " << fe._x << "\n";
235  for (unsigned i = 0; i < fe._objs.size(); i++)
236  s << i + 1 << ": " << fe._objs[i];
237  return s;
238  }
239 
241  //
242  // Purpose: Add an object to the event.
243  //
244  // Inputs:
245  // obj - The object to add.
246  // It should not be a neutrino.
247  //
248  {
249  assert(obj.label != nu_label);
250 
251  // Add to the end of the list, but before any neutrino.
252  if (_has_neutrino) {
253  assert(!_objs.empty());
254  _objs.insert(_objs.begin() + _objs.size() - 1, obj);
255  } else
256  _objs.push_back(obj);
257 
258  // Maintain kt.
259  _kt += obj.p;
260  }
261 
263  //
264  // Purpose: Set the neutrino 4-momentum to P.
265  // This adds a neutrino if there wasn't one there already.
266  //
267  // Inputs:
268  // p - The new 4-momentum of the neutrino.
269  //
270  {
271  if (_has_neutrino) {
272  _kt -= _objs.back().p;
273  _objs.back().p = p;
274  } else {
275  _has_neutrino = true;
276  _objs.push_back(FE_Obj(p, 0, nu_label, 0, 0, 0, false));
277  }
278 
279  _kt += p;
280  }
281 
283  //
284  // Purpose: Set object I's 4-momentum to P.
285  //
286  // Inputs:
287  // i - The index of the object to change (0-based indexing).
288  // p - The new 4-momentum.
289  //
290  {
291  assert(i < _objs.size());
292  _kt -= _objs[i].p;
293  _objs[i].p = p;
294  _kt += p;
295  }
296 
298  //
299  // Purpose: Set the momentum of the X object to P.
300  //
301  // Inputs:
302  // p - The new 4-momentum.
303  //
304  {
305  _kt -= _x;
306  _x = p;
307  _kt += p;
308  }
309 
310  void Fourvec_Event::set_kt_error(double kt_x_error, double kt_y_error, double kt_xy_covar)
311  //
312  // Purpose: Set the kt uncertainties.
313  //
314  // Inputs:
315  // kt_x_error - The uncertainty in the X component of kt.
316  // kt_y_error - The uncertainty in the Y component of kt.
317  // kt_xy_covar - The covariance between the X and Y components.
318  //
319  {
323  }
324 
325 } // namespace hitfit
hitfit::Fourvec_Event::kt
const Fourvec & kt() const
Access the four-momentum.
Definition: Fourvec_Event.cc:163
mps_fire.i
i
Definition: mps_fire.py:428
hitfit::Fourvec_Event::set_kt_error
void set_kt_error(double kt_x_error, double kt_y_error, double kt_xy_covar)
Set the uncertainties on .
Definition: Fourvec_Event.cc:310
hitfit
Definition: Base_Constrainer.h:43
hitfit::Fourvec
CLHEP::HepLorentzVector Fourvec
Typedef for a HepLorentzVector.
Definition: fourvec.h:55
funct::false
false
Definition: Factorize.h:29
Fourvec_Event.h
Represent an event for kinematic fitting as a collection of four-momenta.
cms::cuda::assert
assert(be >=bs)
watchdog.const
const
Definition: watchdog.py:83
hitfit::Fourvec_Event::obj
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.
Definition: Fourvec_Event.cc:142
hitfit::Fourvec_Event::_kt
Fourvec _kt
Definition: Fourvec_Event.h:345
hitfit::Fourvec_Event
Represent an event for kinematic fitting as a collection of four-momenta. Each object is represented ...
Definition: Fourvec_Event.h:193
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
hitfit::Fourvec_Event::nu
const Fourvec & nu() const
Access the neutrino four-momentum.
Definition: Fourvec_Event.cc:154
hitfit::FE_Obj
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
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
hitfit::Fourvec_Event::kt_y_error
double kt_y_error() const
Return the y uncertainty in .
Definition: Fourvec_Event.cc:190
hitfit::Fourvec_Event::set_nu_p
void set_nu_p(const Fourvec &p)
Set the neutrino four-momentum to . This method adds a neutrino if there wasn't already one.
Definition: Fourvec_Event.cc:262
hitfit::operator<<
std::ostream & operator<<(std::ostream &s, const Constraint_Intermed &ci)
Output stream operator, print the content of this Constraint_Intermed to an output stream.
Definition: Constraint_Intermed.cc:268
hitfit::Fourvec_Event::has_neutrino
bool has_neutrino() const
Return TRUE is this event contains a neutrino, otherwise returns FALSE.
Definition: Fourvec_Event.cc:108
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
hitfit::Fourvec_Event::_objs
std::vector< FE_Obj > _objs
Definition: Fourvec_Event.h:337
hitfit::Fourvec_Event::kt_x_error
double kt_x_error() const
Return the x uncertainty in .
Definition: Fourvec_Event.cc:179
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
hitfit::FE_Obj::label
int label
Definition: Fourvec_Event.h:114
hitfit::Fourvec_Event::_kt_xy_covar
double _kt_xy_covar
Definition: Fourvec_Event.h:366
hitfit::Fourvec_Event::nobjs_all
int nobjs_all() const
Return the number of objects in the event including any neutrinos.
Definition: Fourvec_Event.cc:131
hitfit::Fourvec_Event::_kt_x_error
double _kt_x_error
Definition: Fourvec_Event.h:356
hitfit::Fourvec_Event::set_x_p
void set_x_p(const Fourvec &p)
Set the four-momentum of the object.
Definition: Fourvec_Event.cc:297
hitfit::Fourvec_Event::x
const Fourvec & x() const
Access the four-momentum.
Definition: Fourvec_Event.cc:171
hitfit::Fourvec_Event::add
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.
Definition: Fourvec_Event.cc:240
hitfit::nu_label
const int nu_label
Definition: Fourvec_Event.h:178
hitfit::FE_Obj::p
Fourvec p
Definition: Fourvec_Event.h:100
hitfit::Fourvec_Event::nobjs
int nobjs() const
Return the number of objects in the event not including any neutrinos.
Definition: Fourvec_Event.cc:119
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
hitfit::Fourvec_Event::kt_xy_covar
double kt_xy_covar() const
Return the xy covariance in .
Definition: Fourvec_Event.cc:201
hitfit::Fourvec_Event::_kt_y_error
double _kt_y_error
Definition: Fourvec_Event.h:360
hitfit::Fourvec_Event::set_obj_p
void set_obj_p(std::vector< FE_Obj >::size_type i, const Fourvec &p)
Set the four-momentum of object at index i to .
Definition: Fourvec_Event.cc:282
hitfit::FE_Obj::FE_Obj
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.
Definition: Fourvec_Event.cc:44
hitfit::Fourvec_Event::Fourvec_Event
Fourvec_Event()
Default constructor.
Definition: Fourvec_Event.cc:102
hitfit::Fourvec_Event::_x
Fourvec _x
Definition: Fourvec_Event.h:351
label
const char * label
Definition: PFTauDecayModeTools.cc:11
hitfit::Fourvec_Event::_has_neutrino
bool _has_neutrino
Definition: Fourvec_Event.h:372