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

Auxiliary program to add or modify mechanical model data of detector string. More...

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include "JAcoustics/JMechanics.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JContainer.hh"
#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)
 

Detailed Description

Auxiliary program to add or modify mechanical model data of detector string.

Syntax:

    -M "<string number>     (set) a b"

The options

    -A "<string number> a b"
    -r "<string number>"

can be used to add or remove a specific string, respectively.

Author
mdejong

Definition in file JEditMechanics.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 100 of file JEditMechanics.cc.

101{
102 using namespace std;
103 using namespace JPP;
104
105 typedef JContainer< map<int, JMechanics> > container_type;
106
107 string inputFile;
108 string outputFile;
111 set<int> rm;
112 bool squash;
113 int debug;
114
115 try {
116
117 JParser<> zap("Auxiliary program to add or modify mechanical model data of detector string.");
118
119 zap['f'] = make_field(inputFile, "mechanics input file");
120 zap['o'] = make_field(outputFile, "mechanics output file");
121 zap['M'] = make_field(mod, "mechanics modifier") = JPARSER::initialised();
122 zap['A'] = make_field(add, "add string mechanics") = JPARSER::initialised();
123 zap['r'] = make_field(rm, "remove string[s]") = JPARSER::initialised();
124 zap['q'] = make_field(squash, "squash meta data");
125 zap['d'] = make_field(debug, "debug level") = 2;
126
127 zap(argc, argv);
128 }
129 catch(const exception &error) {
130 FATAL(error.what() << endl);
131 }
132
133 container_type data;
134
135 try {
136 data.load(inputFile.c_str());
137 }
138 catch(const exception&) {}
139
140 if (squash) {
141 data.comment.clear();
142 }
143
144 data.comment.add(JMeta(argc,argv));
145
146 for (map<int, JMechanics>::const_iterator i = add.begin(); i != add.end(); ++i) {
147 if (data.count(i->first) == 0u)
148 data[i->first] = i->second;
149 else
150 ERROR("String " << i->first << " already exists." << endl);
151 }
152
153 for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
154
155 DEBUG("Modifier" << ' '
156 << "(" << FILL(2,'0') << i->id << FILL() << ")" << ' '
157 << "action" << ' ' << i->mechanics << endl);
158
159 JMechanics mechanics;
160
161 container_type::iterator p = data.find(i->id);
162
163 if (p != data.end()) {
164 mechanics = p->second;
165 }
166
167 if (!i->apply(mechanics))
168 ERROR("No valid action: " << *i << endl);
169 else
170 data[i->id] = mechanics;
171 }
172
173 for (set<int>::const_iterator i = rm.begin(); i != rm.end(); ++i) {
174
175 container_type::iterator p = data.find(*i);
176
177 if (p != data.end()) {
178 data.erase(p);
179 }
180 }
181
182 data.store(outputFile.c_str());
183}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#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
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
Auxiliary data structure for parameters of mechanical model.
Definition JMechanics.hh:41
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition JContainer.hh:42
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72