Jpp
Functions
JPMTSimulator.cc File Reference
#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

◆ main()

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 
63  const JPMTDefaultSimulator simulator(parameters, pmt);
64 
65  JPMTData<JPMTSignal> input;
66  JPMTData<JPMTPulse> output;
67 
68 
69  TFile out(outputFile.c_str(), "recreate");
70 
71  TProfile h0("tot", NULL, 1000, parameters.threshold, 1000.0);
72  TProfile h1("hit", NULL, 1000, parameters.threshold, 1000.0);
73  TProfile2D h2("2D", NULL, 50, 0.0, 250.0, 100, 0.0, 1000.0);
74 
75 
76  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
77 
78  const double t_ns = 100.0;
79  const double x = h1.GetBinCenter(i);
80  const int npe = (int) x;
81 
82  for (int i = 0; i != numberOfHits; ++i) {
83 
84  input .clear();
85  output.clear();
86 
87  input.push_back(JPMTSignal(t_ns, npe));
88 
89  simulator.processHits(pmt, calibration, input, output);
90 
91  double tot = 0.0;
92 
93  for (JPMTData<JPMTPulse>::const_iterator hit = output.begin(); hit != output.end(); ++hit) {
94  tot += hit->tot_ns;
95  }
96 
97  h0.Fill(x, tot);
98  h1.Fill(x, (double) output.size());
99  }
100  }
101 
102 
103  for (int i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) {
104  for (int j = 1; j <= h2.GetYaxis()->GetNbins(); ++j) {
105 
106  const double t_ns = (int) h2.GetXaxis()->GetBinCenter(i);
107  const int npe = (int) h2.GetYaxis()->GetBinCenter(j);
108 
109  for (int i = 0; i != numberOfHits; ++i) {
110 
111  input .clear();
112  output.clear();
113 
114  input.push_back(JPMTSignal(0.0, npe));
115  input.push_back(JPMTSignal(t_ns, 1));
116 
117  simulator.processHits(pmt, calibration, input, output);
118 
119  if (!output.empty()) {
120  h2.Fill(t_ns, (double) npe, output.begin()->tot_ns);
121  }
122  }
123  }
124  }
125 
126  out.Write();
127  out.Close();
128 }
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:63
JTOOLS::j
int j
Definition: JPolint.hh:634
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JLANG::JEquationParameters
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Definition: JEquationParameters.hh:20
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JEEP::JProperties
Utility class to parse parameter values.
Definition: JProperties.hh:496
std
Definition: jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JEEP::debug_t
debug
Definition: JMessage.hh:29