CbmRoot
Loading...
Searching...
No Matches
CbmStsRecoModule.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
10#include "CbmStsRecoModule.h"
11
14#include "CbmStsAlgoFindHits.h"
16#include "CbmStsDigi.h"
17#include "CbmStsModule.h"
18#include "CbmStsParSensor.h"
19#include "CbmStsSensor.h"
20
21#include <FairField.h>
22#include <FairRun.h>
23#include <Logger.h>
24
25#include <TGeoBBox.h>
26#include <TGeoPhysicalNode.h>
27#include <TMath.h>
28#include <TStopwatch.h>
29
30using std::pair;
31
33
34
35 // ----- Standard constructor ------------------------------------------
37{
38}
39// -------------------------------------------------------------------------
40
41
42// ----- Default constructor -------------------------------------------
44 const CbmStsParSensor& parSensor, Double_t lorentzShiftF, Double_t lorentzShiftB)
45 : fSetupModule(setupModule)
46 , fParModule(&parModule)
47 , fParSensor(&parSensor)
48 , fLorentzShiftF(lorentzShiftF)
49 , fLorentzShiftB(lorentzShiftB)
50{
51 Init();
52}
53// -------------------------------------------------------------------------
54
55
56// ----- Destructor ----------------------------------------------------
58// -------------------------------------------------------------------------
59
60
61// --------------- Add digi to queues ----------------------------------
62void CbmStsRecoModule::AddDigiToQueue(const CbmStsDigi* digi, Int_t digiIndex)
63{
64 fLock.lock();
65 Int_t moduleAddress = CbmStsAddress::GetMotherAddress(digi->GetAddress(), kStsModule);
66 assert(moduleAddress == fSetupModule->GetAddress());
67 assert(digi->GetChannel() < fNofStripsF + fNofStripsB);
68 if (digi->GetChannel() < fNofStripsF)
69 fDigisF.push_back({digi, digiIndex});
70 else
71 fDigisB.push_back({digi, digiIndex});
72 fLock.unlock();
73}
74// -------------------------------------------------------------------------
75
76
77// ----- Reconstruction ------------------------------------------------
85
87{
88 TStopwatch timer;
89
90 timer.Start();
91 // --- Sort the digi queues by digi time stamp
92 std::sort(fDigisF.begin(), fDigisF.end(),
93 [](pair<const CbmStsDigi*, Int_t> digi1, pair<const CbmStsDigi*, Int_t> digi2) {
94 return digi1.first->GetTime() < digi2.first->GetTime();
95 });
96 std::sort(fDigisB.begin(), fDigisB.end(),
97 [](pair<const CbmStsDigi*, Int_t> digi1, pair<const CbmStsDigi*, Int_t> digi2) {
98 return digi1.first->GetTime() < digi2.first->GetTime();
99 });
100 timer.Stop();
101 fTimings.timeSortDigi = timer.RealTime();
102}
103
105{
106 // --- Perform cluster finding
107 TStopwatch timer;
108
109 timer.Start();
114
115 // --- Perform cluster analysis
116 for (auto& cluster : fClustersF)
117 fClusterAna->Exec(cluster, fParModule);
118 for (auto& cluster : fClustersB)
119 fClusterAna->Exec(cluster, fParModule);
120
121 timer.Stop();
122 fTimings.timeCluster = timer.RealTime();
123}
124
126{
127 // --- Sort clusters by time
128 TStopwatch timer;
129
130 timer.Start();
131 std::sort(fClustersF.begin(), fClustersF.end(), [](const CbmStsCluster& cluster1, const CbmStsCluster& cluster2) {
132 return (cluster1.GetTime() < cluster2.GetTime());
133 });
134 std::sort(fClustersB.begin(), fClustersB.end(), [](const CbmStsCluster& cluster1, const CbmStsCluster& cluster2) {
135 return (cluster1.GetTime() < cluster2.GetTime());
136 });
137 timer.Stop();
138 fTimings.timeSortCluster = timer.RealTime();
139}
140
158
159// -------------------------------------------------------------------------
160
161
162// ----- Reset before new time slice -----------------------------------
164{
165 fDigisF.clear();
166 fDigisB.clear();
167}
168// -------------------------------------------------------------------------
169
170
171// ----- Get the sensor parameters -------------------------------------
173{
174
175 // Reconstruction is currently implemented for double-sided strip
176 // sensors (class DssdStereo or DssdOrtho)
177
178 // --- Sensor class must be DssdStereo
179 auto type = fParSensor->GetClass();
181
182 // --- Check for physical node of sensor
183 assert(fSetupModule);
184 assert(fSetupModule->GetNofDaughters() == 1);
185 TGeoPhysicalNode* sensorNode = fSetupModule->GetDaughter(0)->GetPnode();
186 assert(sensorNode);
187
188 // --- Check consistency of parameters with geometry
189 TGeoBBox* shape = dynamic_cast<TGeoBBox*>(sensorNode->GetShape());
190 assert(shape);
191 assert(TMath::Abs(2. * shape->GetDX() - fParSensor->GetPar(0)) < 0.001);
192 assert(TMath::Abs(2. * shape->GetDY() - fParSensor->GetPar(1)) < 0.001);
193 assert(TMath::Abs(2. * shape->GetDZ() - fParSensor->GetPar(2)) < 0.001);
194
195 // --- Positioning of sensor in global C.S.
196 fMatrix = sensorNode->GetMatrix();
197
198 // --- Number of strips must be the same on both sides
199 // --- Number of strips, strip pitch and stereo angle
206 assert(fNofStripsF > 0);
207 assert(fNofStripsB > 0);
208 assert(fStripPitchF > 0.);
209 assert(fStripPitchB > 0.);
210
211 // --- For DssdStereo, number of strips and pitch must be the same on both sides
212 if (type == CbmStsSensorClass::kDssdStereo) {
213 assert(fNofStripsB == fNofStripsF);
214 assert(fStripPitchB == fStripPitchF);
215 }
216
217 // --- Check consistency with geometric extensions
218 if (type == CbmStsSensorClass::kDssdStereo) {
219 assert(Double_t(fNofStripsF) * fStripPitchF <= fParSensor->GetPar(0));
221 assert(fDyActive <= fParSensor->GetPar(1));
222 }
223 else if (type == CbmStsSensorClass::kDssdOrtho) {
224 assert(Double_t(fNofStripsF) * fStripPitchF <= fParSensor->GetPar(0));
225 assert(Double_t(fNofStripsB) * fStripPitchB <= fParSensor->GetPar(1));
226 }
227
228 // --- Horizontal cross-connection for non-vanishing stereo angles
229 if (fStereoFront > 1.) fConnectEdgeFront = kTRUE;
230 if (fStereoBack > 1.) fConnectEdgeBack = kTRUE;
231
232 // Disable cross-connection (needs bug fixing still)
233 // TODO: Enable again
234 fConnectEdgeFront = kFALSE;
235 fConnectEdgeBack = kFALSE;
236
237 // Algorithms
242 else
244
245 // Name
246 fName = fSetupModule->GetName();
247}
248// -------------------------------------------------------------------------
249
250
251// ----- Info to string -------------------------------------------------
252std::string CbmStsRecoModule::ToString() const
253{
254 std::stringstream ss;
255 ss << fSetupModule->ToString() << " Strips " << fNofStripsF << " / " << fNofStripsB;
256 return ss.str();
257}
258// -------------------------------------------------------------------------
@ kStsModule
ClassImp(CbmStsRecoModule) CbmStsRecoModule
Determination of cluster parameters.
void Exec(CbmStsCluster &cluster, const CbmStsParModule *module)
Algorithm execution.
Algorithm for cluster finding in a linear array of channels.
Long64_t Exec(const std::vector< InputData > &input, std::vector< CbmStsCluster > &output, UInt_t address, UShort_t nChannels, UShort_t channelOffset, Double_t timeCutSigma, Double_t timeCutAbs, Bool_t connectEdge, const CbmStsParModule *modPar)
Algorithm execution.
Algorithm for hit finding in sensors with orthogonal strips.
Long64_t Exec(const std::vector< CbmStsCluster > &clustersF, const std::vector< CbmStsCluster > &clustersB, std::vector< CbmStsHit > &hits, UInt_t address, Double_t timeCutSig, Double_t timeCutAbs, UInt_t nStripsF, UInt_t nStripsB, Double_t pitchF, Double_t pitchB, Double_t lorentzF, Double_t lorentzB, TGeoHMatrix *matrix)
Execute algorithm.
Algorithm for hit finding in the sensors of the CBM-STS.
Long64_t Exec(const std::vector< CbmStsCluster > &clustersF, const std::vector< CbmStsCluster > &clustersB, std::vector< CbmStsHit > &hits, UInt_t address, Double_t timeCutSig, Double_t timeCutAbs, Double_t dY, UInt_t nStrips, Double_t pitch, Double_t stereoF, Double_t stereoB, Double_t lorentzF, Double_t lorentzB, TGeoHMatrix *matrix)
Execute algorithm.
Data class for STS clusters.
Data class for a single-channel message in the STS.
Definition CbmStsDigi.h:40
XPU_D uint16_t GetChannel() const
Channel number in module @value Channel number.
Definition CbmStsDigi.h:93
XPU_D int32_t GetAddress() const
Definition CbmStsDigi.h:74
Int_t GetAddress() const
TGeoPhysicalNode * GetPnode() const
Int_t GetNofDaughters() const
CbmStsElement * GetDaughter(Int_t index) const
Class representing an instance of a readout unit in the CBM-STS.
std::string ToString() const
Parameters for one STS module.
Constructional parameters of a STS sensor.
Int_t GetParInt(UInt_t index) const
Get the nearest integer value of a parameter.
CbmStsSensorClass GetClass() const
Get the sensor class.
Float_t GetPar(UInt_t index) const
Get a parameter.
Class for reconstruction in one STS module.
std::mutex fLock
///< Algo
Double_t fStereoFront
Strip stereo angle front side [deg].
Bool_t fConnectEdgeFront
Round-the edge clustering front side.
void AddDigiToQueue(const CbmStsDigi *digi, Int_t digiIndex)
Add a digi to the processing queue.
std::string ToString() const
Info to string.
CbmStsAlgoAnaCluster * fClusterAna
Double_t fLorentzShiftB
Average Lorentz shift back side [cm|.
Double_t fTimeCutDigisAbs
Time cut for cluster finding (in ns)
CbmStsAlgoFindHitsOrtho * fHitFinderOrtho
///< Algo
virtual ~CbmStsRecoModule()
Destructor.
TGeoHMatrix * fMatrix
Sensor position in global C.S. [cm].
Double_t fTimeCutClustersAbs
Time cut for hit finding (in sigma)
UInt_t fNofStripsF
Number of sensor strips front side.
Double_t fStripPitchF
Sensor strip pitch front side [cm].
void Init()
Set and check the needed parameters.
CbmStsAlgoFindHits * fHitFinder
///< Algo
Double_t fStereoBack
Strip stereo angle back side [deg].
std::vector< CbmStsCluster > fClustersF
std::vector< CbmStsHit > fHits
Double_t fTimeCutDigisSig
Time cut for cluster finding (in sigma)
Double_t fLorentzShiftF
Average Lorentz shift front side [cm|.
CbmStsAlgoFindClusters * fClusterFinder
///< Algo
Double_t fTimeCutClustersSig
Time cut for hit finding (in ns)
Double_t fDyActive
Active sensor size in y.
Bool_t fConnectEdgeBack
Round-the edge clustering back side.
CbmStsModule * fSetupModule
void Reconstruct()
Perform reconstruction.
void Reset()
Clear input queue.
UInt_t fNofStripsB
Number of sensor strips back side.
CbmStsRecoModule()
Default constructor.
std::vector< CbmStsCluster > fClustersB
std::vector< std::pair< const CbmStsDigi *, Long64_t > > fDigisF
Double_t fStripPitchB
Sensor strip pitch back side [cm].
std::vector< std::pair< const CbmStsDigi *, Long64_t > > fDigisB
const CbmStsParModule * fParModule
const CbmStsParSensor * fParSensor
int32_t GetMotherAddress(int32_t address, int32_t level)
Construct the address of an element from the address of a descendant element.