CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
hitfit::Vector_Resolution Class Reference

Calculate and represent resolution for a vector of $p$, pseudorapidity $\eta$, and azimuthal angle $\phi$. An instance of this class holds three Resolution objects, one each for $p$, $\eta$, and $\phi$. In addition, we have a flag to indicate if the momentum resolution is in $p_{T}$ or $p$. This flag is set by appending [/et] at the end of the string. More...

#include <Vector_Resolution.h>

Public Member Functions

const Resolutioneta_res () const
 Return a constant reference to the pseudorapidity resolution. More...
 
double eta_sigma (const Fourvec &v) const
 Calculate the pseudorapidity resolution of a four-momentum. More...
 
const Resolutionp_res () const
 Return a constant reference to the momentum resolution. More...
 
double p_sigma (const Fourvec &v) const
 Calculate the momentum resolution of a four-momentum. More...
 
const Resolutionphi_res () const
 Return a constant reference to the azimuthal angle resolution. More...
 
double phi_sigma (const Fourvec &v) const
 Calculate the azimuthal angle resolution of a four-momentum. More...
 
void smear (Fourvec &v, CLHEP::HepRandomEngine &engine, bool do_smear_dir=false) const
 Smear a four-momentum according to the resolutions. More...
 
bool use_et () const
 Return the use_et flag. More...
 
 Vector_Resolution ()
 Constructor, instantiate an instance of Vector_Resolution with infinite precision. More...
 
 Vector_Resolution (std::string s)
 Constructor, instantiate an instance of Vector_Resolution from a string using format as described in the class description. More...
 
 Vector_Resolution (const Resolution &p_res, const Resolution &eta_res, const Resolution &phi_res, bool use_et=false)
 Constructor, instantiate an instance of Vector_Resolution from three instances of Resolution objects. More...
 

Private Member Functions

void smear_dir (Fourvec &v, CLHEP::HepRandomEngine &engine) const
 Helper function to smear direction. More...
 

Private Attributes

Resolution _eta_res
 
Resolution _p_res
 
Resolution _phi_res
 
bool _use_et
 

Friends

std::ostream & operator<< (std::ostream &s, const Vector_Resolution &r)
 Output stream operator, print the content of this Vector_Resolution object to an output stream. More...
 

Detailed Description

Calculate and represent resolution for a vector of $p$, pseudorapidity $\eta$, and azimuthal angle $\phi$. An instance of this class holds three Resolution objects, one each for $p$, $\eta$, and $\phi$. In addition, we have a flag to indicate if the momentum resolution is in $p_{T}$ or $p$. This flag is set by appending [/et] at the end of the string.

This class is initialized from a string with format

<p-resolution>/<eta-resolution>/<phi-resolution>[/et]

where the resolution formats are given in the documentation for the Resolution class.

Addendum by Haryo Sumowidagdo: When using the inverse flag, only the inverse flag in p-resolution will be used by the fitter to set that flag which says the error in 'p' is really the error on '1/p'. The inverse flag for $\eta$ in eta-resolution and $\phi$ in phi-resolution are not used by the fitter. As usually the angular resolution is of the form

$ \sigma_{\eta,\phi} = \sqrt{\frac{C^{2}}{p^{2}} + \frac{R^{2}}{p} + N^2}$

where $ p $ can be the magnitude of the momentum ( $ p $) or or transverse momentum ( $ p_{T} $), one then can (and should!) use the inverse flag for $ \eta $ and $ \phi $ resolution.

Definition at line 89 of file Vector_Resolution.h.

Constructor & Destructor Documentation

◆ Vector_Resolution() [1/3]

hitfit::Vector_Resolution::Vector_Resolution ( )

Constructor, instantiate an instance of Vector_Resolution with infinite precision.

Definition at line 91 of file Vector_Resolution.cc.

96  : _p_res("0,0,0"),
97  _eta_res("0,0,0"),
98  _phi_res("0,0,0"),
99  _use_et(false)
100 
101  {}

◆ Vector_Resolution() [2/3]

hitfit::Vector_Resolution::Vector_Resolution ( std::string  s)

Constructor, instantiate an instance of Vector_Resolution from a string using format as described in the class description.

Parameters
sString enconding the resolution parameters.

Definition at line 103 of file Vector_Resolution.cc.

111  : _p_res(field(s, 0)), _eta_res(field(s, 1)), _phi_res(field(s, 2)), _use_et(field(s, 3) == "et") {}

◆ Vector_Resolution() [3/3]

hitfit::Vector_Resolution::Vector_Resolution ( const Resolution p_res,
const Resolution eta_res,
const Resolution phi_res,
bool  use_et = false 
)

Constructor, instantiate an instance of Vector_Resolution from three instances of Resolution objects.

Parameters
p_resThe momentum resolution.
eta_resThe pseudorapidity resolution.
phi_resThe azimuthal angle resolution.
use_etIf TRUE then use $p_{T}$ instead of $p$ for momentum resolution.

Definition at line 113 of file Vector_Resolution.cc.

const Resolution & p_res() const
Return a constant reference to the momentum resolution.
const Resolution & phi_res() const
Return a constant reference to the azimuthal angle resolution.
bool use_et() const
Return the use_et flag.
const Resolution & eta_res() const
Return a constant reference to the pseudorapidity resolution.

