Jpp  15.0.1-rc.1-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
#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
Mathematical constants.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
double getSinThetaC()
Get average sine of Cherenkov angle of water corresponding to group velocity.