Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
Functions
JPMT.cc File Reference

Auxiliary program to plot QE and angular acceptance of PMT. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JLang/Jpp.hh"
#include "JPhysics/Antares.hh"
#include "JPhysics/KM3NeT.hh"
#include "JPhysics/KM3NeT2D.hh"
#include "JROOT/JManager.hh"
#include "JROOT/JRootToolkit.hh"
#include "JGizmo/JGizmoToolkit.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 plot QE and angular acceptance of PMT.

Author
mdejong

Definition in file JPMT.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file JPMT.cc.

29 {
30  using namespace std;
31 
32  string outputFile;
33  bool pdf;
34  int debug;
35 
36  try {
37 
38  JParser<> zap("Auxiliary program to plot QE and angular acceptance of PMT.");
39 
40  zap['o'] = make_field(outputFile) = "pmt.root";
41  zap['P'] = make_field(pdf);
42  zap['d'] = make_field(debug) = 2;
43 
44  zap(argc, argv);
45  }
46  catch(const exception &error) {
47  FATAL(error.what() << endl);
48  }
49 
50  using namespace NAMESPACE;
51  using namespace JPP;
52 
53 
54  TH1D h0(MAKE_CSTRING("QE[" << getNamespace() << "]"), NULL, 340, 280.0, 900.0);
55  TH1D h1(MAKE_CSTRING("PMT[" << getNamespace() << "]"), NULL, 1000, -1.0, +1.0);
56 
57  typedef JManager<double, TH1D> JManager_t;
58 
59  JManager_t qe ((TH1D*) h0.Clone("QE[%]"), '%', JFormat_t(3, 1, ios::fixed));
60  JManager_t pmt((TH1D*) h1.Clone("PMT[%]"), '%', JFormat_t(4, 0, ios::fixed));
61 
62  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
63 
64  const double y = h0.GetBinCenter (i);
65 
66  h0.SetBinContent(i, getQE(y));
67 
68  for (double x = -1.0; x <= +1.0; x += 0.1) {
69  if (KM3NET::getAngularAcceptance(x) > 0.0) {
70  qe [floor(x*10.0)/10.0]->SetBinContent(i, KM3NET2D::getPhotocathodeArea2D(x, y) / KM3NET::getPhotocathodeArea() / KM3NET::getAngularAcceptance(x));
71  }
72  }
73  }
74 
75 
76  double W = 0.0;
77 
78  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
79 
80  const double x = h1.GetBinCenter (i);
81  const double dx = h1.GetBinWidth (i);
82 
83  h1.SetBinContent(i, getPhotocathodeArea() * getAngularAcceptance(x) * 1.0e4);
84 
85  W += getPhotocathodeArea() * getAngularAcceptance(x) * dx * 1.0e4;
86 
87  for (double y = 340; y <= 640; y += 20.0) {
88  if (KM3NET::getQE(y) > 0.0) {
89  pmt[y]->SetBinContent(i, KM3NET2D::getPhotocathodeArea2D(x, y) * 1.0e4 / KM3NET::getQE(y));
90  }
91  }
92  }
93 
94  NOTICE(getNamespace() << " PMT average photo-cathode area " << FIXED(5,2) << W << " [cm^2]" << endl);
95 
96  if (pdf) {
97 
98  convertToPDF(h0, "NW");
99  convertToPDF(h1, "NW");
100 
101  for (JManager_t::iterator i = qe .begin(); i != qe .end(); ++i) { convertToPDF(*i->second, "NW"); }
102  for (JManager_t::iterator i = pmt.begin(); i != pmt.end(); ++i) { convertToPDF(*i->second, "NW"); }
103  }
104 
105 
106  TFile out(outputFile.c_str(), "recreate");
107 
108  out << h0 << h1;
109  out << qe << pmt;
110 
111  out.Write();
112  out.Close();
113 }
string outputFile
double getAngularAcceptance(const double x)
Angular acceptence of PMT.
Definition: JDrawLED.cc:68
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:72
Utility class to parse command line options.
Definition: JParser.hh:1698
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Definition: JManager.hh:47
double getPhotocathodeArea()
Get photo-cathode area of PMT.
Definition: Antares.hh:51
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.
std::string getNamespace(const std::string &type_name)
Get name space, i.e. part before JEEP::TYPENAME_SEPARATOR.
Definition: JeepToolkit.hh:270
void convertToPDF(TH1 &h1, const std::string &option="NW", const double factor=1.0)
Convert 1D histogram to PDF.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const JPhotocathodeArea2D getPhotocathodeArea2D
Function object for effective photo-cathode area of PMT.
Definition: KM3NeT2D.hh:5235
double getPhotocathodeArea()
Get photo-cathode area of PMT.
Definition: KM3NeT.hh:60
double getQE(const double lambda)
Get quantum efficiency of KM3NeT PMT.
Definition: KM3NeT.hh:207
double getAngularAcceptance(const double x)
Get angular acceptance of PMT.
Definition: KM3NeT.hh:154
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Data structure for format specifications.
Definition: JManip.hh:524