Jpp  16.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPlotOscProb.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4 
5 #include "JLang/JVectorize.hh"
6 
7 #include "Jeep/JPrint.hh"
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 
11 #include "JOscProb/JOscChannel.hh"
14 
16 
17 #include "TFile.h"
18 #include "TH2D.h"
19 
20 
21 /**
22  * \file
23  * Example program to plot oscillation probabilties interpolated in energy and zenith-angle.
24  *
25  * \author bjung
26  */
27 int main(int argc, char **argv)
28 {
29  using namespace std;
30  using namespace JPP;
31 
32  typedef JAbstractHistogram<Double_t> JHistogram_t;
33 
34  string inputFile;
35  string outputFile;
36  JOscParameters parameters;
37  JHistogram_t X;
38  JHistogram_t Y;
39  JOscChannel channel;
40  int debug;
41 
42  try {
43 
44  JParser<> zap;
45 
46  zap['f'] = make_field(inputFile, "8D oscillation probability table file");
47  zap['o'] = make_field(outputFile, "output file");
48  zap['x'] = make_field(X, "histogram binning in log10(E)");
49  zap['y'] = make_field(Y, "histogram binning in cos(theta)");
50  zap['@'] = make_field(parameters, "oscillation parameters") = JPARSER::initialised();
51  zap['#'] = make_field(channel, "Oscillation channel") = JOscChannel(JOscChannel::MUON, JOscChannel::MUON, JOscChannel::PARTICLE);
52  zap['d'] = make_field(debug) = 2;
53 
54  zap(argc, argv);
55  }
56  catch (const exception& error) {
57  FATAL(error.what() << endl);
58  }
59 
60 
61  TH2D h0("h0", "; log_{10}(E); cos(#theta)",
62  X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
63  Y.getNumberOfBins(), Y.getLowerLimit(), Y.getUpperLimit());
64 
65  const JOscProbTable6D<> g6(inputFile.c_str());
66  const JOscProbTable2D<> g2(g6, parameters);
67 
68  const JOscProbInterpolator2D<> interpolator(&g2);
69 
70  NOTICE(RIGHT(15) << "Energy [GeV]" <<
71  RIGHT(15) << "cos(theta)" <<
72  RIGHT(15) << "P" << endl);
73 
74  for (Int_t ix = 1; ix <= h0.GetNbinsX(); ++ix) {
75  for (Int_t iy = 1; iy <= h0.GetNbinsY(); ++iy) {
76 
77  const Double_t log10E = h0.GetXaxis()->GetBinCenter(ix);
78  const Double_t costh = h0.GetYaxis()->GetBinCenter(iy);
79  const Double_t P = interpolator(channel, log10E, costh);
80 
81  NOTICE(FIXED(15,3) << pow(10, log10E) <<
82  FIXED(15,3) << costh <<
83  FIXED(15,3) << P << '\r'); DEBUG(endl);
84 
85  h0.SetBinContent(ix, iy, P);
86  }
87  }
88 
89  TFile out(outputFile.c_str(), "recreate");
90 
91  h0.Write();
92 
93  out.Write();
94  out.Close();
95 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
*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
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
then break fi done getCenter read X Y Z let X
int debug
debug level
Definition: JSirene.cc:63
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62