63 int main(
int argc,
char **argv)
81 transmitters_container transmitters;
82 hydrophones_container hydrophones;
88 JParser<> zap(
"Main program to trigger events in acoustic data.");
90 zap[
'f'] =
make_field(inputFile,
"output of JConvertDB -q toashort");
91 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
95 zap[
'a'] =
make_field(detectorFile,
"detector file");
100 zap[
'p'] =
make_field(precision,
"precision time-of-arrival") = 1.0e-6;
105 catch(
const exception &error) {
106 FATAL(error.what() << endl);
124 for (JDetector::const_iterator i =
detector.begin(); i !=
detector.end(); ++i) {
131 if (i->getFloor() == 0) {
138 catch(
const exception&) {
143 receivers[i->getID()] =
JReceiver(i->getID(),
144 i->getPosition() + pos,
145 i->getT0() * 1.0e-9);
149 for (tripods_container::const_iterator i =
tripods.begin(); i !=
tripods.end(); ++i) {
150 emitters[i->getID()] =
JEmitter(i->getID(),
151 i->getUTMPosition() -
detector.getUTMPosition());
154 for (transmitters_container::const_iterator i = transmitters.begin(); i != transmitters.end(); ++i) {
156 emitters[i->getID()] =
JEmitter(i->getID(),
159 catch(
const exception&) {
177 public map<int, JQuantile>
179 long long int sum()
const
181 long long int count = 0;
183 for (const_iterator i = this->begin(); i != this->end(); ++i) {
184 count += i->second.getCount();
191 map_type number_of_entries;
192 map_type number_of_aliens;
193 map_type number_of_triggers;
194 map_type number_of_events;
195 map_type number_of_outliers;
205 while (inputFile.hasNext()) {
207 if (inputFile.getCounter()%1000 == 0) {
208 STATUS(
"counter: " << setw(8) << inputFile.getCounter() <<
'\r' << flush);
DEBUG(endl);
214 oid = parameters->
DETID;
217 if (oid != parameters->
DETID) {
218 FATAL(
"Invalid detector identifier " << parameters->
DETID <<
" != " << oid << endl);
225 number_of_entries[parameters->
EMITTERID].put(1);
227 if (emitters.has(
id) && receivers.has(parameters->
DOMID)) {
234 catch(
const exception&) {
235 number_of_aliens[parameters->
EMITTERID].put(1);
240 for (map_type::const_iterator i = number_of_entries.begin(); i != number_of_entries.end(); ++i) {
241 STATUS(
"number of entries: " << setw(3) << i->first <<
' ' << setw(8) << i->second.getCount() << endl);
244 for (map_type::const_iterator i = number_of_aliens.begin(); i != number_of_aliens.end(); ++i) {
245 STATUS(
"number of aliens: " << setw(3) << i->first <<
' ' << setw(8) << i->second.getCount() << endl);
255 buffer_type& buffer = receiver->second;
274 buffer_type& f2 = receiver->second;
287 copy(f2.begin(), __end, back_inserter(buffer));
291 sort(buffer.begin(), buffer.end());
297 for (buffer_type::const_iterator p = buffer.begin(); p != buffer.end(); ++p) {
299 buffer_type::const_iterator q = p;
303 while (++q != buffer.end() && q->getToE() - p->getToE() <=
parameters.TMax_s) {}
309 STATUS(
"trigger: " << setw(8) << number_of_triggers.sum() <<
'\r' << flush);
DEBUG(endl);
311 JEvent event(oid, number_of_triggers.sum(), i->first, p, q);
313 number_of_triggers[i->first].put(event.size());
315 DEBUG(
"trigger: " << endl << event);
317 data.push_back(event);
321 STATUS(
"number of toes: " << setw(3) << i->first <<
' ' << setw(8) << buffer.size());
322 if (Q.getCount() > 0) {
324 ' ' <<
FIXED(6,1) << Q.getXmin() <<
325 ' ' <<
FIXED(6,1) << Q.getXmax());
331 for (JTriggerOutput::const_iterator event = data.begin();
event != data.end(); ++event) {
333 number_of_events[
event->getID()].put(event->size());
337 const int M = (int) (event->size() * 0.5 * (1.0 -
parameters.quantile));
339 JEvent::const_iterator p =
event-> begin();
advance(p, M);
340 JEvent::const_reverse_iterator q =
event->rbegin();
advance(q, M);
342 const double Tmin = p->getToE();
343 const double Tmax = q->getToE();
347 while (p != event-> begin() && (p - 1)->getToE() >= Tmin - 0.5 * (Tmax - Tmin) * W) { --p; }
348 while (q != event->rbegin() && (q - 1)->getToE() <= Tmax + 0.5 * (Tmax - Tmin) * W) { --q; }
350 number_of_outliers[
event->getID()].put(event->size() -
distance(p, q.base()));
359 number_of_outliers[
event->getID()].put(0);
367 for (map_type::const_iterator i = number_of_triggers.begin(); i != number_of_triggers.end(); ++i) {
368 STATUS(
"number of triggers: " << setw(3) << i->first <<
' ' << setw(8) << i->second.getCount() << endl);
371 for (map_type::const_iterator i = number_of_events.begin(); i != number_of_events.end(); ++i) {
372 STATUS(
"number of events: " << setw(3) << i->first <<
' ' << setw(8) << i->second.getCount() <<
' ' <<
FIXED(7,3) << i->second.getMean() <<
' ' <<
FIXED(7,3) << number_of_outliers[i->first].getMean() << endl);
Utility class to parse command line options.
Q(UTCMax_s-UTCMin_s)-livetime_s
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
int main(int argc, char *argv[])
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
General purpose class for hash map of unique elements.
ROOT TTree parameter settings.
Recording of objects on file according a format that follows from the file name extension.
std::string DETID
constraint
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
Data structure for detector geometry and calibration.
Data structure for hydrophone.
then fatal Not enough arguments fi set_variable INDEX_STRING_START while[[${${argv[${START_INDEX_STRING}]}##*.}!="root"]]
const JPolynome f1(1.0, 2.0, 3.0)
Function.
Auxiliary class for defining the range of iterations of objects.
static const JSoundVelocity getSoundVelocity(1541.0,-17.0e-3,-2000.0)
Function object for velocity of sound.
I/O formatting auxiliaries.
Data structure for transmitter.
void merge(const JMatch_t &match)
Merge events.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
int getID() const
Get identifier.
JPosition3D getPosition(const Vec &pos)
Get position.
static struct JACOUSTICS::@4 compare
Auxiliary data structure to sort transmissions.
JTransmission getTransmission(const JToAshort &data, const JAbstractSoundVelocity &V) const
Get transmission.
ROOT TTree parameter settings.
double getQ(const double D_m, const double f_kHz, const double d_m)
Get relative quality for given frequency at given distance.
General purpose messaging.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Implementation for depth dependend velocity of sound.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Acoustic trigger parameters.
Auxiliary class to define a range between two values.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
static const int PIEZO_DISABLE
Enable (disable) use of piezo if this status bit is 0 (1);.
void copy(const Head &from, JHead &to)
Copy header from from to to.
static const int HYDROPHONE_DISABLE
Enable (disable) use of hydrophone if this status bit is 0 (1);.
Data structure for position in three dimensions.
const JLimit & getLimit() const
Get limit.
bool equals(const JFirst_t &first, const JSecond_t &second, const double precision=std::numeric_limits< double >::min())
Check equality.
static JEmitterID getEmitterID
Function object for emitter identification.
do set_variable DETECTOR_TXT $WORKDIR detector
Data structure for tripod.
Match of two events considering overlap in time.
int EMITTERID
waveform identifier
#define DEBUG(A)
Message macros.