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
 

Public Member Functions

float discriminator (const TagInfoHelper &ti) const
 
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

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

Definition at line 17 of file TemplatedJetBProbabilityComputer.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file TemplatedJetBProbabilityComputer.h.

References edm::ParameterSet::getParameter(), 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" ||
36  trackQualityType == "Any" ||
37  trackQualityType == "ANY" ) m_useAllQualities = true;
38 
39  useVariableJTA_ = parameters.getParameter<bool>("useVariableJTA");
40  if(useVariableJTA_)
41  varJTApars = {
42  parameters.getParameter<double>("a_dR"),
43  parameters.getParameter<double>("b_dR"),
44  parameters.getParameter<double>("a_pT"),
45  parameters.getParameter<double>("b_pT"),
46  parameters.getParameter<double>("min_pT"),
47  parameters.getParameter<double>("max_pT"),
48  parameters.getParameter<double>("min_pT_dRcut"),
49  parameters.getParameter<double>("max_pT_dRcut"),
50  parameters.getParameter<double>("max_pT_trackPTcut") };
51 
52  uses("ipTagInfos");
53  }
T getParameter(std::string const &) const
reco::btag::variableJTAParameters varJTApars
void uses(unsigned int id, const std::string &label)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125

Member Function Documentation

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

log(all);

Reimplemented from JetTagComputer.

Definition at line 55 of file TemplatedJetBProbabilityComputer.h.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor::all(), b, HiRegitMuonDetachedTripletStep_cff::DeltaR, JetTagComputer::TagInfoHelper::get(), mps_fire::i, reco::IPTagInfo< Container, Base >::impactParameterData(), edm::Ref< C, T, F >::isNull(), TemplatedJetBProbabilityComputer< Container, Base >::jetProbability(), cmsBatch::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, p4, reco::IPTagInfo< Container, Base >::primaryVertex(), reco::IPTagInfo< Container, Base >::probabilities(), MetAnalyzer::pv(), reco::TrackBase::quality(), reco::IPTagInfo< Container, Base >::selectedTracks(), reco::btag::toTrack(), l1t::tracks, TemplatedJetBProbabilityComputer< Container, Base >::useVariableJTA_, reco::IPTagInfo< Container, Base >::variableJTA(), and TemplatedJetBProbabilityComputer< Container, Base >::varJTApars.

