CMS 3D CMS Logo

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