File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -208,18 +208,23 @@ struct RecoDecay {
208208 // / Constrains angle to be within a range.
209209 // / \note Inspired by TVector2::Phi_0_2pi in ROOT.
210210 // / \param angle angle
211- // / \param min minimum of the range
212- // / \return value within [min, min + 2π).
211+ // / \param minimum minimum of the range
212+ // / \param harmonic harmonic number
213+ // / \return value of angle within [minimum, minimum + 2π / harmonic).
213214 template <typename T, typename U = float >
214- static T constrainAngle (T angle, U min = 0 .)
215+ static T constrainAngle (T angle, U minimum = 0 .0F , unsigned int harmonic = 1U )
215216 {
216- while (angle < min) {
217- angle += o2::constants::math::TwoPI;
217+ auto period = o2::constants::math::TwoPI;
218+ if (harmonic != 1U ) {
219+ period /= harmonic;
218220 }
219- while (angle >= min + o2::constants::math::TwoPI ) {
220- angle -= o2::constants::math::TwoPI ;
221+ while (angle < minimum ) {
222+ angle += period ;
221223 }
222- return (T)angle;
224+ while (angle >= minimum + period) {
225+ angle -= period;
226+ }
227+ return angle;
223228 }
224229
225230 // / Calculates cosine of pointing angle.
You can’t perform that action at this time.
0 commit comments