CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationAgainstElectron.cc

Go to the documentation of this file.
00001 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h"
00002 
00003 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00004 #include "RecoTauTag/TauTagTools/interface/TauTagTools.h"
00005 #include "FWCore/Utilities/interface/isFinite.h"
00006 
00007 /* class CaloRecoTauDiscriminationAgainstElectron
00008  * created : Feb 17 2008,
00009  * revised : ,
00010  * contributors : Konstantinos Petridis, Sebastien Greder, 
00011  *                Maiko Takahashi, Alexandre Nikitenko (Imperial College, London), 
00012  *                Evan Friis (UC Davis)
00013  */
00014 
00015 using namespace reco;
00016 
00017 class CaloRecoTauDiscriminationAgainstElectron : public  CaloTauDiscriminationProducerBase {
00018    public:
00019       explicit CaloRecoTauDiscriminationAgainstElectron(const edm::ParameterSet& iConfig):CaloTauDiscriminationProducerBase(iConfig){   
00020          CaloTauProducer_                            = iConfig.getParameter<edm::InputTag>("CaloTauProducer");
00021          leadTrack_HCAL3x3hitsEtSumOverPt_minvalue_  = iConfig.getParameter<double>("leadTrack_HCAL3x3hitsEtSumOverPt_minvalue");  
00022          ApplyCut_maxleadTrackHCAL3x3hottesthitDEta_ = iConfig.getParameter<bool>("ApplyCut_maxleadTrackHCAL3x3hottesthitDEta");
00023          maxleadTrackHCAL3x3hottesthitDEta_          = iConfig.getParameter<double>("maxleadTrackHCAL3x3hottesthitDEta");
00024          ApplyCut_leadTrackavoidsECALcrack_          = iConfig.getParameter<bool>("ApplyCut_leadTrackavoidsECALcrack");
00025       }
00026       ~CaloRecoTauDiscriminationAgainstElectron(){} 
00027       double discriminate(const CaloTauRef& theCaloTauRef);
00028       void beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup);
00029    private:  
00030       edm::ESHandle<MagneticField> theMagneticField;
00031       edm::InputTag CaloTauProducer_;
00032       double leadTrack_HCAL3x3hitsEtSumOverPt_minvalue_;   
00033       bool ApplyCut_maxleadTrackHCAL3x3hottesthitDEta_;
00034       double maxleadTrackHCAL3x3hottesthitDEta_;
00035       bool ApplyCut_leadTrackavoidsECALcrack_;
00036 };
00037 
00038 void CaloRecoTauDiscriminationAgainstElectron::beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup)
00039 {
00040    if (ApplyCut_leadTrackavoidsECALcrack_)
00041    {
00042       // get the magnetic field, if we need it
00043       eventSetup.get<IdealMagneticFieldRecord>().get(theMagneticField);
00044    }
00045 }
00046 
00047 
00048 double CaloRecoTauDiscriminationAgainstElectron::discriminate(const CaloTauRef& theCaloTauRef)
00049 {
00050    if (ApplyCut_maxleadTrackHCAL3x3hottesthitDEta_){
00051       // optional selection : ask for small |deta| between direction of propag. leading Track - ECAL inner surf. contact point and direction of highest Et hit among HCAL hits inside a 3x3 calo. tower matrix centered on direction of propag. leading Track - ECAL inner surf. contact point
00052       if (edm::isNotFinite((*theCaloTauRef).leadTrackHCAL3x3hottesthitDEta()) || (*theCaloTauRef).leadTrackHCAL3x3hottesthitDEta()>maxleadTrackHCAL3x3hottesthitDEta_) return 0.;
00053    }
00054    if (ApplyCut_leadTrackavoidsECALcrack_){
00055       // optional selection : ask that leading track - ECAL inner surface contact point does not fall inside any ECAL eta crack 
00056       math::XYZPoint thepropagleadTrackECALSurfContactPoint = TauTagTools::propagTrackECALSurfContactPoint(theMagneticField.product(),(*theCaloTauRef).leadTrack());
00057       if(thepropagleadTrackECALSurfContactPoint.R()==0. ||
00058             fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalA().second || 
00059             (fabs(thepropagleadTrackECALSurfContactPoint.eta())>ECALBounds::crack_absEtaIntervalB().first && fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalB().second) ||
00060             (fabs(thepropagleadTrackECALSurfContactPoint.eta())>ECALBounds::crack_absEtaIntervalC().first && fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalC().second) ||
00061             (fabs(thepropagleadTrackECALSurfContactPoint.eta())>ECALBounds::crack_absEtaIntervalD().first && fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalD().second) ||
00062             (fabs(thepropagleadTrackECALSurfContactPoint.eta())>ECALBounds::crack_absEtaIntervalE().first && fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalE().second))
00063       {
00064          return 0.;
00065       }     
00066    }
00067    if (edm::isNotFinite((*theCaloTauRef).leadTrackHCAL3x3hitsEtSum()))
00068    {
00069       return 0.;
00070    } else
00071    {
00072       if ((*theCaloTauRef).leadTrackHCAL3x3hitsEtSum()/(*theCaloTauRef).leadTrack()->pt()<=leadTrack_HCAL3x3hitsEtSumOverPt_minvalue_) return 0.;
00073       else return 1.;
00074    }
00075 }
00076 
00077    /*
00078 void CaloRecoTauDiscriminationAgainstElectron::produce(edm::Event& iEvent,const edm::EventSetup& iEventSetup){
00079   edm::Handle<CaloTauCollection> theCaloTauCollection;
00080   iEvent.getByLabel(CaloTauProducer_,theCaloTauCollection);
00081 
00082   // fill the AssociationVector object
00083   auto_ptr<CaloTauDiscriminator> theCaloTauDiscriminatorAgainstElectron(new CaloTauDiscriminator(CaloTauRefProd(theCaloTauCollection)));
00084 
00085   for(size_t iCaloTau=0;iCaloTau<theCaloTauCollection->size();++iCaloTau) {
00086     CaloTauRef theCaloTauRef(theCaloTauCollection,iCaloTau);
00087     if (!(*theCaloTauRef).leadTrack()){
00088       theCaloTauDiscriminatorAgainstElectron->setValue(iCaloTau,0);
00089       continue;
00090     }
00091     if (ApplyCut_maxleadTrackHCAL3x3hottesthitDEta_){
00092       // optional selection : ask for small |deta| between direction of propag. leading Track - ECAL inner surf. contact point and direction of highest Et hit among HCAL hits inside a 3x3 calo. tower matrix centered on direction of propag. leading Track - ECAL inner surf. contact point
00093       if (edm::isNotFinite((*theCaloTauRef).leadTrackHCAL3x3hottesthitDEta()) || (*theCaloTauRef).leadTrackHCAL3x3hottesthitDEta()>maxleadTrackHCAL3x3hottesthitDEta_){
00094         theCaloTauDiscriminatorAgainstElectron->setValue(iCaloTau,0);
00095         continue;
00096       }
00097     }
00098     if (ApplyCut_leadTrackavoidsECALcrack_){
00099       // optional selection : ask that leading track - ECAL inner surface contact point does not fall inside any ECAL eta crack 
00100       edm::ESHandle<MagneticField> theMagneticField;
00101       iEventSetup.get<IdealMagneticFieldRecord>().get(theMagneticField);
00102       math::XYZPoint thepropagleadTrackECALSurfContactPoint=TauTagTools::propagTrackECALSurfContactPoint(theMagneticField.product(),(*theCaloTauRef).leadTrack());
00103       if(thepropagleadTrackECALSurfContactPoint.R()==0. ||
00104          fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalA().second || 
00105          (fabs(thepropagleadTrackECALSurfContactPoint.eta())>ECALBounds::crack_absEtaIntervalB().first && fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalB().second) ||
00106          (fabs(thepropagleadTrackECALSurfContactPoint.eta())>ECALBounds::crack_absEtaIntervalC().first && fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalC().second) ||
00107          (fabs(thepropagleadTrackECALSurfContactPoint.eta())>ECALBounds::crack_absEtaIntervalD().first && fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalD().second) ||
00108          (fabs(thepropagleadTrackECALSurfContactPoint.eta())>ECALBounds::crack_absEtaIntervalE().first && fabs(thepropagleadTrackECALSurfContactPoint.eta())<ECALBounds::crack_absEtaIntervalE().second)
00109          ){
00110         theCaloTauDiscriminatorAgainstElectron->setValue(iCaloTau,0);
00111         continue;
00112       }     
00113     }
00114     if (edm::isNotFinite((*theCaloTauRef).leadTrackHCAL3x3hitsEtSum())){
00115       theCaloTauDiscriminatorAgainstElectron->setValue(iCaloTau,0);
00116     }else{
00117       if ((*theCaloTauRef).leadTrackHCAL3x3hitsEtSum()/(*theCaloTauRef).leadTrack()->pt()<=leadTrack_HCAL3x3hitsEtSumOverPt_minvalue_) theCaloTauDiscriminatorAgainstElectron->setValue(iCaloTau,0);
00118       else theCaloTauDiscriminatorAgainstElectron->setValue(iCaloTau,1);
00119     }
00120   }
00121    
00122   iEvent.put(theCaloTauDiscriminatorAgainstElectron);
00123 }
00124 */
00125 DEFINE_FWK_MODULE(CaloRecoTauDiscriminationAgainstElectron);