Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
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/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 JEnergyCorrection.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file JEnergyCorrection.cc.

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
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
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
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