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");
49 size_t nDigisAccepted = 0;
50 auto det = entry.first;
55 for (
const auto& digi : event.
fBmon) {
56 if (entry.second.find(digi.GetAddress()) == entry.second.end()) {
65 if (nDigisAccepted < itMinNumDigis->second) {
82 const uint16_t chanPerSide = 1024;
83 std::unordered_set<uint32_t> stations;
84 std::unordered_map<int32_t, bool> modules;
86 for (
auto& digi : digis) {
87 const int32_t addr = digi.GetAddress();
88 auto module = modules.find(addr);
89 if (module == modules.end())
90 modules[addr] = digi.GetChannel() / chanPerSide;
92 if (digi.GetChannel() / chanPerSide != module->second) {
94 if (stations.count(stationAddr) == 0) {
95 stations.insert(stationAddr);
96 if (stations.size() == minNum)
break;
102 if (stations.size() < minNum)
121 std::unordered_set<int32_t> rpcs;
122 std::unordered_set<int32_t> stations;
123 std::unordered_map<int32_t, bool> strips;
124 for (
auto& digi : digis) {
125 const int32_t digiAddr = digi.GetAddress();
128 auto strip = strips.find(stripAddr);
129 if (strip == strips.end())
130 strips[stripAddr] = digi.GetSide();
132 if (digi.GetSide() != strip->second) {
134 if (rpcs.count(rpcAddr) == 0) {
135 const int32_t TofStationId =
fpTrackingSetup->GetTrackingStation<fles::Subsystem::TOF>(digiAddr);
136 if (TofStationId < 0) {
139 stations.insert(TofStationId);
140 if (stations.size() == minNum)
break;
146 if (stations.size() < minNum)
157 std::stringstream out;
158 out <<
"--- Using DigiEventSelector with";
159 out << (
fConfig.
IsEmpty() ?
" no selection criteria" :
" selection criteria: ");
161 out <<
"\n min. digis : ";
163 out <<
::ToString(entry.first) <<
" " << entry.second <<
" ";
166 out <<
"\n min. layers: ";
168 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, std::unordered_set< uint32_t > > fMaskedChannels
A map of masked digi addresses, which should not participate in the event building.
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.
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.