Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JPlotEvtWeightFactorMeffRatio.cc File Reference

Example program for plotting effective mass ratios. More...

#include <iostream>
#include <string>
#include "TH1.h"
#include "TFile.h"
#include "TGraph.h"
#include "TGraph2D.h"
#include "TMultiGraph.h"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "Jeep/JProperties.hh"
#include "JAAnet/JEvtWeightFactorMeffRatio.hh"
#include "JSirene/JVisibleEnergyToolkit.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program for plotting effective mass ratios.

Author
bjjung

Definition in file JPlotEvtWeightFactorMeffRatio.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 26 of file JPlotEvtWeightFactorMeffRatio.cc.

27{
28 using namespace std;
29 using namespace JPP;
30
31 typedef double (JEvtWeightFactorMeffRatio::*pFunction1D)(const double) const;
32 typedef double (JEvtWeightFactorMeffRatio::*pFunction2D)(const double,
33 const double) const;
34
35
36 string outputFile;
37
39
40 int debug;
41
42 try {
43
44 JParser<> zap;
45
46 zap['o'] = make_field(outputFile);
47 zap['@'] = make_field(factor) = JPARSER::initialised();
48 zap['d'] = make_field(debug) = 1;
49
50 zap(argc, argv);
51 }
52 catch(const exception& error) {
53 FATAL(error.what() << endl);
54 }
55
56
57 TFile out(outputFile.c_str(), "recreate");
58
59 const JProperties properties = factor.getProperties();
60
61 const bool logE = properties.getValue<bool>("logE");
62 const int option = properties.getValue<int> ("option");
63
64 const TH1& hMeff = factor.getHistogram();
65
66 const int Nbins = hMeff.GetNbinsX();
67
68 if (option != (int) JEvtWeightFactorMeffRatio::EVIS_LEADING_LEPTON_CONTR &&
69 option != (int) JEvtWeightFactorMeffRatio::EVIS_HADRONIC_CONTR) {
70
71 pFunction1D mfp;
72
73 switch (option) {
74 case (int) JEvtWeightFactorMeffRatio::ENERGY_INITIAL_STATE :
75 mfp = &JEvtWeightFactorMeffRatio::getMeffRatio1;
76 break;
77 case (int) JEvtWeightFactorMeffRatio::ENERGY_NEUTRINO:
78 mfp = &JEvtWeightFactorMeffRatio::getMeffRatio2;
79 break;
80 case (int) JEvtWeightFactorMeffRatio::EVIS:
81 mfp = &JEvtWeightFactorMeffRatio::getMeffRatio3;
82 break;
83 default:
84 THROW(JValueOutOfRange, "JEvtWeightFactorRatio::configure(): Invalid 1D option " << option);
85 }
86
87 TGraph g(Nbins);
88 g.SetName(hMeff.GetName());
89
90 for (Int_t i = 0; i < Nbins; ++i) {
91
92 const double x = hMeff.GetBinCenter(i+1);
93 const double y = (factor.*mfp)(logE ? pow(10.0, x) : x);
94
95 if (isfinite(y)) {
96 g.SetPoint(i, x, y);
97 } else {
98 WARNING("Meff ratio not finite for x = " << SCIENTIFIC(10,3) << x << endl);
99 }
100 }
101
102 g.Write();
103
104 } else {
105
106 pFunction2D mfp;
107
108 switch (option) {
109 case (int) JEvtWeightFactorMeffRatio::EVIS_LEADING_LEPTON_CONTR:
110 mfp = &JEvtWeightFactorMeffRatio::getMeffRatio4;
111 break;
112 case (int) JEvtWeightFactorMeffRatio::EVIS_HADRONIC_CONTR:
113 mfp = &JEvtWeightFactorMeffRatio::getMeffRatio5;
114 break;
115 default:
116 THROW(JValueOutOfRange, "JEvtWeightFactorRatio::configure(): Invalid 2D option " << option);
117 }
118
119 const Int_t N = Nbins * Nbins * (Nbins + 1) / 2;
120
121 TGraph2D g(N);
122 g.SetName(hMeff.GetName());
123
124 Int_t k = 0;
125
126 for (Int_t i = 0; i < Nbins; ++i) {
127
128 const double x = hMeff.GetBinCenter(i+1);
129
130 for (Int_t j = 0; j < i; ++j, ++k) {
131
132 const double y = hMeff.GetBinCenter(j+1);
133 const double z = (logE ?
134 (factor.*mfp)(pow(10.0, x), pow(10.0, y)) :
135 (factor.*mfp)(x, y));
136
137 g.SetPoint(k, x, y, z);
138 }
139 }
140
141 g.Write();
142 }
143
144 out.Write();
145 out.Close();
146
147 return 0;
148}
string outputFile
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define WARNING(A)
Definition JMessage.hh:65
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse parameter values.
const T & getValue(const std::string &key) const
Get value.
Exception for accessing a value in a collection that is outside of its range.
Utility class to parse command line options.
Definition JParser.hh:1698
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).
int j
Definition JPolint.hh:801
Implementation of reweighting factor for effective mass ratios.
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
const TH1 & getHistogram() const
Retrieve effective mass histogram.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488