00001 00008 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronCombinedIsolationProducer.h" 00009 00010 // Framework 00011 #include "FWCore/Framework/interface/Event.h" 00012 #include "FWCore/Framework/interface/EventSetup.h" 00013 #include "DataFormats/Common/interface/Handle.h" 00014 #include "FWCore/Framework/interface/ESHandle.h" 00015 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00016 #include "FWCore/Utilities/interface/Exception.h" 00017 00018 #include "DataFormats/EgammaCandidates/interface/Electron.h" 00019 #include "DataFormats/EgammaCandidates/interface/ElectronIsolationAssociation.h" 00020 00021 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h" 00022 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h" 00023 00024 #include "DataFormats/EgammaReco/interface/SuperCluster.h" 00025 00026 00027 #include "DataFormats/Common/interface/RefToBase.h" 00028 #include "DataFormats/Common/interface/Ref.h" 00029 #include "DataFormats/Common/interface/RefProd.h" 00030 00031 00032 EgammaHLTElectronCombinedIsolationProducer::EgammaHLTElectronCombinedIsolationProducer(const edm::ParameterSet& config) : conf_(config) 00033 { 00034 00035 electronProducer_ = conf_.getParameter<edm::InputTag>("electronProducer"); 00036 recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer"); 00037 00038 CaloIsolTag_ = conf_.getParameter< std::vector<edm::InputTag> > ("CaloIsolationMapTags"); 00039 //need to be in the order EcalIso, HcalIso, EleTrackIso 00040 CaloIsolWeight_ = conf_.getParameter< std::vector<double> > ("CaloIsolationWeight"); 00041 00042 TrackIsolTag_ = conf_.getParameter<edm::InputTag>("TrackIsolationMapTag"); 00043 TrackIsolWeight_ = conf_.getParameter<double>("TrackIsolationWeight"); 00044 00045 if ( CaloIsolTag_.size() != CaloIsolWeight_.size()){ 00046 throw cms::Exception("BadConfig") << "vectors CaloIsolationMapTags and CaloIsolationWeight need to have size 3"; 00047 } 00048 00049 00050 // SCProducer_ = conf_.getParameter<edm::InputTag>("electronProducer"); 00051 00052 //register your products 00053 produces < reco::ElectronIsolationMap >(); 00054 00055 } 00056 EgammaHLTElectronCombinedIsolationProducer::~EgammaHLTElectronCombinedIsolationProducer(){} 00057 00058 00059 void EgammaHLTElectronCombinedIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) 00060 { 00061 00062 using namespace std; 00063 00064 edm::Handle<reco::ElectronCollection> electronHandle; 00065 iEvent.getByLabel(electronProducer_,electronHandle); 00066 00067 edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle; 00068 iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle); 00069 00070 std::vector< edm::Handle<reco::RecoEcalCandidateIsolationMap> > CaloIsoMap; 00071 for( unsigned int u=0; u < CaloIsolTag_.size(); u++){ 00072 edm::Handle<reco::RecoEcalCandidateIsolationMap> depMapTemp; 00073 if(CaloIsolWeight_[u] != 0){ iEvent.getByLabel (CaloIsolTag_[u],depMapTemp);} 00074 CaloIsoMap.push_back(depMapTemp); 00075 } 00076 00077 edm::Handle<reco::ElectronIsolationMap> TrackIsoMap; 00078 if(TrackIsolWeight_ != 0){ iEvent.getByLabel (TrackIsolTag_,TrackIsoMap);} 00079 00080 reco::ElectronIsolationMap TotalIsolMap; 00081 double TotalIso=0; 00082 for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){ 00083 TotalIso=0; 00084 reco::ElectronRef electronref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin())); 00085 const reco::SuperClusterRef theEleClus = electronref->superCluster(); 00086 00087 //look for corresponding recoecal candidates to search for in the ecal and Hcal iso map 00088 for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){ 00089 reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand-recoecalcandHandle->begin()); 00090 const reco::SuperClusterRef cluster = recoecalcandref->superCluster(); 00091 if(&(*cluster) == &(*theEleClus)) {//recoecalcand and electron have the same SC 00092 for(unsigned int u=0; u < CaloIsolTag_.size() ;u++){ 00093 if(CaloIsolWeight_[u]==0){continue;} 00094 reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*CaloIsoMap[u]).find( recoecalcandref ); 00095 TotalIso += mapi->val * CaloIsolWeight_[u]; 00096 } 00097 break; 00098 } 00099 } 00100 00101 //add the track isolation 00102 if(TrackIsolWeight_ != 0){ 00103 reco::ElectronIsolationMap::const_iterator mapi = (*TrackIsoMap).find( electronref ); 00104 TotalIso += mapi->val * TrackIsolWeight_; 00105 } 00106 TotalIsolMap.insert(electronref, TotalIso); 00107 00108 } 00109 00110 std::auto_ptr<reco::ElectronIsolationMap> isolMap(new reco::ElectronIsolationMap(TotalIsolMap)); 00111 iEvent.put(isolMap); 00112 00113 } 00114