Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAcoustics/JEvt.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JEVT__
2 #define __JACOUSTICS__JEVT__
3 
4 #include <string>
5 #include <ostream>
6 #include <iomanip>
7 #include <vector>
8 
9 #include <TROOT.h>
10 #include <TObject.h>
11 
12 #include "JLang/JManip.hh"
13 
14 
15 /**
16  * \file
17  *
18  * Acoustic event fit.
19  * \author mdejong
20  */
21 namespace JACOUSTICS {}
22 namespace JPP { using namespace JACOUSTICS; }
23 
24 namespace JACOUSTICS {
25 
26  /**
27  * Acoustic single fit.
28  */
29  struct JFit :
30  public TObject
31  {
32  /**
33  * Default constructor.
34  */
35  JFit() :
36  id (-1),
37  tx (0.0),
38  ty (0.0),
39  tx2(0.0),
40  ty2(0.0),
41  vs (0.0)
42  {}
43 
44 
45  /**
46  * Constructor.
47  *
48  * \param id string identifier
49  * \param tx slope dx/dz
50  * \param ty slope dy/dz
51  * \param tx2 2nd order correction of slope dx/dz
52  * \param ty2 2nd order correction of slope dy/dz
53  * \param vs stretching factor
54  */
55  JFit(const int id,
56  const double tx,
57  const double ty,
58  const double tx2,
59  const double ty2,
60  const double vs) :
61  id (id),
62  tx (tx),
63  ty (ty),
64  tx2(tx2),
65  ty2(ty2),
66  vs (vs)
67  {}
68 
69 
70  /**
71  * Virtual destructor.
72  */
73  virtual ~JFit()
74  {}
75 
76 
77  /**
78  * Write fit to output.
79  *
80  * \param out output stream
81  * \param fit fit
82  * \return output stream
83  */
84  friend inline std::ostream& operator<<(std::ostream& out, const JFit& fit)
85  {
86  using namespace std;
87 
88  out << setw(4) << fit.id << ' '
89  << FIXED(10,7) << fit.tx << ' '
90  << FIXED(10,7) << fit.ty << ' '
91  << SCIENTIFIC(12,3) << fit.tx2 << ' '
92  << SCIENTIFIC(12,3) << fit.ty2 << ' '
93  << FIXED(8,5) << fit.vs;
94 
95  return out;
96  }
97 
98 
99  ClassDef(JFit, 2);
100 
101  int id; ///< string identifier
102  double tx; ///< slope dx/dz
103  double ty; ///< slope dy/dz
104  double tx2; ///< 2nd order correction of slope dx/dz
105  double ty2; ///< 2nd order correction of slope dy/dz
106  double vs; ///< stretching factor
107  };
108 
109 
110  /**
111  * Acoustic event header.
112  */
113  struct JHead {
114  /**
115  * Default constructor.
116  */
117  JHead() :
118  oid (),
119  UNIXTimeStart(0.0),
120  UNIXTimeStop (0.0),
121  nhit(0),
122  npar(0),
123  ndf (0.0),
124  chi2(0.0)
125  {}
126 
127 
128  /**
129  * Constructor.
130  *
131  * \param oid detector identifer
132  * \param t0 UNIX start time
133  * \param t1 UNIX stop time
134  * \param nhit number of hits
135  * \param npar number of fit parameters
136  * \param ndf weighed number of degrees of freedom
137  * \param chi2 chi2
138  */
139  JHead(const std::string& oid,
140  const double t0,
141  const double t1,
142  const int nhit,
143  const int npar,
144  const double ndf,
145  const double chi2) :
146  oid (oid),
147  UNIXTimeStart(t0),
148  UNIXTimeStop (t1),
149  nhit(nhit),
150  npar(npar),
151  ndf (ndf),
152  chi2(chi2)
153  {}
154 
155 
156  /**
157  * Virtual destructor.
158  */
159  virtual ~JHead()
160  {}
161 
162 
163  ClassDef(JHead, 4);
164 
165  std::string oid; ///< detector identifier
166  double UNIXTimeStart; ///< start time
167  double UNIXTimeStop; ///< stop time
168  int nhit; ///< number of hits
169  int npar; ///< number of fit parameters
170  double ndf; ///< weighed number of degrees of freedom
171  double chi2; ///< chi2
172  };
173 
174 
175  /**
176  * Less than operator for acoustics event headers.
177  *
178  * The less than operator is applied to the object identifier,
179  * the UNIX start time and the UNIX stop time, respectively.
180  *
181  * \param first first header
182  * \param second second header
183  * \return true if first event header earliear than second; else false
184  */
185  inline bool operator<(const JHead& first, const JHead& second)
186  {
187  if (first.oid == second.oid) {
188 
189  if (first.UNIXTimeStart == second.UNIXTimeStart) {
190 
191  return first.UNIXTimeStop < second.UNIXTimeStop;
192 
193  } else {
194 
195  return first.UNIXTimeStart < second.UNIXTimeStart;
196  }
197 
198  } else {
199 
200  return first.oid < second.oid;
201  }
202  }
203 
204 
205  /**
206  * Acoustic event fit.
207  */
208  struct JEvt :
209  public JHead,
210  public std::vector<JFit>,
211  public TObject
212  {
213  /**
214  * Auxiliary class to determine value of acoustic events.\n
215  * This class can be used with JSUPPORT::JTreeScanner so to read acoustics events in order of start time.
216  */
217  struct JEvaluator {
218  /**
219  * Default constructor.
220  */
222  {}
223 
224 
225  /**
226  * Get value of object.
227  *
228  * \param event event
229  * \return value
230  */
231  inline double operator()(const JEvt& event) const
232  {
233  return event.UNIXTimeStart;
234  }
235  };
236 
237 
238  /**
239  * Default constructor.
240  */
241  JEvt() :
242  JHead()
243  {}
244 
245 
246  /**
247  * Constructor.
248  *
249  * \param header header
250  */
251  JEvt(const JHead& header) :
252  JHead(header)
253  {}
254 
255 
256  /**
257  * Virtual destructor.
258  */
259  virtual ~JEvt()
260  {}
261 
262 
263  /**
264  * Write event to output.
265  *
266  * \param out output stream
267  * \param event event
268  * \return output stream
269  */
270  friend inline std::ostream& operator<<(std::ostream& out, const JEvt& event)
271  {
272  using namespace std;
273 
274  out << event.oid << endl
275  << FIXED(20,5) << event.UNIXTimeStart << endl
276  << FIXED(20,5) << event.UNIXTimeStop << endl
277  << setw(5) << event.nhit << ' '
278  << setw(4) << event.npar << endl
279  << FIXED(12,3) << event.chi2 << ' '
280  << FIXED(7,1) << event.ndf << endl;
281 
282  for (JEvt::const_iterator fit = event.begin(); fit != event.end(); ++fit) {
283  out << *fit << endl;
284  }
285 
286  return out;
287  }
288 
289 
290  ClassDef(JEvt, 6);
291  };
292 }
293 
294 #endif
int id
string identifier
int npar
number of fit parameters
JEvaluator()
Default constructor.
JFit(const int id, const double tx, const double ty, const double tx2, const double ty2, const double vs)
Constructor.
std::string oid
detector identifier
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1722
friend std::ostream & operator<<(std::ostream &out, const JFit &fit)
Write fit to output.
Definition: JRoot.hh:19
JHead(const std::string &oid, const double t0, const double t1, const int nhit, const int npar, const double ndf, const double chi2)
Constructor.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
double ty
slope dy/dz
Acoustic single fit.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
virtual ~JFit()
Virtual destructor.
Auxiliary class to determine value of acoustic events.
friend std::ostream & operator<<(std::ostream &out, const JEvt &event)
Write event to output.
double UNIXTimeStop
stop time
double operator()(const JEvt &event) const
Get value of object.
double tx
slope dx/dz
Acoustic event header.
Acoustic event fit.
double ndf
weighed number of degrees of freedom
JEvt(const JHead &header)
Constructor.
virtual ~JEvt()
Virtual destructor.
JHead()
Default constructor.
double ty2
2nd order correction of slope dy/dz
I/O manipulators.
double vs
stretching factor
int nhit
number of hits
double UNIXTimeStart
start time
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
double tx2
2nd order correction of slope dx/dz
virtual ~JHead()
Virtual destructor.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
JEvt()
Default constructor.
JFit()
Default constructor.