Member Function Documentation

◆ eta_res()

const Resolution & hitfit::Vector_Resolution::eta_res ( ) const

Return a constant reference to the pseudorapidity resolution.

Definition at line 139 of file Vector_Resolution.cc.

References _eta_res.

146  {
147  return _eta_res;
148  }

◆ eta_sigma()

double hitfit::Vector_Resolution::eta_sigma ( const Fourvec v) const

Calculate the pseudorapidity resolution of a four-momentum.

Parameters
vThe four-momentum.

Definition at line 226 of file Vector_Resolution.cc.

References findQualityFiles::v.

Referenced by hitfit::Lepjets_Event_Lep::eta_sigma().

236  {
237  return find_sigma(v, _eta_res, _use_et);
238  }

◆ p_res()

const Resolution & hitfit::Vector_Resolution::p_res ( ) const

Return a constant reference to the momentum resolution.

Definition at line 128 of file Vector_Resolution.cc.

References _p_res.

135  {
136  return _p_res;
137  }

◆ p_sigma()

double hitfit::Vector_Resolution::p_sigma ( const Fourvec v) const

Calculate the momentum resolution of a four-momentum.

Parameters
vThe four-momentum.

Definition at line 204 of file Vector_Resolution.cc.

References findQualityFiles::v.

Referenced by hitfit::Lepjets_Event_Lep::p_sigma().

214  {
215  double sig = find_sigma(v, _p_res, _use_et);
216  if (_use_et) {
217  if (_p_res.inverse()) {
218  sig *= v.perp() / v.e();
219  } else {
220  sig *= v.e() / v.perp();
221  }
222  }
223  return sig;
224  }
bool inverse() const
Return the setting of the inverse flag.
Definition: Resolution.cc:144

◆ phi_res()

const Resolution & hitfit::Vector_Resolution::phi_res ( ) const

Return a constant reference to the azimuthal angle resolution.

Definition at line 150 of file Vector_Resolution.cc.

References _phi_res.

157  {
158  return _phi_res;
159  }

◆ phi_sigma()

double hitfit::Vector_Resolution::phi_sigma ( const Fourvec v) const

Calculate the azimuthal angle resolution of a four-momentum.

Parameters
vThe four-momentum.

Definition at line 240 of file Vector_Resolution.cc.

References findQualityFiles::v.

Referenced by hitfit::Lepjets_Event_Lep::phi_sigma().

250  {
251  return find_sigma(v, _phi_res, _use_et);
252  }

◆ smear()

void hitfit::Vector_Resolution::smear ( Fourvec v,
CLHEP::HepRandomEngine &  engine,
bool  do_smear_dir = false 
) const

Smear a four-momentum according to the resolutions.

Parameters
vThe four-momentum to smear.
engineThe underlying random number generator.
do_smear_dirIf FALSE, only smear the energy. If TRUE, also smear the direction.

Definition at line 316 of file Vector_Resolution.cc.

References findQualityFiles::v.

Referenced by hitfit::Lepjets_Event_Lep::smear().

328  {
329  double ee = _use_et ? v.perp() : v.e(); // ??? is perp() correct?
330  v *= _p_res.pick(ee, ee, engine) / ee;
331 
332  if (do_smear_dir) {
333  smear_eta(v, ee, _eta_res, engine);
334  smear_phi(v, ee, _phi_res, engine);
335  }
336  }
double pick(double x, double p, CLHEP::HepRandomEngine &engine) const
Generate random value from a Gaussian distribution described by this resolution. Given a value ...
Definition: Resolution.cc:182

◆ smear_dir()

void hitfit::Vector_Resolution::smear_dir ( Fourvec v,
CLHEP::HepRandomEngine &  engine 
) const
private

Helper function to smear direction.

Parameters
vThe four-momentum to smear.
engineThe underlying random number generator.

◆ use_et()

bool hitfit::Vector_Resolution::use_et ( ) const

Return the use_et flag.

Definition at line 161 of file Vector_Resolution.cc.

References _use_et.

168  {
169  return _use_et;
170  }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  s,
const Vector_Resolution r 
)
friend

Output stream operator, print the content of this Vector_Resolution object to an output stream.

Parameters
sThe stream to which to write.
rThe instance of Vector_Resolution to be printed.

Definition at line 346 of file Vector_Resolution.cc.

357  {
358  s << r._p_res << "/ " << r._eta_res << "/ " << r._phi_res;
359  if (r._use_et)
360  s << "/et";
361  s << "\n";
362  return s;
363  }

Member Data Documentation

◆ _eta_res

Resolution hitfit::Vector_Resolution::_eta_res
private

The pseudorapidity resolution.

Definition at line 201 of file Vector_Resolution.h.

Referenced by eta_res().

◆ _p_res

Resolution hitfit::Vector_Resolution::_p_res
private

The momentum resolution.

Definition at line 196 of file Vector_Resolution.h.

Referenced by p_res().

◆ _phi_res

Resolution hitfit::Vector_Resolution::_phi_res
private

The phi resolution.

Definition at line 206 of file Vector_Resolution.h.

Referenced by phi_res().

◆ _use_et

bool hitfit::Vector_Resolution::_use_et
private

The momentum resolution.

Definition at line 211 of file Vector_Resolution.h.

Referenced by use_et().