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