Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
examples/JReconstruction/JEnergyCorrection.cc File Reference

Example program to histogram energy corrections. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JReconstruction/JEvtToolkit.hh"
#include "JReconstruction/JEnergyCorrection.hh"
#include "JROOT/JManager.hh"
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to histogram energy corrections.

Author
mdejong

Definition in file examples/JReconstruction/JEnergyCorrection.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file examples/JReconstruction/JEnergyCorrection.cc.

25 {
26  using namespace std;
27  using namespace JPP;
28 
29  string outputFile;
30  vector<string> energy_correction;
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Example program to histogram energy corrections.");
36 
37  zap['o'] = make_field(outputFile);
38  zap['E'] = make_field(energy_correction);
39  zap['d'] = make_field(debug) = 2;
40 
41  zap(argc, argv);
42  }
43  catch(const exception& error) {
44  FATAL(error.what() << endl);
45  }
46 
47 
48  JManager<string, TH1D> zmap(new TH1D("h[%]", NULL, 1000, +2.0, +7.0)); // [log(E)]
49 
50  for (vector<string>::const_iterator f1 = energy_correction.begin(); f1 != energy_correction.end(); ++f1) {
51 
52  const JEnergyCorrection fcn(*f1);
53 
54  DEBUG(getFilename(*f1) << endl << fcn << endl);
55 
56  for (int i = 1; i <= zmap->GetNbinsX(); ++i) {
57 
58  const double x = zmap->GetBinCenter (i);
59  const double E = pow(10.0, x);
60  const double y = fcn(E) / E;
61 
62  zmap[getFilename(*f1)]->SetBinContent(i, y);
63  }
64  }
65 
66  zmap.Write(outputFile.c_str());
67 }
Utility class to parse command line options.
Definition: JParser.hh:1500
string outputFile
then usage E
Definition: JMuonPostfit.sh:35
#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
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:88