RdAirplaneArrivalDirectionSetter.cc
Go to the documentation of this file.
2 #include "Ads_bDataBase.h"
3 #include "Airplane.h"
4 #include "Flight.h"
5 
6 using namespace evt;
7 using namespace revt;
8 using namespace std;
9 using namespace utl;
10 using namespace fwk;
11 using namespace RdAirplane;
12 using namespace boost;
13 using namespace det;
14 namespace fs = boost::filesystem;
15 
16 RdAirplaneArrivalDirectionSetter::RdAirplaneArrivalDirectionSetter() :
17  _ads_bDataBase_(NULL) {}
18 
20 
22  Detector& detector = Detector::GetInstance();
24  string eventAirplaneAssociationFile;
25  CentralConfig* centralConfig = CentralConfig::GetInstance();
26  Branch directionSetterTopBranch = centralConfig->GetTopBranch("RdAirplaneArrivalDirectionSetter");
27  directionSetterTopBranch.GetChild("AirplaneEventAssociationFile").GetData(eventAirplaneAssociationFile);
28  INFO("Loading event ids and associated airplane ids from file " + eventAirplaneAssociationFile);
29  if(!_readInEventAirplaneAssociations(eventAirplaneAssociationFile)) {
30  ERROR("Could not load event-airplane-associations.");
31  return eFailure;
32  }
33 
35 
36  return eSuccess;
37 }
38 
39 
41  evt::Header& header = event.GetHeader();
42  EventIdToEventInfoMap::iterator iter = _eventAirplaneAssociation_.find(header.GetId());
43  if(iter==_eventAirplaneAssociation_.end()) {
44  INFO("Event is not from an airplane");
45  return eContinueLoop;
46  }
47  const EventInfo& eventInfo = iter->second;
48  Airplane* airplane=_ads_bDataBase_->getAirplaneById(eventInfo.airplaneId);
49  if(airplane==NULL) {
50  INFO("No airplane with the right id found.");
51  return eContinueLoop;
52  }
53  const TimeStamp& time = header.GetTime();
54  Flight* flight = airplane->getFlight(time);
55  if(flight==NULL) {
56  INFO("Airplane was not over the AERA field at that time.");
57  return eContinueLoop;
58  }
59  Point* airplanePosition = flight->getPosition(time);
60  if(airplanePosition==NULL) {
61  INFO("No position data for airplane at that time.");
62  return eContinueLoop;
63  }
64  REvent& radioEvent = event.GetREvent();
65  const det::Detector& detector = det::Detector::GetInstance();
66  const rdet::RDetector& radioDetector = detector.GetRDetector();
67 
68  for (REvent::StationIterator stationIter = radioEvent.StationsBegin(); stationIter != radioEvent.StationsEnd(); ++stationIter) {
69  Station& station = *stationIter;
70  const rdet::Station& radioStation = radioDetector.GetStation(station);
71  const CoordinateSystemPtr stationCS = radioStation.GetLocalCoordinateSystem();
72  StationRecData& recData = station.GetRecData();
73  recData.SetParameter(eSignalArrivalDirectionX, airplanePosition->GetX(stationCS));
74  recData.SetParameter(eSignalArrivalDirectionY, airplanePosition->GetY(stationCS));
75  recData.SetParameter(eSignalArrivalDirectionZ, airplanePosition->GetZ(stationCS));
76  }
77 
78  const Point& coreCoordinates = eventInfo.coreCoordinates;
79  utl::CoordinateSystemPtr coreCoordinateSystem = LocalCoordinateSystem::Create(coreCoordinates);
80  double coreX = coreCoordinates.GetX(_globalCoordinateSystem_);
81  double coreY = coreCoordinates.GetY(_globalCoordinateSystem_);
82  double coreZ = coreCoordinates.GetZ(_globalCoordinateSystem_);
83  ShowerRRecData& showerRRecData = event.GetRecShower().GetRRecShower();
84  showerRRecData.SetParameter(eCoreX, coreX);
85  showerRRecData.SetParameter(eCoreY, coreY);
86  showerRRecData.SetParameter(eCoreZ, coreZ);
87  showerRRecData.SetParameter(eShowerAxisX, airplanePosition->GetX(coreCoordinateSystem));
88  showerRRecData.SetParameter(eShowerAxisY, airplanePosition->GetY(coreCoordinateSystem));
89  showerRRecData.SetParameter(eShowerAxisZ, airplanePosition->GetZ(coreCoordinateSystem));
90 
91  showerRRecData.SetParameter(eRecStage, ShowerRRecData::kSphericalWaveFitVarC);
92 
93 
94 
95  return eSuccess;
96 }
97 
98 
100  return eSuccess;
101 }
102 
104  fs::path pathToFile = fs::path(pFile);
105  if(!fs::exists(pathToFile)) {
106  return false;
107  }
108  ifstream file(pFile.c_str());
109  try {
110  if(!file.is_open())
111  return false;
112  string line;
113  while(getline(file,line)) {
114  if(line.empty() || line==" ")
115  continue;
116  string eventId;
117  string airplaneId;
118  double coreX = 0.0;
119  double coreY = 0.0;
120  double coreZ = 0.0;
121  stringstream lineAsStream(line);
122  lineAsStream >> eventId;
123  lineAsStream >> airplaneId;
124  lineAsStream >> coreX;
125  lineAsStream >> coreY;
126  lineAsStream >> coreZ;
127  _eventAirplaneAssociation_.insert(make_pair(eventId,EventInfo(eventId,airplaneId,Point(coreX,coreY,coreZ,_globalCoordinateSystem_))));
128  }
129  } catch(...) {
130  file.close();
131  throw;
132  }
133  file.close();
134  return true;
135 }
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger reference system centered on the station.
Class to access station level reconstructed data.
void SetParameter(Parameter i, double value, bool lock=true)
Point object.
Definition: Point.h:32
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Report success to RunController.
Definition: VModule.h:62
Detector description interface for Station-related data.
StationRecData & GetRecData()
Get station level reconstructed data.
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
utl::Point * getPosition(const utl::TimeStamp &pTime, Ads_bEvent::AltitudeType pAltitudeType) const
Definition: Flight.cc:186
Skip remaining modules in the current loop and continue with next iteration of the loop...
Definition: VModule.h:68
Interface class to access to the RD Reconstruction of a Shower.
Flight * getFlight(const utl::TimeStamp &pTime) const
Definition: Airplane.cc:44
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
StationIterator StationsEnd()
Definition: REvent.h:130
StationIterator StationsBegin()
Definition: REvent.h:128
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
boost::filter_iterator< StationFilter, AllStationIterator > StationIterator
Iterator over all (non-exculded) stations.
Definition: REvent.h:125
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
const utl::TimeStamp & GetTime() const
Definition: Event/Header.h:33
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
char * exists
Definition: XbArray.cc:12
Class representing a document branch.
Definition: Branch.h:107
class to hold data at the radio Station level.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
const string file
const std::string & GetId() const
Get the event identifier.
Definition: Event/Header.h:31
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
utl::CoordinateSystemPtr GetReferenceCoordinateSystem() const
Get the reference coordinate system used for analysis (usually PampaAmarilla for Auger) ...
Definition: Detector.h:141
void SetParameter(Parameter i, double value, bool lock=true)
static Ads_bDataBase * getSharedDataBase()
Report failure to RunController, causing RunController to terminate execution.
Definition: VModule.h:64
Main configuration utility.
Definition: CentralConfig.h:51
Airplane * getAirplaneById(const std::string &pId)
const rdet::RDetector & GetRDetector() const
Definition: Detector.cc:143
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Global event header.
Definition: Event/Header.h:27

, generated on Tue Sep 26 2023.