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
JAtmosphericNeutrinoFlux.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"
14 #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 
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
Exceptions.
int main(int argc, char *argv[])
Definition: Main.cc:15
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
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Implementation of event-weight factor for multiple particle types.
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
General purpose messaging.
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
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
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