Jpp  17.0.0-rc.1
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 
73  shiftinfo.program = "JShift";
74  shiftinfo.version = getGITVersion();
75  shiftinfo.date = getDate();
76  shiftinfo.time = getTime();
77  buffer.simul.push_back(shiftinfo);
78  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
79 
80  bool can_found = buffer.pull(&JHead::can) != buffer.end();
81  bool fixedcan_found = buffer.pull(&JHead::fixedcan) != buffer.end();
82 
83  if (debug >= debug_t) {
84  if (can_found) {
85  NOTICE("can found" << endl);
86  }
87  if (fixedcan_found) {
88  NOTICE("fixedcan found" << endl);
89  }
90  }
91 
92  if (can_found and !(fixedcan_found)) {
93  buffer.fixedcan.xcenter = xshift;
94  buffer.fixedcan.ycenter = yshift;
95  buffer.fixedcan.zmin = buffer.can.zmin;
96  buffer.fixedcan.zmax = buffer.can.zmax;
97  buffer.fixedcan.radius = buffer.can.r;
98  buffer.erase(&JHead::can);
99  buffer.push(&JHead::fixedcan);
100  } else if (fixedcan_found and !(can_found)) {
101  buffer.fixedcan.xcenter = buffer.fixedcan.xcenter + xshift;
102  buffer.fixedcan.ycenter = buffer.fixedcan.ycenter + yshift;
103  } else if (!(can_found) and !(fixedcan_found)) {
104  FATAL("Neither can nor fixedcan is found" << endl);
105  } else {
106  FATAL("Both can and fixedcan are found" << endl);
107  }
108 
109  copy(buffer, header);
110  }
111  catch(const JException& error) {
112  FATAL(error);
113  }
114  outputFile.put(header);
115 
116 
117  while (inputFile.hasNext()) {
118 
119  Evt* evt = inputFile.next(); // input
120 
121  for (vector<Trk>::iterator track = evt->mc_trks.begin(); track != evt->mc_trks.end(); ++track) {
122  track->pos += center;
123  }
124 
125  outputFile.put(*evt);
126  }
127 
128  outputFile.close();
129 }
double zmin
Bottom [m].
Definition: JHead.hh:583
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
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:511
std::string program
program name
Definition: JHead.hh:489
Recording of objects on file according a format that follows from the file name extension.
double zmax
Top [m].
Definition: JHead.hh:624
std::vector< JAANET::simul > simul
Definition: JHead.hh:1482
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
double ycenter
y-center [m]
Definition: JHead.hh:622
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:1489
JAANET::can can
Definition: JHead.hh:1488
double xcenter
x-center [m]
Definition: JHead.hh:621
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:1290
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:1302
#define NOTICE(A)
Definition: JMessage.hh:64
std::string version
program version
Definition: JHead.hh:490
int debug
debug level
Definition: JSirene.cc:66
double zmin
Bottom [m].
Definition: JHead.hh:623
const char * getDate(const JDateAndTimeFormat option=ISO8601)
Get ASCII formatted date.
General purpose messaging.
Monte Carlo run header.
Definition: JHead.hh:1165
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:585
General purpose class for object reading from a list of file names.
std::string date
processing date
Definition: JHead.hh:491
Utility class to parse command line options.
double radius
Radius [m].
Definition: JHead.hh:625
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:492
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:584
const_iterator pull(T JHead::*pd) const
Pull given data member from Head.
Definition: JHead.hh:1265