Jpp  master_rocky-43-ge265d140c
the software that should make you happy
JTrack3D.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TRandom3.h"
7 
8 #include "JMath/JConstants.hh"
9 
10 #include "JGeometry3D/JVector3D.hh"
11 #include "JGeometry3D/JVersor3D.hh"
12 #include "JGeometry3D/JAxis3D.hh"
13 #include "JGeometry3D/JTrack3D.hh"
15 
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 
20 /**
21  * \file
22  *
23  * Example program to test angle of incidence of a photon from a muon on a PMT.
24  * \author mdejong
25  */
26 int main(int argc, char**argv)
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 }
Mathematical constants.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
int main(int argc, char **argv)
Definition: JTrack3D.cc:26
Axis object.
Definition: JAxis3D.hh:41
double getDistance(const JVector3D &pos) const
Get distance.
Definition: JAxis3D.hh:213
void transform(const JAxis3D &axis)
Transform axis to reference frame of given axis.
Definition: JAxis3D.hh:359
const JDirection3D & getDirection() const
Get direction.
double getDot(const JAngle3D &angle) const
Get dot product.
double getDot(const JAxis3D &axis) const
Get cosine angle of impact of Cherenkov light on PMT.
Definition: JTrack3D.hh:170
Data structure for vector in three dimensions.
Definition: JVector3D.hh:36
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:28
Utility class to parse command line options.
Definition: JParser.hh:1698
double getCosThetaC()
Get average cosine of Cherenkov angle of water corresponding to group velocity.
double getSinThetaC()
Get average sine of Cherenkov angle of water corresponding to group velocity.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14