CMS 3D CMS Logo

Public Member Functions | Private Attributes

JetBProbabilityComputer Class Reference

#include <JetBProbabilityComputer.h>

Inheritance diagram for JetBProbabilityComputer:
JetTagComputer

List of all members.

Public Member Functions

float discriminator (const TagInfoHelper &ti) const
 JetBProbabilityComputer (const edm::ParameterSet &parameters)
double jetProbability (const std::vector< float > &v) const

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

Detailed Description

Definition at line 13 of file JetBProbabilityComputer.h.


Constructor & Destructor Documentation

JetBProbabilityComputer::JetBProbabilityComputer ( const edm::ParameterSet parameters) [inline]

Definition at line 16 of file JetBProbabilityComputer.h.

References edm::ParameterSet::getParameter(), m_cutMaxDecayLen, m_cutMaxDistToAxis, m_deltaR, m_ipType, m_minTrackProb, m_nbTracks, m_trackQuality, m_trackSign, m_useAllQualities, reco::TrackBase::qualityByName(), and JetTagComputer::uses().

  { 
     m_ipType           = parameters.getParameter<int>("impactParameterType");
     m_minTrackProb     = parameters.getParameter<double>("minimumProbability");
     m_deltaR           = parameters.getParameter<double>("deltaR");
     m_trackSign        = parameters.getParameter<int>("trackIpSign");
     m_nbTracks         = parameters.getParameter<unsigned int>("numberOfBTracks");
     m_cutMaxDecayLen   = parameters.getParameter<double>("maximumDecayLength");
     m_cutMaxDistToAxis = parameters.getParameter<double>("maximumDistanceToJetAxis");
 
     //
     // access track quality class; "any" takes everything
     //
     std::string trackQualityType = parameters.getParameter<std::string>("trackQualityClass"); //used
     m_trackQuality =  reco::TrackBase::qualityByName(trackQualityType);
     m_useAllQualities = false;
     if (trackQualityType == "any" || 
         trackQualityType == "Any" || 
         trackQualityType == "ANY" ) m_useAllQualities = true;

     uses("ipTagInfos");
  }

Member Function Documentation

float JetBProbabilityComputer::discriminator ( const TagInfoHelper ti) const [inline, virtual]

log(all);

Reimplemented from JetTagComputer.

Definition at line 39 of file JetBProbabilityComputer.h.

References cond::ecalcond::all, b, JetTagComputer::TagInfoHelper::get(), i, reco::TrackIPTagInfo::impactParameterData(), PyquenDefaultSettings_cff::impactParameters, edm::Ref< C, T, F >::isNull(), reco::JTATagInfo::jet(), jetProbability(), funct::log(), m_cutMaxDecayLen, m_cutMaxDistToAxis, m_deltaR, m_ipType, m_nbTracks, m_trackQuality, m_trackSign, m_useAllQualities, L1TEmulatorMonitor_cff::p, p4, reco::TrackIPTagInfo::primaryVertex(), reco::TrackIPTagInfo::probabilities(), reco::TrackIPTagInfo::selectedTracks(), python::multivaluedict::sort(), and testEve_cfg::tracks.

   {
      const reco::TrackIPTagInfo & tkip = ti.get<reco::TrackIPTagInfo>();
      const edm::RefVector<reco::TrackCollection> & tracks(tkip.selectedTracks());
      const std::vector<float> & allProbabilities((tkip.probabilities(m_ipType)));
      const std::vector<reco::TrackIPTagInfo::TrackIPData> & impactParameters((tkip.impactParameterData()));

      if(tkip.primaryVertex().isNull()) return 0;

      GlobalPoint pv(tkip.primaryVertex()->position().x(),tkip.primaryVertex()->position().y(),tkip.primaryVertex()->position().z());

      std::vector<float> probabilities;
      std::vector<float> probabilitiesB;
      int i=0;
      for(std::vector<float>::const_iterator it = allProbabilities.begin(); it!=allProbabilities.end(); ++it, i++)
       {
        if (fabs(impactParameters[i].distanceToJetAxis.value()) < m_cutMaxDistToAxis  &&        // distance to JetAxis
            (impactParameters[i].closestToJetAxis - pv).mag() < m_cutMaxDecayLen  &&      // max decay len
            (m_useAllQualities  == true || (*tracks[i]).quality(m_trackQuality)) // use selected track qualities
           )
         {
    // Use only positive(or negative) tracks for B
           float p=fabs(*it);
           if( m_deltaR < 0 || ROOT::Math::VectorUtil::DeltaR((*tkip.jet()).p4().Vect(), (*tracks[i]).momentum()) < m_deltaR)
             {
               //if(m_trackSign>0 || *it >0 ) probabilities.push_back(p); //Use all tracks for positive tagger and only negative for negative tagger
               if(m_trackSign>0 || *it <0 ) probabilities.push_back(p); //Use all tracks for positive tagger and only negative for negative tagger

               if(m_trackSign>0 && *it >=0){probabilitiesB.push_back(*it);} //Use only positive tracks for positive tagger
               if(m_trackSign<0 && *it <=0){probabilitiesB.push_back(- *it);} //Use only negative tracks for negative tagger 
             }
         }
       }

      float all = jetProbability(probabilities); 
      std::sort(probabilitiesB.begin(), probabilitiesB.end());
      if(probabilitiesB.size() > m_nbTracks )  probabilitiesB.resize(m_nbTracks);
      float b = jetProbability(probabilitiesB);
        
      return -log(b)/4-log(all)/4; 
   }
