Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
JEvtWeightToolkit.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JEVTWEIGHTTOOLKIT__
2 #define __JAANET__JEVTWEIGHTTOOLKIT__
3 
4 #include <vector>
5 
12 
13 #include "JLang/JType.hh"
14 #include "JLang/JException.hh"
15 
16 #include "JPhysics/JConstants.hh"
17 
18 #include "JAAnet/JHead.hh"
19 #include "JAAnet/JHeadToolkit.hh"
20 
21 #include "JAAnet/JEvtWeight.hh"
22 #include "JAAnet/JEvtWeightDAQ.hh"
29 
30 #include "JAAnet/JParticleTypes.hh"
31 #include "JAAnet/JAAnetToolkit.hh"
32 
33 
34 /**
35  * \author bjung, mdejong
36  */
37 
38 namespace JAANET {}
39 namespace JPP { using namespace JAANET; }
40 
41 namespace JAANET {
42 
43  using JLANG::JType;
45  using JEEP::JProperties;
46 
47 
48  /**
49  * Look-up table for event weighters.
50  */
51  struct JEvtWeighter :
52  public std::vector<std::shared_ptr<JEvtWeight> >
53  {
54  /**
55  * Constructor
56  */
58  {
59  this->emplace_back(new JEvtWeightGSeaGen());
60  this->emplace_back(new JEvtWeightKM3BUU());
61  this->emplace_back(new JEvtWeightCorsika());
62  this->emplace_back(new JEvtWeightMupage());
63  this->emplace_back(new JEvtWeightGenhen());
64  this->emplace_back(new JEvtWeightDAQ()); // must be after Monte Carlo weighters
65  this->emplace_back(new JEvtWeightMiscellaneous());
66  }
67 
68 
69  /**
70  * Get event weighter corresponding to given header.
71  *
72  * \param header header
73  * \return event weighter
74  */
75  const JEvtWeight& operator()(const JHead& header) const
76  {
77  using namespace std;
78  using namespace JPP;
79 
80  for (const_iterator i = this->begin(); i != this->end(); ++i) {
81 
82  if ((*i)->check(header)) {
83  return *(*i);
84  }
85  }
86 
87  THROW(JValueOutOfRange, "JEvtWeighter::operator(): No event weighter found for given header:" << endl << header);
88  }
89  };
90 
91 
92  /**
93  * Get volume of given event according given weighter.
94  *
95  * \param type type
96  * \param evt event
97  * \return volume [m^3 Gev sr]
98  */
99  inline double getVolume(const JType<JEvtWeightGSeaGen>& type, const Evt& evt)
100  {
104  }
105 
106 
107  /**
108  * Get volume of given event according given weighter.
109  *
110  * \param type type
111  * \param evt event
112  * \return volume [m^3 Gev sr]
113  */
114  inline double getVolume(const JType<JEvtWeightKM3BUU>& type, const Evt& evt)
115  {
119  }
120 
121 
122  /**
123  * Get volume of given event according given weighter.
124  *
125  * \param type type
126  * \param evt event
127  * \return volume [m^3 Gev sr]
128  */
129  inline double getVolume(const JType<JEvtWeightGenhen>& type, const Evt& evt)
130  {
131  using namespace JPHYSICS;
132 
133  const double l_int = 1.0e-6 * NUCLEON_MOLAR_MASS / (evt.w2list[W2LIST_GENHEN_SIG] * DENSITY_SEA_WATER * AVOGADRO);
134  const double year = 60*60*24*365; // [s]
135 
137  l_int /
138  year /
140  }
141 
142 
143  /**
144  * Get volume of given event according given weighter.
145  *
146  * The return value should be normalised to
147  * - number of generated events;
148  * - solid angle covered by the generation; and
149  * - bin width of the histogram.
150  *
151  * \param weighter weighter
152  * \param evt event
153  * \return volume [m^3 GeV sr]
154  */
155  inline double getVolume(const JEvtWeight& weighter, const Evt& evt)
156  {
157  if (dynamic_cast<const JEvtWeightGSeaGen*>(&weighter) != NULL) { return getVolume(JType<JEvtWeightGSeaGen>(), evt); }
158  if (dynamic_cast<const JEvtWeightGenhen*> (&weighter) != NULL) { return getVolume(JType<JEvtWeightGenhen> (), evt); }
159  if (dynamic_cast<const JEvtWeightKM3BUU*> (&weighter) != NULL) { return getVolume(JType<JEvtWeightKM3BUU> (), evt); }
160 
161  THROW(JCastException, "No valid weighter.");
162  }
163 
164  extern JEvtWeighter getEventWeighter; //!< Function object for mapping header to event weighter.
165 }
166 
167 #endif
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Definition of particle types.
Physics constants.
Monte Carlo run header.
Definition: JHead.hh:1236
Utility class to parse parameter values.
Definition: JProperties.hh:501
Exception for cast operation.
Definition: JException.hh:252
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
Extensions to Evt data format.
double getVolume(const JEvtWeight &weighter, const Evt &evt)
Get volume of given event according given weighter.
JEvtWeighter getEventWeighter
Function object for mapping header to event weighter.
Auxiliary methods for light properties of deep-sea water.
static const double DENSITY_SEA_WATER
Fixed environment values.
static const double AVOGADRO
Avogadro's number.
static const double NUCLEON_MOLAR_MASS
nucleon molar mass [g/mol]
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:21
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. Tag list or km3net-dataformat/definitions)
Definition: Evt.hh:42
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
Implementation of event weighting for Corsika data.
Implementation of event weighing for DAQ data.
Implementation of event weighting for GSeaGen data.
Implementation of event weighting for Genhen data.
Implementation of event weighting for KM3BUU data.
Implementation of event weighing for miscellaneous data such as a merged offline file containing neut...
Implementation of event weighing for MUPAGE data.
Abstract base class for event weighing.
Definition: JEvtWeight.hh:31
Look-up table for event weighters.
JEvtWeighter()
Constructor.
const JEvtWeight & operator()(const JHead &header) const
Get event weighter corresponding to given header.
Auxiliary class for a type holder.
Definition: JType.hh:19
static const int W2LIST_GENHEN_SIG
Cross section of the neutrion interaction.
static const int W2LIST_GENHEN_P_EARTH
Transmission probability in the Earth.
static const int W2LIST_GSEAGEN_WATER_INT_LEN
Interaction length in pure water in m.
static const int W2LIST_GSEAGEN_P_EARTH
Transmission probability in the Earth (XSEC_MEAN and COLUMN_DEPTH used to compute PEarth)
static const int W2LIST_KM3BUU_WATER_INT_LEN
Interaction length in pure water in m.
static const int W2LIST_KM3BUU_P_EARTH
Transmission probability in the Earth.
static const int WEIGHTLIST_DIFFERENTIAL_EVENT_RATE
Event rate per unit of flux (c.f. taglist document) [GeV m2 sr].
Definition: weightlist.hh:14