Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
13 #include "Jeep/JParser.hh"
14 #include "Jeep/JMessage.hh"
15 
16 
17 /**
18  * \file
19  *
20  * Example program to histogram energy corrections.
21  * \author mdejong
22  */
23 int main(int argc, char **argv)
24 {
25  using namespace std;
26 
27  string outputFile;
28  vector<string> energy_correction;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Example program to histogram energy corrections.");
34 
35  zap['o'] = make_field(outputFile);
36  zap['E'] = make_field(energy_correction);
37  zap['d'] = make_field(debug) = 2;
38 
39  zap(argc, argv);
40  }
41  catch(const exception& error) {
42  FATAL(error.what() << endl);
43  }
44 
45  using namespace JPP;
46 
47  JManager<string, TH1D> zmap(new TH1D("h[%]", NULL, 1000, +2.0, +7.0)); // [log(E)]
48 
49  for (vector<string>::const_iterator f1 = energy_correction.begin(); f1 != energy_correction.end(); ++f1) {
50 
51  const JEnergyCorrection fcn(*f1);
52 
53  DEBUG("Formula " << fcn << endl);
54 
55  for (int i = 1; i <= zmap[*f1]->GetNbinsX(); ++i) {
56 
57  const double x = zmap[*f1]->GetBinCenter (i);
58  const double E = pow(10.0, x);
59  const double y = fcn(E) / E;
60 
61  zmap[*f1]->SetBinContent(i, y);
62  }
63  }
64 
65  zmap.Write(outputFile.c_str());
66 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
Dynamic ROOT object management.
string outputFile
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
Auxiliary class for correction of energy determined by JEnergy.cc.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition: JManager.hh:295
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
then usage $script[input file[working directory[option]]] nWhere option can be E
Definition: JMuonPostfit.sh:37
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62