AiresShowerFileParticleIterator.cc
Go to the documentation of this file.
1 
8 #include <io/AiresShowerFileParticleIterator.h>
9 
10 #include <io/AiresShowerFile.h>
11 #include <io/AiresUtilities.h>
12 #include <io/AiresWrapper.h>
13 using namespace io;
14 
15 #include <evt/ShowerSimData.h>
16 using namespace evt;
17 
18 #include <utl/AugerUnits.h>
19 #include <utl/AugerException.h>
20 #include <utl/CoordinateSystem.h>
21 #include <utl/ErrorLogger.h>
22 #include <utl/MathConstants.h>
23 #include <utl/Point.h>
24 #include <utl/Vector.h>
25 using namespace utl;
26 
27 #include <boost/tuple/tuple.hpp>
28 #include <boost/tuple/tuple_io.hpp>
29 
30 #include <cmath>
31 #include <iostream>
32 #include <sstream>
33 
34 using namespace std;
35 
38  fFile(theFile),
39  fCurrentParticle(utl::Particle::eUndefined,
40  utl::Particle::eShower,
41  utl::Point(0.0, 0.0, 0.0,
42  CoordinateSystem::GetRootCoordinateSystem()),
43  utl::Vector(0.0, 0.0, 0.0,
44  CoordinateSystem::GetRootCoordinateSystem()),
45  utl::TimeInterval(0.0),
46  0.0),
47  fChannel(theFile.fChannel),
48  fVerbosity(theFile.fVerbosity),
49  fIrc(theFile.fIrc),
50  fHeadOfList(-1), fEndOfList(-1),
51  fAltType(theFile.fAltType),
52  fGroundParticleCodeIndex(theFile.fGroundParticleCodeIndex),
53  fLogRIndex(theFile.fLogRIndex),
54  fLogEIndex(theFile.fLogEIndex),
55  fThetaIndex(theFile.fThetaIndex),
56  fUxIndex(theFile.fUxIndex),
57  fUyIndex(theFile.fUyIndex),
58  fTimeIndex(theFile.fTimeIndex),
59  fWeightIndex(theFile.fWeightIndex),
60  fCurrentRecordNumber(-1),
61  fIteratorValid(false) {
62 
63  fHeadOfList = fFile.fCurrentShowerLocation->second.first + 1;
64  fEndOfList = fFile.fCurrentShowerLocation->second.second;
65 
66  for (unsigned int i = 0; i < 99; ++i) {
67 
68  fIntData[i] = 0;
69  fDoubleData[i] = 0.0;
70 
71  }
72 
74 
75 }
76 
78 
79 }
80 
82 
83  if (!fIteratorValid)
84  throw IOFailureException("AiresShowerFileParticleIterator not valid.");
85 
87 
88  int recordNumber = fCurrentRecordNumber - 1;
89  AiresWrapper::crogotorec(&fChannel, &recordNumber, &fVerbosity, &fIrc);
90 
92  &fAltType, &fVerbosity, &fIrc)) {
93 
94  ERROR("Error attempting to retrieve record from AIRES file.");
95  fIteratorValid = false;
96  return NULL;
97 
98  }
99 
100  if (fIrc != 0 && fIrc != 1 && fIrc != 2) {
101 
103  return GetOneParticle(cs);
104 
105  }
106 
107  const double r = pow(10.0, fDoubleData[fLogRIndex])*m;
108  const double theta = fDoubleData[fThetaIndex]*rad;
109  const double z = 0.0;
110 
111  const double pX = fDoubleData[fUxIndex];
112  const double pY = fDoubleData[fUyIndex];
113  const double pZ2 = 1.0 - pX*pX - pY*pY;
114  const double pZ = pZ2 > 0 ? -sqrt(pZ2) : 0.0;
115 
119  Point(r*cos(theta), r*sin(theta), z, cs),
120  Vector(pX, pY, pZ, cs),
123  pow(10.0, fDoubleData[fLogEIndex])*GeV);
124 
126 
127  return &fCurrentParticle;
128 
129  }
130 
131  fIteratorValid = false;
132  return NULL;
133 
134 }
135 
137 
139 
142 
143  fIteratorValid = true;
144 
145 }
146 
149  const CoordinateSystemPtr& theCoordinateSystem)
150 {
151  const double angle = io::Aires::AiresAzimuthToAuger(0.0*deg);
152 
153  return CoordinateSystem::RotationZ(angle, theCoordinateSystem);
154 }
155 
156 
157 // Configure (x)emacs for this file ...
158 // Local Variables:
159 // mode:c++
160 // compile-command: "make -C .. -k check"
161 // End:
int AiresToPDG(int theAiresCode)
Convert AIRES particle code to PDG.
Point object.
Definition: Point.h:32
static int crorecnumber(int *channel, int *vrb, int *irc)
Describes a particle for Simulation.
Definition: Particle.h:26
constexpr double rad
Definition: AugerUnits.h:137
double fGeomagneticFieldDeclination
Constructors for Transformer classes.
DataLocationsType::iterator fCurrentShowerLocation
virtual void Rewind()
Rewind the particle list in the shower file to the beginning.
double pow(const double x, const unsigned int i)
Base class to report exceptions in IO.
constexpr double deg
Definition: AugerUnits.h:140
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
const double ns
double AiresAzimuthToAuger(const double airesAzimuth)
Returns the azimuth rotated from AIRES&#39;s system to Auger standard.
static bool crogotorec(int *channel, int *recnumber, int *vrb, int *irc)
virtual utl::Particle * GetOneParticle(const utl::CoordinateSystemPtr &cs)
Member function to fetch the next particle.
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
constexpr double GeV
Definition: AugerUnits.h:187
Vector object.
Definition: Vector.h:30
static double kMagneticFieldDeclination
Utility to open an Aires generated shower file on disc.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
constexpr double m
Definition: AugerUnits.h:121
virtual utl::CoordinateSystemPtr ComputeExternalShowerCoordinateSystem(const utl::CoordinateSystemPtr &ptr)
Compute the coordinate system for the ground particle file.
static bool getcrorecord(int *channel, int *intfields, double *realfields, bool *altrec, int *vrb, int *irc)

, generated on Tue Sep 26 2023.