CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetProbabilityComputer.h
Go to the documentation of this file.
1 #ifndef ImpactParameter_JetProbabilityComputer_h
2 #define ImpactParameter_JetProbabilityComputer_h
3 
9 #include "Math/GenVector/VectorUtil.h"
11 
12 #include <iostream>
13 
15 {
16  public:
18  {
19  m_ipType = parameters.getParameter<int>("impactParameterType");
20  m_minTrackProb = parameters.getParameter<double>("minimumProbability");
21  m_deltaR = parameters.getParameter<double>("deltaR");
22  m_trackSign = parameters.getParameter<int>("trackIpSign");
23  m_cutMaxDecayLen = parameters.getParameter<double>("maximumDecayLength");
24  m_cutMaxDistToAxis = parameters.getParameter<double>("maximumDistanceToJetAxis");
25  //
26  // access track quality class; "any" takes everything
27  //
28  std::string trackQualityType = parameters.getParameter<std::string>("trackQualityClass"); //used
30  m_useAllQualities = false;
31  if (trackQualityType == "any" ||
32  trackQualityType == "Any" ||
33  trackQualityType == "ANY" ) m_useAllQualities = true;
34 
35  uses("ipTagInfos");
36  }
37 
38  float discriminator(const TagInfoHelper & ti) const
39  {
40  const reco::TrackIPTagInfo & tkip = ti.get<reco::TrackIPTagInfo>();
41 
43  const std::vector<float> & allProbabilities((tkip.probabilities(m_ipType)));
44  const std::vector<reco::TrackIPTagInfo::TrackIPData> & impactParameters((tkip.impactParameterData()));
45 
46  if (tkip.primaryVertex().isNull()) return 0 ;
47 
48  GlobalPoint pv(tkip.primaryVertex()->position().x(),tkip.primaryVertex()->position().y(),tkip.primaryVertex()->position().z());
49 
50  std::vector<float> probabilities;
51  int i=0;
52  for(std::vector<float>::const_iterator it = allProbabilities.begin(); it!=allProbabilities.end(); ++it, i++)
53  {
54  if ( fabs(impactParameters[i].distanceToJetAxis.value()) < m_cutMaxDistToAxis && // distance to JetAxis
55  (impactParameters[i].closestToJetAxis - pv).mag() < m_cutMaxDecayLen && // max decay len
56  (m_useAllQualities == true || (*tracks[i]).quality(m_trackQuality)) // use selected track qualities
57  )
58  {
59  float p;
60  if(m_trackSign ==0 )
61  {
62  if (*it >=0){p=*it/2.;}else{p=1.+*it/2.;}
63  }
64  else if(m_trackSign > 0)
65  {
66  if(*it >=0 ) p=*it; else continue;
67  } else
68  {
69  if(*it <=0 ) p= -*it; else continue;
70  }
71  if(m_deltaR <= 0 || ROOT::Math::VectorUtil::DeltaR((*tkip.jet()).p4().Vect(), (*tracks[i]).momentum()) < m_deltaR )
72  probabilities.push_back(p);
73  }
74  }
75  return jetProbability(probabilities);
76  }
77 
78 double jetProbability( const std::vector<float> & v ) const
79 {
80  int ngoodtracks=v.size();
81  double SumJet=0.;
82 
83  for(std::vector<float>::const_iterator q = v.begin(); q != v.end(); q++){
84  SumJet+=(*q>m_minTrackProb)?log(*q):log(m_minTrackProb);
85  }
86 
87  double ProbJet;
88  double Loginvlog=0;
89 
90  if(SumJet<0.){
91  if(ngoodtracks>=2){
92  Loginvlog=log(-SumJet);
93  }
94  double Prob=1.;
95  double lfact=1.;
96  for(int l=1; l!=ngoodtracks; l++){
97  lfact*=l;
98  Prob+=exp(l*Loginvlog-log(1.*lfact));
99  }
100  double LogProb=log(Prob);
101  ProbJet=
102  std::min(exp(std::max(LogProb+SumJet,-30.)),1.);
103  }else{
104  ProbJet=1.;
105  }
106  if(ProbJet>1)
107  std::cout << "ProbJet too high: " << ProbJet << std::endl;
108 
109  //double LogProbJet=-log(ProbJet);
110  // //return 1.-ProbJet;
111  return -log10(ProbJet)/4.;
112  }
113  private:
115  int m_ipType;
116  double m_deltaR;
122 
123 
124 };
125 
126 #endif // ImpactParameter_JetProbabilityComputer_h
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
const T & get(unsigned int index=0) const
const edm::Ref< VertexCollection > & primaryVertex() const
TrackQuality
track quality
Definition: TrackBase.h:95
#define min(a, b)
Definition: mlp_lapack.h:161
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
double jetProbability(const std::vector< float > &v) const
bool isNull() const
Checks for null.
Definition: Ref.h:246
const T & max(const T &a, const T &b)
double p4[4]
Definition: TauolaWrapper.h:92
void uses(unsigned int id, const std::string &label)
reco::TrackBase::TrackQuality m_trackQuality
const std::vector< float > & probabilities(int ip) const
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
Definition: JTATagInfo.h:20
JetProbabilityComputer(const edm::ParameterSet &parameters)
float discriminator(const TagInfoHelper &ti) const
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
Log< T >::type log(const T &t)
Definition: Log.h:22
tuple tracks
Definition: testEve_cfg.py:39
const std::vector< TrackIPData > & impactParameterData() const
tuple cout
Definition: gather_cfg.py:41
const edm::RefVector< TrackCollection > & selectedTracks() const
mathSSE::Vec4< T > v