Jpp test-rotations-new
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
14#include "Jeep/JeepToolkit.hh"
15#include "Jeep/JParser.hh"
16#include "Jeep/JMessage.hh"
17
18
19/**
20 * \file
21 *
22 * Example program to histogram energy corrections.
23 * \author mdejong
24 */
25int main(int argc, char **argv)
26{
27 using namespace std;
28 using namespace JPP;
29
30 typedef JRange<double> JRange_t;
31
32 string outputFile;
33 vector<string> energy_correction;
34 JRange_t X;
35 int debug;
36
37 try {
38
39 JParser<> zap("Example program to histogram energy corrections.");
40
41 zap['o'] = make_field(outputFile);
42 zap['E'] = make_field(energy_correction);
43 zap['x'] = make_field(X, "axis range in log(E/GeV)");
44 zap['d'] = make_field(debug) = 2;
45
46 zap(argc, argv);
47 }
48 catch(const exception& error) {
49 FATAL(error.what() << endl);
50 }
51
52
53 JManager<string, TH1D> zmap(new TH1D("h[%]", NULL, 1000, X.getLowerLimit(), X.getUpperLimit())); // [log(E)]
54
55 for (vector<string>::const_iterator f1 = energy_correction.begin(); f1 != energy_correction.end(); ++f1) {
56
57 const JEnergyCorrection fcn(*f1);
58
59 DEBUG(getFilename(*f1) << endl << fcn << endl);
60
61 for (int i = 1; i <= zmap->GetNbinsX(); ++i) {
62
63 const double x = zmap->GetBinCenter (i);
64 const double E = pow(10.0, x);
65 const double y = fcn(E) / E;
66
67 zmap[getFilename(*f1)]->SetBinContent(i, y);
68 }
69 }
70
71 zmap.Write(outputFile.c_str());
72}
string outputFile
Dynamic ROOT object management.
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).