CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
TemplatedJetBProbabilityComputer< Container, Base > Class Template Reference

#include <TemplatedJetBProbabilityComputer.h>

Inheritance diagram for TemplatedJetBProbabilityComputer< Container, Base >:
JetTagComputer

Public Types

typedef reco::IPTagInfo< Container, Base > TagInfo
 
using Tokens = void
 

Public Member Functions

float discriminator (const TagInfoHelper &ti) const override
 
double jetProbability (const std::vector< float > &v) const
 
 TemplatedJetBProbabilityComputer (const edm::ParameterSet &parameters)
 
- Public Member Functions inherited from JetTagComputer
const std::vector< std::string > & getInputLabels () const
 
virtual void initialize (const JetTagComputerRecord &)
 
 JetTagComputer ()
 
 JetTagComputer (const edm::ParameterSet &configuration)
 
float operator() (const reco::BaseTagInfo &info) const
 
float operator() (const TagInfoHelper &helper) const
 
void setupDone ()
 
virtual ~JetTagComputer ()
 

Private Attributes

double m_cutMaxDecayLen
 
double m_cutMaxDistToAxis
 
double m_deltaR
 
int m_ipType
 
double m_minTrackProb
 
unsigned int m_nbTracks
 
reco::TrackBase::TrackQuality m_trackQuality
 
int m_trackSign
 
bool m_useAllQualities
 
bool useVariableJTA_
 
reco::btag::variableJTAParameters varJTApars
 

Additional Inherited Members

- Protected Member Functions inherited from JetTagComputer
virtual float discriminator (const reco::BaseTagInfo &) const
 
void uses (unsigned int id, const std::string &label)
 
void uses (const std::string &label)
 

Detailed Description

template<class Container, class Base>
class TemplatedJetBProbabilityComputer< Container, Base >

Definition at line 14 of file TemplatedJetBProbabilityComputer.h.

Member Typedef Documentation

◆ TagInfo

template<class Container , class Base >
typedef reco::IPTagInfo<Container, Base> TemplatedJetBProbabilityComputer< Container, Base >::TagInfo

Definition at line 18 of file TemplatedJetBProbabilityComputer.h.

◆ Tokens

template<class Container , class Base >
using TemplatedJetBProbabilityComputer< Container, Base >::Tokens = void

Definition at line 16 of file TemplatedJetBProbabilityComputer.h.

Constructor & Destructor Documentation

◆ TemplatedJetBProbabilityComputer()

template<class Container , class Base >
TemplatedJetBProbabilityComputer< Container, Base >::TemplatedJetBProbabilityComputer ( const edm::ParameterSet parameters)
inline

Definition at line 20 of file TemplatedJetBProbabilityComputer.h.

References TemplatedJetBProbabilityComputer< Container, Base >::m_cutMaxDecayLen, TemplatedJetBProbabilityComputer< Container, Base >::m_cutMaxDistToAxis, TemplatedJetBProbabilityComputer< Container, Base >::m_deltaR, TemplatedJetBProbabilityComputer< Container, Base >::m_ipType, TemplatedJetBProbabilityComputer< Container, Base >::m_minTrackProb, TemplatedJetBProbabilityComputer< Container, Base >::m_nbTracks, TemplatedJetBProbabilityComputer< Container, Base >::m_trackQuality, TemplatedJetBProbabilityComputer< Container, Base >::m_trackSign, TemplatedJetBProbabilityComputer< Container, Base >::m_useAllQualities, reco::TrackBase::qualityByName(), AlCaHLTBitMon_QueryRunRegistry::string, JetTagComputer::uses(), TemplatedJetBProbabilityComputer< Container, Base >::useVariableJTA_, and TemplatedJetBProbabilityComputer< Container, Base >::varJTApars.

20  {
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
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  }
reco::btag::variableJTAParameters varJTApars
void uses(unsigned int id, const std::string &label)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126

Member Function Documentation

◆ discriminator()

template<class Container , class Base >
float TemplatedJetBProbabilityComputer< Container, Base >::discriminator ( const TagInfoHelper ti) const
inlineoverridevirtual

log(all);

Reimplemented from JetTagComputer.

Definition at line 53 of file TemplatedJetBProbabilityComputer.h.

