CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc

Go to the documentation of this file.
00001 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h"
00002 #include "FWCore/Utilities/interface/InputTag.h"
00003 
00004 /* class PFRecoTauDiscriminationByDeltaE
00005  * created : August 30 2010,
00006  * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki)
00007  * based on H+ tau ID by Lauri Wendland
00008  */
00009 
00010 #include "TLorentzVector.h"
00011 
00012 using namespace reco;
00013 using namespace std;
00014 using namespace edm;
00015 
00016 class PFRecoTauDiscriminationByDeltaE : public PFTauDiscriminationProducerBase  {
00017     public:
00018         explicit PFRecoTauDiscriminationByDeltaE(const ParameterSet& iConfig):PFTauDiscriminationProducerBase(iConfig){
00019                 deltaEmin               = iConfig.getParameter<double>("deltaEmin");
00020                 deltaEmax               = iConfig.getParameter<double>("deltaEmax");
00021                 chargedPionMass         = 0.139;
00022                 booleanOutput           = iConfig.getParameter<bool>("BooleanOutput");
00023         }
00024 
00025         ~PFRecoTauDiscriminationByDeltaE(){}
00026 
00027         void beginEvent(const edm::Event&, const edm::EventSetup&);
00028         double discriminate(const reco::PFTauRef&);
00029 
00030     private:
00031         double DeltaE(const PFTauRef&);
00032 
00033         double chargedPionMass;
00034 
00035         double deltaEmin,deltaEmax;
00036         bool booleanOutput;
00037 };
00038 
00039 void PFRecoTauDiscriminationByDeltaE::beginEvent(const Event& iEvent, const EventSetup& iSetup){
00040 }
00041 
00042 double PFRecoTauDiscriminationByDeltaE::discriminate(const PFTauRef& tau){
00043 
00044         double dE = DeltaE(tau);
00045         if(booleanOutput) return ( dE > deltaEmin && dE < deltaEmax ? 1. : 0. );
00046         return dE;
00047 }
00048 
00049 double PFRecoTauDiscriminationByDeltaE::DeltaE(const PFTauRef& tau){
00050         double tracksE = 0;
00051         PFCandidateRefVector signalTracks = tau->signalPFChargedHadrCands();
00052         for(size_t i = 0; i < signalTracks.size(); ++i){
00053                 TLorentzVector p4;
00054                 p4.SetXYZM(signalTracks[i]->px(),
00055                            signalTracks[i]->py(),
00056                            signalTracks[i]->pz(),
00057                            chargedPionMass);
00058                 tracksE += p4.E();
00059         }
00060 
00061         double hadrTauP = tau->momentum().r() * (1.0 - tau->emFraction());
00062         if (tau->emFraction() >= 1.0) {
00063                 return -1.0; // electron
00064         } else {
00065                 return tracksE / hadrTauP - 1.0;
00066         }
00067 }
00068 
00069 DEFINE_FWK_MODULE(PFRecoTauDiscriminationByDeltaE);
00070