CbmRoot
Loading...
Searching...
No Matches
tof/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 <numeric>
13#include <unordered_set>
14
17
18// ---------------------------------------------------------------------------------------------------------------------
19//
20TrkStationIdMap::TrkStationIdMap(std::vector<SmTypeInfo>&& smTypeRpcMap, std::vector<int>&& trkStationIdMap)
21 : fSmTypeRpcMap(std::move(smTypeRpcMap))
22 , fTrkStationIdMap(std::move(trkStationIdMap))
23{
24 // Validate consistency
25 // - a difference in offsets with the next SmType must be equal to nSm * nRpc
26 // - including the "end" SmTypeInfo, which has an offset == fTrkStationId.size()
27 auto ValidateConsSmTypes = [](SmTypeInfo thisSmType, SmTypeInfo nextSmType, uint16_t iThisSmType) {
28 uint32_t offsetDiff = nextSmType.offset - thisSmType.offset;
29 uint32_t nRpcsSmt = thisSmType.nSm * thisSmType.nRpc;
30 if (nRpcsSmt != offsetDiff) {
31 std::stringstream msg;
32 msg << "Mapping issue for iSmType=" << iThisSmType << ": num of RPCs ((nSm=)" << thisSmType.nSm << " x (nRpc=)"
33 << thisSmType.nRpc << " = " << nRpcsSmt << ") differs from the offset difference relative to the next "
34 << "supermodule type ((next.offset=)" << nextSmType.offset << " - (this.offset=)" << thisSmType.offset
35 << " = " << offsetDiff;
36 throw std::runtime_error(msg.str());
37 }
38 };
39
40 SmTypeInfo thisSmt = fSmTypeRpcMap[0];
41 for (uint16_t iSmType = 0; iSmType < GetNofSmTypes() - 1; ++iSmType) {
42 SmTypeInfo nextSmt{fSmTypeRpcMap[iSmType + 1]};
43 ValidateConsSmTypes(thisSmt, nextSmt, iSmType);
44 thisSmt = nextSmt;
45 }
46 ValidateConsSmTypes(thisSmt,
47 SmTypeInfo{.offset = static_cast<uint16_t>(fTrkStationIdMap.size()), .nSm = 0, .nRpc = 0},
48 GetNofSmTypes() - 1);
49}
50
51
52// ---------------------------------------------------------------------------------------------------------------------
53//
54RecoSetupUnit::RecoSetupUnit(std::pair<std::vector<GeoVolume>, std::vector<GeoVolume>>&& stationVolumes,
55 TrkStationIdMap&& trkStationIdMap)
56 : TrackingSetupIfs<RecoSetupUnit>(std::move(stationVolumes))
57 , fTrkStationIdMap(std::move(trkStationIdMap))
58{
59}
60
61// ---------------------------------------------------------------------------------------------------------------------
62//
64{
65 // TOF tracking detector is initialized, if:
66 // - the fvTrackingStationId contain as much stations, as defined in stationFullVolumes
67
68 // Collect all knownStationIds (> -1)
69 std::unordered_set<int> knownStationIds;
70 for (int stationId : fTrkStationIdMap.GetTrkStationIdMap()) {
71 if (stationId > -1) knownStationIds.insert(stationId);
72 }
73
74 bool res{true};
75 for (int stationId : knownStationIds) {
76 if (stationId > GetNofTrackingStations()) {
77 LOG(error) << "\t - found stationID (" << stationId << ") greater than max. stationID provided by geometry ("
78 << (GetNofTrackingStations() - 1) << ')';
79 res = false;
80 }
81 }
82
83 if (knownStationIds.size() != static_cast<size_t>(GetNofTrackingStations())) {
84 LOG(error) << "\t - number of tracking stations provided by geometry (" << GetNofTrackingStations()
85 << ") differs from one retrieved from digitization parameters (" << knownStationIds.size() << ')';
86 res = false;
87 }
88
89 return res;
90}
TrkStationIdMap()=default
Default constructor (for serialization)
TOF detector representation in online/offline reconstruction.
bool IsInitialized() const
Validates initialization of the instance.
RecoSetupUnit()=default
Default constructor (note: needed for serialization)
TrkStationIdMap fTrkStationIdMap
A map of tracking station indexing.
A mapper for TOF tracking stations.
uint16_t GetNofSmTypes() const
Gets number of supermodule types.
std::vector< SmTypeInfo > fSmTypeRpcMap
Information on the RPC indexing within differnt SM types.
std::vector< int > fTrkStationIdMap
Index of tracking station vs. RPC.
Hash for CbmL1LinkKey.
Information on RPC offsets for each SM type.
uint16_t nRpc
Number of RPCs for a given SM type.
uint32_t offset
An index of first RPC for a given SM type.
uint16_t nSm
Number of supermodules for a given SM type.
TOF representation for tracking.