11 #include <evt/Event.h>
12 #include <evt/ShowerRecData.h>
13 #include <evt/ShowerRRecData.h>
14 #include <evt/ShowerSimData.h>
15 #include <evt/BeamMap.h>
16 #include <revt/REvent.h>
17 #include <revt/Header.h>
18 #include <revt/Station.h>
19 #include <revt/StationRecData.h>
21 #include <det/Detector.h>
22 #include <rdet/RDetector.h>
24 #include <utl/Trace.h>
25 #include <utl/TraceAlgorithm.h>
26 #include <utl/ErrorLogger.h>
27 #include <utl/Reader.h>
28 #include <utl/config.h>
29 #include <utl/AugerUnits.h>
30 #include <utl/Triple.h>
31 #include <utl/PhysicalConstants.h>
33 #include <fwk/CoordinateSystemRegistry.h>
34 #include <fwk/LocalCoordinateSystem.h>
35 #include <fwk/CentralConfig.h>
45 #define PRINT(...) {stringstream msg; msg << __VA_ARGS__; INFO(msg.str());}
53 RdPolarGrid::~RdPolarGrid()
67 conf.
GetChild(
"UseStepFromTrueDirection").
GetData(fUseStepFromTrueDirection);
70 conf.
GetChild(
"NumberOfStepsFromTrueDirection").
GetData(fNumberOfStepsFromTrueDirection);
98 if (minTh == maxTh && minTh == 0) {
102 if (minPhi == maxPhi)
106 if (minRho == maxRho)
114 bool RdPolarGrid::step(){
117 if (!fUseTrueDirection) {
119 if (waveModel ==
"ePlane") {
121 if (minPhi==0 && maxPhi==360)
122 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi-1) || (iPhi=0) || (++iTh<=nTh);
124 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi) || (iPhi=0) || (++iTh<=nTh);
127 else if (waveModel ==
"eSpherical") {
129 if (minPhi==0 && maxPhi==360)
130 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi-1) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) || (++iR<=nR);
132 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) || (++iR<=nR);
135 else if (waveModel ==
"eConical") {
137 if (minPhi==0 && maxPhi==360)
138 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi-1) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) || (++iRho<=nRho);
140 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) || (++iRho<=nRho);
143 else if (waveModel ==
"eHyperbolic") {
145 if (minPhi==0 && maxPhi==360)
146 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi-1) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) ||
147 (++iRho<=nRho) || (iRho=0) || (++iB<=nB);
149 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) ||
150 (++iRho<=nRho) || (iRho=0) || (++iB<=nB);
154 if (!fUseStepFromTrueDirection) {
155 if (waveModel ==
"ePlane")
157 else if (waveModel ==
"eSpherical")
159 else if (waveModel ==
"eConical")
160 return (++iRho<=nRho);
161 else if (waveModel ==
"eHyperbolic")
162 return (++iRho<=nRho) || (iRho=0) || (++iB<=nB);
165 if (waveModel ==
"ePlane") {
166 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi) || (iPhi=0) || (++iTh<=nTh);
168 else if (waveModel ==
"eSpherical") {
169 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) || (++iR<=nR);
171 else if (waveModel ==
"eConical") {
172 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) || (++iRho<=nRho);
174 else if (waveModel ==
"eHyperbolic") {
175 return (minTh==0 && iTh==0 && ++iTh<=nTh) || (++iPhi<=nPhi) || (iPhi=0) || (++iTh<=nTh) || (iTh=0) ||
176 (++iRho<=nRho) || (iRho=0) || (++iB<=nB);
185 event.MakeRecShower();
186 INFO (
"Making RecShower");
190 event.GetRecShower().MakeRRecShower();
191 INFO (
"Making RRecShower");
231 return event.GetRecShower().GetRRecShower();
246 evt::BeamGrid &thetaGrid = *
new evt::BeamGrid ( minTh*M_PI/180.0, maxTh*M_PI/180.0, (maxTh-minTh)/nTh*M_PI/180.0);
247 evt::BeamGrid &phiGrid = *
new evt::BeamGrid ( minPhi*M_PI/180.0, maxPhi*M_PI/180.0, (maxPhi-minPhi)/nTh*M_PI/180.0);
254 if (rrec.HasCurrentBeamMap())
255 map = &rrec.GetCurrentBeamMap();
257 map =
new evt::BeamMap();
258 rrec.AddBeamMap(*map);
260 map->AddDimension(thetaGrid);
261 map->AddDimension(phiGrid);
266 double th, phi, r, rho,
b;
268 if (!fUseTrueDirection) {
270 th=minTh+iTh*(maxTh-minTh)/nTh;
271 phi=minPhi+iPhi*(maxPhi-minPhi)/nPhi;
273 if (waveModel ==
"ePlane") {
275 Vector skyVec (r*
km, th*
degree, phi*degree, coreCS, Vector::kSpherical);
281 else if (waveModel ==
"eSpherical") {
282 r=minR+iR*(maxR-minR)/nR;
283 Vector skyVec (r*
km, th*
degree, phi*degree, coreCS, Vector::kSpherical);
289 else if (waveModel ==
"eConical") {
290 rho = minRho+iRho*(maxRho-minRho)/nRho;
294 Vector skyVec (r*
km, th*
degree, phi*degree, coreCS, Vector::kSpherical);
300 else if (waveModel ==
"eHyperbolic") {
301 rho = minRho+iRho*(maxRho-minRho)/nRho;
302 b = minB+iB*(maxB-minB)/nB;
305 rrec.SetParameter(eB, b*
ns);
307 Vector skyVec (r*
km, th*
degree, phi*degree, coreCS, Vector::kSpherical);
315 if (!fUseStepFromTrueDirection) {
319 const utl::Triple polarCoords = trueDirection.GetSphericalCoordinates(coreCS);
320 double true_th = polarCoords.get<1>();
321 double true_phi = polarCoords.get<2>();
323 if (waveModel ==
"ePlane") {
325 Vector skyVec (-r*
km, true_th, true_phi, coreCS, Vector::kSpherical);
326 const utl::Triple skyCoords = skyVec.GetSphericalCoordinates(coreCS);
327 double sky_r = skyCoords.get<0>();
328 double sky_th = skyCoords.get<1>();
329 double sky_phi = skyCoords.get<2>();
335 else if (waveModel ==
"eSpherical") {
336 r=minR+iR*(maxR-minR)/nR;
337 Vector skyVec (-r*
km, true_th, true_phi, coreCS, Vector::kSpherical);
338 const utl::Triple skyCoords = skyVec.GetSphericalCoordinates(coreCS);
339 double sky_r = skyCoords.get<0>();
340 double sky_th = skyCoords.get<1>();
341 double sky_phi = skyCoords.get<2>();
347 else if (waveModel ==
"eConical") {
349 rho = minRho+iRho*(maxRho-minRho)/nRho;
352 Vector skyVec (-r*
km, true_th, true_phi, coreCS, Vector::kSpherical);
353 const utl::Triple skyCoords = skyVec.GetSphericalCoordinates(coreCS);
354 double sky_r = skyCoords.get<0>();
355 double sky_th = skyCoords.get<1>();
356 double sky_phi = skyCoords.get<2>();
363 else if (waveModel ==
"eHyperbolic") {
365 rho = minRho+iRho*(maxRho-minRho)/nRho;
366 b = minB+iB*(maxB-minB)/nB;
369 rrec.SetParameter(eB, b*
ns);
370 Vector skyVec (-r*
km, true_th, true_phi, coreCS, Vector::kSpherical);
371 const utl::Triple skyCoords = skyVec.GetSphericalCoordinates(coreCS);
372 double sky_r = skyCoords.get<0>();
373 double sky_th = skyCoords.get<1>();
374 double sky_phi = skyCoords.get<2>();
385 const utl::Triple polarCoords = trueDirection.GetSphericalCoordinates(coreCS);
386 double true_th = polarCoords.get<1>();
387 double true_phi = polarCoords.get<2>();
390 Vector skyVec (-r*
km, true_th, true_phi, coreCS, Vector::kSpherical);
391 const utl::Triple skyCoords = skyVec.GetSphericalCoordinates(coreCS);
392 double sky_r = skyCoords.get<0>()/km;
393 double sky_th = skyCoords.get<1>()/
degree;
394 double sky_phi = skyCoords.get<2>()/
degree;
396 minTh = sky_th - fStepFromTrueDirection;
397 maxTh = sky_th + fStepFromTrueDirection;
398 minPhi = sky_phi - fStepFromTrueDirection;
399 maxPhi = sky_phi + fStepFromTrueDirection;
400 nTh = 2*fNumberOfStepsFromTrueDirection;
401 nPhi = 2*fNumberOfStepsFromTrueDirection;
403 th=minTh+iTh*(maxTh-minTh)/nTh;
404 phi=minPhi+iPhi*(maxPhi-minPhi)/nPhi;
406 if (waveModel ==
"ePlane") {
408 Vector skyVec (r*km, th*
degree, phi*degree, coreCS, Vector::kSpherical);
414 else if (waveModel ==
"eSpherical") {
415 r=minR+iR*(maxR-minR)/nR;
416 Vector skyVec (r*km, th*
degree, phi*degree, coreCS, Vector::kSpherical);
422 else if (waveModel ==
"eConical") {
423 rho = minRho+iRho*(maxRho-minRho)/nRho;
427 Vector skyVec (r*km, th*
degree, phi*degree, coreCS, Vector::kSpherical);
433 else if (waveModel ==
"eHyperbolic") {
434 rho = minRho+iRho*(maxRho-minRho)/nRho;
435 b = minB+iB*(maxB-minB)/nB;
438 rrec.SetParameter(eB, b*
ns);
440 Vector skyVec (r*km, th*
degree, phi*degree, coreCS, Vector::kSpherical);
467 WARNING(
"RdPolarGrid::No radio event found!");
471 REvent& rEvent =
event.GetREvent();
474 int id = rHeader.
GetId();
475 PRINT (
"Found header with ID " <<
id);
477 static int oldEvt = 0;
480 WARNING (
"Attempt to step out of scanned sky cube.");
489 Vector skyVec = skyVector(event);
491 setRRecDirection (skyVec, event);
497 RdPolarGrid::Finish()
Branch GetTopBranch() const
void SetParameter(Parameter i, double value, bool lock=true)
bool HasRecShower() const
Interface class to access to the Radio part of an event.
ShowerRecData & GetRecShower()
Interface class to access to the RD Reconstruction of a Shower.
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Interface class to access Shower Simulated parameters.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
boost::tuple< double, double, double > Triple
Coordinate triple for easy getting or setting of coordinates.
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
#define DEBUGLOG(message)
Macro for logging debugging messages.
const utl::Point & GetPosition() const
Get the position of the shower core.
bool HasRRecShower() const
Header & GetHeader()
access to REvent Header
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
double GetY(const CoordinateSystemPtr &coordinateSystem) const
ResultFlag
Flag returned by module methods to the RunController.
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.