Jpp  17.0.0-rc.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, "8D 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 JOscProbTable6D<> g6(oscProbTable.c_str());
64  const JOscProbTable2D<> g2(g6, parameters);
65 
66  const JOscProbInterpolator2D<> interpolator(&g2);
67 
68  const JFluxAtmosphericNeutrino atmFlux(interpolator);
69 
70 
71  // Scan events
72 
73  JEvtWeightFileScannerSet<> scanners(inputFiles);
74 
75  for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
76 
77  if (scanner->simul.size() > 0) {
78  STATUS("Scanning " << scanner->simul[0].program << " files..." << endl);
79  }
80 
81  // Assign flux function
82 
83  const JHead& header = scanner->getHeader();
84 
85  const JFluxMultiParticle multiFlux(header, make_fluxFunction(atmFlux));
86 
87  scanner->setFlux(multiFlux);
88 
89 
90  // Print event-weights
91 
92  STATUS(LEFT (10) << "event ID" <<
93  RIGHT(15) << "E [GeV]" <<
94  RIGHT(15) << "costh" <<
95  RIGHT(10) << "flux " <<
96  LEFT (30) << "[GeV^-1 * m^-2 * sr^-1 * s^-1]" << endl);
97 
98  while (scanner->hasNext()) {
99 
100  const Evt* event = scanner->next();
101  const Trk& neutrino = get_neutrino(*event);
102 
103  const double E = neutrino.E;
104  const double costh = -neutrino.dir.z / neutrino.dir.len();
105  const double weight = scanner->getWeight(*event);
106 
107  STATUS(LEFT (10) << scanner->getCounter() << FILL(10,' ') << ' ' <<
108  FIXED ( 5, 3) << right << E << FILL(10,' ') << ' ' <<
109  FIXED ( 5, 3) << right << costh << FILL(10,' ') << ' ' <<
110  SCIENTIFIC(10, 3) << weight << '\r'); DEBUG(endl);
111  }
112  }
113 
114  return 0;
115 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Exceptions.
int main(int argc, char *argv[])
Definition: Main.cc:15
then usage E
Definition: JMuonPostfit.sh:35
Explicit template specialization for 6D interpolation table in:
double z
Definition: Vec.hh:14
Auxiliary class for interpolating an oscillation probability table in 8 dimensions in terms of: ...
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1198
#define STATUS(A)
Definition: JMessage.hh:63
Vec dir
track direction
Definition: Trk.hh:18
Data structure for 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:66
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:1961
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...
int debug
debug level
Definition: JSirene.cc:66
General purpose messaging.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
Monte Carlo run header.
Definition: JHead.hh:1165
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Explicit template specialization for 2D interpolation table in:
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
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19
std::vector< double > weight
Definition: JAlgorithm.hh:417
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62