#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 "JSystem/JDateAndTime.hh" #include "JROOT/JROOTClassSelector.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Auxiliary program to shift the tracks to a given vector (horizontal shifts only!). * * \author vkulikovskiy */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JMultipleFileScanner inputFile; JFileRecorder outputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); int debug; double xshift; double yshift; try { JParser<> zap("Auxiliary program to convert data formats."); 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['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } outputFile.open(); Vec center(xshift,yshift,0); if (debug >= 3) NOTICE("Offset applied to true tracks is: " << center << endl); Head header; try { header = getHeader(inputFile); JHead buffer(header); JAANET::simul shiftinfo; shiftinfo.program = "JShift"; shiftinfo.version = getGITVersion(); shiftinfo.date = getDate(); shiftinfo.time = getTime(); buffer.simul.push_back(shiftinfo); 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 bool can_found = buffer.is_valid(&JHead::can); bool fixedcan_found = buffer.is_valid(&JHead::fixedcan); if (debug >= debug_t) { if (can_found) { NOTICE("can found" << endl); } if (fixedcan_found) { NOTICE("fixedcan found" << endl); } } if (can_found and !(fixedcan_found)) { buffer.fixedcan.xcenter = xshift; buffer.fixedcan.ycenter = yshift; buffer.fixedcan.zmin = buffer.can.zmin; buffer.fixedcan.zmax = buffer.can.zmax; buffer.fixedcan.radius = buffer.can.r; buffer.erase(&JHead::can); buffer.push(&JHead::fixedcan); } else if (fixedcan_found and !(can_found)) { buffer.fixedcan.xcenter = buffer.fixedcan.xcenter + xshift; buffer.fixedcan.ycenter = buffer.fixedcan.ycenter + yshift; } else if (!(can_found) and !(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); } 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 += center; } outputFile.put(*evt); } outputFile.close(); }