Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPlotK40.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <cmath>
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 #include "TH1D.h"
10 
11 #include "JDetector/JModule.hh"
13 
15 #include "JCalibrate/JFitK40.hh"
16 
17 #include "Jeep/JProperties.hh"
18 #include "Jeep/JPrint.hh"
19 #include "Jeep/JParser.hh"
20 #include "Jeep/JMessage.hh"
21 
22 
23 /**
24  * \file
25  *
26  * Auxiliary plot fit function of JFitK40.cc.
27  * \author mdejong
28  */
29 int main(int argc, char **argv)
30 {
31  using namespace std;
32  using namespace JPP;
33 
34  JK40Parameters K40 = JK40Parameters::getInstance();
35 
36  string outputFile;
37  int debug;
38 
39  try {
40 
41  JProperties properties;
42 
43  properties.insert(gmake_property(K40.R));
44  properties.insert(gmake_property(K40.p1));
45  properties.insert(gmake_property(K40.p2));
46  properties.insert(gmake_property(K40.p3));
47  properties.insert(gmake_property(K40.p4));
48 
49  JParser<> zap("Auxiliary plot fit function of JFitK40.cc.");
50 
51  zap['@'] = make_field(properties) = JPARSER::initialised();
52  zap['o'] = make_field(outputFile, "output file.") = "k40.root";
53  zap['d'] = make_field(debug, "debug.") = 1;
54 
55  zap(argc, argv);
56  }
57  catch(const exception &error) {
58  FATAL(error.what() << endl);
59  }
60 
61 
62  const JModule module = getModule<JKM3NeT_t>(1001);
63 
64  const JModel model(module, K40);
65 
66  const int nx = model.getNumberOfPairs();
67  const double xmin = -0.5;
68  const double xmax = nx - 0.5;
69 
70 
71  TFile out(outputFile.c_str(), "recreate");
72 
73  TH1D h1("h1", NULL, nx, xmin, xmax);
74 
75  for (int ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
76 
77  const Double_t x = h1.GetXaxis()->GetBinCenter(ix);
78 
79  const pair_type pair = model.getPair((int) x);
80  const double rate = model.getValue(pair);
81 
82  h1.SetBinContent(ix, rate);
83  }
84 
85  out.Write();
86  out.Close();
87 }
const double xmax
Definition: JQuadrature.cc:24
Utility class to parse command line options.
Definition: JParser.hh:1514
JCombinatorics::pair_type pair_type
int main(int argc, char *argv[])
Definition: Main.cc:15
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
then set_variable singlesRate set_variable doublesRate set_variable numberOfSlices echo Generating random background echo Singles rate
Utility class to parse parameter values.
Definition: JProperties.hh:497
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
string outputFile
Utility class to parse parameter values.
I/O formatting auxiliaries.
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
const double xmin
Definition: JQuadrature.cc:23
Utility class to parse command line options.
int debug
debug level
Data structure for optical module.