Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JFixedCan.cc File Reference

Auxiliary program to shift the generated tracks according a given offset. More...

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to shift the generated tracks according a given offset.

Author
vkulikovskiy

Definition in file JFixedCan.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 30 of file JFixedCan.cc.

31{
32 using namespace std;
33 using namespace JPP;
34
36 JFileRecorder <JTYPELIST<JAAnetTypes_t, JMeta>::typelist> outputFile;
37 JLimit_t& numberOfEvents = inputFile.getLimit();
38 double xshift;
39 double yshift;
40 double zshift;
41 int debug;
42
43 try {
44
45 JParser<> zap("Auxiliary program to shift the generated tracks according a given offset.");
46
47 zap['f'] = make_field(inputFile);
48 zap['o'] = make_field(outputFile);
49 zap['n'] = make_field(numberOfEvents) = JLimit::max();
50 zap['x'] = make_field(xshift) = 0.0;
51 zap['y'] = make_field(yshift) = 0.0;
52 zap['z'] = make_field(zshift) = 0.0;
53 zap['d'] = make_field(debug) = 1;
54
55 zap(argc, argv);
56 }
57 catch(const exception& error) {
58 FATAL(error.what() << endl);
59 }
60
61
62 outputFile.open();
63
64 outputFile.put(JMeta(argc,argv));
65
66 const Vec offset(xshift,yshift,zshift);
67
68 NOTICE("Offset applied to true tracks is: " << offset << endl);
69
70 Head header;
71
72 try {
73
74 header = getHeader(inputFile);
75
76 JHead buffer(header);
77
78 JAANET::simul info;
79
80 info.program = argv[0];
81 info.version = getGITVersion();
82 info.date = getDate();
83 info.time = getTime();
84
85 buffer.simul.push_back(info);
86
87 buffer.push(&JHead::simul);
88
89 bool can_found = buffer.is_valid(&JHead::can);
90 bool fixedcan_found = buffer.is_valid(&JHead::fixedcan);
91
92 if (can_found) {
93 NOTICE("can found" << endl);
94 }
95 if (fixedcan_found) {
96 NOTICE("fixedcan found" << endl);
97 }
98
99 if (can_found && !fixedcan_found) {
100
101 buffer.fixedcan.xcenter = xshift;
102 buffer.fixedcan.ycenter = yshift;
103 buffer.fixedcan.zmin = buffer.can.zmin + zshift;
104 buffer.fixedcan.zmax = buffer.can.zmax + zshift;
105 buffer.fixedcan.radius = buffer.can.r;
106
107 buffer.push(&JHead::fixedcan);
108
109 buffer.erase(&JHead::can);
110
111 } else if (fixedcan_found && !can_found) {
112
113 buffer.fixedcan.xcenter = buffer.fixedcan.xcenter + xshift;
114 buffer.fixedcan.ycenter = buffer.fixedcan.ycenter + yshift;
115 buffer.fixedcan.zmin = buffer.fixedcan.zmin + zshift;
116 buffer.fixedcan.zmax = buffer.fixedcan.zmax + zshift;
117
118 } else if (!can_found && !fixedcan_found) {
119
120 FATAL("Neither can nor fixedcan is found" << endl);
121
122 } else {
123
124 FATAL("Both can and fixedcan are found" << endl);
125 }
126
127 copy(buffer, header);
128 }
129 catch(const JException& error) {
130 FATAL(error << endl);
131 }
132
133 outputFile.put(header);
134
135
136 while (inputFile.hasNext()) {
137
138 Evt* evt = inputFile.next(); // input
139
140 for (vector<Trk>::iterator track = evt->mc_trks.begin(); track != evt->mc_trks.end(); ++track) {
141 track->pos += offset;
142 }
143
144 outputFile.put(*evt);
145 }
146
147 outputFile.close();
148}
string outputFile
#define NOTICE(A)
Definition JMessage.hh:64
#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
Monte Carlo run header.
Definition JHead.hh:1236
std::vector< JAANET::simul > simul
Definition JHead.hh:1591
JAANET::can can
Definition JHead.hh:1598
JAANET::fixedcan fixedcan
Definition JHead.hh:1599
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
const char * getGITVersion()
Get GIT version.
Definition Jpp.cc:9
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
const char * getTime()
Get current local time conform ISO-8601 standard.
const char * getDate()
Get current local date conform ISO-8601 standard.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition Evt.hh:49
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition Head.hh:65
std::string time
processing time
Definition JHead.hh:507
std::string date
processing date
Definition JHead.hh:506
std::string program
program name
Definition JHead.hh:504
std::string version
program version
Definition JHead.hh:505
Generator for simulation.
Definition JHead.hh:528
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition Vec.hh:13