Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JTransitTime.cc File Reference

Example program to histogram PMT transit time distribution. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TRandom3.h"
#include "JDetector/JPMTTransitTimeProbability.hh"
#include "JDetector/JPMTParameters.hh"
#include "JDetector/JPMTAnalogueSignalProcessor.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 histogram PMT transit time distribution.

Author
mdejong

Definition in file JTransitTime.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 25 of file JTransitTime.cc.

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
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
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.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Utility class to parse command line options.
Definition JParser.hh:1698
@ debug_t
debug
Definition JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68