Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPMTSignalProcessor.cc File Reference

Example program to test PMT signal processor probability. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDetector/JPMTParametersMap.hh"
#include "JDetector/JPMTIdentifier.hh"
#include "JDetector/JPMTAnalogueSignalProcessor.hh"
#include "Jeep/JPrint.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 test PMT signal processor probability.

Author
mdejong

Definition in file JPMTSignalProcessor.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file JPMTSignalProcessor.cc.

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;
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->getRandomCharge(npe);
83 
84  try {
85 
86  if (cpu->applyThreshold(x) >= cpu->ABOVE_THRESHOLD) {
87  ++number_of_hits;
88  }
89 
90  } catch (const JValueOutOfRange& exception) {
91 
92  DEBUG(exception.what());
93  continue;
94  }
95 
96  }
97 
98  const double P = (double) number_of_hits / (double) numberOfHits;
99 
100  DEBUG("Number of generated hits " << setw(8) << right << numberOfHits << endl);
101  DEBUG("Number of accepted hits " << setw(8) << right << number_of_hits << endl);
102  DEBUG("Probability (real) " << FIXED(8,5) << P << endl);
103  DEBUG("Probability (calc) " << FIXED(8,5) << cpu->getSurvivalProbability(NPE) << endl);
104 
105  ASSERT(fabs(P - cpu->getSurvivalProbability(NPE)) < precision * cpu->getSurvivalProbability(NPE));
106 
107  delete cpu;
108 
109  return 0;
110 }
Utility class to parse command line options.
Definition: JParser.hh:1500
#define WARNING(A)
Definition: JMessage.hh:65
*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
Definition: diff-Tuna.sh:38
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:60