Jpp  17.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
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

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 }
Utility class to parse command line options.
Definition: JParser.hh:1500
debug
Definition: JMessage.hh:29
Utility class to parse parameter values.
Definition: JProperties.hh:496
*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).
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
getTransitionTimeProbability
Function object of transition time prabability.
int debug
debug level
Definition: JSirene.cc:66
#define FATAL(A)
Definition: JMessage.hh:67