Jpp  18.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
JACOUSTICS::JEvent Struct Reference

Acoustic event. More...

#include <JEvent.hh>

Inheritance diagram for JACOUSTICS::JEvent:
JIO::JSerialisable JACOUSTICS::JCounter std::vector< JTransmission > TObject

Classes

struct  JEvaluator
 Auxiliary class to determine value of acoustic events. More...
 

Public Member Functions

 JEvent ()
 Default constructor. More...
 
template<class T >
 JEvent (const std::string &oid, const int counter, const int id, T __begin, T __end)
 Constructor. More...
 
virtual ~JEvent ()
 Virtual destructor. More...
 
const std::stringgetOID () const
 Get detector identifier. More...
 
int getOverlays () const
 Get number of overlayed events. More...
 
int getID () const
 Get emitter identifier. More...
 
void merge (const JEvent &event)
 Merge event. More...
 
virtual JReaderread (JReader &in) override
 Read from input. More...
 
virtual JWriterwrite (JWriter &out) const override
 Write to output. More...
 
 ClassDefOverride (JEvent, 3)
 
int getCounter () const
 Get counter. More...
 
 ClassDefNV (JCounter, 1)
 

Static Public Member Functions

template<class T >
static void overlap (T p, T q, const double Tmax_s)
 Empty overlapping events. More...
 

Protected Attributes

std::string oid
 
int overlays
 
int id
 
int counter
 

Friends

void swap (JEvent &first, JEvent &second)
 Swap events. More...
 
bool operator< (const JEvent &first, const JEvent &second)
 Less than operator for acoustics events. More...
 
std::ostream & operator<< (std::ostream &out, const JEvent &event)
 Write event to output stream. More...
 

Detailed Description

Acoustic event.

Definition at line 38 of file JAcoustics/JEvent.hh.

Constructor & Destructor Documentation

JACOUSTICS::JEvent::JEvent ( )
inline

Default constructor.

Definition at line 72 of file JAcoustics/JEvent.hh.

72  :
73  JCounter(),
74  overlays(0),
75  id (-1)
76  {}
JCounter()
Default constructor.
template<class T >
JACOUSTICS::JEvent::JEvent ( const std::string oid,
const int  counter,
const int  id,
T  __begin,
T  __end 
)
inline

Constructor.

The transmissions will be sorted to ensure proper functioning of method JEvent::merge and class JEventOverlap.

Parameters
oiddetector identifier
countercounter
ididentifier
__beginbegin of data
__endend of data

Definition at line 91 of file JAcoustics/JEvent.hh.

95  :
97  oid (oid),
98  overlays(0),
99  id (id)
100  {
101  using namespace std;
102 
103  for (T i = __begin; i != __end; ++i) {
104  push_back(*i);
105  }
106 
107  sort(this->begin(), this->end());
108  }
JCounter()
Default constructor.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
virtual JACOUSTICS::JEvent::~JEvent ( )
inlinevirtual

Virtual destructor.

Definition at line 114 of file JAcoustics/JEvent.hh.

115  {}

Member Function Documentation

const std::string& JACOUSTICS::JEvent::getOID ( ) const
inline

Get detector identifier.

Returns
detector identifier.

Definition at line 123 of file JAcoustics/JEvent.hh.

124  {
125  return oid;
126  }
int JACOUSTICS::JEvent::getOverlays ( ) const
inline

Get number of overlayed events.

Returns
overlays

Definition at line 134 of file JAcoustics/JEvent.hh.

135  {
136  return overlays;
137  }
int JACOUSTICS::JEvent::getID ( ) const
inline

Get emitter identifier.

Returns
identifier

Definition at line 145 of file JAcoustics/JEvent.hh.

146  {
147  return id;
148  }
void JACOUSTICS::JEvent::merge ( const JEvent event)
inline

Merge event.

It is assumed that the transmissions in both events are ordered according the default less-than operator.

Parameters
eventevent

Definition at line 159 of file JAcoustics/JEvent.hh.

160  {
161  using namespace std;
162 
163  vector<JTransmission> buffer;
164 
165  const_iterator __hit1 = this ->begin();
166  const_iterator __end1 = this ->end();
167 
168  const_iterator __hit2 = event.begin();
169  const_iterator __end2 = event.end();
170 
171  buffer.resize(this->size() + event.size());
172 
173  iterator out = buffer.begin();
174 
175  while (__hit1 != __end1 && __hit2 != __end2) {
176 
177  if (*__hit1 < *__hit2) {
178 
179  *out = *__hit1;
180  ++__hit1;
181 
182  } else if (*__hit2 < *__hit1) {
183 
184  *out = *__hit2;
185  ++__hit2;
186 
187  } else {
188 
189  *out = *__hit1;
190 
191  ++__hit1;
192  ++__hit2;
193  }
194 
195  ++out;
196  }
197 
198  // append remaining hits from either set
199 
200  out = copy(__hit1, __end1, out);
201  out = copy(__hit2, __end2, out);
202 
203  buffer.resize(distance(buffer.begin(), out));
204 
205  this->swap(buffer);
206 
207  ++overlays;
208  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
friend void swap(JEvent &first, JEvent &second)
Swap events.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
template<class T >
static void JACOUSTICS::JEvent::overlap ( T  p,
T  q,
const double  Tmax_s 
)
inlinestatic

Empty overlapping events.

The events should be time sorted on input.
The time window applies to the difference between the first transmission of an event and the last transmission of the previous event.

Parameters
pbegin of events
qend of events
Tmax_stime window [s]

Definition at line 241 of file JAcoustics/JEvent.hh.

242  {
243  for (T __q = p, __p = __q++; __p != q && __q != q; __p = __q++) {
244 
245  if (!__p->empty() &&
246  !__q->empty() &&
247  __q->begin()->getToE() < __p->rbegin()->getToE() + Tmax_s) {
248 
249  __p->clear(); // clear first
250 
251  for (__p = __q++; __p != q && __q != q; __p = __q++) {
252 
253  if (__q->begin()->getToE() < __p->rbegin()->getToE() + Tmax_s)
254  __p->clear(); // clear intermediate
255  else
256  break;
257  }
258 
259  __p->clear(); // clear last
260  }
261  }
262  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
virtual JReader& JACOUSTICS::JEvent::read ( JReader in)
inlineoverridevirtual

Read from input.

Parameters
inreader
Returns
reader

Implements JIO::JSerialisable.

Definition at line 320 of file JAcoustics/JEvent.hh.

321  {
322  in >> static_cast<JCounter&>(*this);
323  in >> this->oid;
324  in >> this->overlays;
325  in >> this->id;
326  in >> static_cast<std::vector<JTransmission>&>(*this);
327 
328  return in;
329  }
Acoustic counter.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
virtual JWriter& JACOUSTICS::JEvent::write ( JWriter out) const
inlineoverridevirtual

Write to output.

Parameters
outwriter
Returns
writer

Implements JIO::JSerialisable.

Definition at line 338 of file JAcoustics/JEvent.hh.

339  {
340  out << static_cast<const JCounter&>(*this);
341  out << this->oid;
342  out << this->overlays;
343  out << this->id;
344  out << static_cast<const std::vector<JTransmission>&>(*this);
345 
346  return out;
347  }
JACOUSTICS::JEvent::ClassDefOverride ( JEvent  ,
 
)
int JACOUSTICS::JCounter::getCounter ( ) const
inlineinherited

Get counter.

Returns
counter

Definition at line 51 of file JAcoustics/JCounter.hh.

52  {
53  return counter;
54  }
JACOUSTICS::JCounter::ClassDefNV ( JCounter  ,
 
)
inherited

Friends And Related Function Documentation

void swap ( JEvent first,
JEvent second 
)
friend

Swap events.

Parameters
firstfirst event
secondsecond event

Definition at line 217 of file JAcoustics/JEvent.hh.

218  {
219  std::swap(first.counter, second.counter);
220  std::swap(first.oid, second.oid);
221  std::swap(first.overlays, second.overlays);
222  std::swap(first.id, second.id);
223 
224  static_cast<std::vector<JTransmission>&>(first).swap(static_cast<std::vector<JTransmission>&>(second));
225  }
friend void swap(JEvent &first, JEvent &second)
Swap events.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
bool operator< ( const JEvent first,
const JEvent second 
)
friend

Less than operator for acoustics events.

The less than operator is applied to the first hit in the events.
If there are no hits in either event, the counter of the events is used.

Parameters
firstfirst event
secondsecond event
Returns
true if first event earliear than second; else false

Definition at line 275 of file JAcoustics/JEvent.hh.

276  {
277  if (!first.empty() && !second.empty())
278  return first.begin()->getToE() < second.begin()->getToE();
279  else
280  return first.getCounter() < second.getCounter();
281  }
int getCounter() const
Get counter.
std::ostream& operator<< ( std::ostream &  out,
const JEvent event 
)
friend

Write event to output stream.

Parameters
outoutput stream
eventevent
Returns
output stream

Definition at line 291 of file JAcoustics/JEvent.hh.

292  {
293  using namespace std;
294 
295  out << event.getOID() << endl;
296  out << setw(8) << event.getCounter() << endl;
297  out << setw(2) << event.getOverlays() << endl;
298  out << setw(3) << event.getID() << endl;
299 
300  for (const_iterator i = event.begin(); i != event.end(); ++i) {
301 
302  out << setw(10) << i->getID() << ' '
303  << setw(10) << i->getRunNumber() << ' '
304  << fixed << setw(12) << setprecision(6) << i->getToA() << ' '
305  << fixed << setw(12) << setprecision(6) << i->getToE() << ' '
306  << fixed << setw(8) << setprecision(0) << i->getQ() << ' '
307  << fixed << setw(8) << setprecision(0) << i->getW() << endl;
308  }
309 
310  return out;
311  }

Member Data Documentation

std::string JACOUSTICS::JEvent::oid
protected

Definition at line 352 of file JAcoustics/JEvent.hh.

int JACOUSTICS::JEvent::overlays
protected

Definition at line 353 of file JAcoustics/JEvent.hh.

int JACOUSTICS::JEvent::id
protected

Definition at line 354 of file JAcoustics/JEvent.hh.

int JACOUSTICS::JCounter::counter
protectedinherited

Definition at line 89 of file JAcoustics/JCounter.hh.


The documentation for this struct was generated from the following file: