Jpp  17.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFluxAtmosphericNeutrino.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4 #include <set>
5 
8 
9 #include "JLang/JException.hh"
10 
11 #include "JAAnet/JAAnetToolkit.hh"
13 #include "JAAnet/JFlux.hh"
15 
16 #include "JSupport/JLimit.hh"
19 
20 #include "JOscProb/JOscChannel.hh"
23 
24 #include "Jeep/JPrint.hh"
25 #include "Jeep/JParser.hh"
26 #include "Jeep/JMessage.hh"
27 
28 
29 /**
30  * \file
31  * Example program for printing the atmospheric neutrino fluxes in a given neutrino MC-file.
32  *
33  * \author bjung
34  */
35 int main(int argc, char **argv)
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
Exceptions.
int main(int argc, char *argv[])
Definition: Main.cc:15
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
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
Implementation of event-weight factor for multiple particle types.
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
Implementation of atmospheric neutrino flux using official KM3NeT atmospheric flux function...
General purpose messaging.
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
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Auxiliary base class for list of file names.
std::vector< filescanner_type >::iterator iterator
Utility class to parse command line options.
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
Auxiliaries for defining the range of iterations of objects.
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
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62