Jpp  17.3.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 #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  npar(0),
124  ndf (0.0),
125  chi2(0.0)
126  {}
127 
128 
129  /**
130  * Constructor.
131  *
132  * \param oid detector identifer
133  * \param range UNIX start and stop time [s]
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 JTimeRange& range,
141  const int nhit,
142  const int npar,
143  const double ndf,
144  const double chi2) :
145  oid (oid),
146  UNIXTimeStart(range.getLowerLimit()),
147  UNIXTimeStop (range.getUpperLimit()),
148  nhit(nhit),
149  npar(npar),
150  ndf (ndf),
151  chi2(chi2)
152  {}
153 
154 
155  /**
156  * Virtual destructor.
157  */
158  virtual ~JHead()
159  {}
160 
161 
162  ClassDef(JHead, 4);
163 
164  std::string oid; ///< detector identifier
165  double UNIXTimeStart; ///< start time
166  double UNIXTimeStop; ///< stop time
167  int nhit; ///< number of hits
168  int npar; ///< number of fit parameters
169  double ndf; ///< weighed number of degrees of freedom
170  double chi2; ///< chi2
171  };
172 
173 
174  /**
175  * Less than operator for acoustics event headers.
176  *
177  * The less than operator is applied to the object identifier,
178  * the UNIX start time and the UNIX stop time, respectively.
179  *
180  * \param first first header
181  * \param second second header
182  * \return true if first event header earliear than second; else false
183  */
184  inline bool operator<(const JHead& first, const JHead& second)
185  {
186  if (first.oid == second.oid) {
187 
188  if (first.UNIXTimeStart == second.UNIXTimeStart) {
189 
190  return first.UNIXTimeStop < second.UNIXTimeStop;
191 
192  } else {
193 
194  return first.UNIXTimeStart < second.UNIXTimeStart;
195  }
196 
197  } else {
198 
199  return first.oid < second.oid;
200  }
201  }
202 
203 
204  /**
205  * Acoustic event fit.
206  */
207  struct JEvt :
208  public JHead,
209  public std::vector<JFit>,
210  public TObject
211  {
212  /**
213  * Auxiliary class to determine value of acoustic events.\n
214  * This class can be used with JSUPPORT::JTreeScanner so to read acoustics events in order of start time.
215  */
216  struct JEvaluator {
217  /**
218  * Default constructor.
219  */
221  {}
222 
223 
224  /**
225  * Get value of object.
226  *
227  * \param event event
228  * \return value
229  */
230  inline double operator()(const JEvt& event) const
231  {
232  return event.UNIXTimeStart;
233  }
234  };
235 
236 
237  /**
238  * Default constructor.
239  */
240  JEvt() :
241  JHead()
242  {}
243 
244 
245  /**
246  * Constructor.
247  *
248  * \param header header
249  */
250  JEvt(const JHead& header) :
251  JHead(header)
252  {}
253 
254 
255  /**
256  * Virtual destructor.
257  */
258  virtual ~JEvt()
259  {}
260 
261 
262  /**
263  * Write event to output.
264  *
265  * \param out output stream
266  * \param event event
267  * \return output stream
268  */
269  friend inline std::ostream& operator<<(std::ostream& out, const JEvt& event)
270  {
271  using namespace std;
272 
273  out << event.oid << endl
274  << FIXED(20,5) << event.UNIXTimeStart << endl
275  << FIXED(20,5) << event.UNIXTimeStop << endl
276  << setw(5) << event.nhit << ' '
277  << setw(4) << event.npar << endl
278  << FIXED(12,3) << event.chi2 << ' '
279  << FIXED(7,1) << event.ndf << endl;
280 
281  for (JEvt::const_iterator fit = event.begin(); fit != event.end(); ++fit) {
282  out << *fit << endl;
283  }
284 
285  return out;
286  }
287 
288 
289  ClassDef(JEvt, 6);
290  };
291 }
292 
293 #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:1741
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
JHead(const std::string &oid, const JTimeRange &range, const int nhit, const int npar, const double ndf, const double chi2)
Constructor.
JEvt()
Default constructor.
JFit()
Default constructor.