CbmRoot
Loading...
Searching...
No Matches
Cluster2D.h
Go to the documentation of this file.
1/* Copyright (C) 2024 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dominik Smith [committer], Alexandru Bercuci */
4
5#pragma once
6
7#include "DigiRec.h"
8#include "compat/RTypes.h"
9
10#include <cstdint>
11#include <vector> // for vector
12
13class CbmTrdDigi;
14
15namespace cbm::algo::trd
16{
22 class Cluster2D {
23
24 public:
26 {
27 kFasp = 5
28 ,
29 kStart
30 ,
31 kStop
32 };
33
37 Cluster2D() = delete;
38 Cluster2D(const Cluster2D& ref);
49 Cluster2D(int32_t address, int32_t idx, const CbmTrdDigi* digi, uint16_t chT, uint16_t chR, int32_t r,
50 int32_t time);
54 virtual ~Cluster2D(){};
55
61 void AddDigiIdxPair(int32_t index, const CbmTrdDigi* digi)
62 {
63 fDigiIndices.push_back(index);
64 fDigis.push_back(digi);
65 }
66
71 void AddDigiIdxPairs(const std::vector<int32_t>& indices, const std::vector<const CbmTrdDigi*> digis)
72 {
73 fDigiIndices.insert(fDigiIndices.end(), indices.begin(), indices.end());
74 fDigis.insert(fDigis.end(), digis.begin(), digis.end());
75 }
76
81 int32_t GetNofDigis() const { return fDigiIndices.size(); }
82
88 int32_t GetDigi(int32_t index) const { return fDigiIndices[index]; }
89
94 const std::vector<int32_t>& GetDigiIndices() const { return fDigiIndices; }
95
100 std::vector<const CbmTrdDigi*>& GetDigis() { return fDigis; }
101
106 const std::vector<DigiRec>& GetRecDigis() const { return fRecDigis; }
107
112 {
113 fDigiIndices.clear();
114 fDigis.clear();
115 fRecDigis.clear();
116 }
117
119 int32_t GetAddress() const { return fAddress; }
120
129 bool AddDigi(int32_t idx, const CbmTrdDigi* digi, uint16_t chT = 0xffff, uint16_t chR = 0, int32_t dt = 0);
130
132 uint16_t GetNCols() const { return fNCols; }
133 uint16_t GetNRows() const { return fNRows & 0x1f; }
134 uint16_t GetNRowsRaw() const { return fNRows; }
135 uint16_t GetEndCh() const { return fStartCh + fNCols - 1; }
136 uint16_t GetRow() const { return GetNRows(); }
137 uint16_t GetSize() const { return GetNCols(); }
138 uint16_t GetStartCh() const { return fStartCh; }
139 uint32_t GetStartTime() const { return fStartTime; }
140 bool HasFaspDigis() const { return true; }
141 bool HasStart() const { return TESTBIT(fNRows, kStart); }
142 bool HasStop() const { return TESTBIT(fNRows, kStop); }
143
149 int32_t IsChannelInRange(uint16_t chT, uint16_t chR) const;
150
156 bool Merge(Cluster2D* second);
157
162 bool Finalize(const size_t numCols);
163
165 void SetNCols(uint16_t ncols) { fNCols = ncols; }
166 void SetNRows(uint16_t nrows)
167 {
168 fNRows &= (7 << 5);
169 fNRows |= (nrows & 0x1f);
170 }
171 void SetStart(bool set = true) { set ? SETBIT(fNRows, kStart) : CLRBIT(fNRows, kStart); }
172 void SetStop(bool set = true) { set ? SETBIT(fNRows, kStop) : CLRBIT(fNRows, kStop); }
173
174 private:
175 std::vector<DigiRec> fRecDigis;
176 std::vector<const CbmTrdDigi*> fDigis;
177 std::vector<int32_t> fDigiIndices;
178
179 int32_t fAddress = 0;
180 uint8_t fNCols = 0; //< number of columns with charge above threshold
181 uint8_t fNRows = 0x1f; //< cluster row info plus extra meta data. Use dedicated getters for the correct value
182 uint16_t fStartCh = 0xffff; //< channel address of first channel
183 uint32_t fStartTime = 0xffffffff;
184 };
185} // namespace cbm::algo::trd
Compatibility header for basic ROOT macros.
#define SETBIT(n, i)
Definition RTypes.h:15
#define TESTBIT(n, i)
Definition RTypes.h:17
#define CLRBIT(n, i)
Definition RTypes.h:16
Data Container for TRD clusters.
Definition Cluster2D.h:22
uint32_t GetStartTime() const
Definition Cluster2D.h:139
uint16_t GetSize() const
Definition Cluster2D.h:137
bool Finalize(const size_t numCols)
Fill array of calibrated digis.
bool Merge(Cluster2D *second)
Merge current cluster with info from second.
uint16_t GetNRowsRaw() const
Definition Cluster2D.h:134
const std::vector< DigiRec > & GetRecDigis() const
Get array of calibrated digis.
Definition Cluster2D.h:106
int32_t GetDigi(int32_t index) const
Get digi at position index.
Definition Cluster2D.h:88
void ClearDigis()
Remove all digis.
Definition Cluster2D.h:111
uint16_t GetRow() const
Definition Cluster2D.h:136
int32_t fAddress
Unique detector ID.
Definition Cluster2D.h:179
virtual ~Cluster2D()
Destructor.
Definition Cluster2D.h:54
const std::vector< int32_t > & GetDigiIndices() const
Get array of digi indices.
Definition Cluster2D.h:94
std::vector< const CbmTrdDigi * > fDigis
Array of digi pointers.
Definition Cluster2D.h:176
void AddDigiIdxPair(int32_t index, const CbmTrdDigi *digi)
Add digi to cluster.
Definition Cluster2D.h:61
int32_t GetNofDigis() const
Number of digis in cluster.
Definition Cluster2D.h:81
uint16_t GetNCols() const
Definition Cluster2D.h:132
std::vector< const CbmTrdDigi * > & GetDigis()
Get array of digi pointers.
Definition Cluster2D.h:100
void SetStart(bool set=true)
Definition Cluster2D.h:171
uint16_t GetEndCh() const
Definition Cluster2D.h:135
@ kStart
only for triangular if no T in first col
Definition Cluster2D.h:29
@ kStop
only for triangular if no R in last col
Definition Cluster2D.h:31
@ kFasp
set type of FEE digis contained
Definition Cluster2D.h:27
std::vector< int32_t > fDigiIndices
Array of digi indices.
Definition Cluster2D.h:177
void SetStop(bool set=true)
Definition Cluster2D.h:172
Cluster2D()=delete
Default constructor.
uint16_t GetNRows() const
Definition Cluster2D.h:133
bool AddDigi(int32_t idx, const CbmTrdDigi *digi, uint16_t chT=0xffff, uint16_t chR=0, int32_t dt=0)
Append digi to cluster.
Definition Cluster2D.cxx:44
bool HasFaspDigis() const
Definition Cluster2D.h:140
void SetNRows(uint16_t nrows)
Definition Cluster2D.h:166
int32_t IsChannelInRange(uint16_t chT, uint16_t chR) const
Query on RO channels list.
void SetNCols(uint16_t ncols)
Definition Cluster2D.h:165
int32_t GetAddress() const
Definition Cluster2D.h:119
void AddDigiIdxPairs(const std::vector< int32_t > &indices, const std::vector< const CbmTrdDigi * > digis)
Add array of digi to cluster.
Definition Cluster2D.h:71
std::vector< DigiRec > fRecDigis
Array of calibrated digis.
Definition Cluster2D.h:175
uint16_t GetStartCh() const
Definition Cluster2D.h:138