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

Auxiliary program to modify transmitter configuration. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include "JDetector/JTransmitter.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 modify transmitter configuration.

Syntax:

    -S "<string number>         (set|add|sub) x y z"
    -S "<string number>         (rot) phi"

For option rot, the angle phi refers to an anti-clockwise rotation around the z-axis.
The rotation angle is defined in radians.

The options

    -A "<identifier> <string number> <floor> x y z"
    -r "<string number>"

can be used to add and remove a transmitter, respectively.

Author
mdejong

Definition in file JEditTransmitter.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 171 of file JEditTransmitter.cc.

172{
173 using namespace std;
174 using namespace JPP;
175
176 typedef JContainer< vector<JTransmitter> > container_type;
177
178 string inputFile;
179 string outputFile;
182 set<int> keep;
183 set<int> rm;
184 bool squash;
185 int debug;
186
187 try {
188
189 JParser<> zap("Auxiliary program to modify transmitter configuration.");
190
191 zap['f'] = make_field(inputFile, "transmitter input file") = "";
192 zap['o'] = make_field(outputFile, "transmitter output file");
193 zap['S'] = make_field(mod, "transmitter modifier") = JPARSER::initialised();
194 zap['A'] = make_field(add, "add transmitter") = JPARSER::initialised();
195 zap['k'] = make_field(keep, "keep transmitter[s]") = JPARSER::initialised();
196 zap['r'] = make_field(rm, "remove transmitter[s]") = JPARSER::initialised();
197 zap['q'] = make_field(squash, "squash meta data");
198 zap['d'] = make_field(debug, "debug level") = 2;
199
200 zap(argc, argv);
201 }
202 catch(const exception &error) {
203 FATAL(error.what() << endl);
204 }
205
206 container_type data;
207
208 if (inputFile != "") {
209 try {
210 data.load(inputFile.c_str());
211 }
212 catch(const exception& error) {
213 //FATAL(error.what() << endl);
214 }
215 }
216
217 if (squash) {
218 data.comment.clear();
219 }
220
221 data.comment.add(JMeta(argc, argv));
222
223 for (vector<JTransmitter>::const_iterator i = add.begin(); i != add.end(); ++i) {
224 data.push_back(*i);
225 }
226
227 for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
228
229 for (container_type::iterator target = data.begin(); target != data.end(); ++target) {
230
231 if (target->getString() == i->id) {
232
233 DEBUG("Modifier" << ' '
234 << "(" << FILL(4,'0') << target->getString() << "," << FILL(2,'0') << target->getFloor() << FILL() << ")" << ' '
235 << "action" << ' ' << i->action << JEEPZ() << i->data << endl);
236
237 if (!i->apply(*target)) {
238 ERROR("No valid action: " << *i << endl);
239 }
240 }
241 }
242 }
243
244 for (container_type::iterator i = data.begin(); i != data.end(); ) {
245
246 if ((keep.empty() || keep.count(i->getString()) != 0) &&
247 (rm .empty() || rm .count(i->getString()) == 0))
248 ++i;
249 else
250 i = data.erase(i);
251 }
252
253 data.store(outputFile.c_str());
254}
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
Target.
Definition JHead.hh:300
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition JContainer.hh:42
Auxiliary data structure for streaming of STL containers.
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