SdHorizontalEventSelector.cc
Go to the documentation of this file.
1 
11 
12 #include <fwk/CentralConfig.h>
13 
14 #include <det/Detector.h>
15 
16 #include <sdet/SDetector.h>
17 #include <sdet/Station.h>
18 
19 #include <evt/Event.h>
20 #include <evt/ShowerRecData.h>
21 #include <evt/ShowerSRecData.h>
22 
23 #include <sevt/SEvent.h>
24 #include <sevt/Station.h>
25 
26 #include <utl/Vector.h>
27 #include <utl/ErrorLogger.h>
28 #include <utl/Branch.h>
29 
30 using namespace fwk;
31 using namespace evt;
32 using namespace sevt;
33 using namespace utl;
34 using namespace std;
35 using namespace SdHorizontalEventSelectorHOG;
36 
37 
38 inline
39 double
40 Distance(const Point& p, const sdet::Station& s)
41 {
42  return (p - s.GetPosition()).GetMag();
43 }
44 
45 
46 inline
47 bool
49 {
50  return s.IsCandidate() ||
51  s.IsSilent() ||
56 }
57 
58 
59 inline
60 std::pair<int, std::vector<int>>
61 SdHorizontalEventSelector::CalculateT5HASTrigger(const Event& event)
62  const
63 {
64  const SEvent& sEvent = event.GetSEvent();
65 
66  const ShowerRecData& shRec = event.GetRecShower();
67  if (!shRec.HasSRecShower())
68  return make_pair(0U, vector<int>());
69 
70  const ShowerSRecData& shSRec = shRec.GetSRecShower();
71  const utl::Point& core = shSRec.GetCorePosition();
72 
73  SEvent::ConstStationIterator closestStation = sEvent.StationsEnd();
74  {
75  double closestDistance = 10000*meter;
76  for (SEvent::ConstStationIterator sIt = sEvent.StationsBegin();
77  sIt != sEvent.StationsEnd(); ++sIt) {
78  if (!IsActive(*sIt))
79  continue;
80 
81  const sdet::Station& ds = fSDetector->GetStation(*sIt);
82  const double distanceToCore = Distance(core, ds);
83  if (distanceToCore < closestDistance) {
84  closestDistance = distanceToCore;
85  closestStation = sIt;
86  }
87  }
88 
89  if (closestStation == sEvent.StationsEnd()) {
90  // this should never happen
91  ERROR("No station closest to core found");
92  return make_pair(0U, vector<int>());
93  }
94  }
95 
96  pair<unsigned int, vector<int>> ret;
97  ret.first = closestStation->GetId();
98  const utl::Point& closestStationPos =
99  fSDetector->GetStation(*closestStation).GetPosition();
100 
101  auto& functioningNeighbors = ret.second;
102  for (SEvent::ConstStationIterator sIt = sEvent.StationsBegin();
103  sIt != sEvent.StationsEnd(); ++sIt) {
104  if (!IsActive(*sIt))
105  continue;
106 
107  const sdet::Station& ds = fSDetector->GetStation(*sIt);
108  const double dist = Distance(closestStationPos, ds);
109  if (dist > fFirstCrownDistanceRange[0] && dist < fFirstCrownDistanceRange[1])
110  functioningNeighbors.push_back(sIt->GetId());
111  }
112 
113  if (int(functioningNeighbors.size()) >= fMinNumberOfActiveStations)
114  return ret;
115 
116  return make_pair(0U, vector<int>());;
117 }
118 
119 
122 {
123  Branch topB = CentralConfig::GetInstance()->GetTopBranch("SdHorizontalEventSelector");
124 
125  topB.GetChild("EnableT5HasTrigger").GetData(fEnableT5HasTrigger);
126 
127  topB.GetChild("RejectNonT5HasEvents").GetData(fRejectNonT5HasEvents);
128 
129  topB.GetChild("MinNumberOfActiveStations").GetData(fMinNumberOfActiveStations);
130 
131  topB.GetChild("FirstCrownDistanceRange").GetData(fFirstCrownDistanceRange);
132 
133  fSDetector = &det::Detector::GetInstance().GetSDetector();
134 
135  return eSuccess;
136 }
137 
138 
140 SdHorizontalEventSelector::Run(evt::Event& event)
141 {
142  if (!event.HasSEvent())
143  return eContinueLoop;
144 
145  ShowerRecData& shRec = event.GetRecShower();
146  if (!shRec.HasSRecShower())
147  return eContinueLoop;
148 
149  if (fEnableT5HasTrigger) {
150 
151  const auto t5Stations = CalculateT5HASTrigger(event);
152  const unsigned int closestStation = t5Stations.first;
153  const int nActive = t5Stations.second.size();
154  const bool t5Has = (closestStation && nActive >= fMinNumberOfActiveStations);
155 
156  bool closestIsUUB = false;
157  if(t5Has)
158  closestIsUUB = fSDetector->GetStation(closestStation).IsUUB();
159 
160  // Fill vector denoting which T5 neighbor stations were UUBs
161  vector<int> t5NeighborsUUB;
162  for (const auto sid : t5Stations.second) {
163  const bool isUUB = fSDetector->GetStation(sid).IsUUB();
164  if (isUUB)
165  t5NeighborsUUB.push_back(sid);
166  }
167 
168  ostringstream info;
169  info << "T5Has = " << t5Has;
170  INFO(info);
171 
172  if (fRejectNonT5HasEvents && !t5Has)
173  return eContinueLoop;
174 
175  ShowerSRecData& shSRec = shRec.GetSRecShower();
176  shSRec.SetT5Trigger(shSRec.GetT5Trigger() | t5Has*ShowerSRecData::eT5_Has);
177  shSRec.SetT5ClosestStation(closestStation);
178  shSRec.SetT5ClosestStationIsUUB(closestIsUUB);
179  shSRec.SetT5PosteriorActiveNeighbors(t5Stations.second);
180  shSRec.SetT5PosteriorActiveUUBNeighbors(t5NeighborsUUB);
181 
182  }
183 
184  return eSuccess;
185 }
186 
187 
189 SdHorizontalEventSelector::Finish()
190 {
191  return eSuccess;
192 }
193 
194 // Configure (x)emacs for this file ...
195 // Local Variables:
196 // mode: c++
197 // End:
StationIterator StationsEnd()
End of all stations.
Definition: SEvent.h:59
Point object.
Definition: Point.h:32
Detector description interface for Station-related data.
void SetT5PosteriorActiveUUBNeighbors(const std::vector< int > &neigh)
Interface class to access to the SD Reconstruction of a Shower.
Interface class to access Shower Reconstructed parameters.
Definition: ShowerRecData.h:33
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
void SetT5PosteriorActiveNeighbors(const std::vector< int > &neigh)
const double meter
Definition: GalacticUnits.h:29
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
void SetT5ClosestStation(const int id)
bool IsSilent() const
Check if the station is silent.
ShowerSRecData & GetSRecShower()
#define U
bool IsCandidate() const
Check if the station is a candidate.
utl::Point GetPosition() const
Tank position.
void SetT5ClosestStationIsUUB(const bool flag)
Class representing a document branch.
Definition: Branch.h:107
class to hold data at Station level
constexpr double s
Definition: AugerUnits.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
double Distance(const Point &p, const sdet::Station &s)
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
int GetRejectionStatus() const
int GetT5Trigger() const
void SetT5Trigger(const int t5)
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
StationIterator StationsBegin()
Beginning of all stations.
Definition: SEvent.h:57
bool IsActive(const sevt::Station &s)
const utl::Point & GetCorePosition() const
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
Definition: SEvent.h:54
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSRecShower() const
bool HasSEvent() const
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)

, generated on Tue Sep 26 2023.