#include #include #include #include #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/Evt.hh" #include "JLang/JException.hh" #include "JLang/JVectorize.hh" #include "JAAnet/JAAnetToolkit.hh" #include "JAAnet/JEvtWeightToolkit.hh" #include "JSupport/JLimit.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JEvtWeightFileScannerSet.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" #include "Jeep/JProperties.hh" namespace { /** * Set flux of given event to zero. * * \param evt event * \return zero [GeV * m^-2 * sr^-1 * s^-1] */ inline double zeroFlux(const Evt& evt) { return 0.0; } } /** * \file * Example program for scanning event-weights of Monte Carlo files\n * containing a given set of primaries. * * The list of possible options for the flux includes: *
 *    -@ zero         \
 *    -@ flat         \  \
 *    -@ powerlaw     \  \  \
 *    -@ atmospheric  \
 * 
* * \author bjung */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JMultipleFileScanner_t inputFiles; vector zeroFluxes; JFluxMap fluxMap; int debug; try { JParser<> zap; zap['f'] = make_field(inputFiles); zap['@'] = make_field(fluxMap) = JPARSER::initialised(); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } // Set event weighter JEvtWeightFileScannerSet<> scanners(inputFiles); if (scanners.setFlux(fluxMap) == 0) { WARNING("No file found containing all given primaries; Flux function not set." << endl); } // Scan events for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) { if (scanner->simul.size() > 0) { STATUS("Scanning " << scanner->simul[0].program << " files..." << endl); } STATUS(LEFT(15) << "event" << RIGHT(15) << "weight" << endl); while (scanner->hasNext()) { const Evt* event = scanner->next(); const double weight = scanner->getWeight(*event); STATUS(LEFT (15) << scanner->getCounter() << SCIENTIFIC(15, 3) << weight << '\r'); DEBUG(endl); } } return 0; }