Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ 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);
62 const JStatus status;
63
64 const JPMTDefaultSimulator simulator(parameters, pmt);
65
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}
string outputFile
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Data structure for time calibration.
Template data structure for PMT I/O.
std::vector< JElement_t >::const_iterator const_iterator
Data structure for PMT parameters.
double threshold
threshold [npe]
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters())
Get properties of this class.
Utility class to parse parameter values.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Utility class to parse command line options.
Definition JParser.hh:1698
@ debug_t
debug
Definition JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
int j
Definition JPolint.hh:801
Calibration.
Definition JHead.hh:330
Data structure for PMT analogue signal.
Auxiliary class for handling status.
Definition JStatus.hh:39
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68