Jpp  pmt_effective_area_update_2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPMTSimulator.cc File Reference

Example program to histogram PMT simulator features. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TProfile.h"
#include "TProfile2D.h"
#include "JDetector/JPMTSimulator.hh"
#include "JDetector/JPMTAnalogueSignalProcessor.hh"
#include "JDetector/JPMTDefaultSimulator.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

Example program to histogram PMT simulator features.

Author
mdejong

Definition in file JPMTSimulator.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file JPMTSimulator.cc.

26 {
27  using namespace std;
28  using namespace JPP;
29 
30  string outputFile;
31  int numberOfHits;
32  JPMTParameters parameters;
33  int debug;
34 
35  try {
36 
37  JProperties properties = parameters.getProperties();
38 
39  JParser<> zap("Example program to histogram PMT simulator features.");
40 
41  zap['o'] = make_field(outputFile) = "pmt.root";
42  zap['n'] = make_field(numberOfHits) = 100;
43  zap['P'] = make_field(properties) = JPARSER::initialised();
44  zap['d'] = make_field(debug) = 0;
45 
46  zap(argc, argv);
47  }
48  catch(const exception &error) {
49  FATAL(error.what() << endl);
50  }
51 
52 
53  if (debug >= JEEP::debug_t) {
54  cout << "PMT parameters:" << endl;
55  cout << parameters.getProperties(JEquationParameters("=", "\n", "", "")) << endl;
56  }
57 
58  const JPMTAnalogueSignalProcessor cpu(parameters);
59 
60  const JPMTIdentifier pmt(1,0);
61  const JCalibration calibration;
62  const JStatus status;
63 
64  const JPMTDefaultSimulator simulator(parameters, pmt);
65 
66  JPMTData<JPMTSignal> input;
67  JPMTData<JPMTPulse> output;
68 
69 
70  TFile out(outputFile.c_str(), "recreate");
71 
72  TProfile h0("tot", NULL, 1000, parameters.threshold, 1000.0);
73  TProfile h1("hit", NULL, 1000, parameters.threshold, 1000.0);
74  TProfile2D h2("2D", NULL, 50, 0.0, 250.0, 100, 0.0, 1000.0);
75 
76 
77  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
78 
79  const double t_ns = 100.0;
80  const double x = h1.GetBinCenter(i);
81  const int npe = (int) x;
82 
83  for (int i = 0; i != numberOfHits; ++i) {
84 
85  input .clear();
86  output.clear();
87 
88  input.push_back(JPMTSignal(t_ns, npe));
89 
90  simulator.processHits(pmt, calibration, status, input, output);
91 
92  double tot = 0.0;
93 
94  for (JPMTData<JPMTPulse>::const_iterator hit = output.begin(); hit != output.end(); ++hit) {
95  tot += hit->tot_ns;
96  }
97 
98  h0.Fill(x, tot);
99  h1.Fill(x, (double) output.size());
100  }
101  }
102 
103 
104  for (int i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) {
105  for (int j = 1; j <= h2.GetYaxis()->GetNbins(); ++j) {
106 
107  const double t_ns = (int) h2.GetXaxis()->GetBinCenter(i);
108  const int npe = (int) h2.GetYaxis()->GetBinCenter(j);
109 
110  for (int i = 0; i != numberOfHits; ++i) {
111 
112  input .clear();
113  output.clear();
114 
115  input.push_back(JPMTSignal(0.0, npe));
116  input.push_back(JPMTSignal(t_ns, 1));
117 
118  simulator.processHits(pmt, calibration, status, input, output);
119 
120  if (!output.empty()) {
121  h2.Fill(t_ns, (double) npe, output.begin()->tot_ns);
122  }
123  }
124  }
125  }
126 
127  out.Write();
128  out.Close();
129 }
Utility class to parse command line options.
Definition: JParser.hh:1500
debug
Definition: JMessage.hh:29
Utility class to parse parameter values.
Definition: JProperties.hh:496
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Simple data structure to support I/O of equations (see class JLANG::JEquation).
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
int j
Definition: JPolint.hh:666