Jpp  18.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JFixedCan.cc File Reference

Auxiliary program to shift the tracks to a given vector (horizontal shifts only!). More...

#include <string>
#include <iostream>
#include <iomanip>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JSystem/JDateAndTime.hh"
#include "JROOT/JROOTClassSelector.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 shift the tracks to a given vector (horizontal shifts only!).

Author
vkulikovskiy

Definition in file JFixedCan.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file JFixedCan.cc.

30 {
31  using namespace std;
32  using namespace JPP;
33 
34  JMultipleFileScanner<Evt> inputFile;
36  JLimit_t& numberOfEvents = inputFile.getLimit();
37  int debug;
38  double xshift;
39  double yshift;
40 
41  try {
42 
43  JParser<> zap("Auxiliary program to convert data formats.");
44 
45  zap['f'] = make_field(inputFile);
46  zap['o'] = make_field(outputFile);
47  zap['n'] = make_field(numberOfEvents) = JLimit::max();
48  zap['x'] = make_field(xshift) = 0.0;
49  zap['y'] = make_field(yshift) = 0.0;
50  zap['d'] = make_field(debug) = 1;
51 
52  zap(argc, argv);
53  }
54  catch(const exception& error) {
55  FATAL(error.what() << endl);
56  }
57 
58 
59  outputFile.open();
60 
61  Vec center(xshift,yshift,0);
62 
63  if (debug >= 3)
64  NOTICE("Offset applied to true tracks is: " << center << endl);
65 
66  Head header;
67 
68  try {
69 
70  header = getHeader(inputFile);
71 
72  JHead buffer(header);
73 
74  JAANET::simul shiftinfo;
75 
76  shiftinfo.program = "JShift";
77  shiftinfo.version = getGITVersion();
78  shiftinfo.date = getDate();
79  shiftinfo.time = getTime();
80  buffer.simul.push_back(shiftinfo);
81  buffer.push(&JHead::simul); //simul tag is registered with this. Actually there should be already simul info registered from generator, so we don't really need it
82 
83  bool can_found = buffer.is_valid(&JHead::can);
84  bool fixedcan_found = buffer.is_valid(&JHead::fixedcan);
85 
86  if (debug >= debug_t) {
87  if (can_found) {
88  NOTICE("can found" << endl);
89  }
90  if (fixedcan_found) {
91  NOTICE("fixedcan found" << endl);
92  }
93  }
94 
95  if (can_found and !(fixedcan_found)) {
96  buffer.fixedcan.xcenter = xshift;
97  buffer.fixedcan.ycenter = yshift;
98  buffer.fixedcan.zmin = buffer.can.zmin;
99  buffer.fixedcan.zmax = buffer.can.zmax;
100  buffer.fixedcan.radius = buffer.can.r;
101  buffer.erase(&JHead::can);
102  buffer.push(&JHead::fixedcan);
103  } else if (fixedcan_found and !(can_found)) {
104  buffer.fixedcan.xcenter = buffer.fixedcan.xcenter + xshift;
105  buffer.fixedcan.ycenter = buffer.fixedcan.ycenter + yshift;
106  } else if (!(can_found) and !(fixedcan_found)) {
107  FATAL("Neither can nor fixedcan is found" << endl);
108  } else {
109  FATAL("Both can and fixedcan are found" << endl);
110  }
111 
112  copy(buffer, header);
113  }
114  catch(const JException& error) {
115  FATAL(error);
116  }
117  outputFile.put(header);
118 
119 
120  while (inputFile.hasNext()) {
121 
122  Evt* evt = inputFile.next(); // input
123 
124  for (vector<Trk>::iterator track = evt->mc_trks.begin(); track != evt->mc_trks.end(); ++track) {
125  track->pos += center;
126  }
127 
128  outputFile.put(*evt);
129  }
130 
131  outputFile.close();
132 }
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:24
debug
Definition: JMessage.hh:29
Generator for simulation.
Definition: JHead.hh:526
std::string program
program name
Definition: JHead.hh:504
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:12
std::string getGITVersion(const std::string &tag)
Get GIT version for given GIT tag.
Monte Carlo run header.
Definition: JHead.hh:1234
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define NOTICE(A)
Definition: JMessage.hh:64
std::string version
program version
Definition: JHead.hh:505
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:65
#define FATAL(A)
Definition: JMessage.hh:67
const char * getDate()
Get current local date conform ISO-8601 standard.
Definition: JDateAndTime.hh:36
General purpose class for object reading from a list of file names.
std::string date
processing date
Definition: JHead.hh:506
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
std::string time
processing time
Definition: JHead.hh:507
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition: Evt.hh:49
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20