Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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 */
21int 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
string outputFile
Mathematical constants.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int numberOfPoints
Definition JResultPDF.cc:22
int main(int argc, char **argv)
Definition JSpectrum.cc:21
Auxiliary methods for handling file names, type names and environment.
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488