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

Implementation of reweighting factor for simulated neutrino interactions according to a specifiable ROOT TFormula. More...

#include <JEvtWeightFactorGSeaGen.hh>

Inheritance diagram for JAANET::JEvtWeightFactorGSeaGen:
JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >

Public Types

enum  variables {
  COSTH, ENERGY, BJORKEN_X, INELASTICITY,
  NUMBER_OF_VARIABLES
}
 Indices of reweighting variables for GSeaGen. More...
 
typedef JEvtWeightFactorHelper
< JEvtWeightFactor_t > 
JEvtWeightFactorHelper_t
 
typedef std::shared_ptr
< JEvtWeightFactor_t > 
pointer_type
 

Public Member Functions

 JEvtWeightFactorGSeaGen ()
 Default constructor. More...
 
 JEvtWeightFactorGSeaGen (const JFlux &flux, const char *name, const char *formula)
 Constructor. More...
 
double operator() (const Evt &evt) const
 Get weighting factor for given event. More...
 
void configure (const JEvtWeightFactor_t &factor)
 Configure event-weight factor. More...
 
JEvtWeightFactor_t & getEvtWeightFactor () const
 Get reference to event-weight factor. More...
 
double getFactor (const Evt &evt) const
 Get weight-factor of given event. More...
 

Friends

std::istream & operator>> (std::istream &in, JEvtWeightFactorGSeaGen &object)
 Stream input. More...
 
std::ostream & operator<< (std::ostream &out, const JEvtWeightFactorGSeaGen &object)
 Stream output. More...
 

Detailed Description

Implementation of reweighting factor for simulated neutrino interactions according to a specifiable ROOT TFormula.

Note: The ROOT TFormula may assume any number of parameters, but should be restricted to
the physical variables listed among JEvtWeightFactorGSeaGen::variables.
These variables may be specified within the ROOT TFormula as 'x[<index>]',
where <index> corresponds to the index of the desired physical variable within JEvtWeightFactorGSeaGen::variables.

Definition at line 38 of file JEvtWeightFactorGSeaGen.hh.

Member Typedef Documentation

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

Definition at line 32 of file JEvtWeightFactorHelper.hh.

template<class JEvtWeightFactor_t>
typedef std::shared_ptr<JEvtWeightFactor_t> JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::pointer_type
inherited

Definition at line 33 of file JEvtWeightFactorHelper.hh.

Member Enumeration Documentation

Indices of reweighting variables for GSeaGen.

Enumerator
COSTH 

Cosine zenith angle.

ENERGY 

Initial state energy.

BJORKEN_X 

Björken-x (= fractional momentum carried by the struck nucleon)

INELASTICITY 

Inelasticity (= Björken-y)

NUMBER_OF_VARIABLES 

Number of reweighting variables;
N.B. This enum value needs to be specified last!

Definition at line 45 of file JEvtWeightFactorGSeaGen.hh.

45  {
46  COSTH, //!< Cosine zenith angle
47  ENERGY, //!< Initial state energy
48  BJORKEN_X, //!< Björken-x (= fractional momentum carried by the struck nucleon)
49  INELASTICITY, //!< Inelasticity (= Björken-y)
50  NUMBER_OF_VARIABLES //!< Number of reweighting variables; \n
51  //!< N.B.\ This enum value needs to be specified last!
52  };
Number of reweighting variables; N.B. This enum value needs to be specified last! ...
Björken-x (= fractional momentum carried by the struck nucleon)

Constructor & Destructor Documentation

JAANET::JEvtWeightFactorGSeaGen::JEvtWeightFactorGSeaGen ( )
inline

Default constructor.

Definition at line 58 of file JEvtWeightFactorGSeaGen.hh.

58  :
59  JFluxHelper(),
60  TFormula()
61  {}
JEvtWeightFactorHelper< JFlux > JFluxHelper
Type definition of event-weight factor helper for flux functions.
JAANET::JEvtWeightFactorGSeaGen::JEvtWeightFactorGSeaGen ( const JFlux flux,
const char *  name,
const char *  formula 
)
inline

Constructor.

Parameters
fluxflux function
namename
formulaformula

Definition at line 71 of file JEvtWeightFactorGSeaGen.hh.

73  :
74  JFluxHelper(flux),
75  TFormula(name, formula)
76  {}
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
JEvtWeightFactorHelper< JFlux > JFluxHelper
Type definition of event-weight factor helper for flux functions.

Member Function Documentation

double JAANET::JEvtWeightFactorGSeaGen::operator() ( const Evt evt) const
inline

Get weighting factor for given event.

Parameters
evtevent
Returns
weighting factor

Definition at line 85 of file JEvtWeightFactorGSeaGen.hh.

