CMS 3D CMS Logo

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