Jpp test-rotations-old-57-g407471f53
the software that should make you happy
Loading...
Searching...
No Matches
JAANET::JEvtCategoryMap< JFluxHelper > Class Referencefinal

Template specialisation for a map between event categories and flux factors. More...

#include <JEvtCategoryMap.hh>

Inheritance diagram for JAANET::JEvtCategoryMap< JFluxHelper >:
std::map< JEvtCategoryHelper, JFluxHelper > JLANG::JClonable< JClonable_t, JDerived_t >

Classes

struct  JEvtCategoryMapHelper
 Auxiliary class for I/O of map of event categories and weight factors. More...
 

Public Types

typedef JEvtCategoryMap< JFluxHelperJEvtCategoryMap_t
 
typedef std::map< JEvtCategoryHelper, JFluxHelpermap_type
 
typedef map_type::iterator iterator
 
typedef map_type::const_iterator const_iterator
 
typedef JClonable< JClonable_t >::clone_type clone_type
 

Public Member Functions

 JEvtCategoryMap ()
 Default constructor.
 
 JEvtCategoryMap (const JOscProbHelper &oscProb)
 Constructor.
 
 JEvtCategoryMap (const JOscProbHelper &oscProb, const JEvtCategoryHelper &category, const JFluxHelper &factor)
 Constructor.
 
template<class ... Args>
 JEvtCategoryMap (const JOscProbHelper &oscProb, const JEvtCategoryHelper &category, const JFluxHelper &factor, const Args &...args)
 Constructor.
 
 JEvtCategoryMap (const JEvtCategoryHelper &category, const JFluxHelper &flux)
 Constructor.
 
template<class ... Args>
 JEvtCategoryMap (const JEvtCategoryHelper &category, const JFluxHelper &flux, const Args &...args)
 Constructor.
 
void insert (const JEvtCategoryHelper &category, const JFluxHelper &flux)
 Insert pair of an event category and a flux function.
 
template<class ... Args>
void insert (const JEvtCategoryHelper &category, const JFluxHelper &flux, const Args &...args)
 Insert pairs of event categories and flux functions.
 
const JOscProbHelpergetOscProb () const
 Get oscillation probability calculator.
 
size_t setOscProb (const JOscProbHelper &oscProb)
 Set oscillation probability calculator for all compatible flux factors.
 
double getFactor (const Evt &evt) const override final
 Get weight factor of given event.
 
bool is_valid () const override final
 Check whether this flux factor is valid.
 
