Jpp  18.4.0
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"
12 #include "JROOT/JRootToolkit.hh"
13 #include "JCalibrate/JFitK40.hh"
14 #include "Jeep/JProperties.hh"
15 #include "Jeep/JPrint.hh"
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 /**
20  * \file
21  *
22  * Auxiliary program to draw K40 fit function.
23  * \author mdejong
24  */
25 int main(int argc, char **argv)
26 {
27  using namespace std;
28  using namespace JPP;
29 
30  JK40Parameters K40 = JK40Parameters::getInstance();
31 
32  string outputFile;
33  int debug;
34 
35  try {
36 
37  JProperties properties;
38 
39  properties.insert(gmake_property(K40.R));
40  properties.insert(gmake_property(K40.p1));
41  properties.insert(gmake_property(K40.p2));
42  properties.insert(gmake_property(K40.p3));
43  properties.insert(gmake_property(K40.p4));
44 
45  JParser<> zap("Auxiliary program to draw K40 fit function.");
46 
47  zap['@'] = make_field(properties) = JPARSER::initialised();
48  zap['o'] = make_field(outputFile, "output file.");
49  zap['d'] = make_field(debug, "debug.") = 1;
50 
51  zap(argc, argv);
52  }
53  catch(const exception &error) {
54  FATAL(error.what() << endl);
55  }
56 
57 
58  const JModule module = getModule<JKM3NeT_t>(1001);
59 
60  double ct = -1.0;
61 
62  for (JModule::const_iterator i = module.begin(); i != module.end(); ++i) {
63  for (JModule::const_iterator j = module.begin(); j != i; ++j) {
64 
65  if (getDot(i->getDirection(), j->getDirection()) > ct) {
66  ct = getDot(i->getDirection(), j->getDirection());
67  }
68  }
69  }
70 
71  cout << "Cosine minimal angle between PMT axes " << FIXED(5,3) << ct << endl;
72  cout << "Default rate [Hz] " << FIXED(6,3) << JK40Parameters::getInstance().getValue(ct) << '/' << FIXED(6,3) << JK40Parameters::getInstance().getValue(+1.0) << endl;
73  cout << "Modified rate [Hz] " << FIXED(6,3) << K40 .getValue(ct) << '/' << FIXED(6,3) << K40 .getValue(+1.0) << endl;
74 
75  TFile out(outputFile.c_str(), "recreate");
76 
77  TH1D h0("h0", NULL, 5000, -1.0, +1.0);
78 
79  for (Int_t i = 1; i <= h0.GetXaxis()->GetNbins(); ++i) {
80 
81  const Double_t x = h0.GetBinCenter(i);
82 
83  h0.SetBinContent(i, K40.getValue(x));
84  }
85 
86  out.Write();
87  out.Close();
88 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
#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:674
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
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
Utility class to parse parameter values.
I/O formatting auxiliaries.
Detector support kit.
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
Utility class to parse command line options.
int j
Definition: JPolint.hh:792
int debug
debug level
Data structure for optical module.