2 #include <utl/ErrorLogger.h>
4 #include <fwk/LocalCoordinateSystem.h>
5 #include <fwk/CentralConfig.h>
6 #include <fwk/RunController.h>
9 #include <evt/ShowerRecData.h>
10 #include <evt/ShowerSRecData.h>
11 #include <evt/ShowerMRecData.h>
12 #include <sevt/Station.h>
14 #include <utl/Vector.h>
15 #include <utl/Point.h>
16 #include <utl/ConfigUtils.h>
25 MdEventSelector::MdEventSelector()
29 MdEventSelector::~MdEventSelector()
40 LoadConfig(config,
"MinNumberOfCountersAtBeginning", fMinNumberOfCounters, 3);
41 LoadConfig(config,
"silentRange", fSilentRange, 5000);
42 LoadConfig(config,
"selectEventByTheta", fSelectEventByTheta,
false);
45 LoadConfig(config,
"T5NumberOfActiveStations", fT5NumberOfActiveStations, 6);
46 LoadConfig(config,
"RejectNonT5Events", fRejectNonT5Events, 0);
47 LoadConfig(config,
"FirstCrownMinDistance", fFirstCrownMinDistance, 600);
48 LoadConfig(config,
"FirstCrownMaxDistance", fFirstCrownMaxDistance, 1000);
50 LoadConfig(config,
"RejectSaturatedEvents", fRejectSaturatedEvents, 0);
51 LoadConfig(config,
"RejectDenseStations", fRejectDenseStations, 0);
53 LoadConfig(config,
"RejectTimeOutlierCounters", fRejectTimeOutlierCounters, 0);
54 LoadConfig(config,
"timeOutlierMuons", fTimeOutlierMuons, 10);
55 LoadConfig(config,
"timeOutlierDistance", fTimeOutlierDistance, 0);
56 LoadConfig(config,
"timeOutlierConstant", fTimeOutlierConstant, 0);
57 LoadConfig(config,
"timeOutlierSlope", fTimeOutlierSlope, 0);
59 theMDetector = &(det::Detector::GetInstance().GetMDetector());
72 WARNING(
"Event without muon detector event: nothing to be done. Skipping to next event.");
80 os <<
"Saturated event " <<
event.
GetHeader().
GetId() <<
" will not be reconstructed." << std::endl;
87 if (fSelectEventByTheta && IsHighTheta(event)) {
89 os <<
"Skipping to next event. Zenith angle is greater than " << fMaxTheta/
utl::deg <<
" degrees";
94 RejectCloseSimDetectors(me);
96 if (fRejectDenseStations)
97 RejectDenseDetectors(me);
99 if (fRejectTimeOutlierCounters) {
100 RejectTimeOutliers(me, se);
103 if (!HasEnoughDetectors(me)) {
104 INFO(
"Not enough detectors to reconstruct event, skipping...");
105 return eContinueLoop;
109 const bool t5 = IsMEventT5(me);
113 ++RunController::GetInstance().GetRunData().GetNamedCounters()[
"MdEventSelector/T5"];
116 if (fRejectNonT5Events && !t5) {
117 INFO(
"Rejecting non T5 event");
118 return eContinueLoop;
126 MdEventSelector::Finish()
154 if (nCandidateCounters < fMinNumberOfCounters)
158 unsigned int nCountersWithMuons = 0;
160 if (ic->IsCandidate() && !ic->IsEmpty()) {
161 ++nCountersWithMuons;
165 return nCountersWithMuons >= fMinNumberOfCounters;
178 const mevt::Counter* hottestCounter = FindHottestCounter(me);
180 const unsigned int hottestId = hottestCounter->
GetId();
181 utl::Point hottestPosition = theMDetector->GetCounter(hottestId).GetPosition();
185 const unsigned int counterId = ic->GetId();
186 const utl::Point counterPosition = theMDetector->GetCounter(counterId).GetPosition();
188 const utl::Vector moduleToHottest = counterPosition-hottestPosition;
189 const double distance = moduleToHottest.
GetMag();
191 if (ic->IsSilent() && distance > fSilentRange)
192 ic->SetRejected(
"Far silent");
202 return me.
IsSaturated() ? FindHottestCounterSaturated(me) : FindHottestCounterUnsaturated(me);
212 double maxDensity = -1;
219 if (ic->IsCandidate() && !ic->IsSaturated()) {
225 if (density > maxDensity) {
226 hottestCounter = &(*ic);
227 maxDensity = density;
236 return hottestCounter;
246 unsigned int maxWindowsOn = 0;
253 if (ic->IsCandidate() && ic->IsSaturated()) {
259 if (windowsOn>maxWindowsOn) {
260 hottestCounter = &(*ic);
261 maxWindowsOn = windowsOn;
270 return hottestCounter;
279 if (!(event.
HasRecShower() &&
event.GetRecShower().HasSRecShower())) {
280 ERROR(
"Current event does not have a recontructed shower.");
304 if (ic->HasSimData() && ic->GetSimData().IsInsideMinRadius())
305 ic->SetRejected(
"Inside minimal radius");
318 const mdet::Counter& counter = theMDetector->GetCounter(ic->GetId());
320 ic->SetRejected(
"In dense array");
336 if (ic->IsRejected() || !ic->HasT50())
342 const mdet::Counter& dCounter = theMDetector->GetCounter(ic->GetId());
360 if (
int(ic->GetNumberOfChannelsOn()) < fTimeOutlierMuons && IsTimeOutlier(md2sdTimeInterval, distance)) {
361 ic->SetRejected(
"Time outlier");
363 os <<
"Counter " << dCounter.
GetId() <<
" rejected because its t50 is out of time with the SD t0.";
372 MdEventSelector::IsTimeOutlier(
const double md2sdTimeInterval,
const double distance)
376 if (distance < fTimeOutlierDistance)
377 return md2sdTimeInterval > fTimeOutlierConstant;
379 return md2sdTimeInterval > fTimeOutlierConstant + fTimeOutlierSlope * (distance - fTimeOutlierDistance);
389 const mevt::Counter*
const hottestCounter = FindHottestCounter(me);
391 const unsigned int hottestId = hottestCounter->
GetId();
392 utl::Point hottestPosition = theMDetector->GetCounter(hottestId).GetPosition();
394 int functioningNeighbors = 0;
398 if (ic->IsCandidate() || ic->IsSilent()) {
400 const unsigned int counterId = ic->GetId();
401 const utl::Point counterPosition = theMDetector->GetCounter(counterId).GetPosition();
403 const utl::Vector moduleToHottest = counterPosition-hottestPosition;
404 const double distance = moduleToHottest.
GetMag();
408 if (fFirstCrownMinDistance < distance && distance < fFirstCrownMaxDistance) {
409 ++functioningNeighbors;
416 if (functioningNeighbors >= fT5NumberOfActiveStations) {
417 INFO(
"Event is MD T5");
421 info <<
"Event is not MD T5: only " << functioningNeighbors <<
" "
422 "(out of " << fT5NumberOfActiveStations <<
") "
423 "functioning neighbours of the hottest counter "
424 << hottestCounter->
GetId() <<
" found";
InternalCounterCollection::ComponentConstIterator CounterConstIterator
CounterConstIterator CountersBegin() const
bool HasStation(const int stationId) const
Check whether station exists.
Interface class to access to the SD Reconstruction of a Shower.
Interface class to access Shower Reconstructed parameters.
Counter level event data.
bool HasRecShower() const
Interface class to access to the SD part of an event.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
sevt::StationRecData & GetRecData()
Get station level reconstructed data.
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
A TimeStamp holds GPS second and nanosecond for some event.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
double GetMuonDensity() const
The density measured by a counter is the calculated as the number of estimated muons over the active ...
Class representing a document branch.
class to hold data at Station level
utl::TimeStamp GetSignalStartTime() const
Start time of the signal.
int GetAssociatedTankId() const
Retrieve the id of the associated surface tank.
unsigned int GetNumberOfChannelsOn() const
const utl::Vector & GetAxis() const
#define WARNING(message)
Macro for logging warning messages.
bool HasMRecShower() const
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
Root detector of the muon detector hierarchy.
ShowerMRecData & GetMRecShower()
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
int GetId() const
The id of the counter.
InternalCounterCollection::ComponentIterator CounterIterator
bool HasRecData() const
Check whether station reconstructed data exists.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
double GetSPDistance() const
Distance from core in shower plane coordinates.
void LoadConfig(const utl::Branch &b, const std::string &tag, T1 &var, const T2 &defaultValue)
Helper method to load a particular configuration parameter.
CounterConstIterator CountersEnd() const
const utl::Point & GetCorePosition() const
sevt::Header & GetHeader()
int GetId() const
The id of this component.
Interface class to access to the Muon Reconstruction of a Shower.
void SetT5Trigger(const bool t5)
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
#define ERROR(message)
Macro for logging error messages.
unsigned int GetNumberOfCandidateCounters() const
Root of the Muon event hierarchy.
Selects events and detectors for the MD reconstruction.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)