Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPlotOscProbInterpolation6D.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"
15 
16 #include "TFile.h"
17 #include "TH2D.h"
18 
19 
20 /**
21  * \file
22  * Example program to plot oscillogram from 8D oscillations probability table\n
23  * after 6D interpolation in oscillation parameters.
24  *
25  * \author bjung
26  */
27 int main(int argc, char **argv)
28 {
29  using namespace std;
30  using namespace JPP;
31 
32  string inputFile;
33  string outputFile;
34  JOscParameters parameters;
37  JOscChannel channel;
38  int debug;
39 
40  try {
41 
42  JParser<> zap;
43 
44  zap['f'] = make_field(inputFile, "8D oscillation probability table file");
45  zap['o'] = make_field(outputFile, "output file");
46  zap['x'] = make_field(X, "histogram binning in energy [GeV]");
47  zap['y'] = make_field(Y, "histogram binning in cos(theta)");
48  zap['@'] = make_field(parameters, "oscillation parameters") = JPARSER::initialised();
49  zap['#'] = make_field(channel, "Oscillation channel") = JOscChannel(JOscChannel::MUON, JOscChannel::MUON, JOscChannel::ANTIPARTICLE);
50  zap['d'] = make_field(debug) = 2;
51 
52  zap(argc, argv);
53  }
54  catch (const exception& error) {
55  FATAL(error.what() << endl);
56  }
57 
58 
59  TH2D h0("h0", "; energy [GeV]; cos(#theta)", X.size()-1, &X[0], Y.size()-1, &Y[0]);
60 
61  const JOscProbTable6D<> g6(inputFile.c_str());
62  const JOscProbTable2D<> g2(g6, parameters);
63 
64  const JOscProbInterpolator2D<> interpolator(&g2);
65 
66  NOTICE(RIGHT(15) << "energy [GeV]" <<
67  RIGHT(15) << "cos(theta)" <<
68  RIGHT(15) << "P" << endl);
69 
70  for (Int_t ix = 1; ix <= h0.GetNbinsX(); ++ix) {
71  for (Int_t iy = 1; iy <= h0.GetNbinsY(); ++iy) {
72 
73  const Double_t energy = h0.GetXaxis()->GetBinCenter(ix);
74  const Double_t costh = h0.GetYaxis()->GetBinCenter(iy);
75 
76  const Double_t prob = interpolator(channel, energy, costh);
77 
78  NOTICE(FIXED(15,3) << energy <<
79  FIXED(15,3) << costh <<
80  FIXED(15,3) << prob << '\r'); DEBUG(endl);
81 
82  h0.SetBinContent(ix, iy, prob);
83  }
84  }
85 
86  TFile out(outputFile.c_str(), "recreate");
87 
88  h0.Write();
89 
90  out.Write();
91  out.Close();
92 }
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
int debug
debug level
Definition: JSirene.cc:66
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
then for APP in event gandalf start energy
Definition: JMuonMCEvt.sh:44
Utility class to parse command line options.
no fit printf nominal n $STRING awk v X
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62