Jpp test-rotations-old
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.

Input syntax as follows:

      <oscprob_key>=<oscprob_value>[,<oscprob_key>=<oscprob_value>]...

      oscprob.<oscprob_key>=<oscprob_value>[,oscprob.<oscprob_key>=<oscprob_value>]...

      oscprob=<oscprob_file>

      <oscprob_file>

      <PDG type> [<PDG type>]...;           <flux identifier> [<flux arguments>];

      <key>=<value>[,<key>=<value>]...; <flux identifier> [<flux arguments>];

where

  • <oscprob_key> refers to an oscillation probability calculator configuration key;
  • <oscprob_value> to an oscillation probability calculator configuration value;
  • <oscprob_file> to an oscillation probability calculator configuration file;
  • <PDG type> to a PDG identifier;
  • <key> to one of the data members of a data structure derived from JAANET::JEvtCategory;
  • <value> to the corresponding value;
  • <flux identifier> to a flux identifier (c.f. JAANET::JFluxDictionary) and
  • <flux arguments> to the list of arguments of the corresponding flux factor.

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 streampos pos = in.tellg();
859
860 // Optional loading of data from file
861
862 std::string buffer;
863 in >> buffer;
864
865 if (getFileStatus(buffer.c_str())) {
866
867 ifstream ifs(buffer.c_str());
868
869 read(ifs);
870
871 ifs.close();
872
873 return in;
874
875 } else {
876
877 in.clear();
878 in.seekg(pos);
879 }
880
881 // Read optional oscillation probability calculator configuration
882
883 in >> oscProb;
884
885 if (fail(in)) {
886
887 in.clear();
888 in.seekg(pos);
889 }
890
891 for (JToken<';'> token1, token2; in >> token1 >> token2; ) {
892
893 istringstream iss1(token1); // Read event categories
894
895 JEvtCategorySet categories;
896
897 iss1 >> categories;
898
899 istringstream iss2(token2); // Read event-weight factors
900
901 int fluxID = 0;
902
903 if (iss2 >> fluxID) {
904
905 JFluxHelper helper(dictionary.at(fluxID).getFlux());
906
907 JFlux& flux = helper.getFlux();
908
909 iss2 >> flux;
910
911 if (!fail(iss2)) {
912 for (JEvtCategorySet::const_iterator i = categories.cbegin(); i != categories.cend(); ++i) {
913 this->insert(*i, helper);
914 }
915 }
916 }
917 }
918
919 return in;
920 }
std::istream & read(std::istream &in) override final
Read map between event categories and flux factors.
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.
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 929 of file JEvtCategoryMap.hh.

930 {
931 return out << getProperties(JEquationParameters("=", "\n", "./", "#"));
932 }
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 970 of file JEvtCategoryMap.hh.


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