ATLAS Offline Software
Loading...
Searching...
No Matches
OfflineTruthMatcher.h
Go to the documentation of this file.
1
12
13
14#ifndef IDTPM2_OFFLINETRUTHMATCHER_H
15#define IDTPM2_OFFLINETRUTHMATCHER_H
16
17#include <iostream>
18#include <cmath>
19
22
24#include "AthLinks/ElementLink.h"
25
28
29namespace IDTPM2 {
30
31
33template<typename T>
34class decorator {
35
36 inline static const SG::ConstAccessor<ElementLink<xAOD::TruthParticleContainer>> m_acc = {"truthParticleLink"};
37 inline static const SG::ConstAccessor<float> m_probAcc = {"truthMatchProbability"};
38
39public:
40
41 template<typename Tp>
42 explicit decorator( const Tp* t ) : m_t(t->template as<T>()) { }
43
44 explicit operator bool() const { return m_t!=0; }
45
47 if ( m_t && m_acc.isAvailable(*m_t) ) {
49 if (link.isValid()) return *link;
50 }
51 return 0;
52 }
53
54 double discriminant() const {
55 if ( m_t && m_probAcc.isAvailable(*m_t) ) {
56 float prob = m_probAcc(*m_t);
57 if ( prob ) return std::log10(1.0/prob);
58 }
59 return std::numeric_limits<double>::max();
60 }
61
62private:
63
64 const T* m_t;
65
66};
67
68
69
70
71template<typename T, typename R=T>
72class TOfflineTruthMatcher : public BestMatcher<T,R> {
73
74public:
75
76 TOfflineTruthMatcher( const std::string& name, double d ) :
77 BestMatcher<T,R>(name, std::log10(1.0/d)) {
78 }
79
80 virtual ~TOfflineTruthMatcher() { }
81
82 virtual std::unique_ptr<TIDA::Associator<T,R>> uclone() const override { return std::make_unique<TOfflineTruthMatcher<T,R>>(*this); }
83
84 virtual double distance( const T* t0, const R* t1 ) const override {
86 if ( tp && tp.truthMatch() == t0->template as<xAOD::TruthParticle>() ) return tp.discriminant();
87 return std::numeric_limits<double>::max();
88 }
89
90};
91
92
93}
94
95
96#endif // IDTPM2_OFFLINETRUTHMATCHER_H
97
98
99
100
101
102
103
104
105
106
truely generic template class of a best matching algorithm based on an efficient implementation of th...
static Double_t Tp(Double_t *t, Double_t *par)
static Double_t t0
BestMatcher(const std::string &name, double d)
Definition BestMatcher.h:61
virtual double distance(const T *t0, const R *t1) const override
TOfflineTruthMatcher(const std::string &name, double d)
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone() const override
decorates types with the truth match information
static const SG::ConstAccessor< ElementLink< xAOD::TruthParticleContainer > > m_acc
static const SG::ConstAccessor< float > m_probAcc
double discriminant() const
const xAOD::TruthParticle * truthMatch() const
Helper class to provide constant type-safe access to aux data.
emacs: this is -*- c++ -*-
STL namespace.
TruthParticle_v1 TruthParticle
Typedef to implementation.