Jpp 21.0.1
the software that should make you happy
Loading...
Searching...
No Matches
JPlotOscillogram.cc File Reference

Example program to plot oscillogram. More...

#include <iostream>
#include <iomanip>
#include <string>
#include "TFile.h"
#include "TH2D.h"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JTools/JAbstractHistogram.hh"
#include "JOscProb/JOscChannel.hh"
#include "JOscProb/JOscParameters.hh"
#include "JOscProb/JOscillogram.hh"
#include "JOscProb/JOscProbToolkit.hh"
#include "JOscProb/JOscProbInterpolator.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to plot oscillogram.

Author
bjung

Definition in file JPlotOscillogram.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 27 of file JPlotOscillogram.cc.

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
#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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2107
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).
JAbstractHistogram< JAbscissa_t > make_histogram(const int nx, const JAbscissa_t xmin, const JAbscissa_t xmax)
Helper method for JAbstractHistogram.
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.
Simple data structure for histogram binning.
Auxiliary data structure for alignment of data.
Definition JManip.hh:298