Jpp  17.2.1-pre0
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/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 27 of file JFixedCan.cc.

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