Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t > Struct Template Reference

Implementation of event-weight factor for multiple particle types. More...

#include <JEvtWeightFactorMultiParticle.hh>

Inheritance diagram for JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >:
JLANG::JClonable< JClonable_t, JDerived_t > std::map< int, JEvtWeightFactorHelper< JEvtWeightFactor_t > >

Public Types

typedef JEvtWeightFactorHelper
< JEvtWeightFactor_t > 
JEvtWeightFactorHelper_t
 
typedef std::map< int,
JEvtWeightFactorHelper_t
map_type
 
typedef JClonable< JClonable_t >
::clone_type 
clone_type
 

Public Member Functions

 JEvtWeightFactorMultiParticle ()
 Default constructor. More...
 
 JEvtWeightFactorMultiParticle (const JHead &header, const JEvtWeightFactor_t &factor)
 Constructor. More...
 
template<class... Args>
 JEvtWeightFactorMultiParticle (const int type, const JEvtWeightFactor_t &factor, const Args &...args)
 Constructor. More...
 
void insert (const int type, const JEvtWeightFactor_t &factor)
 Insert pair of particle code and event-weight factor. More...
 
template<class... Args>
void insert (const int type, const JEvtWeightFactor_t &factor, const Args &...args)
 Insert pairs of particle codes and event-weight factors. More...
 
virtual double getFactor (const Evt &evt) const override
 Get weight factor of given event. More...
 
virtual clone_type clone () const override
 Get clone of this object. More...
 

Detailed Description

template<class JEvtWeightFactor_t>
struct JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >

Implementation of event-weight factor for multiple particle types.

The first template argument corresponds to the type of event-weight factor class. This class must contain the method getFactor(const Evt&). The second template argument refers to the helper-class to the event-weight factor of the type of the first template argument.

Definition at line 38 of file JEvtWeightFactorMultiParticle.hh.

Member Typedef Documentation

template<class JEvtWeightFactor_t>
typedef JEvtWeightFactorHelper<JEvtWeightFactor_t> JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >::JEvtWeightFactorHelper_t

Definition at line 42 of file JEvtWeightFactorMultiParticle.hh.

template<class JEvtWeightFactor_t>
typedef std::map<int, JEvtWeightFactorHelper_t> JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >::map_type

Definition at line 43 of file JEvtWeightFactorMultiParticle.hh.

template<class JClonable_t, class JDerived_t = JNullType>
typedef 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

template<class JEvtWeightFactor_t>
JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >::JEvtWeightFactorMultiParticle ( )
inline

Default constructor.

Definition at line 49 of file JEvtWeightFactorMultiParticle.hh.

49  :
50  map_type()
51  {}
std::map< int, JEvtWeightFactorHelper_t > map_type
template<class JEvtWeightFactor_t>
JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >::JEvtWeightFactorMultiParticle ( const JHead header,
const JEvtWeightFactor_t &  factor 
)
inline

Constructor.

The multi-particle flux function is created
listing all the primaries in the JHead::flux vector field of the given header.

Parameters
headerheader
factorfactor

Definition at line 63 of file JEvtWeightFactorMultiParticle.hh.

64  :
65  map_type()
66  {
67  if (!header.flux.empty()) {
68 
69  for (vector<JAANET::flux>::const_iterator i = header.flux.cbegin(); i != header.flux.cend(); ++i) {
70  insert(i->type, factor);
71  }
72 
73  } else {
74 
75  THROW(JValueOutOfRange, "JEvtWeightFactorMultiParticle::JEvtWeightFactorMultiParticle(): Empty flux header-field.");
76  }
77  }
void insert(const int type, const JEvtWeightFactor_t &factor)
Insert pair of particle code and event-weight factor.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
std::map< int, JEvtWeightFactorHelper_t > map_type
template<class JEvtWeightFactor_t>
template<class... Args>
JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >::JEvtWeightFactorMultiParticle ( const int  type,
const JEvtWeightFactor_t &  factor,
const Args &...  args 
)
inline

Constructor.

Parameters
typeparticle PDG code
factorevent-weight factor
argsremaining pairs of PDG codes and event-weight factors

Definition at line 88 of file JEvtWeightFactorMultiParticle.hh.

90  :
91  map_type()
92  {
93  insert(type, factor, args...);
94  }
void insert(const int type, const JEvtWeightFactor_t &factor)
Insert pair of particle code and event-weight factor.
std::map< int, JEvtWeightFactorHelper_t > map_type

Member Function Documentation

template<class JEvtWeightFactor_t>
void JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >::insert ( const int  type,
const JEvtWeightFactor_t &  factor 
)
inline

Insert pair of particle code and event-weight factor.

Parameters
typeparticle PDG code
factorevent-weight factor

Definition at line 103 of file JEvtWeightFactorMultiParticle.hh.

105  {
106  map_type::insert(std::make_pair(type, JEvtWeightFactorHelper_t(factor)));
107  }
JEvtWeightFactorHelper< JEvtWeightFactor_t > JEvtWeightFactorHelper_t
template<class JEvtWeightFactor_t>
template<class... Args>
void JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >::insert ( const int  type,
const JEvtWeightFactor_t &  factor,
const Args &...  args 
)
inline

Insert pairs of particle codes and event-weight factors.

Parameters
typeparticle PDG code
factorevent-weight factor
argsremaining pairs of PDG codes and event-weight factors

Definition at line 118 of file JEvtWeightFactorMultiParticle.hh.

121  {
122  insert(type, factor);
123  insert(args...);
124  }
void insert(const int type, const JEvtWeightFactor_t &factor)
Insert pair of particle code and event-weight factor.
template<class JEvtWeightFactor_t>
virtual double JAANET::JEvtWeightFactorMultiParticle< JEvtWeightFactor_t >::getFactor ( const Evt evt) const
inlineoverridevirtual

Get weight factor of given event.

Parameters
evtevent
Returns
weight-factor for given event

Definition at line 133 of file JEvtWeightFactorMultiParticle.hh.

134  {
135  using namespace std;
136  using namespace JPP;
137 
138  vector<Trk>::const_iterator primary = find_if(evt.mc_trks.cbegin(),
139  evt.mc_trks.cend(),
141 
142  if (primary != evt.mc_trks.cend()) {
143 
144  return this->at(primary->type).getFactor(evt);
145 
146  } else if (has_neutrino(evt)) {
147 
148  const Trk& neutrino = get_neutrino(evt);
149 
150  return this->at(neutrino.type).getFactor(evt);
151 
152  } else {
153 
154  THROW(JValueOutOfRange, "JEvtWeightFactorMultiParticle::getFactor(): No primary track found for event " << evt.id << ".");
155  }
156  }
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
bool is_primary() const
Check if this is a primary particle.
Definition: Trk.hh:77
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
int id
offline event identifier
Definition: Evt.hh:22
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition: Evt.hh:49
template<class JClonable_t, class JDerived_t = JNullType>
virtual clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone ( ) const
inlineoverridevirtualinherited

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