Jpp  master_rocky
the software that should make you happy
JHondaFluxInterpolator.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4 
7 
8 #include "JTools/JGrid.hh"
9 #include "JTools/JPolint.hh"
10 
11 #include "JAAnet/JParticleTypes.hh"
12 #include "JAAnet/JAAnetToolkit.hh"
15 
16 #include "JSupport/JSupport.hh"
19 
23 
24 #include "Jeep/JPrint.hh"
25 #include "Jeep/JParser.hh"
26 #include "Jeep/JMessage.hh"
27 
28 #include "JROOT/JManager.hh"
29 
30 #include "TFile.h"
31 #include "TH2D.h"
32 
33 
34 /**
35  * \file
36  * Example program for plotting the atmospheric neutrino fluxes given by an azimuth-averaged Honda flux table\n
37  * and comparing them with the atmospheric neutrino flux from the KM3NeT flux library.
38  *
39  * \author bjjung
40  */
41 int main(int argc, char **argv)
42 {
43  using namespace std;
44  using namespace JPP;
45 
46  typedef JGrid<double> JGrid_t;
47 
48 
49  JMultipleFileScanner_t inputFiles;
50  string outputFile;
51  string HondaTable;
52  string oscProbTable;
53  JOscParameters<double> oscParameters;
54  JGrid_t log10Egrid;
55  JGrid_t coszGrid;
56  int debug;
57 
58  try {
59 
60  JParser<> zap;
61 
62  zap['f'] = make_field(inputFiles);
63  zap['T'] = make_field(HondaTable);
64  zap['o'] = make_field(outputFile) = "honda.root";
65  zap['P'] = make_field(oscProbTable) = JPARSER::initialised();
66  zap['@'] = make_field(oscParameters) = JPARSER::initialised();
67  zap['X'] = make_field(log10Egrid) = make_grid(100, -1.0, 4.0);
68  zap['C'] = make_field(coszGrid) = make_grid(200, -1.0, 1.0);
69  zap['d'] = make_field(debug) = 1;
70 
71  zap(argc, argv);
72  }
73  catch(const exception& error) {
74  FATAL(error.what() << endl);
75  }
76 
77 
78  // Create atmospheric neutrino flux function
79 
80  JDiffuseFluxHelper flux1;
81  JDiffuseFluxHelper flux2;
82 
83  const JFluxAtmospheric atmFlux;
84  const JHondaFluxInterpolator2D<> interpolator(HondaTable.c_str());
85 
86  if (!oscProbTable.empty()) {
87 
88  const JOscProbInterpolator<> oscProb(oscProbTable.c_str(), oscParameters);
89 
90  const JOscFlux oscFlux1(atmFlux, oscProb);
91  const JOscFlux oscFlux2(interpolator, oscProb);
92 
93  flux1.configure(oscFlux1);
94  flux2.configure(oscFlux2);
95 
96  } else {
97 
98  flux1.configure(atmFlux);
99  flux2.configure(interpolator);
100  }
101 
102  const vector<int> nuTypes {
107  };
108 
109  JManager<int, TH2D> h0(new TH2D("h0[%]", NULL,
110  log10Egrid.getSize(), log10Egrid.getXmin(), log10Egrid.getXmax(),
111  coszGrid .getSize(), coszGrid .getXmin(), coszGrid .getXmax()));
112 
113  JManager<int, TH2D> h1(new TH2D("h1[%]", NULL,
114  log10Egrid.getSize(), log10Egrid.getXmin(), log10Egrid.getXmax(),
115  coszGrid .getSize(), coszGrid .getXmin(), coszGrid .getXmax()));
116 
117  DEBUG(LEFT(15) << "E [GeV]" << RIGHT(10) << "cosz" << RIGHT(25) << "flux1" << RIGHT(52) << "flux2 [GeV^-1 * m^-2 * sr^-1 * s^-1]" << endl);
118 
119  for (vector<int>::const_iterator type = nuTypes.cbegin(); type != nuTypes.cend(); ++type) {
120 
121  for (int i = 0; i < log10Egrid.getSize(); ++i) {
122 
123  const double X = log10Egrid.getX(i);
124 
125  for (int j = 0; j < coszGrid.getSize(); ++j) {
126 
127  const double cosz = coszGrid.getX(j);
128 
129  const double F0 = flux1(*type, X, cosz);
130  const double F1 = flux2(*type, X, cosz);
131 
132  DEBUG(SCIENTIFIC(15,3) << pow(10.0,X) <<
133  FIXED (10,3) << cosz <<
134  SCIENTIFIC(25,3) << F0 <<
135  SCIENTIFIC(25,3) << F1 << endl);
136 
137  ASSERT(isfinite(F1));
138 
139  h0[*type]->SetBinContent(i+1, j+1, F0);
140  h1[*type]->SetBinContent(i+1, j+1, F1);
141  }
142  }
143  }
144 
145  TFile out(outputFile.c_str(), "recreate");
146 
147  out << h0 << h1;
148 
149  out.Write();
150  out.Close();
151 
152  return 0;
153 }
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
string outputFile
int main(int argc, char **argv)
Dynamic ROOT object management.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Definition of particle types.
I/O formatting auxiliaries.
ROOT TTree parameter settings of various packages.
Data structure for single set of oscillation parameters.
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
Definition: JParser.hh:1698
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Definition: JManager.hh:47
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition: JManager.hh:304
const JPolynome F1
Integral.
Definition: JQuadrature.cc:34
@ TRACK_TYPE_ANTINUMU
@ TRACK_TYPE_ANTINUE
@ TRACK_TYPE_NUE
@ TRACK_TYPE_NUMU
@ LEFT
Definition: JTwosome.hh:18
@ RIGHT
Definition: JTwosome.hh:18
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:209
int j
Definition: JPolint.hh:792
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Helper class for diffuse flux factor.
Specialisation of event-weight factor interface for atmospheric neutrino flux.
void configure(const pointer_type &p)
Configure event-weight factor.
Implementation of oscillated neutrino flux.
Definition: JOscFlux.hh:44
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:68
Auxiliary base class for list of file names.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:488