Jpp  18.5.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTrack3D.cc File Reference

Example program to test angle of incidence of a photon from a muon on a PMT. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TRandom3.h"
#include "JMath/JConstants.hh"
#include "JGeometry3D/JVector3D.hh"
#include "JGeometry3D/JVersor3D.hh"
#include "JGeometry3D/JAxis3D.hh"
#include "JGeometry3D/JTrack3D.hh"
#include "JGeometry3D/JRotation3D.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 angle of incidence of a photon from a muon on a PMT.

Author
mdejong

Definition in file JTrack3D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JTrack3D.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30 
31  JAxis3D pmt;
32  int numberOfEvents;
33  double precision;
34  UInt_t seed;
35  int debug;
36 
37  try {
38 
39  JParser<> zap("Example program to test angle of incidence of a photon from a muon on a PMT.");
40 
41  zap['n'] = make_field(numberOfEvents) = 1000;
42  zap['P'] = make_field(pmt) = JAxis3D(JVector3D(0,0,1), JVersor3D(0,0,1));
43  zap['e'] = make_field(precision) = 1.0e-6;
44  zap['S'] = make_field(seed) = 0;
45  zap['d'] = make_field(debug) = 3;
46 
47  zap(argc, argv);
48  }
49  catch(const exception &error) {
50  FATAL(error.what() << endl);
51  }
52 
53  gRandom->SetSeed(seed);
54 
55 
56  const JVersor3D U(getSinThetaC(), 0.0, getCosThetaC()); // photon direction in the reference frame of muon track
57 
58  int number_of_errors = 0;
59  int number_of_events = 0;
60 
61  for (int i = 0; i != numberOfEvents; ++i) {
62 
63  STATUS(setw(4) << i << '\r'); DEBUG(endl);
64 
65  const double x = gRandom->Uniform(-1.0, +1.0);
66  const double y = gRandom->Uniform(-1.0, +1.0);
67  const double z = gRandom->Uniform(-1.0, +1.0);
68 
69  const double dx = gRandom->Uniform(-1.0, +1.0);
70  const double dy = gRandom->Uniform(-1.0, +1.0);
71  const double dz = gRandom->Uniform(-1.0, +1.0);
72 
73  JTrack3D ta(JVector3D(x, y, z), JVersor3D(dx, dy, dz), 0.0);
74  JAxis3D tb(pmt);
75 
76  tb.transform(ta); // transform PMT to reference frame of muon track
77 
78  if (ta.getDistance(pmt) > precision) {
79 
80  ++number_of_events;
81 
82  // method JTrack3D::getDot(..) calculates angle of incidence of photon on PMT
83 
84  if (fabs(tb.getDirection().getDot(U) - ta.getDot(pmt)) > precision) {
85  ++number_of_errors;
86  }
87  }
88 
89  DEBUG("distance " << ta.getDistance(pmt) << endl);
90  DEBUG("dot (1) " << tb.getDirection().getDot(U) << endl);
91  DEBUG("dot (2) " << ta.getDot(pmt) << endl);
92  }
93  STATUS(endl);
94 
95  NOTICE("Number of errors: " << number_of_errors << " out of " << number_of_events << " events." << endl);
96 
97  ASSERT(number_of_events > 0);
98  ASSERT(number_of_errors == 0);
99 
100  return 0;
101 }
Utility class to parse command line options.
Definition: JParser.hh:1514
#define STATUS(A)
Definition: JMessage.hh:63
double getCosThetaC()
Get average cosine of Cherenkov angle of water corresponding to group velocity.
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
double getSinThetaC()
Get average sine of Cherenkov angle of water corresponding to group velocity.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62