JProperties getProperties (const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
 Get properties of this class.
 
JProperties getProperties (const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const override final
 Get properties of this class.
 
std::istream & read (std::istream &in) override final
 Read map between event categories and flux factors.
 
std::ostream & write (std::ostream &out) const override final
 Write event-weight factor to output.
 
virtual clone_type clone () const override
 Get clone of this object.
 

Private Attributes

JOscProbHelper oscProb
 oscillation probability calculator
 

Detailed Description

Template specialisation for a map between event categories and flux factors.

The input syntax follows the following scheme:

[oscillation probabilities configuration] (<categories> <flux>)+,

in which:

  • oscillation probabilities configuration refers to an optional specification of the oscillation parameters, which can be given according to one of the following formats:
    1. <oscprob_file>;,
    2. oscprob=<oscprob_file>;,
    3. <oscprob_key>=<oscprob_value>[<end of line> <oscprob_key>=<oscprob_value>]+; or
    4. oscprob.<oscprob_key>=<oscprob_value>[<end of line> oscprob.<oscprob_key>=<oscprob_value>]+;, where:
    • oscprob_key refers to an oscillation probability calculator configuration key;
    • oscprob_value to an oscillation probability calculator configuration value and
    • oscprob_file to an oscillation probability calculator configuration file with key-value pairs,
  • categories refers to a set of event categories, which can be specified according to one of the following formats:
    1. <PDG type> [ & <PDG type>]+;
    2. <key>=<value>[<end of line> <key>=<value>]+ [ & <key>=<value>[<end of line> <key>=<value>]+ ]+; where:
    • PDG type refers to a PDG identifier;
    • key to one of the data members of a data structure derived from JAANET::JEvtCategory and
    • value to the corresponding value;
  • flux refers to a flux, which needs to be specified according to the following format:
    1. <flux identifier> [<flux arguments>];, where:
    • flux identifier refers to an event-weight flux identifier (c.f. JAANET::JFluxDictionary::factors); and
    • flux arguments to the list of arguments for the corresponding flux,
  • each set of arguments for the oscillation probabilities, an event category or flux needs to be separated by a semi-colon (';') and
  • multiple event categories can be specified as a group, separated by the '&' character.

Definition at line 607 of file JEvtCategoryMap.hh.

Member Typedef Documentation

◆ JEvtCategoryMap_t

Definition at line 613 of file JEvtCategoryMap.hh.

◆ map_type

◆ iterator

map_type::iterator JAANET::JEvtCategoryMap< JFluxHelper >::iterator

Definition at line 617 of file JEvtCategoryMap.hh.

◆ const_iterator

map_type::const_iterator JAANET::JEvtCategoryMap< JFluxHelper >::const_iterator

Definition at line 618 of file JEvtCategoryMap.hh.

◆ clone_type

template<class JClonable_t , class JDerived_t >
JClonable<JClonable_t>::clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone_type
inherited

Definition at line 61 of file JClonable.hh.

Constructor & Destructor Documentation

◆ JEvtCategoryMap() [1/6]

JAANET::JEvtCategoryMap< JFluxHelper >::JEvtCategoryMap ( )
inline

Default constructor.

Definition at line 625 of file JEvtCategoryMap.hh.

625 :
626 map_type(),
627 oscProb(JOscProbInterpolator<>())
628 {}
JOscProbHelper oscProb
oscillation probability calculator
std::map< JEvtCategoryHelper, JFluxHelper > map_type

◆ JEvtCategoryMap() [2/6]

JAANET::JEvtCategoryMap< JFluxHelper >::JEvtCategoryMap ( const JOscProbHelper & oscProb)
inline

Constructor.

Parameters
oscProboscillation probability calculator

Definition at line 636 of file JEvtCategoryMap.hh.

636 :
637 map_type(),
639 {}

◆ JEvtCategoryMap() [3/6]

JAANET::JEvtCategoryMap< JFluxHelper >::JEvtCategoryMap ( const JOscProbHelper & oscProb,
const JEvtCategoryHelper & category,
const JFluxHelper & factor )
inline

Constructor.

Parameters
oscProboscillation probability calculator
categoryevent category
factorevent-weight factor

Definition at line 649 of file JEvtCategoryMap.hh.

651 :
652 map_type(),
654 {
655 insert(category, factor);
656 }
void insert(const JEvtCategoryHelper &category, const JFluxHelper &flux)
Insert pair of an event category and a flux function.

◆ JEvtCategoryMap() [4/6]

template<class ... Args>
JAANET::JEvtCategoryMap< JFluxHelper >::JEvtCategoryMap ( const JOscProbHelper & oscProb,
const JEvtCategoryHelper & category,
const JFluxHelper & factor,
const Args &... args )
inline

Constructor.

Parameters
oscProboscillation probability calculator
categoryevent category
factorevent-weight factor
argsremaining pairs of event categories and event-weight factors

Definition at line 668 of file JEvtCategoryMap.hh.

671 :
672 map_type(),
674 {
675 insert(category, factor, args...);
676 }

◆ JEvtCategoryMap() [5/6]

JAANET::JEvtCategoryMap< JFluxHelper >::JEvtCategoryMap ( const JEvtCategoryHelper & category,
const JFluxHelper & flux )
inline

Constructor.

Parameters
categoryevent category
fluxflux function

Definition at line 685 of file JEvtCategoryMap.hh.

686 :
687 map_type(),
688 oscProb()
689 {
690 insert(category, flux);
691 }

◆ JEvtCategoryMap() [6/6]

template<class ... Args>
JAANET::JEvtCategoryMap< JFluxHelper >::JEvtCategoryMap ( const JEvtCategoryHelper & category,
const JFluxHelper & flux,
const Args &... args )
inline

Constructor.

Parameters
categoryevent category
fluxflux function
argsremaining pairs of event categories and flux functions

Definition at line 703 of file JEvtCategoryMap.hh.

705 :
706 map_type()
707 {
708 insert(category, flux, args...);
709 }

Member Function Documentation

◆ insert() [1/2]

void JAANET::JEvtCategoryMap< JFluxHelper >::insert ( const JEvtCategoryHelper & category,
const JFluxHelper & flux )
inline

Insert pair of an event category and a flux function.

Parameters
categoryevent category
fluxflux function

Definition at line 718 of file JEvtCategoryMap.hh.

720 {
721 map_type::insert(std::make_pair(category, flux));
722 }

◆ insert() [2/2]

template<class ... Args>
void JAANET::JEvtCategoryMap< JFluxHelper >::insert ( const JEvtCategoryHelper & category,
const JFluxHelper & flux,
const Args &... args )
inline

Insert pairs of event categories and flux functions.

Parameters
categoryevent category
fluxflux function
argsremaining pairs of event categories and flux functions

Definition at line 733 of file JEvtCategoryMap.hh.

736 {
737 insert(category, flux);
738 insert(args...);
739 }

◆ getOscProb()

const JOscProbHelper & JAANET::JEvtCategoryMap< JFluxHelper >::getOscProb ( ) const
inline

Get oscillation probability calculator.

Returns
oscillation probability calculator

Definition at line 747 of file JEvtCategoryMap.hh.

748 {
749 return oscProb;
750 }

◆ setOscProb()

size_t JAANET::JEvtCategoryMap< JFluxHelper >::setOscProb ( const JOscProbHelper & oscProb)
inline

Set oscillation probability calculator for all compatible flux factors.

Parameters
oscProboscillation probability calculator
Returns
number of modified event weighters

Definition at line 759 of file JEvtCategoryMap.hh.

760 {
761 using namespace JPP;
762
763 if (oscProb) {
764
765 size_t n = 0;
766
767 this->oscProb = oscProb;
768
769 for (iterator i = this->begin(); i != this->end(); ++i) {
770
771 JOscFlux* p = dynamic_cast<JOscFlux*>(&(i->second.getFlux()));
772
773 if (p != NULL) {
775 ++n;
776 }
777 }
778
779 return n;
780
781 } else {
782
783 THROW(JNullPointerException, "JEvtCategoryMap<JFluxHelper>::setOscProb(): Given oscillation probability function is invalid.");
784 }
785 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for null pointer operation.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const int n
Definition JPolint.hh:791
Implementation of oscillated neutrino flux.
Definition JOscFlux.hh:44
void setOscProb(const JOscProbHelper oscProb)
Set oscillation probability calculator.
Definition JOscFlux.hh:76

◆ getFactor()

double JAANET::JEvtCategoryMap< JFluxHelper >::getFactor ( const Evt & evt) const
inlinefinaloverride

Get weight factor of given event.

Parameters
evtevent
Returns
weight-factor for given event

Definition at line 794 of file JEvtCategoryMap.hh.

795 {
796 using namespace JPP;
797
798 for (typename map_type::const_iterator i = this->cbegin(); i != this->cend(); ++i) {
799 if (i->first.match(evt)) {
800 return i->second.getFactor(evt);
801 }
802 }
803
804 THROW(JValueOutOfRange, "JEvtCategoryMap<JFluxHelper>::getFactor(): No flux factor for given event.");
805 }
Exception for accessing a value in a collection that is outside of its range.

◆ is_valid()

bool JAANET::JEvtCategoryMap< JFluxHelper >::is_valid ( ) const
inlinefinaloverride

Check whether this flux factor is valid.

Returns
true if valid; else false

Definition at line 813 of file JEvtCategoryMap.hh.

814 {
815 for (typename map_type::const_iterator i = this->cbegin(); i != this->cend(); ++i) {
816 if (!(i->second.is_valid())) { return false; }
817 }
818
819 return true;
820 }

◆ getProperties() [1/2]

Get properties of this class.

Parameters
eqparsequation parameters

Definition at line 828 of file JEvtCategoryMap.hh.

829 {
830 return JEvtCategoryMapHelper(*this, eqpars);
831 }

◆ getProperties() [2/2]

JProperties JAANET::JEvtCategoryMap< JFluxHelper >::getProperties ( const JEquationParameters & eqpars = JEvtWeightFactor::getEquationParameters()) const
inlinefinaloverride

Get properties of this class.

Parameters
eqparsequation parameters

Definition at line 839 of file JEvtCategoryMap.hh.

840 {
841 return JEvtCategoryMapHelper(*this, eqpars);
842 }

◆ read()

std::istream & JAANET::JEvtCategoryMap< JFluxHelper >::read ( std::istream & in)
inlinefinaloverride

Read map between event categories and flux factors.

Parameters
ininput stream
Returns
input stream

Definition at line 851 of file JEvtCategoryMap.hh.

852 {
853 using namespace std;
854 using namespace JPP;
855
856 static const JFluxDictionary dictionary(oscProb);
857
858 JStringStream is(in);
859
860 if (getFileStatus(is.str().c_str())) {
861 is.load();
862 }
863
864 const streampos pos = is.tellg();
865 const ios_base::iostate state = is.rdstate();
866
867 // Read optional oscillation probability calculator configuration
868
869 JToken<';'> token;
870 is >> token;
871
872 istringstream iss(token);
873 iss >> oscProb;
874
875 if (fail(iss)) {
876 is.clear(state);
877 is.seekg(pos);
878 }
879
880 for (JToken<';'> token1, token2; is >> token1 >> token2; ) {
881
882 istringstream iss1(token1); // Read event categories
883
884 JEvtCategorySet categories;
885
886 iss1 >> categories;
887
888 istringstream iss2(token2); // Read event-weight factors
889
890 int fluxID = 0;
891
892 if (iss2 >> fluxID) {
893
894 const JFluxHelper helper = dictionary[fluxID];
895
896 JFlux& flux = helper.getFlux();
897
898 iss2 >> flux;
899
900 if (!fail(iss2)) {
901 for (JEvtCategorySet::const_iterator i = categories.cbegin(); i != categories.cend(); ++i) {
902 this->insert(*i, helper);
903 }
904 }
905 }
906 }
907
908 return in;
909 }
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
Wrapper class around string.
Definition JToken.hh:26
bool fail(std::istream &in)
Check for stream state.
Definition JParser.hh:98
Container for a set of event categories.
Helper class for flux function.
JFlux & getFlux() const
Get reference to flux function.
Neutrino flux.
Definition JHead.hh:906

◆ write()

std::ostream & JAANET::JEvtCategoryMap< JFluxHelper >::write ( std::ostream & out) const
inlinefinaloverride

Write event-weight factor to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 918 of file JEvtCategoryMap.hh.

919 {
920 return out << getProperties(JEquationParameters("=", "\n", "./", "#"));
921 }
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
Simple data structure to support I/O of equations (see class JLANG::JEquation).

◆ clone()

template<class JClonable_t , class JDerived_t >
virtual clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone ( ) const
inlineoverridevirtualinherited

Member Data Documentation

◆ oscProb

oscillation probability calculator

Definition at line 959 of file JEvtCategoryMap.hh.


The documentation for this class was generated from the following file: