Jpp  debug
the software that should make you happy
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 int detid, const int counter, const int id, T __begin, T __end)
 Constructor. More...
 
virtual ~JEvent ()
 Virtual destructor. More...
 
const int getDetectorID () 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, 4)
 
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

int detid
 
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

◆ JEvent() [1/2]

JACOUSTICS::JEvent::JEvent ( )
inline

Default constructor.

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

78  :
79  JCounter(),
80  overlays(0),
81  id (-1)
82  {}
JCounter()
Default constructor.

◆ JEvent() [2/2]

template<class T >
JACOUSTICS::JEvent::JEvent ( const int  detid,
const int  counter,
const int  id,
__begin,
__end 
)
inline

Constructor.

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

Parameters
detiddetector identifier
countercounter
ididentifier
__beginbegin of data
__endend of data

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

101  :
102  JCounter(counter),
103  detid (detid),
104  overlays(0),
105  id (id)
106  {
107  using namespace std;
108 
109  for (T i = __begin; i != __end; ++i) {
110  push_back(*i);
111  }
112 
113  sort(this->begin(), this->end());
114  }
Definition: JSTDTypes.hh:14

◆ ~JEvent()

virtual JACOUSTICS::JEvent::~JEvent ( )
inlinevirtual

Virtual destructor.

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

121  {}

Member Function Documentation

◆ getDetectorID()

const int JACOUSTICS::JEvent::getDetectorID ( ) const
inline

Get detector identifier.

Returns
detector identifier.

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

130  {
131  return detid;
132  }

◆ getOverlays()

int JACOUSTICS::JEvent::getOverlays ( ) const
inline

Get number of overlayed events.

Returns
overlays

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

141  {
142  return overlays;
143  }

◆ getID()

int JACOUSTICS::JEvent::getID ( ) const
inline

Get emitter identifier.

Returns
identifier

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

152  {
153  return id;
154  }

◆ merge()

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 165 of file JAcoustics/JEvent.hh.

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

◆ overlap()

template<class T >
static void JACOUSTICS::JEvent::overlap ( p,
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 247 of file JAcoustics/JEvent.hh.

248  {
249  for (T __q = p, __p = __q++; __p != q && __q != q; __p = __q++) {
250 
251  if (!__p->empty() &&
252  !__q->empty() &&
253  __q->begin()->getToE() < __p->rbegin()->getToE() + Tmax_s) {
254 
255  __p->clear(); // clear first
256 
257  for (__p = __q++; __p != q && __q != q; __p = __q++) {
258 
259  if (__q->begin()->getToE() < __p->rbegin()->getToE() + Tmax_s)
260  __p->clear(); // clear intermediate
261  else
262  break;
263  }
264 
265  __p->clear(); // clear last
266  }
267  }
268  }

◆ read()

virtual JReader& JACOUSTICS::JEvent::read ( JReader in)
inlineoverridevirtual

Read from input.

Parameters
inreader
Returns
reader

Implements JIO::JSerialisable.

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

327  {
328  in >> static_cast<JCounter&>(*this);
329  in >> this->detid;
330  in >> this->overlays;
331  in >> this->id;
332  in >> static_cast<std::vector<JTransmission>&>(*this);
333 
334  return in;
335  }

◆ write()

virtual JWriter& JACOUSTICS::JEvent::write ( JWriter out) const
inlineoverridevirtual

Write to output.

Parameters
outwriter
Returns
writer

Implements JIO::JSerialisable.

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

345  {
346  out << static_cast<const JCounter&>(*this);
347  out << this->detid;
348  out << this->overlays;
349  out << this->id;
350  out << static_cast<const std::vector<JTransmission>&>(*this);
351 
352  return out;
353  }

◆ ClassDefOverride()

JACOUSTICS::JEvent::ClassDefOverride ( JEvent  ,
 
)

◆ getCounter()

int JACOUSTICS::JCounter::getCounter ( ) const
inlineinherited

Get counter.

Returns
counter

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

52  {
53  return counter;
54  }

◆ ClassDefNV()

JACOUSTICS::JCounter::ClassDefNV ( JCounter  ,
 
)
inherited

Friends And Related Function Documentation

◆ swap

void swap ( JEvent first,
JEvent second 
)
friend

Swap events.

Parameters
firstfirst event
secondsecond event

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

224  {
225  std::swap(first.counter, second.counter);
226  std::swap(first.detid, second.detid);
227  std::swap(first.overlays, second.overlays);
228  std::swap(first.id, second.id);
229 
230  static_cast<std::vector<JTransmission>&>(first).swap(static_cast<std::vector<JTransmission>&>(second));
231  }

◆ operator<

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 281 of file JAcoustics/JEvent.hh.

282  {
283  if (!first.empty() && !second.empty())
284  return first.begin()->getToE() < second.begin()->getToE();
285  else
286  return first.getCounter() < second.getCounter();
287  }
int getCounter() const
Get counter.

◆ operator<<

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 297 of file JAcoustics/JEvent.hh.

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

Member Data Documentation

◆ detid

int JACOUSTICS::JEvent::detid
protected

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

◆ overlays

int JACOUSTICS::JEvent::overlays
protected

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

◆ id

int JACOUSTICS::JEvent::id
protected

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

◆ counter

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: