Jpp  master_rocky
the software that should make you happy
JAcoustics/JEvtToolkit.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JEVTTOOLKIT__
2 #define __JACOUSTICS__JEVTTOOLKIT__
3 
4 #include <set>
5 #include <map>
6 #include <limits>
7 
8 #include "JAcoustics/JModel.hh"
9 #include "JAcoustics/JEvt.hh"
10 
11 
12 /**
13  * \file
14  *
15  * Acoustic event fit toolkit.
16  * \author mdejong
17  */
18 namespace JACOUSTICS {}
19 namespace JPP { using namespace JACOUSTICS; }
20 
21 namespace JACOUSTICS {
22 
23  /**
24  * Get quality of fit.\n
25  * The larger the quality, the better the fit.
26  *
27  * \param chi2 chi2
28  * \param NDF number of degrees of freedom
29  * \return quality
30  */
31  inline double getQuality(const double chi2, const int NDF)
32  {
33  return NDF - 0.25 * chi2 / NDF;
34  }
35 
36 
37  /**
38  * Get number of emitters.
39  *
40  * \param __begin begin of events
41  * \param __end end of events
42  * \return number of emitters
43  */
44  template<class T>
45  inline size_t getNumberOfEmitters(T __begin, T __end)
46  {
47  using namespace std;
48 
49  set<int> buffer;
50 
51  for (T i = __begin; i != __end; ++i) {
52  if (!i->empty()) {
53  buffer.insert(i->getID());
54  }
55  }
56 
57  return buffer.size();
58  }
59 
60 
61  /**
62  * Get minimum number of emitters for any string in data.
63  *
64  * \param __begin begin of events
65  * \param __end end of events
66  * \return number of emitters
67  */
68  template<class T>
69  inline size_t getMinimumNumberOfEmitters(T __begin, T __end)
70  {
71  using namespace std;
72 
73  map<int, set<int> > buffer;
74 
75  for (T i = __begin; i != __end; ++i) {
76  buffer[i->getString()].insert(i->getID());
77  }
78 
79  if (!buffer.empty()) {
80 
81  size_t n = numeric_limits<size_t>::max();
82 
83  for (map<int, set<int> >::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
84  if (i->second.size() < n) {
85  n = i->second.size();
86  }
87  }
88 
89  return n;
90  }
91 
92  return 0;
93  }
94 
95 
96  /**
97  * Get model parameters of string.
98  *
99  * \param fit fit parameters
100  * \return model parameters
101  */
102  inline JMODEL::JString getString(const JFit& fit)
103  {
104  return JMODEL::JString(fit.tx, fit.ty, fit.tx2, fit.ty2, fit.vs);
105  }
106 
107 
108  /**
109  * Get fit parameters of string.
110  *
111  * \param id identifier
112  * \param string model parameters
113  * \return fit parameters
114  */
115  inline JFit getFit(const int id, const JMODEL::JString& string)
116  {
117  return JFit(id, string.tx, string.ty, string.tx2, string.ty2, string.vs);
118  }
119 
120 
121  /**
122  * Auxiliary data structure to convert event to model.
123  */
124  struct getModel :
125  public JModel
126  {
127  /**
128  * Constructor.
129  */
130  template<class T>
131  getModel(const T& object);
132  };
133 
134 
135  /**
136  * Get model of detector.
137  *
138  * \param evt event
139  */
140  template<>
141  inline
143  {
144  for (JEvt::const_iterator i = evt.begin(); i != evt.end(); ++i) {
145  this->string[i->id] = getString(*i);
146  }
147  }
148 
149 
150  /**
151  * Auxiliary data structure to convert model to event.
152  */
153  struct getEvt :
154  public JEvt
155  {
156  /**
157  * Constructor.
158  *
159  * \param header header
160  * \param model model
161  */
162  getEvt(const JHead& header,
163  const JModel& model) :
164  JEvt(header)
165  {
166  for (JModel::string_type::const_iterator i = model.string.begin(); i != model.string.end(); ++i) {
167  this->push_back(getFit(i->first, i->second));
168  }
169  }
170  };
171 }
172 
173 #endif
Acoustic event fit.
Model for fit to acoutsics data.
Auxiliary classes and methods for acoustic position calibration.
size_t getMinimumNumberOfEmitters(T __begin, T __end)
Get minimum number of emitters for any string in data.
double getQuality(const double chi2, const int NDF)
Get quality of fit.
JMODEL::JString getString(const JFit &fit)
Get model parameters of string.
JFit getFit(const int id, const JMODEL::JString &string)
Get fit parameters of string.
size_t getNumberOfEmitters(T __begin, T __end)
Get number of emitters.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< double > vs
const int n
Definition: JPolint.hh:786
Definition: JSTDTypes.hh:14
Acoustic event fit.
Acoustic single fit.
double tx
slope dx/dz
double vs
stretching factor
double ty
slope dy/dz
double ty2
2nd order correction of slope dy/dz
double tx2
2nd order correction of slope dx/dz
Acoustic event header.
Model for fit to acoustics data.
Auxiliary data structure to convert model to event.
getEvt(const JHead &header, const JModel &model)
Constructor.
Auxiliary data structure to convert event to model.
getModel(const T &object)
Constructor.
container_type::const_iterator const_iterator
Definition: JHashMap.hh:86