Jpp
 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 "JGizmo/JManager.hh"
13 #include "JGizmo/JGizmoToolkit.hh"
14 
15 #include "Jeep/JPrint.hh"
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 
20 /**
21  * \file
22  *
23  * Auxiliary program to plot QE and angular acceptance of PMT.
24  * \author mdejong
25  */
26 int main(int argc, char **argv)
27 {
28  using namespace std;
29 
30  string outputFile;
31  bool pdf;
32  int debug;
33 
34  try {
35 
36  JParser<> zap("Auxiliary program to plot QE and angular acceptance of PMT.");
37 
38  zap['o'] = make_field(outputFile) = "pmt.root";
39  zap['P'] = make_field(pdf);
40  zap['d'] = make_field(debug) = 2;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48  using namespace NAMESPACE;
49  using namespace JPP;
50 
51 
52  TH1D h0((string("QE[") + getNamespace() + "]").c_str(), NULL, 340, 280.0, 700.0);
53  TH1D h1((string("PMT[") + getNamespace() + "]").c_str(), NULL, 1000, -1.0, +1.0);
54 
55  typedef JManager<double, TH1D> JManager_t;
56 
57  JManager_t qe ((TH1D*) h0.Clone("QE[%]"));
58  JManager_t pmt((TH1D*) h1.Clone("PMT[%]"));
59 
60  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
61 
62  const double y = h0.GetBinCenter (i);
63 
64  h0.SetBinContent(i, getQE(y));
65 
66  for (double x = -1.0; x <= +1.0; x += 0.1) {
67  qe [floor(x*10.0)/10.0]->SetBinContent(i, getPhotocathodeArea2D(x, y) / getPhotocathodeArea() / getAngularAcceptance(x));
68  }
69  }
70 
71 
72  double W = 0.0;
73 
74  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
75 
76  const double x = h1.GetBinCenter (i);
77  const double dx = h1.GetBinWidth (i);
78 
79  h1.SetBinContent(i, getPhotocathodeArea() * getAngularAcceptance(x) * 1.0e4);
80 
81  W += getPhotocathodeArea() * getAngularAcceptance(x) * dx * 1.0e4;
82 
83  for (double y = 340; y <= 640; y += 20.0) {
84  pmt[y]->SetBinContent(i, getPhotocathodeArea2D(x, y) * 1.0e4 / getQE(y));
85  }
86  }
87 
88  NOTICE("PMT photo-cathode area [cm^2] " << getNamespace() << " " << FIXED(5,2) << W << endl);
89 
90  if (pdf) {
91 
92  convertToPDF(h0, "NW");
93  convertToPDF(h1, "NW");
94 
95  for (JManager_t::iterator i = qe .begin(); i != qe .end(); ++i) { convertToPDF(*i->second, "NW"); }
96  for (JManager_t::iterator i = pmt.begin(); i != pmt.end(); ++i) { convertToPDF(*i->second, "NW"); }
97  }
98 
99 
100  TFile out(outputFile.c_str(), "recreate");
101 
102  out.WriteTObject(&h0);
103  out.WriteTObject(&h1);
104 
105  qe .Write(out);
106  pmt.Write(out);
107 
108  out.Write();
109  out.Close();
110 }
Utility class to parse command line options.
Definition: JParser.hh:1493
const double getPhotocathodeArea()
Photo-cathode area 10 inch PMT.
Definition: Antares.hh:41
Optical properties of Antares deep-sea site.
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
Jpp environment information.
Dynamic ROOT object management.
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
std::string getNamespace(const std::string &type_name)
Get name space, i.e. part before JEEP::TYPENAME_SEPARATOR.
Definition: JeepToolkit.hh:225
string outputFile
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
Definition: JTransitTime.sh:36
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:1954
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:61
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
double getAngularAcceptance(const double x)
Angular acceptence of PMT.
Definition: JDrawLED.cc:84
int main(int argc, char *argv[])
Definition: Main.cpp:15