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
59 void PushBackHit(const Hit& hit, int64_t streamId)
60 {
61 if (fInputData.fvStreamStartIndices.size() == 0 || fLastStreamId != streamId) { // new data stream
62 fLastStreamId = streamId;
63 fInputData.fvStreamStartIndices.push_back(fInputData.fvHits.size());
64 // for a case.. it is fixed later in InitData()
65 fInputData.fvStreamStopIndices.push_back(fInputData.fvHits.size());
66 }
67 fInputData.fvHits.push_back(hit);
68 }
69
72 void SetNhitKeys(int nKeys) { fInputData.fNhitKeys = nKeys; }
73
76 bool SendInputData(InputData& destination);
77
80
83 void WriteInputData(const std::string& fileName) const;
84
85
86 private:
90 void InitData();
91
99 template<int Level>
100 bool CheckInputData() const;
101
102
103 // ***************************
104 // ** Member variables list **
105 // ***************************
107 int64_t fLastStreamId{-1};
108 };
109
110
111 // *************************************
112 // ** Inline functions implementation **
113 // *************************************
114
115 // -------------------------------------------------------------------------------------------------------------------
116 //
117
118 // TODO: Complete this function
119 template<int Level>
120 inline bool DataManager::CheckInputData() const
121 {
122 if constexpr (Level == 0) {
123 return true;
124 } // Level = 0 -> do nothing
125 else if constexpr (Level > 0) { // Level = 1 and higher
126 // ----- Check if the hits container is not empty ----------------------------------------------------------------
127 if (fInputData.fvHits.size() == 0) {
128 LOG(warn) << "DataManager [check input]: Sample contains empty hits, tracking will not be executed";
129 return false;
130 }
131
132 // ----- Checks if the number of hit keys is valid ---------------------------------------------------------------
133 if (fInputData.fNhitKeys < 1) {
134 LOG(error) << "DataManager [check input]: Incorrect number of keys passed (" << fInputData.fNhitKeys
135 << "), tracking will not be executed";
136 return false;
137 }
138
139 // ----- Checks the indexes of first and last hits in stations
140 // TODO: Add one of the two following checks for fvStartHitIn
141
142 if constexpr (Level > 1) { // Level = 2 and higher
143 // ----- Checks for hits sorting -------------------------------------------------------------------------------
144 // TODO...
145 if constexpr (Level > 2) { // Level = 3 and higher
146 // ----- Checks for consistency of the particular hit --------------------------------------------------------
147 // TODO...
148 }
149 }
150 return true;
151 }
152 return true;
153 }
154} // 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.
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.
bool SendInputData(InputData &destination)
Sends (moves) input data to an object (alternative method of data sending)
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