1 #include <fwk/CentralConfig.h>
2 #include <utl/Reader.h>
3 #include <utl/ErrorLogger.h>
4 #include <utl/Reader.h>
5 #include <fwk/VModule.h>
6 #include <fwk/MagneticFieldModel.h>
9 #include <evt/ShowerRecData.h>
10 #include <evt/ShowerSRecData.h>
12 #include <revt/Station.h>
14 #include <utl/TimeStamp.h>
15 #include <utl/AugerUnits.h>
16 #include <det/Detector.h>
17 #include <rdet/RDetector.h>
19 #include <fwk/LocalCoordinateSystem.h>
20 #include <fwk/CoordinateSystemRegistry.h>
25 #include <utl/Point.h>
26 #include <utl/UTMPoint.h>
27 #include <utl/ReferenceEllipsoid.h>
46 RdCOREASSimulationCreator::~RdCOREASSimulationCreator()
52 INFO(
"RdCOREASSimulationCreator::Init()");
54 Branch topBranch = CentralConfig::GetInstance()->
GetTopBranch(
"RdCOREASSimulationCreator");
67 if (curmodel.GetName() ==
"Shower") {
70 if(curp.GetName() ==
"CorsikaDirectory") {
73 if(curp.GetName() ==
"CorsikaBinary") {
76 if(curp.GetName() ==
"FlukaDirectory") {
79 if(curp.GetName() ==
"DataDirectory") {
82 if(curp.GetName() ==
"Run") {
83 curp.GetData(shower->
Run);
85 if(curp.GetName() ==
"Seed1") {
86 curp.GetData(shower->
Seed1);
88 if(curp.GetName() ==
"Seed2") {
89 curp.GetData(shower->
Seed2);
91 if(curp.GetName() ==
"Seed3") {
92 curp.GetData(shower->
Seed3);
94 if(curp.GetName() ==
"REASSeed") {
97 if(curp.GetName() ==
"PrimaryParticle") {
100 if(curp.GetName() ==
"Energy") {
101 curp.GetData(shower->
Energy);
103 if(curp.GetName() ==
"Zenith") {
104 curp.GetData(shower->
Zenith);
106 if(curp.GetName() ==
"Azimuth") {
109 if(curp.GetName() ==
"CoreX") {
110 curp.GetData(shower->
CoreX);
112 if(curp.GetName() ==
"CoreY") {
113 curp.GetData(shower->
CoreY);
115 if(curp.GetName() ==
"CoreZ") {
116 curp.GetData(shower->
CoreZ);
118 if(curp.GetName() ==
"UTCDate") {
120 cout <<
"DATE: " << shower->
UTCDate << endl;
134 cout <<
"Starting simulation creator" << endl;
138 cout <<
"test" << endl;
139 event.MakeRecShower();
140 event.GetRecShower().MakeSRecShower();
142 Detector& Det = Detector::GetInstance();
145 const CoordinateSystemPtr coordsys = det::Detector::GetInstance().GetReferenceCoordinateSystem();
148 double coreX = (*fShowerIterator)->CoreX *
m;
149 double coreY = (*fShowerIterator)->CoreY *
m;
150 double coreZ = (*fShowerIterator)->CoreZ *
m;
151 int eventid = (*fShowerIterator)->Run;
152 double energy = (*fShowerIterator)->Energy;
153 double theta = (*fShowerIterator)->Zenith;
154 double phi = (*fShowerIterator)->Azimuth;
158 Point core(coreX,coreY,coreZ,coordsys);
159 cout <<
"X : " << core.
GetX(coordsys)/
m <<
" Y: " << core.
GetY(coordsys)/
m <<
" Z : " << core.
GetZ(coordsys)/
m << endl;
162 utl::Vector axis(cos(phi)*sin(theta), sin(phi)*sin(theta), cos(theta),coordsys);
165 Header& head =
event.GetHeader();
166 stringstream ev_id(
"");
168 head.
SetId(ev_id.str().c_str());
170 double date = (*fShowerIterator)->UTCDate;
171 cout << (*fShowerIterator)->UTCDate <<
" " << date << endl;
173 const int kGPSEpoch = 315964815;
174 TimeStamp ts((*fShowerIterator)->UTCDate - kGPSEpoch, 0);
176 det::Detector::GetInstance().Update(head.
GetTime());
183 filename << setw(6) << setfill(
'0');
184 filename << (*fShowerIterator)->Run <<
".inp";
185 string corsikaparameterfile = filename.str();
186 ofstream inpfile(((*fShowerIterator)->DataDirectory +
"/" + filename.str()).c_str());
192 UTMPoint utmcore(core,ReferenceEllipsoid::GetWGS84());
195 inpfile <<
"RUNNR\t"<< (*fShowerIterator)->Run << endl;
196 inpfile <<
"EVTNR\t1" << endl;
200 inpfile <<
"SEED\t" << (*fShowerIterator)->Seed1 <<
"\t0\t0" << endl;
201 inpfile <<
"SEED\t" << (*fShowerIterator)->Seed2 <<
"\t0\t0" << endl;
202 inpfile <<
"SEED\t" << (*fShowerIterator)->Seed3 <<
"\t0\t0" << endl;
203 inpfile <<
"NSHOW\t1" << endl;
205 inpfile <<
"PRMPAR\t" << (*fShowerIterator)->PrimaryParticle << endl;
206 inpfile <<
"THETAP\t" << zen <<
"\t" << zen << endl;
207 inpfile <<
"PHIP\t"<< az <<
"\t" << az <<
"\n";
208 inpfile <<
"ECUTS\t3.000E-01\t3.000E-01\t4.010E-04\t4.010E-04\n";
209 inpfile <<
"ELMFLG\tT\tT\n";
210 inpfile <<
"THIN\t1.000E-06\t" << shower.
GetEnergy() /
GeV*1e-6 <<
"\t0.000E+00\n";
211 inpfile <<
"THINH\t1.000E+01\t1.000E+02\n";
212 inpfile <<
"OBSLEV\t"<< utmcore.GetHeight()/
cm << endl;
213 inpfile <<
"ECTMAP\t1.E5" << endl;
214 inpfile <<
"STEPFC\t1.0" << endl;
215 inpfile <<
"MUADDI\tT" << endl;
216 inpfile <<
"MUMULT\tT" << endl;
217 inpfile <<
"MAXPRT\t1" << endl;
218 inpfile <<
"MAGNET\t" << siteMagneticField->GetHorizontalComponent() /
microtesla <<
"\t" << siteMagneticField->GetHorizontalComponent() /
microtesla << endl;
219 inpfile <<
"ATMOD\t0\tF" << endl;
220 inpfile <<
"PAROUT\tF\tF" << endl;
221 inpfile <<
"LONGI\tT\t5.\tT\tT" << endl;
222 inpfile <<
"RADNKG\t5.e5" << endl;
223 inpfile <<
"DIRECT\t" << (*fShowerIterator)->DataDirectory <<
"/" << endl;
224 inpfile <<
"DATBAS\tF" << endl;
233 filename << setw(6) << setfill(
'0');
234 filename << (*fShowerIterator)->Run <<
".reas";
235 ofstream reasfile(((*fShowerIterator)->DataDirectory +
"/" + filename.str()).c_str());
238 reasfile <<
"# global parameters:\n";
239 reasfile <<
"ParameterFileVersion = 22 ; do not change manually\n";
240 reasfile <<
"NumParticlesToCalculate = 10000000000\n";
241 reasfile <<
"NumSimultaneousParticles = 1000000\n";
242 reasfile <<
"RandomSeed = " << (*fShowerIterator)->REASSeed <<
" ; -1: chosen randomly, other: chosen manually\n";
243 reasfile <<
"AtmosphereModel = 0 ; 0: US Standard, 10: Argentina Winter, 20: Europe January, 30: South Pole March, 90: Constant Density\n";
244 reasfile <<
"CurvedGeometry = 0\n";
245 reasfile <<
"EarthRadius = 637131500 ; in cm, only used if Curved = 1\n";
248 reasfile <<
"\n# parameters setting up the spatial observer configuration:\n\n";
250 reasfile <<
"CoreCoordinateNorth = 0 ; in cm\n";
251 reasfile <<
"CoreCoordinateWest = 0 ; in cm\n";
252 reasfile <<
"CoreCoordinateVertical = " << utmcore.GetHeight() /
cm<<
" ; in cm\n";
255 reasfile<<
"\n# parameters setting up the temporal observer configuration:\n\n";
257 reasfile<<
"TimeLowerBoundary = -1 ; in s, only if AutomaticTimeBoundaries set to 0\n";
258 reasfile<<
"TimeUpperBoundary = 1 ; in s, only if AutomaticTimeBoundaries set to 0\n";
259 reasfile<<
"TimeResolution = 2e-10 ; in s\n";
260 reasfile<<
"GroundLevelRefractiveIndex = 1.000292 ; specify refractive index at 0 m asl\n";
263 reasfile<<
"\n# parameters setting the optimisation strategies:\n\n";
265 reasfile<<
"AutomaticTimeBoundaries = 4e-07 ; 0: off, x: automatic boundaries with width x in s\n";
266 reasfile<<
"ResolutionReductionScale = 5000 ; 0: off, x: decrease time resolution linearly every x cm in radius\n";
267 reasfile<<
"AutomaticLambdaEnlargementToggle = 1\n";
268 reasfile<<
"AutomaticBinInactivationToggle = 1\n";
269 reasfile<<
"ComparisonLowestFrequency = 0 ; in Hz, for automatic groundbin inactivation\n";
270 reasfile<<
"ComparisonHighestFrequency = 100000000 ; in Hz, for automatic groundbin inactivation\n";
271 reasfile<<
"RequiredRelativePrecision = 0.001 ; in case of automatic groundbin inactivation\n";
272 reasfile<<
"SufficientDynamicRange = 0.001 ; in case of automatic groundbin inactivation\n";
273 reasfile<<
"NumPrecisionComparisons = 5 ; in case of automatic groundbin inactivation\n";
274 reasfile<<
"TrajectoryPointsPerUnitPathDepth = 0\n";
277 reasfile<<
"\n# general air shower related parameters:\n\n";
279 reasfile<<
"ShowerEvolutionClippingDistance = 100000 ; in cm\n";
280 reasfile<<
"MeanPathDepth = 0.05 ; in g/cm^2\n";
281 reasfile<<
"PathDepthProjectionToggle = 1 ; backproject path depths appropriately\n";
295 reasfile <<
"\n# parameters specific to CORSIKA based showers - other parameters are read from the CORSIKA input file:\n\n";
298 reasfile <<
"\nCorsikaFilePath = ./ ; path to the CORSIKA files (cannot include space characters!)\n";
299 reasfile <<
"CorsikaParameterFile = " << corsikaparameterfile <<
"; specify CORSIKA card file\n";
300 reasfile <<
"CorsikaSlantOptionToggle = 1 ; set to 1 if CORSIKA option SLANT is used\n";
301 reasfile <<
"SelectedCorsikaShower = 1 ; 0: averaged, i: i-th shower\n";
302 reasfile<<
"ShowerEvolutionShift = 0 ; apply slant depth shift to CORSIKA-derived shower evolution, in g/cm^2\n";
311 reasfile <<
"\n# parameters not used by REAS but needed for read-in to Offline\n";
313 reasfile <<
"EventNumber = "<< eventid <<
"\n";
319 reasfile <<
"RotationAngleForMagfieldDeclination = " << siteMagneticField->GetDeclination() /
degree <<
"; in degrees\n";
327 filename << setw(6) << setfill(
'0');
328 filename << (*fShowerIterator)->Run <<
".list";
329 ofstream reaslist(((*fShowerIterator)->DataDirectory +
"/" + filename.str()).c_str());
332 if (!rdIt->IsInGrid())
334 Point Position = rdIt->GetPosition();
335 Vector VecAntenna = Position - core;
337 double antX = Position.
GetX(coreCS);
338 double antY = Position.
GetY(coreCS);
339 double antZ = utmcore.GetHeight() + Position.
GetZ(coreCS);
340 double rotX = cos(siteMagneticField->GetDeclination()) * antX - sin(siteMagneticField->GetDeclination()) * antY;
341 double rotY = sin(siteMagneticField->GetDeclination()) * antX + cos(siteMagneticField->GetDeclination()) * antY;
343 reaslist <<
"AntennaPosition = "<< rotY /
cm <<
" " << -rotX /
cm <<
" " << antZ /
cm <<
" " << rdIt->GetName() << endl;
354 INFO(
"RdCOREASSimulationCreator::Finish()");
Branch GetTopBranch() const
boost::transform_iterator< InternalStationFunctor, InternalStationIterator, const Station & > StationIterator
StationIterator returns a pointer to a station.
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.
Report success to RunController.
Interface class to access to the SD Reconstruction of a Shower.
Class to hold and convert a point in geodetic coordinates.
StationIterator StationsEnd() const
End of the collection of pointers to commissioned stations.
CoordinateSystemPtr GetCoordinateSystem() const
Get the coordinate system of the current internal representation.
StationIterator StationsBegin() const
Beginning of the collection of pointers to commissioned stations.
#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.
int fInfoLevel
xml settings: info level (verbosity)
A TimeStamp holds GPS second and nanosecond for some event.
Detector description interface for RDetector-related data.
Branch GetNextSibling() const
Get next sibling of this branch.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Break current loop. It works for nested loops too!
double GetX(const CoordinateSystemPtr &coordinateSystem) const
void SetAxis(const utl::Vector &axis)
Top of the hierarchy of the detector description interface.
unsigned int PrimaryParticle
const utl::Vector & GetAxis() const
void GetData(bool &b) const
Overloads of the GetData member template function.
constexpr double microtesla
double GetY(const CoordinateSystemPtr &coordinateSystem) const
ResultFlag
Flag returned by module methods to the RunController.
unsigned long GetGPSSecond() const
GPS second.
double GetGPSNanoSecond() const
GPS nanosecond.
Get the magnetic field of the earth dependent on location and time.
TimeStamp GetCurrentSystemTime()
get current time as reported by system
const utl::Point & GetCorePosition() const
void SetCorePosition(const utl::Point &core)
const rdet::RDetector & GetRDetector() const
Branch GetFirstChild() const
Get first child of this Branch.
void SetEnergy(const double energy, const double error)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
vector< simparams * >::iterator fShowerIterator
vector< simparams * > fShowers