CMS 3D CMS Logo

TemplatedTrackCountingComputer.h
Go to the documentation of this file.
1 #ifndef ImpactParameter_TemplatedTrackCountingComputer_h
2 #define ImpactParameter_TemplatedTrackCountingComputer_h
3 
8 #include "Math/GenVector/VectorUtil.h"
10 
11 template <class Container, class Base>
13 {
14 
15  public:
17 
19  {
20  m_minIP = parameters.existsAs<double>("minimumImpactParameter") ? parameters.getParameter<double>("minimumImpactParameter") : -1;
21  m_useSignedIPSig = parameters.existsAs<bool>("useSignedImpactParameterSig") ? parameters.getParameter<bool>("useSignedImpactParameterSig") : true;
22  m_nthTrack = parameters.getParameter<int>("nthTrack");
23  m_ipType = parameters.getParameter<int>("impactParameterType");
24  m_deltaR = parameters.getParameter<double>("deltaR");
25  m_cutMaxDecayLen = parameters.getParameter<double>("maximumDecayLength"); //used
26  m_cutMaxDistToAxis = parameters.getParameter<double>("maximumDistanceToJetAxis"); //used
27  //
28  // access track quality class; "any" takes everything
29  //
30  std::string trackQualityType = parameters.getParameter<std::string>("trackQualityClass"); //used
32  m_useAllQualities = false;
33  if (trackQualityType == "any" ||
34  trackQualityType == "Any" ||
35  trackQualityType == "ANY" ) m_useAllQualities = true;
36 
37  uses("ipTagInfos");
38 
39  useVariableJTA_ = parameters.existsAs<bool>("useVariableJTA") ? parameters.getParameter<bool>("useVariableJTA") : false ;
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  }
53 
54 
55  float discriminator(const TagInfoHelper & ti) const override
56  {
57  const TagInfo & tkip = ti.get<TagInfo>();
58  std::multiset<float> significances = orderedSignificances(tkip);
59  std::multiset<float>::reverse_iterator nth=significances.rbegin();
60  for(int i=0;i<m_nthTrack-1 && nth!=significances.rend();i++) nth++;
61  if(nth!=significances.rend()) return *nth; else return -100.;
62  }
63 
64  protected:
65 
66  std::multiset<float> orderedSignificances(const TagInfo & tkip) const {
67 
68  const std::vector<reco::btag::TrackIPData> & impactParameters((tkip.impactParameterData()));
69  const Container & tracks(tkip.selectedTracks());
70  std::multiset<float> significances;
71  int i=0;
72  if(tkip.primaryVertex().isNull()) { return std::multiset<float>();}
73 
74  GlobalPoint pv(tkip.primaryVertex()->position().x(),tkip.primaryVertex()->position().y(),tkip.primaryVertex()->position().z());
75 
76  for(std::vector<reco::btag::TrackIPData>::const_iterator it = impactParameters.begin(); it!=impactParameters.end(); ++it, i++) {
77  if( fabs(impactParameters[i].distanceToJetAxis.value()) < m_cutMaxDistToAxis && // distance to JetAxis
78  (impactParameters[i].closestToJetAxis - pv).mag() < m_cutMaxDecayLen && // max decay len
79  (m_useAllQualities == true || reco::btag::toTrack(tracks[i])->quality(m_trackQuality)) && // use selected track qualities
80  (fabs(((m_ipType==0) ? it->ip3d:it->ip2d).value()) > m_minIP) // minimum impact parameter
81  ) {
82 
83  //calculate the signed or un-signed significance
84  float signed_sig = ((m_ipType == 0) ? it->ip3d : it->ip2d).significance();
85  float unsigned_sig = fabs(signed_sig);
86  float significance = (m_useSignedIPSig) ? signed_sig : unsigned_sig;
87 
88  if (useVariableJTA_) {
89  if (tkip.variableJTA( varJTApars )[i]) significances.insert( significance );
90  }
91  else // no using variable JTA, use the default method
92  if(m_deltaR <=0 || ROOT::Math::VectorUtil::DeltaR((*tkip.jet()).p4().Vect(), (*tracks[i]).momentum()) < m_deltaR)
93  significances.insert( significance );
94  }
95  }
96 
97  return significances;
98  }
99 
100 
103 
104  double m_minIP;
106 
108  int m_ipType;
109  double m_deltaR;
114 };
115 
116 #endif // ImpactParameter_TemplatedTrackCountingComputer_h
T getParameter(std::string const &) const
const T & get(unsigned int index=0) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
std::vector< bool > variableJTA(const btag::variableJTAParameters &params) const
Definition: IPTagInfo.h:212
TrackQuality
track quality
Definition: TrackBase.h:151
const Container & selectedTracks() const
Definition: IPTagInfo.h:101
reco::TrackBase::TrackQuality m_trackQuality
reco::IPTagInfo< Container, Base > TagInfo
const reco::Track * toTrack(const reco::TrackBaseRef &t)
Definition: IPTagInfo.h:24
TemplatedTrackCountingComputer(const edm::ParameterSet &parameters)
const edm::Ref< VertexCollection > & primaryVertex() const
Definition: IPTagInfo.h:133
double p4[4]
Definition: TauolaWrapper.h:92
void uses(unsigned int id, const std::string &label)
def pv(vc)
Definition: MetAnalyzer.py:6
bool isNull() const
Checks for null.
Definition: Ref.h:250
float discriminator(const TagInfoHelper &ti) const override
const std::vector< btag::TrackIPData > & impactParameterData() const
Definition: IPTagInfo.h:91
std::multiset< float > orderedSignificances(const TagInfo &tkip) const
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
reco::btag::variableJTAParameters varJTApars
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:510
significance
Definition: met_cff.py:30
edm::AssociationVector< reco::JetRefBaseProd, Values > Container