BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnNdetEvent.cxx
Go to the documentation of this file.
1#include "BmnNdetEvent.h"
2
3#include "FairLogger.h"
4
5#include <iostream>
6
8 : TNamed("BmnNdetEvent", "NdetEvent")
9 , fCells(new TClonesArray("BmnNdetCell"))
10{}
11
13{
14 if (fCells) {
15 fCells->Delete();
16 delete fCells;
17 fCells = nullptr;
18 }
19}
20
22 : TNamed(other)
23 , fCells(new TClonesArray("BmnNdetCell", other.fCells->GetSize()))
24{
25 for (int i = 0; i < other.fCells->GetEntriesFast(); ++i) {
26 new ((*fCells)[i]) BmnNdetCell(*(BmnNdetCell*)other.fCells->At(i));
27 }
28}
29
31 : TNamed(std::move(other))
32 , fCells(other.fCells)
33{
34 other.fCells = nullptr;
35}
36
38{
39 if (this != &other) {
40 TNamed::operator=(other);
41
42 if (fCells) {
43 fCells->Delete();
44 delete fCells;
45 }
46
47 fCells = new TClonesArray("BmnNdetCell", other.fCells->GetSize());
48 for (int i = 0; i < other.fCells->GetEntriesFast(); ++i) {
49 new ((*fCells)[i]) BmnNdetCell(*(BmnNdetCell*)other.fCells->At(i));
50 }
51 }
52 return *this;
53}
54
56{
57 if (this != &other) {
58 TNamed::operator=(std::move(other));
59
60 if (fCells) {
61 fCells->Delete();
62 delete fCells;
63 }
64
65 fCells = other.fCells;
66 other.fCells = nullptr;
67 }
68 return *this;
69}
70
72{
73 BmnNdetCell* existing = GetCell(cell->GetAddress());
74 if (!existing) {
75 new ((*fCells)[fCells->GetEntriesFast()]) BmnNdetCell(*cell);
76 return;
77 }
78
79 LOG(warn) << "BmnNdetEvent::AddCell. Duplicate address, keeping earlier hit.";
80 if (cell->GetTime() < existing->GetTime()) {
81 *existing = *cell;
82 }
83}
84
86{
87 for (int i = 0; i < fCells->GetEntriesFast(); ++i) {
88 BmnNdetCell* cell = (BmnNdetCell*)fCells->At(i);
89 if (cell->GetAddress() == address) {
90 return cell;
91 }
92 }
93 return nullptr;
94}
95
96BmnNdetCell* BmnNdetEvent::GetCell(uint32_t ArmId, uint32_t RowId, uint32_t ColumnId, uint32_t LayerId)
97{
98 uint32_t address = BmnNdetAddress::GetAddress(ArmId, RowId, ColumnId, LayerId);
99 return GetCell(address);
100}
101
103{
104 if (fCells) {
105 fCells->Delete();
106 }
107}
108
110{
111 for (int i = 0; i < fCells->GetEntriesFast(); ++i) {
112 BmnNdetCell* cell = (BmnNdetCell*)fCells->At(i);
113 cell->ResetTimeEnergy();
114 }
115}
int i
Definition P4_F32vec4.h:22
static uint32_t GetAddress(uint32_t ArmId, uint32_t RowId, uint32_t ColumnId, uint32_t LayerId)
Return address.
uint32_t GetAddress() const
Definition BmnNdetCell.h:44
double GetTime() const
Definition BmnNdetCell.h:46
void ResetTimeEnergy()
virtual ~BmnNdetEvent()
Destructor.
TClonesArray * fCells
BmnNdetEvent()
Default constructor.
BmnNdetCell * GetCell(uint32_t address)
Get a cell based on its address.
void reset()
Zero all fields.
void AddCell(BmnNdetCell *cell)
Add a cell to the event.
BmnNdetEvent & operator=(const BmnNdetEvent &)
Assignment operator.
void ResetCells()
Reset time and energy for all cells.
virtual Int_t GetSize() const
TNamed & operator=(const TNamed &rhs)
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
friend friend class TClonesArray