RecoBTag
ImpactParameter
interface
TemplatedJetBProbabilityComputer.h
Go to the documentation of this file.
1
#ifndef ImpactParameter_TemplatedJetBProbabilityComputer_h
2
#define ImpactParameter_TemplatedJetBProbabilityComputer_h
3
4
#include "
DataFormats/TrackReco/interface/Track.h
"
5
#include "
DataFormats/BTauReco/interface/TrackProbabilityTagInfo.h
"
6
#include "
DataFormats/BTauReco/interface/TrackIPTagInfo.h
"
7
#include "
DataFormats/VertexReco/interface/Vertex.h
"
8
#include "Math/GenVector/VectorUtil.h"
9
#include "
RecoBTau/JetTagComputer/interface/JetTagComputer.h
"
10
#include <algorithm>
11
#include <iostream>
12
13
template
<
class
Container,
class
Base>
14
class
TemplatedJetBProbabilityComputer
:
public
JetTagComputer
{
15
public
:
16
using
Tokens
=
void
;
17
18
typedef
reco::IPTagInfo<Container, Base>
TagInfo
;
19
20
TemplatedJetBProbabilityComputer
(
const
edm::ParameterSet
&
parameters
) {
21
m_ipType
=
parameters
.getParameter<
int
>(
"impactParameterType"
);
22
m_minTrackProb
=
parameters
.getParameter<
double
>(
"minimumProbability"
);
23
m_deltaR
=
parameters
.getParameter<
double
>(
"deltaR"
);
24
m_trackSign
=
parameters
.getParameter<
int
>(
"trackIpSign"
);
25
m_nbTracks
=
parameters
.getParameter<
unsigned
int
>(
"numberOfBTracks"
);
26
m_cutMaxDecayLen
=
parameters
.getParameter<
double
>(
"maximumDecayLength"
);
27
m_cutMaxDistToAxis
=
parameters
.getParameter<
double
>(
"maximumDistanceToJetAxis"
);
28
29
//
30
// access track quality class; "any" takes everything
31
//
32
std::string
trackQualityType =
parameters
.getParameter<
std::string
>(
"trackQualityClass"
);
//used
33
m_trackQuality
=
reco::TrackBase::qualityByName
(trackQualityType);
34
m_useAllQualities
=
false
;
35
if
(trackQualityType ==
"any"
|| trackQualityType ==
"Any"
|| trackQualityType ==
"ANY"
)
36
m_useAllQualities
=
true
;
37
38
useVariableJTA_
=
parameters
.getParameter<
bool
>(
"useVariableJTA"
);
39
if
(
useVariableJTA_
)
40
varJTApars
= {
parameters
.getParameter<
double
>(
"a_dR"
),
41
parameters
.getParameter<
double
>(
"b_dR"
),
42
parameters
.getParameter<
double
>(
"a_pT"
),
43
parameters
.getParameter<
double
>(
"b_pT"
),
44
parameters
.getParameter<
double
>(
"min_pT"
),
45
parameters
.getParameter<
double
>(
"max_pT"
),
46
parameters
.getParameter<
double
>(
"min_pT_dRcut"
),
47
parameters
.getParameter<
double
>(
"max_pT_dRcut"
),
48
parameters
.getParameter<
double
>(
"max_pT_trackPTcut"
)};
49
50
uses
(
"ipTagInfos"
);
51
}
52
53
float
discriminator
(
const
TagInfoHelper
& ti)
const override
{
54
const
TagInfo
& tkip = ti.
get
<
TagInfo
>();
55
const
Container
&
tracks
(tkip.
selectedTracks
());
56
const
std::vector<float>& allProbabilities((tkip.
probabilities
(
m_ipType
)));
57
const
std::vector<reco::btag::TrackIPData>& impactParameters((tkip.
impactParameterData
()));
58
59
if
(tkip.
primaryVertex
().
isNull
())
60
return
0;
61
62
GlobalPoint
pv
(tkip.
primaryVertex
()->position().x(),
63
tkip.
primaryVertex
()->position().y(),
64
tkip.
primaryVertex
()->position().z());
65
66
std::vector<float> probabilities;
67
std::vector<float> probabilitiesB;
68
int
i
= 0;
69
for
(std::vector<float>::const_iterator it = allProbabilities.begin(); it != allProbabilities.end(); ++it,
i
++) {
70
if
(fabs(impactParameters[
i
].distanceToJetAxis.value()) <
m_cutMaxDistToAxis
&&
// distance to JetAxis
71
(impactParameters[
i
].closestToJetAxis -
pv
).mag() <
m_cutMaxDecayLen
&&
// max decay len
72
(
m_useAllQualities
==
true
||
73
reco::btag::toTrack
(
tracks
[
i
])->
quality
(
m_trackQuality
))
// use selected track qualities
74
) {
75
// Use only positive(or negative) tracks for B
76
float
p
= fabs(*it);
77
if
(
useVariableJTA_
) {
78
if
(tkip.
variableJTA
(
varJTApars
)[
i
]) {
79
if
(
m_trackSign
> 0 || *it < 0)
80
probabilities.push_back(
p
);
//Use all tracks for positive tagger and only negative for negative tagger
81
if
(
m_trackSign
> 0 && *it >= 0) {
82
probabilitiesB.push_back(*it);
83
}
//Use only positive tracks for positive tagger
84
if
(
m_trackSign
< 0 && *it <= 0) {
85
probabilitiesB.push_back(-*it);
86
}
//Use only negative tracks for negative tagger
87
}
88
}
else
if
(
m_deltaR
< 0 ||
89
ROOT::Math::VectorUtil::DeltaR
((*tkip.jet()).
p4
().Vect(), (*
tracks
[
i
]).momentum()) <
m_deltaR
) {
90
//if(m_trackSign>0 || *it >0 ) probabilities.push_back(p); //Use all tracks for positive tagger and only negative for negative tagger
91
if
(
m_trackSign
> 0 || *it < 0)
92
probabilities.push_back(
p
);
//Use all tracks for positive tagger and only negative for negative tagger
93
94
if
(
m_trackSign
> 0 && *it >= 0) {
95
probabilitiesB.push_back(*it);
96
}
//Use only positive tracks for positive tagger
97
if
(
m_trackSign
< 0 && *it <= 0) {
98
probabilitiesB.push_back(-*it);
99
}
//Use only negative tracks for negative tagger
100
}
101
}
102
}
103
104
float
all
=
jetProbability
(probabilities);
105
std::sort(probabilitiesB.begin(), probabilitiesB.end());
106
if
(probabilitiesB.size() >
m_nbTracks
)
107
probabilitiesB.resize(
m_nbTracks
);
108
float
b
=
jetProbability
(probabilitiesB);
109
110
return
-
log
(
b
) / 4 -
log
(
all
) / 4;
111
}
112
113
double
jetProbability
(
const
std::vector<float>&
v
)
const
{
114
int
ngoodtracks =
v
.size();
115
double
SumJet = 0.;
116
117
for
(std::vector<float>::const_iterator
q
=
v
.begin();
q
!=
v
.end();
q
++) {
118
SumJet += (*
q
>
m_minTrackProb
) ?
log
(*
q
) :
log
(
m_minTrackProb
);
119
}
120
121
double
ProbJet;
122
double
Loginvlog = 0;
123
124
if
(SumJet < 0.) {
125
if
(ngoodtracks >= 2) {
126
Loginvlog =
log
(-SumJet);
127
}
128
double
Prob = 1.;
129
double
lfact = 1.;
130
for
(
int
l
= 1;
l
!= ngoodtracks;
l
++) {
131
lfact *=
l
;
132
Prob +=
exp
(
l
* Loginvlog -
log
(1. * lfact));
133
}
134
double
LogProb =
log
(Prob);
135
ProbJet =
std::min
(
exp
(
std::max
(LogProb + SumJet, -30.)), 1.);
136
}
else
{
137
ProbJet = 1.;
138
}
139
if
(ProbJet > 1)
140
std::cout
<<
"ProbJet too high: "
<< ProbJet << std::endl;
141
142
//double LogProbJet=-log(ProbJet);
143
// //return 1.-ProbJet;
144
return
ProbJet;
145
}
146
147
private
:
148
bool
useVariableJTA_
;
149
reco::btag::variableJTAParameters
varJTApars
;
150
double
m_minTrackProb
;
151
int
m_ipType
;
152
double
m_deltaR
;
153
int
m_trackSign
;
154
unsigned
int
m_nbTracks
;
155
double
m_cutMaxDecayLen
;
156
double
m_cutMaxDistToAxis
;
157
reco::TrackBase::TrackQuality
m_trackQuality
;
158
bool
m_useAllQualities
;
159
};
160
161
#endif // ImpactParameter_TemplatedJetBProbabilityComputer_h
reco::IPTagInfo::primaryVertex
const edm::Ref< VertexCollection > & primaryVertex() const
Definition:
IPTagInfo.h:133
BeamSpotPI::parameters
parameters
Definition:
BeamSpotPayloadInspectorHelper.h:29
PDWG_EXOHSCP_cff.tracks
tracks
Definition:
PDWG_EXOHSCP_cff.py:28
reco::IPTagInfo
Definition:
IPTagInfo.h:48
mps_fire.i
i
Definition:
mps_fire.py:428
TemplatedJetBProbabilityComputer::m_deltaR
double m_deltaR
Definition:
TemplatedJetBProbabilityComputer.h:152
TemplatedJetBProbabilityComputer::m_cutMaxDecayLen
double m_cutMaxDecayLen
Definition:
TemplatedJetBProbabilityComputer.h:155
TemplatedJetBProbabilityComputer::discriminator
float discriminator(const TagInfoHelper &ti) const override
Definition:
TemplatedJetBProbabilityComputer.h:53
TemplatedJetBProbabilityComputer::m_useAllQualities
bool m_useAllQualities
Definition:
TemplatedJetBProbabilityComputer.h:158
reco::btag::toTrack
const reco::Track * toTrack(const reco::TrackBaseRef &t)
Definition:
IPTagInfo.h:24
min
T min(T a, T b)
Definition:
MathUtil.h:58
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition:
Ref.h:235
reco::IPTagInfo::probabilities
const std::vector< float > & probabilities(int ip) const
Definition:
IPTagInfo.h:101
AlCaHLTBitMon_ParallelJobs.p
p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
reco::IPTagInfo::selectedTracks
const Container & selectedTracks() const
Definition:
IPTagInfo.h:99
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition:
TrackBase.h:150
TemplatedJetBProbabilityComputer::TagInfo
reco::IPTagInfo< Container, Base > TagInfo
Definition:
TemplatedJetBProbabilityComputer.h:18
JetTagComputer::TagInfoHelper
Definition:
JetTagComputer.h:16
TemplatedJetBProbabilityComputer::m_minTrackProb
double m_minTrackProb
Definition:
TemplatedJetBProbabilityComputer.h:150
findQualityFiles.v
v
Definition:
findQualityFiles.py:179
TemplatedJetBProbabilityComputer::m_cutMaxDistToAxis
double m_cutMaxDistToAxis
Definition:
TemplatedJetBProbabilityComputer.h:156
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition:
cmstools.py:26
reco::JetExtendedAssociation::Container
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
Definition:
JetExtendedAssociation.h:29
JetTagComputer::TagInfoHelper::get
const T & get(unsigned int index=0) const
Definition:
JetTagComputer.h:42
TemplatedJetBProbabilityComputer::useVariableJTA_
bool useVariableJTA_
Definition:
TemplatedJetBProbabilityComputer.h:148
TemplatedJetBProbabilityComputer::m_trackSign
int m_trackSign
Definition:
TemplatedJetBProbabilityComputer.h:153
JetTagComputer.h
Track.h
TrackIPTagInfo.h
Point3DBase< float, GlobalTag >
b
double b
Definition:
hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
TrackProbabilityTagInfo.h
edm::ParameterSet
Definition:
ParameterSet.h:47
SiStripPI::max
Definition:
SiStripPayloadInspectorHelper.h:169
TemplatedJetBProbabilityComputer::m_nbTracks
unsigned int m_nbTracks
Definition:
TemplatedJetBProbabilityComputer.h:154
TemplatedJetBProbabilityComputer
Definition:
TemplatedJetBProbabilityComputer.h:14
MetAnalyzer.pv
def pv(vc)
Definition:
MetAnalyzer.py:7
p4
double p4[4]
Definition:
TauolaWrapper.h:92
submitPVResolutionJobs.q
q
Definition:
submitPVResolutionJobs.py:84
TemplatedJetBProbabilityComputer::Tokens
void Tokens
Definition:
TemplatedJetBProbabilityComputer.h:16
electronAnalyzer_cfi.DeltaR
DeltaR
Definition:
electronAnalyzer_cfi.py:33
JetTagComputer
Definition:
JetTagComputer.h:14
reco::IPTagInfo::impactParameterData
const std::vector< btag::TrackIPData > & impactParameterData() const
Definition:
IPTagInfo.h:90
cmsLHEtoEOSManager.l
l
Definition:
cmsLHEtoEOSManager.py:204
JetTagComputer::uses
void uses(unsigned int id, const std::string &label)
Definition:
JetTagComputer.cc:17
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition:
TrackBase.cc:126
TemplatedJetBProbabilityComputer::m_trackQuality
reco::TrackBase::TrackQuality m_trackQuality
Definition:
TemplatedJetBProbabilityComputer.h:157
TemplatedJetBProbabilityComputer::varJTApars
reco::btag::variableJTAParameters varJTApars
Definition:
TemplatedJetBProbabilityComputer.h:149
dqm-mbProfile.log
log
Definition:
dqm-mbProfile.py:17
funct::void
TEMPL(T2) struct Divides void
Definition:
Factorize.h:24
TemplatedJetBProbabilityComputer::TemplatedJetBProbabilityComputer
TemplatedJetBProbabilityComputer(const edm::ParameterSet ¶meters)
Definition:
TemplatedJetBProbabilityComputer.h:20
TemplatedJetBProbabilityComputer::jetProbability
double jetProbability(const std::vector< float > &v) const
Definition:
TemplatedJetBProbabilityComputer.h:113
TemplatedJetBProbabilityComputer::m_ipType
int m_ipType
Definition:
TemplatedJetBProbabilityComputer.h:151
JetChargeProducer_cfi.exp
exp
Definition:
JetChargeProducer_cfi.py:6
reco::TrackBase::quality
bool quality(const TrackQuality) const
Track quality.
Definition:
TrackBase.h:552
reco::btag::variableJTAParameters
Definition:
IPTagInfo.h:37
reco::IPTagInfo::variableJTA
std::vector< bool > variableJTA(const btag::variableJTAParameters ¶ms) const
Definition:
IPTagInfo.h:210
Generated for CMSSW Reference Manual by
1.8.16