CbmRoot
Loading...
Searching...
No Matches
sts/RecoSetupUnit.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
11
12#include <limits>
13#include <unordered_set>
14
16
17// ---------------------------------------------------------------------------------------------------------------------
18//
19RecoSetupUnit::RecoSetupUnit(std::pair<std::vector<GeoVolume>, std::vector<GeoVolume>>&& stationVolumes,
20 StationIdMap_t&& stationIdMap)
21 : TrackingSetupIfs<RecoSetupUnit>(std::move(stationVolumes))
22 , fvStationIdMap(std::move(stationIdMap))
23{
24}
25
26// ---------------------------------------------------------------------------------------------------------------------
27//
29{
30 // STS tracking detector is initialized, if:
31 // - the fvStationIdMap has elements
32 // - the fvStationIdMap contains valid station indices in a range [0, GetNofTrackingStations() - 1]
33
34 bool res = true;
35 if (!fvStationIdMap.size()) {
36 LOG(error) << "\t - station ID map is empty";
37 res = false;
38 }
39
40
41 // Collect the indices of tracking stations, which are stored in fvStationIdMap, in a set; check, if the set
42 // has a size == GetNofTrackingStations(), and if the all the station IDs are in the range
43 // [0, GetNofTrackingStations() - 1].
44 std::unordered_set<int> knownStationIds;
45 for (auto item : fvStationIdMap) {
46 knownStationIds.insert(item.second);
47 if (item.first < std::numeric_limits<decltype(item.first)>::max()) {
48 knownStationIds.insert(item.second + 1);
49 }
50 }
51
52 if (knownStationIds.size() != static_cast<size_t>(GetNofTrackingStations())) {
53 LOG(error) << "\t - number of known tracking station IDs (" << knownStationIds.size() << ") differs from the "
54 << "number of stations, provided by geometry (" << GetNofTrackingStations() << ')';
55 res = false;
56 }
57
58 for (int stationId : knownStationIds) {
59 if (stationId < 0 || stationId >= GetNofTrackingStations()) {
60 LOG(error) << "\t - found a tracking station < 0 or >= " << GetNofTrackingStations()
61 << " (geometry): " << stationId;
62 res = false;
63 }
64 }
65 return res;
66}
friend fscal max(fscal x, fscal y)
StationIdMap_t fvStationIdMap
A map of STS address to STS station ID.
bool IsInitialized() const
Validates initialization of the instance.
std::vector< std::pair< uint32_t, int > > StationIdMap_t
RecoSetupUnit()=default
Default constructor (note: needed for serialization)
Hash for CbmL1LinkKey.
STS representation for tracking.