Main Page
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
o
p
q
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
d
e
f
l
m
o
p
s
t
u
v
Related Functions
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Package Documentation
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
L1Trigger
Phase2L1ParticleFlow
src
TauNNId.cc
Go to the documentation of this file.
1
#include "
L1Trigger/Phase2L1ParticleFlow/interface/TauNNId.h
"
2
#include "
FWCore/ParameterSet/interface/FileInPath.h
"
3
#include "
DataFormats/Math/interface/deltaPhi.h
"
4
#include <cmath>
5
6
static
constexpr
unsigned
int
n_particles_max
= 10;
7
8
TauNNId::TauNNId
(
const
std::string
&iInput,
const
TauNNTFCache
*
cache
,
const
std::string
&iWeightFile,
int
iNParticles) {
9
NNvectorVar_
.clear();
10
edm::FileInPath
fp
(iWeightFile);
11
session_
=
tensorflow::createSession
(
cache
->graphDef);
12
fNParticles_
= iNParticles;
13
14
fPt_
= std::make_unique<float[]>(
fNParticles_
);
15
fEta_
= std::make_unique<float[]>(
fNParticles_
);
16
fPhi_
= std::make_unique<float[]>(
fNParticles_
);
17
fId_
= std::make_unique<float[]>(
fNParticles_
);
18
fInput_
= iInput;
19
}
20
21
TauNNId::~TauNNId
() {
tensorflow::closeSession
(
session_
); }
22
void
TauNNId::setNNVectorVar
() {
23
NNvectorVar_
.clear();
24
for
(
int
i0 = 0; i0 <
fNParticles_
; i0++) {
25
NNvectorVar_
.push_back(
fPt_
.get()[i0]);
//pT
26
NNvectorVar_
.push_back(
fEta_
.get()[i0]);
//dEta from jet axis
27
NNvectorVar_
.push_back(
fPhi_
.get()[i0]);
//dPhi from jet axis
28
if
(
fPt_
.get()[i0] == 0) {
29
for
(
int
i1
= 0;
i1
< 5;
i1
++)
30
NNvectorVar_
.push_back(0);
31
continue
;
32
}
33
NNvectorVar_
.push_back(
fId_
.get()[i0] ==
l1t::PFCandidate::Photon
);
// Photon
34
NNvectorVar_
.push_back(
fId_
.get()[i0] ==
l1t::PFCandidate::Electron
);
// Electron
35
NNvectorVar_
.push_back(
fId_
.get()[i0] ==
l1t::PFCandidate::Muon
);
// Muon
36
NNvectorVar_
.push_back(
fId_
.get()[i0] ==
l1t::PFCandidate::NeutralHadron
);
// Neutral Had
37
NNvectorVar_
.push_back(
fId_
.get()[i0] ==
l1t::PFCandidate::ChargedHadron
);
// Charged Had
38
}
39
}
40
float
TauNNId::EvaluateNN
() {
41
tensorflow::Tensor
input
(tensorflow::DT_FLOAT,
42
{1, (
unsigned
int
)
NNvectorVar_
.size()});
//was {1,35} but get size mismatch, CHECK
43
for
(
unsigned
int
i
= 0;
i
<
NNvectorVar_
.size();
i
++) {
44
input
.matrix<
float
>()(0,
i
) =
float
(
NNvectorVar_
[
i
]);
45
}
46
std::vector<tensorflow::Tensor>
outputs
;
47
tensorflow::run
(
session_
, {{
fInput_
,
input
}}, {
"dense_4/Sigmoid:0"
}, &
outputs
);
48
return
outputs
[0].matrix<
float
>()(0, 0);
49
}
//end EvaluateNN
50
51
float
TauNNId::compute
(
const
l1t::PFCandidate
&iSeed,
l1t::PFCandidateCollection
&iParts) {
52
for
(
int
i0 = 0; i0 <
fNParticles_
; i0++) {
53
fPt_
.get()[i0] = 0;
54
fEta_
.get()[i0] = 0;
55
fPhi_
.get()[i0] = 0;
56
fId_
.get()[i0] = 0;
57
}
58
std::sort
(iParts.begin(), iParts.end(), [](
l1t::PFCandidate
i
,
l1t::PFCandidate
j
) {
return
(
i
.pt() >
j
.pt()); });
59
for
(
unsigned
int
i0 = 0; i0 < iParts.size(); i0++) {
60
if
(i0 >
n_particles_max
|| i0 >= (
unsigned
int
)
fNParticles_
)
61
break
;
62
fPt_
.get()[i0] = iParts[i0].pt();
63
fEta_
.get()[i0] = iSeed.
eta
() - iParts[i0].eta();
64
fPhi_
.get()[i0] =
deltaPhi
(iSeed.
phi
(), iParts[i0].phi());
65
fId_
.get()[i0] = iParts[i0].id();
66
}
67
setNNVectorVar
();
68
return
EvaluateNN
();
69
}
l1t::PFCandidate::Photon
Definition:
PFCandidate.h:15
tensorflow::createSession
Session * createSession(SessionOptions &sessionOptions)
Definition:
TensorFlow.cc:85
mps_fire.i
i
Definition:
mps_fire.py:428
input
static const std::string input
Definition:
EdmProvDump.cc:48
dqmMemoryStats.float
float
Definition:
dqmMemoryStats.py:127
TauNNId::setNNVectorVar
void setNNVectorVar()
Definition:
TauNNId.cc:22
deltaPhi.h
PatBasicFWLiteJetAnalyzer_Selector_cfg.outputs
outputs
Definition:
PatBasicFWLiteJetAnalyzer_Selector_cfg.py:48
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition:
testProducerWithPsetDescEmpty_cfi.py:45
personalPlayback.fp
fp
Definition:
personalPlayback.py:523
TauNNId::fEta_
unique_ptr< float[]> fEta_
Definition:
TauNNId.h:28
l1t::PFCandidate::Electron
Definition:
PFCandidate.h:15
TauNNId::fInput_
std::string fInput_
Definition:
TauNNId.h:25
TauNNTFCache
Definition:
TauNNId.h:8
FileInPath.h
edm::FileInPath
Definition:
FileInPath.h:64
TauNNId.h
tensorflow::closeSession
bool closeSession(Session *&session)
Definition:
TensorFlow.cc:198
TauNNId::fPhi_
unique_ptr< float[]> fPhi_
Definition:
TauNNId.h:29
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition:
SiPixelRawToDigiRegional_cfi.py:9
utilities.cache
def cache(function)
Definition:
utilities.py:3
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition:
LeafCandidate.h:152
jetUpdater_cfi.sort
sort
Definition:
jetUpdater_cfi.py:29
l1t::PFCandidate::ChargedHadron
Definition:
PFCandidate.h:15
TauNNId::TauNNId
TauNNId(const std::string &iInput, const TauNNTFCache *cache, const std::string &iWeightFile, int iNParticles)
Definition:
TauNNId.cc:8
createfilelist.int
int
Definition:
createfilelist.py:10
n_particles_max
static constexpr unsigned int n_particles_max
Definition:
TauNNId.cc:6
TauNNId::fId_
unique_ptr< float[]> fId_
Definition:
TauNNId.h:30
l1t::PFCandidateCollection
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition:
PFCandidate.h:57
l1t::PFCandidate::Muon
Definition:
PFCandidate.h:15
TauNNId::session_
tensorflow::Session * session_
Definition:
TauNNId.h:23
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition:
LeafCandidate.h:148
tensorflow::run
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Definition:
TensorFlow.cc:213
l1t::PFCandidate
Definition:
PFCandidate.h:12
TauNNId::compute
float compute(const l1t::PFCandidate &iSeed, l1t::PFCandidateCollection &iParts)
Definition:
TauNNId.cc:51
TauNNId::~TauNNId
~TauNNId()
Definition:
TauNNId.cc:21
l1t::PFCandidate::NeutralHadron
Definition:
PFCandidate.h:15
dqmiolumiharvest.j
j
Definition:
dqmiolumiharvest.py:66
TauNNId::fPt_
unique_ptr< float[]> fPt_
Definition:
TauNNId.h:27
TauNNId::fNParticles_
int fNParticles_
Definition:
TauNNId.h:26
TauNNId::NNvectorVar_
std::vector< float > NNvectorVar_
Definition:
TauNNId.h:24
TauNNId::EvaluateNN
float EvaluateNN()
Definition:
TauNNId.cc:40
Generated for CMSSW Reference Manual by
1.8.16