CbmRoot
Loading...
Searching...
No Matches
tof/TrackingInterface.cxx
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#include "TrackingInterface.h"
11
13#include "CbmTofAddress.h"
14#include "HitfindSetup.h"
15#include "ParFiles.h"
16#include "fmt/format.h"
17
20
21// ---------------------------------------------------------------------------------------------------------------------
22//
24{
25 L_(info) << "TOF: TrackingInterface initialization";
26
27 // Read NbSm, NbRpc and tracking station ids from the config
28 if (!this->GetContext()) { // Default parameters for tests
29 L_(info) << "TOF: TrackingInterface: no context found, using default setup";
30 // Par: tof_v21j_mcbm.digibdf.par
31 // Hardcoded setup, required for DigiEventSelector unittest
32 fvNofSm = {5, 0, 1, 0, 0, 1, 1, 1, 0, 1};
33 fvNofRpc = {5, 3, 5, 1, 1, 1, 2, 2, 1, 2};
34 fvTrackingStationId.resize(fvNofSm.size());
35 fvTrackingStationId[0] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3};
36 fvTrackingStationId[1] = {};
37 fvTrackingStationId[2] = {2, 2, 2, 2, 2};
38 fvTrackingStationId[3] = {};
39 fvTrackingStationId[4] = {};
40 fvTrackingStationId[5] = {0}; // BMON
41 fvTrackingStationId[6] = {1, 1};
42 fvTrackingStationId[7] = {1, 1};
43 fvTrackingStationId[8] = {};
44 fvTrackingStationId[9] = {2, 2};
45 }
46 else {
47 ParFiles parFiles(Opts().RunId());
48 auto setup = yaml::ReadFromFile<HitfindSetup>(Opts().ParamsDir() / parFiles.tof.hitfinder);
49 fvNofSm = std::move(setup.NbSm);
50 fvNofRpc = std::move(setup.NbRpc);
51 assert(fvNofSm.size() == fvNofRpc.size());
52 int nSmTypes = fvNofSm.size();
53 fvTrackingStationId.resize(nSmTypes);
54 for (int iSmType = 0; iSmType < nSmTypes; ++iSmType) {
55 int nSm = fvNofSm[iSmType];
56 int nRpc = fvNofRpc[iSmType];
57 auto& vStaIds = fvTrackingStationId[iSmType];
58 auto& vRpcPars = setup.rpcs[iSmType];
59 vStaIds.resize(nSm * nRpc);
60 for (int iSm = 0; iSm < nSm; ++iSm) {
61 for (int iRpc = 0; iRpc < nRpc; ++iRpc) {
62 int iGlobRpc = iSm * nRpc + iRpc;
63 vStaIds[iGlobRpc] = vRpcPars[iGlobRpc].trackingStationId;
64 }
65 }
66 }
67 }
68}
69
70// ---------------------------------------------------------------------------------------------------------------------
71//
72int TrackingInterface::GetTrackingStation(uint32_t address) const
73{
74 int iSmType = CbmTofAddress::GetSmType(address);
75 if (5 == iSmType) {
76 return -1; // Bmon hit
77 }
78
79 int iSm = CbmTofAddress::GetSmId(address);
80 int iRpc = CbmTofAddress::GetRpcId(address);
81 if (iSmType < int(fvNofSm.size())) {
82 if (iSm < fvNofSm[iSmType] && iRpc < fvNofRpc[iSmType]) {
83 return fvTrackingStationId[iSmType][iSm * fvNofRpc[iSmType] + iRpc];
84 }
85 }
86
87 L_(error) << "Undefined RPC address " << address << " (iSmType = " << iSmType << ", iSm = " << iSm
88 << ", iRpc = " << iRpc << ')';
89 return -1; // iSmType, iSm or iRpc are out of range
90}
#define L_(level)
This file contains the definition of the ParFiles class.
static int32_t GetSmId(uint32_t address)
static int32_t GetRpcId(uint32_t address)
static int32_t GetSmType(uint32_t address)
const ChainContext * GetContext()
Definition SubChain.h:16
const Options & Opts() const
Definition SubChain.h:20
std::vector< std::vector< int > > fvTrackingStationId
Index of tracking station [NbSmt][NbSm * NbRpc].
std::vector< int > fvNofRpc
Number of RPCs [NbSmt].
std::vector< int > fvNofSm
Number of super modules [NbSmt].
int GetTrackingStation(uint32_t address) const
Returns tracking station index by the TOF address.
T ReadFromFile(fs::path path)
Definition Yaml.h:51
Class to hold the paths to the parameter files for the different detectors.
Definition ParFiles.h:21
fs::path hitfinder
Definition ParFiles.h:35
struct cbm::algo::ParFiles::@2 tof
Hitfind setup / Hardware cabling for TOF Used to create the hardware mapping for the TOF hitfinder.
A TOF-parameter and geometry interface used for tracking input data initialization (header)