Jpp  17.0.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/Evt.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JSystem/JDate.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 26 of file JFixedCan.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30 
31  JMultipleFileScanner<Evt> inputFile;
33  JLimit_t& numberOfEvents = inputFile.getLimit();
34  int debug;
35  double xshift;
36  double yshift;
37 
38  try {
39 
40  JParser<> zap("Auxiliary program to convert data formats.");
41 
42  zap['f'] = make_field(inputFile);
43  zap['o'] = make_field(outputFile);
44  zap['n'] = make_field(numberOfEvents) = JLimit::max();
45  zap['x'] = make_field(xshift) = 0.0;
46  zap['y'] = make_field(yshift) = 0.0;
47  zap['d'] = make_field(debug) = 1;
48 
49  zap(argc, argv);
50  }
51  catch(const exception& error) {
52  FATAL(error.what() << endl);
53  }
54 
55 
56  outputFile.open();
57 
58  Vec center(xshift,yshift,0);
59 
60  if (debug >= 3)
61  NOTICE("Offset applied to true tracks is: " << center << endl);
62 
63  Head header;
64 
65  try {
66 
67  header = getHeader(inputFile);
68 
69  JHead buffer(header);
70 
71  JAANET::simul shiftinfo;
72 
73  shiftinfo.program = "JShift";
74  shiftinfo.version = getGITVersion();
75  shiftinfo.date = getDate();
76  shiftinfo.time = getTime();
77  buffer.simul.push_back(shiftinfo);
78  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
79 
80  bool can_found = buffer.pull(&JHead::can) != buffer.end();
81  bool fixedcan_found = buffer.pull(&JHead::fixedcan) != buffer.end();
82 
83  if (debug >= debug_t) {
84  if (can_found) {
85  NOTICE("can found" << endl);
86  }
87  if (fixedcan_found) {
88  NOTICE("fixedcan found" << endl);
89  }
90  }
91 
92  if (can_found and !(fixedcan_found)) {
93  buffer.fixedcan.xcenter = xshift;
94  buffer.fixedcan.ycenter = yshift;
95  buffer.fixedcan.zmin = buffer.can.zmin;
96  buffer.fixedcan.zmax = buffer.can.zmax;
97  buffer.fixedcan.radius = buffer.can.r;
98  buffer.erase(&JHead::can);
99  buffer.push(&JHead::fixedcan);
100  } else if (fixedcan_found and !(can_found)) {
101  buffer.fixedcan.xcenter = buffer.fixedcan.xcenter + xshift;
102  buffer.fixedcan.ycenter = buffer.fixedcan.ycenter + yshift;
103  } else if (!(can_found) and !(fixedcan_found)) {
104  FATAL("Neither can nor fixedcan is found" << endl);
105  } else {
106  FATAL("Both can and fixedcan are found" << endl);
107  }
108 
109  copy(buffer, header);
110  }
111  catch(const JException& error) {
112  FATAL(error);
113  }
114  outputFile.put(header);
115 
116 
117  while (inputFile.hasNext()) {
118 
119  Evt* evt = inputFile.next(); // input
120 
121  for (vector<Trk>::iterator track = evt->mc_trks.begin(); track != evt->mc_trks.end(); ++track) {
122  track->pos += center;
123  }
124 
125  outputFile.put(*evt);
126  }
127 
128  outputFile.close();
129 }
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
debug
Definition: JMessage.hh:29
Generator for simulation.
Definition: JHead.hh:511
std::string program
program name
Definition: JHead.hh:489
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.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
std::string version
program version
Definition: JHead.hh:490
int debug
debug level
Definition: JSirene.cc:66
const char * getDate(const JDateAndTimeFormat option=ISO8601)
Get ASCII formatted date.
Monte Carlo run header.
Definition: JHead.hh:1165
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:67
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
std::string date
processing date
Definition: JHead.hh:491
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
std::string time
processing time
Definition: JHead.hh:492
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition: Evt.hh:46
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19