Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "JROOT/JManager.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

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JPMT.cc.

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:1500
const double getPhotocathodeArea()
Photo-cathode area 10 inch PMT.
Definition: Antares.hh:41
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
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
#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
#define FATAL(A)
Definition: JMessage.hh:67
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