Jpp  pmt_effective_area_update_2
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 #include "JTools/JCombinatorics.hh"
14 #include "JROOT/JRootToolkit.hh"
16 #include "JCalibrate/JFitK40.hh"
17 
18 #include "Jeep/JProperties.hh"
19 #include "Jeep/JPrint.hh"
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
23 
24 /**
25  * \file
26  *
27  * Auxiliary plot fit function of JFitK40.cc.
28  * \author mdejong
29  */
30 int main(int argc, char **argv)
31 {
32  using namespace std;
33  using namespace JPP;
34 
35  JFitK40Parameters fitk40; // setting of internal fit parameters
36 
37  string outputFile;
38  int debug;
39 
40  try {
41 
42  JProperties properties;
43 
44  properties.insert(gmake_property(fitk40.Rate_Hz));
45  properties.insert(gmake_property(fitk40.p1));
46  properties.insert(gmake_property(fitk40.p2));
47  properties.insert(gmake_property(fitk40.p3));
48  properties.insert(gmake_property(fitk40.p4));
49 
50  JParser<> zap("Auxiliary plot fit function of JFitK40.cc.");
51 
52  zap['@'] = make_field(properties) = JPARSER::initialised();
53  zap['o'] = make_field(outputFile, "output file.") = "k40.root";
54  zap['d'] = make_field(debug, "debug.") = 1;
55 
56  zap(argc, argv);
57  }
58  catch(const exception &error) {
59  FATAL(error.what() << endl);
60  }
61 
62 
63  const JModule module = getModule<JKM3NeT_t>(1001);
64 
65  const JCombinatorics combinatorics(module.size());
66 
67  const int nx = combinatorics.getNumberOfPairs();
68  const double xmin = -0.5;
69  const double xmax = nx - 0.5;
70 
71 
72  TFile out(outputFile.c_str(), "recreate");
73 
74  TH1D h1("h1", NULL, nx, xmin, xmax);
75 
76  JFitK40 fit(module,
77  h1.GetXaxis()->GetXmin(),
78  h1.GetXaxis()->GetXmax(),
79  -20.0,
80  +20.0,
81  true);
82 
83  fit.setModelParameters(fitk40.getModelParameters());
84 
85  fit.sort(JPairwiseComparator(module));
86 
87  for (int ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
88 
89  const Double_t x = h1.GetXaxis()->GetBinCenter(ix);
90 
91  const JFitK40::pair_type pair = fit.getPair((int) x);
92  const double rate = fit.getValue(pair);
93 
94  h1.SetBinContent(ix, rate);
95  }
96 
97  out.Write();
98  out.Close();
99 }
Utility class to parse command line options.
Definition: JParser.hh:1500
JCombinatorics::pair_type pair_type
Auxiliary class to convert pair of indices to unique index and back.
int main(int argc, char *argv[])
Definition: Main.cc:15
Data structure for a composite optical module.
Definition: JModule.hh:66
#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
Template specialisation of two-fold coincidence rate due to K40 and other radioactive decays...
Definition: JFitK40.hh:586
Utility class to parse parameter values.
Definition: JProperties.hh:496
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
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.
Auxiliary class to sort pairs of PMT addresses within optical module.
#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.
unsigned int getNumberOfPairs() const
Get number of pairs.
Fit parameters for two-fold coincidence rate due to K40.
Definition: JFitK40.hh:66
Data structure for optical module.