27 int main(
int argc,
char **argv)
33 JPMTParametersMap parametersMap;
42 JParser<> zap(
"Example program to histogram time over threshold distributions.");
54 catch(
const exception &error) {
55 FATAL(error.what() << endl);
58 const JPMTParameters
parameters = parametersMap.getPMTParameters(
pmt);
60 const JCalibration calibration;
63 const JPMTAnalogueSignalProcessor cpu (
parameters);
65 JPMTData<JPMTSignal> input;
66 JPMTData<JPMTPulse> output;
73 const double dx = 1.0;
74 const double xmin = 0.0 - 0.5 * dx;
75 const double xmax = 255.0 + 0.5 * dx;
76 const int nx = (int) ((xmax - xmin) / dx);
78 TH1D h0(
"h0", NULL, nx, xmin, xmax);
79 TH1D
h1(
"h1", NULL, nx, xmin, xmax);
80 TH1D h2(
"h2", NULL, nx, xmin, xmax);
81 TH1D h3(
"h3", NULL, 500, 0.0, 100.0);
86 DEBUG(
" ToT Probability " << endl);
88 for (
int i = 1; i <= h0.GetNbinsX(); ++i) {
90 const double x = h0.GetBinCenter(i);
91 const double y = cpu.getTimeOverThresholdProbability(x,NPE);
94 <<
FIXED(5,1) << x <<
" "
95 <<
FIXED(6,4) << y << endl);
97 h0.SetBinContent(i, y);
101 if (numberOfHits > 0) {
103 int number_of_hits = 0;
105 for (
int i = 0; i != numberOfHits; ++i) {
107 const double npe = cpu.getRandomCharge(NPE);
112 tot_ns = cpu.getTimeOverThreshold(npe);
114 }
catch (
const JValueOutOfRange& exception) {
116 DEBUG(exception.what());
129 h1.Scale(1.0 / (
double) number_of_hits / dx);
133 if (numberOfHits > 0) {
135 int number_of_hits = 0;
137 const double t_ns = 25.0;
139 for (
int i = 0; i != numberOfHits; ++i) {
144 input.push_back(JPMTSignal(t_ns, NPE));
146 simulator.processHits(
pmt, calibration, status, input, output);
148 for (JPMTData<JPMTPulse>::const_iterator hit = output.begin(); hit != output.end(); ++hit) {
152 h2.Fill(hit->tot_ns);
157 h2.Scale(1.0 / (
double) number_of_hits / dx);
163 for (
int i = 1; i <= h0.GetNbinsX(); ++i) {
165 const Double_t x = h0.GetBinCenter (i);
166 const Double_t y0 = h0.GetBinContent(i);
167 const Double_t y1 = h1.GetBinContent(i);
168 const Double_t y2 = h2.GetBinContent(i);
170 DEBUG(
"[" << setw(3) << i <<
"]" <<
' '
171 <<
FIXED(5,1) << x <<
' '
172 <<
FIXED(6,4) << y0 <<
' '
173 <<
FIXED(6,4) << y1 <<
' '
174 <<
FIXED(6,4) << y2 << endl);
176 ASSERT(fabs(y0 - y1) < precision);
177 ASSERT(fabs(y0 - y2) < precision);
Utility class to parse command line options.
*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
then for HISTOGRAM in h0 h1
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
#define ASSERT(A,...)
Assert macro.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Utility class to parse command line options.
PMT analogue signal processor.
#define DEBUG(A)
Message macros.
int main(int argc, char *argv[])