Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JOmega3D.cc File Reference

Example program to test JGEOMETRY3D::JOmega3D class. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TRandom3.h"
#include "JTools/JConstants.hh"
#include "JTools/JQuantile.hh"
#include "JROOT/JRootToolkit.hh"
#include "JGeometry3D/JOmega3D.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 JGEOMETRY3D::JOmega3D class.

Author
mdejong

Definition in file JOmega3D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file JOmega3D.cc.

29 {
30  using namespace std;
31  using namespace JPP;
32 
33  string outputFile;
34  int numberOfEvents;
35  JAngleRange range_Deg;
36  int debug;
37 
38  try {
39 
40  JParser<> zap("Example program to test JOmega3D class.");
41 
42  zap['o'] = make_field(outputFile) = "";
43  zap['n'] = make_field(numberOfEvents) = 100;
44  zap['G'] = make_field(range_Deg) = JAngleRange(0.5, 10.5);
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 
54  const int N = 10;
55 
56  TH1D h0("h0[grid", NULL, N, range_Deg.getLowerLimit(), range_Deg.getUpperLimit());
57  TH1D h1("h1[RMS]", NULL, N, range_Deg.getLowerLimit(), range_Deg.getUpperLimit());
58  TH1D h2("h2[deviation]", NULL, N, range_Deg.getLowerLimit(), range_Deg.getUpperLimit());
59 
60 
61  vector<JOmega3D> omega;
62  vector<JQuantile> quantile;
63 
64  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
65 
66  const Double_t x = h0.GetBinCenter(i);
67 
68  omega .push_back(JOmega3D(x * PI/180.0));
69  quantile.push_back(JQuantile());
70  }
71 
72 
73  for (int i = 0; i != numberOfEvents; ++i) {
74 
75  STATUS("event: " << setw(10) << i << '\r'); DEBUG(endl);
76 
77  const double theta = gRandom->Uniform(0.0, PI);
78  const double phi = gRandom->Uniform(0.0, 2*PI);
79 
80  const JAngle3D angle(theta, phi);
81 
82  for (size_t j = 0; j != omega.size(); ++j) {
83 
84  const int pos = omega[j].find(angle);
85  const double dot = angle.getDot(omega[j][pos]);
86 
87  quantile[j].put(acos(dot) * 180.0/PI);
88  }
89  }
90  STATUS(endl);
91 
92 
93  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
94  h0.SetBinContent(i, omega [i-1].size());
95  h1.SetBinContent(i, quantile[i-1].getSTDev());
96  h2.SetBinContent(i, quantile[i-1].getDeviation());
97  }
98 
99  if (outputFile != "") {
100 
101  TFile out(outputFile.c_str(), "recreate");
102 
103  out << h0 << h1 << h2;
104 
105  out.Write();
106  out.Close();
107  }
108 
109  for (int i = 1; i <= h2.GetNbinsX(); ++i) {
110 
111  const Double_t x = h2.GetBinCenter (i);
112  const Double_t y = h2.GetBinContent(i);
113 
114  NOTICE("Grid test " << x << " [deg]: " << y << " [deg]." << endl);
115  ASSERT(y < x / sqrt(2));
116  }
117 
118  return 0;
119 }
Utility class to parse command line options.
Definition: JParser.hh:1493
JRange< double > JAngleRange
Type definition for angle range.
Definition: JAngleRange.hh:19
#define STATUS(A)
Definition: JMessage.hh:63
static const double PI
Constants.
Definition: JConstants.hh:20
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
string outputFile
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
#define NOTICE(A)
Definition: JMessage.hh:64
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
int j
Definition: JPolint.hh:634
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62