Skip to content
Snippets Groups Projects
Commit bc6f27e0 authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

algo: Update STS Hitfinder.

parent b8e756c9
No related branches found
No related tags found
1 merge request!1161algo: Update STS GPU Reco
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
#define CBM_ALGO_BASE_CHAINCONTEXT_H #define CBM_ALGO_BASE_CHAINCONTEXT_H
#include "Options.h" #include "Options.h"
#include "RecoParams.h"
namespace cbm::algo namespace cbm::algo
{ {
struct ChainContext { struct ChainContext {
Options opts; Options opts;
RecoParams recoParams;
}; };
} // namespace cbm::algo } // namespace cbm::algo
......
...@@ -16,6 +16,7 @@ namespace cbm::algo ...@@ -16,6 +16,7 @@ namespace cbm::algo
void SetContext(ChainContext* ctx) { fContext = ctx; } void SetContext(ChainContext* ctx) { fContext = ctx; }
const Options& Opts() const { return gsl::make_not_null(fContext)->opts; } const Options& Opts() const { return gsl::make_not_null(fContext)->opts; }
const RecoParams& Params() const { return gsl::make_not_null(fContext)->recoParams; }
private: private:
ChainContext* fContext = nullptr; ChainContext* fContext = nullptr;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "Prelude.h" #include "Prelude.h"
#include "Property.h" #include "Property.h"
namespace CORE_INTERFACE_NS::config namespace cbm::algo::config
{ {
template<typename T, T... Values, typename Func> template<typename T, T... Values, typename Func>
...@@ -144,6 +144,6 @@ namespace CORE_INTERFACE_NS::config ...@@ -144,6 +144,6 @@ namespace CORE_INTERFACE_NS::config
} }
}; };
} // namespace CORE_INTERFACE_NS::config } // namespace cbm::algo::config
#endif #endif
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
Authors: Felix Weiglhofer [committer] */ Authors: Felix Weiglhofer [committer] */
#include "LandauTable.h" #include "LandauTable.h"
#include <fairlogger/Logger.h>
#include <fstream> #include <fstream>
using namespace cbm::algo; using namespace cbm::algo;
...@@ -16,10 +18,13 @@ sts::LandauTable sts::LandauTable::FromFile(std::filesystem::path path) ...@@ -16,10 +18,13 @@ sts::LandauTable sts::LandauTable::FromFile(std::filesystem::path path)
std::ifstream file(path); std::ifstream file(path);
while (!file.eof()) { while (!file.eof()) {
f32 q, p; f32 q, p;
file >> q >> p; file >> q >> p;
charge.push_back(q); charge.push_back(q);
prob.push_back(p); prob.push_back(p);
LOG(trace) << "Reading Landau table " << path << " q=" << q << " p=" << p;
} }
// TODO: check if charge is monotonically increasing, also more than 2 entries // TODO: check if charge is monotonically increasing, also more than 2 entries
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -14,46 +14,16 @@ ...@@ -14,46 +14,16 @@
#include <optional> #include <optional>
#include <vector> #include <vector>
#include <xpu/host.h>
#include "StsHitfinder.h" #include "StsHitfinder.h"
#include "SubChain.h"
#include "gpu/xpu_legacy.h"
#include "sts/HitfinderPars.h"
#include "sts/LandauTable.h"
namespace cbm::algo namespace cbm::algo::sts
{ {
struct StsModuleTransformationMatrix { struct HitfinderTimes {
// Rotation + translation matrix to transform
// local module coordinates into global coordinate system.
// No need for fancy math types here. These values are just copied
// and moved to the GPU.
std::array<float, 9> rotation; // 3x3 matrix
std::array<float, 3> translation;
};
struct StsModulePar {
int32_t address;
float dY;
float pitch;
float stereoF;
float stereoB;
float lorentzF;
float lorentzB;
StsModuleTransformationMatrix localToGlobal;
};
struct StsLandauTable {
std::vector<float> values;
float stepSize;
};
struct StsHitfinderPar {
StsAsicPar asic; // Asic definitions. Currently assumes same parameters for all asics.
int nChannels; // Total number of channels per module. Hitfinder assumes nChannels / 2 channels per side.
std::vector<StsModulePar> modules;
StsLandauTable landauTable;
};
struct StsHitfinderTimes {
double timeIO = 0; double timeIO = 0;
double timeSortDigi = 0; double timeSortDigi = 0;
double timeCluster = 0; double timeCluster = 0;
...@@ -67,22 +37,14 @@ namespace cbm::algo ...@@ -67,22 +37,14 @@ namespace cbm::algo
* handles memory transfer for input / output data and conversion to the * handles memory transfer for input / output data and conversion to the
* regular CBM STS types. * regular CBM STS types.
*/ */
class StsHitfinderChain { class HitfinderChain : public SubChain {
public: public:
void SetParameters(const StsHitfinderPar& parameters); void SetParameters(const sts::HitfinderPars& parameters);
const StsHitfinderPar& GetParameters() const { return *fPars; } const sts::HitfinderPars& GetParameters() const { return *fPars; }
void operator()(gsl::span<const CbmStsDigi>); void operator()(gsl::span<const CbmStsDigi>);
StsHitfinderTimes GetHitfinderTimes() const { return fHitfinderTimes; }
/**
* Returns access to (host copies of) the raw buffers used by the gpu hitfinder.
* This is currently the only way to access the produced hits and cluster.
*/
const StsHitfinderHost& GetHitfinderBuffers() const { return fHitfinderHost; }
private: private:
// Shorthands to map module-address onto digis in that module // Shorthands to map module-address onto digis in that module
using DigiMapSide = std::map<int, std::vector<CbmStsDigi>>; using DigiMapSide = std::map<int, std::vector<CbmStsDigi>>;
...@@ -96,8 +58,8 @@ namespace cbm::algo ...@@ -96,8 +58,8 @@ namespace cbm::algo
* TODO: These values might be wildly off. Look for better estimations. * TODO: These values might be wildly off. Look for better estimations.
* TODO: Should be configurable at runtime. * TODO: Should be configurable at runtime.
*/ */
static constexpr float kClustersPerDigiFactor = 0.5f; static constexpr float kClustersPerDigiFactor = 1.f;
static constexpr float kHitsPerClustersFactor = 4.f; static constexpr float kHitsPerClustersFactor = 1.5f;
/** /**
* Ensure parameters were set. Raises log(fatal) otherwise. * Ensure parameters were set. Raises log(fatal) otherwise.
...@@ -127,21 +89,24 @@ namespace cbm::algo ...@@ -127,21 +89,24 @@ namespace cbm::algo
void FlattenDigis(DigiMap& digiMap); void FlattenDigis(DigiMap& digiMap);
void FlattenDigisSide(DigiMapSide& digis, bool isFront); void FlattenDigisSide(DigiMapSide& digis, bool isFront);
void CollectTimingInfo();
/** /**
* Transfer Hits / Clusters back to host and convert to common CBM types. * Transfer Hits / Clusters back to host and convert to common CBM types.
*/ */
void AppendClustersModule(int module, bool isFront, std::vector<StsGpuCluster>&); void AppendClustersModule(int module, bool isFront, std::vector<sts::Cluster>&);
void AppendHitsModule(int module, std::vector<StsGpuHit>&); void AppendHitsModule(int module, std::vector<sts::Hit>&);
// Debug functions, ensure reco produces sane results
void EnsureDigiOffsets(DigiMap&);
void EnsureDigisSorted();
void EnsureChannelOffsets(span<u32>);
void EnsureClustersSane(span<GpuClusterIdx>, span<int>);
void EnsureClustersSorted();
std::optional<const StsHitfinderPar> fPars; std::optional<const sts::HitfinderPars> fPars;
StsHitfinderTimes fHitfinderTimes;
StsHitfinderHost fHitfinderHost; Hitfinder fHitfinder;
StsHitfinderGpu fHitfinderGpu;
}; };
} // namespace cbm::algo } // namespace cbm::algo::sts
#endif // #ifndef CBM_ALGO_STS_HITFINDER_CHAIN_H #endif // #ifndef CBM_ALGO_STS_HITFINDER_CHAIN_H
../../parameters/sts/LandauWidthTable.txt
\ No newline at end of file
---
asic:
nAdc: 32
dynamicRange: 75000
threshold: 3000
timeResolution: 5
deadTime: 800
noise: 1000
zeroNoiseRate: 0.00397890015
nChannels: 2048
modules:
- address: 0x10008002
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [-1, -1.22464685e-16, 0, 1.22464685e-16, -1, 0, 0, 0, 1]
translation: [-2.97959995, 2.86999989, 27.2849998]
- address: 0x10018002
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [-1, -1.22464685e-16, 0, 1.22464685e-16, -1, 0, 0, 0, 1]
translation: [-2.97959995, -2.86999989, 27.4850006]
- address: 0x10008402
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [1, 1.22464685e-16, 1.22464685e-16, 1.22464685e-16, -1, 0, 1.22464685e-16, 1.49975976e-32, -1]
translation: [2.97959995, 2.86999989, 28.7150002]
- address: 0x10018402
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [1, 1.22464685e-16, 1.22464685e-16, 1.22464685e-16, -1, 0, 1.22464685e-16, 1.49975976e-32, -1]
translation: [2.97959995, -2.86999989, 28.5149994]
- address: 0x10008012
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [1, 1.22464685e-16, 1.22464685e-16, 1.22464685e-16, -1, 0, 1.22464685e-16, 1.49975976e-32, -1]
translation: [-5.95919991, 5.96999979, 42.9150009]
- address: 0x10018012
dY: 12.1599998
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [1, 1.22464685e-16, 1.22464685e-16, 1.22464685e-16, -1, 0, 1.22464685e-16, 1.49975976e-32, -1]
translation: [-5.95919991, -2.86999989, 42.7150002]
- address: 0x10008412
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [-1, -1.22464685e-16, 0, 1.22464685e-16, -1, 0, 0, 0, 1]
translation: [7.31114159e-16, 5.96999979, 41.0849991]
- address: 0x10018412
dY: 12.1599998
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [-1, -1.22464685e-16, 0, 1.22464685e-16, -1, 0, 0, 0, 1]
translation: [-3.51473622e-16, -2.86999989, 41.2849998]
- address: 0x10008812
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [1, 1.22464685e-16, 1.22464685e-16, 1.22464685e-16, -1, 0, 1.22464685e-16, 1.49975976e-32, -1]
translation: [5.95919991, 5.73999977, 42.9150009]
- address: 0x10018812
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [1, 1.22464685e-16, 1.22464685e-16, 1.22464685e-16, -1, 0, 1.22464685e-16, 1.49975976e-32, -1]
translation: [5.95919991, 1.33226763e-15, 42.7150002]
- address: 0x10028812
dY: 5.96000004
pitch: 0.00579999993
stereoF: 0
stereoB: 7.5
lorentzF: 0
lorentzB: 0
localToGlobal:
rotation: [1, 1.22464685e-16, 1.22464685e-16, 1.22464685e-16, -1, 0, 1.22464685e-16, 1.49975976e-32, -1]
translation: [5.95919991, -5.73999977, 42.5149994]
...
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment