12#include <unordered_map>
13#include <unordered_set>
23 for (
auto& entry :
fConfig.fMinNumDigis) {
24 if (!(event.
Size(entry.first) >= entry.second)) {
31 for (
auto& entry :
fConfig.fMinNumLayers) {
32 if (entry.second == 0)
continue;
33 switch (entry.first) {
41 throw std::runtime_error(
"Number of layers for " + std::string(
util::ToString(entry.first))
42 +
" is not implemented");
48 for (
auto& entry :
fConfig.fMaskedChannels) {
49 size_t nDigisAccepted = 0;
50 auto det = entry.first;
51 auto itMinNumDigis =
fConfig.fMinNumDigis.find(det);
52 if (itMinNumDigis !=
fConfig.fMinNumDigis.end() && itMinNumDigis->second > 0) {
55 for (
const auto& digi : event.
fBmon) {
56 if (entry.second.find(digi.GetAddress()) == entry.second.end()) {
65 if (nDigisAccepted < itMinNumDigis->second) {
88 const uint16_t chanPerSide = 1024;
89 std::unordered_set<int> stations;
90 std::unordered_map<int32_t, bool> modules;
92 for (
auto& digi : digis) {
93 const int32_t addr = digi.GetAddress();
94 auto module = modules.find(addr);
95 if (module == modules.end())
96 modules[addr] = digi.GetChannel() / chanPerSide;
98 if (digi.GetChannel() / chanPerSide != module->second) {
99 const int stationAddr =
fpRecoSetup->GetSts()->GetTrackingStationId(addr);
100 if (stations.count(stationAddr) == 0) {
101 stations.insert(stationAddr);
102 if (stations.size() == minNum)
break;
108 if (stations.size() < minNum)
132 std::unordered_set<int32_t> rpcs;
133 std::unordered_set<int32_t> stations;
134 std::unordered_map<int32_t, bool> strips;
135 for (
auto& digi : digis) {
136 const int32_t digiAddr = digi.GetAddress();
139 auto strip = strips.find(stripAddr);
140 if (strip == strips.end())
141 strips[stripAddr] = digi.GetSide();
143 if (digi.GetSide() != strip->second) {
145 if (rpcs.count(rpcAddr) == 0) {
146 const int32_t TofStationId =
fpRecoSetup->GetTof()->GetTrackingStationId(digiAddr);
147 if (TofStationId < 0) {
150 stations.insert(TofStationId);
151 if (stations.size() == minNum)
break;
157 if (stations.size() < minNum)
168 std::stringstream out;
169 out <<
"--- Using DigiEventSelector with";
170 out << (
fConfig.IsEmpty() ?
" no selection criteria" :
" selection criteria: ");
171 if (!
fConfig.fMinNumDigis.empty()) {
172 out <<
"\n min. digis : ";
173 for (
const auto& entry :
fConfig.fMinNumDigis)
174 out << entry.first <<
" " << entry.second <<
" ";
176 if (!
fConfig.fMinNumLayers.empty()) {
177 out <<
"\n min. layers: ";
178 for (
const auto& entry :
fConfig.fMinNumLayers)
179 out << 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)
DigiEventSelectorConfig fConfig
Configuration / parameters.
bool operator()(const DigiEvent &event) const
Test one event for the selection criteria.
bool CheckStsStations(gsl::span< const CbmStsDigi > digis, size_t minNum) const
Test for the number of STS stations.
std::shared_ptr< RecoSetup > fpRecoSetup
Tracking setup (access to stations info)
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.
std::string_view ToString(T t)
PODVector< CbmStsDigi > fSts
Unpacked STS digis.
PODVector< CbmTofDigi > fTof
Unpacked TOF digis.
PODVector< CbmBmonDigi > fBmon
Unpacked Bmon digis.
size_t Size(ECbmModuleId system) const
Get the number of digis for a given subsystem.
Event data with event number and trigger time.