Jpp 19.3.0-rc.5
the software that should make you happy
Loading...
Searching...
No Matches
examples/JReconstruction/JEnergyCorrection.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
5#include "TROOT.h"
6#include "TFile.h"
7#include "TH1D.h"
8
11#include "JROOT/JManager.hh"
12#include "JTools/JRange.hh"
13#include "JLang/JManip.hh"
14
15#include "Jeep/JeepToolkit.hh"
16#include "Jeep/JParser.hh"
17#include "Jeep/JMessage.hh"
18
19
20/**
21 * \file
22 *
23 * Example program to histogram energy corrections.
24 * \author mdejong
25 */
26int main(int argc, char **argv)
27{
28 using namespace std;
29 using namespace JPP;
30
31 typedef JRange<double> JRange_t;
32
33 string outputFile;
34 vector<string> energy_correction;
35 JRange_t X;
36 int debug;
37
38 try {
39
40 JParser<> zap("Example program to histogram energy corrections.");
41
42 zap['o'] = make_field(outputFile);
43 zap['E'] = make_field(energy_correction);
44 zap['x'] = make_field(X, "axis range in log(E/GeV)");
45 zap['d'] = make_field(debug) = 2;
46
47 zap(argc, argv);
48 }
49 catch(const exception& error) {
50 FATAL(error.what() << endl);
51 }
52
53
54 JManager<string, TH1D> zmap(new TH1D("h[%]", NULL, 1000, X.getLowerLimit(), X.getUpperLimit())); // [log(E)]
55
56 for (vector<string>::const_iterator f1 = energy_correction.begin(); f1 != energy_correction.end(); ++f1) {
57
58 const JEnergyCorrection correct(*f1);
59
60 DEBUG(getFilename(*f1) << endl << correct << endl);
61
62 for (int i = 1; i <= zmap->GetNbinsX(); ++i) {
63
64 const double x = zmap->GetBinCenter (i);
65 const double E = pow(10.0, x);
66 const double y = pow(10.0, correct(x)) / E;
67
68 DEBUG(SCIENTIFIC(12,3) << E << ' ' << FIXED(7,3) << y << endl);
69
70 zmap[getFilename(*f1)]->SetBinContent(i, y);
71 }
72 }
73
74 zmap.Write(outputFile.c_str());
75}
string outputFile
Dynamic ROOT object management.
I/O manipulators.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Auxiliary class to define a range between two values.
Auxiliary methods for handling file names, type names and environment.
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class for correction of energy determined by JEnergy.cc.
Range of values.
Definition JRange.hh:42
int main(int argc, char **argv)
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
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488