Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JDrawK40.cc File Reference

Auxiliary program to draw K40 fit function. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDetector/JModule.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDetectorSupportkit.hh"
#include "JROOT/JRootToolkit.hh"
#include "JCalibrate/JCalibrateK40.hh"
#include "JCalibrate/JFitK40.hh"
#include "Jeep/JProperties.hh"
#include "Jeep/JPrint.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

Auxiliary program to draw K40 fit function.

Author
mdejong

Definition in file JDrawK40.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JDrawK40.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30 
31  JK40Parameters K40 = JK40Parameters::getInstance();
32 
33  string outputFile;
34  int debug;
35 
36  try {
37 
38  JProperties properties;
39 
40  properties.insert(gmake_property(K40.R));
41  properties.insert(gmake_property(K40.p1));
42  properties.insert(gmake_property(K40.p2));
43  properties.insert(gmake_property(K40.p3));
44  properties.insert(gmake_property(K40.p4));
45 
46  JParser<> zap("Auxiliary program to draw K40 fit function.");
47 
48  zap['@'] = make_field(properties) = JPARSER::initialised();
49  zap['o'] = make_field(outputFile, "output file.");
50  zap['d'] = make_field(debug, "debug.") = 1;
51 
52  zap(argc, argv);
53  }
54  catch(const exception &error) {
55  FATAL(error.what() << endl);
56  }
57 
58 
59  const JModule module = getModule<JKM3NeT_t>(1001);
60 
61  double ct = -1.0;
62 
63  for (JModule::const_iterator i = module.begin(); i != module.end(); ++i) {
64  for (JModule::const_iterator j = module.begin(); j != i; ++j) {
65 
66  if (getDot(i->getDirection(), j->getDirection()) > ct) {
67  ct = getDot(i->getDirection(), j->getDirection());
68  }
69  }
70  }
71 
72  const JCombinatorics_t combinatorics(module);
73 
74  cout << "Cosine minimal angle between PMT axes " << FIXED(5,3) << ct << endl;
75  cout << "Default rate [Hz] " << FIXED(6,3) << JK40Parameters::getInstance().getValue(ct) << '/' << FIXED(6,3) << JK40Parameters::getInstance().getValue(+1.0) << endl;
76  cout << "Modified rate [Hz] " << FIXED(6,3) << K40 .getValue(ct) << '/' << FIXED(6,3) << K40 .getValue(+1.0) << endl;
77 
78  TFile out(outputFile.c_str(), "recreate");
79 
80  const Int_t nx = combinatorics.getNumberOfPairs();
81  const Double_t xmin = -0.5;
82  const Double_t xmax = nx - 0.5;
83 
84  TH1D h0("h0", NULL, 5000, -1.0, +1.0);
85  TH1D h1("h1", NULL, nx, xmin, xmax);
86 
87  for (Int_t i = 1; i <= h0.GetXaxis()->GetNbins(); ++i) {
88 
89  const Double_t x = h0.GetBinCenter(i);
90 
91  h0.SetBinContent(i, K40.getValue(x));
92  }
93 
94  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
95 
96  const int index = h1.GetBinCenter(i);
97 
98  const JCombinatorics_t::pair_type pair = combinatorics.getPair(index);
99 
100  const double x = getDot(module[pair.first].getDirection(), module[pair.second].getDirection());
101 
102  h1.SetBinContent(i, K40.getValue(x));
103  }
104 
105  out.Write();
106  out.Close();
107 }
const double xmax
Definition: JQuadrature.cc:24
Utility class to parse command line options.
Definition: JParser.hh:1711
JCombinatorics::pair_type pair_type
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
double getDot(const JNeutrinoDirection &first, const JNeutrinoDirection &second)
Dot product.
Definition: JAstronomy.hh:676
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:84
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
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:2158
#define FATAL(A)
Definition: JMessage.hh:67
const double xmin
Definition: JQuadrature.cc:23
int j
Definition: JPolint.hh:792
int debug
debug level