Jpp  18.1.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 toolkit.
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 parameters of string.
59  *
60  * \param fit fit parameters
61  * \return model parameters
62  */
63  inline JMODEL::JString getString(const JFit& fit)
64  {
65  return JMODEL::JString(fit.tx, fit.ty, fit.tx2, fit.ty2, fit.vs);
66  }
67 
68 
69  /**
70  * Get fit parameters of string.
71  *
72  * \param id identifier
73  * \param string model parameters
74  * \return fit parameters
75  */
76  inline JFit getFit(const int id, const JMODEL::JString& string)
77  {
78  return JFit(id, string.tx, string.ty, string.tx2, string.ty2, string.vs);
79  }
80 
81 
82  /**
83  * Auxiliary data structure to convert event to model.
84  */
85  struct getModel :
86  public JModel
87  {
88  /**
89  * Constructor.
90  */
91  template<class T>
92  getModel(const T& object);
93  };
94 
95 
96  /**
97  * Get model of detector.
98  *
99  * \param evt event
100  */
101  template<>
102  inline
104  {
105  for (JEvt::const_iterator i = evt.begin(); i != evt.end(); ++i) {
106  this->string[i->id] = getString(*i);
107  }
108  }
109 
110 
111  /**
112  * Auxiliary data structure to convert model to event.
113  */
114  struct getEvt :
115  public JEvt
116  {
117  /**
118  * Constructor.
119  *
120  * \param header header
121  * \param model model
122  */
123  getEvt(const JHead& header,
124  const JModel& model) :
125  JEvt(header)
126  {
127  for (JModel::string_type::const_iterator i = model.string.begin(); i != model.string.end(); ++i) {
128  this->push_back(getFit(i->first, i->second));
129  }
130  }
131  };
132 }
133 
134 #endif
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.
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.