Jpp  17.2.1-pre0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JFluxAtmosphericNeutrino.cc File Reference

Example program for printing the atmospheric neutrino fluxes in a given neutrino MC-file. More...

#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JLang/JException.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JAAnet/JEvtWeightFactorFunction.hh"
#include "JAAnet/JFlux.hh"
#include "JAAnet/JFluxAtmosphericNeutrino.hh"
#include "JSupport/JLimit.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JEvtWeightFileScannerSet.hh"
#include "JOscProb/JOscChannel.hh"
#include "JOscProb/JOscParameters.hh"
#include "JOscProb/JOscProbInterpolator.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program for printing the atmospheric neutrino fluxes in a given neutrino MC-file.

Author
bjung

Definition in file JFluxAtmosphericNeutrino.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 35 of file JFluxAtmosphericNeutrino.cc.

36 {
37  using namespace std;
38  using namespace JPP;
39 
40  JMultipleFileScanner_t inputFiles;
41  string oscProbTable;
43  int debug;
44 
45  try {
46 
47  JParser<> zap;
48 
49  zap['f'] = make_field(inputFiles);
50  zap['P'] = make_field(oscProbTable, "oscillation probability table file");
51  zap['@'] = make_field(parameters, "oscillation parameters") = JPARSER::initialised();
52  zap['d'] = make_field(debug) = 1;
53 
54  zap(argc, argv);
55  }
56  catch(const exception& error) {
57  FATAL(error.what() << endl);
58  }
59 
60 
61  // Create atmospheric neutrino flux function
62 
63  const JOscProbInterpolator<> interpolator(oscProbTable.c_str(), parameters);
64 
65  const JFluxAtmosphericNeutrino atmFlux(interpolator);
66 
67 
68  // Scan events
69 
70  JEvtWeightFileScannerSet<> scanners(inputFiles);
71 
72  for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
73 
74  if (scanner->simul.size() > 0) {
75  STATUS("Scanning " << scanner->simul[0].program << " files..." << endl);
76  }
77 
78  // Assign flux function
79 
80  const JHead& header = scanner->getHeader();
81 
82  const JFluxMultiParticle multiFlux(header, make_fluxFunction(atmFlux));
83 
84  scanner->setFlux(multiFlux);
85 
86 
87  // Print event-weights
88 
89  STATUS(LEFT (10) << "event ID" <<
90  RIGHT(15) << "E [GeV]" <<
91  RIGHT(15) << "costh" <<
92  RIGHT(10) << "flux " <<
93  LEFT (30) << "[GeV^-1 * m^-2 * sr^-1 * s^-1]" << endl);
94 
95  while (scanner->hasNext()) {
96 
97  const Evt* event = scanner->next();
98  const Trk& neutrino = get_neutrino(*event);
99 
100  const double E = neutrino.E;
101  const double costh = -neutrino.dir.z / neutrino.dir.len();
102  const double weight = scanner->getWeight(*event);
103 
104  STATUS(LEFT (10) << scanner->getCounter() << FILL(10,' ') << ' ' <<
105  FIXED ( 5, 3) << right << E << FILL(10,' ') << ' ' <<
106  FIXED ( 5, 3) << right << costh << FILL(10,' ') << ' ' <<
107  SCIENTIFIC(10, 3) << weight << '\r'); DEBUG(endl);
108  }
109  }
110 
111  return 0;
112 }
Utility class to parse command line options.
Definition: JParser.hh:1517
then usage E
Definition: JMuonPostfit.sh:35
double z
Definition: Vec.hh:14
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1202
#define STATUS(A)
Definition: JMessage.hh:63
Vec dir
track direction
Definition: Trk.hh:18
Data structure for single set of oscillation parameters.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
JEvtWeightFactorFunction< JFunction_t, JFlux > make_fluxFunction(const JFunction_t &flux)
Auxiliary method for creating an interface to a flux function.
double E
Energy [GeV] (either MC truth or reconstructed)
Definition: Trk.hh:20
double len() const
Get length.
Definition: Vec.hh:145
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
Implementation of event-weight factor for multiple particle types.
Implementation of atmospheric neutrino flux using official KM3NeT atmospheric flux function...
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
Monte Carlo run header.
Definition: JHead.hh:1167
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary base class for list of file names.
std::vector< filescanner_type >::iterator iterator
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
Template definition of a multi-dimensional oscillation probability interpolation table.
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
std::vector< double > weight
Definition: JAlgorithm.hh:417
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62