Jpp  18.2.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 41 of file JEvtWeightFactorMultiParticle.hh.

Member Typedef Documentation

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

Definition at line 45 of file JEvtWeightFactorMultiParticle.hh.

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

Definition at line 46 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 52 of file JEvtWeightFactorMultiParticle.hh.

52  :
53  map_type()
54  {}
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 66 of file JEvtWeightFactorMultiParticle.hh.

67  :
68  map_type()
69  {
70  using namespace std;
71  using namespace JPP;
72 
73  if (!header.flux.empty()) {
74 
75  for (vector<JAANET::flux>::const_iterator i = header.flux.cbegin(); i != header.flux.cend(); ++i) {
76  insert(i->type, factor);
77  }
78 
79  } else {
80 
81  THROW(JValueOutOfRange, "JEvtWeightFactorMultiParticle::JEvtWeightFactorMultiParticle(): Empty flux header-field.");
82  }
83  }
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:712
std::vector< JAANET::flux > flux
Definition: JHead.hh:1609
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 94 of file JEvtWeightFactorMultiParticle.hh.

96  :
97  map_type()
98  {
99  insert(type, factor, args...);
100  }
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 109 of file JEvtWeightFactorMultiParticle.hh.

111  {
112  map_type::insert(std::make_pair(type, JEvtWeightFactorHelper_t(factor)));
113  }
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 124 of file JEvtWeightFactorMultiParticle.hh.

127  {
128  insert(type, factor);
129  insert(args...);
130  }
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 139 of file JEvtWeightFactorMultiParticle.hh.

140  {
141  using namespace std;
142  using namespace JPP;
143 
144  vector<Trk>::const_iterator primary = find_if(evt.mc_trks.cbegin(),
145  evt.mc_trks.cend(),
147 
148  if (primary != evt.mc_trks.cend()) {
149 
150  return this->at(primary->type).getFactor(evt);
151 
152  } else if (has_neutrino(evt)) {
153 
154  const Trk& neutrino = get_neutrino(evt);
155 
156  return this->at(neutrino.type).getFactor(evt);
157 
158  } else {
159 
160  THROW(JValueOutOfRange, "JEvtWeightFactorMultiParticle::getFactor(): No primary track found for event " << evt.id << ".");
161  }
162  }
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:712
bool is_primary() const
Check if this is a primary particle.
Definition: Trk.hh:77
int type
Particle type.
Definition: JHead.hh:1204
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
Primary particle.
Definition: JHead.hh:1174
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: