CbmRoot
Loading...
Searching...
No Matches
CaDataManager.h
Go to the documentation of this file.
1/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov, Sergei Zharko [committer] */
4
9
10#pragma once // include this header only once per compilation unit
11
12#include "CaDefs.h"
13#include "CaInputData.h"
14
15namespace cbm::algo::ca
16{
20 class alignas(constants::misc::Alignment) DataManager {
21 public:
23 DataManager() = default;
24
26 ~DataManager() = default;
27
29 DataManager(const DataManager& other) = delete;
30
32 DataManager(DataManager&& other) = delete;
33
35 DataManager& operator=(const DataManager& other) = delete;
36
38 DataManager& operator=(DataManager&& other) = delete;
39
42 int GetNofHits() { return fInputData.fvHits.size(); }
43
46 void ReadInputData(const std::string& fileName);
47
51 void ReserveNhits(HitIndex_t nHits) { fInputData.fvHits.reserve(nHits); }
52
55 void ResetInputData(HitIndex_t nHits = 0) noexcept;
56
60 void PushBackHit(const Hit& hit, int64_t streamId)
61 {
62 if (fInputData.fvStreamStartIndices.size() == 0 || fLastStreamId != streamId) { // new data stream
63 fLastStreamId = streamId;
64 fInputData.fvStreamStartIndices.push_back(fInputData.fvHits.size());
65 // for a case.. it is fixed later in InitData()
66 fInputData.fvStreamStopIndices.push_back(fInputData.fvHits.size());
67 }
68 fInputData.fvHits.push_back(hit);
69 }
70
73 void PushBackHit(const Hit& hit) { fInputData.fvHits.push_back(hit); }
74
77 void SetNhitKeys(int nKeys) { fInputData.fNhitKeys = nKeys; }
78
81
84 void WriteInputData(const std::string& fileName) const;
85
86
87 private:
91 void InitData();
92
100 template<int Level>
101 bool CheckInputData() const;
102
103
104 // ***************************
105 // ** Member variables list **
106 // ***************************
108 int64_t fLastStreamId{-1};
109 };
110
111
112 // *************************************
113 // ** Inline functions implementation **
114 // *************************************
115
116 // -------------------------------------------------------------------------------------------------------------------
117 //
118
119 // TODO: Complete this function
120 template<int Level>
121 inline bool DataManager::CheckInputData() const
122 {
123 if constexpr (Level == 0) {
124 return true;
125 } // Level = 0 -> do nothing
126 else if constexpr (Level > 0) { // Level = 1 and higher
127 // ----- Check if the hits container is not empty ----------------------------------------------------------------
128 if (fInputData.fvHits.size() == 0) {
129 LOG(warn) << "DataManager [check input]: Sample contains empty hits, tracking will not be executed";
130 return false;
131 }
132
133 // ----- Checks if the number of hit keys is valid ---------------------------------------------------------------
134 if (fInputData.fNhitKeys < 1) {
135 LOG(error) << "DataManager [check input]: Incorrect number of keys passed (" << fInputData.fNhitKeys
136 << "), tracking will not be executed";
137 return false;
138 }
139
140 // ----- Checks the indexes of first and last hits in stations
141 // TODO: Add one of the two following checks for fvStartHitIn
142
143 if constexpr (Level > 1) { // Level = 2 and higher
144 // ----- Checks for hits sorting -------------------------------------------------------------------------------
145 // TODO...
146 if constexpr (Level > 2) { // Level = 3 and higher
147 // ----- Checks for consistency of the particular hit --------------------------------------------------------
148 // TODO...
149 }
150 }
151 return true;
152 }
153 return true;
154 }
155} // namespace cbm::algo::ca
Compile-time constants definition for the CA tracking algorithm.
Structure for input data to the L1 tracking algorithm (declaration)
A manager for the input-output data of the CA tracking algorithm.
DataManager(DataManager &&other)=delete
Move constructor.
void SetNhitKeys(int nKeys)
Sets the number of hit keys.
void ReserveNhits(HitIndex_t nHits)
Reserve number of hits.
void ReadInputData(const std::string &fileName)
Reads input data object from boost-serialized binary file.
DataManager & operator=(const DataManager &other)=delete
Copy assignment operator.
DataManager(const DataManager &other)=delete
Copy constructor.
DataManager()=default
Default constructor.
void WriteInputData(const std::string &fileName) const
Writes input data object to boost-serialized binary file.
DataManager & operator=(DataManager &&other)=delete
Move assignment operator.
void PushBackHit(const Hit &hit, int64_t streamId)
Pushes back a hit (with a data stream info)
InputData && TakeInputData()
Takes (moves) the instance of the input data object.
InputData fInputData
Object of input data.
int64_t fLastStreamId
data stream Id of the last hit added
void InitData()
Initializes data object.
void ResetInputData(HitIndex_t nHits=0) noexcept
Resets the input data block.
int GetNofHits()
Gets number of hits stored.
~DataManager()=default
Destructor.
void PushBackHit(const Hit &hit)
Pushes back a hit.
ca::Hit class describes a generic hit for the CA tracker
Definition CaHit.h:32
int fNhitKeys
Number of hit keys used for rejecting fake STS hits.
Vector< Hit > fvHits
Sample of input hits.
Vector< HitIndex_t > fvStreamStartIndices
Index of the first hit in the sorted hits vector for a given data stream.
TODO: SZh 8.11.2022: add selection of parameterisation.
Definition CaBranch.h:14
unsigned int HitIndex_t
Index of ca::Hit.
Definition CaHit.h:27