BmnRoot
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 if (!GetCell(cell->GetAddress())) {
74 new ((*fCells)[fCells->GetEntriesFast()]) BmnNdetCell(*cell);
75 } else {
76 LOG(error) << "BmnNdetEvent::AddCell. Tried to duplicate address.";
77 return;
78 }
79}
80
82{
83 for (int i = 0; i < fCells->GetEntriesFast(); ++i) {
84 BmnNdetCell* cell = (BmnNdetCell*)fCells->At(i);
85 if (cell->GetAddress() == address) {
86 return cell;
87 }
88 }
89 return nullptr;
90}
91
92BmnNdetCell* BmnNdetEvent::GetCell(uint32_t ArmId, uint32_t RowId, uint32_t ColumnId, uint32_t LayerId)
93{
94 uint32_t address = BmnNdetAddress::GetAddress(ArmId, RowId, ColumnId, LayerId);
95 return GetCell(address);
96}
97
99{
100 if (fCells) {
101 fCells->Delete();
102 }
103}
104
106{
107 for (int i = 0; i < fCells->GetEntriesFast(); ++i) {
108 BmnNdetCell* cell = (BmnNdetCell*)fCells->At(i);
109 cell->ResetTimeEnergy();
110 }
111}
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
void ResetTimeEnergy()
Class for Bmn Ndet data container in event.
virtual ~BmnNdetEvent()
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 &)
void ResetCells()
Reset time and energy for all cells.