12#include <unordered_map>
13#include <unordered_set>
25 if (!(event.
Size(entry.first) >= entry.second)) {
33 if (entry.second == 0)
continue;
34 switch (entry.first) {
42 throw std::runtime_error(
"Number of layers for " + ::ToString(entry.first) +
" is not implemented");
58 const uint16_t chanPerSide = 1024;
59 std::unordered_set<uint32_t> stations;
60 std::unordered_map<int32_t, bool> modules;
62 for (
auto& digi : digis) {
63 const int32_t addr = digi.GetAddress();
64 auto module = modules.find(addr);
65 if (module == modules.end())
66 modules[addr] = digi.GetChannel() / chanPerSide;
68 if (digi.GetChannel() / chanPerSide != module->second) {
70 if (stations.count(stationAddr) == 0) {
71 stations.insert(stationAddr);
72 if (stations.size() == minNum)
break;
78 if (stations.size() < minNum)
97 std::unordered_set<int32_t> rpcs;
98 std::unordered_set<int32_t> stations;
99 std::unordered_map<int32_t, bool> strips;
100 for (
auto& digi : digis) {
101 const int32_t digiAddr = digi.GetAddress();
104 auto strip = strips.find(stripAddr);
105 if (strip == strips.end())
106 strips[stripAddr] = digi.GetSide();
108 if (digi.GetSide() != strip->second) {
110 if (rpcs.count(rpcAddr) == 0) {
111 const int32_t TofStationId =
fpTrackingSetup->GetTrackingStation<fles::Subsystem::TOF>(digiAddr);
112 if (TofStationId < 0) {
115 stations.insert(TofStationId);
116 if (stations.size() == minNum)
break;
122 if (stations.size() < minNum)
133 std::stringstream out;
134 out <<
"--- Using DigiEventSelector with";
135 out << (
fConfig.
IsEmpty() ?
" no selection criteria" :
" selection criteria: ");
137 out <<
"\n min. digis : ";
139 out <<
::ToString(entry.first) <<
" " << entry.second <<
" ";
142 out <<
"\n min. layers: ";
144 out <<
::ToString(entry.first) <<
" " << entry.second <<
" ";
@ kTof
Time-of-flight Detector.
@ kSts
Silicon Tracking System.
static int32_t GetStripFullId(uint32_t address)
static int32_t GetRpcFullId(uint32_t address)
bool IsEmpty() const
Presence of selection criteria.
std::map< ECbmModuleId, size_t > fMinNumLayers
Key: detector, value: Minimal number of layers.
std::map< ECbmModuleId, size_t > fMinNumDigis
Key: detector, value: minimal number of digis.
DigiEventSelectorConfig fConfig
Configuration / parameters.
bool operator()(const DigiEvent &event) const
Test one event for the selection criteria.
std::shared_ptr< TrackingSetup > fpTrackingSetup
Tracking setup (access to stations info)
bool CheckStsStations(gsl::span< const CbmStsDigi > digis, size_t minNum) const
Test for the number of STS stations.
bool CheckTofLayers(gsl::span< const CbmTofDigi > digis, size_t minNum) const
Test for the number of TOF layers.
std::string ToString() const
Info to string.
uint32_t GetElementId(int32_t address, int32_t level)
Get the index of an element.
PODVector< CbmStsDigi > fSts
Unpacked STS digis.
PODVector< CbmTofDigi > fTof
Unpacked TOF digis.
size_t Size(ECbmModuleId system) const
Get the number of digis for a given subsystem.
Event data with event number and trigger time.