Jpp  15.0.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  shiftinfo.program = "JShift";
73  shiftinfo.version = getGITVersion();
74  shiftinfo.date = getDate();
75  shiftinfo.time = getTime();
76  buffer.simul.push_back(shiftinfo);
77  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
78 
79  bool can_found = buffer.pull(&JHead::can) != buffer.end();
80  bool fixedcan_found = buffer.pull(&JHead::fixedcan) != buffer.end();
81 
82  if (debug >= 3) {
83  if (can_found) {
84  NOTICE("can found" << endl);
85  }
86  if (fixedcan_found) {
87  NOTICE("fixedcan found" << endl);
88  }
89  }
90 
91  if (can_found and !(fixedcan_found)) {
92  buffer.fixedcan.xcenter = xshift;
93  buffer.fixedcan.ycenter = yshift;
94  buffer.fixedcan.zmin = buffer.can.zmin;
95  buffer.fixedcan.zmax = buffer.can.zmax;
96  buffer.fixedcan.radius = buffer.can.r;
97  buffer.erase(&JHead::can);
98  buffer.push(&JHead::fixedcan);
99  } else if (fixedcan_found and !(can_found)) {
100  buffer.fixedcan.xcenter = buffer.fixedcan.xcenter + xshift;
101  buffer.fixedcan.ycenter = buffer.fixedcan.ycenter + yshift;
102  } else if (!(can_found) and !(fixedcan_found)) {
103  FATAL("Neither can nor fixedcan is found" << endl);
104  } else {
105  FATAL("Both can and fixedcan are found" << endl);
106  }
107 
108  copy(buffer, header);
109  }
110  catch(const JException& error) {
111  FATAL(error);
112  }
113  outputFile.put(header);
114 
115 
116  while (inputFile.hasNext()) {
117 
118  Evt* evt = inputFile.next(); // input
119 
120  for (vector<Trk>::iterator track = evt->mc_trks.begin(); track != evt->mc_trks.end(); ++track) {
121  track->pos += center;
122  }
123 
124  outputFile.put(*evt);
125  }
126 
127  outputFile.close();
128 }
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
Generator for simulation.
Definition: JHead.hh:460
std::string program
program name
Definition: JHead.hh:438
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:439
int debug
debug level
Definition: JSirene.cc:63
const char * getDate(const JDateAndTimeFormat option=ISO8601)
Get ASCII formatted date.
Monte Carlo run header.
Definition: JHead.hh:1113
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:440
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:441
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