References python.cmstools::all(), b, electronAnalyzer_cfi::DeltaR, JetTagComputer::TagInfoHelper::get(), mps_fire::i, reco::IPTagInfo< Container, Base >::impactParameterData(), edm::Ref< C, T, F >::isNull(), TemplatedJetBProbabilityComputer< Container, Base >::jetProbability(), dqm-mbProfile::log, TemplatedJetBProbabilityComputer< Container, Base >::m_cutMaxDecayLen, TemplatedJetBProbabilityComputer< Container, Base >::m_cutMaxDistToAxis, TemplatedJetBProbabilityComputer< Container, Base >::m_deltaR, TemplatedJetBProbabilityComputer< Container, Base >::m_ipType, TemplatedJetBProbabilityComputer< Container, Base >::m_nbTracks, TemplatedJetBProbabilityComputer< Container, Base >::m_trackQuality, TemplatedJetBProbabilityComputer< Container, Base >::m_trackSign, TemplatedJetBProbabilityComputer< Container, Base >::m_useAllQualities, AlCaHLTBitMon_ParallelJobs::p, reco::IPTagInfo< Container, Base >::primaryVertex(), reco::IPTagInfo< Container, Base >::probabilities(), MetAnalyzer::pv(), reco::TrackBase::quality(), reco::IPTagInfo< Container, Base >::selectedTracks(), jetUpdater_cfi::sort, reco::btag::toTrack(), pwdgSkimBPark_cfi::tracks, TemplatedJetBProbabilityComputer< Container, Base >::useVariableJTA_, reco::IPTagInfo< Container, Base >::variableJTA(), and TemplatedJetBProbabilityComputer< Container, Base >::varJTApars.

53  {
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  }
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:552
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
reco::IPTagInfo< Container, Base > TagInfo
const reco::Track * toTrack(const reco::TrackBaseRef &t)
Definition: IPTagInfo.h:24
reco::btag::variableJTAParameters varJTApars
def pv(vc)
Definition: MetAnalyzer.py:7
double jetProbability(const std::vector< float > &v) const
double b
Definition: hdecay.h:118
edm::AssociationVector< reco::JetRefBaseProd, Values > Container

◆ jetProbability()

template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::jetProbability ( const std::vector< float > &  v) const
inline

Definition at line 113 of file TemplatedJetBProbabilityComputer.h.

References gather_cfg::cout, JetChargeProducer_cfi::exp, MainPageGenerator::l, dqm-mbProfile::log, TemplatedJetBProbabilityComputer< Container, Base >::m_minTrackProb, SiStripPI::max, SiStripPI::min, submitPVResolutionJobs::q, and findQualityFiles::v.

Referenced by TemplatedJetBProbabilityComputer< Container, Base >::discriminator().

113  {
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  }

Member Data Documentation

◆ m_cutMaxDecayLen

template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::m_cutMaxDecayLen
private

◆ m_cutMaxDistToAxis

template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::m_cutMaxDistToAxis
private

◆ m_deltaR

template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::m_deltaR
private

◆ m_ipType

template<class Container , class Base >
int TemplatedJetBProbabilityComputer< Container, Base >::m_ipType
private

◆ m_minTrackProb

template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::m_minTrackProb
private

◆ m_nbTracks

template<class Container , class Base >
unsigned int TemplatedJetBProbabilityComputer< Container, Base >::m_nbTracks
private

◆ m_trackQuality

template<class Container , class Base >
reco::TrackBase::TrackQuality TemplatedJetBProbabilityComputer< Container, Base >::m_trackQuality
private

◆ m_trackSign

template<class Container , class Base >
int TemplatedJetBProbabilityComputer< Container, Base >::m_trackSign
private

◆ m_useAllQualities

template<class Container , class Base >
bool TemplatedJetBProbabilityComputer< Container, Base >::m_useAllQualities
private

◆ useVariableJTA_

template<class Container , class Base >
bool TemplatedJetBProbabilityComputer< Container, Base >::useVariableJTA_
private

◆ varJTApars

template<class Container , class Base >
reco::btag::variableJTAParameters TemplatedJetBProbabilityComputer< Container, Base >::varJTApars
private