CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoTauTag/ImpactParameter/src/ImpactParameterAlgorithm.cc

Go to the documentation of this file.
00001 #include "RecoTauTag/ImpactParameter/interface/ImpactParameterAlgorithm.h"
00002 
00003 #include "RecoBTag/BTagTools/interface/SignedTransverseImpactParameter.h"
00004 #include "RecoBTag/BTagTools/interface/SignedImpactParameter3D.h"
00005 
00006 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00007 
00008 ImpactParameterAlgorithm::ImpactParameterAlgorithm(){
00009         ip_min   = -9999;
00010         ip_max   = 9999;
00011         sip_min  = 0;
00012         use_sign = false;
00013         use3D    = false; 
00014 }
00015 
00016 ImpactParameterAlgorithm::ImpactParameterAlgorithm(const edm::ParameterSet & parameters){
00017         ip_min       = parameters.getParameter<double>("TauImpactParameterMin");
00018         ip_max       = parameters.getParameter<double>("TauImpactParameterMax");
00019         sip_min      = parameters.getParameter<double>("TauImpactParameterSignificanceMin");
00020         use_sign     = parameters.getParameter<bool>("UseTauImpactParameterSign");
00021         use3D        = parameters.getParameter<bool>("UseTau3DImpactParameter");
00022 
00023 }
00024 
00025 void ImpactParameterAlgorithm::setTransientTrackBuilder(const TransientTrackBuilder * builder) { 
00026         transientTrackBuilder = builder; 
00027 }
00028 
00029 
00030 std::pair<float,reco::TauImpactParameterInfo> ImpactParameterAlgorithm::tag(const reco::IsolatedTauTagInfoRef & tauRef, const reco::Vertex & pv) {
00031 
00032         if(transientTrackBuilder == 0){
00033              std::cout << "Transient track builder is 0. abort!" << std::endl;
00034              abort(); //FIXME: trow an exception here
00035         }
00036 
00037         reco::TauImpactParameterInfo resultExtended;
00038         resultExtended.setIsolatedTauTag(tauRef);
00039 
00040         const reco::Jet* jet = tauRef->jet().get();
00041         GlobalVector direction(jet->px(),jet->py(),jet->pz());
00042 
00043         const reco::TrackRefVector& tracks = tauRef->selectedTracks();
00044 
00045         edm::RefVector<reco::TrackCollection>::const_iterator iTrack;
00046         for(iTrack = tracks.begin(); iTrack!= tracks.end(); iTrack++){
00047 
00048           const reco::TransientTrack transientTrack = (transientTrackBuilder->build(&(**iTrack)));
00049 
00050           SignedTransverseImpactParameter stip;
00051           Measurement1D ip = stip.apply(transientTrack,direction,pv).second;
00052 
00053           SignedImpactParameter3D signed_ip3D;
00054           Measurement1D ip3D = signed_ip3D.apply(transientTrack,direction,pv).second;
00055           //std::cout << "check pv,ip3d,track z " << pv.z() << " " << ip3D.value() << " " << transientTrack->dz() << std::endl;
00056           if(!use_sign){
00057             Measurement1D tmp2D(fabs(ip.value()),ip.error());
00058             ip = tmp2D;
00059 
00060             Measurement1D tmp3D(fabs(ip3D.value()),ip3D.error());
00061             ip3D = tmp3D;
00062           }
00063 
00064           reco::TauImpactParameterTrackData theData;
00065 
00066           theData.transverseIp = ip;
00067           theData.ip3D = ip3D;
00068           resultExtended.storeTrackData(*iTrack,theData);
00069 
00070         }
00071 
00072         float discriminator = resultExtended.discriminator(ip_min,ip_max,sip_min,use_sign,use3D);
00073 
00074         return std::make_pair( discriminator, resultExtended );
00075 }