#include #include #include #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 "JSupport/JMeta.hh" #include "JSystem/JDateAndTime.hh" #include "JROOT/JROOTClassSelector.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Auxiliary program to shift the generated tracks according a given offset. * * \author vkulikovskiy */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JMultipleFileScanner inputFile; JFileRecorder ::typelist> outputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); double xshift; double yshift; double zshift; int debug; try { JParser<> zap("Auxiliary program to shift the generated tracks according a given offset."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['x'] = make_field(xshift) = 0.0; zap['y'] = make_field(yshift) = 0.0; zap['z'] = make_field(zshift) = 0.0; zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } outputFile.open(); outputFile.put(JMeta(argc,argv)); const Vec offset(xshift,yshift,zshift); NOTICE("Offset applied to true tracks is: " << offset << endl); Head header; try { header = getHeader(inputFile); JHead buffer(header); JAANET::simul info; info.program = argv[0]; info.version = getGITVersion(); info.date = getDate(); info.time = getTime(); buffer.simul.push_back(info); buffer.push(&JHead::simul); bool can_found = buffer.is_valid(&JHead::can); bool fixedcan_found = buffer.is_valid(&JHead::fixedcan); if (can_found) { NOTICE("can found" << endl); } if (fixedcan_found) { NOTICE("fixedcan found" << endl); } if (can_found && !fixedcan_found) { buffer.fixedcan.xcenter = xshift; buffer.fixedcan.ycenter = yshift; buffer.fixedcan.zmin = buffer.can.zmin + zshift; buffer.fixedcan.zmax = buffer.can.zmax + zshift; buffer.fixedcan.radius = buffer.can.r; buffer.push(&JHead::fixedcan); buffer.erase(&JHead::can); } else if (fixedcan_found && !can_found) { buffer.fixedcan.xcenter = buffer.fixedcan.xcenter + xshift; buffer.fixedcan.ycenter = buffer.fixedcan.ycenter + yshift; buffer.fixedcan.zmin = buffer.fixedcan.zmin + zshift; buffer.fixedcan.zmax = buffer.fixedcan.zmax + zshift; } else if (!can_found && !fixedcan_found) { FATAL("Neither can nor fixedcan is found" << endl); } else { FATAL("Both can and fixedcan are found" << endl); } copy(buffer, header); } catch(const JException& error) { FATAL(error << endl); } outputFile.put(header); while (inputFile.hasNext()) { Evt* evt = inputFile.next(); // input for (vector::iterator track = evt->mc_trks.begin(); track != evt->mc_trks.end(); ++track) { track->pos += offset; } outputFile.put(*evt); } outputFile.close(); }