Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JPMTAngularAcceptance.cc File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <limits>
#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)
 Auxiliary program to convert PMT QE(angle) data.
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Auxiliary program to convert PMT QE(angle) data.

Author
mdejong

Definition at line 19 of file JPMTAngularAcceptance.cc.

20{
21 using namespace std;
22
23 string inputFile;
24 int debug;
25
26 try {
27
28 JParser<> zap("Auxiliary program to convert PMT QE(angle) data.");
29
30 zap['f'] = make_field(inputFile);
31 zap['d'] = make_field(debug) = 1;
32
33 zap(argc, argv);
34 }
35 catch(const exception &error) {
36 FATAL(error.what() << endl);
37 }
38
39
40 const string DEG("deg");
41
42
43 if (inputFile != "") {
44
45 ifstream in(inputFile.c_str());
46
47 while (in.peek() == '#') {
48 in.ignore(numeric_limits<streamsize>::max(), '\n');
49 }
50
51 // header
52
53 vector<double> energy;
54 vector<double> wavelength;
55
56 string buffer, key;
57
58 if (getline(in,buffer)) {
59
60 istringstream is(buffer);
61
62 is >> key;
63
64 for (double x; is >> x; ) {
65 energy.push_back(x);
66 }
67 }
68
69 if (getline(in,buffer)) {
70
71 istringstream is(buffer);
72
73 is >> key;
74
75 for (double x; is >> x; ) {
76 wavelength.push_back(x);
77 }
78 }
79
80 //in.ignore(numeric_limits<streamsize>::max(), '\n');
81
82
83 // data
84
85 while (getline(in,buffer)) {
86
87 istringstream is(buffer);
88
89 // first column
90 /*
91 is >> key;
92
93 const size_t pos = key.find(DEG);
94
95 if (pos != string::npos) {
96 key.replace(pos, DEG.size(), "");
97 }
98
99 double angle;
100
101 istringstream(key) >> angle;
102 */
103 double ct;
104
105 is >> ct;
106
107 // following columns
108
109 size_t i = 0;
110
111 for (double y ; is >> y; ++i) {
112
113 if (i != energy.size()) {
114 cout << " (*this)"
115 << noshowpos
116 //<< "[" << FIXED(5,1) << angle << "]"
117 //<< "[" << FIXED(3,1) << energy[i] << "]"
118 << "[" << FIXED(5,2) << -ct << "]"
119 << "[" << FIXED(3,1) << wavelength[i] << "]"
120 << " = "
121 << showpos
122 << FIXED(9,5) << y
123 << ";" << endl;
124 } else {
125 //FATAL("Inconsistent data " << i << " != " << energy.size() << endl);
126 FATAL("Inconsistent data " << i << " != " << wavelength.size() << endl);
127 }
128 }
129
130 if (i != energy.size()) {
131 //FATAL("Inconsistent data " << i << " != " << energy.size() << endl);
132 FATAL("Inconsistent data " << i << " != " << wavelength.size() << endl);
133 }
134 }
135
136 in.close();
137 }
138}
#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
Utility class to parse command line options.
Definition JParser.hh:1698
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448