Jpp  18.0.1-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JAtmosphericNeutrinoFlux.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/JAtmosphericNeutrinoFlux.hh"
#include "JAAnet/JFlux.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 JAtmosphericNeutrinoFlux.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 35 of file JAtmosphericNeutrinoFlux.cc.

36 {
37  using namespace std;
38  using namespace JPP;
39 
41 
42 
43  JMultipleFileScanner_t inputFiles;
44  string oscProbTable;
46  int debug;
47 
48  try {
49 
50  JParser<> zap;
51 
52  zap['f'] = make_field(inputFiles);
53  zap['P'] = make_field(oscProbTable, "oscillation probability table file");
54  zap['@'] = make_field(parameters, "oscillation parameters") = JPARSER::initialised();
55  zap['d'] = make_field(debug) = 1;
56 
57  zap(argc, argv);
58  }
59  catch(const exception& error) {
60  FATAL(error.what() << endl);
61  }
62 
63 
64  // Create atmospheric neutrino flux function
65 
66  const JFluxFunction_t fluxFunction = make_atmosphericNeutrinoFluxFunction(oscProbTable.c_str(), parameters);
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, fluxFunction);
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:1514
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
double z
Definition: Vec.hh:14
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1256
#define STATUS(A)
Definition: JMessage.hh:63
Vec dir
track direction
Definition: Trk.hh:18
Implementation of event-weight factor interface.
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
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:1989
Implementation of event-weight factor for multiple particle types.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
Monte Carlo run header.
Definition: JHead.hh:1221
#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
JEvtWeightFactorFunction< JAtmosphericNeutrinoFlux, JFlux > make_atmosphericNeutrinoFluxFunction(const string &oscProbTableFile, const JOscParameters &oscParameters)
Auxiliary method for creating an interface to an atmospheric neutrino flux function using an oscillat...
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62