Jpp 21.0.1
the software that should make you happy
Loading...
Searching...
No Matches
JPlotOscillogram.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <string>
4
5#include "TFile.h"
6#include "TH2D.h"
7
8#include "Jeep/JPrint.hh"
9#include "Jeep/JParser.hh"
10#include "Jeep/JMessage.hh"
11
13
19
20
21/**
22 * \file
23 * Example program to plot oscillogram.
24 *
25 * \author bjung
26 */
27int main(int argc, char **argv)
28{
29 using namespace std;
30 using namespace JPP;
31
32 typedef JAbstractHistogram<double> JAbstractHistogram_t;
33
34
35 string inputFile;
36 string outputFile;
37
38 string Xtype;
39 JAbstractHistogram_t Xbinning;
40
41 string Ytype;
42 JAbstractHistogram_t Ybinning;
43
44 JOscParameters<double> parameters;
45 JOscChannel channel;
46
47 int debug;
48
49 try {
50
51 JParser<> zap;
52
53 zap['f'] = make_field(inputFile, "oscillation probability table file");
54 zap['o'] = make_field(outputFile, "output file");
55 zap['X'] = make_field(Xtype, "abscissa type") =
56 JOscVars::energy(),
57 JOscVars::log10E(),
58 JOscVars::LoE();
59 zap['x'] = make_field(Xbinning, "abscissa binning")
60 = make_histogram(100, 1.0, 100.0);
61 zap['Y'] = make_field(Ytype, "ordinate type") =
62 JOscVars::costh(),
63 JOscVars::sinth(),
64 JOscVars::L();
65 zap['y'] = make_field(Ybinning, "ordinate binning")
66 = make_histogram(200, -1.0, 1.0);
67 zap['@'] = make_field(parameters, "oscillation parameters")
69 zap['#'] = make_field(channel, "oscillation channel")
70 = JOscChannel(JFlavour_t::MUON, JFlavour_t::MUON, JChargeParity_t::PARTICLE);
71 zap['d'] = make_field(debug)
72 = 2;
73
74 zap(argc, argv);
75 }
76 catch (const exception& error) {
77 FATAL(error.what() << endl);
78 }
79
80
81 JOscProbHelper::pointer_type p = make_shared<JOscProbInterpolator<> >(inputFile.c_str(), parameters);
82
83 TH2D h0("h0", NULL,
84 Xbinning.getNumberOfBins(), Xbinning.getLowerLimit(), Xbinning.getUpperLimit(),
85 Ybinning.getNumberOfBins(), Ybinning.getLowerLimit(), Ybinning.getUpperLimit());
86
87 const JOscillogram oscillogram(Xtype, Xbinning,
88 Ytype, Ybinning,
89 channel, p);
90
91 NOTICE(RIGHT(15) << Xtype << RIGHT(15) << Ytype << RIGHT(15) << "P" << endl);
92
93 for (int ix = 1; ix <= h0.GetXaxis()->GetNbins(); ++ix) {
94 for (int iy = 1; iy <= h0.GetYaxis()->GetNbins(); ++iy) {
95
96 const double x = h0.GetXaxis()->GetBinCenter(ix);
97 const double y = h0.GetYaxis()->GetBinCenter(iy);
98
99 const double P = oscillogram.getP(ix-1, iy-1);
100
101 NOTICE(FIXED(15,3) << x << FIXED(15,3) << y << FIXED(15,3) << P << '\r'); DEBUG(endl);
102
103 h0.SetBinContent(ix, iy, P);
104 }
105 }
106
107 TFile out(outputFile.c_str(), "recreate");
108
109 h0.Write();
110
111 out.Write();
112 out.Close();
113}
string outputFile
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2107
I/O formatting auxiliaries.
Data structure for single set of oscillation parameters.
Utility class to parse command line options.
Definition JParser.hh:1664
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Neutrino oscillation channel.
std::shared_ptr< JOscProbInterface > pointer_type
Auxiliary class for creating oscillograms.
double getP(const int i, const int j) const
Get oscillation probability for given bin indices.
Simple data structure for histogram binning.
Auxiliary data structure for alignment of data.
Definition JManip.hh:298