Jpp 19.3.0
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 614 of file JEvtCategoryMap.hh.

Member Typedef Documentation

◆ JEvtCategoryMap_t

Definition at line 620 of file JEvtCategoryMap.hh.

◆ map_type

◆ iterator

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

Definition at line 624 of file JEvtCategoryMap.hh.

◆ const_iterator

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

Definition at line 625 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 632 of file JEvtCategoryMap.hh.

632 :
633 map_type(),
634 oscProb(JOscProbInterpolator<>())
635 {}
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 643 of file JEvtCategoryMap.hh.

643 :
644 map_type(),
646 {}

◆ 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 656 of file JEvtCategoryMap.hh.

658 :
659 map_type(),
661 {
662 insert(category, factor);
663 }
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 675 of file JEvtCategoryMap.hh.

678 :
679 map_type(),
681 {
682 insert(category, factor, args...);
683 }

◆ JEvtCategoryMap() [5/6]

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

Constructor.

Parameters
categoryevent category
fluxflux function

Definition at line 692 of file JEvtCategoryMap.hh.

693 :
694 map_type(),
695 oscProb()
696 {
697 insert(category, flux);
698 }

◆ 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 710 of file JEvtCategoryMap.hh.

712 :
713 map_type()
714 {
715 insert(category, flux, args...);
716 }

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 725 of file JEvtCategoryMap.hh.

727 {
728 map_type::insert(std::make_pair(category, flux));
729 }

◆ 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 740 of file JEvtCategoryMap.hh.

743 {
744 insert(category, flux);
745 insert(args...);
746 }

◆ getOscProb()

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

Get oscillation probability calculator.

Returns
oscillation probability calculator

Definition at line 754 of file JEvtCategoryMap.hh.

755 {
756 return oscProb;
757 }

◆ 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 766 of file JEvtCategoryMap.hh.

767 {
768 using namespace JPP;
769
770 if (oscProb) {
771
772 size_t n = 0;
773
774 this->oscProb = oscProb;
775
776 for (iterator i = this->begin(); i != this->end(); ++i) {
777
778 JOscFlux* p = dynamic_cast<JOscFlux*>(&(i->second.getFlux()));
779
780 if (p != NULL) {
782 ++n;
783 }
784 }
785
786 return n;
787
788 } else {
789
790 THROW(JNullPointerException, "JEvtCategoryMap<JFluxHelper>::setOscProb(): Given oscillation probability function is invalid.");
791 }
792 }
#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 801 of file JEvtCategoryMap.hh.

802 {
803 using namespace JPP;
804
805 for (typename map_type::const_iterator i = this->cbegin(); i != this->cend(); ++i) {
806 if (i->first.match(evt)) {
807 return i->second.getFactor(evt);
808 }
809 }
810
811 THROW(JValueOutOfRange, "JEvtCategoryMap<JFluxHelper>::getFactor(): No flux factor for given event.");
812 }
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 820 of file JEvtCategoryMap.hh.

821 {
822 for (typename map_type::const_iterator i = this->cbegin(); i != this->cend(); ++i) {
823 if (!(i->second.is_valid())) { return false; }
824 }
825
826 return true;
827 }

◆ getProperties() [1/2]

Get properties of this class.

Parameters
eqparsequation parameters

Definition at line 835 of file JEvtCategoryMap.hh.

836 {
837 return JEvtCategoryMapHelper(*this, eqpars);
838 }

◆ 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 846 of file JEvtCategoryMap.hh.

847 {
848 return JEvtCategoryMapHelper(*this, eqpars);
849 }

◆ 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 858 of file JEvtCategoryMap.hh.

859 {
860 using namespace std;
861 using namespace JPP;
862
863 static const char SEPARATOR = ';';
864
865 static const JFluxDictionary dictionary(oscProb);
866
867 JStringStream is(in);
868
869 if (getFileStatus(is.str().c_str())) {
870 is.load();
871 }
872
873 const string contents = is.str();
874
875 const streampos pos = is.tellg();
876 const ios_base::iostate state = is.rdstate();
877
878 const int N = std::count(contents.begin(), contents.end(), SEPARATOR);
879
880 if (N & 1) { // Uneven number of terms; First term may correspond to optional oscillation parameters
881
882 JToken<SEPARATOR> token;
883 is >> token;
884
885 istringstream iss(token);
886 iss >> oscProb;
887
888 if (fail(iss)) {
889 is.clear(state);
890 is.seekg(pos);
891 }
892 }
893
894 for (JToken<SEPARATOR> token1, token2; is >> token1 >> token2; ) {
895
896 istringstream iss1(token1); // Read event categories
897
898 JEvtCategorySet categories;
899
900 iss1 >> categories;
901
902 istringstream iss2(token2); // Read event-weight factors
903
904 int fluxID = 0;
905
906 if (iss2 >> fluxID) {
907
908 const JFluxHelper helper = dictionary[fluxID];
909
910 JFlux& flux = helper.getFlux();
911
912 iss2 >> flux;
913
914 if (!fail(iss2)) {
915 for (JEvtCategorySet::const_iterator i = categories.cbegin(); i != categories.cend(); ++i) {
916 this->insert(*i, helper);
917 }
918 }
919 }
920 }
921
922 return in;
923 }
Dictionary to map distinct flux function categories to unique identifiers.
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 932 of file JEvtCategoryMap.hh.

933 {
934 return out << getProperties(JEquationParameters("=", "\n", "./", "#"));
935 }
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 973 of file JEvtCategoryMap.hh.


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