Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDrawK40.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "TROOT.h"
6 #include "TFile.h"
7 #include "TH1D.h"
8 
9 #include "JDetector/JModule.hh"
11 #include "JROOT/JRootToolkit.hh"
12 #include "JCalibrate/JFitK40.hh"
13 #include "Jeep/JProperties.hh"
14 #include "Jeep/JPrint.hh"
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 /**
19  * \file
20  *
21  * Auxiliary program to draw K40 fit function.
22  * \author mdejong
23  */
24 int main(int argc, char **argv)
25 {
26  using namespace std;
27  using namespace JPP;
28 
29  JFitK40Parameters fitk40; // setting of internal fit parameters
30 
31  string outputFile;
32  int debug;
33 
34  try {
35 
36  JProperties properties;
37 
38  properties.insert(gmake_property(fitk40.Rate_Hz));
39  properties.insert(gmake_property(fitk40.p1));
40  properties.insert(gmake_property(fitk40.p2));
41  properties.insert(gmake_property(fitk40.p3));
42  properties.insert(gmake_property(fitk40.p4));
43 
44  JParser<> zap("Auxiliary program to draw K40 fit function.");
45 
46  zap['@'] = make_field(properties) = JPARSER::initialised();
47  zap['o'] = make_field(outputFile, "output file.");
48  zap['d'] = make_field(debug, "debug.") = 1;
49 
50  zap(argc, argv);
51  }
52  catch(const exception &error) {
53  FATAL(error.what() << endl);
54  }
55 
56 
57  const JModule module = getModule<JKM3NeT_t>(1001);
58 
59  double ct = -1.0;
60 
61  for (JModule::const_iterator i = module.begin(); i != module.end(); ++i) {
62  for (JModule::const_iterator j = module.begin(); j != i; ++j) {
63 
64  if (getDot(i->getDirection(), j->getDirection()) > ct) {
65  ct = getDot(i->getDirection(), j->getDirection());
66  }
67  }
68  }
69 
70  cout << "Cosine minimal angle between PMT axes " << FIXED(5,3) << ct << endl;
71  cout << "Default rate [Hz] " << FIXED(6,3) << JFitK40Parameters().getValue(ct) << '/' << FIXED(6,3) << JFitK40Parameters().getValue(+1.0) << endl;
72  cout << "Modified rate [Hz] " << FIXED(6,3) << fitk40 .getValue(ct) << '/' << FIXED(6,3) << fitk40 .getValue(+1.0) << endl;
73 
74  TFile out(outputFile.c_str(), "recreate");
75 
76  TH1D h0("h0", NULL, 5000, -1.0, +1.0);
77 
78  for (Int_t i = 1; i <= h0.GetXaxis()->GetNbins(); ++i) {
79 
80  const Double_t x = h0.GetBinCenter(i);
81 
82  h0.SetBinContent(i, fitk40.getValue(x));
83  }
84 
85  out.Write();
86  out.Close();
87 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
Data structure for a composite optical module.
Definition: JModule.hh:68
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
double getDot(const JNeutrinoDirection &first, const JNeutrinoDirection &second)
Dot product.
Definition: JAstronomy.hh:409
Utility class to parse parameter values.
Definition: JProperties.hh:496
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
Utility class to parse parameter values.
Double_t getValue(const Double_t ct) const
Get K40 coincidence rate as a function of cosine angle between PMT axes.
Definition: JFitK40.hh:263
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:68
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
int j
Definition: JPolint.hh:682
Fit parameters for two-fold coincidence rate due to K40.
Definition: JFitK40.hh:66
Data structure for optical module.