Jpp  debug
the software that should make you happy
JTransitTime.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TROOT.h"
7 #include "TFile.h"
8 #include "TH1D.h"
9 #include "TRandom3.h"
10 
14 
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 
19 /**
20  * \file
21  *
22  * Example program to histogram PMT transit time distribution.
23  * \author mdejong
24  */
25 int main(int argc, char **argv)
26 {
27  using namespace std;
28  using namespace JPP;
29 
30  string outputFile;
31  JPMTParameters parameters;
32  int numberOfEvents;
33  int option;
34  int debug;
35 
36  try {
37 
38  JProperties properties = parameters.getProperties();
39 
40  JParser<> zap("Example program to histogram PMT transit time distribution.");
41 
42  zap['o'] = make_field(outputFile) = "histogram.root";
43  zap['P'] = make_field(properties) = JPARSER::initialised();
44  zap['n'] = make_field(numberOfEvents) = 0;
45  zap['O'] = make_field(option) = 0;
46  zap['d'] = make_field(debug) = 0;
47 
48  zap(argc, argv);
49  }
50  catch(const exception &error) {
51  FATAL(error.what() << endl);
52  }
53 
54  if (debug >= JEEP::debug_t) {
55  cout << "PMT parameters:" << endl;
56  cout << parameters.getProperties(JEquationParameters("=", "\n", "", "")) << endl;
57  }
58 
59  parameters.TTS_ns = -option;
60 
61  const JPMTAnalogueSignalProcessor cpu(parameters);
62 
63  TFile out(outputFile.c_str(), "recreate");
64 
65  TH1D h1("tts", NULL, 1300, -30.0, +100.0);
66  TH1D h2("pmt", NULL, 130, -30.0, +100.0);
67 
68  double W = 0.0;
69 
70  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
71 
72  const double t1 = h1.GetBinCenter(i);
73  const double y = getTransitionTimeProbability(t1, option);
74  const double z = h1.GetBinWidth (i);
75 
76  h1.SetBinContent(i, y);
77 
78  W += y * z;
79  }
80 
81  h1.Scale(1.0 / W, "nosw2");
82 
83  if (numberOfEvents > 0) {
84 
85  for (int i = 0; i != numberOfEvents; ++i) {
86 
87  const double t0 = 0.0;
88  const double t1 = cpu.getRandomTime(t0);
89 
90  h2.Fill(t1);
91  }
92 
93  h2.Scale(1.0 / numberOfEvents);
94  }
95 
96  out.Write();
97  out.Close();
98 }
string outputFile
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
PMT analogue signal processor.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
int main(int argc, char **argv)
Definition: JTransitTime.cc:25
Data structure for PMT parameters.
double TTS_ns
transition time spread [ns]
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters())
Get properties of this class.
Utility class to parse parameter values.
Definition: JProperties.hh:501
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Utility class to parse command line options.
Definition: JParser.hh:1714
JDETECTOR::getTransitionTimeProbability getTransitionTimeProbability
Function object of transition time prabability.
@ debug_t
debug
Definition: JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
virtual double getRandomTime(const double t_ns) const override
Get randomised time according transition time distribution.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84