Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JWriteOscParametersGrid.cc
Go to the documentation of this file.
1#include <set>
2#include <string>
3#include <iostream>
4
6
7#include "Jeep/JPrint.hh"
8#include "Jeep/JParser.hh"
9#include "Jeep/JMessage.hh"
10
12
13
14namespace {
15
16 /**
17 * Auxiliary function to terminate recursive calculation of flattened multi-dimensional container index.
18 *
19 * \param index index
20 * \return index
21 */
22 int getIndex(const int index)
23 {
24 return index;
25 }
26
27
28 /**
29 * Auxiliary function to retrieve the index of a flattened multi-dimensional container.
30 *
31 * Note: The containers and container indices corresponding to higher dimensions\n
32 * should be specified before those of lower dimensions.
33 *
34 * \param grid constituent grid
35 * \param index constituent grid index
36 * \param args remaining arguments
37 * \return index for flattened multi-dimensional container
38 */
39 template<class ...Args, class JContainer_t>
40 int getIndex(const int index,
41 const JContainer_t& container,
42 const Args& ...args)
43 {
44 return getIndex(args...) * container.getSize() + index;
45 }
46}
47
48
49/**
50 * Auxiliary program to write all elements in an oscillation parameters grid to separate output files.
51 */
52int main(const int argc, const char **argv)
53{
54 using namespace std;
55 using namespace JPP;
56
57 typedef JGrid<double> JGrid_t;
58 typedef JOscParameters<JGrid_t> JOscParameters_t;
59
60
61 JOscParameters_t parameterGrids;
62 string outputFile;
63
64 char wildcard;
65
66 int debug;
67
68 try {
69
70 JParser<> zap;
71
72 zap['o'] = make_field(outputFile, "output file")
73 = "oscillation_parameters.%.txt";
74 zap['w'] = make_field(wildcard, "wildcard character")
75 = '%';
76 zap['@'] = make_field(parameterGrids, "oscillation parameter grids")
77 = JOscParameters_t(true);
78 zap['d'] = make_field(debug, "debug")
79 = 0;
80
81 zap(argc, argv);
82 }
83 catch(const exception& error) {
84 FATAL(error.what() << endl);
85 }
86
87
88 const size_t pos = outputFile.find(wildcard);
89
90 if (pos == std::string::npos) {
91 FATAL("Given output file name must contain the given wildcard character " << wildcard);
92 }
93
94 const JGrid_t& theta12 = parameterGrids.theta12;
95 const JGrid_t& theta13 = parameterGrids.theta13;
96 const JGrid_t& theta23 = parameterGrids.theta23;
97 const JGrid_t& deltaCP = parameterGrids.deltaCP;
98 const JGrid_t& dM21sq = parameterGrids.dM21sq;
99 const JGrid_t& dM31sq = parameterGrids.dM31sq;
100
101 const int N = (theta12.getSize() *
102 theta13.getSize() *
103 theta23.getSize() *
104 deltaCP.getSize() *
105 dM21sq.getSize() *
106 dM31sq.getSize());
107
108 const int maxDigits = to_string(N).length();
109
110 NOTICE("Writing " << N << " oscillation parameters files" << endl);
111
112 JOscParameters<double> parameters;
113
114 for (int i1 = 0; i1 != dM21sq.getSize(); ++i1) {
115
116 parameters.dM21sq = dM21sq.getX(i1);
117
118 for (int i2 = 0; i2 != dM31sq.getSize(); ++i2) {
119
120 parameters.dM31sq = dM31sq.getX(i2);
121
122 for (int i3 = 0; i3 != deltaCP.getSize(); ++i3) {
123
124 parameters.deltaCP = deltaCP.getX(i3);
125
126 for (int i4 = 0; i4 != theta12.getSize(); ++i4) {
127
128 parameters.theta12 = theta12.getX(i4);
129
130 for (int i5 = 0; i5 != theta13.getSize(); ++i5) {
131
132 parameters.theta13 = theta13.getX(i5);
133
134 for (int i6 = 0; i6 != theta23.getSize(); ++i6) {
135
136 parameters.theta23 = theta23.getX(i6);
137
138 const int index = (getIndex(i6, theta23,
139 i5, theta13,
140 i4, theta12,
141 i3, deltaCP,
142 i2, dM31sq,
143 i1) + 1);
144
145 const string filename = string(outputFile).replace(pos, 1, MAKE_STRING(FILL(maxDigits,'0') << index));
146
147 ofstream out(filename.c_str());
148
149 out << parameters;
150
151 out.close();
152 }
153 }
154 }
155 }
156 }
157 }
158
159 return 0;
160}
string outputFile
General purpose messaging.
#define NOTICE(A)
Definition JMessage.hh:64
#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
I/O formatting auxiliaries.
#define MAKE_STRING(A)
Make string.
Definition JPrint.hh:63
int main(const int argc, const char **argv)
Auxiliary program to write all elements in an oscillation parameters grid to separate output files.
Data structure for single set of oscillation parameters.
JMixingAngle< T > theta23
PMNS mixing angle between the second and third neutrino mass eigenstates [rad].
JMassSquaredDifference< T > dM21sq
Squared mass difference between the first and second neutrino mass eigenstates [eV2].
JMixingAngle< T > theta12
PMNS mixing angle between the first and second neutrino mass eigenstates [rad].
JMassSquaredDifference< T > dM31sq
Squared mass difference between the first and third neutrino mass eigenstates [eV2].
JMixingAngle< T > theta13
PMNS mixing angle between the first and third neutrino mass eigenstates [rad].
JComplexPhase< T > deltaCP
PMNS phase angle [rad].
Utility class to parse command line options.
Definition JParser.hh:1698
int getIndex()
Get index for user I/O manipulation.
Definition JManip.hh:26
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Simple data structure for an abstract collection of equidistant abscissa values.
Definition JGrid.hh:40