Jpp  17.3.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSpectrum.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <fstream>
4 #include <iomanip>
5 #include <cmath>
6 
7 #include "JLang/gzstream.h"
8 #include "JMath/JConstants.hh"
9 
10 #include "Jeep/JeepToolkit.hh"
11 #include "Jeep/JParser.hh"
12 #include "Jeep/JMessage.hh"
13 
14 
15 /**
16  * \file
17  * Auxiliary program to generate spectrum for fast Fourier transformation.
18  *
19  * \author mdejong
20  */
21 int main(int argc, char **argv)
22 {
23  using namespace std;
24  using namespace JPP;
25 
26  string outputFile;
27  size_t numberOfPoints;
28  double frequency;
29  double binWidth;
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Auxiliary program to generate spectrum for fast Fourier transformation.");
35 
36  zap['o'] = make_field(outputFile) = "waveform.txt";
37  zap['n'] = make_field(numberOfPoints);
38  zap['F'] = make_field(frequency);
39  zap['B'] = make_field(binWidth);
40  zap['d'] = make_field(debug) = 2;
41 
42  zap(argc, argv);
43  }
44  catch(const exception& error) {
45  FATAL(error.what() << endl);
46  }
47 
48  // output
49 
50  ostream* out = open<ostream>(outputFile.c_str());
51 
52  for (size_t i = 0; i != numberOfPoints; ++i) {
53 
54  const double x = i * binWidth;
55  const double y = sin(x * 2*PI * frequency);
56 
57  *out << SCIENTIFIC(9,6) << y << endl;
58  }
59 
60  close(out);
61 }
62 
Utility class to parse command line options.
Definition: JParser.hh:1517
int main(int argc, char *argv[])
Definition: Main.cc:15
string outputFile
then usage set_variable ACOUSTICS_WORKDIR $WORKDIR set_variable FORMULA sin([0]+2 *$PI *([1]+[2]*x)*x)" set_variable DY 1.0e-8 mkdir $WORKDIR for DETECTOR in $DETECTORS[*]
Mathematical constants.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
void close(std::istream *pf)
Close file.
Definition: JeepToolkit.hh:386
Auxiliary methods for handling file names, type names and environment.
static const double PI
Mathematical constants.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
int numberOfPoints
Definition: JResultPDF.cc:22
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
int debug
debug level