Jpp
JPMTSignalProcessor.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
9 
10 #include "Jeep/JPrint.hh"
11 #include "Jeep/JParser.hh"
12 #include "Jeep/JMessage.hh"
13 
14 
15 /**
16  * \file
17  *
18  * Example program to test PMT signal processor probability.
19  * \author mdejong
20  */
21 int main(int argc, char **argv)
22 {
23  using namespace std;
24  using namespace JPP;
25 
26  int numberOfHits;
27  JPMTParametersMap parameters;
28  JPMTIdentifier pmt;
29  int NPE;
30  double precision;
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Example program to test PMT signal processor probability.");
36 
37  zap['n'] = make_field(numberOfHits) = 10000;
38  zap['P'] = make_field(parameters) = JPARSER::initialised();
39  zap['p'] = make_field(pmt) = JPMTIdentifier(-1,0);
40  zap['N'] = make_field(NPE) = 1;
41  zap['e'] = make_field(precision) = 0.02;
42  zap['d'] = make_field(debug) = 3;
43 
44  zap(argc, argv);
45  }
46  catch(const exception &error) {
47  FATAL(error.what() << endl);
48  }
49 
50 
51  const double QEmax = 1.0;
52 
53  JPMTParameters buffer = parameters.getPMTParameters(pmt);
54 
55  DEBUG("PMT parameters:" << endl);
56  DEBUG(buffer.getProperties(JEquationParameters("=", "\n", "", "")) << endl);
57 
58  if (buffer.QE > QEmax) {
59 
60  WARNING("PMT QE set to " << QEmax << endl);
61 
62  buffer.QE = QEmax;
63  }
64 
65  JPMTSignalProcessorInterface* cpu = new JPMTAnalogueSignalProcessor(buffer);
66  //JPMTSignalProcessorInterface* cpu = new JPMTSignalProcessorInterface();
67 
68  ASSERT(numberOfHits > 0);
69 
70  int number_of_hits = 0;
71 
72  for (int i = 0; i != numberOfHits; ++i) {
73 
74  int npe = 0;
75 
76  for (int __i = 0; __i != NPE; ++__i) {
77  if (cpu->applyQE()) {
78  ++npe;
79  }
80  }
81 
82  double x = cpu->getRandomAmplitude(npe);
83 
84  if (cpu->applyThreshold(x)) {
85  ++number_of_hits;
86  }
87  }
88 
89  const double P = (double) number_of_hits / (double) numberOfHits;
90 
91  DEBUG("Number of generated hits " << setw(8) << right << numberOfHits << endl);
92  DEBUG("Number of accepted hits " << setw(8) << right << number_of_hits << endl);
93  DEBUG("Probability (real) " << FIXED(8,5) << P << endl);
94  DEBUG("Probability (calc) " << FIXED(8,5) << cpu->getSurvivalProbability(NPE) << endl);
95 
96  ASSERT(fabs(P - cpu->getSurvivalProbability(NPE)) < precision * cpu->getSurvivalProbability(NPE));
97 
98  delete cpu;
99 
100  return 0;
101 }
JPMTParametersMap.hh
JPMTAnalogueSignalProcessor.hh
FIXED
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
main
int main(int argc, char **argv)
Definition: JPMTSignalProcessor.cc:21
JMessage.hh
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
JPrint.hh
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:63
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
WARNING
#define WARNING(A)
Definition: JMessage.hh:65
debug
int debug
debug level
Definition: JSirene.cc:59
JPMTIdentifier.hh
JParser.hh
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
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition: JMessage.hh:67