BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnMatch.cxx
Go to the documentation of this file.
1
/**
2
* \file BmnMatch.cxx
3
* \author Andrey Lebedev <andrey.lebedev@gsi.de> - original author for CBM experiment
4
* \author Sergey Merts <sergey.merts@gmail.com> - modifications for BMN experiment
5
* \date 2013-2014
6
**/
7
8
#include "
BmnMatch.h
"
9
10
#include <sstream>
11
12
using
std::make_pair;
13
using
std::stringstream;
14
15
BmnMatch::BmnMatch
()
16
:
fLinks
()
17
,
fTotalWeight
(0.)
18
,
fMatchedIndex
(-1)
19
{}
20
21
BmnMatch::~BmnMatch
()
22
{
23
fLinks
.clear();
24
}
25
26
string
BmnMatch::ToString
()
const
27
{
28
stringstream ss;
29
ss <<
"BmnMatch: "
;
30
Int_t
nofLinks =
GetNofLinks
();
31
ss <<
"nofLinks="
<< nofLinks <<
"\n"
;
32
for
(
Int_t
i
= 0;
i
< nofLinks;
i
++) {
33
const
BmnLink
& link =
fLinks
[
i
];
34
ss << link.
ToString
();
35
}
36
ss <<
" totalWeight="
<<
fTotalWeight
<<
", matchedIndex="
<<
fMatchedIndex
<< std::endl;
37
return
ss.str();
38
}
39
40
void
BmnMatch::AddLink
(
const
BmnMatch
&
match
)
41
{
42
Int_t
nofLinks =
match
.GetNofLinks();
43
for
(
Int_t
i
= 0;
i
< nofLinks;
i
++) {
44
AddLink
(
match
.GetLink(
i
));
45
}
46
}
47
48
void
BmnMatch::AddLink
(
const
BmnLink
& newLink)
49
{
50
Int_t
addedIndex = -1;
51
Int_t
nofLinks =
GetNofLinks
();
52
for
(
Int_t
i
= 0;
i
< nofLinks;
i
++) {
53
BmnLink
& link =
fLinks
[
i
];
54
if
(link == newLink) {
55
link.
AddWeight
(newLink.
GetWeight
());
56
addedIndex =
i
;
57
break
;
58
}
59
}
60
if
(addedIndex < 0) {
61
fLinks
.push_back(newLink);
62
addedIndex =
fLinks
.size() - 1;
63
}
64
65
fTotalWeight
+= newLink.
GetWeight
();
66
if
(
fMatchedIndex
< 0) {
67
fMatchedIndex
= addedIndex;
68
}
else
{
69
if
(
fLinks
[addedIndex].GetWeight() >
fLinks
[
fMatchedIndex
].GetWeight()) {
70
fMatchedIndex
= addedIndex;
71
}
72
}
73
}
74
75
void
BmnMatch::AddLink
(
Double_t
weight,
Int_t
index,
Int_t
entry,
Int_t
file)
76
{
77
BmnLink
link(weight, index, entry, file);
78
AddLink
(link);
79
}
80
81
void
BmnMatch::ClearLinks
()
82
{
83
fLinks
.clear();
84
fTotalWeight
= 0.;
85
fMatchedIndex
= -1;
86
}
i
int i
Definition
P4_F32vec4.h:22
Int_t
int Int_t
Double_t
double Double_t
BmnMatch.h
BmnLink
Definition
BmnLink.h:20
BmnLink::AddWeight
void AddWeight(Float_t weight)
Definition
BmnLink.h:49
BmnLink::ToString
virtual string ToString() const
Return string representation of the object.
Definition
BmnLink.cxx:32
BmnLink::GetWeight
Float_t GetWeight() const
Definition
BmnLink.h:41
BmnMatch::fTotalWeight
Double_t fTotalWeight
Definition
BmnMatch.h:60
BmnMatch::fLinks
vector< BmnLink > fLinks
Definition
BmnMatch.h:59
BmnMatch::fMatchedIndex
Int_t fMatchedIndex
Definition
BmnMatch.h:61
BmnMatch::AddLink
void AddLink(const BmnMatch &match)
Definition
BmnMatch.cxx:40
BmnMatch::ClearLinks
void ClearLinks()
Definition
BmnMatch.cxx:81
BmnMatch::~BmnMatch
virtual ~BmnMatch()
Destructor.
Definition
BmnMatch.cxx:21
BmnMatch::BmnMatch
BmnMatch()
Default constructor.
Definition
BmnMatch.cxx:15
BmnMatch::ToString
virtual string ToString() const
Return string representation of the object.
Definition
BmnMatch.cxx:26
BmnMatch::GetNofLinks
Int_t GetNofLinks() const
Definition
BmnMatch.h:41
match
Definition
BmnMwpcTrackFinder.cxx:27
base
data
BmnMatch.cxx
Generated on
for BmnRoot by
1.17.0