Jpp  15.0.1-rc.1-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFixedCan.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
8 
12 #include "JSupport/JSupport.hh"
13 #include "JSystem/JDate.hh" //for getDate
15 
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 
20 /**
21  * \file
22  * Auxiliary program to shift the tracks to a given vector (horizontal shifts only!).
23  *
24  * \author vkulikovskiy
25  */
26 int main(int argc, char **argv)
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 }
double zmin
Bottom [m].
Definition: JHead.hh:532
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Generator for simulation.
Definition: JHead.hh:460
std::string program
program name
Definition: JHead.hh:438
Recording of objects on file according a format that follows from the file name extension.
double zmax
Top [m].
Definition: JHead.hh:573
std::vector< JAANET::simul > simul
Definition: JHead.hh:1400
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
double ycenter
y-center [m]
Definition: JHead.hh:571
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Date and time functions.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JAANET::fixedcan fixedcan
Definition: JHead.hh:1407
JAANET::can can
Definition: JHead.hh:1406
double xcenter
x-center [m]
Definition: JHead.hh:570
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:12
void push(T JHead::*pd)
Push given data member to Head.
Definition: JHead.hh:1238
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
void erase(T JHead::*pd)
Remove given data member from Head.
Definition: JHead.hh:1250
#define NOTICE(A)
Definition: JMessage.hh:64
std::string version
program version
Definition: JHead.hh:439
int debug
debug level
Definition: JSirene.cc:63
double zmin
Bottom [m].
Definition: JHead.hh:572
const char * getDate(const JDateAndTimeFormat option=ISO8601)
Get ASCII formatted date.
General purpose messaging.
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
Scanning of objects from multiple files according a format that follows from the extension of each fi...
double r
Radius [m].
Definition: JHead.hh:534
General purpose class for object reading from a list of file names.
std::string date
processing date
Definition: JHead.hh:440
Utility class to parse command line options.
double radius
Radius [m].
Definition: JHead.hh:574
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
double zmax
Top [m].
Definition: JHead.hh:533
const_iterator pull(T JHead::*pd) const
Pull given data member from Head.
Definition: JHead.hh:1213