TestTorus.cc
Go to the documentation of this file.
1 
12 #include <utl/config.h>
13 
14 #include "TestTorus.h"
15 #include "RTFunctions.h"
16 
17 #include <TCanvas.h>
18 #include <TPolyMarker3D.h>
19 
20 #include <utl/Reader.h>
21 #include <utl/ErrorLogger.h>
22 #include <utl/AugerUnits.h>
23 #include <utl/MathConstants.h>
24 #include <utl/Math.h>
25 #include <utl/PhysicalConstants.h>
26 #include <utl/PhysicalFunctions.h>
27 #include <utl/Point.h>
28 #include <utl/TabulatedFunction.h>
29 #include <utl/TabulatedFunctionErrors.h>
30 #include <utl/Trace.h>
31 #include <utl/MultiTabulatedFunction.h>
32 #include <utl/Photon.h>
33 #include <utl/RandomEngine.h>
34 #include <utl/UTMPoint.h>
35 
36 #include <fwk/CentralConfig.h>
37 #include <fwk/CoordinateSystemRegistry.h>
38 #include <fwk/RandomEngineRegistry.h>
39 
40 #include <det/Detector.h>
41 
42 #include <fdet/FDetector.h>
43 #include <fdet/Eye.h>
44 #include <fdet/Telescope.h>
45 #include <fdet/Camera.h>
46 #include <fdet/Pixel.h>
47 #include <fdet/Mirror.h>
48 #include <fdet/Filter.h>
49 #include <fdet/Corrector.h>
50 
51 #include <evt/Event.h>
52 
53 #include <fevt/FEvent.h>
54 #include <fevt/Eye.h>
55 #include <fevt/TelescopeSimData.h>
56 #include <fevt/Telescope.h>
57 #include <fevt/PixelSimData.h>
58 #include <fevt/Pixel.h>
59 
60 #include <boost/tuple/tuple.hpp>
61 
62 #include <TDirectory.h>
63 #include <TFile.h>
64 #include <TTree.h>
65 
66 #include <CLHEP/Random/Randomize.h>
67 
68 #include <iomanip>
69 #include <fstream>
70 #include <sstream>
71 
72 using namespace TestTorusKG;
73 using namespace std;
74 using namespace utl;
75 using namespace evt;
76 using namespace fwk;
77 using namespace det;
78 using namespace fdet;
79 
80 using CLHEP::RandFlat;
81 
82 
83 
85 {
86 }
87 
88 
91 {
92  cout << " Init TestTorus " << endl;
93 
94  return eSuccess;
95 }
96 
97 
100 {
101  cout << " Run TestTorus " << endl;
102 
103  TimeStamp simTime(900000000, 3);
104 
105  Detector& detector = Detector::GetInstance();
106  detector.Update (simTime);
107  const FDetector& theFDetector = detector.GetFDetector();
108 
109  const fdet::Eye &detEye = *(theFDetector.EyesBegin ());
110  const fdet::Telescope &detTel = *(detEye.TelescopesBegin ());
111  const CoordinateSystemPtr& telCS = detTel.GetTelescopeCoordinateSystem ();
112 
113  utl::RandomEngine* theRandomEngine =
114  &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::eDetector);
115 
116  const double tubeRadius = 524351.7*mm;//6130*mm;//8380*mm;
117  const double torusRadius = 750.*mm;//850.*mm;//804.1*mm;
118  const double torusZ = tubeRadius + 9.39*mm;//tubeRadius + 6.9*mm;//8386.775*mm;
119 
120  const double phiMin = 0;
121  const double phiMax = 360*deg;
122  const double distMin = 0.*m;
123  const double distMax = 1.1*(tubeRadius+torusRadius);
124 
125  //const double thetaMin = 0;
126  //const double thetaMax = 30*deg;
127 
128  const Point origin(0,0,torusZ ,telCS);
129  const Vector inwards(0,0,-1,telCS);
130 
131  TCanvas* canvas = new TCanvas("torus");
132 
133  const int n = 100000;
134  int count = 0;
135  TPolyMarker3D* poly = new TPolyMarker3D(n*4);
136 
137 
138  for (int i=0; i<n; ++i) {
139 
140  const double phi = RandFlat::shoot(&theRandomEngine->GetEngine(), phiMin, phiMax);
141  const double dist = RandFlat::shoot(&theRandomEngine->GetEngine(), distMin, distMax);
142 
143  const utl::Point point(dist*cos(phi), dist*sin(phi), 3.*tubeRadius, telCS);
144 
145  //const double phi2 = RandFlat::shoot(&theRandomEngine->GetEngine(), phiMin, phiMax);
146  //const double theta = RandFlat::shoot(&theRandomEngine->GetEngine(), thetaMin, thetaMax);
147 
148  //const utl::Vector dir(sin(theta)*cos(phi2), sin(theta)*sin(phi2), -cos(theta), telCS);
149  const utl::Vector dir(0, 0, -1., telCS);
150 
151  Photon phot(point, dir, 1, 1, 1);
152 
154  TelescopeSimulatorKG2::RTFunctions::Torus(origin, inwards, torusRadius, tubeRadius, phot, intersections);
155 
156  if (intersections.size()==0)
157  continue;
158 
159  if (intersections.size() != 2 && intersections.size() != 4 ) {
160  cout << " s=" << intersections.size() << endl;
161  }
162 
163  unsigned int indexOfSmallestZ = 4; // maximum number of intersections is 4 (0 to 3)
164  double smallestZ = 10*tubeRadius/m; // definitely outside the torus and outside the telescope
165  for (unsigned int j=0; j<intersections.size(); ++j) {
166 
167  const double tmp_x = intersections[j].first.GetPosition().GetX(telCS);
168  const double tmp_y = intersections[j].first.GetPosition().GetY(telCS);
169  const double tmp_r = sqrt(tmp_x*tmp_x + tmp_y*tmp_y);
170  const double tmp_z = intersections[j].first.GetPosition().GetZ(telCS);
171 
172  if( tmp_r/m < 1.1*m && tmp_r/m > 0.85*m && tmp_z/m < smallestZ/m ) {
173  smallestZ = tmp_z/m;
174  indexOfSmallestZ = j;
175  }
176  poly->SetPoint(count++, tmp_x, tmp_y, tmp_z);
177 
178  }
179  if (indexOfSmallestZ < 4) {
180  const double tmpx = intersections[indexOfSmallestZ].first.GetPosition().GetX(telCS);
181  const double tmpy = intersections[indexOfSmallestZ].first.GetPosition().GetY(telCS);
182  const double tmpz = intersections[indexOfSmallestZ].first.GetPosition().GetZ(telCS);
183  const double tmpr = sqrt(tmpx*tmpx + tmpy*tmpy);
184 
185  cout << "lenspoint " << tmpx/mm << " "
186  << tmpy/mm << " "
187  << tmpz/mm << " "
188  << tmpr/mm << endl;
189  /* poly->SetPoint(count++,
190  intersections[indexOfSmallestZ].first.GetPosition().GetX(telCS),
191  intersections[indexOfSmallestZ].first.GetPosition().GetY(telCS),
192  intersections[indexOfSmallestZ].first.GetPosition().GetZ(telCS));
193  */
194  }
195 
196  }
197 
198  canvas->cd();
199  poly->Draw();
200 
201  canvas->SaveAs("torus.C");
202  canvas->SaveAs("torus.eps");
203 
204  return eSuccess;
205 } // end of Run
206 
207 
210 {
211  cout << " Finish TestTorus " << endl;
212 
213  return eSuccess;
214 }
215 
216 // Configure (x)emacs for this file ...
217 // Local Variables:
218 // mode: c++
219 // compile-command: "cd $AUGER_BASE && make"
220 // End:
std::vector< PhotonNormalPair > IntersectionList
Definition: /RTFunctions.h:47
void Update(const utl::TimeStamp &time, const bool invData=true, const bool invComp=true, const bool forceRadio=false)
Update detector: deletes currently constructed stations and sets new time.
Definition: Detector.cc:179
constexpr double mm
Definition: AugerUnits.h:113
Point object.
Definition: Point.h:32
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Definition: TestTorus.cc:90
RandomEngineType & GetEngine()
Definition: RandomEngine.h:32
EyeIterator EyesBegin(const FDetComponentSelector::Type type=FDetComponentSelector::ePhysical) const
iterator pointing to first eye of given type (ePhysical, eVirtual, eAll)
Definition: FDetector.h:72
Detector description interface for Eye-related data.
Definition: FDetector/Eye.h:45
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
constexpr double deg
Definition: AugerUnits.h:140
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
Wraps the random number engine used to generate distributions.
Definition: RandomEngine.h:27
TelescopeIterator TelescopesBegin() const
Beginning of the collection of telescopes.
Definition: FDetector/Eye.h:79
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
const fdet::FDetector & GetFDetector() const
Definition: Detector.cc:131
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Definition: TestTorus.cc:99
Detector description interface for Telescope-related data.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Vector object.
Definition: Vector.h:30
constexpr double m
Definition: AugerUnits.h:121
void Torus(const utl::Point &origin, const utl::Vector &inwards, const double torusRadius, const double tubeRadius, const utl::Photon &photonIn, IntersectionList &intersections)
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
Definition: TestTorus.cc:209

, generated on Tue Sep 26 2023.