BmnRoot
Loading...
Searching...
No Matches
BmnMatch.cxx
Go to the documentation of this file.
1
8#include "BmnMatch.h"
9
10#include <sstream>
11
12using std::make_pair;
13using std::stringstream;
14
16 fLinks(),
17 fTotalWeight(0.),
18 fMatchedIndex(-1)
19{
20
21}
22
24{
25 fLinks.clear();
26}
27
28string BmnMatch::ToString() const
29{
30 stringstream ss;
31 ss << "BmnMatch: ";
32 Int_t nofLinks = GetNofLinks();
33 ss << "nofLinks=" << nofLinks << "\n";
34 for (Int_t i = 0; i < nofLinks; i++) {
35 const BmnLink& link = fLinks[i];
36 ss << link.ToString();
37 }
38 ss << " totalWeight=" << fTotalWeight << ", matchedIndex="
39 << fMatchedIndex << std::endl;
40 return ss.str();
41}
42
44{
45 Int_t nofLinks = match.GetNofLinks();
46 for (Int_t i = 0; i < nofLinks; i++) {
47 AddLink(match.GetLink(i));
48 }
49}
50
51void BmnMatch::AddLink(const BmnLink& newLink)
52{
53 Int_t addedIndex = -1;
54 Int_t nofLinks = GetNofLinks();
55 for (Int_t i = 0; i < nofLinks; i++) {
56 BmnLink& link = fLinks[i];
57 if (link == newLink) {
58 link.AddWeight(newLink.GetWeight());
59 addedIndex = i;
60 break;
61 }
62 }
63 if (addedIndex < 0) {
64 fLinks.push_back(newLink);
65 addedIndex = fLinks.size() - 1;
66 }
67
68 fTotalWeight += newLink.GetWeight();
69 if (fMatchedIndex < 0) {
70 fMatchedIndex = addedIndex;
71 } else {
72 if (fLinks[addedIndex].GetWeight() > fLinks[fMatchedIndex].GetWeight()) {
73 fMatchedIndex = addedIndex;
74 }
75 }
76}
77
78void BmnMatch::AddLink(Double_t weight, Int_t index, Int_t entry, Int_t file) {
79 BmnLink link(weight, index, entry, file);
80 AddLink(link);
81}
82
83
85{
86 fLinks.clear();
87 fTotalWeight = 0.;
88 fMatchedIndex = -1;
89}
int i
Definition P4_F32vec4.h:22
Double_t fTotalWeight
Definition BmnMatch.h:59
vector< BmnLink > fLinks
Definition BmnMatch.h:58
Int_t fMatchedIndex
Definition BmnMatch.h:60
void AddLink(const BmnMatch &match)
Definition BmnMatch.cxx:43
void ClearLinks()
Definition BmnMatch.cxx:84
virtual ~BmnMatch()
Destructor.
Definition BmnMatch.cxx:23
BmnMatch()
Default constructor.
Definition BmnMatch.cxx:15
virtual string ToString() const
Return string representation of the object.
Definition BmnMatch.cxx:28
Int_t GetNofLinks() const
Definition BmnMatch.h:40