CMS 3D CMS Logo

Public Member Functions | Private Attributes

EgammaHLTElectronCombinedIsolationProducer Class Reference

#include <RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronCombinedIsolationProducer.h>

Inheritance diagram for EgammaHLTElectronCombinedIsolationProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EgammaHLTElectronCombinedIsolationProducer (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~EgammaHLTElectronCombinedIsolationProducer ()

Private Attributes

std::vector< edm::InputTagCaloIsolTag_
std::vector< double > CaloIsolWeight_
edm::ParameterSet conf_
edm::InputTag electronProducer_
edm::InputTag recoEcalCandidateProducer_
edm::InputTag TrackIsolTag_
double TrackIsolWeight_

Detailed Description

Author:
Alessio Ghezzi

Definition at line 29 of file EgammaHLTElectronCombinedIsolationProducer.h.


Constructor & Destructor Documentation

EgammaHLTElectronCombinedIsolationProducer::EgammaHLTElectronCombinedIsolationProducer ( const edm::ParameterSet config) [explicit]

Definition at line 32 of file EgammaHLTElectronCombinedIsolationProducer.cc.

References CaloIsolTag_, CaloIsolWeight_, conf_, electronProducer_, Exception, edm::ParameterSet::getParameter(), recoEcalCandidateProducer_, TrackIsolTag_, and TrackIsolWeight_.

                                                                                                                    : conf_(config)
{

  electronProducer_         = conf_.getParameter<edm::InputTag>("electronProducer");
  recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");

  CaloIsolTag_ = conf_.getParameter< std::vector<edm::InputTag> > ("CaloIsolationMapTags");
  //need to be in the order EcalIso, HcalIso, EleTrackIso
  CaloIsolWeight_ = conf_.getParameter< std::vector<double> > ("CaloIsolationWeight");

  TrackIsolTag_ = conf_.getParameter<edm::InputTag>("TrackIsolationMapTag");
  TrackIsolWeight_ = conf_.getParameter<double>("TrackIsolationWeight");

  if ( CaloIsolTag_.size() != CaloIsolWeight_.size()){
    throw cms::Exception("BadConfig") << "vectors CaloIsolationMapTags and CaloIsolationWeight need to have size 3";
  }
  
  
  //  SCProducer_               = conf_.getParameter<edm::InputTag>("electronProducer");

  //register your products
  produces < reco::ElectronIsolationMap >();

}
EgammaHLTElectronCombinedIsolationProducer::~EgammaHLTElectronCombinedIsolationProducer ( )

Definition at line 56 of file EgammaHLTElectronCombinedIsolationProducer.cc.

{}

Member Function Documentation

void EgammaHLTElectronCombinedIsolationProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 59 of file EgammaHLTElectronCombinedIsolationProducer.cc.

References CaloIsolTag_, CaloIsolWeight_, electronProducer_, spr::find(), edm::Event::getByLabel(), edm::Event::put(), recoEcalCandidateProducer_, TrackIsolTag_, and TrackIsolWeight_.

{
  
  using namespace std;

  edm::Handle<reco::ElectronCollection> electronHandle;
  iEvent.getByLabel(electronProducer_,electronHandle);

    edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle;
  iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
  
  std::vector< edm::Handle<reco::RecoEcalCandidateIsolationMap> > CaloIsoMap;
  for( unsigned int u=0; u < CaloIsolTag_.size(); u++){
    edm::Handle<reco::RecoEcalCandidateIsolationMap> depMapTemp;
    if(CaloIsolWeight_[u] != 0){ iEvent.getByLabel (CaloIsolTag_[u],depMapTemp);}
    CaloIsoMap.push_back(depMapTemp);
  }

  edm::Handle<reco::ElectronIsolationMap> TrackIsoMap;
  if(TrackIsolWeight_ != 0){ iEvent.getByLabel (TrackIsolTag_,TrackIsoMap);}
  
  reco::ElectronIsolationMap TotalIsolMap;
  double TotalIso=0;
  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
    TotalIso=0; 
    reco::ElectronRef electronref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin()));
    const reco::SuperClusterRef theEleClus = electronref->superCluster();
 
   //look for corresponding recoecal candidates to search for in the ecal and Hcal iso map
    for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){
      reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand-recoecalcandHandle->begin());
      const reco::SuperClusterRef cluster = recoecalcandref->superCluster();
      if(&(*cluster) ==  &(*theEleClus)) {//recoecalcand and electron have the same SC
        for(unsigned int u=0;  u < CaloIsolTag_.size() ;u++){
          if(CaloIsolWeight_[u]==0){continue;}
          reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*CaloIsoMap[u]).find( recoecalcandref );
          TotalIso += mapi->val * CaloIsolWeight_[u];
        }
        break;
      }
    }
  
    //add the track isolation
    if(TrackIsolWeight_ != 0){
      reco::ElectronIsolationMap::const_iterator mapi = (*TrackIsoMap).find( electronref );
      TotalIso += mapi->val * TrackIsolWeight_;
    }
    TotalIsolMap.insert(electronref, TotalIso);
    
  }

  std::auto_ptr<reco::ElectronIsolationMap> isolMap(new reco::ElectronIsolationMap(TotalIsolMap));
  iEvent.put(isolMap);

}

Member Data Documentation