File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
boosteddmanalysis/Reconstruction Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 3636// ------------------------------------------------------------------------------
3737namespace {
3838
39+ // / Returns the square of the specified value.
40+ template <typename T>
41+ T sqr (T value) { return value * value; }
42+
43+
3944 // / Returns a random value distributed within a truncated Gaussian between
4045 // / `min` and `max`.
4146 double cappedGaus (CLHEP::RandGauss& gaus, double min, double max)
@@ -62,11 +67,16 @@ namespace {
6267 // details of the direction of the displacement rotation around the
6368 // original vector are not relevant.
6469 //
65- double const dr = dtheta* v.R ();
70+ // In the end, we restore the modulus of the vector.
71+ //
72+ if (dtheta == 0.0 ) return v; // actually, no smearing
73+ double const vR = v.R ();
74+ double const dr = dtheta* vR;
6675 geo::Vector_t dv { dr * std::cos (dphi), dr * std::sin (dphi), 0.0 };
6776 auto const rotation
6877 = ROOT::Math::RotationZ (v.Phi ()) * ROOT::Math::RotationY (v.Theta ());
69- return v + rotation * dv;
78+ double const rescale = std::sqrt (1.0 / (1.0 + sqr (dr/vR)));
79+ return rescale * (v + rotation * dv);
7080 }
7181
7282} // local namespace
You can’t perform that action at this time.
0 commit comments