Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTransitTimeGenerator.cc File Reference

Example program to test generation of transit times using PMT simulator. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDetector/JPMTSimulator.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 test generation of transit times using PMT simulator.

Author
mdejong

Definition in file JTransitTimeGenerator.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file JTransitTimeGenerator.cc.

24 {
25  using namespace std;
26  using namespace JPP;
27 
28  string outputFile;
29  int numberOfHits;
30  JPMTParameters parameters;
31  int debug;
32 
33  try {
34 
35  JProperties properties = parameters.getProperties();
36 
37  JParser<> zap("Example program to test generation of transit times using PMT simulator.");
38 
39  zap['o'] = make_field(outputFile) = "pmt.root";
40  zap['n'] = make_field(numberOfHits) = 10000;
41  zap['P'] = make_field(properties) = JPARSER::initialised();
42  zap['d'] = make_field(debug) = 0;
43 
44  zap(argc, argv);
45  }
46  catch(const exception &error) {
47  FATAL(error.what() << endl);
48  }
49 
50 
51  if (debug >= JEEP::debug_t) {
52  cout << "PMT parameters:" << endl;
53  cout << parameters.getProperties(JEquationParameters("=", "\n", "", "")) << endl;
54  }
55 
56  const JPMTIdentifier pmt(1,0);
57  const JCalibration calibration;
58 
59  const JPMTDefaultSimulator simulator(parameters, pmt);
60 
61 
62  TFile out(outputFile.c_str(), "recreate");
63 
64  JPMTData<JPMTSignal> input;
65  JPMTData<JPMTPulse> output;
66 
67 
68  TH1D h1("tts", NULL, 120, -20.0, +100.0);
69 
70  for (int i = 0; i != numberOfHits; ++i) {
71 
72  const double t_ns = 0.0;
73  const int npe = 1;
74  const double W = 1.0 / (double) numberOfHits;
75 
76  input .clear();
77  output.clear();
78 
79  input.push_back(JPMTSignal(t_ns, npe));
80 
81  simulator.processHits(pmt, calibration, input, output);
82 
83  for (JPMTData<JPMTPulse>::const_iterator hit = output.begin(); hit != output.end(); ++hit) {
84  h1.Fill(hit->t_ns, W);
85  }
86  }
87 
88  out.Write();
89  out.Close();
90 }
Utility class to parse command line options.
Definition: JParser.hh:1410
debug
Definition: JMessage.hh:27
Utility class to parse parameter values.
Definition: JProperties.hh:484
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.
Definition: JParser.hh:64
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65