Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JACOUSTICS::JEvent Struct Reference

Acoustic event. More...

#include <JEvent.hh>

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

Classes

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

Public Member Functions

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

Static Public Member Functions

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

Protected Attributes

int detid
 
int overlays
 
int id
 
int counter
 

Friends

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

Detailed Description

Acoustic event.

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

Constructor & Destructor Documentation

◆ JEvent() [1/2]

JACOUSTICS::JEvent::JEvent ( )
inline

Default constructor.

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

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

◆ JEvent() [2/2]

template<class T >
JACOUSTICS::JEvent::JEvent ( const int detid,
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
detiddetector identifier
countercounter
ididentifier
__beginbegin of data
__endend of data

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

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

◆ ~JEvent()

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

Virtual destructor.

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

122 {}

Member Function Documentation

◆ getDetectorID()

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

Get detector identifier.

Returns
detector identifier.

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

131 {
132 return detid;
133 }

◆ getOverlays()

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

Get number of overlayed events.

Returns
overlays

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

142 {
143 return overlays;
144 }

◆ getID()

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

Get emitter identifier.

Returns
identifier

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

153 {
154 return id;
155 }

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

167 {
168 using namespace std;
169
171
172 const_iterator __hit1 = this ->begin();
173 const_iterator __end1 = this ->end();
174
175 const_iterator __hit2 = event.begin();
176 const_iterator __end2 = event.end();
177
178 buffer.resize(this->size() + event.size());
179
180 iterator out = buffer.begin();
181
182 while (__hit1 != __end1 && __hit2 != __end2) {
183
184 if (*__hit1 < *__hit2) {
185
186 *out = *__hit1;
187 ++__hit1;
188
189 } else if (*__hit2 < *__hit1) {
190
191 *out = *__hit2;
192 ++__hit2;
193
194 } else {
195
196 *out = *__hit1;
197
198 ++__hit1;
199 ++__hit2;
200 }
201
202 ++out;
203 }
204
205 // append remaining hits from either set
206
207 out = copy(__hit1, __end1, out);
208 out = copy(__hit2, __end2, out);
209
210 buffer.resize(distance(buffer.begin(), out));
211
212 this->swap(buffer);
213
214 ++overlays;
215 }
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:163
friend void swap(JEvent &first, JEvent &second)
Swap events.

◆ overlap()

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

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

◆ read()

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

Read from input.

Parameters
inreader
Returns
reader

Implements JIO::JSerialisable.

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

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

◆ write()

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

Write to output.

Parameters
outwriter
Returns
writer

Implements JIO::JSerialisable.

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

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

◆ ClassDefOverride()

JACOUSTICS::JEvent::ClassDefOverride ( JEvent ,
4  )

◆ getCounter()

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

Get counter.

Returns
counter

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

51 {
52 return counter;
53 }

◆ ClassDefNV()

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

Friends And Related Symbol Documentation

◆ swap

void swap ( JEvent & first,
JEvent & second )
friend

Swap events.

Parameters
firstfirst event
secondsecond event

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

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

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

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

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

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

Member Data Documentation

◆ detid

int JACOUSTICS::JEvent::detid
protected

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

◆ overlays

int JACOUSTICS::JEvent::overlays
protected

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

◆ id

int JACOUSTICS::JEvent::id
protected

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

◆ counter

int JACOUSTICS::JCounter::counter
protectedinherited

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


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