SdMonteCarloEventSelector.cc
Go to the documentation of this file.
1 #include <string>
2 
3 #include <fwk/CentralConfig.h>
4 #include <sdet/SDetector.h>
5 #include <utl/Reader.h>
6 #include <utl/String.h>
7 #include <evt/Event.h>
8 #include <sevt/SEvent.h>
9 #include <sevt/Station.h>
10 #include <sevt/StationSimData.h>
12 
13 using namespace std;
14 using namespace fwk;
15 using namespace evt;
16 using namespace sevt;
17 using namespace utl;
18 
19 
20 namespace SdMonteCarloEventSelectorOG {
21 
22  void
23  MakeInfo(const vector<int>& ids, const string& message)
24  {
25  if (ids.empty())
26  return;
27  ostringstream info;
28  info << "station" << String::Plural(ids) << ' ' << String::OfSortedIds(ids) << ' ' << message;
29  INFO(info);
30  }
31 
32 
35  {
36  Branch topB =
37  CentralConfig::GetInstance()->GetTopBranch("SdMonteCarloEventSelector");
38 
39  string arrayLayout;
40  topB.GetChild("ArrayLayout").GetData(arrayLayout);
41  if (arrayLayout == "KeepOnlyDenseArray")
42  fArrayLayout = eKeepOnlyDenseArray;
43  else if (arrayLayout == "KeepOnlyRegularArray")
44  fArrayLayout = eKeepOnlyRegularArray;
45  else
46  fArrayLayout = eKeepAll;
47 
48  string innerRadiusTreatment;
49  topB.GetChild("InnerRadiusTreatment").GetData(innerRadiusTreatment);
50  if (innerRadiusTreatment == "KeepInnerRadiusStation")
51  fInnerRadiusTreatment = eKeepInnerRadiusStation;
52  else if (innerRadiusTreatment == "RejectInnerRadiusStation")
53  fInnerRadiusTreatment = eRejectInnerRadiusStation;
54  else
55  fInnerRadiusTreatment = eSkipEvent;
56 
57  return eSuccess;
58  }
59 
60 
62  SdMonteCarloEventSelector::Run(Event& event)
63  {
64  const sdet::SDetector& sDetector = det::Detector::GetInstance().GetSDetector();
65 
66  sevt::SEvent& sEvent = event.GetSEvent();
67 
68  vector<int> svInnerRadiusTreatment;
69  vector<int> svArrayLayout;
70 
71  for (SEvent::StationIterator sIt = sEvent.StationsBegin();
72  sIt != sEvent.StationsEnd(); ++sIt) {
73 
74  // Stations with distance in shower plane coordinates smaller than the
75  // inner radius used in simulations (CORSIKA/AIRES) are eith removed, kept
76  // or the hole event is skipped
77 
78  if (sIt->HasSimData()) {
79  const sevt::StationSimData& sSim = sIt->GetSimData();
80  if (sSim.IsInsideMinRadius()) {
81  svInnerRadiusTreatment.push_back(sIt->GetId());
82  if (fInnerRadiusTreatment == eRejectInnerRadiusStation)
83  sIt->SetRejected(StationConstants::eMCInnerRadiusCut);
84  }
85  }
86 
87  const int sId = sIt->GetId();
88  const bool isDense = sDetector.GetStation(sId).IsDense();
89 
90  // removal of dense array stations or regular array stations
91 
92  switch (fArrayLayout) {
93  case eKeepAll:
94  if (isDense && sIt->IsRejected() &&
95  sIt->GetRejectionStatus() ==
97  sIt->SetCandidate();
98  break;
99  case eKeepOnlyDenseArray:
100  if (isDense) {
101  if (sIt->IsRejected() &&
102  sIt->GetRejectionStatus() ==
104  if (sIt->HasRecData())
105  sIt->SetCandidate();
106  else
107  sIt->SetSilent();
108  }
109  } else {
110  svArrayLayout.push_back(sId);
111  sIt->SetRejected(StationConstants::eNotDenseArray);
112  }
113  break;
114  case eKeepOnlyRegularArray:
115  if (isDense) {
116  svArrayLayout.push_back(sId);
117  sIt->SetRejected(StationConstants::eDenseArray);
118  }
119  break;
120  }
121  }
122 
123  if (!svInnerRadiusTreatment.empty()) {
124  MakeInfo(svInnerRadiusTreatment, string("within inner radius cut") +
125  (fInnerRadiusTreatment == eKeepInnerRadiusStation ?
126  " kept: " :
127  (fInnerRadiusTreatment == eRejectInnerRadiusStation ?
128  " rejected: " : ", event skipped.")));
129  if (fInnerRadiusTreatment == eSkipEvent)
130  return eContinueLoop;
131  }
132 
133  if (!svArrayLayout.empty()) {
134  MakeInfo(svArrayLayout, string("not in ") +
135  (fArrayLayout == eKeepOnlyDenseArray ?
136  "dense " : "regular ") +
137  "array rejected.");
138  } else if (fArrayLayout == eKeepAll)
139  INFO("Keeping both dense and regular stations.");
140 
141  return eSuccess;
142  }
143 
144 
146  SdMonteCarloEventSelector::Finish()
147  {
148  return eSuccess;
149  }
150 
151 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Station Level Simulated Data
StationIterator StationsEnd()
End of all stations.
Definition: SEvent.h:59
bool IsInsideMinRadius() const
Check whether the station is in the shower hole.
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
#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
const char * Plural(const T n)
Definition: String.h:104
Class representing a document branch.
Definition: Branch.h:107
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
void MakeInfo(const vector< int > &ids, const string &message)
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
StationIterator StationsBegin()
Beginning of all stations.
Definition: SEvent.h:57
bool IsDense() const
Tells whether the station belongs to set of hypothetical &quot;dense&quot; stations.
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
Definition: SEvent.h:52
string OfSortedIds(vector< int > ids)
Definition: String.cc:65
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: SDetector.cc:192

, generated on Tue Sep 26 2023.