BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
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
7
BmnNdetEvent::BmnNdetEvent
()
8
:
TNamed
(
"BmnNdetEvent"
,
"NdetEvent"
)
9
,
fCells
(new
TClonesArray
(
"BmnNdetCell"
))
10
{}
11
12
BmnNdetEvent::~BmnNdetEvent
()
13
{
14
if
(
fCells
) {
15
fCells
->Delete();
16
delete
fCells
;
17
fCells
=
nullptr
;
18
}
19
}
20
21
BmnNdetEvent::BmnNdetEvent
(
const
BmnNdetEvent
& other)
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
30
BmnNdetEvent::BmnNdetEvent
(
BmnNdetEvent
&& other) noexcept
31
:
TNamed
(std::move(other))
32
,
fCells
(other.fCells)
33
{
34
other.fCells =
nullptr
;
35
}
36
37
BmnNdetEvent
&
BmnNdetEvent::operator=
(
const
BmnNdetEvent
& other)
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
55
BmnNdetEvent
&
BmnNdetEvent::operator=
(
BmnNdetEvent
&& other)
noexcept
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
71
void
BmnNdetEvent::AddCell
(
BmnNdetCell
* cell)
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
85
BmnNdetCell
*
BmnNdetEvent::GetCell
(uint32_t address)
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
96
BmnNdetCell
*
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
102
void
BmnNdetEvent::reset
()
103
{
104
if
(
fCells
) {
105
fCells
->Delete();
106
}
107
}
108
109
void
BmnNdetEvent::ResetCells
()
110
{
111
for
(
int
i
= 0;
i
<
fCells
->GetEntriesFast(); ++
i
) {
112
BmnNdetCell
* cell = (
BmnNdetCell
*)
fCells
->At(
i
);
113
cell->
ResetTimeEnergy
();
114
}
115
}
i
int i
Definition
P4_F32vec4.h:22
BmnNdetAddress::GetAddress
static uint32_t GetAddress(uint32_t ArmId, uint32_t RowId, uint32_t ColumnId, uint32_t LayerId)
Return address.
Definition
BmnNdetAddress.h:39
BmnNdetCell
Definition
BmnNdetCell.h:11
BmnNdetCell::GetAddress
uint32_t GetAddress() const
Definition
BmnNdetCell.h:44
BmnNdetCell::GetTime
double GetTime() const
Definition
BmnNdetCell.h:46
BmnNdetCell::ResetTimeEnergy
void ResetTimeEnergy()
Definition
BmnNdetCell.cxx:88
BmnNdetEvent::~BmnNdetEvent
virtual ~BmnNdetEvent()
Destructor.
Definition
BmnNdetEvent.cxx:12
BmnNdetEvent::fCells
TClonesArray * fCells
Definition
BmnNdetEvent.h:89
BmnNdetEvent::BmnNdetEvent
BmnNdetEvent()
Default constructor.
Definition
BmnNdetEvent.cxx:7
BmnNdetEvent::GetCell
BmnNdetCell * GetCell(uint32_t address)
Get a cell based on its address.
Definition
BmnNdetEvent.cxx:85
BmnNdetEvent::reset
void reset()
Zero all fields.
Definition
BmnNdetEvent.cxx:102
BmnNdetEvent::AddCell
void AddCell(BmnNdetCell *cell)
Add a cell to the event.
Definition
BmnNdetEvent.cxx:71
BmnNdetEvent::operator=
BmnNdetEvent & operator=(const BmnNdetEvent &)
Assignment operator.
Definition
BmnNdetEvent.cxx:37
BmnNdetEvent::ResetCells
void ResetCells()
Reset time and energy for all cells.
Definition
BmnNdetEvent.cxx:109
TCollection::GetSize
virtual Int_t GetSize() const
TNamed::TNamed
TNamed()
TNamed::operator=
TNamed & operator=(const TNamed &rhs)
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TObject::TClonesArray
friend friend class TClonesArray
BmnNdetEvent.h
detectors
ndet
BmnNdetEvent.cxx
Generated on
for BmnRoot by
1.17.0