#include #include #include #include "km3net-dataformat/definitions/applications.hh" #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/Evt.hh" #include "JMath/JRandom.hh" #include "JAAnet/JAAnetTestkit.hh" #include "JAAnet/JParticleTypes.hh" #include "JSupport/JSingleFileScanner.hh" #include "JSupport/JFileRecorder.hh" #include "JSupport/JSupport.hh" #include "JSupport/JMonteCarloFileSupportkit.hh" #include "Jeep/JeepToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" #include "TRandom3.h" /** * \file * * Auxiliary program to create input offline files for testing. * \author bjjung */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JFileRecorder outputFile; string program; int primary; Long64_t numberOfEvents; UInt_t seed; int debug; try { JParser<> zap("Auxiliary program to create input offline files for testing."); zap['o'] = make_field(outputFile) = "evt.root"; zap['n'] = make_field(numberOfEvents) = 10; zap['P'] = make_field(program) = APPLICATION_GSEAGEN, APPLICATION_KM3BUU, APPLICATION_MUPAGE, APPLICATION_CORSIKA; zap['p'] = make_field(primary) = TRACK_TYPE_ANTINUE, TRACK_TYPE_ANTINUMU, TRACK_TYPE_ANTIMUON, TRACK_TYPE_ANTINUTAU, TRACK_TYPE_NUE, TRACK_TYPE_MUON, TRACK_TYPE_NUMU, TRACK_TYPE_NUTAU; zap['S'] = make_field(seed) = 0; zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } if ( ((program == APPLICATION_MUPAGE || program == APPLICATION_CORSIKA) && abs(primary) != TRACK_TYPE_MUON) || ( program == APPLICATION_GSEAGEN && (abs(primary) != TRACK_TYPE_NUE && abs(primary) != TRACK_TYPE_NUMU && abs(primary) != TRACK_TYPE_NUTAU) ) ) { FATAL("Incompatible program (" << program << ") and primary (" << primary << ")"); } gRandom->SetSeed(seed); if (debug >= JEEP::debug_t) { setLongprint(cout); } use_root = getFilenameExtension(outputFile.getFilename()) == ".root"; outputFile.open(); if (!outputFile.is_open()) { FATAL("Error opening file " << outputFile << endl); } Head head; head["start_run"] = "1 1"; head["simul"] = MAKE_STRING(program << " v1.0.0 230328 1529"); head["primary"] = MAKE_STRING(primary); outputFile.put(head); // create data vector buffer; for (int n = 1; n <= numberOfEvents; ++n) { Evt event = getRandom(); for (vector::iterator trk = event.mc_trks.begin(); trk != event.mc_trks.end(); ++trk) { trk->type = primary; } buffer.push_back(event); outputFile.put(*buffer.rbegin()); } outputFile.close(); ASSERT((Long64_t) buffer.size() == numberOfEvents); return 0; }