ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
FPGATrackSimMultiTruth Class Reference

#include <FPGATrackSimMultiTruth.h>

Collaboration diagram for FPGATrackSimMultiTruth:

Classes

struct  AddAccumulator
 
struct  MaxAccumulator
 
struct  TruthMapWeightAcc
 
struct  TruthMapWeightLt
 

Public Types

typedef std::pair< unsigned long, unsigned long > Barcode
 
typedef float Weight
 
typedef std::map< Barcode, WeightTruthMap
 

Public Member Functions

 FPGATrackSimMultiTruth ()=default
 
 FPGATrackSimMultiTruth (const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight weight=1.)
 
virtual ~FPGATrackSimMultiTruth ()=default
 
auto begin ()
 
auto end ()
 
auto begin () const
 
auto end () const
 
bool isEmpty () const
 
unsigned long best_barcode () const
 
void add (const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
 
void add (const FPGATrackSimMultiTruth &rval)
 
void maximize (const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
 
void maximize (const FPGATrackSimMultiTruth &rval)
 
void assign_equal_normalization ()
 
unsigned multiplicity () const
 
bool best (FPGATrackSimMultiTruth::Barcode &code, FPGATrackSimMultiTruth::Weight &weight) const
 

Private Member Functions

const FPGATrackSimMultiTruth add (const FPGATrackSimMultiTruth &rval) const
 
const FPGATrackSimMultiTruth maximize (const FPGATrackSimMultiTruth &rval) const
 
FPGATrackSimMultiTruth::Weight total_weight () const
 
FPGATrackSimMultiTruth::Weight weight (const FPGATrackSimMultiTruth::Barcode &code) const
 

Private Attributes

TruthMap m_truth
 

Detailed Description

Definition at line 46 of file FPGATrackSimMultiTruth.h.

Member Typedef Documentation

◆ Barcode

typedef std::pair<unsigned long, unsigned long> FPGATrackSimMultiTruth::Barcode

Definition at line 49 of file FPGATrackSimMultiTruth.h.

◆ TruthMap

Definition at line 51 of file FPGATrackSimMultiTruth.h.

◆ Weight

Definition at line 50 of file FPGATrackSimMultiTruth.h.

Constructor & Destructor Documentation

◆ FPGATrackSimMultiTruth() [1/2]

FPGATrackSimMultiTruth::FPGATrackSimMultiTruth ( )
default

◆ FPGATrackSimMultiTruth() [2/2]

FPGATrackSimMultiTruth::FPGATrackSimMultiTruth ( const FPGATrackSimMultiTruth::Barcode code,
const FPGATrackSimMultiTruth::Weight  weight = 1. 
)
inline

Definition at line 54 of file FPGATrackSimMultiTruth.h.

54 { m_truth[code] = weight; }

◆ ~FPGATrackSimMultiTruth()

virtual FPGATrackSimMultiTruth::~FPGATrackSimMultiTruth ( )
virtualdefault

Member Function Documentation

◆ add() [1/3]

void FPGATrackSimMultiTruth::add ( const FPGATrackSimMultiTruth rval)

Definition at line 27 of file FPGATrackSimMultiTruth.cxx.

27  {
28  for (auto& rval_truth : rval.m_truth) {
29  m_truth[rval_truth.first] += rval_truth.second;
30  }
31 }

◆ add() [2/3]

const FPGATrackSimMultiTruth FPGATrackSimMultiTruth::add ( const FPGATrackSimMultiTruth rval) const
private

Definition at line 95 of file FPGATrackSimMultiTruth.cxx.

96 {
98  result.add(rval);
99  return result;
100 }

◆ add() [3/3]

void FPGATrackSimMultiTruth::add ( const FPGATrackSimMultiTruth::Barcode code,
const FPGATrackSimMultiTruth::Weight weight 
)

Definition at line 22 of file FPGATrackSimMultiTruth.cxx.

22  {
23  assert(weight >= 0.);
24  m_truth[code] += weight;
25 }

◆ assign_equal_normalization()

void FPGATrackSimMultiTruth::assign_equal_normalization ( )

Definition at line 69 of file FPGATrackSimMultiTruth.cxx.

70 {
71  for ( auto& truth : m_truth) truth.second = 1. / m_truth.size();
72 }

◆ begin() [1/2]

auto FPGATrackSimMultiTruth::begin ( )
inline

Definition at line 65 of file FPGATrackSimMultiTruth.h.

65 { return m_truth.begin(); }

◆ begin() [2/2]

auto FPGATrackSimMultiTruth::begin ( ) const
inline

Definition at line 67 of file FPGATrackSimMultiTruth.h.

67 { return m_truth.begin(); }

◆ best()

bool FPGATrackSimMultiTruth::best ( FPGATrackSimMultiTruth::Barcode code,
FPGATrackSimMultiTruth::Weight weight 
) const
inline

Definition at line 86 of file FPGATrackSimMultiTruth.h.

87  {
88  if (m_truth.empty()) return false;
89  auto i = std::max_element(m_truth.begin(), m_truth.end(), TruthMapWeightLt());
90  code = i->first;
91  weight = total_weight() > 0. ? (i->second) / total_weight() : 0.;
92  return true;
93  }

◆ best_barcode()

unsigned long FPGATrackSimMultiTruth::best_barcode ( ) const

Definition at line 16 of file FPGATrackSimMultiTruth.cxx.

16  {
17  Barcode code;
18  Weight weight;
19  return !best(code, weight) ? -999 : code.second;
20 }

◆ end() [1/2]

auto FPGATrackSimMultiTruth::end ( )
inline

Definition at line 66 of file FPGATrackSimMultiTruth.h.

66 { return m_truth.end(); }

◆ end() [2/2]

auto FPGATrackSimMultiTruth::end ( ) const
inline

Definition at line 68 of file FPGATrackSimMultiTruth.h.

68 { return m_truth.end(); }

◆ isEmpty()

bool FPGATrackSimMultiTruth::isEmpty ( ) const
inline

Definition at line 70 of file FPGATrackSimMultiTruth.h.

70 { return m_truth.empty(); }

◆ maximize() [1/3]

void FPGATrackSimMultiTruth::maximize ( const FPGATrackSimMultiTruth rval)

Definition at line 50 of file FPGATrackSimMultiTruth.cxx.

51 {
52  if (rval.m_truth.empty()) return; // if rval has no truth info, do nothing.
53 
54  // find input barcode with maximum weight;
55  Weight maxweight = 0.;
56  Barcode maxweight_barcode(-1l, -1l);
57  for (const auto & rval_truth : rval.m_truth)
58  {
59  if (rval_truth.second > maxweight)
60  {
61  maxweight = rval_truth.second;
62  maxweight_barcode = rval_truth.first;
63  }
64  }
65 
66  maximize(maxweight_barcode, maxweight);
67 }

◆ maximize() [2/3]

const FPGATrackSimMultiTruth FPGATrackSimMultiTruth::maximize ( const FPGATrackSimMultiTruth rval) const
private

Definition at line 102 of file FPGATrackSimMultiTruth.cxx.

103 {
105  result.maximize(rval);
106  return result;
107 }

◆ maximize() [3/3]

void FPGATrackSimMultiTruth::maximize ( const FPGATrackSimMultiTruth::Barcode code,
const FPGATrackSimMultiTruth::Weight weight 
)

Definition at line 36 of file FPGATrackSimMultiTruth.cxx.

37 {
38  if (m_truth.empty()) m_truth[code] = weight;
39  else
40  {
41  assert(m_truth.size() == 1);
42  if (m_truth.begin()->second < weight)
43  {
44  m_truth.clear();
45  m_truth[code] = weight;
46  }
47  }
48 }

◆ multiplicity()

unsigned FPGATrackSimMultiTruth::multiplicity ( ) const
inline

Definition at line 82 of file FPGATrackSimMultiTruth.h.

82 { return m_truth.size(); }

◆ total_weight()

FPGATrackSimMultiTruth::Weight FPGATrackSimMultiTruth::total_weight ( ) const
inlineprivate

Definition at line 116 of file FPGATrackSimMultiTruth.h.

116 { return std::accumulate(m_truth.begin(), m_truth.end(), 0., TruthMapWeightAcc()); }

◆ weight()

FPGATrackSimMultiTruth::Weight FPGATrackSimMultiTruth::weight ( const FPGATrackSimMultiTruth::Barcode code) const
inlineprivate

Definition at line 118 of file FPGATrackSimMultiTruth.h.

118  {
119  return m_truth.empty() || (m_truth.find(code) == m_truth.end()) ? 0. : ((m_truth.find(code))->second) / total_weight();
120  }

Member Data Documentation

◆ m_truth

TruthMap FPGATrackSimMultiTruth::m_truth
private

Definition at line 122 of file FPGATrackSimMultiTruth.h.


The documentation for this class was generated from the following files:
Barcode
Definition: IBarcodeSvc.h:17
get_generator_info.result
result
Definition: get_generator_info.py:21
FPGATrackSimMultiTruth::m_truth
TruthMap m_truth
Definition: FPGATrackSimMultiTruth.h:122
FPGATrackSimMultiTruth::Weight
float Weight
Definition: FPGATrackSimMultiTruth.h:50
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
FPGATrackSimMultiTruth::best
bool best(FPGATrackSimMultiTruth::Barcode &code, FPGATrackSimMultiTruth::Weight &weight) const
Definition: FPGATrackSimMultiTruth.h:86
histSizes.code
code
Definition: histSizes.py:129
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimMultiTruth::weight
FPGATrackSimMultiTruth::Weight weight(const FPGATrackSimMultiTruth::Barcode &code) const
Definition: FPGATrackSimMultiTruth.h:118
FPGATrackSimMultiTruth::maximize
void maximize(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
Definition: FPGATrackSimMultiTruth.cxx:36
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimMultiTruth::total_weight
FPGATrackSimMultiTruth::Weight total_weight() const
Definition: FPGATrackSimMultiTruth.h:116