31 JPMTParameters parameters;
39 JProperties properties = parameters.getProperties();
41 JParser<> zap(
"Example program to histogram time over threshold distributions.");
52 catch(
const exception &error) {
53 FATAL(error.what() << endl);
58 cout <<
"PMT parameters:" << endl;
62 const JPMTAnalogueSignalProcessor cpu(parameters);
64 const JPMTIdentifier pmt(1,0);
65 const JCalibration calibration;
67 const JPMTDefaultSimulator simulator(parameters, pmt);
69 JPMTData<JPMTSignal> input;
70 JPMTData<JPMTPulse> output;
77 const double xmin = -0.5;
78 const double xmax = 255.5;
79 const double dx = 1.0;
80 const int nx = (int) ((xmax - xmin) / dx);
82 TH1D h0(
"h0", NULL, nx, xmin, xmax);
83 TH1D h1(
"h1", NULL, nx, xmin, xmax);
84 TH1D h2(
"h2", NULL, nx, xmin, xmax);
85 TH1D h3(
"h3", NULL, 500, 0.0, 100.0);
90 DEBUG(
" ToT npe dP/dnpe dP/dToT" << endl);
92 for (
int i = 1; i <= h0.GetNbinsX(); ++i) {
94 const double x = h0.GetBinCenter(i);
95 const double npe = cpu.getNPE(x);
96 const double y = cpu.getProbability(npe, NPE);
97 const double v = cpu.getDerivative(npe);
100 <<
FIXED(5,1) << x <<
" "
101 <<
FIXED(7,3) << npe <<
" "
102 <<
FIXED(5,3) << y <<
" "
103 <<
FIXED(6,4) << y*
v << endl);
105 h0.SetBinContent(i, y*
v);
109 if (numberOfHits > 0) {
111 int number_of_hits = 0;
113 for (
int i = 0; i != numberOfHits; ++i) {
115 const double npe = cpu.getRandomAmplitude(NPE);
117 if (cpu.applyThreshold(npe)) {
119 const double tot_ns = cpu.getTimeOverThreshold(npe);
127 h1.Scale(1.0 / (
double) number_of_hits / dx);
131 if (numberOfHits > 0) {
133 int number_of_hits = 0;
135 const double t_ns = 25.0;
137 for (
int i = 0; i != numberOfHits; ++i) {
142 input.push_back(JPMTSignal(t_ns, NPE));
144 simulator.processHits(pmt, calibration, input, output);
146 for (JPMTData<JPMTPulse>::const_iterator hit = output.begin(); hit != output.end(); ++hit) {
150 h2.Fill(hit->tot_ns);
155 h2.Scale(1.0 / (
double) number_of_hits / dx);
161 for (
int i = 1; i <= h0.GetNbinsX(); ++i) {
163 const Double_t x = h0.GetBinCenter (i);
164 const Double_t y0 = h0.GetBinContent(i);
165 const Double_t y1 = h1.GetBinContent(i);
166 const Double_t y2 = h2.GetBinContent(i);
168 DEBUG(
"[" << setw(3) << i <<
"]" <<
' '
169 <<
FIXED(5,1) << x <<
' '
170 <<
FIXED(6,4) << y0 <<
' '
171 <<
FIXED(6,4) << y1 <<
' '
172 <<
FIXED(6,4) << y2 << endl);
174 ASSERT(fabs(y0 - y1) < precision);
175 ASSERT(fabs(y0 - y2) < precision);