Jpp  18.6.0-rc.1
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 #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
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.
getModel(const T &object)
Constructor.
double ty
slope dy/dz
JMODEL::JString getString(const JFit &fit)
Get model parameters of string.
Acoustic single fit.
size_t getNumberOfEmitters(T __begin, T __end)
Get number of emitters.
const int n
Definition: JPolint.hh:786
Model for fit to acoustics data.
Auxiliary data structure to convert model to event.
double tx
slope dx/dz
std::vector< double > vs
Acoustic event header.
Acoustic event fit.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
double ty2
2nd order correction of slope dy/dz
double vs
stretching factor
JACOUSTICS::JModel::string_type string
JFit getFit(const int id, const JMODEL::JString &string)
Get fit parameters of string.
getEvt(const JHead &header, const JModel &model)
Constructor.
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
container_type::const_iterator const_iterator
Definition: JHashMap.hh:86
double tx2
2nd order correction of slope dx/dz
Auxiliary data structure to convert event to model.
Model for fit to acoutsics data.
Acoustic event fit.