Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JDetector
JPMTAngularAcceptance.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <fstream>
4
#include <iomanip>
5
#include <limits>
6
7
#include "
Jeep/JPrint.hh
"
8
#include "
Jeep/JParser.hh
"
9
#include "
Jeep/JMessage.hh
"
10
11
12
/**
13
* \author mdejong
14
*/
15
16
/**
17
* Auxiliary program to convert PMT QE(angle) data.
18
*/
19
int
main
(
int
argc,
char
**argv)
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
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1493
in
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition:
JSirene.sh:45
FIXED
Auxiliary data structure for floating point format specification.
Definition:
JPrint.hh:481
is
is
Definition:
JDAQCHSM.chsm:167
std::vector< double >
JPrint.hh
I/O formatting auxiliaries.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1954
JLANG::getline
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition:
JString.hh:478
debug
int debug
debug level
Definition:
JSirene.cc:61
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
energy
then for APP in event gandalf start energy
Definition:
JMuonMCEvt.sh:42
JParser.hh
Utility class to parse command line options.
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5