CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoBTag/SecondaryVertex/interface/SimpleSecondaryVertexComputer.h

Go to the documentation of this file.
00001 #ifndef RecoBTag_SecondaryVertex_SimpleSecondaryVertexComputer_h
00002 #define RecoBTag_SecondaryVertex_SimpleSecondaryVertexComputer_h
00003 
00004 #include <cmath>
00005 
00006 #include "Math/GenVector/VectorUtil.h"
00007 
00008 #include "DataFormats/TrackReco/interface/Track.h"
00009 #include "DataFormats/VertexReco/interface/Vertex.h"
00010 #include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h"
00011 
00012 #include "RecoBTau/JetTagComputer/interface/JetTagComputer.h"
00013 
00014 #include "RecoBTag/SecondaryVertex/interface/TrackKinematics.h"
00015 
00016 class SimpleSecondaryVertexComputer : public JetTagComputer {
00017     public:
00018         SimpleSecondaryVertexComputer(const edm::ParameterSet &parameters) :
00019                 use2d(!parameters.getParameter<bool>("use3d")),
00020                 useSig(parameters.getParameter<bool>("useSignificance")),
00021                 unBoost(parameters.getParameter<bool>("unBoost")),
00022                 minTracks(parameters.getParameter<unsigned int>("minTracks")),
00023                 minVertices_(1)
00024                   { 
00025                     uses("svTagInfos"); 
00026                     minVertices_    = parameters.existsAs<unsigned int>("minVertices") ?  parameters.getParameter<unsigned int>("minVertices") : 1 ;
00027                   }
00028 
00029         float discriminator(const TagInfoHelper &tagInfos) const
00030         {
00031                 const reco::SecondaryVertexTagInfo &info =
00032                                 tagInfos.get<reco::SecondaryVertexTagInfo>();
00033                 if(info.nVertices() < minVertices_) return -1;
00034                 unsigned int idx = 0;
00035                 while(idx < info.nVertices()) {
00036                         if (info.nVertexTracks(idx) >= minTracks)
00037                                 break;
00038                         idx++;
00039                 }
00040                 if (idx >= info.nVertices())
00041                         return -1.0;
00042 
00043                 double gamma;
00044                 if (unBoost) {
00045                         reco::TrackKinematics kinematics(
00046                                                 info.secondaryVertex(idx));
00047                         gamma = kinematics.vectorSum().Gamma();
00048                 } else
00049                         gamma = 1.0;
00050 
00051                 double value;
00052                 if (useSig)
00053                         value = info.flightDistance(idx, use2d).significance();
00054                 else
00055                         value = info.flightDistance(idx, use2d).value();
00056 
00057                 value /= gamma;
00058 
00059                 if (useSig)
00060                         value = (value > 0) ? +std::log(1 + value)
00061                                             : -std::log(1 - value);
00062 
00063                 return value;
00064         }
00065 
00066     private:
00067         bool            use2d;
00068         bool            useSig;
00069         bool            unBoost;
00070         unsigned int    minTracks;
00071         unsigned int    minVertices_;
00072 };
00073 
00074 #endif // RecoBTag_SecondaryVertex_SimpleSecondaryVertexComputer_h