Jpp - 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 
12 
13 #include "JDetector/JModule.hh"
14 #include "JTools/JCombinatorics.hh"
15 #include "JROOT/JRootToolkit.hh"
17 #include "JCalibrate/JFitK40.hh"
18 
19 #include "Jeep/JProperties.hh"
20 #include "Jeep/JPrint.hh"
21 #include "Jeep/JParser.hh"
22 #include "Jeep/JMessage.hh"
23 
24 
25 /**
26  * \file
27  *
28  * Auxiliary plot fit function of JFitK40.cc.
29  * \author mdejong
30  */
31 int main(int argc, char **argv)
32 {
33  using namespace std;
34  using namespace JPP;
35  using namespace KM3NETDAQ;
36 
37  JFitK40Parameters fitk40; // setting of internal fit parameters
38 
39  string outputFile;
40  int debug;
41 
42  try {
43 
44  JProperties properties;
45 
46  properties.insert(gmake_property(fitk40.Rate_Hz));
47  properties.insert(gmake_property(fitk40.p1));
48  properties.insert(gmake_property(fitk40.p2));
49  properties.insert(gmake_property(fitk40.p3));
50  properties.insert(gmake_property(fitk40.p4));
51 
52  JParser<> zap("Auxiliary plot fit function of JFitK40.cc.");
53 
54  zap['@'] = make_field(properties) = JPARSER::initialised();
55  zap['o'] = make_field(outputFile, "output file.") = "fit.root";
56  zap['d'] = make_field(debug, "debug.") = 1;
57 
58  zap(argc, argv);
59  }
60  catch(const exception &error) {
61  FATAL(error.what() << endl);
62  }
63 
64 
65  JCombinatorics combinatorics(NUMBER_OF_PMTS);
66 
67  JModule module = JModule::getInstance();
68 
69  const int nx = combinatorics.getNumberOfPairs();
70  const double xmin = -0.5;
71  const double xmax = nx - 0.5;
72 
73 
74  TFile out(outputFile.c_str(), "recreate");
75 
76  TH1D h1("h1", NULL, nx, xmin, xmax);
77 
78  JFitK40 fit(module,
79  h1.GetXaxis()->GetXmin(),
80  h1.GetXaxis()->GetXmax(),
81  -20.0,
82  +20.0,
83  true);
84 
85  fit.setModelParameters(fitk40.getModelParameters());
86 
87  fit.sort(JPairwiseComparator(module));
88 
89  for (int ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
90 
91  const Double_t x = h1.GetXaxis()->GetBinCenter(ix);
92 
93  const JFitK40::pair_type pair = fit.getPair((int) x);
94  const double rate = fit.getValue(pair);
95 
96  h1.SetBinContent(ix, rate);
97  }
98 
99  out.Write();
100  out.Close();
101 }
Utility class to parse command line options.
Definition: JParser.hh:1500
JCombinatorics::pair_type pair_type
int main(int argc, char *argv[])
Definition: Main.cc:15
JFitK40_t< TF2 > JFitK40
Type definition for backward compatibility.
Definition: JFitK40.hh:806
#define gmake_property(A)
macro 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:496
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
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:1961
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.
KM3NeT DAQ constants, bit handling, etc.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
Data structure for a composite optical module.