Jpp  pmt_effective_area_update
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPMT.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 "JLang/Jpp.hh"
10 #include "JPhysics/Antares.hh"
11 #include "JPhysics/KM3NeT.hh"
12 #include "JROOT/JManager.hh"
13 #include "JROOT/JRootToolkit.hh"
14 #include "JGizmo/JGizmoToolkit.hh"
15 
16 #include "Jeep/JPrint.hh"
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 
21 /**
22  * \file
23  *
24  * Auxiliary program to plot QE and angular acceptance of PMT.
25  * \author mdejong
26  */
27 int main(int argc, char **argv)
28 {
29  using namespace std;
30 
31  string outputFile;
32  bool pdf;
33  int debug;
34 
35  try {
36 
37  JParser<> zap("Auxiliary program to plot QE and angular acceptance of PMT.");
38 
39  zap['o'] = make_field(outputFile) = "pmt.root";
40  zap['P'] = make_field(pdf);
41  zap['d'] = make_field(debug) = 2;
42 
43  zap(argc, argv);
44  }
45  catch(const exception &error) {
46  FATAL(error.what() << endl);
47  }
48 
49  using namespace NAMESPACE;
50  using namespace JPP;
51 
52 
53  TH1D h0(MAKE_CSTRING("QE[" << getNamespace() << "]"), NULL, 340, 280.0, 900.0);
54  TH1D h1(MAKE_CSTRING("PMT[" << getNamespace() << "]"), NULL, 1000, -1.0, +1.0);
55 
56  typedef JManager<double, TH1D> JManager_t;
57 
58  JManager_t qe ((TH1D*) h0.Clone("QE[%]"), '%', JFormat_t(3, 1, ios::fixed));
59  JManager_t pmt((TH1D*) h1.Clone("PMT[%]"), '%', JFormat_t(4, 0, ios::fixed));
60 
61  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
62 
63  const double y = h0.GetBinCenter (i);
64 
65  h0.SetBinContent(i, getQE(y));
66 
67  for (double x = -1.0; x <= +1.0; x += 0.1) {
68  if (getAngularAcceptance(x) > 0.0) {
69  qe [floor(x*10.0)/10.0]->SetBinContent(i, getPhotocathodeArea2D(x, y) / getPhotocathodeArea() / getAngularAcceptance(x));
70  }
71  }
72  }
73 
74 
75  double W = 0.0;
76 
77  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
78 
79  const double x = h1.GetBinCenter (i);
80  const double dx = h1.GetBinWidth (i);
81 
82  h1.SetBinContent(i, getPhotocathodeArea() * getAngularAcceptance(x) * 1.0e4);
83 
84  W += getPhotocathodeArea() * getAngularAcceptance(x) * dx * 1.0e4;
85 
86  for (double y = 340; y <= 640; y += 20.0) {
87  if (getQE(y) > 0.0) {
88  pmt[y]->SetBinContent(i, getPhotocathodeArea2D(x, y) * 1.0e4 / getQE(y));
89  }
90  }
91  }
92 
93  NOTICE(getNamespace() << " PMT average photo-cathode area " << FIXED(5,2) << W << " [cm^2]" << endl);
94 
95  if (pdf) {
96 
97  convertToPDF(h0, "NW");
98  convertToPDF(h1, "NW");
99 
100  for (JManager_t::iterator i = qe .begin(); i != qe .end(); ++i) { convertToPDF(*i->second, "NW"); }
101  for (JManager_t::iterator i = pmt.begin(); i != pmt.end(); ++i) { convertToPDF(*i->second, "NW"); }
102  }
103 
104 
105  TFile out(outputFile.c_str(), "recreate");
106 
107  out << h0 << h1;
108  out << qe << pmt;
109 
110  out.Write();
111  out.Close();
112 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
const double getPhotocathodeArea()
Photo-cathode area 10 inch PMT.
Definition: Antares.hh:41
Optical properties of Antares deep-sea site.
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
Jpp environment information.
Dynamic ROOT object management.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
std::string getNamespace(const std::string &type_name)
Get name space, i.e. part before JEEP::TYPENAME_SEPARATOR.
Definition: JeepToolkit.hh:225
string outputFile
Optical properties of KM3NeT deep-sea site.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
double getQE(const double R, const double mu)
Get QE for given ratio of hit probabilities and expectation value of the number of photo-electrons...
void convertToPDF(TH1 &h1, const std::string &option="NW", const double factor=1.0)
Convert 1D histogram to PDF.
#define NOTICE(A)
Definition: JMessage.hh:64
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.
static const JPhotocathodeArea2D getPhotocathodeArea2D
Function object for photo-cathode area 3 inch PMT.
Definition: KM3NeT.hh:5820
Data structure for format specifications.
Definition: JManip.hh:522
double getAngularAcceptance(const double x)
Angular acceptence of PMT.
Definition: JDrawLED.cc:84