CbmRoot
Loading...
Searching...
No Matches
CbmRichMCbmDenoiseCnn.h
Go to the documentation of this file.
1/* Copyright (C) 2024 UGiessen, Giessen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Martin Beyer [committer] */
4
11#if HAVE_ONNXRUNTIME
12
13#pragma once
14
15#include <TObject.h>
16#include <TSystem.h>
17
18#include <array>
19#include <string>
20#include <vector>
21
22#include <onnxruntime/core/session/onnxruntime_cxx_api.h>
23
24class CbmEvent;
26class TClonesArray;
27
36class CbmRichMCbmDenoiseCnn : public TObject {
37 public:
39 CbmRichMCbmDenoiseCnn() = default;
40
42 ~CbmRichMCbmDenoiseCnn() = default;
43
45 CbmRichMCbmDenoiseCnn(const CbmRichMCbmDenoiseCnn&) = delete;
46
48 CbmRichMCbmDenoiseCnn operator=(const CbmRichMCbmDenoiseCnn&) = delete;
49
51 void Init();
52
58 void Process(CbmEvent* event, const TClonesArray* richHits);
59
67 void ProcessTimeWindow(const std::vector<int>& timeWindowHitIndices, const double& seedHitTime,
68 const TClonesArray* richHits);
69
75 int AddressToGridIndex(const int address);
76
82 std::vector<float> Inference(const std::vector<int>& gridIndices);
83
88 void SetClassificationThreshold(float threshold) { fClassificationThreshold = threshold; }
89
90 private:
91 const double fTimeWindowLength{25.};
92 const int fMinHitsInTimeWindow{7};
93
94 float fClassificationThreshold{0.5};
95
96 const std::string fOnnxFilePath =
97 std::string(gSystem->Getenv("VMCWORKDIR")) + "/parameters/rich/mRich/rich_v21c_mcbm_UNet.onnx";
98
99 // TODO: read names/shapes from onnx file
100 const std::vector<const char*> fInputNames{"input"};
101 const std::vector<const char*> fOutputNames{"output"};
102
103 const std::array<int64_t, 4> fInputShape{1, 1, 72, 32};
104 const std::array<int64_t, 4> fOutputShape{1, 1, 72, 32};
105
106 std::array<float, 2304> fInput{};
107
108 std::unique_ptr<Ort::Env> fOrtEnv{nullptr};
109 std::unique_ptr<Ort::SessionOptions> fOrtSessionOptions{nullptr};
110 std::unique_ptr<Ort::Session> fOrtSession{nullptr};
111 std::unique_ptr<Ort::MemoryInfo> fOrtAllocatorInfo{nullptr};
112 std::unique_ptr<Ort::RunOptions> fOrtRunOptions{nullptr};
113
114 std::unique_ptr<Ort::Value> fOrtInput{nullptr};
115
116 CbmRichDigiMapManager* fCbmRichDigiMapManager{nullptr};
117
118 ClassDef(CbmRichMCbmDenoiseCnn, 1);
119};
120
121#endif
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34