Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintRMS.cc File Reference

Auxiliary program to print RMS of acoustic events. More...

#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "JSupport/JMultipleFileScanner.hh"
#include "JAcoustics/JEvent.hh"
#include "JAcoustics/JSupport.hh"
#include "JTools/JQuantile.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print RMS of acoustic events.

Author
mdejong

Definition in file JPrintRMS.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file JPrintRMS.cc.

26 {
27  using namespace std;
28  using namespace JPP;
29 
31  JLimit_t& numberOfEvents = inputFile.getLimit();
32  size_t numberOfOutliers;
33  int debug;
34 
35  try {
36 
37  JParser<> zap("Auxiliary program to print RMS of acoustic events.");
38 
39  zap['f'] = make_field(inputFile);
40  zap['n'] = make_field(numberOfEvents) = JLimit_t::max();
41  zap['N'] = make_field(numberOfOutliers) = 0;
42  zap['d'] = make_field(debug) = 1;
43 
44  zap(argc, argv);
45  }
46  catch(const exception &error) {
47  FATAL(error.what() << endl);
48  }
49 
50 
51  JQuantile Q;
52 
53  while (inputFile.hasNext()) {
54 
55  const JEvent* evt = inputFile.next();
56 
57  vector<double> buffer;
58 
59  for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
60  buffer.push_back(i->getToE());
61  }
62 
63  if (buffer.size() >= 2 * numberOfOutliers + 5) {
64 
65  sort(buffer.begin(), buffer.end());
66 
67  vector<double>::iterator p = buffer.begin();
68  vector<double>::reverse_iterator q = buffer.rbegin();
69 
70  for (size_t i = 0; i != numberOfOutliers; ++i) {
71  ++p;
72  ++q;
73  }
74 
75  const double x0 = 0.5 * (*p + *q);
76 
77  for (vector<double>::iterator i = p; i != q.base(); ++i) {
78  *i -= x0;
79  }
80 
81  const JQuantile q1("", p, q.base());
82 
83  Q.put(q1.getSTDev());
84  }
85  }
86 
87  cout << Q.getMean();
88 }
Utility class to parse command line options.
Definition: JParser.hh:1493
Quantile calculator.
Definition: JQuantile.hh:83
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
void put(const double x, const double w=1.0)
Put value.
Definition: JQuantile.hh:198
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
Acoustic event.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73