56  {
57  const TagInfo & tkip = ti.get<TagInfo>();
58  const Container & tracks(tkip.selectedTracks());
59  const std::vector<float> & allProbabilities((tkip.probabilities(m_ipType)));
60  const std::vector<reco::btag::TrackIPData> & impactParameters((tkip.impactParameterData()));
61 
62  if(tkip.primaryVertex().isNull()) return 0;
63 
64  GlobalPoint pv(tkip.primaryVertex()->position().x(),tkip.primaryVertex()->position().y(),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  {
71  if (fabs(impactParameters[i].distanceToJetAxis.value()) < m_cutMaxDistToAxis && // distance to JetAxis
72  (impactParameters[i].closestToJetAxis - pv).mag() < m_cutMaxDecayLen && // max decay len
73  (m_useAllQualities == true || reco::btag::toTrack(tracks[i])->quality(m_trackQuality)) // use selected track qualities
74  )
75  {
76  // Use only positive(or negative) tracks for B
77  float p=fabs(*it);
78  if (useVariableJTA_) {
79  if (tkip.variableJTA( varJTApars )[i]) {
80  if(m_trackSign>0 || *it <0 ) probabilities.push_back(p); //Use all tracks for positive tagger and only negative for negative tagger
81  if(m_trackSign>0 && *it >=0){probabilitiesB.push_back(*it);} //Use only positive tracks for positive tagger
82  if(m_trackSign<0 && *it <=0){probabilitiesB.push_back(- *it);} //Use only negative tracks for negative tagger
83  }
84  }
85  else
86  if( m_deltaR < 0 || ROOT::Math::VectorUtil::DeltaR((*tkip.jet()).p4().Vect(), (*tracks[i]).momentum()) < m_deltaR)
87  {
88  //if(m_trackSign>0 || *it >0 ) probabilities.push_back(p); //Use all tracks for positive tagger and only negative for negative tagger
89  if(m_trackSign>0 || *it <0 ) probabilities.push_back(p); //Use all tracks for positive tagger and only negative for negative tagger
90 
91  if(m_trackSign>0 && *it >=0){probabilitiesB.push_back(*it);} //Use only positive tracks for positive tagger
92  if(m_trackSign<0 && *it <=0){probabilitiesB.push_back(- *it);} //Use only negative tracks for negative tagger
93  }
94  }
95  }
96 
97  float all = jetProbability(probabilities);
98  std::sort(probabilitiesB.begin(), probabilitiesB.end());
99  if(probabilitiesB.size() > m_nbTracks ) probabilitiesB.resize(m_nbTracks);
100  float b = jetProbability(probabilitiesB);
101 
102  return -log(b)/4-log(all)/4;
103  }
double jetProbability(const std::vector< float > &v) const
const reco::Track * toTrack(const reco::TrackBaseRef &t)
Definition: IPTagInfo.h:24
reco::btag::variableJTAParameters varJTApars
double p4[4]
Definition: TauolaWrapper.h:92
def pv(vc)
Definition: MetAnalyzer.py:6
double b
Definition: hdecay.h:120
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:505
reco::IPTagInfo< Container, Base > TagInfo
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::jetProbability ( const std::vector< float > &  v) const
inline

Definition at line 105 of file TemplatedJetBProbabilityComputer.h.

References gather_cfg::cout, JetChargeProducer_cfi::exp, checklumidiff::l, cmsBatch::log, TemplatedJetBProbabilityComputer< Container, Base >::m_minTrackProb, hpstanc_transforms::max, min(), and lumiQueryAPI::q.

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

106 {
107  int ngoodtracks=v.size();
108  double SumJet=0.;
109 
110  for(std::vector<float>::const_iterator q = v.begin(); q != v.end(); q++){
111  SumJet+=(*q>m_minTrackProb)?log(*q):log(m_minTrackProb);
112  }
113 
114  double ProbJet;
115  double Loginvlog=0;
116 
117  if(SumJet<0.){
118  if(ngoodtracks>=2){
119  Loginvlog=log(-SumJet);
120  }
121  double Prob=1.;
122  double lfact=1.;
123  for(int l=1; l!=ngoodtracks; l++){
124  lfact*=l;
125  Prob+=exp(l*Loginvlog-log(1.*lfact));
126  }
127  double LogProb=log(Prob);
128  ProbJet=
129  std::min(exp(std::max(LogProb+SumJet,-30.)),1.);
130  }else{
131  ProbJet=1.;
132  }
133  if(ProbJet>1)
134  std::cout << "ProbJet too high: " << ProbJet << std::endl;
135 
136  //double LogProbJet=-log(ProbJet);
137  // //return 1.-ProbJet;
138  return ProbJet;
139  }
T min(T a, T b)
Definition: MathUtil.h:58

Member Data Documentation

template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::m_cutMaxDecayLen
private
template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::m_cutMaxDistToAxis
private
template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::m_deltaR
private
template<class Container , class Base >
int TemplatedJetBProbabilityComputer< Container, Base >::m_ipType
private
template<class Container , class Base >
double TemplatedJetBProbabilityComputer< Container, Base >::m_minTrackProb
private
template<class Container , class Base >
unsigned int TemplatedJetBProbabilityComputer< Container, Base >::m_nbTracks
private
template<class Container , class Base >
reco::TrackBase::TrackQuality TemplatedJetBProbabilityComputer< Container, Base >::m_trackQuality
private
template<class Container , class Base >
int TemplatedJetBProbabilityComputer< Container, Base >::m_trackSign
private
template<class Container , class Base >
bool TemplatedJetBProbabilityComputer< Container, Base >::m_useAllQualities
private
template<class Container , class Base >
bool TemplatedJetBProbabilityComputer< Container, Base >::useVariableJTA_
private
template<class Container , class Base >
reco::btag::variableJTAParameters TemplatedJetBProbabilityComputer< Container, Base >::varJTApars
private