Jpp
 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 "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 24 of file JTransitTime.cc.

25 {
26  using namespace std;
27  using namespace JPP;
28 
29  string outputFile;
30  JPMTParameters parameters;
31  int NPE;
32  int numberOfEvents;
33  double TTS_ns;
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(NPE) = 1;
45  zap['n'] = make_field(numberOfEvents) = 0;
46  zap['T'] = make_field(TTS_ns) = 2.0;
47  zap['d'] = make_field(debug) = 0;
48 
49  zap(argc, argv);
50  }
51  catch(const exception &error) {
52  FATAL(error.what() << endl);
53  }
54 
55  if (debug >= JEEP::debug_t) {
56  cout << "PMT parameters:" << endl;
57  cout << parameters.getProperties(JEquationParameters("=", "\n", "", "")) << endl;
58  }
59 
60  const JPMTAnalogueSignalProcessor cpu(parameters);
61 
62  TFile out(outputFile.c_str(), "recreate");
63 
64  TH1D h1("tts", NULL, 100, -20.0, +20.0);
65  TH1D h2("tt2", NULL, 100, -20.0, +20.0);
66  TH1D h3("pmt", NULL, 100, -20.0, +20.0);
67 
68  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
69 
70  const double t1 = h1.GetBinCenter(i);
71 
72  h1.SetBinContent(i, getTransitionTimeProbability(t1));
73  }
74 
75  for (int i = 1; i <= h2.GetNbinsX(); ++i) {
76 
77  const double t1 = h2.GetBinCenter(i);
78 
79  h2.SetBinContent(i, getTransitionTimeProbability2D(t1));
80  }
81 
82  for (int i = 0; i != numberOfEvents; ++i) {
83 
84  const double npe = cpu.getRandomCharge(NPE);
85 
86  try {
87 
88  if (cpu.applyThreshold(npe) == cpu.ABOVE_THRESHOLD) {
89 
90  const Double_t t1 = cpu.getRiseTime(npe) + gRandom->Gaus(0.0, TTS_ns);
91 
92  h3.Fill((Double_t) t1);
93  }
94 
95  } catch (const JValueOutOfRange& exception) {
96 
97  DEBUG(exception.what());
98  continue;
99  }
100 
101  }
102 
103  out.Write();
104  out.Close();
105 }
Utility class to parse command line options.
Definition: JParser.hh:1493
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:69
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:63
static const JTransitionTimeProbability getTransitionTimeProbability
Function object of transition time prabability.
string outputFile
static const JTransitionTimeProbability2D getTransitionTimeProbability2D
Function object of twofold transition time prabability.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62