def simple_inside(self, x):
        """
        Check if the point x is inside the phase space
        """
        ma1a2 = self.m_a1a2(x)
        mb1b2 = self.m_b1b2(x)
        ctha = self.cos_helicity_a(x)
        cthb = self.cos_helicity_b(x)
        phi = self.phi(x)

        inside = tf.logical_and(
            tf.logical_and(tf.greater(ctha, self.costhamin),
                           tf.less(ctha, self.costhamax)),
            tf.logical_and(tf.greater(cthb, self.costhbmin),
                           tf.less(cthb, self.costhbmax)),
        )
        inside = tf.logical_and(
            inside,
            tf.logical_and(tf.greater(phi, -math.pi), tf.less(phi, math.pi)))

        mb1b2max = atfi.min(atfi.cast_real(self.mb1b2max),
                            atfi.cast_real(self.md) - ma1a2)

        inside = tf.logical_and(
            inside,
            tf.logical_and(tf.greater(ma1a2, self.ma1a2min),
                           tf.less(ma1a2, self.ma1a2max)),
        )
        inside = tf.logical_and(
            inside,
            tf.logical_and(tf.greater(mb1b2, self.mb1b2min),
                           tf.less(mb1b2, mb1b2max)),
        )

        return inside
Exemple #2
0
def generate_exp(rnd, x1, x2, alpha=None):
    """
    Exponential random distribution with constant "alpha", 
    limited to the range x1 to x2
  """
    if isinstance(x1, float): x1 = atfi.const(x1)
    if isinstance(x2, float): x2 = atfi.const(x2)
    if alpha is None or alpha == 0:
        return uniform_random(rnd, x1, x2)
    else:
        if isinstance(alpha, float): alpha = atfi.const(alpha)
        xi1 = atfi.exp(-x1 / alpha)
        xi2 = atfi.exp(-x2 / alpha)
        ximin = atfi.min(xi1, xi2)
        ximax = atfi.max(xi1, xi2)
        return atfi.abs(alpha * atfi.log(uniform_random(rnd, ximin, ximax)))