CbmRoot
Loading...
Searching...
No Matches
CbmTrdTrackingInterface.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 CbmTrdTrackingInterface.cxx
7 * @brief Input data and parameters interface from TRD subsystem used in L1 tracker (definition)
8 * @since 31.05.2022
9 * @author S.Zharko <s.zharko@gsi.de>
10 ***************************************************************************************************/
11
13
14#include "CbmTrdHit.h"
15#include "FairDetector.h"
16#include "FairRunAna.h"
17#include "TGeoManager.h"
18#include "TString.h"
19
20#include <Logger.h>
21
22#include <regex>
23
25
26 // ---------------------------------------------------------------------------------------------------------------------
27 //
29 : FairTask("CbmTrdTrackingInterface")
30{
31 if (!fpInstance) { fpInstance = this; }
32}
33
34// ---------------------------------------------------------------------------------------------------------------------
35//
40
41// ---------------------------------------------------------------------------------------------------------------------
42//
43std::tuple<double, double> CbmTrdTrackingInterface::GetStereoAnglesSensor(int address) const
44{
45 const CbmTrdParModDigi* par = dynamic_cast<const CbmTrdParModDigi*>(fTrdDigiPar->GetModulePar(address));
46 if (!par) {
47 LOG(fatal) << "CbmTrdTrackingInterface::Init: error accessing the TRD module for address " << address
48 << " (failed dynamic cast to CbmTrdParModDigi)";
49 }
50 if ((par->GetOrientation() == 1) || (par->GetOrientation() == 3)) {
51 // swap X & Y for orientations 1 or 3
52 return std::tuple(TMath::Pi() / 2., 0.);
53 }
54 return std::tuple(0., TMath::Pi() / 2.);
55}
56
57// ---------------------------------------------------------------------------------------------------------------------
58//
59std::tuple<double, double, double> CbmTrdTrackingInterface::GetHitRanges(const CbmPixelHit& hit) const
60{
61 const CbmTrdHit* trdHit = dynamic_cast<const CbmTrdHit*>(&hit);
62 if (!trdHit) { LOG(fatal) << "CbmTrdTrackingInterface::GetHitRange: input hit is not of type CbmTrdHit"; }
63 const CbmTrdParModDigi* par = dynamic_cast<const CbmTrdParModDigi*>(fTrdDigiPar->GetModulePar(trdHit->GetAddress()));
64
65 auto [rangeX, rangeY, rangeT] = CbmTrackingDetectorInterfaceBase::GetHitRanges(hit);
66
67 if (trdHit->GetClassType() == 1) {
68 // TRD 2D hit
69 // TODO: replace with more sophisticated values once the errors are correct
70 rangeX = 1.7;
71 rangeY = 3.5;
72 rangeT = 200.;
73 }
74 else { // TRD 1D hit
75 if ((par->GetOrientation() == 1) || (par->GetOrientation() == 3)) {
76 // Y coordinate is uniformly distributed
77 rangeY = sqrt(3.) * trdHit->GetDy();
78 }
79 else { // X coordinate is uniformly distributed
80 rangeX = sqrt(3.) * trdHit->GetDx();
81 }
82 }
83
84 return std::tuple(rangeX, rangeY, rangeT);
85}
86
87// ---------------------------------------------------------------------------------------------------------------------
88//
90{
91 // Collect nodes
92 if constexpr (!kLegacy) {
93 auto vLayerPaths{CollectNodes("trd", "layer", "", gGeoManager->GetTopNode())};
94 fvStationFullVolume.clear();
95 fvStationFullVolume.resize(vLayerPaths.size());
97 fvStationActiveVolume.resize(vLayerPaths.size());
98 std::regex stationPattern{"layer(\\d+)_(\\d+)"};
99 for (const auto& layerPath : vLayerPaths) {
100 std::smatch match;
101 std::string line{layerPath.Data()};
102 if (std::regex_search(line, match, stationPattern)) {
103 int iStation{std::stoi(match[1]) - 1}; // the tracking station is a TRD layer
104 fvStationFullVolume[iStation] = ReadVolume(layerPath);
105 gGeoManager->cd(layerPath);
106 auto vGasPaths{CollectNodes("trd", "gas", layerPath(0, layerPath.Last('/')), gGeoManager->GetCurrentNode())};
107 for (const auto& gasPath : vGasPaths) {
108 fvStationActiveVolume[iStation] += ReadVolume(gasPath);
109 }
110 }
111 }
112 }
113 else {
114 int nStations = 0;
115 {
116 auto topNodes = gGeoManager->GetTopNode()->GetNodes();
117 for (int iTopNode = 0; iTopNode < topNodes->GetEntriesFast(); ++iTopNode) {
118 auto topNode = static_cast<TGeoNode*>(topNodes->At(iTopNode));
119 if (TString(topNode->GetName()).Contains("trd")) {
120 auto layers = topNode->GetNodes();
121 for (int iLayer = 0; iLayer < layers->GetEntriesFast(); ++iLayer) {
122 auto layer = static_cast<TGeoNode*>(layers->At(iLayer));
123 if (TString(layer->GetName()).Contains("layer")) {
124 ++nStations;
125 }
126 }
127 }
128 }
129 }
130 fvStationFullVolume.clear();
131 fvStationFullVolume.reserve(nStations);
132 for (int iSt = 0; iSt < nStations; ++iSt) {
133 const auto* pModulePar = GetTrdModulePar(iSt);
134 fvStationFullVolume.emplace_back(
135 pModulePar->GetX() - pModulePar->GetSizeX(), pModulePar->GetX() + pModulePar->GetSizeX(),
136 pModulePar->GetY() - pModulePar->GetSizeY(), pModulePar->GetY() + pModulePar->GetSizeY(),
137 pModulePar->GetZ() - pModulePar->GetSizeZ(), pModulePar->GetZ() + pModulePar->GetSizeZ());
138 }
140 }
141
142 // Check access to TRD modules
143 for (int iSt = 0; iSt < this->GetNtrackingStations(); ++iSt) {
144 if (!dynamic_cast<CbmTrdParModDigi*>(fTrdDigiPar->GetModulePar(fTrdDigiPar->GetModuleId(iSt)))) {
145 LOG(fatal) << "CbmTrdTrackingInterface::Init: error accessing the TRD tracking station " << iSt
146 << " (failed dynamic cast to CbmTrdParModDigi)";
147 }
148 }
149
150 // Check the validity of the parameters
151 if (!this->Check()) {
152 LOG(error)
153 << "Some errors occurred in the tracking detector interface initialization for TRD (see information above)";
154 return kFATAL;
155 }
156
157 return kSUCCESS;
158}
159
160// ---------------------------------------------------------------------------------------------------------------------
161//
163{
164 this->SetParContainers();
165 return Init();
166}
167
168// ---------------------------------------------------------------------------------------------------------------------
169//
171{
172 auto runtimeDb = FairRunAna::Instance()->GetRuntimeDb();
173 fTrdDigiPar = dynamic_cast<CbmTrdParSetDigi*>(runtimeDb->getContainer("CbmTrdParSetDigi"));
174 if (!fTrdDigiPar) {
175 LOG(fatal) << "CbmTrdTrackingInterface::SetParContainers: error accessing to CbmTrdParSetDigi container";
176 }
177}
178
Class for hits in TRD detector.
ClassImp(CbmTrdTrackingInterface) CbmTrdTrackingInterface
friend fvec sqrt(const fvec &a)
int32_t GetAddress() const
Definition CbmHit.h:74
double GetDy() const
Definition CbmPixelHit.h:76
double GetDx() const
Definition CbmPixelHit.h:75
int GetNtrackingStations() const
Gets actual number of stations, provided by the current geometry setup.
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.
virtual std::tuple< double, double, double > GetHitRanges(const CbmPixelHit &hit) const
Gets x,y,t ranges of a CbmPixelHit.
data class for a reconstructed Energy-4D measurement in the TRD
Definition CbmTrdHit.h:40
bool GetClassType() const
Definition CbmTrdHit.h:80
Definition of chamber gain conversion for one TRD module.
Int_t GetOrientation() const
virtual Int_t GetModuleId(Int_t i) const
virtual const CbmTrdParMod * GetModulePar(Int_t detId) const
A CbmL1 subtask, which provides necessary methods for CA tracker to access the geometry and dataflow ...
CbmTrdTrackingInterface()
Default constructor.
InitStatus Init() override
FairTask: Init method.
InitStatus ReInit() override
FairTask: ReInit method.
static CbmTrdTrackingInterface * fpInstance
Instance of the class.
std::tuple< double, double > GetStereoAnglesSensor(int address) const override
Gets stereo angles of the two independent measured coordinates.
void SetParContainers() override
FairTask: sets parameter containers up.
std::tuple< double, double, double > GetHitRanges(const CbmPixelHit &hit) const override
Gets x,y,t ranges of a CbmTrdHit.