Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JSpectrum.cc File Reference

Auxiliary program to generate spectrum for fast Fourier transformation. More...

#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include "JLang/gzstream.h"
#include "JMath/JConstants.hh"
#include "Jeep/JeepToolkit.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 generate spectrum for fast Fourier transformation.

Author
mdejong

Definition in file JSpectrum.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 21 of file JSpectrum.cc.

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}
string outputFile
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int numberOfPoints
Definition JResultPDF.cc:22
Utility class to parse command line options.
Definition JParser.hh:1698
void close(std::istream *pf)
Close file.
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