double JetBProbabilityComputer::jetProbability ( const std::vector< float > &  v) const [inline]

Definition at line 81 of file JetBProbabilityComputer.h.

References gather_cfg::cout, funct::exp(), prof2calltree::l, funct::log(), m_minTrackProb, max(), min, and lumiQueryAPI::q.

Referenced by discriminator().

{
   int ngoodtracks=v.size();
   double SumJet=0.;

  for(std::vector<float>::const_iterator q = v.begin(); q != v.end(); q++){
    SumJet+=(*q>m_minTrackProb)?log(*q):log(m_minTrackProb);
  }

  double ProbJet;
  double Loginvlog=0;

  if(SumJet<0.){
    if(ngoodtracks>=2){
      Loginvlog=log(-SumJet);
    }
    double Prob=1.;
    double lfact=1.;
    for(int l=1; l!=ngoodtracks; l++){
       lfact*=l;
      Prob+=exp(l*Loginvlog-log(1.*lfact));
    }
    double LogProb=log(Prob);
    ProbJet=
      std::min(exp(std::max(LogProb+SumJet,-30.)),1.);
  }else{
    ProbJet=1.;
  }
  if(ProbJet>1)
   std::cout << "ProbJet too high: "  << ProbJet << std::endl;

  //double LogProbJet=-log(ProbJet);
  //  //return 1.-ProbJet;
      return ProbJet;
  }

Member Data Documentation

Definition at line 122 of file JetBProbabilityComputer.h.

Referenced by discriminator(), and JetBProbabilityComputer().

Definition at line 123 of file JetBProbabilityComputer.h.

Referenced by discriminator(), and JetBProbabilityComputer().

Definition at line 119 of file JetBProbabilityComputer.h.

Referenced by discriminator(), and JetBProbabilityComputer().

Definition at line 118 of file JetBProbabilityComputer.h.

Referenced by discriminator(), and JetBProbabilityComputer().

Definition at line 117 of file JetBProbabilityComputer.h.

Referenced by JetBProbabilityComputer(), and jetProbability().

unsigned int JetBProbabilityComputer::m_nbTracks [private]

Definition at line 121 of file JetBProbabilityComputer.h.

Referenced by discriminator(), and JetBProbabilityComputer().

Definition at line 124 of file JetBProbabilityComputer.h.

Referenced by discriminator(), and JetBProbabilityComputer().

Definition at line 120 of file JetBProbabilityComputer.h.

Referenced by discriminator(), and JetBProbabilityComputer().

Definition at line 125 of file JetBProbabilityComputer.h.

Referenced by discriminator(), and JetBProbabilityComputer().