Jpp  18.0.1-rc.2
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 
9 
13 #include "JSupport/JSupport.hh"
14 
15 #include "JSystem/JDateAndTime.hh"
16 
18 
19 #include "Jeep/JParser.hh"
20 #include "Jeep/JMessage.hh"
21 
22 
23 /**
24  * \file
25  * Auxiliary program to shift the tracks to a given vector (horizontal shifts only!).
26  *
27  * \author vkulikovskiy
28  */
29 int main(int argc, char **argv)
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 }
double zmin
Bottom [m].
Definition: JHead.hh:585
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:23
debug
Definition: JMessage.hh:29
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Generator for simulation.
Definition: JHead.hh:513
std::string program
program name
Definition: JHead.hh:491
Recording of objects on file according a format that follows from the file name extension.
double zmax
Top [m].
Definition: JHead.hh:626
std::vector< JAANET::simul > simul
Definition: JHead.hh:1574
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
Date and time functions.
double ycenter
y-center [m]
Definition: JHead.hh:624
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
JAANET::fixedcan fixedcan
Definition: JHead.hh:1581
JAANET::can can
Definition: JHead.hh:1580
double xcenter
x-center [m]
Definition: JHead.hh:623
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:1360
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:1989
void erase(T JHead::*pd)
Reset and remove given data member from Head.
Definition: JHead.hh:1378
#define NOTICE(A)
Definition: JMessage.hh:64
std::string version
program version
Definition: JHead.hh:492
double zmin
Bottom [m].
Definition: JHead.hh:625
General purpose messaging.
Monte Carlo run header.
Definition: JHead.hh:1221
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
Scanning of objects from multiple files according a format that follows from the extension of each fi...
const char * getDate()
Get current local date conform ISO-8601 standard.
Definition: JDateAndTime.hh:36
double r
Radius [m].
Definition: JHead.hh:587
General purpose class for object reading from a list of file names.
std::string date
processing date
Definition: JHead.hh:493
Utility class to parse command line options.
double radius
Radius [m].
Definition: JHead.hh:627
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:494
bool is_valid(T JHead::*pd) const
Check validity of given data member in JHead.
Definition: JHead.hh:1305
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
double zmax
Top [m].
Definition: JHead.hh:586