Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAcoustics/JEvtToolkit.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JEVTTOOLKIT__
2 #define __JACOUSTICS__JEVTTOOLKIT__
3 
4 #include <set>
5 
6 #include "JAcoustics/JModel.hh"
7 #include "JAcoustics/JEvt.hh"
8 
9 
10 /**
11  * \file
12  *
13  * Acoustic event fit.
14  * \author mdejong
15  */
16 namespace JACOUSTICS {}
17 namespace JPP { using namespace JACOUSTICS; }
18 
19 namespace JACOUSTICS {
20 
21  /**
22  * Get quality of fit.\n
23  * The larger the quality, the better the fit.
24  *
25  * \param chi2 chi2
26  * \param NDF number of degrees of freedom
27  * \return quality
28  */
29  inline double getQuality(const double chi2, const int NDF)
30  {
31  return NDF - 0.25 * chi2 / NDF;
32  }
33 
34 
35  /**
36  * Get number of emitters.
37  *
38  * \param __begin begin of events
39  * \param __end end of events
40  * \return number of emitters
41  */
42  template<class T>
43  inline size_t getNumberOfEmitters(T __begin, T __end)
44  {
45  std::set<int> buffer;
46 
47  for (T i = __begin; i != __end; ++i) {
48  if (!i->empty()) {
49  buffer.insert(i->getID());
50  }
51  }
52 
53  return buffer.size();
54  }
55 
56 
57  /**
58  * Get model.
59  *
60  * \param evt event
61  * \return model
62  */
63  inline JModel getModel(const JEvt& evt)
64  {
65  JModel model;
66 
67  for (JEvt::const_iterator i = evt.begin(); i != evt.end(); ++i) {
68  model.string[i->id] = JMODEL::JString(i->tx, i->ty);
69  }
70 
71  return model;
72  }
73 
74 
75  /**
76  * Get event.
77  *
78  * \param header header
79  * \param model model
80  * \return event
81  */
82  inline JEvt getEvt(const JHead& header,
83  const JModel& model)
84  {
85  JEvt evt(header);
86 
87  for (JModel::string_type::const_iterator i = model.string.begin(); i != model.string.end(); ++i) {
88  evt.push_back(JFit(i->first,
89  i->second.tx,
90  i->second.ty));
91  }
92 
93  return evt;
94  }
95 }
96 
97 #endif
JModel getModel(const JEvt &evt)
Get model.
double getQuality(const double chi2, const int NDF)
Get quality of fit.
JEvt getEvt(const JHead &header, const JModel &model)
Get event.
size_t getNumberOfEmitters(T __begin, T __end)
Get number of emitters.
Model for fit to acoustics data.
Acoustic event header.
Acoustic event fit.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JACOUSTICS::JModel::string_type string
container_type::const_iterator const_iterator
Definition: JHashMap.hh:86
Model for fit to acoutsics data.
Acoustic event fit.