CbmRoot
Loading...
Searching...
No Matches
CbmTofTrackingInterface.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov, Sergei Zharko [committer] */
4
5/***************************************************************************************************
6 * @file CbmTofTrackingInterface.cxx
7 * @brief Input data and parameters interface from TOF subsystem used in L1 tracker (definition)
8 * @since 23.06.2022
9 * @author S.Zharko <s.zharko@gsi.de>
10 ***************************************************************************************************/
11
13
14#include "CbmTofCreateDigiPar.h"
15#include "FairDetector.h"
16#include "FairRunAna.h"
17
18#include <Logger.h>
19
20#include <limits>
21#include <regex>
22
24
25 // ---------------------------------------------------------------------------------------------------------------------
26 //
28 : FairTask("CbmTofTrackingInterface")
29{
30 if (!fpInstance) {
31 fpInstance = this;
32 }
33}
34
35// ---------------------------------------------------------------------------------------------------------------------
36//
38{
39 if (fpInstance == this) {
40 fpInstance = nullptr;
41 }
42}
43
44// ---------------------------------------------------------------------------------------------------------------------
45//
47{
48 static_assert(std::is_trivially_copyable_v<VolumeInfo> == true);
49
50 // create digitization parameters from geometry file
51 auto tofDigiPar = new CbmTofCreateDigiPar("TOF Digi Producer", "TOF task");
52 LOG(info) << "Create DigiPar";
53 tofDigiPar->Init();
54
55 // ** ToF tracking station geometrical information initialization **
56
57 auto nStations = fDigiBdfPar->GetNbTrackingStations();
58 // Init ToF stations position z-components. For each ToF tracking station the position z-component is calculated
59 // as an average of the components for each ToF module inside the tracking station.
60 // Number of ToF RPCs for a given tracking station:
61 std::vector<int> nTofStationModules(nStations, 0);
62
63 fvStationFullVolume.clear();
64 fvStationFullVolume.resize(nStations);
66 fvStationActiveVolume.resize(nStations);
67 if constexpr (!kLegacy) {
68 // loop over all RPCs; assign a tracking station ID using DigiBdfPar; combine the RPCs for each station ID
69 auto vRpcPaths{CollectNodes("tof", "counter", "", gGeoManager->GetTopNode())};
70 std::regex rpcPattern{"module_(\\d+)_(\\d+)/gas_box_(\\d+)/counter_(\\d+)"};
71 for (const auto& rpcPath : vRpcPaths) {
72 std::smatch match;
73 std::string line{rpcPath.Data()};
74 if (std::regex_search(line, match, rpcPattern)) {
75 int iSmType{std::stoi(match[1])};
76 int iSm{std::stoi(match[2])};
77 int iRpc{std::stoi(match[4])};
78 int iStation{fDigiBdfPar->GetTrackingStation(iSmType, iSm, iRpc)};
79
80 if (5 == iSmType || iStation < 0) { // NOTE: Check for BeamOn modules or other inactive RPCs
81 continue;
82 }
83
84 fvStationFullVolume[iStation] += ReadVolume(rpcPath); // Adding RPC as a passive volume
85 gGeoManager->cd(rpcPath);
86 auto vCellPaths{CollectNodes("tof", "cell", rpcPath(0, rpcPath.Last('/')), gGeoManager->GetCurrentNode())};
87 for (const auto& cellPath : vCellPaths) {
88 fvStationActiveVolume[iStation] += ReadVolume(cellPath);
89 }
90 }
91 }
92 }
93 else { // old tracking station definition
94 fTofStationZ.clear();
95 fTofStationZ.resize(nStations);
96 fTofStationZMin.clear();
97 fTofStationZMin.resize(nStations, std::numeric_limits<double>::max());
98 fTofStationZMax.clear();
99 fTofStationZMax.resize(nStations, std::numeric_limits<double>::lowest());
100
101 for (int iSmType{0}; iSmType < fDigiBdfPar->GetNbSmTypes(); ++iSmType) {
102 for (int iSm{0}; iSm < fDigiBdfPar->GetNbSm(iSmType); ++iSm) {
103 for (int iRpc{0}; iRpc < fDigiBdfPar->GetNbRpc(iSmType); ++iRpc) {
104 auto address{CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType)};
105 int iStation{fDigiBdfPar->GetTrackingStation(iSmType, iSm, iRpc)}; // Local index of tracking station
106 auto* pChannelInfo{dynamic_cast<CbmTofCell*>(fDigiPar->GetCell(address))};
107 if (nullptr == pChannelInfo) {
108 LOG(warn) << fName << ": CbmTofCell object is not defined for iSmType = " << iSmType << ", iSm = " << iSm
109 << ", iRpc = " << iRpc;
110 continue;
111 }
112
113 // Tracking station sizes
114 auto chPosZ{pChannelInfo->GetZ()};
115
116 // Cuts on Bmon and undefined station ID
117 if (5 == iSmType) {
118 continue;
119 } // Skip Bmon
120 if (iStation < 0) {
121 continue;
122 }
123
124 fTofStationZ[iStation] += chPosZ;
125 if (chPosZ > fTofStationZMax[iStation]) {
126 fTofStationZMax[iStation] = chPosZ;
127 }
128 if (chPosZ < fTofStationZMin[iStation]) {
129 fTofStationZMin[iStation] = chPosZ;
130 }
131
132 nTofStationModules[iStation] += 1;
133 }
134 }
135 }
136
138 for (int iSt{0}; iSt < nStations; ++iSt) {
139 fTofStationZ[iSt] = fTofStationZ[iSt] / nTofStationModules[iSt];
140 auto& station{fvStationActiveVolume[iSt]};
141 station.fXmin = -100.;
142 station.fXmax = +100.;
143 station.fYmin = -100.;
144 station.fYmax = +100.;
145 station.fZmin = fTofStationZMin[iSt] - .5;
146 station.fZmax = fTofStationZMax[iSt] + .5;
147 }
149 }
150
151 // Check the validity of the parameters
152 if (!this->Check()) {
153 LOG(error)
154 << "Some errors occurred in the tracking detector interface initialization for TOF (see information above)";
155 return kFATAL;
156 }
157
158 return kSUCCESS;
159}
160
161// ---------------------------------------------------------------------------------------------------------------------
162//
164{
165 this->SetParContainers();
166 return Init();
167}
168
169// ---------------------------------------------------------------------------------------------------------------------
170//
172{
173
174 auto runtimeDb = FairRunAna::Instance()->GetRuntimeDb();
175 fDigiPar = dynamic_cast<CbmTofDigiPar*>(runtimeDb->getContainer("CbmTofDigiPar"));
176 fDigiBdfPar = dynamic_cast<CbmTofDigiBdfPar*>(runtimeDb->getContainer("CbmTofDigiBdfPar"));
177 if (!fDigiPar) {
178 LOG(fatal) << "CbmTofTrackingInterface::SetParContainers: error accessing to CbmTofDigiPar container";
179 }
180 if (!fDigiBdfPar) {
181 LOG(fatal) << "CbmTofTrackingInterface::SetParContainers: error accessing to CbmTofDigiBdfPar container";
182 }
183 runtimeDb->initContainers(FairRunAna::Instance()->GetRunId());
184}
ClassImp(CbmTofTrackingInterface) CbmTofTrackingInterface
static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side=0, uint32_t SmType=0, uint32_t RpcType=0)
Parameters class for the CBM ToF digitizer using beam data distributions.
Int_t GetNbSmTypes() const
Int_t GetNbSm(Int_t iSmType) const
Int_t GetNbRpc(Int_t iSmType) const
Int_t GetNbTrackingStations() const
Int_t GetTrackingStation(Int_t iSmType, Int_t iSm, Int_t iRpc) const
CbmTofCell * GetCell(Int_t i)
std::vector< double > fTofStationZ
Centers of TOF stations along z-axis [cm].
void SetParContainers() override
FairTask: sets parameter containers up.
InitStatus Init() override
FairTask: Init method.
CbmTofTrackingInterface()
Default constructor.
static CbmTofTrackingInterface * fpInstance
Instance of the class.
std::vector< double > fTofStationZMin
Lower bounds of TOF stations along z-axis [cm].
std::vector< double > fTofStationZMax
Upper bounds of TOF stations along z-axis [cm].
InitStatus ReInit() override
FairTask: ReInit method.
std::vector< VolumeInfo > fvStationFullVolume
Geometric properties of each station passive volume.
VolumeInfo ReadVolume(const TString &path)
Creates volume info from a geo node provided by path.
std::vector< VolumeInfo > fvStationActiveVolume
Geometric properties of each station active volume.
std::vector< TString > CollectNodes(const TString &detector, const TString &component, const TString &path, TGeoNode *pNode)
Collects paths of the components.
bool Check() const
Checks detector interface: boundary conditions of the parameters.
static constexpr bool kLegacy
If use legacy tracking detector interface definition FIXME: Remove after testing.