86  {
87  using namespace std;
88  using namespace JPP;
89 
90  if (static_cast<const JFluxHelper&>(*this)) {
91 
92  Double_t vars[NUMBER_OF_VARIABLES] = { 0.0 };
93 
94  const Trk& neutrino = get_neutrino(evt);
95  const double flux = getFactor(evt);
96 
97  vars[COSTH] = neutrino.dir.z;
98  vars[ENERGY] = getE0(evt);
99  vars[BJORKEN_X] = evt.w2list[W2LIST_GSEAGEN_BX];
101 
102  return this->DoEval(&vars[0]) * flux;
103 
104  } else {
105 
106  THROW(JNullPointerException, "JEvtWeightFactorGSeaGen::operator(): Unspecified flux function.");
107  }
108  }
static const int W2LIST_GSEAGEN_BX
Bjorken x.
double z
Definition: Vec.hh:14
double getE0(const Evt &evt)
Get initial state energy of a neutrino interaction.
Vec dir
track direction
Definition: Trk.hh:18
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Number of reweighting variables; N.B. This enum value needs to be specified last! ...
double getFactor(const Evt &evt) const
Get weight-factor of given event.
Neutrino flux.
Definition: JHead.hh:906
Björken-x (= fractional momentum carried by the struck nucleon)
static const int W2LIST_GSEAGEN_BY
Bjorken y.
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< double > w2list
MC: factors that make up w[1]=w2 (see e.g. Tag list or km3net-dataformat/definitions) ...
Definition: Evt.hh:43
template<class JEvtWeightFactor_t>
void JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::configure ( const JEvtWeightFactor_t &  factor)
inlineinherited

Configure event-weight factor.

Parameters
factorevent-weight factor

Definition at line 59 of file JEvtWeightFactorHelper.hh.

60  {
61  using namespace JPP;
62 
63  JEvtWeightFactor_t* p = dynamic_cast<JEvtWeightFactor_t*>(factor.clone());
64 
65  if (p != NULL) {
66  this->reset(p);
67  } else {
68  THROW(JNullPointerException, "JEvtWeightFactorHelper::configure(): Invalid downcast to class derived from JEvtWeightFactor.");
69  }
70  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
void reset(T &value)
Reset value.
template<class JEvtWeightFactor_t>
JEvtWeightFactor_t& JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::getEvtWeightFactor ( ) const
inlineinherited

Get reference to event-weight factor.

Returns
reference to event-weight factor

Definition at line 78 of file JEvtWeightFactorHelper.hh.

79  {
80  using namespace JPP;
81 
82  if (static_cast<const JEvtWeightFactorHelper_t&>(*this)) {
83  return *(this->get());
84  } else {
85  THROW(JNullPointerException, "JEvtWeightFactorHelper::getEvtWeightFactor(): Event-weight factor is not set.");
86  }
87  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
template<class JEvtWeightFactor_t>
double JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::getFactor ( const Evt evt) const
inlineinherited

Get weight-factor of given event.

Parameters
evtevent
Returns
event-weight factor

Definition at line 96 of file JEvtWeightFactorHelper.hh.

97  {
98  const JEvtWeightFactor_t& weightFactor = getEvtWeightFactor();
99 
100  return weightFactor.getFactor(evt);
101  }
JEvtWeightFactor_t & getEvtWeightFactor() const
Get reference to event-weight factor.

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JEvtWeightFactorGSeaGen object 
)
friend

Stream input.

Parameters
ininput stream
objectgSeaGen event-weight factor
Returns
input stream

Definition at line 118 of file JEvtWeightFactorGSeaGen.hh.

120  {
121  using namespace std;
122  using namespace JPP;
123 
124  typedef JToken<';'> JToken_t;
125 
126  JToken_t formula;
127  JToken_t equation;
128 
129  in >> formula;
130 
131  object.Clear();
132  object.Compile(formula.c_str());
133 
134  for (int count = 0; count < object.GetNpar() && in >> equation; ++count) {
135 
136  const int index = getParameter(equation);
137  const double value = getValue(equation, 0);
138 
139  object.SetParameter(index, value);
140  }
141 
142  return in;
143  }
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
Definition: JScale.hh:47
int getParameter(const std::string &text)
Get parameter number from text string.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
std::ostream& operator<< ( std::ostream &  out,
const JEvtWeightFactorGSeaGen object 
)
friend

Stream output.

Parameters
outoutput stream
objectgSeaGen event-weight factor
Returns
output stream

Definition at line 153 of file JEvtWeightFactorGSeaGen.hh.

155  {
156  using namespace std;
157  using namespace JPP;
158 
159  out << object.GetExpFormula() << ';';
160 
161  for (int i = 0; i < object.GetNpar(); ++i) {
162  out << " p" << i << " = " << SCIENTIFIC(6,3) << object.GetParameter(i) << ';';
163  }
164 
165  return out;
166  }
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:486

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