Jpp  17.3.0-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 #include "JSystem/JDate.hh" //for getDate
16 
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 
21 /**
22  * \file
23  * Auxiliary program to shift the tracks to a given vector (horizontal shifts only!).
24  *
25  * \author vkulikovskiy
26  */
27 int main(int argc, char **argv)
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 }
double zmin
Bottom [m].
Definition: JHead.hh:585
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
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:1517
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
double ycenter
y-center [m]
Definition: JHead.hh:624
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:1524
JAANET::can can
Definition: JHead.hh:1523
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:1306
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
void erase(T JHead::*pd)
Reset and remove given data member from Head.
Definition: JHead.hh:1324
#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: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
Scanning of objects from multiple files according a format that follows from the extension of each fi...
const char * getDate()
Get current date conform ISO-8601 standard.
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:73
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:1251
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