Exemple #1
0
 def _validate_NuFlav(self, signature):
     if self.interactions:
         if not isinstance(signature, flavInt.NuFlavInt):
             signature = flavInt.NuFlavInt(signature)
     else:
         if not isinstance(signature, flavInt.NuFlav):
             signature = flavInt.NuFlav(signature)
     if signature not in self._spline_dict:
         raise ValueError('signature {0} not loaded, choices are: '
                          '{1}'.format(signature, self._spline_dict.keys()))
     return signature
Exemple #2
0
 def __getattr__(self, attr):
     try:
         if self.interactions:
             sign = str(flavInt.NuFlavInt(attr))
         else:
             sign = str(flavInt.NuFlav(attr))
     except:
         raise ValueError('{0} is not a value signature'.format(attr))
     for signature in self._spline_data.iterkeys():
         if self._spline_data[signature].name == sign:
             return self._spline_data[signature]
     return super(CombinedSpline, self).__getattribute__(sign)
Exemple #3
0
    def __init__(self, inSpline, interactions=True, ver=None):
        super(CombinedSpline, self).__init__()
        self.interactions = interactions

        if isinstance(inSpline, Spline):
            inSpline = [inSpline]
        if not all(isinstance(x, Spline) for x in inSpline):
            raise TypeError('Argument/object unhandled type: '
                            '{0}'.format(type(inSpline)))

        if interactions:
            self._spline_dict = {flavInt.NuFlavInt(flavint.name): flavint
                                 for flavint in inSpline}
            self._spline_data = {flavInt.NuFlavInt(flavint.name): None
                                 for flavint in inSpline}
        else:
            self._spline_dict = {flavInt.NuFlav(flav.name): flav
                                 for flav in inSpline}
            self._spline_data = {flavInt.NuFlav(flav.name): None
                                 for flav in inSpline}
        self._update_data_dict()
Exemple #4
0
    def barnobarfract(self,
                      barnobar=None,
                      is_particle=None,
                      flav_or_flavint=None):
        """Fraction of events generated (either particles or antiparticles).

        Specifying whether you want the fraction for particle or
        antiparticle is done by specifying one (and only one) of the three
        parameters:
            `barnobar`, `is_particle` or `flav_or_flavint`

        Parameters
        ----------
        barnobar : None or int
            -1 for antiparticle, +1 for particle
        is_particle : None or bool
            True for particle, false for antiparticle
        flav_or_flavint : None or convertible to NuFlav or NuFlavInt
            Particle or antiparticles is determined from the flavor or flavint
            passed

        """
        nargs = sum([(not barnobar is None), (not is_particle is None),
                     (not flav_or_flavint is None)])
        if nargs != 1:
            raise ValueError('One and only one of `barnobar`, `is_particle`,'
                             ' and `flav_or_flavint` must be specified. Got'
                             ' %d non-None args instead.' % nargs)

        if flav_or_flavint is not None:
            is_particle = flavInt.NuFlavInt(flav_or_flavint).particle
        elif barnobar is not None:
            is_particle = barnobar > 0

        if is_particle:
            return self['nu_to_total_fract']
        return 1 - self['nu_to_total_fract']